Ejemplo n.º 1
0
        public MainWindow(ExplorerWindowCleanerClient ewClient)
        {
            _ewClient = ewClient;
            InitializeComponent();

            DataContext = this;

            this.Closing += (sender, args) =>
            {
                args.Cancel     = true;
                this.Visibility = Visibility.Hidden;
                _ewClient.AppConfig.WindowBounds = new Rect(this.Left, this.Top, this.Width, this.Height);
            };


            if (!_ewClient.AppConfig.WindowBounds.IsAllZero())
            {
                var windowBounds = _ewClient.AppConfig.WindowBounds;
                Top    = windowBounds.Top;
                Left   = windowBounds.Left;
                Width  = windowBounds.Width;
                Height = windowBounds.Height;
            }
            SwitchViewLabel = ClosedWindows;
        }
Ejemplo n.º 2
0
        /// <summary>
        ///     System.Windows.Application.Startup イベント を発生させます。
        /// </summary>
        /// <param name="e">イベントデータ を格納している StartupEventArgs</param>
        protected override void OnStartup(StartupEventArgs e)
        {
            base.OnStartup(e);
            ShutdownMode = ShutdownMode.OnExplicitShutdown;

            _client = new ExplorerWindowCleanerClient(Assembly.GetExecutingAssembly());
            _client.Initialize();

            _notifyIcon = new NotifyIconContainer(_client);
        }
Ejemplo n.º 3
0
        public NotifyIconContainer(ExplorerWindowCleanerClient client)
        {
            _ewClient = client;

            _mainWindow = new MainWindow(_ewClient);
            InitializeComponent();

            // コンテキストメニューの設定
            SetContextMenuStartUp();
            toolStripMenuItemOpen.Click       += toolStripMenuItemOpen_Click;
            toolStripMenuItemExit.Click       += toolStripMenuItemExit_Click;
            toolStripMenuItemAutoClose.Click  += ToolStripMenuItemAutoCloseOnClick;
            toolStripMenuItemStartup.Click    += ToolStripMenuItemStartupOnClick;
            toolStripMenuItemAutoClose.Checked = client.AppConfig.IsAutoCloseUnused;

            _ewClient.Cleaned += (sender, args) =>
            {
                _mainWindow.Dispatcher.Invoke(() =>
                {
                    notifyIcon.Text = string.Format("ExplorerWindowCleaner - {0} Windows", args.WindowCount);
                    toolStripMenuItemAutoClose.Text = _ewClient.AppConfig.IsAutoCloseUnused
                        ? string.Format("Auto Close Unused expire:{0}",
                                        args.ExpireDateTime.ToString("yyyy-MM-dd HH:mm:ss"))
                        : "Auto Close Unused";
                    if (_ewClient.AppConfig.IsNotifyCloseWindow && args.CloseInfos.Count > 0)
                    {
                        notifyIcon.ShowBalloonTip(3000,
                                                  string.Format("{0} Windows Closed.", args.CloseInfos.Count),
                                                  string.Format("{0}", string.Join("\n", args.CloseInfos.Select(x => string.Format("{0} [{1}]", x.WindowTitle, x.CloseReason.ToString())))), ToolTipIcon.Info);
                    }
                    _mainWindow.NowWindowCount    = args.WindowCount;
                    _mainWindow.MaxWindowCount    = args.MaxWindowCount;
                    _mainWindow.PinedCount        = args.PinedCount;
                    _mainWindow.TotalClosedWindow = args.TotalCloseWindowCount;
                    if (args.IsUpdated)
                    {
                        _mainWindow.UpdateView();
                    }
                });
            };
        }
Ejemplo n.º 4
0
 public ExplorerWindowCleanerClientOperator(ExplorerWindowCleanerClient explorerWindowCleanerClient, ExplorerCleaner explorerCleaner)
 {
     Client          = explorerWindowCleanerClient;
     ExplorerCleaner = explorerCleaner;
 }