Files
GeekDesk/ViewModel/IconInfo.cs

373 lines
8.3 KiB
C#
Raw Normal View History

2021-05-08 17:27:41 +08:00
using GeekDesk.Constant;
2021-05-14 16:48:26 +08:00
using GeekDesk.Util;
2021-05-08 17:27:41 +08:00
using System;
2021-04-13 15:26:19 +08:00
using System.ComponentModel;
using System.Windows.Media.Imaging;
2021-05-19 17:31:28 +08:00
/// <summary>
/// 图标信息
/// </summary>
2021-04-13 15:26:19 +08:00
namespace GeekDesk.ViewModel
{
[Serializable]
public class IconInfo : INotifyPropertyChanged
{
private string path; //路径
private string name; //文件名
private int count = 0; //打开次数
[field: NonSerialized]
private BitmapImage bitmapImage; //位图
2021-05-20 21:59:32 +08:00
private byte[] imageByteArr; //图片 byte数组
2021-04-13 15:26:19 +08:00
private string content; //显示信息
2021-05-14 16:48:26 +08:00
private bool adminStartUp = false; //始终管理员方式启动 默认否
2021-05-19 17:31:28 +08:00
private byte[] defaultImage; //默认图标
private string startArg; //启动参数
private string lnkPath;
2021-05-14 16:48:26 +08:00
2022-06-07 16:34:07 +08:00
private string relativePath; //相对路径
private IconType iconType = IconType.OTHER;
2021-05-14 16:48:26 +08:00
2025-03-07 10:59:39 +08:00
private bool isChecked = false; //是否选中
public bool IsChecked_NoWrite
{
get
{
return isChecked;
}
set
{
isChecked = value;
OnPropertyChanged("IsChecked_NoWrite");
}
}
2021-05-14 16:48:26 +08:00
2022-06-07 16:34:07 +08:00
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");
}
}
2021-05-14 16:48:26 +08:00
public byte[] DefaultImage
{
get
{
return defaultImage;
}
set
{
defaultImage = value;
OnPropertyChanged("DefaultImage");
}
}
public byte[] DefaultImage_NoWrite
{
get
{
return defaultImage;
}
set
{
defaultImage = value;
}
}
2021-05-14 16:48:26 +08:00
public bool AdminStartUp
{
get
{
return adminStartUp;
}
set
{
adminStartUp = value;
OnPropertyChanged("AdminStartUp");
}
}
2021-04-13 15:26:19 +08:00
public int Count
{
get
{
return count;
}
set
{
count = value;
if (StringUtil.IsEmpty(Path))
{
Content = Name + "\n使用次数: " + Count;
}
else
{
Content = Path + "\n" + Name + "\n使用次数: " + Count;
}
2021-04-13 15:26:19 +08:00
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;
}
2021-04-13 15:26:19 +08:00
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;
}
}
}
2021-04-13 15:26:19 +08:00
public string Path
{
get
{
return path;
}
set
{
path = value;
if (StringUtil.IsEmpty(Path))
{
Content = Name + "\n使用次数: " + Count;
}
else
{
Content = Path + "\n" + Name + "\n使用次数: " + Count;
}
2021-04-13 15:26:19 +08:00
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;
}
}
}
2021-04-13 15:26:19 +08:00
public BitmapImage BitmapImage
{
get
{
2021-05-14 16:48:26 +08:00
return ImageUtil.ByteArrToImage(ImageByteArr);
2021-04-13 15:26:19 +08:00
}
set
{
bitmapImage = value;
2021-05-14 16:48:26 +08:00
ImageByteArr = ImageUtil.BitmapImageToByte(bitmapImage);
2021-04-13 15:26:19 +08:00
OnPropertyChanged("BitmapImage");
}
}
public BitmapImage BitmapImage_NoWrite
{
get
{
return ImageUtil.ByteArrToImage(ImageByteArr_NoWrite);
}
set
{
bitmapImage = value;
ImageByteArr_NoWrite = ImageUtil.BitmapImageToByte(bitmapImage);
2023-03-31 09:06:04 +08:00
OnPropertyChanged("BitmapImage_NoWrite");
}
}
2021-04-13 15:26:19 +08:00
public byte[] ImageByteArr
{
get
{
return imageByteArr;
}
set
{
imageByteArr = value;
OnPropertyChanged("ImageByteArr");
}
}
public byte[] ImageByteArr_NoWrite
{
get
{
return imageByteArr;
}
set
{
imageByteArr = value;
}
}
2021-04-13 15:26:19 +08:00
public string Content
{
get
{
return content;
}
set
{
content = value;
OnPropertyChanged("Content");
}
}
2021-05-12 10:00:12 +08:00
public string Content_NoWrite
{
get
{
return content;
}
set
{
content = value;
}
}
2021-04-13 15:26:19 +08:00
[field: NonSerializedAttribute()]
public event PropertyChangedEventHandler PropertyChanged;
private void OnPropertyChanged(string propertyName)
{
PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(propertyName));
2025-03-07 10:59:39 +08:00
if (propertyName!=null && !propertyName.Contains("NoWrite"))
2023-03-31 09:06:04 +08:00
{
CommonCode.SaveAppData(MainWindow.appData, Constants.DATA_FILE_PATH);
}
2021-04-13 15:26:19 +08:00
}
}
}