コード例 #1
0
ファイル: NotifyIconManager.cs プロジェクト: hirekoke/FloWin
        public NotifyIconManager(MainWindow mainWindow)
        {
            _notifyIcon = new NotifyIcon();
            _notifyIcon.Text = Properties.Resources.Str_AppName;
            _notifyIcon.Icon = Properties.Resources.Ico_App;

            // コンテキストメニューを作成
            _contextMenu = new ContextMenuStrip();

            // メニューを開くタイミングで選択可否を設定
            _contextMenu.Opened += (s, e) =>
            {
                for (int i = 0; i < _contextMenu.Items.Count; i++)
                {
                    var item = _contextMenu.Items[i];
                    var command = (DelegateCommand)item.Tag;
                    item.Enabled = command.CanExecute();
                }
            };

            _notifyIcon.ContextMenuStrip = _contextMenu;
            // アイコンを表示する
            _notifyIcon.Visible = true;
        }
コード例 #2
0
ファイル: App.xaml.cs プロジェクト: hirekoke/FloWin
        /// <summary>メイン処理を開始する</summary>
        private void Start()
        {
            // 設定読み込み
            Model.Config.Instance.Load();

            // フック開始
            GlobalHook.Hook();

            // モデル
            Model.SimModel _model = new Model.SimModel();

            // 窓の表示
            _win = new View.MainWindow(_model);
            _win.Show();

            // メインループ
            while (!_win.IsClosed)
            {
                _currentTick = Environment.TickCount;
                double diffms = Math.Floor(1000.0 / Model.Config.Instance.FrameRate);

                if (_currentTick < _nextTick)
                {
                    // 待ち
                }
                else
                {
                    // 処理
                    _model.Update();

                    if (Environment.TickCount >= _nextTick + diffms)
                    {
                        // フレームスキップ
                    }
                    else
                    {
                        // 描画
                        _win.Draw();
                    }

                    _frameCount++;
                    _lastCountTick = _currentTick;
                    while (_currentTick >= _nextTick)
                    {
                        _nextTick += (long)diffms;
                    }
                }

                // frame rate 計算
                if (_currentTick - _lastFpsTick >= 1000)
                {
                    _frameRate = _frameCount * 1000 / (double)(_currentTick - _lastFpsTick);
                    _frameCount = 0;
                    _lastFpsTick = _currentTick;
                }

                // UIメッセージ処理
                DoEvents();
            }

            // フック終了
            GlobalHook.Unhook();

            // 設定保存
            Model.Config.Instance.Save();
        }