private void InitializeNotifyIcon()
        {
            this.notifyIconManager = new NotifyIconManager(this)
            {
                NotifyIcon =
                {
                    Icon = this.Icon,
                    Text = this.Text
                }
            };

            this.TextChanged += (s, a) => this.notifyIconManager.NotifyIcon.Text = this.Text;

            var showHideMenuItem = new ToolStripMenuItem("Show/Hide");

            showHideMenuItem.Font   = new Font(showHideMenuItem.Font, FontStyle.Bold);
            showHideMenuItem.Click += (s, a) => this.notifyIconManager.SwitchFormState();

            this.notifyIconManager.NotifyIcon.ContextMenuStrip.Items.Add(showHideMenuItem);
            this.notifyIconManager.NotifyIcon.ContextMenuStrip.Items.Add("-");
            this.notifyIconManager.NotifyIcon.ContextMenuStrip.Items.Add(
                "Exit",
                null,
                (s, a) => this.notifyIconManager.CloseForm());
        }
Exemple #2
0
        protected override void OnExit(ExitEventArgs e)
        {
            if (!_isFirstInstance)
            {
                return;
            }
            _isRunning.ReleaseMutex();

            NotifyIconManager.GetInstance().Dispose();
            base.OnExit(e);
        }
Exemple #3
0
        public ConfigureMenuHandler(ConfigurationUpdater configurationUpdater, NotifyIconManager notifyIconManager)
        {
            this.configurationUpdater = configurationUpdater ?? throw new ArgumentNullException(nameof(configurationUpdater));

            if (notifyIconManager is null)
            {
                throw new ArgumentNullException(nameof(notifyIconManager));
            }

            notifyIconManager.NotifyIcon.DoubleClick += NotifyIcon_DoubleClick;
        }
        public MainWindow()
        {
            InitializeComponent();
            var utilityService = new UtilityService();

            notifyIconManager = new NotifyIconManager(utilityService, this);
            notifyIconManager.RefreshTrayItems();
            StartupUIConfigure();
            DataContext = mainViewModel = new MainViewModel(utilityService, notifyIconManager);
            Loaded     += MainWindow_Loaded;
        }
 public override void Process(ProcessorArgs args)
 {
     NotifyIconManager notifyIconManager = NotifyIconManager.ActualManager;
       if (args.ClipboardEvent)
       {
     args.CurrentNotifyIconChangerClient = notifyIconManager.GlobalNotifyIconChangerClient;
       }
       else
       {
     args.CurrentNotifyIconChangerClient = args.OriginatorIsGlobalIcon
                                         ? notifyIconManager.GlobalNotifyIconChangerClient
                                         : notifyIconManager.NotifyIconChangerClient;
       }
 }
Exemple #6
0
        private async void StartupAsync(object sender, StartupEventArgs e)
        {
            //实现单实例
            InitializeAsSingle();
            //托盘图标
            NotifyIconManager.GetInstance();
            //更新
            await UpdateService.GetInstance().HandleUpdateCheckAsync();

            //读取设置
            await SettingService.GetInstance().RetriveSettingsAsync();

            //主题色
            ThemeManager.Initialize();
        }
Exemple #7
0
        void Init()
        {
            Console.WriteLine("Started Init...");
            _current = this;

            _notifyiconmanager = new NotifyIconManager(AddNewNotification);
            SetPanelPos(PanelPosition);
            //Dispatcher.Invoke(() => SetTopMost());
            //_drawer = new AppDrawer();
            DesktopD d = new DesktopD();

            d.Show();
            ClockTimer.Elapsed += ClockTimer_Elapsed;
            ClockTimer.Start();
            d.InitializeDesktop();
            _drawer = new AppDrawer();
        }
Exemple #8
0
        void Init()
        {
            Config.Current = new Config(Directory.GetCurrentDirectory() + "\\Config", "config", ".json");

            Dispatcher.Invoke(
              () =>
              {
                  usermenu.Header = Environment.UserName;
                  _appChooser = new AppChooser();

                  _current = this;
                  DesktopD D = new DesktopD();
                  D.Show();
                  Clock.Header = DateTime.Now.ToString("HH:mm:ss");

                  ClockTimer.Elapsed += (object sender, ElapsedEventArgs e) => { Dispatcher.Invoke(() => Clock.Header = DateTime.Now.ToString("HH:mm:ss")); };
                  ClockTimer.Start();
                  menu.ContextMenu = new ContextMenu();
                  MenuItem m = new MenuItem();
                  m.Header = "Choose Items...";
                  m.Click += (object sender, RoutedEventArgs e) => { _appChooser = new AppChooser(); _appChooser.Show(); };
                  menu.ContextMenu.Items.Add(m);
                  try
                  {
                      Volume.Value = defaultPlaybackDevice.Volume;
                  }
                  catch
                  {

                  }
                  D.InitializeDesktop();
                  Dock d = new Dock();
                  d.Show();
              });

            WindowManager wm = new WindowManager(AddNewTaskItem);
            _notifyiconmanager = new NotifyIconManager(AddNewNotification);
            _applist = new List<xApp>();
            SetPanelPos(PanelPosition);
            _appListing = new AppsListing();
            new Thread(new ThreadStart(GetApps)).Start();

           // Dispatcher.Invoke(() => SetTopMost());
        }
Exemple #9
0
        public void Initialize(ApplicationStartupHandler handler, IDIContext container)
        {
            _manager = container.Resolve <IUIManager>();

            _manager.CreateUIElement(NotifyIconManagerId, () =>
            {
                var notifyIconManager = new NotifyIconManager(new[] { "app", "debug", "close" }, "app")
                {
                    Text    = "Gobchat",
                    Icon    = Gobchat.Resources.GobIcon,
                    Visible = true
                };

                var closeMenu    = new ToolStripMenuItem(Resources.Module_NotifyIcon_UI_Close);
                closeMenu.Click += OnEvent_MenuItem_Close;
                notifyIconManager.AddMenuToGroup("close", "close", closeMenu);

                return(notifyIconManager);
            });
        }
Exemple #10
0
 public UpdateChecker(NotifyIconManager manager) => nim = manager;
Exemple #11
0
 public ExitMenuHandler(NotifyIconManager notifyIconManager)
 {
     this.notifyIconManager = notifyIconManager ?? throw new ArgumentNullException(nameof(notifyIconManager));
 }
Exemple #12
0
        public MainWindow(
            //OptionsWindow optionsWindow,
            IOptionsMonitor <ConfigModelApp> configApp,
            ICollection <Card> allCards,
            MainWindowVM viewModel,
            ProcessMonitor processMonitor,
            LogFileZipper zipper,
            ServerApiCaller api,
            StartupShortcutManager startupManager,
            LogSplitter logSplitter,
            MtgaResourcesLocator resourcesLocator,
            FileMonitor fileMonitor,
            DraftHelper draftHelper,
            //LogProcessor logProcessor,
            ReaderMtgaOutputLog readerMtgaOutputLog,
            //CacheSingleton<ICollection<Card>> allCards,
            InGameTracker inMatchTracker,
            ExternalProviderTokenManager tokenManager,
            PasswordHasher passwordHasher,
            NotifyIconManager notifyIconManager,
            CacheSingleton <Dictionary <string, DraftRatings> > draftRatings
            )
        {
            this.configApp = configApp.CurrentValue;
            //optionsWindow.Init(this.configApp);
            //optionsWindow.Owner = Window.GetWindow(this);
            //this.optionsWindow = optionsWindow;

            this.reader         = readerMtgaOutputLog;
            this.processMonitor = processMonitor;
            processMonitor.OnProcessMonitorStatusChanged += OnProcessMonitorStatusChanged;
            this.zipper           = zipper;
            this.api              = api;
            this.startupManager   = startupManager;
            this.logSplitter      = logSplitter;
            this.resourcesLocator = resourcesLocator;
            this.fileMonitor      = fileMonitor;
            fileMonitor.OnFileSizeChangedNewText += OnFileSizeChangedNewText;
            this.draftHelper = draftHelper;
            //this.logProcessor = logProcessor;
            this.inGameTracker     = inMatchTracker;
            this.tokenManager      = tokenManager;
            this.passwordHasher    = passwordHasher;
            this.notifyIconManager = notifyIconManager;
            this.draftRatings      = draftRatings;
            this.resourcesLocator.LocateLogFilePath(this.configApp);
            this.resourcesLocator.LocateGameClientFilePath(this.configApp);

            fileMonitor.SetFilePath(this.configApp.LogFilePath);
            //viewModel.ValidateUserId(this.configApp.UserId);
            viewModel.Opacity = this.configApp.Opacity;
            vm          = viewModel;
            DataContext = vm;

            InitializeComponent();

            ucWelcome.Init(tokenManager);
            ucPlaying.Init(vm, this.configApp.WindowSettingsOpponentCards);

            //trayIcon = new System.Windows.Forms.NotifyIcon { Text = "MTGAHelper Tracker" };
            //trayIcon.Icon = new System.Drawing.Icon(Application.GetResourceStream(new Uri("pack://application:,,,/Assets/Images/wcC.ico")).Stream);
            //trayIcon.MouseClick += new System.Windows.Forms.MouseEventHandler(TrayIcon_MouseClick);
            //trayIcon.ContextMenu = new System.Windows.Forms.ContextMenu(new System.Windows.Forms.MenuItem[]
            //{
            //    new System.Windows.Forms.MenuItem("Quit", new EventHandler(TrayIcon_Quit))
            //});

            statusBarTop.Init(this, vm /*, draftHelper, logProcessor, this.configApp.UserId,*/);
            ucReady.Init(this.configApp.GameFilePath);
            ucDraftHelper.Init(allCards, vm.DraftingVM);
            //ucPlaying.Init(vm);

            ucDraftHelper.SetPopupRatingsSource(this.configApp.ShowLimitedRatings, this.configApp.ShowLimitedRatingsSource);

            this.processMonitor.Start(new System.Threading.CancellationToken());
            this.fileMonitor.Start(new System.Threading.CancellationToken());

            var timer = new DispatcherTimer {
                Interval = TimeSpan.FromMilliseconds(200)
            };

            timer.Tick += (object sender, EventArgs e) =>
            {
                vm.SetCardsDraftFromBuffered();
                vm.SetCardsInMatchTrackingFromBuffered();
            };
            timer.Start();

            var timerTokenRefresh = new DispatcherTimer {
                Interval = TimeSpan.FromMinutes(9)
            };

            timerTokenRefresh.Tick += (object sender, EventArgs e) =>
            {
                RefreshAccessToken();
            };
            timerTokenRefresh.Start();
        }