添加自定义菜单图标
This commit is contained in:
43
Control/Other/CustomIconUrlDialog.xaml
Normal file
43
Control/Other/CustomIconUrlDialog.xaml
Normal file
@@ -0,0 +1,43 @@
|
||||
<Border x:Class="GeekDesk.Control.Other.CustomIconUrlDialog"
|
||||
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
|
||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||
xmlns:hc="https://handyorg.github.io/handycontrol"
|
||||
CornerRadius="3"
|
||||
Width="400"
|
||||
Height="230"
|
||||
Opacity="0.95">
|
||||
<Border.Resources>
|
||||
<Style x:Key="LeftTB" TargetType="TextBlock" BasedOn="{StaticResource TextBlockBaseStyle}">
|
||||
<Setter Property="Width" Value="100"/>
|
||||
<Setter Property="HorizontalAlignment" Value="Left"/>
|
||||
<Setter Property="VerticalAlignment" Value="Center"/>
|
||||
<Setter Property="FontSize" Value="14"/>
|
||||
</Style>
|
||||
</Border.Resources>
|
||||
<Border.Background>
|
||||
<SolidColorBrush Color="AliceBlue" Opacity="1"/>
|
||||
</Border.Background>
|
||||
<hc:SimplePanel Margin="10">
|
||||
<Grid Margin="8,20,8,20">
|
||||
|
||||
<hc:UniformSpacingPanel Spacing="10" Margin="0,10,0,-10">
|
||||
<TextBlock Text="SVG 图标地址:" Style="{StaticResource LeftTB}"/>
|
||||
<TextBox x:Name="IconUrl" Text="{Binding Name, Mode=OneWay}" Width="240" FontSize="14"/>
|
||||
</hc:UniformSpacingPanel>
|
||||
|
||||
<hc:UniformSpacingPanel Spacing="10" Margin="0,58.276,0,-58.276">
|
||||
<TextBlock Text="JSON 配置地址:" Style="{StaticResource LeftTB}"/>
|
||||
<TextBox x:Name="JsonUrl" Text="{Binding Name, Mode=OneWay}" Width="240" FontSize="14"/>
|
||||
</hc:UniformSpacingPanel>
|
||||
|
||||
<!--<hc:UniformSpacingPanel Spacing="10" Margin="246.206,124.551,-246.206,-124.551">
|
||||
<Button Content="取消" Click=""
|
||||
/>
|
||||
<Button Content="保存" Click=""
|
||||
Background="#5BC0DE"
|
||||
Foreground="White"/>
|
||||
</hc:UniformSpacingPanel>-->
|
||||
</Grid>
|
||||
<!--<Button Width="22" Height="22" Command="hc:ControlCommands.Close" Style="{StaticResource ButtonIcon}" Foreground="{DynamicResource {x:Static SystemColors.ControlDarkDarkBrushKey}}" hc:IconElement.Geometry="{StaticResource ErrorGeometry}" Padding="0" HorizontalAlignment="Right" VerticalAlignment="Top" Margin="0,4,4,0"/>-->
|
||||
</hc:SimplePanel>
|
||||
</Border>
|
||||
30
Control/Other/CustomIconUrlDialog.xaml.cs
Normal file
30
Control/Other/CustomIconUrlDialog.xaml.cs
Normal file
@@ -0,0 +1,30 @@
|
||||
using GeekDesk.Util;
|
||||
using GeekDesk.ViewModel;
|
||||
using Microsoft.Win32;
|
||||
using System;
|
||||
using System.Windows;
|
||||
using System.Windows.Controls;
|
||||
using System.Windows.Media.Imaging;
|
||||
|
||||
|
||||
namespace GeekDesk.Control.Other
|
||||
{
|
||||
/// <summary>
|
||||
/// TextDialog.xaml 的交互逻辑
|
||||
/// </summary>
|
||||
public partial class CustomIconUrlDialog
|
||||
{
|
||||
|
||||
public CustomIconUrlDialog(AppConfig appConfig)
|
||||
{
|
||||
this.DataContext = appConfig;
|
||||
InitializeComponent();
|
||||
}
|
||||
|
||||
public CustomIconUrlDialog()
|
||||
{
|
||||
InitializeComponent();
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
@@ -19,12 +19,6 @@
|
||||
</Border.Background>
|
||||
<hc:SimplePanel Margin="10">
|
||||
<Grid Margin="8,20,8,20">
|
||||
<Grid.ColumnDefinitions>
|
||||
<ColumnDefinition Width="93*"/>
|
||||
<ColumnDefinition Width="38*"/>
|
||||
<ColumnDefinition Width="126*"/>
|
||||
<ColumnDefinition Width="7*"/>
|
||||
</Grid.ColumnDefinitions>
|
||||
<hc:UniformSpacingPanel Spacing="10" Grid.ColumnSpan="4">
|
||||
<TextBlock Text="名称:" Style="{StaticResource LeftTB}"/>
|
||||
<TextBox x:Name="IconName" Text="{Binding Name, Mode=OneWay}" Width="180" FontSize="14"/>
|
||||
|
||||
@@ -4,7 +4,6 @@
|
||||
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
|
||||
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
|
||||
xmlns:cvt="clr-namespace:GeekDesk.Converts"
|
||||
xmlns:local="clr-namespace:GeekDesk.Control.UserControls"
|
||||
xmlns:hc="https://handyorg.github.io/handycontrol"
|
||||
mc:Ignorable="d"
|
||||
Background="AliceBlue"
|
||||
|
||||
@@ -8,7 +8,7 @@
|
||||
mc:Ignorable="d"
|
||||
>
|
||||
<WrapPanel HorizontalAlignment="Center" VerticalAlignment="Top">
|
||||
<ListBox x:Name="IconListBox" ItemsSource="{Binding iconListSystem}" SelectionChanged="ListBox_SelectionChanged" BorderThickness="0" Background="AliceBlue">
|
||||
<ListBox x:Name="IconListBox" ItemsSource="{Binding}" BorderThickness="0" Background="AliceBlue">
|
||||
<ListBox.ItemsPanel>
|
||||
<ItemsPanelTemplate>
|
||||
<WrapPanel Orientation="Horizontal" Background="Transparent"/>
|
||||
|
||||
@@ -23,6 +23,7 @@ namespace GeekDesk.Control.UserControls.IconFont
|
||||
{
|
||||
public IconPannel()
|
||||
{
|
||||
//DataContext = this;
|
||||
InitializeComponent();
|
||||
}
|
||||
|
||||
|
||||
@@ -107,7 +107,7 @@
|
||||
|
||||
<ListBox.ItemTemplate>
|
||||
<DataTemplate>
|
||||
<StackPanel MouseLeftButtonDown="MenuClick" Tag="{Binding}">
|
||||
<StackPanel MouseLeftButtonDown="MenuClick" MouseRightButtonDown="MenuClick" Tag="{Binding}">
|
||||
<hc:TextBox Text="{Binding Path=MenuName, Mode=TwoWay}"
|
||||
HorizontalAlignment="Left"
|
||||
Width="{Binding RelativeSource={RelativeSource FindAncestor,AncestorType={x:Type ListBox},AncestorLevel=1},Path=Tag, Mode=TwoWay, Converter={StaticResource MenuWidthConvert}}"
|
||||
@@ -119,27 +119,19 @@
|
||||
IsVisibleChanged="MenuEditWhenVisibilityChanged"
|
||||
Visibility="{Binding MenuEdit}"/>
|
||||
<StackPanel Orientation="Horizontal">
|
||||
<!--<Button Background="Transparent"
|
||||
BorderThickness="0"
|
||||
hc:IconElement.Geometry="{StaticResource test}"
|
||||
hc:IconElement.Height="18"
|
||||
hc:IconElement.Width="18"
|
||||
/>-->
|
||||
<!--<Button Background="Transparent" BorderThickness="0" Height="10" Width="10">
|
||||
<Canvas>
|
||||
<Path Fill="#92E3C3" Data="M391.68 957.44h-66.56v-158.4128H66.56v-66.56h258.56v-174.08H66.56v-66.56h258.56V307.2h66.56l-0.0512 184.6272h240.6912V307.2h66.56l-0.0512 184.6272H957.44v307.2h-258.6112V957.44h-66.4576l-0.0512-158.4128H391.6288V957.44z m-0.0512-224.9728h240.6912v-174.08H391.6288v174.08z m565.8112-174.08h-258.6112v174.08H957.44v-174.08z"/>
|
||||
<Path Fill="#5D7092" Data="M51.2 51.2h921.6v256H51.2z"/>
|
||||
<Path Fill="#5D7092" Data="M921.6 0a102.4 102.4 0 0 1 102.4 102.4v819.2a102.4 102.4 0 0 1-102.4 102.4H102.4a102.4 102.4 0 0 1-102.4-102.4V102.4a102.4 102.4 0 0 1 102.4-102.4h819.2z m0 66.56H102.4a35.84 35.84 0 0 0-35.5328 30.976L66.56 102.4v819.2a35.84 35.84 0 0 0 30.976 35.5328L102.4 957.44h819.2a35.84 35.84 0 0 0 35.5328-30.976L957.44 921.6V102.4a35.84 35.84 0 0 0-30.976-35.5328L921.6 66.56z"/>
|
||||
</Canvas>
|
||||
</Button>-->
|
||||
<!--<TextBlock Text="" Style="{StaticResource MyIcon}"/>-->
|
||||
<TextBlock Text="{Binding MenuName}"
|
||||
HorizontalAlignment="Center"
|
||||
TextAlignment="Center"
|
||||
VerticalAlignment="Center"
|
||||
IsVisibleChanged="MenuWhenVisibilityChanged"
|
||||
Visibility="{Binding NotMenuEdit}"
|
||||
/>
|
||||
<Button Background="Transparent"
|
||||
BorderThickness="0"
|
||||
hc:IconElement.Geometry="{Binding MenuGeometry}"
|
||||
hc:IconElement.Height="18"
|
||||
hc:IconElement.Width="18"
|
||||
/>
|
||||
<TextBlock Text="{Binding MenuName}"
|
||||
HorizontalAlignment="Center"
|
||||
TextAlignment="Center"
|
||||
VerticalAlignment="Center"
|
||||
IsVisibleChanged="MenuWhenVisibilityChanged"
|
||||
Visibility="{Binding NotMenuEdit}"
|
||||
/>
|
||||
</StackPanel>
|
||||
</StackPanel>
|
||||
</DataTemplate>
|
||||
|
||||
@@ -3,21 +3,14 @@ using GeekDesk.Control.Windows;
|
||||
using GeekDesk.Util;
|
||||
using GeekDesk.ViewModel;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
|
||||
using System.Collections.ObjectModel;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
using System.Windows;
|
||||
using System.Windows.Controls;
|
||||
using System.Windows.Data;
|
||||
using System.Windows.Documents;
|
||||
|
||||
using System.Windows.Input;
|
||||
using System.Windows.Media;
|
||||
using System.Windows.Media.Effects;
|
||||
using System.Windows.Media.Imaging;
|
||||
using System.Windows.Navigation;
|
||||
using System.Windows.Shapes;
|
||||
|
||||
|
||||
namespace GeekDesk.Control.UserControls.PannelCard
|
||||
{
|
||||
|
||||
@@ -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