优化修改菜单名时的样式

This commit is contained in:
liufei
2022-01-20 15:47:40 +08:00
parent 9c687117f9
commit ff2a103682

View File

@@ -1,6 +1,8 @@
using GeekDesk.Constant; using GeekDesk.Constant;
using GeekDesk.Util; using GeekDesk.Util;
using Newtonsoft.Json;
using System; using System;
using System.Collections.Generic;
using System.Collections.ObjectModel; using System.Collections.ObjectModel;
using System.ComponentModel; using System.ComponentModel;
using System.Windows; using System.Windows;
@@ -11,17 +13,33 @@ namespace GeekDesk.ViewModel
[Serializable] [Serializable]
public class MenuInfo : INotifyPropertyChanged public class MenuInfo : INotifyPropertyChanged
{ {
private string menuName; private string menuName;
private string menuId; private string menuId;
private Visibility menuEdit = Visibility.Collapsed; private Visibility menuEdit = Visibility.Collapsed;
private Visibility notMenuEdit = Visibility.Visible; private Visibility notMenuEdit = Visibility.Visible;
private bool isEdit = false;
private string menuGeometry; //菜单几何图标 private string menuGeometry; //菜单几何图标
private string geometryColor; //几何图标颜色 private string geometryColor; //几何图标颜色
private ObservableCollection<IconInfo> iconList = new ObservableCollection<IconInfo>(); private ObservableCollection<IconInfo> iconList = new ObservableCollection<IconInfo>();
[field: NonSerializedAttribute()]
private string[] NO_WRITE_ARR = new string[] { "IsEdit" };
public bool IsEdit
{
get
{
return isEdit;
}
set
{
isEdit = value;
OnPropertyChanged("IsEdit");
}
}
public string MenuGeometry public string MenuGeometry
{ {
get get
@@ -65,7 +83,7 @@ namespace GeekDesk.ViewModel
set set
{ {
menuName = value; menuName = value;
OnPropertyChanged("MenuName"); OnPropertyChanged("MenuName");
} }
} }
@@ -93,9 +111,12 @@ namespace GeekDesk.ViewModel
menuEdit = value; menuEdit = value;
if (menuEdit == Visibility.Visible) if (menuEdit == Visibility.Visible)
{ {
IsEdit = true;
NotMenuEdit = Visibility.Collapsed; NotMenuEdit = Visibility.Collapsed;
} else }
else
{ {
IsEdit = false;
NotMenuEdit = Visibility.Visible; NotMenuEdit = Visibility.Visible;
} }
OnPropertyChanged("MenuEdit"); OnPropertyChanged("MenuEdit");
@@ -128,12 +149,24 @@ namespace GeekDesk.ViewModel
} }
} }
public override String ToString()
{
return JsonConvert.SerializeObject(this);
}
[field: NonSerializedAttribute()] [field: NonSerializedAttribute()]
public event PropertyChangedEventHandler PropertyChanged; public event PropertyChangedEventHandler PropertyChanged;
private void OnPropertyChanged(string propertyName) private void OnPropertyChanged(string propertyName)
{ {
PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(propertyName)); PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(propertyName));
foreach (var field in NO_WRITE_ARR)
{
if (field.Equals(propertyName))
{
return;
}
}
CommonCode.SaveAppData(MainWindow.appData); CommonCode.SaveAppData(MainWindow.appData);
} }
} }
} }