示例#1
0
 public static LocalInfo GetSingle()
 {
     if (instance == null)
     {
         instance = new LocalInfo();
     }
     return(instance);
 }
示例#2
0
        public MainWindow()
        {
            InitializeComponent();

            instance = this;

            // 初始化本地数据
            local   = LocalInfo.GetSingle();
            allTask = new List <TextToggle>();

            // 模拟一个任务小任务
            //var tmp = CreateTask("Big");
            //DispatcherTimer time = new DispatcherTimer();
            //time.Tick += (sender, e) =>
            //{
            //    tmp.CreateItem("Small");
            //};

            //time.Interval = new TimeSpan(0, 0, 0, 1);
            //time.Start();

            local.LoadXML();
            if (local.LoadConfig())
            {
                PowerBoot.IsChecked = local.powerBootIsOn;
                this.Left           = local.left;
                this.Top            = local.top;
                this.Height         = local.height;
            }
            else
            {
                local.powerBootIsOn = PowerBoot.IsChecked;
                local.left          = this.Left;
                local.top           = this.Top;
            }

            // 托盘
            icon         = new System.Windows.Forms.NotifyIcon();
            icon.Icon    = new System.Drawing.Icon("Images/mIco.ico");
            icon.Text    = "便签";
            icon.Visible = true;
            icon.Click  += (obj, e) =>
            {
                //    if (this.WindowState == WindowState.Normal)
                //    {
                //        this.WindowState = WindowState.Minimized;
                //    }
                //    else
                //    if (this.WindowState == WindowState.Minimized)
                //    {
                //        //    如果当前是最小化,就前置
                //        this.WindowState = WindowState.Normal;
                //    }
                this.Topmost = true;
                this.Topmost = false;
            };
        }
示例#3
0
 // 落下
 private void Window_Drop(object sender, DragEventArgs e)
 {
     if (e.Data.GetDataPresent(DataFormats.FileDrop))
     {
         object data = e.Data.GetData(DataFormats.FileDrop);
         string path = ((System.Array)data).GetValue(0).ToString();
         LocalInfo.GetSingle().LoadXML(path);
     }
 }
示例#4
0
        // 功能暂定 - 右键退出
        private void Window_MouseRightButtonDown(object sender, MouseButtonEventArgs e)
        {
            MessageBoxResult result = MessageBox.Show(this, "确定退出?", "退出便签?", MessageBoxButton.YesNo);

            if (result == MessageBoxResult.Yes)
            {
                LocalInfo.GetSingle().ChangedPowerBoot(PowerBoot.IsChecked, this.Left, this.Top, this.Height);
                icon.Dispose();
                this.Close();
            }
        }
示例#5
0
        // 打开文件按钮
        private void OpenBtn_Click(object sender, RoutedEventArgs e)
        {
            OpenFileDialog openFileDialog = new OpenFileDialog();

            openFileDialog.Title       = "选择要打开的 XML 文件";
            openFileDialog.Filter      = "xml文件|*.xml";
            openFileDialog.FilterIndex = 1;
            openFileDialog.FileName    = string.Empty;
            openFileDialog.Multiselect = false;  // 不能选择多个文件
            openFileDialog.DefaultExt  = "xml";
            //openFileDialog.FileOk += (obj, e1) => {  };
            if (openFileDialog.ShowDialog() == false)
            {
                return;
            }
            string path = openFileDialog.FileName; // 获取文件路径

            LocalInfo.GetSingle().LoadXML(path);   // 打开该文件
        }
示例#6
0
        // 开机启动
        private void PowerBoot_Checked(object sender, RoutedEventArgs e)
        {
            CheckBox cb = sender as CheckBox;

            LocalInfo.GetSingle().ChangedPowerBoot(cb.IsChecked);
        }
示例#7
0
 // 保存按钮
 private void SavaBtn_Click(object sender, RoutedEventArgs e)
 {
     LocalInfo.GetSingle().SavaXML();
 }