Example #1
1
 public MWindow()
 {
     try
     {
         InitializeComponent();
         Closing += new CancelEventHandler(MWindow_Closing);
         worker.DoWork += new DoWorkEventHandler(worker_DoWork);
         worker.RunWorkerCompleted += new RunWorkerCompletedEventHandler(worker_RunWorkerCompleted);
         dt.Interval = TimeSpan.FromSeconds(1);
         dt.Tick += new EventHandler(dt_Tick);
         foldingManager = FoldingManager.Install(textEditor.TextArea);
         foldingStrategy = new XmlFoldingStrategy();
         textEditor.TextChanged += new EventHandler(textEditor_TextChanged);
         if (App.StartUpCommand != "" && App.StartUpCommand != null)
         {
             openFile(App.StartUpCommand);
         }
         KeyGesture renderKeyGesture = new KeyGesture(Key.F5);
         KeyBinding renderCmdKeybinding = new KeyBinding(Commands.Render, renderKeyGesture);
         this.InputBindings.Add(renderCmdKeybinding);
         status.Text = "Ready!";
     }
     catch (Exception e)
     {
         MessageBox.Show(e.Message);
     }
 }
Example #2
0
        // -------------------------------
        // Window operations
        // -------------------------------
        /// <summary>
        /// (Constructor) Initializes main window and sets up shortcut keys.
        /// </summary>
        public MainWindow()
        {
            InitializeComponent();

            // Bind "New" command
            CommandBinding cb = new CommandBinding( commandNew , new_Executed );
            KeyGesture kg = new KeyGesture( Key.N , ModifierKeys.Control );
            InputBinding ib = new InputBinding( commandNew , kg );
            this.CommandBindings.Add( cb );
            this.InputBindings.Add( ib );

            // Bind "Open" command
            cb = new CommandBinding( commandOpen , open_Executed );
            kg = new KeyGesture( Key.O , ModifierKeys.Control );
            ib = new InputBinding( commandOpen , kg );
            this.CommandBindings.Add( cb );
            this.InputBindings.Add( ib );

            // Bind "Save" command
            cb = new CommandBinding( commandSave , save_Executed );
            kg = new KeyGesture( Key.S , ModifierKeys.Control );
            ib = new InputBinding( commandSave , kg );
            this.CommandBindings.Add( cb );
            this.InputBindings.Add( ib );

            // Bind "SaveAll" command
            cb = new CommandBinding( commandSaveAll , saveAll_Executed );
            kg = new KeyGesture( Key.S , ModifierKeys.Alt );
            ib = new InputBinding( commandSaveAll , kg );
            this.CommandBindings.Add( cb );
            this.InputBindings.Add( ib );

            // Bind "Exit" command
            cb = new CommandBinding( commandExit , exit_Executed );
            kg = new KeyGesture( Key.X , ModifierKeys.Control );
            ib = new InputBinding( commandExit , kg );
            this.CommandBindings.Add( cb );
            this.InputBindings.Add( ib );

            // Bind "Delete" command
            cb = new CommandBinding( commandDelete , deleteBlock_Executed );
            kg = new KeyGesture( Key.Delete );
            ib = new InputBinding( commandDelete , kg );
            this.CommandBindings.Add( cb );
            this.InputBindings.Add( ib );

            // Bind "Generate Mesh" command
            cb = new CommandBinding( commandGenerateMesh , generateMesh_Executed );
            kg = new KeyGesture( Key.F7 );
            ib = new InputBinding( commandGenerateMesh , kg );
            this.CommandBindings.Add( cb );
            this.InputBindings.Add( ib );

            // Bind "Run Analysis" command
            cb = new CommandBinding( commandRunAnalysis , run_Executed );
            kg = new KeyGesture( Key.F5 );
            ib = new InputBinding( commandRunAnalysis , kg );
            this.CommandBindings.Add( cb );
            this.InputBindings.Add( ib );
        }
Example #3
0
 public PadWindow()
 {
     InitializeComponent();
     KeyGesture F5Key = new KeyGesture(Key.F5, ModifierKeys.None);
     KeyBinding F5CmdKeybinding = new KeyBinding(RunRoutedCommand, F5Key);
     this.InputBindings.Add(F5CmdKeybinding);
 }
Example #4
0
        /// <summary>Registers a given shortcut for a specific views and connect that shortcut with a given action.</summary>
        /// <param name="viewTypes">The view types.</param>
        /// <param name="gesture">The shortcut.</param>
        /// <param name="command">The command.</param>
        public static void RegisterShortcut(Type[] viewTypes, KeyGesture gesture, ICommand command)
        {
            Contract.Requires(command != null);

            foreach (var type in viewTypes)
                RegisterShortcut(type, gesture, command);
        }
Example #5
0
        /// <summary>Registers a given shortcut for a specific view and connect that shortcut with a given action.</summary>
        /// <param name="viewType">The type of the view.</param>
        /// <param name="gesture">The shortcut.</param>
        /// <param name="command">The command.</param>
        public static void RegisterShortcut(Type viewType, KeyGesture gesture, ICommand command)
        {
            Contract.Requires(command != null);

            CommandManager.RegisterClassInputBinding(
                viewType, new InputBinding(command, gesture));
        }
Example #6
0
 public AbstractMenuItem(string header, int priority, ImageSource icon = null, ICommand command = null,
                         KeyGesture gesture = null, bool isCheckable = false)
 {
     Priority = priority;
     IsSeparator = false;
     Header = header;
     Key = header;
     Command = command;
     IsCheckable = isCheckable;
     Icon = icon;
     if (gesture != null && command != null)
     {
         Application.Current.MainWindow.InputBindings.Add(new KeyBinding(command, gesture));
         InputGestureText = gesture.DisplayString;
     }
     if (isCheckable)
     {
         IsChecked = false;
     }
     if (Header == "SEP")
     {
         Key = "SEP" + sepCount.ToString();
         Header = "";
         sepCount++;
         IsSeparator = true;
     }
 }
Example #7
0
 /// <summary>
 /// Sets the gesture property.
 /// </summary>
 /// <param name="element">The element.</param>
 /// <param name="value">The value.</param>
 public static void SetGesture(UIElement element, KeyGesture value)
 {
     if (element != null)
     {
         element.SetValue(GestureProperty, value);
     }
 }
Example #8
0
 /// <summary>
 /// Initializes a new instance of the <see cref="RelayCommand"/> class.
 /// </summary>
 /// <param name="kg">The associated <see cref="KeyGesture"/>.</param>
 /// <param name="registeredType">Type of the registered command.</param>
 /// <param name="execute">The action to execute.</param>
 /// <param name="canExecute">The predicate that determines if the command can be executed.</param>
 /// <example>
 /// <code><![CDATA[
 /// var cmd = new RelayCommand(new KeyGesture(Key.F7), typeof(DesignerItemWithData), 
 ///        this.CommandNameExecuted, this.CommandNameEnabled);
 /// ]]>
 /// </code>
 /// </example>
 public RelayCommand(KeyGesture kg, Type registeredType, Action<object> execute, Predicate<object> canExecute)
 {
     this.execute = execute;
     this.canExecute = canExecute;
     this.InputGestures.Add(kg);
     InputBinding ib = new InputBinding(this, kg);
     CommandManager.RegisterClassInputBinding(registeredType, ib);
 }
Example #9
0
        public CommandMenuItem(Command command, StandardMenuItem parent)
        {
            _command = command;
            _keyGesture = IoC.Get<ICommandKeyGestureService>().GetPrimaryKeyGesture(_command.CommandDefinition);
            _parent = parent;

            _listItems = new List<StandardMenuItem>();
        }
Example #10
0
		/// <summary>
		/// Registers a given shortcut for a specific views and connect that shortcut with a given action.
		/// </summary>
		/// <param name="viewTypes">The view types.</param>
		/// <param name="gesture">The shortcut.</param>
		/// <param name="command">The command.</param>
		public static void RegisterShortcut(Type[] viewTypes, KeyGesture gesture, ICommand command)
		{
			if (command == null)
				throw new ArgumentNullException(nameof(command));

			foreach (var type in viewTypes)
				RegisterShortcut(type, gesture, command);
		}
Example #11
0
		/// <summary>
		/// Registers a given shortcut for a specific view and connect that shortcut with a given action.
		/// </summary>
		/// <param name="viewType">The type of the view.</param>
		/// <param name="gesture">The shortcut.</param>
		/// <param name="command">The command.</param>
		public static void RegisterShortcut(Type viewType, KeyGesture gesture, ICommand command)
		{
			if (command == null)
				throw new ArgumentNullException(nameof(command));

			CommandManager.RegisterClassInputBinding(
				viewType, new InputBinding(command, gesture));
		}
Example #12
0
 public Command(CommandDefinitionBase commandDefinition)
 {
     _commandDefinition = commandDefinition;
     Text = commandDefinition.Text;
     ToolTip = commandDefinition.ToolTip;
     IconSource = commandDefinition.IconSource;
     _keyGesture = commandDefinition.KeyGesture;
 }
Example #13
0
        public CommandToolBarItem(ToolBarItemDefinition toolBarItem, Command command, IToolBar parent)
        {
            _toolBarItem = toolBarItem;
            _command = command;
            _keyGesture = IoC.Get<ICommandKeyGestureService>().GetPrimaryKeyGesture(_command.CommandDefinition);
            _parent = parent;

            command.PropertyChanged += OnCommandPropertyChanged;
        }
Example #14
0
		public TestWindow()
		{
			this.InitializeComponent();
			
			CommandBinding cb = new CommandBinding(MyCommand, MyCommandExecute);
			this.CommandBindings.Add(cb);
			KeyGesture kg = new KeyGesture(Key.Escape, ModifierKeys.Shift);
			InputBinding ib = new InputBinding(MyCommand, kg);
			this.InputBindings.Add(ib);
		}
        /// <summary>
        /// Creates the input gesture.
        /// </summary>
        /// <param name="element">The element.</param>
        /// <param name="key">The key to listen to.</param>
        /// <param name="modifierKeys">The modifier keys to listen to.</param>
        /// <param name="execute">The command to execute.</param>
        /// <param name="canExecute">The command to check if the main command can execute.</param>
        public static void CreateInputGesture(this UIElement element, Key key, ModifierKeys modifierKeys, ExecutedRoutedEventHandler execute, CanExecuteRoutedEventHandler canExecute)
        {
            var command = new RoutedUICommand();
            var binding = new CommandBinding(command, execute, canExecute);

            var gesture = new KeyGesture(key, modifierKeys);
            var keyBinding = new KeyBinding(command, gesture);

            element.CommandBindings.Add(binding);
            element.InputBindings.Add(keyBinding);
        }
Example #16
0
        public MainWindow()
        {
            InitializeComponent();

            RootFrame.NavigationService.Navigate(new Uri("/Pages/MainPage.xaml", UriKind.Relative));

            var timestampCommand = new DelegateCommand(OnTimestampKeyBinding);
            var timestampGesture = new KeyGesture(Key.T, ModifierKeys.Alt);
            var timestampBinding = new KeyBinding(timestampCommand, timestampGesture);
            InputBindings.Add(timestampBinding);
        }
 /// <summary>
 ///     Initializes a new instance of the <see cref="MenuItemViewModel" /> class.
 /// </summary>
 /// <param name="header">The header.</param>
 /// <param name="priority">The priority.</param>
 /// <param name="icon">The icon.</param>
 /// <param name="command">The command.</param>
 /// <param name="gesture">The gesture.</param>
 /// <param name="isCheckable">if set to <c>true</c> this menu acts as a checkable menu.</param>
 /// <param name="hideDisabled">if set to <c>true</c> this menu is not visible when disabled.</param>
 /// <param name="container">The container.</param>
 public SaveAsMenuItemViewModel(string header, int priority, ImageSource icon = null, ICommand command = null,
     KeyGesture gesture = null, bool isCheckable = false, bool hideDisabled = false,
     IUnityContainer container = null)
     : base(header, priority, icon, command, gesture, isCheckable, hideDisabled)
 {
     if (container != null)
     {
         var eventAggregator = container.Resolve<IEventAggregator>();
         eventAggregator.GetEvent<ActiveContentChangedEvent>().Subscribe(SaveAs);
     }
 }
Example #18
0
 private void OnHotkeyChanged(KeyGesture hotkey)
 {
     if (hotkey == null)
         //Subscription will be recreated by static property watcher
         Stop();
     else
     {
         Unregister();
         _hotkey = hotkey;
         Register();
     }
 }
Example #19
0
		public MainWindow()
		{
			this.InitializeComponent();
            PlaySound();
			frame = mainFrame;
			
			CommandBinding cb = new CommandBinding(GameMenuCommand, GameMenuExecute);
			this.CommandBindings.Add(cb);
			KeyGesture kg = new KeyGesture(Key.Escape, ModifierKeys.Shift);
			InputBinding ib = new InputBinding(GameMenuCommand, kg);
			this.InputBindings.Add(ib);
			GameMenu.LockElement = LayoutRoot;
		}
Example #20
0
 /// <summary>
 /// Initializes a new instance of the <see cref="KeyGestureExtension"/> class with a string representing the gesture.
 /// </summary>
 /// <param name="gesture">A string representing the gesture.</param>
 public KeyGestureExtension(string gesture)
 {
     var modifiers = ModifierKeys.None;
     var tokens = gesture.Split('+');
     for (int i = 0; i < tokens.Length - 1; ++i)
     {
         var token = tokens[i].Replace("Ctrl", "Control");
         var modifier = (ModifierKeys)Enum.Parse(typeof(ModifierKeys), token, true);
         modifiers |= modifier;
     }
     var key = (Key)Enum.Parse(typeof(Key), tokens[tokens.Length - 1], true);
     Gesture = new KeyGesture(key, modifiers);
 }
        public void Add(Icon icon, string text, Action action, KeyGesture gesture)
        {
            var screenAction = new ScreenAction()
            {
                Binding = new InputBinding(new ActionCommand(action), gesture),
                Icon = icon,
                Name = text
            };

            InputBindings.Add(screenAction.Binding);
            var item = CommandMenuItem.Build(screenAction);
            item.StaysOpenOnClick = true;

            Items.Add(item);
        }
        public RecentMenuItemViewModel(string header, int priority, IUnityContainer container = null, ImageSource icon = null,
								ICommand command = null, KeyGesture gesture = null, bool isCheckable = false)
            : base(header, priority, icon, command, gesture, isCheckable)
        {
            if (container != null)
            {
                _containerWeak = new GenericWeakReference<IUnityContainer>(container);
                IFileHistoryService service = _containerWeak.Get().Resolve<IFileHistoryService>();
                if (service != null)
                {
                    _historyServWeak = new GenericWeakReference<IFileHistoryService>(service);
                    _historyServWeak.Get().RecentChanged += RecentMenuItemViewModel_RecentChanged;
                }
            }
        }
Example #23
0
        public CopyWindow()
        {
            InitializeComponent();

            ExplorerNet.Tools.ViewSettings.ViewLocation.LoadWindowLocation(this);
            /////////////////////////
            CommandBinding cbCopy = new CommandBinding(CopyCommand, ExecutedCopyCommand);
            this.CommandBindings.Add(cbCopy);

            KeyGesture kgCopyF5 = new KeyGesture(Key.F5);
            KeyBinding kbCopyF5 = new KeyBinding(CopyCommand, kgCopyF5);

            this.InputBindings.Add(kbCopyF5);

            ////////////////////////
            CommandBinding cbMove = new CommandBinding(MoveCommand, ExecutedMoveCommand);
            this.CommandBindings.Add(cbMove);

            KeyGesture kgMoveF6 = new KeyGesture(Key.F6);
            KeyBinding kbMoveF6 = new KeyBinding(MoveCommand, kgMoveF6);

            this.InputBindings.Add(kbMoveF6);

            //CreateVisualData();
            //lvFromCopy.ItemsSource = copyFiles;
            //cbToCopy.ItemsSource = FilePanelSelector.FilePanels;
            //cbToCopy.Text = FilePanelSelector.SecondSelected.p;

            //FilePanel fpFirst = null;
            //if (FilePanelSelector.FirstSelected != null)
            //{
            //    fpFirst = FilePanelSelector.FirstSelected;
            //}
            //else
            //{
            //    throw new Exception("Not set FilePanelSelector.FirstSelected");
            //}

            //FilePanel fpSecond = null;
            //if (FilePanelSelector.SecondSelected != null)
            //{
            //    fpSecond = FilePanelSelector.SecondSelected;
            //}
            //else
            //{
            //    throw new Exception("Not set FilePanelSelector.SecondSelected");
            //}
        }
Example #24
0
        public LauncherWindow()
        {
            Initialized += LauncherInitialized;
            InitializeComponent();
            DebugWindowCommand.InputGestures.Add(new KeyGesture(Key.D, ModifierKeys.Control));

            var cb = new CommandBinding(DebugWindowCommand,
                                        MyCommandExecute, MyCommandCanExecute);
            CommandBindings.Add(cb);

            var kg = new KeyGesture(Key.M, ModifierKeys.Control);
            var ib = new InputBinding(DebugWindowCommand, kg);
            InputBindings.Add(ib);

            ConstructAnim();
        }
Example #25
0
 public static string GetDisplayStringForShortcut(KeyGesture kg)
 {
     string old = kg.GetDisplayStringForCulture(Thread.CurrentThread.CurrentUICulture);
     string text = KeyCodeConversion.KeyToUnicode(kg.Key.ToKeys());
     if (text != null && !text.Any(ch => char.IsWhiteSpace(ch))) {
         if ((kg.Modifiers & ModifierKeys.Alt) == ModifierKeys.Alt)
             text = StringParser.Format("${res:Global.Shortcuts.Alt}+{0}", text);
         if ((kg.Modifiers & ModifierKeys.Shift) == ModifierKeys.Shift)
             text = StringParser.Format("${res:Global.Shortcuts.Shift}+{0}", text);
         if ((kg.Modifiers & ModifierKeys.Control) == ModifierKeys.Control)
             text = StringParser.Format("${res:Global.Shortcuts.Ctrl}+{0}", text);
         if ((kg.Modifiers & ModifierKeys.Windows) == ModifierKeys.Windows)
             text = StringParser.Format("${res:Global.Shortcuts.Win}+{0}", text);
         return text;
     }
     return old;
 }
Example #26
0
        public DWindow()
        {
            InitializeComponent();
            Color color = Color.FromRgb(0x00, 0x00, 0x00);
            _turnBrush = new SolidColorBrush(color);
            _turnBrush.Freeze();

            DebugWindowCommand.InputGestures.Add(new KeyGesture(Key.D, ModifierKeys.Control));

            var cb = new CommandBinding(DebugWindowCommand,
                                        MyCommandExecute, MyCommandCanExecute);
            CommandBindings.Add(cb);

            var kg = new KeyGesture(Key.M, ModifierKeys.Control);
            var ib = new InputBinding(DebugWindowCommand, kg);
            InputBindings.Add(ib);
        }
        public void InitilizeBindings()
        {
            //Playback Go
            CommandBinding bindingPlaybackGO = new CommandBinding(_playbackGO, _mainWindow.CommandBinding_PlaybackGo_Executed, _mainWindow.CommandBinding_PlaybackGO_CanExecute);
            _mainWindow.CommandBindings.Add(bindingPlaybackGO);
            _mainWindow.playbackGO.Command = _playbackGO;
            KeyGesture keyGuestureGO = new KeyGesture(Key.Space);
            InputBinding inputBindingGO = new InputBinding(_playbackGO, keyGuestureGO);
            _mainWindow.InputBindings.Add(inputBindingGO);

            //Playback Fade
            CommandBinding bindingPlaybackFADE = new CommandBinding(_playbackFADE, _mainWindow.CommandBinding_PlaybackFADE_Executed, _mainWindow.CommandBinding_PlaybackFADE_CanExecute);
            _mainWindow.CommandBindings.Add(bindingPlaybackFADE);
            _mainWindow.playbackGO.Command = _playbackGO;
            KeyGesture keyGuestureFADE = new KeyGesture(Key.F);
            InputBinding inputBindingFADE = new InputBinding(_playbackFADE, keyGuestureFADE);
            _mainWindow.InputBindings.Add(inputBindingFADE);
        }
Example #28
0
        public CommandInfo(string id, string name, string text, string icon, KeyGesture key, Type owner, string viewKey, CommandAnchor anchor)
        {
            Id = id;
            Name = name;
            Text = text;
            Key = key;
            Icon = icon;
            ViewKey = viewKey;

            Command = new RoutedUICommand(text,
                            name,
                            owner,
                            new InputGestureCollection(new InputGesture[] { key }));

            CommandBinding = null;

            Anchor = anchor;
        }
        private void shortcutTextBox_PreviewKeyDown(object sender, KeyEventArgs e)
        {
            e.Handled = true;

            Key key = (e.Key == Key.System ? e.SystemKey : e.Key);

            if (key == Key.LeftShift || key == Key.RightShift
                || key == Key.LeftCtrl || key == Key.RightCtrl
                || key == Key.LeftAlt || key == Key.RightAlt
                || key == Key.LWin || key == Key.RWin)
            {
                return;
            }

            KeyGesture shortcut = new KeyGesture(key, Keyboard.Modifiers);

            saveShortcut(shortcut);
            shortcutTextBox.Text = converter.ConvertToInvariantString(shortcut);
        }
Example #30
0
        public App()
        {
            HighlightingManager.Instance.RegisterHighlighting("XQuery", new string[] { ".xq" }, 
                GetHighlightingDefinition("XQueryConsole.XQuery.xshd"));
            HighlightingManager.Instance.RegisterHighlighting("SQLX", new string[] { ".xsql" }, 
                GetHighlightingDefinition("XQueryConsole.SQLX.xshd"));

            // set keyboard shortcuts
            KeyGesture ExecuteCmdKeyGesture = new KeyGesture(Key.F5, ModifierKeys.None);
            KeyGesture CancelExecuteCmdKeyGesture = new KeyGesture(Key.Escape, ModifierKeys.None);
            KeyGesture ShowResultsCmdKeyGesture = new KeyGesture(Key.R, ModifierKeys.Control);
            ((RoutedUICommand)QueryPage.ExecuteCommand).InputGestures.Add(ExecuteCmdKeyGesture);
            ApplicationCommands.Stop.InputGestures.Add(CancelExecuteCmdKeyGesture);
            ((RoutedUICommand)XQueryConsole.MainWindow.ShowResultsCommand).InputGestures.Add(ShowResultsCmdKeyGesture);
            
            // register extension function in wmh namespace
            XQueryFunctionTable.Register(typeof(WmhFuncs));
            XQueryAdapterImpl.Init();
        }