添加自定义菜单图标
This commit is contained in:
@@ -15,25 +15,45 @@
|
||||
MouseDown="DragMove"
|
||||
>
|
||||
|
||||
<Window.Resources>
|
||||
<Style x:Key="LeftTB" TargetType="TextBlock" BasedOn="{StaticResource TextBlockBaseStyle}">
|
||||
<Setter Property="Width" Value="80"/>
|
||||
<Setter Property="HorizontalAlignment" Value="Left"/>
|
||||
<Setter Property="VerticalAlignment" Value="Center"/>
|
||||
<Setter Property="FontSize" Value="11"/>
|
||||
</Style>
|
||||
</Window.Resources>
|
||||
|
||||
|
||||
<Border MouseDown="DragMove">
|
||||
<Grid MouseDown="DragMove">
|
||||
|
||||
<hc:TabControl x:Name="MyTabControl" IsAnimationEnabled="True" SelectionChanged="TabControl_SelectionChanged" ShowContextMenu="True" IsTabFillEnabled="True" Margin="20,30,20,20" Height="350" VerticalAlignment="Top">
|
||||
<hc:TabItem Tag="System" Header="系统" hc:IconElement.Height="16" hc:IconElement.Width="16" hc:IconElement.Geometry="{StaticResource CalendarGeometry}" >
|
||||
<hc:TabItem Tag="System" IsSelected="True" Header="系统图标" hc:IconElement.Height="16" hc:IconElement.Width="16" hc:IconElement.Geometry="{StaticResource CalendarGeometry}" >
|
||||
<hc:SimplePanel Background="AliceBlue">
|
||||
<uc:IconPannel IconfontList="{Binding iconListSystem}" IconInfo="{Binding iconInfoSystem}"/>
|
||||
<!--<hc:UniformSpacingPanel Spacing="10" Margin="0,10,0,-10">
|
||||
<TextBlock Text="SVG 图标地址:" Style="{StaticResource LeftTB}"/>
|
||||
<TextBox x:Name="IconUrl1" Text="{Binding Name, Mode=OneWay}" Width="240" FontSize="11"/>
|
||||
</hc:UniformSpacingPanel>
|
||||
<hc:UniformSpacingPanel Spacing="10" Margin="0,40,0,-40">
|
||||
<TextBlock Text="JSON 配置地址:" Style="{StaticResource LeftTB}"/>
|
||||
<TextBox x:Name="JsonUrl2" Text="{Binding Name, Mode=OneWay}" Width="240" FontSize="11"/>
|
||||
</hc:UniformSpacingPanel>-->
|
||||
<uc:IconPannel x:Name="SystemIcon"/>
|
||||
</hc:SimplePanel>
|
||||
</hc:TabItem>
|
||||
<hc:TabItem Tag="Custom" IsSelected="True" Header="自定义" hc:IconElement.Height="16" hc:IconElement.Width="16" hc:IconElement.Geometry="{StaticResource CalendarGeometry}">
|
||||
<hc:TabItem Tag="Custom" Header="自定义图标" hc:IconElement.Height="16" hc:IconElement.Width="16" hc:IconElement.Geometry="{StaticResource CalendarGeometry}">
|
||||
<hc:SimplePanel Background="AliceBlue">
|
||||
<uc:IconPannel IconfontList="{Binding iconListCustom}" IconInfo="{Binding iconInfoCustom}"/>
|
||||
<hc:LoadingCircle/>
|
||||
<uc:IconPannel x:Name="CustomIcon"/>
|
||||
</hc:SimplePanel>
|
||||
</hc:TabItem>
|
||||
</hc:TabControl>
|
||||
|
||||
|
||||
<Button Content="取消" Click="Close_Click" Margin="406,397.5,148,22.5"/>
|
||||
<Button Content="确定" Click="Confirm_Click" Background="#5BC0DE" Foreground="White" Margin="500.5,397.5,53.5,22.5" RenderTransformOrigin="0.696,0.45"/>
|
||||
<Button Content="取消" Click="Close_Click" Margin="391,397.5,163,22.5"/>
|
||||
<Button Content="自定义设置" Click="CustomButton_Click" IsEnabled="False" Name="CustomButton" Background="#5BC0DE" Foreground="White" RenderTransformOrigin="-0.868,0.583" Margin="447,397.5,71,22.5"/>
|
||||
<Button Content="确定" Click="Confirm_Click" Background="#5BC0DE" Foreground="White" Margin="534,397.5,20,22.5" RenderTransformOrigin="0.696,0.45"/>
|
||||
</Grid>
|
||||
</Border>
|
||||
|
||||
|
||||
@@ -1,5 +1,7 @@
|
||||
using GeekDesk.Util;
|
||||
using GeekDesk.Control.Other;
|
||||
using GeekDesk.Util;
|
||||
using GeekDesk.ViewModel;
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
@@ -23,14 +25,15 @@ namespace GeekDesk.Control.Windows
|
||||
{
|
||||
|
||||
private static MenuInfo menuInfo;
|
||||
private DataContextInfo dataContextInfo = new DataContextInfo();
|
||||
|
||||
private IconfontWindow(List<IconfontInfo> listInfo, MenuInfo menuInfo)
|
||||
private static List<IconfontInfo> systemIcons;
|
||||
private static List<IconfontInfo> customIcons;
|
||||
private IconfontWindow(List<IconfontInfo> icons, MenuInfo menuInfo)
|
||||
{
|
||||
InitializeComponent();
|
||||
dataContextInfo.iconListSystem = listInfo;
|
||||
this.DataContext = dataContextInfo;
|
||||
systemIcons = icons;
|
||||
this.DataContext = systemIcons;
|
||||
this.Topmost = true;
|
||||
IconfontWindow.menuInfo = menuInfo;
|
||||
InitializeComponent();
|
||||
}
|
||||
|
||||
|
||||
@@ -55,25 +58,42 @@ namespace GeekDesk.Control.Windows
|
||||
|
||||
private void TabControl_SelectionChanged(object sender, SelectionChangedEventArgs e)
|
||||
{
|
||||
//this.DataContext = listInfo;
|
||||
TabItem ti = this.MyTabControl.SelectedItem as TabItem;
|
||||
|
||||
switch (ti.Tag.ToString())
|
||||
{
|
||||
case "Custom":
|
||||
CustomButton.IsEnabled = true;
|
||||
this.DataContext = customIcons;
|
||||
break;
|
||||
default:
|
||||
if (CustomButton != null)
|
||||
{
|
||||
CustomButton.IsEnabled = false;
|
||||
}
|
||||
this.DataContext = systemIcons;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
private void Confirm_Click(object sender, RoutedEventArgs e)
|
||||
{
|
||||
string tag = (MyTabControl.SelectedContent as TabItem).Tag.ToString();
|
||||
|
||||
switch (tag)
|
||||
TabItem ti = this.MyTabControl.SelectedItem as TabItem;
|
||||
int index;
|
||||
switch (ti.Tag.ToString())
|
||||
{
|
||||
case "Custom":
|
||||
if (dataContextInfo.iconInfoCustom != null)
|
||||
index = this.CustomIcon.IconListBox.SelectedIndex;
|
||||
if (index != -1)
|
||||
{
|
||||
menuInfo.MenuGeometry = dataContextInfo.iconInfoCustom.Text;
|
||||
menuInfo.MenuGeometry = customIcons[index].Text;
|
||||
}
|
||||
break;
|
||||
default:
|
||||
if (dataContextInfo.iconInfoSystem != null)
|
||||
index = this.SystemIcon.IconListBox.SelectedIndex;
|
||||
if (index != -1)
|
||||
{
|
||||
menuInfo.MenuGeometry = dataContextInfo.iconInfoSystem.Text;
|
||||
menuInfo.MenuGeometry = systemIcons[index].Text;
|
||||
}
|
||||
break;
|
||||
}
|
||||
@@ -91,14 +111,9 @@ namespace GeekDesk.Control.Windows
|
||||
window.Show();
|
||||
}
|
||||
|
||||
|
||||
private class DataContextInfo
|
||||
private void CustomButton_Click(object sender, RoutedEventArgs e)
|
||||
{
|
||||
public List<IconfontInfo> iconListSystem;
|
||||
public List<IconfontInfo> iconListCustom;
|
||||
public IconfontInfo iconInfoSystem;
|
||||
public IconfontInfo iconInfoCustom;
|
||||
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user