コード例 #1
0
		public MainWindow()
		{
			try
			{
				InitializeComponent();

				if (User.Default.MinimiseToSystemTray)
				{
					//add tray icon
					_tray = new TrayMainWindows(this);

					//add global key
					_hotkey = new HotKeyMainWindows(this, ModifierKeys.Windows | ModifierKeys.Alt, System.Windows.Forms.Keys.T);
				}

                //add view on change file
                _changefile = new ObserverChangeFile();
                _changefile.OnFileTaskListChange += () => Dispatcher.Invoke(DispatcherPriority.Normal, new Action(delegate() { this.Refresh(); }));

                //CheckUpdate new version
                _checkupdate = new CheckUpdate();
                _checkupdate.OnCheckedUpdateVersion += (string version) => Dispatcher.BeginInvoke(new CheckUpdate.CheckUpdateVersion(this.ShowUpdateMenu), version);
                _checkupdate.Check();

				webBrowser1.Navigate("about:blank");

				// migrate the user settings from the previous version, if necessary
				if (User.Default.FirstRun)
				{
					User.Default.Upgrade();
					User.Default.FirstRun = false;
					User.Default.Save();
				}

				Log.LogLevel = User.Default.DebugLoggingOn ? LogLevel.Debug : LogLevel.Error;

				this.Height = User.Default.WindowHeight;
				this.Width = User.Default.WindowWidth;
				this.Left = User.Default.WindowLeft;
				this.Top = User.Default.WindowTop;

				if (!string.IsNullOrEmpty(User.Default.FilePath))
					LoadTasks(User.Default.FilePath);

				FilterAndSort((SortType)User.Default.CurrentSort);

				lbTasks.Focus();

				string startupFile = ((App)App.Current).StartupFile;
				if (!string.IsNullOrEmpty(startupFile))
					LoadTasks(startupFile);
			}
			catch (Exception ex)
			{
				var msg = "An error occurred while intialising the application";
				Log.Error(msg, ex);
				MessageBox.Show(ex.Message, msg, MessageBoxButton.OK);
			}
			
		}
コード例 #2
0
        public MainWindow()
        {
            try
            {
                InitializeComponent();

                if (User.Default.MinimiseToSystemTray)
                {
                    //add tray icon
                    _tray = new TrayMainWindows(this);

                    //add global key
                    _hotkey = new HotKeyMainWindows(this, ModifierKeys.Windows | ModifierKeys.Alt, System.Windows.Forms.Keys.T);
                }

                //add view on change file
                _changefile = new ObserverChangeFile();
                _changefile.OnFileTaskListChange += () => Dispatcher.Invoke(DispatcherPriority.Normal, new Action(delegate() { this.Refresh(); }));

                //CheckUpdate new version
                _checkupdate = new CheckUpdate();
                _checkupdate.OnCheckedUpdateVersion += (string version) => Dispatcher.BeginInvoke(new CheckUpdate.CheckUpdateVersion(this.ShowUpdateMenu), version);
                _checkupdate.Check();

                webBrowser1.Navigate("about:blank");

                // migrate the user settings from the previous version, if necessary
                if (User.Default.FirstRun)
                {
                    User.Default.Upgrade();
                    User.Default.FirstRun = false;
                    User.Default.Save();
                }

                Log.LogLevel = User.Default.DebugLoggingOn ? LogLevel.Debug : LogLevel.Error;

                this.Height = User.Default.WindowHeight;
                this.Width  = User.Default.WindowWidth;
                this.Left   = User.Default.WindowLeft;
                this.Top    = User.Default.WindowTop;

                if (!string.IsNullOrEmpty(User.Default.FilePath))
                {
                    LoadTasks(User.Default.FilePath);
                }

                FilterAndSort((SortType)User.Default.CurrentSort);

                lbTasks.Focus();
            }
            catch (Exception ex)
            {
                var msg = "An error occurred while intialising the application";
                Log.Error(msg, ex);
                MessageBox.Show(ex.Message, msg, MessageBoxButton.OK, MessageBoxImage.Error);
            }
        }
コード例 #3
0
		public MainWindowViewModel(MainWindow window)
		{
			_window = window;

			Log.LogLevel = User.Default.DebugLoggingOn ? LogLevel.Debug : LogLevel.Error;

			//add view on change file
			_changefile = new ObserverChangeFile();
			_changefile.OnFileTaskListChange += () => _window.Dispatcher.BeginInvoke(new Action(delegate() { Refresh(); }));

			SortType = (SortType)User.Default.CurrentSort;

			if (!string.IsNullOrEmpty(User.Default.FilePath))
				LoadTasks(User.Default.FilePath);
		}
コード例 #4
0
        protected virtual void Dispose(bool disposing)
        {
            if (!_disposed)
            {
                if (disposing)
                {
                    if (_tray != null)
                    {
                        _tray.Dispose();
                        _tray = null;
                    }

                    if (_hotkey != null)
                    {
                        _hotkey.Dispose();
                        _hotkey = null;
                    }

                    if (_changefile != null)
                    {
                        _changefile.Dispose();
                        _changefile = null;
                    }
                }

                _disposed = true;
            }
        }