예제 #1
0
파일: MessageBox.cs 프로젝트: Aggror/Stride
        protected override void OnInitialized(EventArgs e)
        {
            base.OnInitialized(e);

            CommandBindings.Add(new CommandBinding(ApplicationCommands.Copy, (_, __) => SafeClipboard.SetDataObject(Content ?? string.Empty, true)));
        }
예제 #2
0
        private void BindFileMenuCommands()
        {
            // Bind the new command
            {
                var cb = new CommandBinding(s_NewProjectCommand, CommandNewProjectExecuted, CommandNewProjectCanExecute);
                CommandBindings.Add(cb);

                InputBindings.Add(new InputBinding(s_NewProjectCommand, new KeyGesture(Key.N, ModifierKeys.Control)));

                // Set the command and set the command target to the control so that we don't run into focus issues
                // as given here:
                // http://social.msdn.microsoft.com/Forums/en-US/wpf/thread/f5de6ffc-fa03-4f08-87e9-77bbad752033
                miFileNew.Command       = s_NewProjectCommand;
                miFileNew.CommandTarget = this;
            }

            // Bind the open command
            {
                var cb = new CommandBinding(s_OpenProjectCommand, CommandOpenProjectExecuted, CommandOpenProjectCanExecute);
                CommandBindings.Add(cb);

                InputBindings.Add(new InputBinding(s_OpenProjectCommand, new KeyGesture(Key.O, ModifierKeys.Control)));

                // Set the command and set the command target to the control so that we don't run into focus issues
                // as given here:
                // http://social.msdn.microsoft.com/Forums/en-US/wpf/thread/f5de6ffc-fa03-4f08-87e9-77bbad752033
                miFileOpen.Command       = s_OpenProjectCommand;
                miFileOpen.CommandTarget = this;
            }

            // Bind the close command
            {
                var cb = new CommandBinding(s_CloseProjectCommand, CommandCloseProjectExecuted, CommandCloseProjectCanExecute);
                CommandBindings.Add(cb);

                InputBindings.Add(new InputBinding(s_CloseProjectCommand, new KeyGesture(Key.W, ModifierKeys.Control)));

                // Set the command and set the command target to the control so that we don't run into focus issues
                // as given here:
                // http://social.msdn.microsoft.com/Forums/en-US/wpf/thread/f5de6ffc-fa03-4f08-87e9-77bbad752033
                miFileClose.Command       = s_CloseProjectCommand;
                miFileClose.CommandTarget = this;
            }

            // Bind the save command
            {
                var cb = new CommandBinding(s_SaveCommand, CommandSaveProjectExecuted, CommandSaveProjectCanExecute);
                CommandBindings.Add(cb);

                InputBindings.Add(new InputBinding(s_SaveCommand, new KeyGesture(Key.S, ModifierKeys.Control)));

                // Set the command and set the command target to the control so that we don't run into focus issues
                // as given here:
                // http://social.msdn.microsoft.com/Forums/en-US/wpf/thread/f5de6ffc-fa03-4f08-87e9-77bbad752033
                miFileSave.Command       = s_SaveCommand;
                miFileSave.CommandTarget = this;
            }

            // Bind the save-as command
            {
                var cb = new CommandBinding(s_SaveAsCommand, CommandSaveAsProjectExecuted, CommandSaveAsProjectCanExecute);
                CommandBindings.Add(cb);

                InputBindings.Add(new InputBinding(s_SaveAsCommand, new KeyGesture(Key.F4, ModifierKeys.Alt | ModifierKeys.Control)));

                // Set the command and set the command target to the control so that we don't run into focus issues
                // as given here:
                // http://social.msdn.microsoft.com/Forums/en-US/wpf/thread/f5de6ffc-fa03-4f08-87e9-77bbad752033
                miFileSaveAs.Command       = s_SaveAsCommand;
                miFileSaveAs.CommandTarget = this;
            }

            // Bind the exit command
            {
                var cb = new CommandBinding(s_ExitCommand, CommandExitExecuted, CommandExitCanExecute);
                CommandBindings.Add(cb);

                InputBindings.Add(new InputBinding(s_ExitCommand, new KeyGesture(Key.F4, ModifierKeys.Alt)));

                // Set the command and set the command target to the control so that we don't run into focus issues
                // as given here:
                // http://social.msdn.microsoft.com/Forums/en-US/wpf/thread/f5de6ffc-fa03-4f08-87e9-77bbad752033
                miFileExit.Command       = s_ExitCommand;
                miFileExit.CommandTarget = this;
            }
        }
예제 #3
0
        }// end:CloseCommandHandler()


        // ------------------------ AddCommandBindings ------------------------
        /// <summary>
        ///     Registers menu commands (helper method).</summary>
        /// <param name="command"></param>
        /// <param name="handler"></param>
        private void AddCommandBindings(ICommand command, ExecutedRoutedEventHandler handler)
        {
            CommandBinding cmdBindings = new CommandBinding(command);
            cmdBindings.Executed += handler;
            CommandBindings.Add(cmdBindings);
        }// end:AddCommandBindings()
예제 #4
0
 protected override void OnInitialized(EventArgs e)
 {
     CommandBindings.Add(new CommandBinding(GlobalCommands.HideStatusCommand, OnCommandExecute, OnCommandCanExecute));
     base.OnInitialized(e);
 }
예제 #5
0
 public CloseableTabItem()
 {
     this.Style = (Style)FindResource("CloseableTabItemStyle");
     CommandBindings.Add(new CommandBinding(TabItemCommand.DeleteCommand, OnDelete, OnDeleteExecute));
 }
예제 #6
0
 public PropertyGrid()
 {
     EditorDefinitions   = new EditorDefinitionCollection();
     PropertyDefinitions = new PropertyDefinitionCollection();
     CommandBindings.Add(new CommandBinding(PropertyGridCommands.ClearFilter, ClearFilter, CanClearFilter));
 }
예제 #7
0
 public void AddCommand(ICommand _command, ExecutedRoutedEventHandler _method)
 {
     CommandBindings.Add(new CommandBinding(_command, _method));
 }
예제 #8
0
 public SourcePanel()
 {
     CommandBindings.Add(new CommandBinding(ApplicationCommands.Stop, new ExecutedRoutedEventHandler(StopCommandHandler)));
 }
 public LabelPrintSchemaConfigHelpWindow()
 {
     InitializeComponent();
     this.WindowStartupLocation = WindowStartupLocation.CenterOwner;
     CommandBindings.Add(new CommandBinding(ApplicationCommands.Close, (send, e) => { this.Close(); }));
 }
예제 #10
0
        private void InitHandlers()
        {
            AddHandler(ButtonBase.ClickEvent, new RoutedEventHandler(this.Button_Click));

            CommandBindings.Add(new CommandBinding(ApplicationCommands.Copy, new ExecutedRoutedEventHandler(ExecuteCopy)));
        }
예제 #11
0
 public SearchBar()
 {
     CommandBindings.Add(new CommandBinding(ControlCommands.Search, (s, e) => OnSearchStarted()));
 }
예제 #12
0
        internal void InitializeMainMenu()
        {
            #region project commands

            bNewPIMDiagram.Command = new cmdNewPIMDiagram(this, bNewPIMDiagram);
            bNewPSMDiagram.Command = new cmdNewPSMDiagram(this, bNewPSMDiagram);
            bNewProject.Command    = new cmdNewProject(this, bNewProject);
            bSaveProject.Command   = new cmdSaveProject(this, bSaveProjectAs);
            bSaveProjectAs.Command = new cmdSaveProjectAs(this, bSaveProjectAs);
            bOpenProject.Command   = new cmdOpenProject(this, bOpenProject);
            bDeleteDiagram.Command = new cmdDeleteDiagram(this, bDeleteDiagram);

            bUndo.Command = CurrentProject.GetModelController().UndoCommand;
            bRedo.Command = CurrentProject.GetModelController().RedoCommand;

            #endregion

            #region delete commands

            bDeleteFromDiagram.Command    = new cmdDeleteFromDiagram(this, bDeleteFromDiagram);
            bDeleteFromModel.Command      = new cmdDeleteFromModel(this, bDeleteFromModel);
            bDeleteFromPSMDiagram.Command = new cmdDeleteFromPSMDiagram(this, bDeleteFromPSMDiagram);
            bDeleteContainer.Command      = new cmdDeleteContainer(this, bDeleteContainer);

            #endregion

            #region alignment commands

            bAlignTop.Command             = new cmdAlign(this, bAlignTop, EAlignment.Top);
            bAlignBottom.Command          = new cmdAlign(this, bAlignBottom, EAlignment.Bottom);
            bAlignLeft.Command            = new cmdAlign(this, bAlignLeft, EAlignment.Left);
            bAlignRight.Command           = new cmdAlign(this, bAlignRight, EAlignment.Right);
            bAlignCenterV.Command         = new cmdAlign(this, bAlignCenterV, EAlignment.CenterV);
            bAlignCenterH.Command         = new cmdAlign(this, bAlignCenterH, EAlignment.CenterH);
            bDistributeVertical.Command   = new cmdAlign(this, bDistributeVertical, EAlignment.DistributeV);
            bDistributeHorizontal.Command = new cmdAlign(this, bDistributeHorizontal, EAlignment.DistributeH);

            #endregion

            #region PIM commands

            bClass.Command           = new cmdNewClass(this, bClass);
            bCommentary.Command      = new cmdComment(this, bCommentary);
            bAssociate.Command       = new cmdAssociate(this, bAssociate);
            bPIMAddAttribute.Command = new cmdAddAttribute(this, bPIMAddAttribute);
            bPIMAddOperation.Command = new cmdAddOperation(this, bPIMAddOperation);
            bDeriveNew.Command       = new cmdDeriveNew(this, bDeriveNew);
            bDeriveExisting.Command  = new cmdDeriveExisting(this, bDeriveExisting);
            connectionCommands       = new List <IDraggedConnectionProcessor>();

            bGeneralization.Command = new cmdDragConnection(this, bGeneralization, EDraggedConnectionType.Generalization)
            {
                ToggleButtonGroup = connectionCommands
            };
            bAssociation.Command = new cmdDragConnection(this, bAssociation, EDraggedConnectionType.Association)
            {
                ToggleButtonGroup = connectionCommands
            };
            bAggregation.Command = new cmdDragConnection(this, bAggregation, EDraggedConnectionType.Aggregation)
            {
                ToggleButtonGroup = connectionCommands
            };
            bComposition.Command = new cmdDragConnection(this, bComposition, EDraggedConnectionType.Composition)
            {
                ToggleButtonGroup = connectionCommands
            };

            connectionCommands.Add((IDraggedConnectionProcessor)bGeneralization.Command);
            connectionCommands.Add((IDraggedConnectionProcessor)bAssociation.Command);
            connectionCommands.Add((IDraggedConnectionProcessor)bAggregation.Command);
            connectionCommands.Add((IDraggedConnectionProcessor)bComposition.Command);

            connectionButtons = new[] { bGeneralization, bAssociation, bAggregation, bComposition };

            bAssociationClass.Command = new cmdAssociationClass(this, bAssociationClass);

            // this command is for draging from Navigator window
            CommandBindings.Add(new CommandBinding(cmdIncludeClass, cmdIncludeClass.Executed));

            #endregion

            #region PSM commands

            cmdMoveToLeft  cmdMoveToLeft  = new cmdMoveToLeft(this, bMoveToLeft);
            cmdMoveToRight cmdMoveToRight = new cmdMoveToRight(this, bMoveToRight);
            cmdMoveToLeft.cmdMoveToRight = cmdMoveToRight;
            cmdMoveToRight.cmdMoveToLeft = cmdMoveToLeft;
            bMoveToLeft.Command          = cmdMoveToLeft;
            bMoveToRight.Command         = cmdMoveToRight;

            bPSMAddAttribute.Command = new cmdAddPSMAttribute(this, bPSMAddAttribute);

            bPSMCommentary.Command      = new cmdComment(this, bPSMCommentary);
            bAddChildren.Command        = new cmdAddChildren(this, bAddChildren);
            bAddAttributes.Command      = new cmdAddAttributes(this, bAddAttributes);
            bClassChoice.Command        = new cmdIntroduceClassUnion(this, bClassChoice);
            bContentChoice.Command      = new cmdIntroduceContentChoice(this, bContentChoice);
            bAttributeContainer.Command = new cmdIntroduceAttributeContainer(this, bAttributeContainer);
            bContentContainer.Command   = new cmdIntroduceContentContainer(this, bContentContainer);
            bAddSpecifications.Command  = new cmdAddSpecializations(this, bAddSpecifications);
            bXMLSchema.Command          = new cmdXmlSchema(this, bXMLSchema);
            bSampleDocument.Command     = new cmdSampleDocument(this, bSampleDocument);
            #endregion

            #region PSM tree traversing commands

            cmdSelectParent       = new cmdSelectParent(this, null);
            cmdSelectRightSibling = new cmdSelectRightSibling(this, null);
            cmdSelectLeftSibling  = new cmdSelectLeftSibling(this, null);
            cmdSelectChild        = new cmdSelectChild(this, null);

            #endregion

            #region Reverse Engineering
            bXSDtoPSM.Command = new cmdXSDtoPSM(this, bXSDtoPSM);
            #endregion

            ShortcutActionManager.Actions.Clear();
            ShortcutActionManager.RegisterStandardShortcuts();
        }
예제 #13
0
        public ClientManager()
        {
            Instance = this;

            InitializeComponent();

            // Check the directories exist
            if (!Directory.Exists(Settings.Default.LibraryPath) || !Directory.Exists(Settings.Default.LibraryPath + @"\backgrounds\"))
            {
                // Will handle the create of everything here
                Directory.CreateDirectory(Settings.Default.LibraryPath + @"\backgrounds");
                Directory.CreateDirectory(Settings.Default.LibraryPath + @"\Layouts");
                Directory.CreateDirectory(Settings.Default.LibraryPath + @"\Uploads\Media");
            }

            // Create a cachemanager
            SetCacheManager();

            ShowSplashScreen();

            // Change the default Proxy class
            OptionForm.SetGlobalProxy();

            Closed += delegate
            {
                Closing();
                Environment.Exit(0);
            };

            MyCommand.InputGestures.Add(new KeyGesture(Key.Q, ModifierKeys.Control));

            CommandBindings.Add(new CommandBinding(MyCommand, MyCommandExecuted));

            InitializeComponent();

            Switcher.ClientManager = this;


            Switcher.Switch(AdvertPlayer.Instance);

            var customerPage = CustomerPage.Instance;

            // Setup the proxy information
            OptionForm.SetGlobalProxy();

            _statLog = new StatLog();

            this.StartKeepAliveThread();

            this.StartMessageReceiveThread();

            try
            {
                // Create the Schedule
                _schedule = new Schedule(App.UserAppDataPath + "\\" + Settings.Default.ScheduleFile, ClientManager.Instance.CacheManager);

                // Bind to the schedule change event - notifys of changes to the schedule
                _schedule.ScheduleChangeEvent += ScheduleScheduleChangeEvent;

                // Initialize the other schedule components
                _schedule.InitializeComponents();
            }
            catch (Exception ex)
            {
                Debug.WriteLine(ex.Message, LogType.Error.ToString());
                MessageBox.Show("Fatal Error initialising AdvertPlayer", "Fatal Error");

                Environment.Exit(0);
            }
        }
예제 #14
0
 public DialogTitle()
 {
     CommandBindings.Add(new CommandBinding(Commands.ClosePopup, ClosePopup_Executed, ClosePopup_CanExecute));
 }
예제 #15
0
        private void Window_Loaded(object sender, RoutedEventArgs e)
        {
            if (!Login.IsOpen)
            {
                Login frm1 = new Login();
                frm1.ShowDialog();
            }
            if (App.Principal != null)
            {
                txtuser.Text = string.Format("当前用户:{0}    权限{1}", App.Principal.Identity.Name, App.Principal.ToString());
                //确定中控员权限
            }
            #region  显示缺省界面
            if (Tag != null && !string.IsNullOrEmpty(Tag.ToString()))
            {
                var            Wintypes = Tag.ToString().TrimEnd(';');
                ContentControl ctrl     = Activator.CreateInstance(Type.GetType(Wintypes)) as ContentControl;
                if (ctrl != null)
                {
                    ScaleControl(ctrl);
                    ctrl.Loaded   += new RoutedEventHandler(ctrl_Loaded);
                    ctrl.Unloaded += new RoutedEventHandler(ctrl_Unloaded);
                    dict[Wintypes] = ctrl;
                    cvs1.Child     = ctrl;
                    this.Title     = Wintypes;
                }
            }
            #endregion
            #region  显示状态栏时间、显示PLC连接状态、与PLC看门狗通讯
            DispatcherTimer ShowTimer = new DispatcherTimer();
            ShowTimer.Interval = new TimeSpan(0, 0, 1);
            ShowTimer.Tick    += (s, e1) =>
            {
                txttime.InvokeAsynchronously(delegate { txttime.Text = DateTime.Now.ToString(); });
                p1_lamp1.Fill = App.Server.Drivers.Any(x => x.IsClosed) ? Brushes.Red : Brushes.Green;
            };
            ShowTimer.Start();
            #endregion
            #region  绑定到Server
            lock (this)
            {
                _valueChangedList = this.BindingToServer(App.Server);
            }
            BindingTagWindow(this);
            CommandBindings.AddRange(BindingCommandHandler());
            var condlist = App.Server.ActivedConditionList as ObservableCollection <ICondition>;
            if (condlist != null)
            {
                condlist.CollectionChanged += new NotifyCollectionChangedEventHandler(condlist_CollectionChanged);
            }
            var tag = App.Server["__CoreEvent"];
            if (tag != null)
            {
                tag.ValueChanged += (s, e1) =>
                {
                    if (tag != null)
                    {
                        App.Events.ReverseEnqueue(string.Format("{0}     {1}     {2}", tag.GetTagName(), DateTime.Now, tag.ToString()));
                        if (tag.ToString().Contains("错误:"))
                        {
                            MessageBox.Show(tag.ToString(), "错误!", MessageBoxButton.OK, MessageBoxImage.Error);
                        }
                    }
                };
            }

            #endregion
        }
예제 #16
0
        public MainWindow()
        {
            Directory.CreateDirectory("Logs");
            FLog = new ServiceFunctions.UI.Log.FileLogger("Logs\\Log_" + ServiceFunctions.UI.Get_TimeNow_String() + ".txt");
            FLog.Log("Programm started...");

            //Init timers
            TimerForRenew           = new DispatcherTimer();
            TimerForRenew.Interval  = new TimeSpan(0, 0, 0, 0, 100); //100 ms
            TimerForRenew.Tick     += TimerForRenew_Tick;
            TimerForRenew.IsEnabled = false;

            WhiteBalanceTimer           = new DispatcherTimer();
            WhiteBalanceTimer.Interval  = new TimeSpan(0, 0, 0, 0, 1000); //1000 ms
            WhiteBalanceTimer.Tick     += WhiteBalanceTimer_Tick;
            WhiteBalanceTimer.IsEnabled = false;

            Timer_recording           = new DispatcherTimer();
            Timer_recording.Interval  = new TimeSpan(0, 0, 0, 0, 100);
            Timer_recording.Tick     += Timer_recording_Tick;
            Timer_recording.IsEnabled = false;

            T1           = new DispatcherTimer();
            T1.Interval  = new TimeSpan(0, 0, 0, 0, 50);
            T1.Tick     += T1_Tick;
            T1.IsEnabled = false;

            Timer_camera_checker           = new DispatcherTimer();
            Timer_camera_checker.Interval  = new TimeSpan(0, 0, 0, 0, 100);
            Timer_camera_checker.Tick     += Timer_camera_checker_Tick;
            Timer_camera_checker.IsEnabled = false;// true;

            BGW_LiveVideoRecording         = new BackgroundWorker();
            BGW_LiveVideoRecording.DoWork += BGW_LiveVideoRecording_DoWork;
            BGW_LiveVideoRecording.WorkerSupportsCancellation = true;
            BGW_LiveVideoRecording.WorkerReportsProgress      = false;

            BGW_CamRestarter = new BackgroundWorker();
            //BGW_CamRestarter.DoWork += BGW_CamRestarter_DoWork;
            //BGW_CamRestarter.WorkerSupportsCancellation = false;
            //BGW_CamRestarter.WorkerReportsProgress = false;

            InitializeComponent();

            windowHandle = new WindowInteropHelper(this).EnsureHandle();

            //Set main view model
            mainViewModel = new ViewModels.MainViewModel();
            mainViewModel.WindowHandle  = windowHandle;
            mainViewModel.DeviceOpened += WhenDeviceOpened;

            DataContext = mainViewModel;
            mainViewModel.PropertyChanged += MainViewModel_PropertyChanged;

            ChB_WhiteBalanceAuto.Checked   += ChB_WhiteBalanceAuto_CheckedChanged;
            ChB_WhiteBalanceAuto.Unchecked += ChB_WhiteBalanceAuto_CheckedChanged;

            FullScreenRoutedCommand.InputGestures.Add(new KeyGesture(Key.F, ModifierKeys.Alt));
            QuiteRoutedCommand.InputGestures.Add(new KeyGesture(Key.Q, ModifierKeys.Alt));
            CRoutedCommand.InputGestures.Add(new KeyGesture(Key.C, ModifierKeys.Alt));
            CommandBindings.Add(new CommandBinding(FullScreenRoutedCommand, FullScreenSwitchKey));
            CommandBindings.Add(new CommandBinding(QuiteRoutedCommand, QuiteKey));
            CommandBindings.Add(new CommandBinding(CRoutedCommand, CodecPropKey));

            B_FS_Switcher_form = Host.Child.Controls[0] as System.Windows.Forms.Button; //new System.Windows.Forms.Button();

            bmpFS_on  = Bitmap.FromFile("FS_on_form.png");
            bmpFS_off = Bitmap.FromFile("FS_off_form.png");
        }
예제 #17
0
 public DrawerHost()
 {
     CommandBindings.Add(new CommandBinding(OpenDrawerCommand, OpenDrawerHandler));
     CommandBindings.Add(new CommandBinding(CloseDrawerCommand, CloseDrawerHandler));
 }
예제 #18
0
        public ClientWindow(
            [NotNull] IClientApplication app,
            [NotNull] IAppContext appContext,
            [NotNull] IAudioEngine audioEngine,
            [NotNull] IMusicPlayer musicPlayer,
            [NotNull] ISoundPlayer soundPlayer,
            [NotNull] IEventAggregator eventAggregator,
            [NotNull] INavigationCommandsProxy navigationCommands)
        {
            if (app == null)
            {
                throw new ArgumentNullException("app");
            }
            if (appContext == null)
            {
                throw new ArgumentNullException("appContext");
            }
            if (audioEngine == null)
            {
                throw new ArgumentNullException("audioEngine");
            }
            if (musicPlayer == null)
            {
                throw new ArgumentNullException("musicPlayer");
            }
            if (soundPlayer == null)
            {
                throw new ArgumentNullException("soundPlayer");
            }
            if (eventAggregator == null)
            {
                throw new ArgumentNullException("eventAggregator");
            }
            if (navigationCommands == null)
            {
                throw new ArgumentNullException("navigationCommands");
            }

            _app                 = app;
            _appContext          = appContext;
            _audioEngine         = audioEngine;
            _musicPlayer         = musicPlayer;
            _soundPlayer         = soundPlayer;
            _eventAggregator     = eventAggregator;
            _navigationCommands  = navigationCommands;
            _waitCursorLock      = new object();
            _settingsChangeScope = new StateScope();

            _defaultCursor = new Cursor(
                Path.Combine(
                    Environment.CurrentDirectory,
                    @"Resources\Cursors\cursor.cur"));

            InitializeComponent();

            /*
             * Officially, we only support video resolutions of 1024x768 and up.  However, considering
             * 1280x720 is one of the standard High Definition resolutions, we will adjust our minimum
             * size constraints to accomodate it.
             */
            // ReSharper disable CompareOfFloatsByEqualityOperator
            if (SystemParameters.PrimaryScreenWidth != 1280d ||
                (SystemParameters.PrimaryScreenHeight != 720d))
            {
                MinHeight = 720;
                Height    = 720;
            }
            // ReSharper restore CompareOfFloatsByEqualityOperator

            Cursor = _defaultCursor;

            Loaded      += OnLoaded;
            SizeChanged += OnSizeChanged;

            _eventAggregator.GetEvent <TurnStartedEvent>().Subscribe(OnTurnStarted, ThreadOption.UIThread);
            _eventAggregator.GetEvent <GameStartedEvent>().Subscribe(OnGameStarted, ThreadOption.UIThread);
            _eventAggregator.GetEvent <GameEndedEvent>().Subscribe(OnGameEnded, ThreadOption.UIThread);
            _eventAggregator.GetEvent <GameEndingEvent>().Subscribe(OnGameEnding, ThreadOption.UIThread);
            _eventAggregator.GetEvent <ClientDisconnectedEvent>().Subscribe(OnClientDisconnected, ThreadOption.UIThread);
            _eventAggregator.GetEvent <GameEndedEvent>().Subscribe(OnGameEnded, ThreadOption.UIThread);
            _eventAggregator.GetEvent <AllTurnEndedEvent>().Subscribe(OnAllTurnEnded, ThreadOption.UIThread);
            _eventAggregator.GetEvent <ChatMessageReceivedEvent>().Subscribe(OnChatMessageReceived, ThreadOption.UIThread);

            ModelessDialogsRegion.SelectionChanged += OnModelessDialogsRegionSelectionChanged;
            ModalDialogsRegion.SelectionChanged    += OnModalDialogsRegionSelectionChanged;

            ClientSettings.Current.EnableAntiAliasingChanged += OnEnableAntiAliasingSettingsChanged;

            ApplyAntiAliasingSettings();

            InputBindings.Add(
                new KeyBinding(
                    CollectGarbageCommand,
                    new KeyGesture(Key.G, ModifierKeys.Control | ModifierKeys.Shift)));

            InputBindings.Add(
                new KeyBinding(
                    ClientCommands.EscapeCommand,
                    new KeyGesture(Key.Escape, ModifierKeys.None)));

            InputBindings.Add(
                new KeyBinding(
                    _navigationCommands.ActivateScreen,
                    new KeyGesture(Key.F1, ModifierKeys.None))
            {
                CommandParameter = StandardGameScreens.GalaxyScreen
            });

            InputBindings.Add(
                new KeyBinding(
                    _navigationCommands.ActivateScreen,
                    new KeyGesture(Key.F2, ModifierKeys.None))
            {
                CommandParameter = StandardGameScreens.ColonyScreen
            });

            InputBindings.Add(
                new KeyBinding(
                    _navigationCommands.ActivateScreen,
                    new KeyGesture(Key.F3, ModifierKeys.None))
            {
                CommandParameter = StandardGameScreens.DiplomacyScreen
            });

            InputBindings.Add(
                new KeyBinding(
                    _navigationCommands.ActivateScreen,
                    new KeyGesture(Key.F4, ModifierKeys.None))
            {
                CommandParameter = StandardGameScreens.ScienceScreen
            });

            InputBindings.Add(
                new KeyBinding(
                    _navigationCommands.ActivateScreen,
                    new KeyGesture(Key.F5, ModifierKeys.None))
            {
                CommandParameter = StandardGameScreens.IntelScreen
            });

            InputBindings.Add(
                new KeyBinding(
                    ToggleFullScreenModeCommand,
                    Key.Enter,
                    ModifierKeys.Alt));

            CommandBindings.Add(
                new CommandBinding(
                    ClientCommands.EscapeCommand,
                    ExecuteEscapeCommand));

            CommandBindings.Add(
                new CommandBinding(
                    ToggleFullScreenModeCommand,
                    (s, e) => ToggleFullScreenMode()));

            CommandBindings.Add(
                new CommandBinding(
                    CollectGarbageCommand,
                    (s, e) =>
            {
                var process    = Process.GetCurrentProcess();
                var workingSet = process.WorkingSet64;
                var heapSize   = GC.GetTotalMemory(false);

                GameLog.Client.General.Info("Forcing garbage collection...");

                GC.Collect(GC.MaxGeneration, GCCollectionMode.Forced);
                GC.WaitForPendingFinalizers();

                process.Refresh();

                GameLog.Client.General.InfoFormat(
                    "[working set [{0:#,#,} K -> {1:#,#,} K], managed heap [{2:#,#,} K -> {3:#,#,} K]]",
                    workingSet,
                    process.WorkingSet64,
                    heapSize,
                    GC.GetTotalMemory(false));

                GameLog.Client.GameData.DebugFormat(
                    "[working set [{0:#,#,} K -> {1:#,#,} K], managed heap [{2:#,#,} K -> {3:#,#,} K]]",
                    workingSet,
                    process.WorkingSet64,
                    heapSize,
                    GC.GetTotalMemory(false));
            }));

            InputBindings.Add(
                new KeyBinding(
                    ClientCommands.AutoTurnCommand,
                    Key.A,
                    ModifierKeys.Alt));

            InputBindings.Add(
                new KeyBinding(
                    ClientCommands.ColonyInfoScreen,
                    Key.F8,
                    ModifierKeys.None));

            InputBindings.Add(
                new KeyBinding(
                    ClientCommands.ColorInfoScreen,
                    Key.F6,
                    ModifierKeys.Alt));

            InputBindings.Add(
                new KeyBinding(
                    ClientCommands.ErrorTxtCommand,
                    Key.E,
                    ModifierKeys.Control));

            InputBindings.Add(
                new KeyBinding(
                    ClientCommands.LogTxtCommand,
                    Key.L,
                    ModifierKeys.Control));

            InputBindings.Add(
                new KeyBinding(
                    ClientCommands.OptionsCommand,
                    Key.O,
                    ModifierKeys.Control));

            // CRTL+S makes saved file "_manual_save"
            InputBindings.Add(
                new KeyBinding(
                    ClientCommands.SaveGame,
                    Key.S,
                    ModifierKeys.Control));

            InputBindings.Add(
                new KeyBinding(
                    ClientCommands.EndTurn,
                    Key.T,
                    ModifierKeys.Control));

            CommandBindings.Add(
                new CommandBinding(
                    ClientCommands.AutoTurnCommand,
                    (s, e) =>
            {
                var service      = ServiceLocator.Current.GetInstance <IPlayerOrderService>();
                service.AutoTurn = !service.AutoTurn;
                if (service.AutoTurn)
                {
                    ClientCommands.EndTurn.Execute(null);
                }
            }));

            var settings = ClientSettings.Current;

            Width  = settings.ClientWindowWidth;
            Height = settings.ClientWindowHeight;

            CheckFullScreenSettings();
        }
예제 #19
0
파일: FileDialog.cs 프로젝트: rox00/WPF
 public FileDialog()
 {
     CommandBindings.Add(new CommandBinding(SelectFileCommand, OnSelectFileCommandExecuted, OnCanExecuteFileCommand));
 }
예제 #20
0
 private void RegisterCommands()
 {
     CommandBindings.Add(new CommandBinding(Commands.LongRunningCommand, ExecutedLongRunningCommand));
 }
예제 #21
0
        private void bindHotkeys()
        {
            try
            {
                // ****************************************************************************************************
                // File Commands
                RoutedCommand newTabBinding = new RoutedCommand();
                newTabBinding.InputGestures.Add(new KeyGesture(Key.N, ModifierKeys.Control));
                CommandBindings.Add(new CommandBinding(newTabBinding, CreateNewTabCommand, Hotkeys_CanExecute));

                RoutedCommand openFromFileBinding = new RoutedCommand();
                openFromFileBinding.InputGestures.Add(new KeyGesture(Key.O, ModifierKeys.Control));
                CommandBindings.Add(new CommandBinding(openFromFileBinding, OpenFromFileCommand, Hotkeys_CanExecute));

                RoutedCommand saveBinding = new RoutedCommand();
                saveBinding.InputGestures.Add(new KeyGesture(Key.S, ModifierKeys.Control));
                CommandBindings.Add(new CommandBinding(saveBinding, SaveCommand, Hotkeys_CanExecute));

                RoutedCommand saveAllBinding = new RoutedCommand();
                saveAllBinding.InputGestures.Add(new KeyGesture(Key.S, ModifierKeys.Shift | ModifierKeys.Control));
                CommandBindings.Add(new CommandBinding(saveAllBinding, SaveAllCommand, Hotkeys_CanExecute));

                // ****************************************************************************************************
                // Project Commands

                RoutedCommand runSimulationBinding = new RoutedCommand();
                runSimulationBinding.InputGestures.Add(new KeyGesture(Key.F5));
                CommandBindings.Add(new CommandBinding(runSimulationBinding, RunSimulationCommand, Hotkeys_CanExecute));

                // ****************************************************************************************************
                // Other Commands
                RoutedCommand closeTabBinding = new RoutedCommand();
                closeTabBinding.InputGestures.Add(new KeyGesture(Key.W, ModifierKeys.Control));
                CommandBindings.Add(new CommandBinding(closeTabBinding, CloseTabCommand, Hotkeys_CanExecute));

                RoutedCommand deleteBinding = new RoutedCommand();
                deleteBinding.InputGestures.Add(new KeyGesture(Key.Delete));
                CommandBindings.Add(new CommandBinding(deleteBinding, DeleteShapeCommand, Hotkeys_CanExecute));


                RoutedCommand copyBinding = new RoutedCommand();
                copyBinding.InputGestures.Add(new KeyGesture(Key.C, ModifierKeys.Control));
                CommandBindings.Add(new CommandBinding(copyBinding, CopyComand));

                RoutedCommand cutBinding = new RoutedCommand();
                cutBinding.InputGestures.Add(new KeyGesture(Key.X, ModifierKeys.Control));
                CommandBindings.Add(new CommandBinding(cutBinding, CutComand));

                RoutedCommand pasteBinding = new RoutedCommand();
                pasteBinding.InputGestures.Add(new KeyGesture(Key.V, ModifierKeys.Control));
                CommandBindings.Add(new CommandBinding(pasteBinding, PasteComand));


                RoutedCommand undoBinding = new RoutedCommand();
                undoBinding.InputGestures.Add(new KeyGesture(Key.Z, ModifierKeys.Control));
                CommandBindings.Add(new CommandBinding(undoBinding, UndoCommand));

                RoutedCommand redoBinding = new RoutedCommand();
                redoBinding.InputGestures.Add(new KeyGesture(Key.Y, ModifierKeys.Control));
                CommandBindings.Add(new CommandBinding(redoBinding, RedoComand));
            }
            catch (Exception err)
            {
                // #TODO
                // enable logger
                MessageBox.Show(err.Message);
            }
        }
예제 #22
0
 public PopupBase()
 {
     CommandBindings.Add(new CommandBinding(PinPopupCommand, PinHandler));
     CommandBindings.Add(new CommandBinding(ExtractDdlCommand, ExtractDdlHandler));
     MaxHeight = SystemParameters.WorkArea.Height;
 }
예제 #23
0
 public MainWindow(object content)
 {
     InitializeComponent();
     contentPresenter.Content = content;
     CommandBindings.Add(new CommandBinding(ApplicationCommands.Close, (s, e) => Close(), (s, e) => e.CanExecute = true));
 }
예제 #24
0
 public StepBar()
 {
     CommandBindings.Add(new CommandBinding(ControlCommands.Next, (s, e) => Next()));
     CommandBindings.Add(new CommandBinding(ControlCommands.Prev, (s, e) => Prev()));
     ItemContainerGenerator.StatusChanged += ItemContainerGenerator_StatusChanged;
 }
예제 #25
0
        public MainWindow()
        {
            InitializeComponent();

            guardado = true;

            RoutedCommand Ctrl_N = new RoutedCommand();

            Ctrl_N.InputGestures.Add(new KeyGesture(Key.N, ModifierKeys.Control));
            CommandBindings.Add(new CommandBinding(Ctrl_N, m_archivo_nuevo_Click));

            RoutedCommand Ctrl_O = new RoutedCommand();

            Ctrl_O.InputGestures.Add(new KeyGesture(Key.O, ModifierKeys.Control));
            CommandBindings.Add(new CommandBinding(Ctrl_O, m_archivo_abrir_Click));

            RoutedCommand Ctrl_S = new RoutedCommand();

            Ctrl_S.InputGestures.Add(new KeyGesture(Key.S, ModifierKeys.Control));
            CommandBindings.Add(new CommandBinding(Ctrl_S, m_archivo_Guardar_Click));

            RoutedCommand Ctrl_P = new RoutedCommand();

            Ctrl_P.InputGestures.Add(new KeyGesture(Key.P, ModifierKeys.Control));
            CommandBindings.Add(new CommandBinding(Ctrl_P, m_archivo_imprimir_Click));

            RoutedCommand Alt_F4 = new RoutedCommand();

            Alt_F4.InputGestures.Add(new KeyGesture(Key.F4, ModifierKeys.Control));
            CommandBindings.Add(new CommandBinding(Alt_F4, m_archivo_Guardar_Click));

            RoutedCommand Ctrl_X = new RoutedCommand();

            Ctrl_X.InputGestures.Add(new KeyGesture(Key.X, ModifierKeys.Control));
            CommandBindings.Add(new CommandBinding(Ctrl_X, m_editar_cortar_Click));

            RoutedCommand Ctrl_C = new RoutedCommand();

            Ctrl_C.InputGestures.Add(new KeyGesture(Key.C, ModifierKeys.Control));
            CommandBindings.Add(new CommandBinding(Ctrl_C, m_editar_copiar_Click));

            RoutedCommand Ctrl_V = new RoutedCommand();

            Ctrl_V.InputGestures.Add(new KeyGesture(Key.V, ModifierKeys.Control));
            CommandBindings.Add(new CommandBinding(Ctrl_V, m_editar_pegar_Click));

            RoutedCommand Ctrl_B = new RoutedCommand();

            Ctrl_B.InputGestures.Add(new KeyGesture(Key.B, ModifierKeys.Control));
            CommandBindings.Add(new CommandBinding(Ctrl_B, m_fuente_negrita_Click));

            RoutedCommand Ctrl_K = new RoutedCommand();

            Ctrl_K.InputGestures.Add(new KeyGesture(Key.K, ModifierKeys.Control));
            CommandBindings.Add(new CommandBinding(Ctrl_K, m_fuente_cursiva_Click));

            RoutedCommand Ctrl_U = new RoutedCommand();

            Ctrl_U.InputGestures.Add(new KeyGesture(Key.U, ModifierKeys.Control));
            CommandBindings.Add(new CommandBinding(Ctrl_U, m_fuente_subrayado_Click));

            RoutedCommand Ctrl_Mas = new RoutedCommand();

            Ctrl_Mas.InputGestures.Add(new KeyGesture(Key.Add, ModifierKeys.Control));
            CommandBindings.Add(new CommandBinding(Ctrl_Mas, m_fuente_Aumentar_tam_Click));

            RoutedCommand Ctrl_Menos = new RoutedCommand();

            Ctrl_Menos.InputGestures.Add(new KeyGesture(Key.Subtract, ModifierKeys.Control));
            CommandBindings.Add(new CommandBinding(Ctrl_Menos, m_fuente_Disminuir_tam_Click));

            m_contenido.Focus();
        }
예제 #26
0
 public Calculator()
 {
     CommandBindings.Add(new CommandBinding(CalculatorCommands.CalculatorButtonClick, ExecuteCalculatorButtonClick));
     AddHandler(MouseDownEvent, new MouseButtonEventHandler(Calculator_OnMouseDown), true);
 }
예제 #27
0
        public MainWindow()
        {
            // Comment Out Below to disable console.
            using (StreamWriter sw = new StreamWriter(".temp"))
            {
                sw.Write(newWindows.Count);
                sw.Close();
            }
            //ConsoleManager.Show();
            ApplicationCommands.SaveAs.InputGestures.Add(new KeyGesture(Key.S, ModifierKeys.Control | ModifierKeys.Shift));
            this.Title           = "Untitled - CodeBreaker";
            sfd.InitialDirectory = "C:\\";
            ofd.InitialDirectory = "C:\\";
            ofd.Filter           = "All Files (*.*)|*.*";
            sfd.Filter           = "All Files (*.*)|*.*";
            ofd.FilterIndex      = 1;
            sfd.FilterIndex      = 1;
            NewWindow.InputGestures.Add(new KeyGesture(Key.N, ModifierKeys.Control | ModifierKeys.Alt));
            New.InputGestures.Add(new KeyGesture(Key.N, ModifierKeys.Control));
            SearchWithBing.InputGestures.Add(new KeyGesture(Key.E, ModifierKeys.Control));
            InitializeComponent();
            CommandBinding oBinding = new CommandBinding
            {
                Command = ApplicationCommands.Open
            };
            CommandBinding sBinding = new CommandBinding
            {
                Command = ApplicationCommands.SaveAs
            };
            CommandBinding sbinding = new CommandBinding
            {
                Command = ApplicationCommands.Save
            };
            CommandBinding undoBinding = new CommandBinding
            {
                Command = ApplicationCommands.Undo
            };
            CommandBinding cutBinding = new CommandBinding
            {
                Command = ApplicationCommands.Cut
            };
            CommandBinding copyBinding = new CommandBinding
            {
                Command = ApplicationCommands.Copy
            };
            CommandBinding pasteBinding = new CommandBinding
            {
                Command = ApplicationCommands.Paste
            };
            CommandBinding deleteBinding = new CommandBinding
            {
                Command = ApplicationCommands.Delete
            };
            CommandBinding searchWithBingBinding = new CommandBinding
            {
                Command = SearchWithBing
            };
            CommandBinding findBinding = new CommandBinding
            {
                Command = ApplicationCommands.Find
            };

            oBinding.Executed                += Event;
            oBinding.CanExecute              += OpenCanExecute;
            sBinding.Executed                += SaveAs;
            sBinding.CanExecute              += SaveAsCanExecute;
            sbinding.Executed                += Save;
            sbinding.CanExecute              += SaveCanExecute;
            undoBinding.CanExecute           += undoCanExecute;
            cutBinding.CanExecute            += cutCanExecute;
            copyBinding.CanExecute           += copyCanExecute;
            pasteBinding.CanExecute          += pasteCanExecute;
            deleteBinding.Executed           += Delete;
            deleteBinding.CanExecute         += deleteCanExecute;
            searchWithBingBinding.Executed   += searchWithBing;
            searchWithBingBinding.CanExecute += searchCanExecute;

            findBinding.CanExecute += findCanExecute;
            CommandBindings.Add(oBinding);
            CommandBindings.Add(sBinding);
            CommandBindings.Add(sbinding);
            CommandBindings.Add(undoBinding);
            CommandBindings.Add(cutBinding);
            CommandBindings.Add(copyBinding);
            CommandBindings.Add(pasteBinding);
            CommandBindings.Add(deleteBinding);
            CommandBindings.Add(searchWithBingBinding);
            CommandBindings.Add(findBinding);
            textbox.Focus();
            var timer = new DispatcherTimer
            {
                Interval = TimeSpan.FromMilliseconds(1)
            };

            timer.Tick += MainLoop;
            timer.Start();
        }
예제 #28
0
 public MainWindow()
 {
     InitializeComponent();
     CommandBindings.Add(new CommandBinding(ApplicationCommands.New, HandleNewCommand));
 }
예제 #29
0
 /// <summary>
 /// Constructor</summary>
 public PropertyGridToolBar()
 {
     CommandBindings.Add(new CommandBinding(ShowAlphaSorted, ExecuteSort, CanExecuteSort));
     CommandBindings.Add(new CommandBinding(ShowCategorized, ExecuteGroup, CanExecuteGroup));
 }
예제 #30
0
 public SearchBar()
 {
     CommandBindings.Add(new CommandBinding(ControlCommands.Clear, (s, e) => _textBox.Text = string.Empty));
     CommandBindings.Add(new CommandBinding(ControlCommands.Search, (s, e) => OnSearchStarted()));
 }