123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373 |
- using GeekDesk.Constant;
- using GeekDesk.Util;
- using System;
- using System.ComponentModel;
- using System.Windows.Media.Imaging;
- /// <summary>
- /// 图标信息
- /// </summary>
- namespace GeekDesk.ViewModel
- {
- [Serializable]
- public class IconInfo : INotifyPropertyChanged
- {
- private string path; //路径
- private string name; //文件名
- private int count = 0; //打开次数
- [field: NonSerialized]
- private BitmapImage bitmapImage; //位图
- private byte[] imageByteArr; //图片 byte数组
- private string content; //显示信息
- private bool adminStartUp = false; //始终管理员方式启动 默认否
- private byte[] defaultImage; //默认图标
- private string startArg; //启动参数
- private string lnkPath;
- private string relativePath; //相对路径
- private IconType iconType = IconType.OTHER;
- private bool isChecked = false; //是否选中
- public bool IsChecked_NoWrite
- {
- get
- {
- return isChecked;
- }
- set
- {
- isChecked = value;
- OnPropertyChanged("IsChecked_NoWrite");
- }
- }
- public string RelativePath_NoWrite
- {
- get
- {
- return relativePath;
- }
- set
- {
- relativePath = value;
- }
- }
- public string RelativePath
- {
- get
- {
- return relativePath;
- }
- set
- {
- relativePath = value;
- OnPropertyChanged("RelativePath");
- }
- }
- public string LnkPath_NoWrite
- {
- get
- {
- return lnkPath;
- }
- set
- {
- lnkPath = value;
- }
- }
- public string LnkPath
- {
- get
- {
- return lnkPath;
- }
- set
- {
- lnkPath = value;
- OnPropertyChanged("LnkPath");
- }
- }
- public string StartArg
- {
- get
- {
- return startArg;
- }
- set
- {
- startArg = value;
- OnPropertyChanged("StartArg");
- }
- }
- public string StartArg_NoWrite
- {
- get
- {
- return startArg;
- }
- set
- {
- startArg = value;
- }
- }
- public IconType IconType
- {
- get
- {
- if (iconType == 0) return IconType.OTHER;
- return iconType;
- }
- set
- {
- iconType = value;
- OnPropertyChanged("IconType");
- }
- }
- public byte[] DefaultImage
- {
- get
- {
- return defaultImage;
- }
- set
- {
- defaultImage = value;
- OnPropertyChanged("DefaultImage");
- }
- }
- public byte[] DefaultImage_NoWrite
- {
- get
- {
- return defaultImage;
- }
- set
- {
- defaultImage = value;
- }
- }
- public bool AdminStartUp
- {
- get
- {
- return adminStartUp;
- }
- set
- {
- adminStartUp = value;
- OnPropertyChanged("AdminStartUp");
- }
- }
- public int Count
- {
- get
- {
- return count;
- }
- set
- {
- count = value;
- if (StringUtil.IsEmpty(Path))
- {
- Content = Name + "\n使用次数: " + Count;
- }
- else
- {
- Content = Path + "\n" + Name + "\n使用次数: " + Count;
- }
- OnPropertyChanged("Count");
- }
- }
- public string Name
- {
- get
- {
- return name;
- }
- set
- {
- name = value;
- if (StringUtil.IsEmpty(Path))
- {
- Content = Name + "\n使用次数: " + Count;
- }
- else
- {
- Content = Path + "\n" + Name + "\n使用次数: " + Count;
- }
- OnPropertyChanged("Name");
- }
- }
- public string Name_NoWrite
- {
- get
- {
- return name;
- }
- set
- {
- name = value;
- if (StringUtil.IsEmpty(Path))
- {
- content = Name + "\n使用次数: " + Count;
- }
- else
- {
- content = Path + "\n" + Name + "\n使用次数: " + Count;
- }
- }
- }
- public string Path
- {
- get
- {
- return path;
- }
- set
- {
- path = value;
- if (StringUtil.IsEmpty(Path))
- {
- Content = Name + "\n使用次数: " + Count;
- }
- else
- {
- Content = Path + "\n" + Name + "\n使用次数: " + Count;
- }
- OnPropertyChanged("Path");
- }
- }
- public string Path_NoWrite
- {
- get
- {
- return path;
- }
- set
- {
- path = value;
- if (StringUtil.IsEmpty(Path))
- {
- content = Name + "\n使用次数: " + Count;
- }
- else
- {
- content = Path + "\n" + Name + "\n使用次数: " + Count;
- }
- }
- }
- public BitmapImage BitmapImage
- {
- get
- {
- return ImageUtil.ByteArrToImage(ImageByteArr);
- }
- set
- {
- bitmapImage = value;
- ImageByteArr = ImageUtil.BitmapImageToByte(bitmapImage);
- OnPropertyChanged("BitmapImage");
- }
- }
- public BitmapImage BitmapImage_NoWrite
- {
- get
- {
- return ImageUtil.ByteArrToImage(ImageByteArr_NoWrite);
- }
- set
- {
- bitmapImage = value;
- ImageByteArr_NoWrite = ImageUtil.BitmapImageToByte(bitmapImage);
- OnPropertyChanged("BitmapImage_NoWrite");
- }
- }
- public byte[] ImageByteArr
- {
- get
- {
- return imageByteArr;
- }
- set
- {
- imageByteArr = value;
- OnPropertyChanged("ImageByteArr");
- }
- }
- public byte[] ImageByteArr_NoWrite
- {
- get
- {
- return imageByteArr;
- }
- set
- {
- imageByteArr = value;
- }
- }
- public string Content
- {
- get
- {
- return content;
- }
- set
- {
- content = value;
- OnPropertyChanged("Content");
- }
- }
- public string Content_NoWrite
- {
- get
- {
- return content;
- }
- set
- {
- content = value;
- }
- }
- [field: NonSerializedAttribute()]
- public event PropertyChangedEventHandler PropertyChanged;
- private void OnPropertyChanged(string propertyName)
- {
- PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(propertyName));
- if (propertyName!=null && !propertyName.Contains("NoWrite"))
- {
- CommonCode.SaveAppData(MainWindow.appData, Constants.DATA_FILE_PATH);
- }
- }
- }
- }
|