now hc styles can be referenced in window.resource
by the way, supported multiple themes at the same time, It may be related to #574
This commit is contained in:
1 parent
3be68c3010
commit
d997aee5f7
23 files changed
+161
-129
No files matched your search
@@ -11,9 +11,9 @@ namespace HandyControlDemo.Resources
|
|||||||
public override ResourceDictionary GetSkin(SkinType skinType) =>
|
public override ResourceDictionary GetSkin(SkinType skinType) =>
|
||||||
ResourceHelper.GetSkin(typeof(App).Assembly, "Resources/Themes", skinType);
|
ResourceHelper.GetSkin(typeof(App).Assembly, "Resources/Themes", skinType);
|
||||||
|
|
||||||
public override ResourceDictionary GetTheme() => new ResourceDictionary
|
public override ResourceDictionary GetTheme() => new Lazy<ResourceDictionary>(() => new ResourceDictionary
|
||||||
{
|
{
|
||||||
Source = new Uri("pack://application:,,,/HandyControlDemo;component/Resources/Themes/Theme.xaml")
|
Source = new Uri("pack://application:,,,/HandyControlDemo;component/Resources/Themes/Theme.xaml")
|
||||||
};
|
}).Value;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -455,7 +455,7 @@ namespace HandyControl.Controls
|
|||||||
var button = new Button
|
var button = new Button
|
||||||
{
|
{
|
||||||
Margin = new Thickness(6),
|
Margin = new Thickness(6),
|
||||||
Style = ResourceHelper.GetResource<Style>(ResourceToken.ButtonCustom),
|
Style = ResourceHelper.GetResourceInternal<Style>(ResourceToken.ButtonCustom),
|
||||||
Content = new Border
|
Content = new Border
|
||||||
{
|
{
|
||||||
Background = brush,
|
Background = brush,
|
||||||
|
|||||||
@@ -328,7 +328,7 @@ namespace HandyControl.Controls
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
PanelElement.SetFluidMoveBehavior(panel, ResourceHelper.GetResource<FluidMoveBehavior>(ResourceToken.BehaviorXY400));
|
PanelElement.SetFluidMoveBehavior(panel, ResourceHelper.GetResourceInternal<FluidMoveBehavior>(ResourceToken.BehaviorXY400));
|
||||||
}
|
}
|
||||||
|
|
||||||
private void Update()
|
private void Update()
|
||||||
@@ -372,8 +372,8 @@ namespace HandyControl.Controls
|
|||||||
{
|
{
|
||||||
Message = growlInfo.Message,
|
Message = growlInfo.Message,
|
||||||
Time = DateTime.Now,
|
Time = DateTime.Now,
|
||||||
Icon = ResourceHelper.GetResource<Geometry>(growlInfo.IconKey),
|
Icon = ResourceHelper.GetResourceInternal<Geometry>(growlInfo.IconKey),
|
||||||
IconBrush = ResourceHelper.GetResource<Brush>(growlInfo.IconBrushKey),
|
IconBrush = ResourceHelper.GetResourceInternal<Brush>(growlInfo.IconBrushKey),
|
||||||
_showCloseButton = growlInfo.ShowCloseButton,
|
_showCloseButton = growlInfo.ShowCloseButton,
|
||||||
ActionBeforeClose = growlInfo.ActionBeforeClose,
|
ActionBeforeClose = growlInfo.ActionBeforeClose,
|
||||||
_staysOpen = growlInfo.StaysOpen,
|
_staysOpen = growlInfo.StaysOpen,
|
||||||
@@ -407,8 +407,8 @@ namespace HandyControl.Controls
|
|||||||
{
|
{
|
||||||
Message = growlInfo.Message,
|
Message = growlInfo.Message,
|
||||||
Time = DateTime.Now,
|
Time = DateTime.Now,
|
||||||
Icon = ResourceHelper.GetResource<Geometry>(growlInfo.IconKey),
|
Icon = ResourceHelper.GetResourceInternal<Geometry>(growlInfo.IconKey),
|
||||||
IconBrush = ResourceHelper.GetResource<Brush>(growlInfo.IconBrushKey),
|
IconBrush = ResourceHelper.GetResourceInternal<Brush>(growlInfo.IconBrushKey),
|
||||||
_showCloseButton = growlInfo.ShowCloseButton,
|
_showCloseButton = growlInfo.ShowCloseButton,
|
||||||
ActionBeforeClose = growlInfo.ActionBeforeClose,
|
ActionBeforeClose = growlInfo.ActionBeforeClose,
|
||||||
_staysOpen = growlInfo.StaysOpen,
|
_staysOpen = growlInfo.StaysOpen,
|
||||||
|
|||||||
@@ -45,7 +45,7 @@ namespace HandyControl.Controls
|
|||||||
{
|
{
|
||||||
Stretch = Stretch.UniformToFill
|
Stretch = Stretch.UniformToFill
|
||||||
}
|
}
|
||||||
: ResourceHelper.GetResource<Brush>("SecondaryRegionBrush");
|
: ResourceHelper.GetResourceInternal<Brush>("SecondaryRegionBrush");
|
||||||
}
|
}
|
||||||
|
|
||||||
public ImageSource Source
|
public ImageSource Source
|
||||||
|
|||||||
@@ -385,7 +385,7 @@ namespace HandyControl.Controls
|
|||||||
{
|
{
|
||||||
return new RadioButton
|
return new RadioButton
|
||||||
{
|
{
|
||||||
Style = ResourceHelper.GetResource<Style>(ResourceToken.PaginationButtonStyle),
|
Style = ResourceHelper.GetResourceInternal<Style>(ResourceToken.PaginationButtonStyle),
|
||||||
Content = page.ToString()
|
Content = page.ToString()
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -55,7 +55,7 @@ namespace HandyControl.Controls
|
|||||||
}
|
}
|
||||||
else if (Application.Current != null)
|
else if (Application.Current != null)
|
||||||
{
|
{
|
||||||
ResourceHelper.GetResource<Storyboard>($"{TransitionMode.ToString()}Transition")?.Begin(_contentPresenter);
|
ResourceHelper.GetResourceInternal<Storyboard>($"{TransitionMode.ToString()}Transition")?.Begin(_contentPresenter);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
+6
-6
@@ -14,9 +14,9 @@ namespace HandyControl.Controls
|
|||||||
{
|
{
|
||||||
public override FrameworkElement CreateElement(PropertyItem propertyItem) => new System.Windows.Controls.ComboBox
|
public override FrameworkElement CreateElement(PropertyItem propertyItem) => new System.Windows.Controls.ComboBox
|
||||||
{
|
{
|
||||||
Style = ResourceHelper.GetResource<Style>("ComboBoxCapsule"),
|
Style = ResourceHelper.GetResourceInternal<Style>("ComboBoxCapsule"),
|
||||||
ItemsSource = Enum.GetValues(propertyItem.PropertyType),
|
ItemsSource = Enum.GetValues(propertyItem.PropertyType),
|
||||||
ItemTemplateSelector = ResourceHelper.GetResource<DataTemplateSelector>("HorizontalAlignmentPathTemplateSelector"),
|
ItemTemplateSelector = ResourceHelper.GetResourceInternal<DataTemplateSelector>("HorizontalAlignmentPathTemplateSelector"),
|
||||||
HorizontalAlignment = HorizontalAlignment.Left
|
HorizontalAlignment = HorizontalAlignment.Left
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -48,16 +48,16 @@ namespace HandyControl.Controls
|
|||||||
switch (horizontalAlignment)
|
switch (horizontalAlignment)
|
||||||
{
|
{
|
||||||
case HorizontalAlignment.Left:
|
case HorizontalAlignment.Left:
|
||||||
factory.SetValue(Path.DataProperty, ResourceHelper.GetResource<Geometry>("AlignLeftGeometry"));
|
factory.SetValue(Path.DataProperty, ResourceHelper.GetResourceInternal<Geometry>("AlignLeftGeometry"));
|
||||||
break;
|
break;
|
||||||
case HorizontalAlignment.Center:
|
case HorizontalAlignment.Center:
|
||||||
factory.SetValue(Path.DataProperty, ResourceHelper.GetResource<Geometry>("AlignHCenterGeometry"));
|
factory.SetValue(Path.DataProperty, ResourceHelper.GetResourceInternal<Geometry>("AlignHCenterGeometry"));
|
||||||
break;
|
break;
|
||||||
case HorizontalAlignment.Right:
|
case HorizontalAlignment.Right:
|
||||||
factory.SetValue(Path.DataProperty, ResourceHelper.GetResource<Geometry>("AlignRightGeometry"));
|
factory.SetValue(Path.DataProperty, ResourceHelper.GetResourceInternal<Geometry>("AlignRightGeometry"));
|
||||||
break;
|
break;
|
||||||
case HorizontalAlignment.Stretch:
|
case HorizontalAlignment.Stretch:
|
||||||
factory.SetValue(Path.DataProperty, ResourceHelper.GetResource<Geometry>("AlignHStretchGeometry"));
|
factory.SetValue(Path.DataProperty, ResourceHelper.GetResourceInternal<Geometry>("AlignHStretchGeometry"));
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
+1
-1
@@ -15,6 +15,6 @@ namespace HandyControl.Controls
|
|||||||
|
|
||||||
public override BindingMode GetBindingMode(PropertyItem propertyItem) => BindingMode.OneWay;
|
public override BindingMode GetBindingMode(PropertyItem propertyItem) => BindingMode.OneWay;
|
||||||
|
|
||||||
protected override IValueConverter GetConverter(PropertyItem propertyItem) => ResourceHelper.GetResource<IValueConverter>("Object2StringConverter");
|
protected override IValueConverter GetConverter(PropertyItem propertyItem) => ResourceHelper.GetResourceInternal<IValueConverter>("Object2StringConverter");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
+1
-1
@@ -8,7 +8,7 @@ namespace HandyControl.Controls
|
|||||||
{
|
{
|
||||||
public override FrameworkElement CreateElement(PropertyItem propertyItem) => new ToggleButton
|
public override FrameworkElement CreateElement(PropertyItem propertyItem) => new ToggleButton
|
||||||
{
|
{
|
||||||
Style = ResourceHelper.GetResource<Style>("ToggleButtonSwitch"),
|
Style = ResourceHelper.GetResourceInternal<Style>("ToggleButtonSwitch"),
|
||||||
HorizontalAlignment = HorizontalAlignment.Left,
|
HorizontalAlignment = HorizontalAlignment.Left,
|
||||||
IsEnabled = !propertyItem.IsReadOnly
|
IsEnabled = !propertyItem.IsReadOnly
|
||||||
};
|
};
|
||||||
|
|||||||
+6
-6
@@ -14,9 +14,9 @@ namespace HandyControl.Controls
|
|||||||
{
|
{
|
||||||
public override FrameworkElement CreateElement(PropertyItem propertyItem) => new System.Windows.Controls.ComboBox
|
public override FrameworkElement CreateElement(PropertyItem propertyItem) => new System.Windows.Controls.ComboBox
|
||||||
{
|
{
|
||||||
Style = ResourceHelper.GetResource<Style>("ComboBoxCapsule"),
|
Style = ResourceHelper.GetResourceInternal<Style>("ComboBoxCapsule"),
|
||||||
ItemsSource = Enum.GetValues(propertyItem.PropertyType),
|
ItemsSource = Enum.GetValues(propertyItem.PropertyType),
|
||||||
ItemTemplateSelector = ResourceHelper.GetResource<DataTemplateSelector>("VerticalAlignmentPathTemplateSelector"),
|
ItemTemplateSelector = ResourceHelper.GetResourceInternal<DataTemplateSelector>("VerticalAlignmentPathTemplateSelector"),
|
||||||
HorizontalAlignment = HorizontalAlignment.Left
|
HorizontalAlignment = HorizontalAlignment.Left
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -48,16 +48,16 @@ namespace HandyControl.Controls
|
|||||||
switch (verticalAlignment)
|
switch (verticalAlignment)
|
||||||
{
|
{
|
||||||
case VerticalAlignment.Top:
|
case VerticalAlignment.Top:
|
||||||
factory.SetValue(Path.DataProperty, ResourceHelper.GetResource<Geometry>("AlignTopGeometry"));
|
factory.SetValue(Path.DataProperty, ResourceHelper.GetResourceInternal<Geometry>("AlignTopGeometry"));
|
||||||
break;
|
break;
|
||||||
case VerticalAlignment.Center:
|
case VerticalAlignment.Center:
|
||||||
factory.SetValue(Path.DataProperty, ResourceHelper.GetResource<Geometry>("AlignVCenterGeometry"));
|
factory.SetValue(Path.DataProperty, ResourceHelper.GetResourceInternal<Geometry>("AlignVCenterGeometry"));
|
||||||
break;
|
break;
|
||||||
case VerticalAlignment.Bottom:
|
case VerticalAlignment.Bottom:
|
||||||
factory.SetValue(Path.DataProperty, ResourceHelper.GetResource<Geometry>("AlignBottomGeometry"));
|
factory.SetValue(Path.DataProperty, ResourceHelper.GetResourceInternal<Geometry>("AlignBottomGeometry"));
|
||||||
break;
|
break;
|
||||||
case VerticalAlignment.Stretch:
|
case VerticalAlignment.Stretch:
|
||||||
factory.SetValue(Path.DataProperty, ResourceHelper.GetResource<Geometry>("AlignVStretchGeometry"));
|
factory.SetValue(Path.DataProperty, ResourceHelper.GetResourceInternal<Geometry>("AlignVStretchGeometry"));
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -188,7 +188,7 @@ namespace HandyControl.Controls
|
|||||||
|
|
||||||
public ScreenshotWindow(Screenshot screenshot)
|
public ScreenshotWindow(Screenshot screenshot)
|
||||||
{
|
{
|
||||||
Style = ResourceHelper.GetResource<Style>(ResourceToken.Window4ScreenshotStyle);
|
Style = ResourceHelper.GetResourceInternal<Style>(ResourceToken.Window4ScreenshotStyle);
|
||||||
_screenshot = screenshot;
|
_screenshot = screenshot;
|
||||||
DataContext = this;
|
DataContext = this;
|
||||||
|
|
||||||
|
|||||||
@@ -208,7 +208,7 @@ namespace HandyControl.Controls
|
|||||||
menu.SetBinding(VisibilityProperty, new Binding(ShowContextMenuProperty.Name)
|
menu.SetBinding(VisibilityProperty, new Binding(ShowContextMenuProperty.Name)
|
||||||
{
|
{
|
||||||
Source = this,
|
Source = this,
|
||||||
Converter = ResourceHelper.GetResource<IValueConverter>(ResourceToken.Boolean2VisibilityConverter)
|
Converter = ResourceHelper.GetResourceInternal<IValueConverter>(ResourceToken.Boolean2VisibilityConverter)
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -29,7 +29,7 @@ namespace HandyControl.Controls
|
|||||||
if (versionInfo < SystemVersionInfo.Windows10 ||
|
if (versionInfo < SystemVersionInfo.Windows10 ||
|
||||||
versionInfo >= SystemVersionInfo.Windows10_1903)
|
versionInfo >= SystemVersionInfo.Windows10_1903)
|
||||||
{
|
{
|
||||||
var colorValue = ResourceHelper.GetResource<uint>(ResourceToken.BlurGradientValue);
|
var colorValue = ResourceHelper.GetResourceInternal<uint>(ResourceToken.BlurGradientValue);
|
||||||
var color = ColorHelper.ToColor(colorValue);
|
var color = ColorHelper.ToColor(colorValue);
|
||||||
color = Color.FromRgb(color.R, color.G, color.B);
|
color = Color.FromRgb(color.R, color.G, color.B);
|
||||||
window.Background = new SolidColorBrush(color);
|
window.Background = new SolidColorBrush(color);
|
||||||
@@ -44,7 +44,7 @@ namespace HandyControl.Controls
|
|||||||
: InteropValues.ACCENTSTATE.ACCENT_ENABLE_ACRYLICBLURBEHIND;
|
: InteropValues.ACCENTSTATE.ACCENT_ENABLE_ACRYLICBLURBEHIND;
|
||||||
|
|
||||||
accentPolicy.AccentFlags = 2;
|
accentPolicy.AccentFlags = 2;
|
||||||
accentPolicy.GradientColor = ResourceHelper.GetResource<uint>(ResourceToken.BlurGradientValue);
|
accentPolicy.GradientColor = ResourceHelper.GetResourceInternal<uint>(ResourceToken.BlurGradientValue);
|
||||||
|
|
||||||
var accentPtr = Marshal.AllocHGlobal(accentPolicySize);
|
var accentPtr = Marshal.AllocHGlobal(accentPolicySize);
|
||||||
Marshal.StructureToPtr(accentPolicy, accentPtr, false);
|
Marshal.StructureToPtr(accentPolicy, accentPtr, false);
|
||||||
|
|||||||
@@ -248,8 +248,8 @@ namespace HandyControl.Controls
|
|||||||
messageBox = CreateMessageBox(null, messageBoxText, caption, MessageBoxButton.OK, MessageBoxImage.None, MessageBoxResult.OK);
|
messageBox = CreateMessageBox(null, messageBoxText, caption, MessageBoxButton.OK, MessageBoxImage.None, MessageBoxResult.OK);
|
||||||
SetButtonStatus(messageBox, MessageBoxButton.OK, MessageBoxResult.OK);
|
SetButtonStatus(messageBox, MessageBoxButton.OK, MessageBoxResult.OK);
|
||||||
messageBox.ShowImage = true;
|
messageBox.ShowImage = true;
|
||||||
messageBox.Image = ResourceHelper.GetResource<Geometry>(ResourceToken.SuccessGeometry);
|
messageBox.Image = ResourceHelper.GetResourceInternal<Geometry>(ResourceToken.SuccessGeometry);
|
||||||
messageBox.ImageBrush = ResourceHelper.GetResource<Brush>(ResourceToken.SuccessBrush);
|
messageBox.ImageBrush = ResourceHelper.GetResourceInternal<Brush>(ResourceToken.SuccessBrush);
|
||||||
SystemSounds.Asterisk.Play();
|
SystemSounds.Asterisk.Play();
|
||||||
messageBox.ShowDialog();
|
messageBox.ShowDialog();
|
||||||
}));
|
}));
|
||||||
@@ -330,8 +330,8 @@ namespace HandyControl.Controls
|
|||||||
messageBox = CreateMessageBox(null, messageBoxText, caption, MessageBoxButton.OK, MessageBoxImage.None, MessageBoxResult.OK);
|
messageBox = CreateMessageBox(null, messageBoxText, caption, MessageBoxButton.OK, MessageBoxImage.None, MessageBoxResult.OK);
|
||||||
SetButtonStatus(messageBox, MessageBoxButton.OK, MessageBoxResult.OK);
|
SetButtonStatus(messageBox, MessageBoxButton.OK, MessageBoxResult.OK);
|
||||||
messageBox.ShowImage = true;
|
messageBox.ShowImage = true;
|
||||||
messageBox.Image = ResourceHelper.GetResource<Geometry>(ResourceToken.FatalGeometry);
|
messageBox.Image = ResourceHelper.GetResourceInternal<Geometry>(ResourceToken.FatalGeometry);
|
||||||
messageBox.ImageBrush = ResourceHelper.GetResource<Brush>(ResourceToken.PrimaryTextBrush);
|
messageBox.ImageBrush = ResourceHelper.GetResourceInternal<Brush>(ResourceToken.PrimaryTextBrush);
|
||||||
SystemSounds.Asterisk.Play();
|
SystemSounds.Asterisk.Play();
|
||||||
messageBox.ShowDialog();
|
messageBox.ShowDialog();
|
||||||
}));
|
}));
|
||||||
@@ -375,13 +375,13 @@ namespace HandyControl.Controls
|
|||||||
if (!string.IsNullOrEmpty(info.IconKey))
|
if (!string.IsNullOrEmpty(info.IconKey))
|
||||||
{
|
{
|
||||||
messageBox.ShowImage = true;
|
messageBox.ShowImage = true;
|
||||||
messageBox.Image = ResourceHelper.GetResource<Geometry>(info.IconKey);
|
messageBox.Image = ResourceHelper.GetResourceInternal<Geometry>(info.IconKey);
|
||||||
messageBox.ImageBrush = ResourceHelper.GetResource<Brush>(info.IconBrushKey);
|
messageBox.ImageBrush = ResourceHelper.GetResourceInternal<Brush>(info.IconBrushKey);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (info.StyleKey != null)
|
if (info.StyleKey != null)
|
||||||
{
|
{
|
||||||
messageBox.Style = ResourceHelper.GetResource<Style>(info.StyleKey);
|
messageBox.Style = ResourceHelper.GetResourceInternal<Style>(info.StyleKey);
|
||||||
}
|
}
|
||||||
SystemSounds.Asterisk.Play();
|
SystemSounds.Asterisk.Play();
|
||||||
messageBox.ShowDialog();
|
messageBox.ShowDialog();
|
||||||
@@ -477,7 +477,7 @@ namespace HandyControl.Controls
|
|||||||
IsDefault = true,
|
IsDefault = true,
|
||||||
Content = Lang.Confirm,
|
Content = Lang.Confirm,
|
||||||
Command = ControlCommands.Confirm,
|
Command = ControlCommands.Confirm,
|
||||||
Style = ResourceHelper.GetResource<Style>("MessageBoxButtonStyle")
|
Style = ResourceHelper.GetResourceInternal<Style>("MessageBoxButtonStyle")
|
||||||
};
|
};
|
||||||
|
|
||||||
break;
|
break;
|
||||||
@@ -499,15 +499,15 @@ namespace HandyControl.Controls
|
|||||||
|
|
||||||
if (defaultResult == MessageBoxResult.Cancel)
|
if (defaultResult == MessageBoxResult.Cancel)
|
||||||
{
|
{
|
||||||
messageBox._buttonOk.Style = ResourceHelper.GetResource<Style>("MessageBoxButtonStyle");
|
messageBox._buttonOk.Style = ResourceHelper.GetResourceInternal<Style>("MessageBoxButtonStyle");
|
||||||
messageBox._buttonCancel.Style = ResourceHelper.GetResource<Style>("MessageBoxPrimaryButtonStyle");
|
messageBox._buttonCancel.Style = ResourceHelper.GetResourceInternal<Style>("MessageBoxPrimaryButtonStyle");
|
||||||
messageBox._buttonCancel.IsDefault = true;
|
messageBox._buttonCancel.IsDefault = true;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
messageBox._buttonOk.Style = ResourceHelper.GetResource<Style>("MessageBoxPrimaryButtonStyle");
|
messageBox._buttonOk.Style = ResourceHelper.GetResourceInternal<Style>("MessageBoxPrimaryButtonStyle");
|
||||||
messageBox._buttonOk.IsDefault = true;
|
messageBox._buttonOk.IsDefault = true;
|
||||||
messageBox._buttonCancel.Style = ResourceHelper.GetResource<Style>("MessageBoxButtonStyle");
|
messageBox._buttonCancel.Style = ResourceHelper.GetResourceInternal<Style>("MessageBoxButtonStyle");
|
||||||
}
|
}
|
||||||
|
|
||||||
break;
|
break;
|
||||||
@@ -528,15 +528,15 @@ namespace HandyControl.Controls
|
|||||||
|
|
||||||
if (defaultResult == MessageBoxResult.No)
|
if (defaultResult == MessageBoxResult.No)
|
||||||
{
|
{
|
||||||
messageBox._buttonYes.Style = ResourceHelper.GetResource<Style>("MessageBoxButtonStyle");
|
messageBox._buttonYes.Style = ResourceHelper.GetResourceInternal<Style>("MessageBoxButtonStyle");
|
||||||
messageBox._buttonNo.Style = ResourceHelper.GetResource<Style>("MessageBoxPrimaryButtonStyle");
|
messageBox._buttonNo.Style = ResourceHelper.GetResourceInternal<Style>("MessageBoxPrimaryButtonStyle");
|
||||||
messageBox._buttonNo.IsDefault = true;
|
messageBox._buttonNo.IsDefault = true;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
messageBox._buttonYes.Style = ResourceHelper.GetResource<Style>("MessageBoxPrimaryButtonStyle");
|
messageBox._buttonYes.Style = ResourceHelper.GetResourceInternal<Style>("MessageBoxPrimaryButtonStyle");
|
||||||
messageBox._buttonYes.IsDefault = true;
|
messageBox._buttonYes.IsDefault = true;
|
||||||
messageBox._buttonNo.Style = ResourceHelper.GetResource<Style>("MessageBoxButtonStyle");
|
messageBox._buttonNo.Style = ResourceHelper.GetResourceInternal<Style>("MessageBoxButtonStyle");
|
||||||
}
|
}
|
||||||
|
|
||||||
break;
|
break;
|
||||||
@@ -565,24 +565,24 @@ namespace HandyControl.Controls
|
|||||||
|
|
||||||
if (defaultResult == MessageBoxResult.No)
|
if (defaultResult == MessageBoxResult.No)
|
||||||
{
|
{
|
||||||
messageBox._buttonYes.Style = ResourceHelper.GetResource<Style>("MessageBoxButtonStyle");
|
messageBox._buttonYes.Style = ResourceHelper.GetResourceInternal<Style>("MessageBoxButtonStyle");
|
||||||
messageBox._buttonNo.Style = ResourceHelper.GetResource<Style>("MessageBoxPrimaryButtonStyle");
|
messageBox._buttonNo.Style = ResourceHelper.GetResourceInternal<Style>("MessageBoxPrimaryButtonStyle");
|
||||||
messageBox._buttonNo.IsDefault = true;
|
messageBox._buttonNo.IsDefault = true;
|
||||||
messageBox._buttonCancel.Style = ResourceHelper.GetResource<Style>("MessageBoxButtonStyle");
|
messageBox._buttonCancel.Style = ResourceHelper.GetResourceInternal<Style>("MessageBoxButtonStyle");
|
||||||
}
|
}
|
||||||
else if (defaultResult == MessageBoxResult.Cancel)
|
else if (defaultResult == MessageBoxResult.Cancel)
|
||||||
{
|
{
|
||||||
messageBox._buttonYes.Style = ResourceHelper.GetResource<Style>("MessageBoxButtonStyle");
|
messageBox._buttonYes.Style = ResourceHelper.GetResourceInternal<Style>("MessageBoxButtonStyle");
|
||||||
messageBox._buttonNo.Style = ResourceHelper.GetResource<Style>("MessageBoxButtonStyle");
|
messageBox._buttonNo.Style = ResourceHelper.GetResourceInternal<Style>("MessageBoxButtonStyle");
|
||||||
messageBox._buttonCancel.Style = ResourceHelper.GetResource<Style>("MessageBoxPrimaryButtonStyle");
|
messageBox._buttonCancel.Style = ResourceHelper.GetResourceInternal<Style>("MessageBoxPrimaryButtonStyle");
|
||||||
messageBox._buttonCancel.IsDefault = true;
|
messageBox._buttonCancel.IsDefault = true;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
messageBox._buttonYes.Style = ResourceHelper.GetResource<Style>("MessageBoxPrimaryButtonStyle");
|
messageBox._buttonYes.Style = ResourceHelper.GetResourceInternal<Style>("MessageBoxPrimaryButtonStyle");
|
||||||
messageBox._buttonYes.IsDefault = true;
|
messageBox._buttonYes.IsDefault = true;
|
||||||
messageBox._buttonNo.Style = ResourceHelper.GetResource<Style>("MessageBoxButtonStyle");
|
messageBox._buttonNo.Style = ResourceHelper.GetResourceInternal<Style>("MessageBoxButtonStyle");
|
||||||
messageBox._buttonCancel.Style = ResourceHelper.GetResource<Style>("MessageBoxButtonStyle");
|
messageBox._buttonCancel.Style = ResourceHelper.GetResourceInternal<Style>("MessageBoxButtonStyle");
|
||||||
}
|
}
|
||||||
|
|
||||||
break;
|
break;
|
||||||
@@ -616,8 +616,8 @@ namespace HandyControl.Controls
|
|||||||
|
|
||||||
if (string.IsNullOrEmpty(iconKey)) return;
|
if (string.IsNullOrEmpty(iconKey)) return;
|
||||||
messageBox.ShowImage = true;
|
messageBox.ShowImage = true;
|
||||||
messageBox.Image = ResourceHelper.GetResource<Geometry>(iconKey);
|
messageBox.Image = ResourceHelper.GetResourceInternal<Geometry>(iconKey);
|
||||||
messageBox.ImageBrush = ResourceHelper.GetResource<Brush>(iconBrushKey);
|
messageBox.ImageBrush = ResourceHelper.GetResourceInternal<Brush>(iconBrushKey);
|
||||||
}
|
}
|
||||||
|
|
||||||
private static bool IsValidMessageBoxButton(MessageBoxButton value)
|
private static bool IsValidMessageBoxButton(MessageBoxButton value)
|
||||||
|
|||||||
@@ -187,7 +187,7 @@ namespace HandyControl.Controls
|
|||||||
WindowStyle = WindowStyle.None,
|
WindowStyle = WindowStyle.None,
|
||||||
ContentStr = message,
|
ContentStr = message,
|
||||||
WindowStartupLocation = WindowStartupLocation.CenterScreen,
|
WindowStartupLocation = WindowStartupLocation.CenterScreen,
|
||||||
Background = ResourceHelper.GetResource<Brush>(ResourceToken.PrimaryBrush)
|
Background = ResourceHelper.GetResourceInternal<Brush>(ResourceToken.PrimaryBrush)
|
||||||
};
|
};
|
||||||
window.Show();
|
window.Show();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -99,7 +99,7 @@ namespace HandyControl.Controls
|
|||||||
|
|
||||||
static Window()
|
static Window()
|
||||||
{
|
{
|
||||||
StyleProperty.OverrideMetadata(typeof(Window), new FrameworkPropertyMetadata(ResourceHelper.GetResource<Style>(ResourceToken.WindowWin10)));
|
StyleProperty.OverrideMetadata(typeof(Window), new FrameworkPropertyMetadata(ResourceHelper.GetResourceInternal<Style>(ResourceToken.WindowWin10)));
|
||||||
}
|
}
|
||||||
|
|
||||||
public Window()
|
public Window()
|
||||||
|
|||||||
@@ -8,7 +8,7 @@ namespace HandyControl.Properties.Langs
|
|||||||
{
|
{
|
||||||
public class LangProvider : INotifyPropertyChanged
|
public class LangProvider : INotifyPropertyChanged
|
||||||
{
|
{
|
||||||
internal static LangProvider Instance => ResourceHelper.GetResource<LangProvider>("Langs");
|
internal static LangProvider Instance => ResourceHelper.GetResourceInternal<LangProvider>("Langs");
|
||||||
|
|
||||||
private static string CultureInfoStr;
|
private static string CultureInfoStr;
|
||||||
|
|
||||||
|
|||||||
@@ -27,7 +27,7 @@ namespace HandyControl.Properties.Langs
|
|||||||
{
|
{
|
||||||
public class LangProvider : INotifyPropertyChanged
|
public class LangProvider : INotifyPropertyChanged
|
||||||
{
|
{
|
||||||
internal static LangProvider Instance => ResourceHelper.GetResource<LangProvider>("Langs");
|
internal static LangProvider Instance => ResourceHelper.GetResourceInternal<LangProvider>("Langs");
|
||||||
|
|
||||||
private static string CultureInfoStr;
|
private static string CultureInfoStr;
|
||||||
|
|
||||||
@@ -81,4 +81,4 @@ namespace HandyControl.Properties.Langs
|
|||||||
|
|
||||||
<#}#>
|
<#}#>
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1,4 +1,5 @@
|
|||||||
using System;
|
using System;
|
||||||
|
using System.Linq;
|
||||||
using System.Windows;
|
using System.Windows;
|
||||||
using HandyControl.Data;
|
using HandyControl.Data;
|
||||||
using HandyControl.Tools;
|
using HandyControl.Tools;
|
||||||
@@ -11,11 +12,11 @@ namespace HandyControl.Themes
|
|||||||
{
|
{
|
||||||
if (DesignerHelper.IsInDesignMode)
|
if (DesignerHelper.IsInDesignMode)
|
||||||
{
|
{
|
||||||
MergedDictionaries.Add(new ResourceDictionary
|
MergedDictionaries.Add(new()
|
||||||
{
|
{
|
||||||
Source = new Uri("pack://application:,,,/HandyControl;component/Themes/SkinDefault.xaml")
|
Source = new Uri("pack://application:,,,/HandyControl;component/Themes/SkinDefault.xaml")
|
||||||
});
|
});
|
||||||
MergedDictionaries.Add(new ResourceDictionary
|
MergedDictionaries.Add(new()
|
||||||
{
|
{
|
||||||
Source = new Uri("pack://application:,,,/HandyControl;component/Themes/Theme.xaml")
|
Source = new Uri("pack://application:,,,/HandyControl;component/Themes/Theme.xaml")
|
||||||
});
|
});
|
||||||
@@ -48,14 +49,51 @@ namespace HandyControl.Themes
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static readonly DependencyProperty SkinProperty = DependencyProperty.RegisterAttached(
|
||||||
|
"Skin", typeof(SkinType), typeof(Theme), new PropertyMetadata(default(SkinType), OnSkinChanged));
|
||||||
|
|
||||||
|
private static void OnSkinChanged(DependencyObject d, DependencyPropertyChangedEventArgs e)
|
||||||
|
{
|
||||||
|
if (d is FrameworkElement element)
|
||||||
|
{
|
||||||
|
var skin = (SkinType) e.NewValue;
|
||||||
|
|
||||||
|
if (element.Resources is Theme resource)
|
||||||
|
{
|
||||||
|
resource.Skin = skin;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
var themes = element.Resources.MergedDictionaries.OfType<Theme>();
|
||||||
|
if (!themes.Any())
|
||||||
|
{
|
||||||
|
element.Resources.MergedDictionaries.Add(new Theme
|
||||||
|
{
|
||||||
|
Skin = skin
|
||||||
|
});
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
foreach (var subResource in element.Resources.MergedDictionaries.OfType<Theme>())
|
||||||
|
{
|
||||||
|
subResource.Skin = skin;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void SetSkin(DependencyObject element, SkinType value)
|
||||||
|
=> element.SetValue(SkinProperty, value);
|
||||||
|
|
||||||
|
public static SkinType GetSkin(DependencyObject element)
|
||||||
|
=> (SkinType) element.GetValue(SkinProperty);
|
||||||
|
|
||||||
public string Name { get; set; }
|
public string Name { get; set; }
|
||||||
|
|
||||||
public virtual ResourceDictionary GetSkin(SkinType skinType) => ResourceHelper.GetSkin(skinType);
|
public virtual ResourceDictionary GetSkin(SkinType skinType) => ResourceHelper.GetSkin(skinType);
|
||||||
|
|
||||||
public virtual ResourceDictionary GetTheme() => new ResourceDictionary
|
public virtual ResourceDictionary GetTheme() => ResourceHelper.GetTheme();
|
||||||
{
|
|
||||||
Source = new Uri("pack://application:,,,/HandyControl;component/Themes/Theme.xaml")
|
|
||||||
};
|
|
||||||
|
|
||||||
private void UpdateResource()
|
private void UpdateResource()
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -1,5 +1,4 @@
|
|||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using System.Reflection;
|
using System.Reflection;
|
||||||
using System.Windows;
|
using System.Windows;
|
||||||
@@ -13,29 +12,6 @@ namespace HandyControl.Tools
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
public class ResourceHelper
|
public class ResourceHelper
|
||||||
{
|
{
|
||||||
/// <summary>
|
|
||||||
/// 获取字符串
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="key"></param>
|
|
||||||
/// <returns></returns>
|
|
||||||
public static string GetString(string key) => Application.Current.TryFindResource(key) as string;
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// 获取字符串
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="separator"></param>
|
|
||||||
/// <param name="keyArr"></param>
|
|
||||||
/// <returns></returns>
|
|
||||||
public static string GetString(string separator = ";", params string[] keyArr) =>
|
|
||||||
string.Join(separator, keyArr.Select(key => Application.Current.TryFindResource(key) as string).ToList());
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// 获取字符串
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="keyArr"></param>
|
|
||||||
/// <returns></returns>
|
|
||||||
public static List<string> GetStringList(params string[] keyArr) => keyArr.Select(key => Application.Current.TryFindResource(key) as string).ToList();
|
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 获取资源
|
/// 获取资源
|
||||||
/// </summary>
|
/// </summary>
|
||||||
@@ -51,23 +27,29 @@ namespace HandyControl.Tools
|
|||||||
return default;
|
return default;
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
internal static T GetResourceInternal<T>(string key)
|
||||||
/// 获取HandyControl皮肤
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="skin"></param>
|
|
||||||
/// <returns></returns>
|
|
||||||
public static ResourceDictionary GetSkin(SkinType skin) => new ResourceDictionary
|
|
||||||
{
|
{
|
||||||
Source = new Uri($"pack://application:,,,/HandyControl;component/Themes/Skin{skin.ToString()}.xaml")
|
if (GetTheme()[key] is T resource)
|
||||||
};
|
{
|
||||||
|
return resource;
|
||||||
|
}
|
||||||
|
|
||||||
|
return default;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static Theme GetTheme(string name, ResourceDictionary resourceDictionary)
|
||||||
|
{
|
||||||
|
if (string.IsNullOrEmpty(name) || resourceDictionary == null)
|
||||||
|
{
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
return resourceDictionary.MergedDictionaries.OfType<Theme>().FirstOrDefault(item => Equals(item.Name, name));
|
||||||
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 获取皮肤
|
/// 获取皮肤
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="assembly"></param>
|
|
||||||
/// <param name="themePath"></param>
|
|
||||||
/// <param name="skin"></param>
|
|
||||||
/// <returns></returns>
|
|
||||||
public static ResourceDictionary GetSkin(Assembly assembly, string themePath, SkinType skin)
|
public static ResourceDictionary GetSkin(Assembly assembly, string themePath, SkinType skin)
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
@@ -87,11 +69,23 @@ namespace HandyControl.Tools
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public static Theme GetTheme(string name, ResourceDictionary resourceDictionary)
|
/// <summary>
|
||||||
|
/// get HandyControl skin
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="skin"></param>
|
||||||
|
/// <returns></returns>
|
||||||
|
public static ResourceDictionary GetSkin(SkinType skin) => new()
|
||||||
{
|
{
|
||||||
if (string.IsNullOrEmpty(name) || resourceDictionary == null) return null;
|
Source = new Uri($"pack://application:,,,/HandyControl;component/Themes/Skin{skin}.xaml")
|
||||||
return resourceDictionary.MergedDictionaries.OfType<Theme>()
|
};
|
||||||
.FirstOrDefault(item => Equals(item.Name, name));
|
|
||||||
}
|
/// <summary>
|
||||||
|
/// get HandyControl theme
|
||||||
|
/// </summary>
|
||||||
|
/// <returns></returns>
|
||||||
|
public static ResourceDictionary GetTheme() => new Lazy<ResourceDictionary>(() => new ResourceDictionary
|
||||||
|
{
|
||||||
|
Source = new Uri("pack://application:,,,/HandyControl;component/Themes/Theme.xaml")
|
||||||
|
}).Value;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
+15
-15
@@ -20,19 +20,19 @@ namespace HandyControl.Tools
|
|||||||
{
|
{
|
||||||
if (count == 1)
|
if (count == 1)
|
||||||
{
|
{
|
||||||
return ResourceHelper.GetResource<Style>(ResourceToken.RadioGroupItemSingle);
|
return ResourceHelper.GetResourceInternal<Style>(ResourceToken.RadioGroupItemSingle);
|
||||||
}
|
}
|
||||||
|
|
||||||
var index = buttonGroup.Items.IndexOf(buttonBase);
|
var index = buttonGroup.Items.IndexOf(buttonBase);
|
||||||
return buttonGroup.Orientation == Orientation.Horizontal
|
return buttonGroup.Orientation == Orientation.Horizontal
|
||||||
? index == 0
|
? index == 0
|
||||||
? ResourceHelper.GetResource<Style>(ResourceToken.RadioGroupItemHorizontalFirst)
|
? ResourceHelper.GetResourceInternal<Style>(ResourceToken.RadioGroupItemHorizontalFirst)
|
||||||
: ResourceHelper.GetResource<Style>(index == count - 1
|
: ResourceHelper.GetResourceInternal<Style>(index == count - 1
|
||||||
? ResourceToken.RadioGroupItemHorizontalLast
|
? ResourceToken.RadioGroupItemHorizontalLast
|
||||||
: ResourceToken.RadioGroupItemDefault)
|
: ResourceToken.RadioGroupItemDefault)
|
||||||
: index == 0
|
: index == 0
|
||||||
? ResourceHelper.GetResource<Style>(ResourceToken.RadioGroupItemVerticalFirst)
|
? ResourceHelper.GetResourceInternal<Style>(ResourceToken.RadioGroupItemVerticalFirst)
|
||||||
: ResourceHelper.GetResource<Style>(index == count - 1
|
: ResourceHelper.GetResourceInternal<Style>(index == count - 1
|
||||||
? ResourceToken.RadioGroupItemVerticalLast
|
? ResourceToken.RadioGroupItemVerticalLast
|
||||||
: ResourceToken.RadioGroupItemDefault);
|
: ResourceToken.RadioGroupItemDefault);
|
||||||
}
|
}
|
||||||
@@ -41,19 +41,19 @@ namespace HandyControl.Tools
|
|||||||
{
|
{
|
||||||
if (count == 1)
|
if (count == 1)
|
||||||
{
|
{
|
||||||
return ResourceHelper.GetResource<Style>(ResourceToken.ButtonGroupItemSingle);
|
return ResourceHelper.GetResourceInternal<Style>(ResourceToken.ButtonGroupItemSingle);
|
||||||
}
|
}
|
||||||
|
|
||||||
var index = buttonGroup.Items.IndexOf(buttonBase);
|
var index = buttonGroup.Items.IndexOf(buttonBase);
|
||||||
return buttonGroup.Orientation == Orientation.Horizontal
|
return buttonGroup.Orientation == Orientation.Horizontal
|
||||||
? index == 0
|
? index == 0
|
||||||
? ResourceHelper.GetResource<Style>(ResourceToken.ButtonGroupItemHorizontalFirst)
|
? ResourceHelper.GetResourceInternal<Style>(ResourceToken.ButtonGroupItemHorizontalFirst)
|
||||||
: ResourceHelper.GetResource<Style>(index == count - 1
|
: ResourceHelper.GetResourceInternal<Style>(index == count - 1
|
||||||
? ResourceToken.ButtonGroupItemHorizontalLast
|
? ResourceToken.ButtonGroupItemHorizontalLast
|
||||||
: ResourceToken.ButtonGroupItemDefault)
|
: ResourceToken.ButtonGroupItemDefault)
|
||||||
: index == 0
|
: index == 0
|
||||||
? ResourceHelper.GetResource<Style>(ResourceToken.ButtonGroupItemVerticalFirst)
|
? ResourceHelper.GetResourceInternal<Style>(ResourceToken.ButtonGroupItemVerticalFirst)
|
||||||
: ResourceHelper.GetResource<Style>(index == count - 1
|
: ResourceHelper.GetResourceInternal<Style>(index == count - 1
|
||||||
? ResourceToken.ButtonGroupItemVerticalLast
|
? ResourceToken.ButtonGroupItemVerticalLast
|
||||||
: ResourceToken.ButtonGroupItemDefault);
|
: ResourceToken.ButtonGroupItemDefault);
|
||||||
}
|
}
|
||||||
@@ -62,19 +62,19 @@ namespace HandyControl.Tools
|
|||||||
{
|
{
|
||||||
if (count == 1)
|
if (count == 1)
|
||||||
{
|
{
|
||||||
return ResourceHelper.GetResource<Style>(ResourceToken.ToggleButtonGroupItemSingle);
|
return ResourceHelper.GetResourceInternal<Style>(ResourceToken.ToggleButtonGroupItemSingle);
|
||||||
}
|
}
|
||||||
|
|
||||||
var index = buttonGroup.Items.IndexOf(buttonBase);
|
var index = buttonGroup.Items.IndexOf(buttonBase);
|
||||||
return buttonGroup.Orientation == Orientation.Horizontal
|
return buttonGroup.Orientation == Orientation.Horizontal
|
||||||
? index == 0
|
? index == 0
|
||||||
? ResourceHelper.GetResource<Style>(ResourceToken.ToggleButtonGroupItemHorizontalFirst)
|
? ResourceHelper.GetResourceInternal<Style>(ResourceToken.ToggleButtonGroupItemHorizontalFirst)
|
||||||
: ResourceHelper.GetResource<Style>(index == count - 1
|
: ResourceHelper.GetResourceInternal<Style>(index == count - 1
|
||||||
? ResourceToken.ToggleButtonGroupItemHorizontalLast
|
? ResourceToken.ToggleButtonGroupItemHorizontalLast
|
||||||
: ResourceToken.ToggleButtonGroupItemDefault)
|
: ResourceToken.ToggleButtonGroupItemDefault)
|
||||||
: index == 0
|
: index == 0
|
||||||
? ResourceHelper.GetResource<Style>(ResourceToken.ToggleButtonGroupItemVerticalFirst)
|
? ResourceHelper.GetResourceInternal<Style>(ResourceToken.ToggleButtonGroupItemVerticalFirst)
|
||||||
: ResourceHelper.GetResource<Style>(index == count - 1
|
: ResourceHelper.GetResourceInternal<Style>(index == count - 1
|
||||||
? ResourceToken.ToggleButtonGroupItemVerticalLast
|
? ResourceToken.ToggleButtonGroupItemVerticalLast
|
||||||
: ResourceToken.ToggleButtonGroupItemDefault);
|
: ResourceToken.ToggleButtonGroupItemDefault);
|
||||||
}
|
}
|
||||||
|
|||||||
+3
-3
@@ -13,13 +13,13 @@ namespace HandyControl.Tools
|
|||||||
var count = comboBox.Items.Count;
|
var count = comboBox.Items.Count;
|
||||||
if (count == 1)
|
if (count == 1)
|
||||||
{
|
{
|
||||||
return ResourceHelper.GetResource<Style>(ResourceToken.ComboBoxItemCapsuleSingle);
|
return ResourceHelper.GetResourceInternal<Style>(ResourceToken.ComboBoxItemCapsuleSingle);
|
||||||
}
|
}
|
||||||
|
|
||||||
var index = comboBox.ItemContainerGenerator.IndexFromContainer(comboBoxItem);
|
var index = comboBox.ItemContainerGenerator.IndexFromContainer(comboBoxItem);
|
||||||
return index == 0
|
return index == 0
|
||||||
? ResourceHelper.GetResource<Style>(ResourceToken.ComboBoxItemCapsuleHorizontalFirst)
|
? ResourceHelper.GetResourceInternal<Style>(ResourceToken.ComboBoxItemCapsuleHorizontalFirst)
|
||||||
: ResourceHelper.GetResource<Style>(index == count - 1
|
: ResourceHelper.GetResourceInternal<Style>(index == count - 1
|
||||||
? ResourceToken.ComboBoxItemCapsuleHorizontalLast
|
? ResourceToken.ComboBoxItemCapsuleHorizontalLast
|
||||||
: ResourceToken.ComboBoxItemCapsuleDefault);
|
: ResourceToken.ComboBoxItemCapsuleDefault);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -13,16 +13,16 @@ namespace HandyControl.Tools
|
|||||||
var count = tabControl.Items.Count;
|
var count = tabControl.Items.Count;
|
||||||
if (count == 1)
|
if (count == 1)
|
||||||
{
|
{
|
||||||
return ResourceHelper.GetResource<Style>(ResourceToken.TabItemCapsuleSingle);
|
return ResourceHelper.GetResourceInternal<Style>(ResourceToken.TabItemCapsuleSingle);
|
||||||
}
|
}
|
||||||
|
|
||||||
var index = tabControl.ItemContainerGenerator.IndexFromContainer(tabItem);
|
var index = tabControl.ItemContainerGenerator.IndexFromContainer(tabItem);
|
||||||
return index == 0
|
return index == 0
|
||||||
? ResourceHelper.GetResource<Style>(
|
? ResourceHelper.GetResourceInternal<Style>(
|
||||||
tabControl.TabStripPlacement == Dock.Top || tabControl.TabStripPlacement == Dock.Bottom
|
tabControl.TabStripPlacement == Dock.Top || tabControl.TabStripPlacement == Dock.Bottom
|
||||||
? ResourceToken.TabItemCapsuleHorizontalFirst
|
? ResourceToken.TabItemCapsuleHorizontalFirst
|
||||||
: ResourceToken.TabItemCapsuleVerticalFirst)
|
: ResourceToken.TabItemCapsuleVerticalFirst)
|
||||||
: ResourceHelper.GetResource<Style>(index == count - 1
|
: ResourceHelper.GetResourceInternal<Style>(index == count - 1
|
||||||
? tabControl.TabStripPlacement == Dock.Top || tabControl.TabStripPlacement == Dock.Bottom
|
? tabControl.TabStripPlacement == Dock.Top || tabControl.TabStripPlacement == Dock.Bottom
|
||||||
? ResourceToken.TabItemCapsuleHorizontalLast
|
? ResourceToken.TabItemCapsuleHorizontalLast
|
||||||
: ResourceToken.TabItemCapsuleVerticalLast
|
: ResourceToken.TabItemCapsuleVerticalLast
|
||||||
|
|||||||
Reference in new issue
Block a user