1.0beta
This commit is contained in:
@@ -1,15 +1,13 @@
|
||||
using GalaSoft.MvvmLight;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
using GeekDesk.Constant;
|
||||
using System;
|
||||
using System.ComponentModel;
|
||||
|
||||
namespace GeekDesk.ViewModel
|
||||
{
|
||||
|
||||
[Serializable]
|
||||
public class AppConfig : ViewModelBase
|
||||
public class AppConfig : System.ComponentModel.INotifyPropertyChanged
|
||||
{
|
||||
private int menuSortType = (int)SortType.CUSTOM; //菜单排序类型
|
||||
private int iconSortType = (int)SortType.CUSTOM; //图表排序类型
|
||||
@@ -18,8 +16,10 @@ namespace GeekDesk.ViewModel
|
||||
private double menuCardWidth = (double)DefaultConstant.MENU_CARD_WIDHT;//菜单栏宽度
|
||||
|
||||
|
||||
|
||||
#region GetSet
|
||||
public int MenuSortType {
|
||||
public int MenuSortType
|
||||
{
|
||||
get
|
||||
{
|
||||
return menuSortType;
|
||||
@@ -27,7 +27,7 @@ namespace GeekDesk.ViewModel
|
||||
set
|
||||
{
|
||||
menuSortType = value;
|
||||
RaisePropertyChanged();
|
||||
OnPropertyChanged("MenuSortType");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -40,7 +40,7 @@ namespace GeekDesk.ViewModel
|
||||
set
|
||||
{
|
||||
iconSortType = value;
|
||||
RaisePropertyChanged();
|
||||
OnPropertyChanged("IconSortType");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -53,7 +53,7 @@ namespace GeekDesk.ViewModel
|
||||
set
|
||||
{
|
||||
windowWidth = value;
|
||||
RaisePropertyChanged();
|
||||
OnPropertyChanged("WindowWidth");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -66,7 +66,7 @@ namespace GeekDesk.ViewModel
|
||||
set
|
||||
{
|
||||
windowHeight = value;
|
||||
RaisePropertyChanged();
|
||||
OnPropertyChanged("WindowHeight");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -79,9 +79,17 @@ namespace GeekDesk.ViewModel
|
||||
set
|
||||
{
|
||||
menuCardWidth = value;
|
||||
RaisePropertyChanged();
|
||||
OnPropertyChanged("MenuCardWidth");
|
||||
}
|
||||
}
|
||||
|
||||
[field: NonSerializedAttribute()]
|
||||
public event PropertyChangedEventHandler PropertyChanged;
|
||||
private void OnPropertyChanged(string propertyName)
|
||||
{
|
||||
PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(propertyName));
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
}
|
||||
|
||||
61
ViewModel/AppData.cs
Normal file
61
ViewModel/AppData.cs
Normal file
@@ -0,0 +1,61 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel;
|
||||
|
||||
namespace GeekDesk.ViewModel
|
||||
{
|
||||
[Serializable]
|
||||
class AppData : INotifyPropertyChanged
|
||||
{
|
||||
private List<string> menuList = new List<string>();
|
||||
private Dictionary<string, List<IconInfo>> iconMap = new Dictionary<string, List<IconInfo>>();
|
||||
private AppConfig appConfig = new AppConfig();
|
||||
|
||||
public List<string> MenuList
|
||||
{
|
||||
get
|
||||
{
|
||||
return menuList;
|
||||
}
|
||||
set
|
||||
{
|
||||
menuList = value;
|
||||
OnPropertyChanged("MenuList");
|
||||
}
|
||||
}
|
||||
|
||||
public Dictionary<string, List<IconInfo>> IconMap
|
||||
{
|
||||
get
|
||||
{
|
||||
return iconMap;
|
||||
}
|
||||
set
|
||||
{
|
||||
iconMap = value;
|
||||
OnPropertyChanged("IconMap");
|
||||
}
|
||||
}
|
||||
|
||||
public AppConfig AppConfig
|
||||
{
|
||||
get
|
||||
{
|
||||
return appConfig;
|
||||
}
|
||||
set
|
||||
{
|
||||
appConfig = value;
|
||||
OnPropertyChanged("AppConfig");
|
||||
}
|
||||
}
|
||||
|
||||
[field: NonSerializedAttribute()]
|
||||
public event PropertyChangedEventHandler PropertyChanged;
|
||||
private void OnPropertyChanged(string propertyName)
|
||||
{
|
||||
PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(propertyName));
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
@@ -1,70 +0,0 @@
|
||||
using GalaSoft.MvvmLight;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using System.Windows.Media.Imaging;
|
||||
|
||||
namespace GeekDesk.ViewModel
|
||||
{
|
||||
public class DataInfos : ViewModelBase
|
||||
{
|
||||
private string path; //路径
|
||||
private string name; //文件名
|
||||
private int count = 0; //打开次数
|
||||
private BitmapImage bitmapImage; //位图
|
||||
|
||||
public int Count
|
||||
{
|
||||
get
|
||||
{
|
||||
return count;
|
||||
}
|
||||
set
|
||||
{
|
||||
count = value;
|
||||
RaisePropertyChanged();
|
||||
}
|
||||
}
|
||||
|
||||
public string Name
|
||||
{
|
||||
get
|
||||
{
|
||||
return name;
|
||||
}
|
||||
set
|
||||
{
|
||||
name = value;
|
||||
RaisePropertyChanged();
|
||||
}
|
||||
}
|
||||
|
||||
public string Path
|
||||
{
|
||||
get
|
||||
{
|
||||
return path;
|
||||
}
|
||||
set
|
||||
{
|
||||
path = value;
|
||||
RaisePropertyChanged();
|
||||
}
|
||||
}
|
||||
|
||||
public BitmapImage BitmapImage
|
||||
{
|
||||
get
|
||||
{
|
||||
return bitmapImage;
|
||||
}
|
||||
set
|
||||
{
|
||||
bitmapImage = value;
|
||||
RaisePropertyChanged();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
137
ViewModel/IconInfo.cs
Normal file
137
ViewModel/IconInfo.cs
Normal file
@@ -0,0 +1,137 @@
|
||||
using System;
|
||||
using System.ComponentModel;
|
||||
using System.IO;
|
||||
using System.Windows.Media.Imaging;
|
||||
|
||||
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; //图片 base64
|
||||
private string content; //显示信息
|
||||
|
||||
public int Count
|
||||
{
|
||||
get
|
||||
{
|
||||
return count;
|
||||
}
|
||||
set
|
||||
{
|
||||
count = value;
|
||||
Content = Path + "\n" + Name + "\n使用次数: " + Count;
|
||||
OnPropertyChanged("Count");
|
||||
}
|
||||
}
|
||||
|
||||
public string Name
|
||||
{
|
||||
get
|
||||
{
|
||||
return name;
|
||||
}
|
||||
set
|
||||
{
|
||||
name = value;
|
||||
Content = Path + "\n" + Name + "\n使用次数: " + Count;
|
||||
OnPropertyChanged("Name");
|
||||
}
|
||||
}
|
||||
|
||||
public string Path
|
||||
{
|
||||
get
|
||||
{
|
||||
return path;
|
||||
}
|
||||
set
|
||||
{
|
||||
path = value;
|
||||
Content = Path + "\n" + Name + "\n使用次数: " + Count;
|
||||
OnPropertyChanged("Path");
|
||||
}
|
||||
}
|
||||
|
||||
public BitmapImage BitmapImage
|
||||
{
|
||||
get
|
||||
{
|
||||
|
||||
return ToImage(ImageByteArr);
|
||||
}
|
||||
set
|
||||
{
|
||||
bitmapImage = value;
|
||||
ImageByteArr = getJPGFromImageControl(bitmapImage);
|
||||
OnPropertyChanged("BitmapImage");
|
||||
}
|
||||
}
|
||||
|
||||
public byte[] ImageByteArr
|
||||
{
|
||||
get
|
||||
{
|
||||
|
||||
return imageByteArr;
|
||||
}
|
||||
set
|
||||
{
|
||||
imageByteArr = value;
|
||||
OnPropertyChanged("ImageByteArr");
|
||||
}
|
||||
}
|
||||
|
||||
public string Content
|
||||
{
|
||||
get
|
||||
{
|
||||
return content;
|
||||
}
|
||||
set
|
||||
{
|
||||
content = value;
|
||||
OnPropertyChanged("Content");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
[field: NonSerializedAttribute()]
|
||||
public event PropertyChangedEventHandler PropertyChanged;
|
||||
private void OnPropertyChanged(string propertyName)
|
||||
{
|
||||
PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(propertyName));
|
||||
}
|
||||
|
||||
public BitmapImage ToImage(byte[] array)
|
||||
{
|
||||
using (var ms = new System.IO.MemoryStream(array))
|
||||
{
|
||||
var image = new BitmapImage();
|
||||
image.BeginInit();
|
||||
image.CacheOption = BitmapCacheOption.OnLoad; // here
|
||||
image.StreamSource = ms;
|
||||
image.EndInit();
|
||||
return image;
|
||||
}
|
||||
}
|
||||
|
||||
public byte[] getJPGFromImageControl(BitmapImage bi)
|
||||
{
|
||||
using (MemoryStream memStream = new MemoryStream())
|
||||
{
|
||||
PngBitmapEncoder encoder = new PngBitmapEncoder();
|
||||
encoder.Frames.Add(BitmapFrame.Create(bi));
|
||||
encoder.Save(memStream);
|
||||
return memStream.GetBuffer();
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
@@ -1,12 +0,0 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace GeekDesk.ViewModel
|
||||
{
|
||||
class MainModel
|
||||
{
|
||||
}
|
||||
}
|
||||
@@ -1,34 +0,0 @@
|
||||
using GalaSoft.MvvmLight;
|
||||
|
||||
namespace GeekDesk.ViewModel
|
||||
{
|
||||
/// <summary>
|
||||
/// This class contains properties that the main View can data bind to.
|
||||
/// <para>
|
||||
/// Use the <strong>mvvminpc</strong> snippet to add bindable properties to this ViewModel.
|
||||
/// </para>
|
||||
/// <para>
|
||||
/// You can also use Blend to data bind with the tool's support.
|
||||
/// </para>
|
||||
/// <para>
|
||||
/// See http://www.galasoft.ch/mvvm
|
||||
/// </para>
|
||||
/// </summary>
|
||||
public class MainViewModel : ViewModelBase
|
||||
{
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the MainViewModel class.
|
||||
/// </summary>
|
||||
public MainViewModel()
|
||||
{
|
||||
////if (IsInDesignMode)
|
||||
////{
|
||||
//// // Code runs in Blend --> create design time data.
|
||||
////}
|
||||
////else
|
||||
////{
|
||||
//// // Code runs "for real"
|
||||
////}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,9 +1,4 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Collections.ObjectModel;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using System.Collections.ObjectModel;
|
||||
|
||||
namespace GeekDesk.ViewModel
|
||||
{
|
||||
@@ -12,7 +7,7 @@ namespace GeekDesk.ViewModel
|
||||
|
||||
public MenuViewModel()
|
||||
{
|
||||
|
||||
|
||||
}
|
||||
|
||||
public ObservableCollection<Menu> GetMenus()
|
||||
@@ -23,7 +18,7 @@ namespace GeekDesk.ViewModel
|
||||
menus.Add(new Menu() { menu = "test3" });
|
||||
return menus;
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user