添加 自定义菜单图标
This commit is contained in:
@@ -2,7 +2,7 @@
|
||||
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="10"
|
||||
CornerRadius="4"
|
||||
Width="300"
|
||||
Height="300"
|
||||
Opacity="0.9">
|
||||
|
||||
45
Control/UserControls/IconFont/IconPannel.xaml
Normal file
45
Control/UserControls/IconFont/IconPannel.xaml
Normal file
@@ -0,0 +1,45 @@
|
||||
<UserControl x:Class="GeekDesk.Control.UserControls.IconFont.IconPannel"
|
||||
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
|
||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
|
||||
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
|
||||
xmlns:hc="https://handyorg.github.io/handycontrol"
|
||||
xmlns:local="clr-namespace:GeekDesk.Control.UserControls.IconFont"
|
||||
mc:Ignorable="d"
|
||||
>
|
||||
<WrapPanel HorizontalAlignment="Center" VerticalAlignment="Top">
|
||||
<ListBox x:Name="IconfontList" ItemsSource="{Binding}" BorderThickness="0" Background="AliceBlue">
|
||||
<ListBox.ItemsPanel>
|
||||
<ItemsPanelTemplate>
|
||||
<WrapPanel Orientation="Horizontal" Background="Transparent"/>
|
||||
</ItemsPanelTemplate>
|
||||
</ListBox.ItemsPanel>
|
||||
|
||||
<ListBox.ItemContainerStyle>
|
||||
<Style>
|
||||
</Style>
|
||||
</ListBox.ItemContainerStyle>
|
||||
|
||||
<ListBox.ItemTemplate>
|
||||
<DataTemplate>
|
||||
<StackPanel Tag="{Binding}" Width="80" Height="80">
|
||||
<Button Background="Transparent"
|
||||
BorderThickness="0"
|
||||
IsEnabled="False"
|
||||
Opacity="0.8"
|
||||
hc:IconElement.Geometry="{Binding Text}"
|
||||
hc:IconElement.Height="35"
|
||||
hc:IconElement.Width="35"
|
||||
Height="60"
|
||||
Width="60"
|
||||
/>
|
||||
<TextBlock TextAlignment="Center"
|
||||
HorizontalAlignment="Center"
|
||||
VerticalAlignment="Center"
|
||||
Width="100" Text="{Binding Name}" />
|
||||
</StackPanel>
|
||||
</DataTemplate>
|
||||
</ListBox.ItemTemplate>
|
||||
</ListBox>
|
||||
</WrapPanel>
|
||||
</UserControl>
|
||||
29
Control/UserControls/IconFont/IconPannel.xaml.cs
Normal file
29
Control/UserControls/IconFont/IconPannel.xaml.cs
Normal file
@@ -0,0 +1,29 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
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.Imaging;
|
||||
using System.Windows.Navigation;
|
||||
using System.Windows.Shapes;
|
||||
|
||||
namespace GeekDesk.Control.UserControls.IconFont
|
||||
{
|
||||
/// <summary>
|
||||
/// IconPannel.xaml 的交互逻辑
|
||||
/// </summary>
|
||||
public partial class IconPannel : UserControl
|
||||
{
|
||||
public IconPannel()
|
||||
{
|
||||
InitializeComponent();
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
@@ -55,13 +55,15 @@
|
||||
<cvt:OpcityConvert x:Key="OpcityConvert"/>
|
||||
</UserControl.Resources>
|
||||
<!--左侧栏-->
|
||||
<hc:Card
|
||||
<hc:Card x:Name="MyCard"
|
||||
BorderThickness="1"
|
||||
Effect="{DynamicResource EffectShadow2}"
|
||||
Margin="5,0,0,5"
|
||||
>
|
||||
<hc:Card.Background>
|
||||
<SolidColorBrush Color="#FFFFFFFF" Opacity="{Binding AppConfig.CardOpacity, Mode=TwoWay, Converter={StaticResource OpcityConvert}}"/>
|
||||
<SolidColorBrush Color="#FFFFFFFF" hc:GeometryEffect.GeometryEffect="20" Opacity="{Binding AppConfig.CardOpacity, Mode=TwoWay, Converter={StaticResource OpcityConvert}}">
|
||||
|
||||
</SolidColorBrush>
|
||||
</hc:Card.Background>
|
||||
<hc:Card.BorderBrush>
|
||||
<SolidColorBrush Color="#FFFFFFFF" Opacity="0"/>
|
||||
@@ -131,8 +133,9 @@
|
||||
</Canvas>
|
||||
</Button>-->
|
||||
<!--<TextBlock Text="" Style="{StaticResource MyIcon}"/>-->
|
||||
<TextBlock Text="" FontFamily="/#IconFont" FontSize="40"/>
|
||||
<TextBlock Text="{Binding MenuName}"
|
||||
HorizontalAlignment="Center"
|
||||
TextAlignment="Center"
|
||||
VerticalAlignment="Center"
|
||||
IsVisibleChanged="MenuWhenVisibilityChanged"
|
||||
Visibility="{Binding NotMenuEdit}"
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
using DraggAnimatedPanelExample;
|
||||
using GeekDesk.Control.Windows;
|
||||
using GeekDesk.Util;
|
||||
using GeekDesk.ViewModel;
|
||||
using System;
|
||||
@@ -13,6 +14,7 @@ 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;
|
||||
@@ -31,6 +33,7 @@ namespace GeekDesk.Control.UserControls.PannelCard
|
||||
{
|
||||
InitializeComponent();
|
||||
appData.AppConfig.SelectedMenuIcons = appData.MenuList[appData.AppConfig.SelectedMenuIndex].IconList;
|
||||
|
||||
}
|
||||
|
||||
DelegateCommand<int[]> _swap;
|
||||
@@ -190,7 +193,8 @@ namespace GeekDesk.Control.UserControls.PannelCard
|
||||
/// <param name="e"></param>
|
||||
private void EditMenuGeometry(object sender, RoutedEventArgs e)
|
||||
{
|
||||
|
||||
MenuInfo menuInfo = ((MenuItem)sender).Tag as MenuInfo;
|
||||
IconfontWindow.Show(SvgToGeometry.GetIconfonts(), menuInfo);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -52,7 +52,7 @@
|
||||
Effect="{DynamicResource EffectShadow2}"
|
||||
Margin="5,0,5,5" Grid.ColumnSpan="2">
|
||||
<hc:Card.Background>
|
||||
<SolidColorBrush Color="#FFFFFFFF" Opacity="{Binding AppConfig.CardOpacity, Mode=TwoWay, Converter={StaticResource OpcityConvert}}"/>
|
||||
<SolidColorBrush Color="AliceBlue" hc:GeometryEffect.GeometryEffect="20" Opacity="{Binding AppConfig.CardOpacity, Mode=TwoWay, Converter={StaticResource OpcityConvert}}"/>
|
||||
</hc:Card.Background>
|
||||
<hc:Card.BorderBrush>
|
||||
<SolidColorBrush Color="#FFFFFFFF" Opacity="0"/>
|
||||
|
||||
@@ -62,7 +62,7 @@
|
||||
<hc:SideMenuItem.Icon>
|
||||
<Button Background="Transparent"
|
||||
BorderThickness="0"
|
||||
hc:IconElement.Geometry="{StaticResource About}"
|
||||
hc:IconElement.Geometry="M671.374222 357.944889c10.467556 0 20.792889 0.711111 31.032889 1.820444-27.875556-124.017778-166.741333-216.149333-325.233778-216.149333-177.180444 0-322.332444 115.342222-322.332444 261.774222 0 84.536889 48.298667 153.941333 128.995556 207.786667L151.608889 705.735111l112.696889-53.959111c40.305778 7.623111 72.675556 15.445333 112.896 15.445333 10.126222 0 20.138667-0.483556 30.094222-1.223111-6.314667-20.565333-9.955556-42.126222-9.955556-64.483556C397.340444 467.057778 518.286222 357.944889 671.374222 357.944889zM498.062222 274.488889c24.263111 0 40.334222 15.246222 40.334222 38.428444 0 23.068444-16.071111 38.513778-40.334222 38.513778-24.149333 0-48.412444-15.473778-48.412444-38.513778C449.678222 289.735111 473.912889 274.488889 498.062222 274.488889zM272.469333 351.431111c-24.149333 0-48.554667-15.473778-48.554667-38.513778 0-23.153778 24.376889-38.428444 48.554667-38.428444 24.149333 0 40.248889 15.246222 40.248889 38.428444C312.718222 335.957333 296.647111 351.431111 272.469333 351.431111zM965.575111 597.816889c0-123.022222-128.967111-223.345778-273.806222-223.345778-153.372444 0-274.147556 100.295111-274.147556 223.345778 0 123.278222 120.803556 223.374222 274.147556 223.374222 32.085333 0 64.483556-7.736889 96.711111-15.445333l88.405333 46.222222-24.234667-76.913778C917.390222 728.689778 965.575111 667.221333 965.575111 597.816889zM602.908444 559.303111c-16.042667 0-32.256-15.246222-32.256-30.805333 0-15.331556 16.184889-30.776889 32.256-30.776889 24.376889 0 40.362667 15.445333 40.362667 30.776889C643.242667 544.056889 627.285333 559.303111 602.908444 559.303111zM780.202667 559.303111c-15.928889 0-32.028444-15.246222-32.028444-30.805333 0-15.331556 16.071111-30.776889 32.028444-30.776889 24.149333 0 40.362667 15.445333 40.362667 30.776889C820.536889 544.056889 804.352 559.303111 780.202667 559.303111z"
|
||||
hc:IconElement.Height="18"
|
||||
hc:IconElement.Width="18"
|
||||
HorizontalAlignment="Right"
|
||||
|
||||
41
Control/Windows/IconfontWindow.xaml
Normal file
41
Control/Windows/IconfontWindow.xaml
Normal file
@@ -0,0 +1,41 @@
|
||||
<Window x:Class="GeekDesk.Control.Windows.IconfontWindow"
|
||||
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
|
||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
|
||||
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
|
||||
xmlns:local="clr-namespace:GeekDesk.Control.Windows"
|
||||
xmlns:hc="https://handyorg.github.io/handycontrol"
|
||||
xmlns:uc="clr-namespace:GeekDesk.Control.UserControls.IconFont"
|
||||
mc:Ignorable="d"
|
||||
Title="IconfontWindow"
|
||||
Height="450" Width="600"
|
||||
WindowStyle="None"
|
||||
AllowsTransparency="True"
|
||||
Background="AliceBlue"
|
||||
MouseDown="DragMove"
|
||||
>
|
||||
|
||||
|
||||
<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:SimplePanel Background="AliceBlue">
|
||||
<uc:IconPannel x:Name="System" />
|
||||
</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:SimplePanel Background="AliceBlue">
|
||||
<uc:IconPannel x:Name="Custom" />
|
||||
</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"/>
|
||||
</Grid>
|
||||
</Border>
|
||||
|
||||
|
||||
</Window>
|
||||
91
Control/Windows/IconfontWindow.xaml.cs
Normal file
91
Control/Windows/IconfontWindow.xaml.cs
Normal file
@@ -0,0 +1,91 @@
|
||||
using GeekDesk.Util;
|
||||
using GeekDesk.ViewModel;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
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.Imaging;
|
||||
using System.Windows.Shapes;
|
||||
|
||||
namespace GeekDesk.Control.Windows
|
||||
{
|
||||
/// <summary>
|
||||
/// IconfontWindow.xaml 的交互逻辑
|
||||
/// </summary>
|
||||
public partial class IconfontWindow : Window
|
||||
{
|
||||
|
||||
private static List<IconfontInfo> listInfo;
|
||||
private static MenuInfo menuInfo;
|
||||
private IconfontWindow(List<IconfontInfo> listInfo, MenuInfo menuInfo)
|
||||
{
|
||||
InitializeComponent();
|
||||
this.DataContext = listInfo;
|
||||
IconfontWindow.listInfo = listInfo;
|
||||
IconfontWindow.menuInfo = menuInfo;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 移动窗口
|
||||
/// </summary>
|
||||
/// <param name="sender"></param>
|
||||
/// <param name="e"></param>
|
||||
private void DragMove(object sender, System.Windows.Input.MouseButtonEventArgs e)
|
||||
{
|
||||
if (e.LeftButton == MouseButtonState.Pressed)
|
||||
{
|
||||
DragMove();
|
||||
}
|
||||
}
|
||||
|
||||
private void Close_Click(object sender, RoutedEventArgs e)
|
||||
{
|
||||
this.Close();
|
||||
}
|
||||
|
||||
private void TabControl_SelectionChanged(object sender, SelectionChangedEventArgs e)
|
||||
{
|
||||
this.DataContext = listInfo;
|
||||
}
|
||||
|
||||
private void Confirm_Click(object sender, RoutedEventArgs e)
|
||||
{
|
||||
string tag = (MyTabControl.SelectedContent as TabItem).Tag.ToString();
|
||||
|
||||
switch (tag)
|
||||
{
|
||||
case "Custom":
|
||||
if (Custom.IconfontList.SelectedIndex != -1)
|
||||
{
|
||||
menuInfo.MenuGeometry = (((StackPanel)Custom.IconfontList.SelectedItem).Tag as IconfontInfo).Text;
|
||||
}
|
||||
break;
|
||||
default:
|
||||
if (System.IconfontList.SelectedIndex != -1)
|
||||
{
|
||||
menuInfo.MenuGeometry = (((StackPanel)System.IconfontList.SelectedItem).Tag as IconfontInfo).Text;
|
||||
}
|
||||
break;
|
||||
}
|
||||
this.Close();
|
||||
}
|
||||
|
||||
|
||||
private static System.Windows.Window window = null;
|
||||
public static void Show(List<IconfontInfo> listInfo, MenuInfo menuInfo)
|
||||
{
|
||||
if (window == null || !window.Activate())
|
||||
{
|
||||
window = new IconfontWindow(listInfo, menuInfo);
|
||||
}
|
||||
window.Show();
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user