优化修改菜单名时的样式

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