public MainViewContent(string fileName, IWorkbenchWindow workbenchWindow)
        {
            codeEditor = new CodeEditor();

            textEditor = new TextEditor();
            textEditor.FontFamily = new FontFamily("Consolas");

            textEditor.TextArea.TextEntering += TextAreaOnTextEntering;
            textEditor.TextArea.TextEntered += TextAreaOnTextEntered;
            textEditor.ShowLineNumbers = true;

            var ctrlSpace = new RoutedCommand();
            ctrlSpace.InputGestures.Add(new KeyGesture(Key.Space, ModifierKeys.Control));
            var cb = new CommandBinding(ctrlSpace, OnCtrlSpaceCommand);
            // this.CommandBindings.Add(cb);

            adapter = new SharpSnippetTextEditorAdapter(textEditor);
            this.WorkbenchWindow = workbenchWindow;
            textEditor.TextArea.TextView.Services.AddService(typeof (ITextEditor), adapter);
            LoadFile(fileName);

            iconBarManager = new IconBarManager();
            textEditor.TextArea.LeftMargins.Insert(0, new IconBarMargin(iconBarManager));

            var textMarkerService = new TextMarkerService(textEditor.Document);
            textEditor.TextArea.TextView.BackgroundRenderers.Add(textMarkerService);
            textEditor.TextArea.TextView.LineTransformers.Add(textMarkerService);
            textEditor.TextArea.TextView.Services.AddService(typeof (ITextMarkerService), textMarkerService);
            textEditor.TextArea.TextView.Services.AddService(typeof (IBookmarkMargin), iconBarManager);
        }
        private static void AutoCopyChanged(DependencyObject obj, DependencyPropertyChangedEventArgs e_)
        {
            var listBox = obj as ListBox;
            if (listBox != null)
            {
                if ((bool)e_.NewValue)
                {
                    ExecutedRoutedEventHandler handler =
                        (sender, arg) =>
                            {
                                if (listBox.SelectedItems.Count > 0)
                                {
                                    var sb = new StringBuilder();
                                    foreach (var selectedItem in listBox.SelectedItems)
                                    {
                                        sb.AppendLine(selectedItem.ToString());
                                    }
                                    Clipboard.SetDataObject(sb.ToString());
                                }
                            };

                    var command = new RoutedCommand("Copy", typeof(ListBox));
                    command.InputGestures.Add(new KeyGesture(Key.C, ModifierKeys.Control, "Copy"));
                    listBox.CommandBindings.Add(new CommandBinding(command, handler));
                }
            }
        }
Exemplo n.º 3
0
        static Zoomer()
        {
            Zoomer.ResetCommand = new RoutedCommand("Reset", typeof(Zoomer));
            Zoomer.ZoomInCommand = new RoutedCommand("ZoomIn", typeof(Zoomer));
            Zoomer.ZoomOutCommand = new RoutedCommand("ZoomOut", typeof(Zoomer));
            Zoomer.PanLeftCommand = new RoutedCommand("PanLeft", typeof(Zoomer));
            Zoomer.PanRightCommand = new RoutedCommand("PanRight", typeof(Zoomer));
            Zoomer.PanUpCommand = new RoutedCommand("PanUp", typeof(Zoomer));
            Zoomer.PanDownCommand = new RoutedCommand("PanDown", typeof(Zoomer));
            Zoomer.SwitchTo2DCommand = new RoutedCommand("SwitchTo2D", typeof(Zoomer));
            Zoomer.SwitchTo3DCommand = new RoutedCommand("SwitchTo3D", typeof(Zoomer));

            Zoomer.ResetCommand.InputGestures.Add(new MouseGesture(MouseAction.LeftDoubleClick));
            Zoomer.ResetCommand.InputGestures.Add(new KeyGesture(Key.F5));
            Zoomer.ZoomInCommand.InputGestures.Add(new KeyGesture(Key.OemPlus));
            Zoomer.ZoomInCommand.InputGestures.Add(new KeyGesture(Key.Up, ModifierKeys.Control));
            Zoomer.ZoomOutCommand.InputGestures.Add(new KeyGesture(Key.OemMinus));
            Zoomer.ZoomOutCommand.InputGestures.Add(new KeyGesture(Key.Down, ModifierKeys.Control));
            Zoomer.PanLeftCommand.InputGestures.Add(new KeyGesture(Key.Left));
            Zoomer.PanRightCommand.InputGestures.Add(new KeyGesture(Key.Right));
            Zoomer.PanUpCommand.InputGestures.Add(new KeyGesture(Key.Up));
            Zoomer.PanDownCommand.InputGestures.Add(new KeyGesture(Key.Down));
            Zoomer.SwitchTo2DCommand.InputGestures.Add(new KeyGesture(Key.F2));
            Zoomer.SwitchTo3DCommand.InputGestures.Add(new KeyGesture(Key.F3));
        }
Exemplo n.º 4
0
        /// <summary>
        /// Tworzy linka i ustawia jego właściwości
        /// </summary>
        /// <param name="linkText"></param>
        /// <param name="linkAdress"></param>
        /// <param name="toolTip"></param>
        /// <returns></returns>
        private static Hyperlink CreateHyperLink(string linkText, string linkAdress, string toolTip, FontWeight weight,
                                                 Brush linkColor, RoutedCommand command)
        {
            System.Windows.Controls.ToolTip tip = new ToolTip();
            tip.Content = toolTip;
            tip.StaysOpen = true;

            tip.Style = (Style) Application.Current.FindResource("YellowToolTipStyle");

            Hyperlink hyperlink = new Hyperlink(new Run(linkText))
                                      {
                                          NavigateUri = new Uri(linkAdress),
                                          TextDecorations = null,
                                          FontWeight = weight,
                                          //FontWeights.SemiBold,
                                          Foreground = linkColor,
                                          ToolTip = tip
                                      };

            hyperlink.Command = command;
            hyperlink.CommandParameter = linkAdress;

            ToolTipService.SetInitialShowDelay(hyperlink,700);
            ToolTipService.SetShowDuration(hyperlink,15000);

            //hyperlink.AddHandler(Hyperlink.RequestNavigateEvent,
            //                        new RequestNavigateEventHandler(HyperLinkRequestNavigate));
            return hyperlink;
        }
        static PrologDebugCommands()
        {
            m_addBreakpoint = new RoutedCommand();

            m_clearAllBreakpoints = new RoutedCommand();

            m_clearBreakpoint = new RoutedCommand();

            m_endProgram = new RoutedCommand();

            m_restart = new RoutedCommand();
            m_restart.InputGestures.Add(new KeyGesture(Key.F5, ModifierKeys.Control | ModifierKeys.Shift));

            m_runToBacktrack = new RoutedCommand();
            m_runToBacktrack.InputGestures.Add(new KeyGesture(Key.F6));

            m_runToSuccess = new RoutedCommand();
            m_runToSuccess.InputGestures.Add(new KeyGesture(Key.F5));

            m_stepIn = new RoutedCommand();
            m_stepIn.InputGestures.Add(new KeyGesture(Key.F11));

            m_stepOut = new RoutedCommand();
            m_stepOut.InputGestures.Add(new KeyGesture(Key.F11, ModifierKeys.Shift));

            m_stepOver = new RoutedCommand();
            m_stepOver.InputGestures.Add(new KeyGesture(Key.F10));

            m_toggleBreakpoint = new RoutedCommand();
        }
Exemplo n.º 6
0
 public ColorViewModel(FrameworkElement window)
 {
     Window = window;
     cmdShow = new RoutedCommand();
     CommandManager.RegisterClassCommandBinding(Window.GetType(), new CommandBinding(cmdShow, cmdShow_Click));
     FillColors();
 }
Exemplo n.º 7
0
        /// <summary>
        /// Initializes the <see cref="WidgetElement"/> class.
        /// </summary>
        static WidgetElement()
        {
            WidgetElement.DefaultStyleKeyProperty.OverrideMetadata(typeof(WidgetElement),
                new FrameworkPropertyMetadata(typeof(WidgetElement)));

            WidgetElement.MinimizeCommand = new RoutedCommand("Minimize", typeof(WidgetElement));

            Control.IsTabStopProperty.OverrideMetadata(typeof(WidgetElement),
                new FrameworkPropertyMetadata(false));

            KeyboardNavigation.DirectionalNavigationProperty.OverrideMetadata(
                typeof(WidgetElement), new FrameworkPropertyMetadata(KeyboardNavigationMode.Cycle));

            KeyboardNavigation.TabNavigationProperty.OverrideMetadata(
                typeof(WidgetElement), new FrameworkPropertyMetadata(KeyboardNavigationMode.Cycle));

            KeyboardNavigation.ControlTabNavigationProperty.OverrideMetadata(
                typeof(WidgetElement), new FrameworkPropertyMetadata(KeyboardNavigationMode.Once));

            if (!DesignMode.IsInDesignMode
                && Application.Current.GetRenderTier() != RenderTier.Tier2)
            {
                WidgetElement.CacheModeProperty.OverrideMetadata(typeof(WidgetElement),
                    new FrameworkPropertyMetadata(new BitmapCache { EnableClearType = true, RenderAtScale = 1, SnapsToDevicePixels = true }));
            }
        }
 public static void AddCommandPreviewExecuteHandler(this CommandBindingCollection collection, RoutedCommand command, ExecutedRoutedEventHandler handler)
 {
     CommandBinding binding = GetOrCreateBinding(collection, command);
     // Remove the handler if it already exist
     binding.PreviewExecuted -= handler;
     binding.PreviewExecuted += handler;
 }
Exemplo n.º 9
0
 static ImportMappingPage()
 {
     MapField = new RoutedCommand("MapFieldCommand", typeof(ImportMappingPage));
     UnmapField = new RoutedCommand("UnmapFieldCommand", typeof(ImportMappingPage));
     UnmapAll = new RoutedCommand("UnmapAllCommand", typeof(ImportMappingPage));
     AutoMap = new RoutedCommand("AutoMapCommand", typeof(ImportMappingPage));
 }
Exemplo n.º 10
0
        static CrudCC()
        {
            DefaultStyleKeyProperty.OverrideMetadata(typeof(CrudCC), new FrameworkPropertyMetadata(typeof(CrudCC)));

            FilterProperty = DependencyProperty.Register("Filter", typeof(ContentControl), typeof(CrudCC), new FrameworkPropertyMetadata(null, FrameworkPropertyMetadataOptions.Inherits));
            FormEditProperty = DependencyProperty.Register("FormEdit", typeof(ContentControl), typeof(CrudCC), new UIPropertyMetadata(null));
            FormNewProperty = DependencyProperty.Register("FormNew", typeof(ContentControl), typeof(CrudCC), new UIPropertyMetadata(null));
            DataViewProviderProperty = DependencyProperty.Register("DataViewProvider", typeof(Type), typeof(CrudCC), new UIPropertyMetadata(typeof(object), OnChangeDataViewProvider));

            IsBindableProperty = DependencyProperty.Register("IsBindable", typeof(bool), typeof(CrudCC), new UIPropertyMetadata(true, null, OnCoerceIsBindable));

            FilterBlockWidthProperty = DependencyProperty.Register("FilterBlockWidth", typeof(double), typeof(CrudCC), new UIPropertyMetadata(0.0));
            FilterBlockHeightProperty = DependencyProperty.Register("FilterBlockHeight", typeof(double), typeof(CrudCC), new UIPropertyMetadata(0.0));
            FormEditBlockWidthProperty = DependencyProperty.Register("FormEditBlockWidth", typeof(double), typeof(CrudCC), new UIPropertyMetadata(0.0, OnFormEditBlockWidthChanged));
            FormEditBlockHeightProperty = DependencyProperty.Register("FormEditBlockHeight", typeof(double), typeof(CrudCC), new UIPropertyMetadata(0.0, OnFormEditBlockHeightChanged));
            FormNewBlockWidthProperty = DependencyProperty.Register("FormNewBlockWidth", typeof(double), typeof(CrudCC), new UIPropertyMetadata(0.0, null, OnCoerceFormNewBlockWidth));
            FormNewBlockHeightProperty = DependencyProperty.Register("FormNewBlockHeight", typeof(double), typeof(CrudCC), new UIPropertyMetadata(0.0, null, OnCoerceFormNewBlockHeight));

            MoveFirstAction = new RoutedCommand("MoveFirstAction", typeof(CrudCC));
            MoveBackwardAction = new RoutedCommand("MoveBackwardAction", typeof(CrudCC));
            MoveForwardAction = new RoutedCommand("MoveForwardAction", typeof(CrudCC));
            MoveLastAction = new RoutedCommand("MoveLastAction", typeof(CrudCC));
            ToggleFilterAction = new RoutedCommand("ToggleFilterAction", typeof(CrudCC));
            ToggleFormAction = new RoutedCommand("ToggleFormAction", typeof(CrudCC));
            NewRowAction = new RoutedCommand("NewRowAction", typeof(CrudCC));
            DeleteAction = new RoutedCommand("DeleteAction", typeof(CrudCC));
        }
Exemplo n.º 11
0
 public SimpleRoutedCommand(string text)
 {
     RoutedUICommand routedCommand = new RoutedUICommand();
     routedCommand.Text = text;
     _routedCommand = routedCommand;
     init();
 }
Exemplo n.º 12
0
        public static RoutedCommand Bind(UIElement target, RoutedCommand command)
        {
            target.CommandBindings.AddCommandExecutedHandler(command,  Execute );
            target.CommandBindings.AddCommandCanExecuteHandler(command, CanExecute);

            return command;
        }
Exemplo n.º 13
0
        public page_chat()
        {
            InitializeComponent();

            RoutedCommand Input_SendMessage = new RoutedCommand();
            RoutedCommand Input_Return = new RoutedCommand();

            KeyBinding Input_SendMessage_Keybinding = new KeyBinding(Input_SendMessage, new KeyGesture(Key.Enter));
            CommandBinding Input_SendMessage_Binding = new CommandBinding(Input_SendMessage, Input_SentMessage_Execute, CmdCanExecute);

            KeyBinding Input_Return_Keybinding = new KeyBinding(Input_Return, new KeyGesture(Key.Enter, ModifierKeys.Control));
            CommandBinding Input_Return_Binding = new CommandBinding(Input_Return, Input_Return_Execute, CmdCanExecute);

            this.rtf_input.InputBindings.Add(Input_SendMessage_Keybinding);
            this.rtf_input.CommandBindings.Add(Input_SendMessage_Binding);

            this.rtf_input.InputBindings.Add(Input_Return_Keybinding);
            this.rtf_input.CommandBindings.Add(Input_Return_Binding);

            CommandBinding pasteCmdBinding = new CommandBinding(ApplicationCommands.Paste, OnPaste, OnCanExecutePaste);
            this.rtf_input.CommandBindings.Add(pasteCmdBinding);

            try
            {
                this.rtf_input.FontSize = Convert.ToDouble(ConfigManager.Instance.GetString("font_size", "12"));
                this.rtf_input.FontFamily = new FontFamily(ConfigManager.Instance.GetString("font", "Segoe WP"));
                this.rtf_input.Foreground = (SolidColorBrush)new BrushConverter().ConvertFromString(ConfigManager.Instance.GetString("font_color", "#000000"));
            }
            catch { }

            this.rtf_input.AddHandler(RichTextBox.DragOverEvent, new DragEventHandler(rtf_DragOver), true);
            this.rtf_input.AddHandler(RichTextBox.DropEvent, new DragEventHandler(rtf_DragDrop), true);
        }
Exemplo n.º 14
0
 internal static void RegisterCommandHandler(Type controlType, RoutedCommand command, ExecutedRoutedEventHandler executedRoutedEventHandler, 
                                             CanExecuteRoutedEventHandler canExecuteRoutedEventHandler,
                                             InputGesture inputGesture, InputGesture inputGesture2, InputGesture inputGesture3, InputGesture inputGesture4) 
 {
     PrivateRegisterCommandHandler(controlType, command, executedRoutedEventHandler, canExecuteRoutedEventHandler,
                                   inputGesture, inputGesture2, inputGesture3, inputGesture4);
 } 
Exemplo n.º 15
0
 static CustomCommands()
 {
     exitCommand = new RoutedCommand("Exit", typeof(CustomCommands));
     aboutCommand = new RoutedCommand("About", typeof(CustomCommands));
     editDeleteCommand = new RoutedCommand("EditDelete", typeof(CustomCommands));
     editRenameCommand = new RoutedCommand("EditRename", typeof(CustomCommands));
     settingsCommand = new RoutedCommand("Settings", typeof(CustomCommands));
     preferencesCommand = new RoutedCommand("Preferences", typeof(CustomCommands));
     selectCommand = new RoutedCommand("Select", typeof(CustomCommands));
     moveCommand = new RoutedCommand("Move", typeof(CustomCommands));
     rotateCommand = new RoutedCommand("Rotate", typeof(CustomCommands));
     scaleCommand = new RoutedCommand("Scale", typeof(CustomCommands));
     camModeSolidCommand = new RoutedCommand("CamModeSolid", typeof(CustomCommands));
     camModeWireframeCommand = new RoutedCommand("CamModeWireframe", typeof(CustomCommands));
     camModePointsCommand = new RoutedCommand("CamModePoints", typeof(CustomCommands));
     clearLogCommand = new RoutedCommand("ClearLog", typeof(CustomCommands));
     toggleRenderCommand = new RoutedCommand("ToggleRender", typeof(CustomCommands));
     toggleSceneCommand = new RoutedCommand("ToggleScene", typeof(CustomCommands));
     toggleObjectsCommand = new RoutedCommand("ToggleObjects", typeof(CustomCommands));
     toggleEntityCommand = new RoutedCommand("ToggleEntity", typeof(CustomCommands));
     togglePropertiesCommand = new RoutedCommand("ToggleProperties", typeof(CustomCommands));
     toggleLogCommand = new RoutedCommand("ToggleLog", typeof(CustomCommands));
     toggleMaterialsCommand = new RoutedCommand("ToggleMaterials", typeof(CustomCommands));
     toggleTemplatesCommand = new RoutedCommand("ToggleTemplates", typeof(CustomCommands));
 }
Exemplo n.º 16
0
        private static void AutoCopyChanged(DependencyObject obj_, DependencyPropertyChangedEventArgs e_)
        {
            var listBox = obj_ as ListBox;
            if (listBox != null)
            {
                if ((bool)e_.NewValue)
                {
                    ExecutedRoutedEventHandler handler =
                        (sender_, arg_) =>
                        {
                            if (listBox.SelectedItems.Count > 0)
                            {
                                string copyContent = string.Empty;
                                foreach (var item in listBox.SelectedItems)
                                    copyContent += item.ToString() + Environment.NewLine;
                                Clipboard.SetText(copyContent);
                            }
                        };

                    var command = new RoutedCommand("Copy", typeof(ListBox));
                    command.InputGestures.Add(new KeyGesture(Key.C, ModifierKeys.Control, "Copy"));
                    listBox.CommandBindings.Add(new CommandBinding(command, handler));
                }
            }
        }
Exemplo n.º 17
0
        private void SetupKeyboardShortcuts() {

            // esc -- close the window
            var close = new RoutedCommand();
            close.InputGestures.Add( new KeyGesture( Key.Escape ) );
            CommandBindings.Add( new CommandBinding( close, this.CloseWindow ) );
        }
Exemplo n.º 18
0
		public MainWindow()
		{
			InitializeComponent();
			Items = new ObservableCollection<string>();

			AddFilesCommand = new RoutedCommand(
				"AddFilesCommand",
				GetType(),
				new InputGestureCollection(
					new [] { new KeyGesture(Key.O, ModifierKeys.Control) }
				)
			);

			GenerateCommand = new RoutedCommand(
				"GenerateCommand",
				GetType(),
				new InputGestureCollection(
					new [] { new KeyGesture(Key.S, ModifierKeys.Control) }
				)
			);

			DeleteCommand = new RoutedCommand(
				"DeleteCommand",
				GetType(),
				new InputGestureCollection(
					new[] { new KeyGesture(Key.Delete) }
				)
			);

			CommandBindings.Add(new CommandBinding(AddFilesCommand, AddFilesCommand_Executed));
			CommandBindings.Add(new CommandBinding(GenerateCommand, GenerateCommand_Executed, GenerateCommand_CanExecute));
			CommandBindings.Add(new CommandBinding(DeleteCommand, DeleteCommand_Executed, DeleteCommand_CanExecute));

			DataContext = this;
		}
Exemplo n.º 19
0
        static CageCommands()
        {
            CommandFeedClick = new RoutedCommand("CommandFeedClick", typeof(CageCommands));
            CommandHealClick = new RoutedCommand("CommandHealClick", typeof(CageCommands));
            CommandGrowClick = new RoutedCommand("CommandGrowClick", typeof(CageCommands));

            CommandBinding bindingfeed = new CommandBinding();
            bindingfeed.Command = CommandFeedClick;
            bindingfeed.Executed += new ExecutedRoutedEventHandler(CommandFeedClick_Executed);
            bindingfeed.CanExecute += new CanExecuteRoutedEventHandler(CommandFeedClick_CanExecute);

            CommandBinding bindingheal = new CommandBinding();
            bindingheal.Command = CommandHealClick;
            bindingheal.Executed += new ExecutedRoutedEventHandler(CommandHealClick_Executed);
            bindingheal.CanExecute += new CanExecuteRoutedEventHandler(CommandHealClick_CanExecute);

            CommandBinding bindinggrow = new CommandBinding();
            bindinggrow.Command = CommandGrowClick;
            bindinggrow.Executed += new ExecutedRoutedEventHandler(CommandGrowClick_Executed);
            bindinggrow.CanExecute += new CanExecuteRoutedEventHandler(CommandGrowClick_CanExecute);

            CommandManager.RegisterClassCommandBinding(typeof(CageControl), bindingfeed);
            CommandManager.RegisterClassCommandBinding(typeof(CageControl), bindingheal);
            CommandManager.RegisterClassCommandBinding(typeof(CageControl), bindinggrow);
        }
Exemplo n.º 20
0
        public MainWindow()
        {
            InitializeComponent();

            FullScreenCommand = new RoutedCommand("FullScreenCommand", typeof(MainWindow));
            FullScreenCommandBinding = new CommandBinding(FullScreenCommand, FullScreenCommandHandler);
        }
 static DockCommands()
 {
     CloseDockPane = new RoutedCommand("CloseDockPane", typeof(DockCommands));
     CloseFloatForm = new RoutedCommand("CloseFloatForm", typeof(DockCommands));
     HideDockPane = new RoutedCommand("HideDockPane", typeof(DockCommands));
     PurgeAndAttachMouse = new RoutedCommand("PurgeAndAttachMouse", typeof(DockCommands));
 }
Exemplo n.º 22
0
 static ContextMenuCommands()
 {
     AnnotateCanvasCommand = new RoutedCommand("Annotate here", typeof (ContextMenuCommands));
     NavigateToTypeCommand = new RoutedCommand("Navigate to type", typeof (ContextMenuCommands));
     AddToTrivialListCommand = new RoutedCommand("Add to trivial list", typeof (ContextMenuCommands));
     ShowAllCommand = new RoutedCommand("Show all", typeof (ContextMenuCommands));
     TemporarilyHideCommand = new RoutedCommand("Temporarily hide", typeof (ContextMenuCommands));
 }
 public static void RemoveCommandPreviewCanExecuteHandler(this CommandBindingCollection collection, RoutedCommand command, CanExecuteRoutedEventHandler handler)
 {
     CommandBinding binding = GetBinding(collection, command);
     if (binding != null)
     {
         binding.PreviewCanExecute -= handler;
     }
 }
Exemplo n.º 24
0
 /// <summary>
 /// "Entry Point"
 /// </summary>
 static App()
 {
     // Тут коментарии не нужны.
     Kernel = new StandardKernel();
     Kernel.Bind<ICalculator>().To<Calculator>();
     Kernel.Bind<CalculatorViewModel>().ToSelf();
     Calculate = new RoutedCommand();
 }
Exemplo n.º 25
0
 static SystemCommands()
 {
     CloseWindowCommand = new RoutedCommand("CloseWindow", typeof (SystemCommands));
     MaximizeWindowCommand = new RoutedCommand("MaximizeWindow", typeof (SystemCommands));
     MinimizeWindowCommand = new RoutedCommand("MinimizeWindow", typeof (SystemCommands));
     RestoreWindowCommand = new RoutedCommand("RestoreWindow", typeof (SystemCommands));
     ShowSystemMenuCommand = new RoutedCommand("ShowSystemMenu", typeof (SystemCommands));
 }
Exemplo n.º 26
0
 static ItemsGroupBox()
 {
     DefaultStyleKeyProperty.OverrideMetadata(typeof(ItemsGroupBox), new FrameworkPropertyMetadata(typeof(ItemsGroupBox)));
     SelectPrevious = new RoutedCommand("SelectPreviousCommand", typeof(ItemsGroupBox));
     SelectNext = new RoutedCommand("SelectNextCommand", typeof(ItemsGroupBox));
     Unlock = new RoutedCommand("UnlockCommand", typeof(ItemsGroupBox));
     AddNew = new RoutedCommand("AddNewCommand", typeof(ItemsGroupBox));
 }
Exemplo n.º 27
0
 static MenuCommand()
 {
     OpenWebServiceConfiguration = new RoutedCommand();
     OpenReporting = new RoutedCommand();
     OpenSettings = new RoutedCommand();
     OpenHelp = new RoutedCommand();
     Quit = new RoutedCommand();
 }
 public static void RemoveCommandExecutedHandler(this CommandBindingCollection collection, RoutedCommand command, ExecutedRoutedEventHandler handler)
 {
     CommandBinding binding = GetBinding(collection, command);
     if (binding != null)
     {
         binding.Executed -= handler;
     }
 }
		void Run(RoutedCommand command)
		{
			if (command.CanExecute(null, null)) {
				command.Execute(null, null);
			} else if (this.Child != null) {
				command.Execute(null, FocusManager.GetFocusedElement(FocusManager.GetFocusScope(this.Child)));
			}
		}
Exemplo n.º 30
0
 /// <summary>
 /// Initialize the static properties of the <see cref="ControlCommands"/> class.
 /// </summary>
 static ControlCommands()
 {
     ClearSelectionCommand = new RoutedCommand("ClearSelectionCommand", typeof(Selector));
     CommandManager.RegisterClassCommandBinding(typeof(Selector), new CommandBinding(ClearSelectionCommand, OnClearSelectionCommand));
     SetAllVectorComponentsCommand = new RoutedCommand("SetAllVectorComponentsCommand", typeof(VectorEditorBase));
     CommandManager.RegisterClassCommandBinding(typeof(VectorEditorBase), new CommandBinding(SetAllVectorComponentsCommand, OnSetAllVectorComponents));
     ResetValueCommand = new RoutedCommand("ResetValueCommand", typeof(VectorEditorBase));
     CommandManager.RegisterClassCommandBinding(typeof(VectorEditorBase), new CommandBinding(ResetValueCommand, OnResetValue));
 }
Exemplo n.º 31
0
 protected static System.Windows.Controls.MenuItem BuildContextMenuItem(string header, System.Windows.Input.RoutedCommand routedCommand)
 {
     System.Windows.Controls.MenuItem menuItem = new System.Windows.Controls.MenuItem();
     menuItem.Header  = header;
     menuItem.Command = routedCommand;
     return(menuItem);
 }
Exemplo n.º 32
0
        private void InitializeTextEditor()
        {
            #region AssemblyLoader
            assemblyLoader = new AssemblyLoader();
            assemblyLoader.AssembliesLoading          += (sender, args) => OnAssembliesLoading(args.Value);
            assemblyLoader.InternalAssembliesLoaded   += (sender, args) => OnInternalAssembliesLoaded(args.Value);
            assemblyLoader.AssembliesLoaded           += (sender, args) => OnAssembliesLoaded(args.Value);
            assemblyLoader.AssembliesUnloading        += (sender, args) => OnAssembliesUnloading(args.Value);
            assemblyLoader.InternalAssembliesUnloaded += (sender, args) => OnInternalAssembliesUnloaded(args.Value);
            assemblyLoader.AssembliesUnloaded         += (sender, args) => OnAssembliesUnloaded(args.Value);
            #endregion

            #region TextMarkerService
            textMarkerService = new TextMarkerService(TextEditor.Document);
            TextEditor.TextArea.TextView.BackgroundRenderers.Add(textMarkerService);
            TextEditor.TextArea.TextView.LineTransformers.Add(textMarkerService);
            TextEditor.TextArea.TextView.Services.AddService(typeof(ITextMarkerService), textMarkerService);
            #endregion

            #region ReadOnlySectionProvider
            TextEditor.TextArea.ReadOnlySectionProvider = new MethodDefinitionReadOnlySectionProvider(this);
            #endregion

            #region SearchPanel
            SearchPanel.Install(TextEditor);
            #endregion

            #region CompletionCommand
            CompletionCommand = new Input.RoutedCommand();
            CompletionCommand.InputGestures.Add(new Input.KeyGesture(Input.Key.Space, Input.ModifierKeys.Control));
            #endregion

            #region MoveLinesUpCommand
            var moveLinesUpCommand = new Input.RoutedCommand();
            moveLinesUpCommand.InputGestures.Add(new Input.KeyGesture(Input.Key.Up, Input.ModifierKeys.Alt));
            var moveLinesUpCommandBinding = new Input.CommandBinding(moveLinesUpCommand, (sender, args) => ExecuteMoveLinesCommand(MovementDirection.Up));
            TextEditor.CommandBindings.Add(moveLinesUpCommandBinding);
            #endregion

            #region MoveLinesDownCommand
            var moveLinesDownCommand = new Input.RoutedCommand();
            moveLinesDownCommand.InputGestures.Add(new Input.KeyGesture(Input.Key.Down, Input.ModifierKeys.Alt));
            var moveLinesDownCommandBinding = new Input.CommandBinding(moveLinesDownCommand, (sender, args) => ExecuteMoveLinesCommand(MovementDirection.Down));
            TextEditor.CommandBindings.Add(moveLinesDownCommandBinding);
            #endregion

            #region GoToLineCommand
            var goToLineCommand = new Input.RoutedCommand();
            goToLineCommand.InputGestures.Add(new Input.KeyGesture(Input.Key.G, Input.ModifierKeys.Control));
            var goToLineCommandBinding = new Input.CommandBinding(goToLineCommand, (sender, args) => ExecuteGoToLineCommand());
            TextEditor.CommandBindings.Add(goToLineCommandBinding);
            #endregion

            TextEditorSyntaxHighlighting   = DefaultTextEditorSyntaxHighlighting;
            TextEditorShowLineNumbers      = DefaultTextEditorShowLineNumbers;
            TextEditorShowSpaces           = DefaultTextEditorShowSpaces;
            TextEditorShowTabs             = DefaultTextEditorShowTabs;
            TextEditorConvertTabsToSpaces  = DefaultTextEditorConvertTabsToSpaces;
            TextEditorHighlightCurrentLine = DefaultTextEditorHighlightCurrentLine;
            TextEditorIndentationSize      = DefaultTextEditorIndentationSize;

            Doc.FileName = DefaultDocumentFileName;

            TextEditor.FontFamily = new Media.FontFamily(DefaultTextEditorFontFamily);
            TextEditor.FontSize   = DefaultTextEditorFontSize;
            TextEditor.Options.EnableVirtualSpace   = true;
            TextEditor.TextArea.IndentationStrategy = new CSharpIndentationStrategy(TextEditor.Options);

            TextEditor.TextChanged += (sender, args) => {
                foreach (var marker in textMarkerService.TextMarkers)
                {
                    if (marker == prefixMarker || marker == suffixMarker)
                    {
                        continue;
                    }
                    if (marker.Length != (int)marker.Tag)
                    {
                        marker.Delete();
                    }
                    else
                    {
                        int caretOffset   = TextEditor.CaretOffset;
                        var line          = Doc.GetLineByOffset(marker.StartOffset);
                        int lineEndOffset = line.EndOffset;
                        if (caretOffset == lineEndOffset) // special case for markers beyond line length
                        {
                            marker.Delete();
                        }
                    }
                }
                OnTextEditorTextChanged();
            };
        }