ViewModel/MainViewModel.cs

(开头部分) 5KB

这里只显示每个文件的开头 60 行。登录后可以解锁完整代码。

using KeyFinder.Models;
using System;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.IO;
using System.Linq;
using System.Windows;
using Utilities;

namespace KeyFinder.ViewModel
{
    public class MainViewModel: BaseViewModel
    {
        string path = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "KeyFinder.info");
        List<Data> _list;
        public ObservableCollection<Data> DataCollection { get; set; }

        public SimpleCommand RefreshCommand { get; set; }

        public SimpleCommand FindCommand { get; set; }

        public SimpleCommand AddCommand { get; set; }

        public SimpleCommand EditCommand { get; set; }

        public SimpleCommand DeleteCommand { get; set; }

        public MainViewModel()
        {
            DataCollection = new ObservableCollection<Data>();
            RefreshCommand = new SimpleCommand(ExecuteRefresh);
            FindCommand = new SimpleCommand(ExecuteFind);
            AddCommand = new SimpleCommand(ExecuteAdd);
            EditCommand = new SimpleCommand(ExecuteEdit);
            DeleteCommand = new SimpleCommand(ExecuteDelete);

            Load();
        }

        private void ExecuteDelete(object obj)
        {
            try
            {
                if (obj == null) return;
                Data d = (Data)obj;
                if(MessageBox.Show("删除后将无法恢复,确定要删除吗?", "提问", MessageBoxButton.YesNo, MessageBoxImage.Question) == MessageBoxResult.Yes)
                {
                    this._list.Remove(d);
                    this.DataCollection.Remove(d);
                    Save(this._list);
                    Load();
                }
            }
            catch (Exception)
            {
            }
        }

        private void ExecuteEdit(object obj)
        {
后面还有 113 行代码,解锁后查看完整代码

24 小时内免费解锁 3 个项目,之后 1 算力/个。 规则说明

AI 解读 AI

登录后可用,每次 10 算力,解读结果公开显示在下面。

还没有人解读过这个文件。