远程图标功能 完成
This commit is contained in:
@@ -27,25 +27,17 @@
|
||||
|
||||
<Border MouseDown="DragMove">
|
||||
<Grid MouseDown="DragMove">
|
||||
|
||||
<TextBox x:Name="CheckSettingUrl" Visibility="Collapsed" Text="{Binding IsSettingUrl}" TextChanged="CheckSettingUrl_TextChanged"/>
|
||||
<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" IsSelected="True" Header="系统图标" hc:IconElement.Height="16" hc:IconElement.Width="16" hc:IconElement.Geometry="{StaticResource CalendarGeometry}" >
|
||||
<hc:SimplePanel Background="AliceBlue">
|
||||
<!--<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" Header="自定义图标" hc:IconElement.Height="16" hc:IconElement.Width="16" hc:IconElement.Geometry="{StaticResource CalendarGeometry}">
|
||||
<hc:SimplePanel Background="AliceBlue">
|
||||
<hc:LoadingCircle/>
|
||||
<uc:IconPannel x:Name="CustomIcon"/>
|
||||
<hc:LoadingCircle x:Name="LoadingEle"/>
|
||||
</hc:SimplePanel>
|
||||
</hc:TabItem>
|
||||
</hc:TabControl>
|
||||
|
||||
@@ -4,17 +4,13 @@ using GeekDesk.ViewModel;
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using System.ComponentModel;
|
||||
|
||||
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
|
||||
{
|
||||
@@ -23,17 +19,24 @@ namespace GeekDesk.Control.Windows
|
||||
/// </summary>
|
||||
public partial class IconfontWindow : Window
|
||||
{
|
||||
|
||||
private static AppConfig appConfig = MainWindow.appData.AppConfig;
|
||||
private static MenuInfo menuInfo;
|
||||
private static List<IconfontInfo> systemIcons;
|
||||
private static List<IconfontInfo> customIcons;
|
||||
public static IconfontViewModel vm;
|
||||
private IconfontWindow(List<IconfontInfo> icons, MenuInfo menuInfo)
|
||||
{
|
||||
|
||||
InitializeComponent();
|
||||
|
||||
systemIcons = icons;
|
||||
this.DataContext = systemIcons;
|
||||
this.Topmost = true;
|
||||
IconfontWindow.menuInfo = menuInfo;
|
||||
InitializeComponent();
|
||||
vm = new IconfontViewModel
|
||||
{
|
||||
Iconfonts = systemIcons
|
||||
};
|
||||
this.DataContext = vm;
|
||||
}
|
||||
|
||||
|
||||
@@ -64,14 +67,33 @@ namespace GeekDesk.Control.Windows
|
||||
{
|
||||
case "Custom":
|
||||
CustomButton.IsEnabled = true;
|
||||
this.DataContext = customIcons;
|
||||
if (StringUtil.IsEmpty(appConfig.CustomIconUrl) || StringUtil.IsEmpty(appConfig.CustomIconJsonUrl))
|
||||
{
|
||||
LoadingEle.Visibility = Visibility.Visible;
|
||||
CustomIcon.Visibility = Visibility.Collapsed;
|
||||
HandyControl.Controls.Dialog.Show(new CustomIconUrlDialog(appConfig));
|
||||
} else
|
||||
{
|
||||
if (customIcons == null)
|
||||
{
|
||||
LoadingOnlineIcon();
|
||||
} else
|
||||
{
|
||||
vm.Iconfonts = customIcons;
|
||||
LoadingEle.Visibility = Visibility.Collapsed;
|
||||
CustomIcon.Visibility = Visibility.Visible;
|
||||
}
|
||||
}
|
||||
break;
|
||||
default:
|
||||
if (CustomButton != null)
|
||||
{
|
||||
CustomButton.IsEnabled = false;
|
||||
}
|
||||
this.DataContext = systemIcons;
|
||||
if (vm != null)
|
||||
{
|
||||
vm.Iconfonts = systemIcons;
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
@@ -113,8 +135,80 @@ namespace GeekDesk.Control.Windows
|
||||
|
||||
private void CustomButton_Click(object sender, RoutedEventArgs e)
|
||||
{
|
||||
|
||||
|
||||
HandyControl.Controls.Dialog.Show(new CustomIconUrlDialog(appConfig));
|
||||
}
|
||||
|
||||
|
||||
private void CheckSettingUrl_TextChanged(object sender, TextChangedEventArgs e)
|
||||
{
|
||||
if (CheckSettingUrl.Text == "true")
|
||||
{
|
||||
LoadingOnlineIcon();
|
||||
} else
|
||||
{
|
||||
LoadingEle.IsRunning = true;
|
||||
CustomIcon.Visibility = Visibility.Collapsed;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
private void LoadingOnlineIcon()
|
||||
{
|
||||
try
|
||||
{
|
||||
string svgJsStr = HttpUtil.Get(appConfig.CustomIconUrl);
|
||||
string jsonStr = HttpUtil.Get(appConfig.CustomIconJsonUrl);
|
||||
List<IconfontInfo> icons = SvgToGeometry.GetIconfonts(svgJsStr, jsonStr);
|
||||
customIcons = icons;
|
||||
vm.Iconfonts = customIcons;
|
||||
LoadingEle.Visibility = Visibility.Collapsed;
|
||||
CustomIcon.Visibility = Visibility.Visible;
|
||||
}
|
||||
catch (Exception)
|
||||
{
|
||||
HandyControl.Controls.Growl.WarningGlobal("加载远程图标异常!");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public class IconfontViewModel : INotifyPropertyChanged
|
||||
{
|
||||
private List<IconfontInfo> iconfonts;
|
||||
private string isSettingUrl;
|
||||
|
||||
public List<IconfontInfo> Iconfonts
|
||||
{
|
||||
get
|
||||
{
|
||||
return iconfonts;
|
||||
}
|
||||
set
|
||||
{
|
||||
iconfonts = value;
|
||||
OnPropertyChanged("Iconfonts");
|
||||
}
|
||||
}
|
||||
|
||||
public string IsSettingUrl
|
||||
{
|
||||
get
|
||||
{
|
||||
return isSettingUrl;
|
||||
}
|
||||
set
|
||||
{
|
||||
isSettingUrl = value;
|
||||
OnPropertyChanged("IsSettingUrl");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public event PropertyChangedEventHandler PropertyChanged;
|
||||
private void OnPropertyChanged(string propertyName)
|
||||
{
|
||||
PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(propertyName));
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user