Example #1
0
        //autofac uses this
        public EditingView(EditingModel model, PageListView pageListView,
			CutCommand cutCommand, CopyCommand copyCommand, PasteCommand pasteCommand, UndoCommand undoCommand,
			DuplicatePageCommand duplicatePageCommand,
			DeletePageCommand deletePageCommand, NavigationIsolator isolator, ControlKeyEvent controlKeyEvent)
        {
            _model = model;
            _pageListView = pageListView;
            _cutCommand = cutCommand;
            _copyCommand = copyCommand;
            _pasteCommand = pasteCommand;
            _undoCommand = undoCommand;
            _duplicatePageCommand = duplicatePageCommand;
            _deletePageCommand = deletePageCommand;
            InitializeComponent();
            _browser1.Isolator = isolator;
            _splitContainer1.Tag = _splitContainer1.SplitterDistance; //save it
            //don't let it grow automatically
            //            _splitContainer1.SplitterMoved+= ((object sender, SplitterEventArgs e) => _splitContainer1.SplitterDistance = (int)_splitContainer1.Tag);
            SetupThumnailLists();
            _model.SetView(this);
            _browser1.SetEditingCommands(cutCommand, copyCommand, pasteCommand, undoCommand);

            _browser1.GeckoReady += new EventHandler(OnGeckoReady);

            _browser1.ControlKeyEvent = controlKeyEvent;

            if(SIL.PlatformUtilities.Platform.IsMono)
            {
                RepositionButtonsForMono();
                BackgroundColorsForLinux();
            }

            controlKeyEvent.Subscribe(HandleControlKeyEvent);

            // Adding this renderer prevents a white line from showing up under the components.
            _menusToolStrip.Renderer = new FixedToolStripRenderer();

            //we're giving it to the parent control through the TopBarControls property
            Controls.Remove(_topBarPanel);
            SetupBrowserContextMenu();
            #if __MonoCS__
            // The inactive button images look garishly pink on Linux/Mono, but look okay on Windows.
            // Merely introducing an "identity color matrix" to the image attributes appears to fix
            // this problem.  (The active form looks okay with or without this fix.)
            // See http://issues.bloomlibrary.org/youtrack/issue/BL-3714.
            float[][] colorMatrixElements = {
                new float[] {1,  0,  0,  0,  0},		// red scaling factor of 1
                new float[] {0,  1,  0,  0,  0},		// green scaling factor of 1
                new float[] {0,  0,  1,  0,  0},		// blue scaling factor of 1
                new float[] {0,  0,  0,  1,  0},		// alpha scaling factor of 1
                new float[] {0,  0,  0,  0,  1}};		// three translations of 0.0
            var colorMatrix = new ColorMatrix(colorMatrixElements);
            _duplicatePageButton.ImageAttributes.SetColorMatrix(colorMatrix, ColorMatrixFlag.Default, ColorAdjustType.Bitmap);
            _deletePageButton.ImageAttributes.SetColorMatrix(colorMatrix, ColorMatrixFlag.Default, ColorAdjustType.Bitmap);
            _undoButton.ImageAttributes.SetColorMatrix(colorMatrix, ColorMatrixFlag.Default, ColorAdjustType.Bitmap);
            _cutButton.ImageAttributes.SetColorMatrix(colorMatrix, ColorMatrixFlag.Default, ColorAdjustType.Bitmap);
            _pasteButton.ImageAttributes.SetColorMatrix(colorMatrix, ColorMatrixFlag.Default, ColorAdjustType.Bitmap);
            _copyButton.ImageAttributes.SetColorMatrix(colorMatrix, ColorMatrixFlag.Default, ColorAdjustType.Bitmap);
            #endif
        }
Example #2
0
        //autofac uses this
        public EditingView(EditingModel model, PageListView pageListView, TemplatePagesView templatePagesView,
			CutCommand cutCommand, CopyCommand copyCommand, PasteCommand pasteCommand, UndoCommand undoCommand, DeletePageCommand deletePageCommand)
        {
            _model = model;
            _pageListView = pageListView;
            _templatePagesView = templatePagesView;
            _cutCommand = cutCommand;
            _copyCommand = copyCommand;
            _pasteCommand = pasteCommand;
            _undoCommand = undoCommand;
            _deletePageCommand = deletePageCommand;
            InitializeComponent();
            _splitContainer1.Tag = _splitContainer1.SplitterDistance;//save it
            //don't let it grow automatically
            //            _splitContainer1.SplitterMoved+= ((object sender, SplitterEventArgs e) => _splitContainer1.SplitterDistance = (int)_splitContainer1.Tag);
            SetupThumnailLists();
            _model.SetView(this);
            _browser1.SetEditingCommands(cutCommand, copyCommand,pasteCommand, undoCommand);

            _browser1.GeckoReady+=new EventHandler(OnGeckoReady);

            _menusToolStrip.Renderer = new FixedToolStripRenderer();

            //we're giving it to the parent control through the TopBarControls property
            Controls.Remove(_topBarPanel);
        }
 private void DelayedPasteCommand(object sender, DelayerActionEventArgs <object> e)
 {
     if (PasteCommand.CanExecute(null))
     {
         PasteCommand.Execute(null);
     }
 }
Example #4
0
        /// <summary>
        /// Paste selected items
        /// </summary>
        /// <returns>
        /// true if at least one object is pasted
        /// </returns>
        public void PasteSelection()
        {
            int n = _inMemoryList.Count;

            UnselectAll();

            if (n > 0)
            {
                var tempList = new ArrayList();

                int i;
                for (i = n - 1; i >= 0; i--)
                {
                    tempList.Add(((DrawObject)_inMemoryList[i]).Clone());
                }

                if (_inMemoryList.Count > 0)
                {
                    var cmd = new PasteCommand(_graphicsList, tempList);
                    cmd.Execute();
                    _undoRedo.AddCommand(cmd);

                    //If the items are cut, we will not delete it
                    if (_isCut)
                    {
                        _inMemoryList.Clear();
                    }
                }
            }
        }
Example #5
0
        internal void AfterTypeDragEnded(object sender, NodeDraggedEventArgs e)
        {
            QAliberTreeNode node = e.SourceNode.CompleteClone() as QAliberTreeNode;

            TreeClipboard.Default.StoreInClipboard(new QAliberTreeNode[] { node }, false);
            if (node != null)
            {
                if (node.Testcase != null)
                {
                    string tcTypeName = node.Testcase.GetType().FullName;
                    node.Checked = node.Testcase.MarkedForExecution;
                    if (!testcaseIconsList.Images.ContainsKey(tcTypeName))
                    {
                        if (node.Testcase.Icon != null)
                        {
                            testcaseIconsList.Images.Add(tcTypeName, node.Testcase.Icon);
                        }
                    }
                    if (testcaseIconsList.Images.ContainsKey(tcTypeName))
                    {
                        node.ImageKey = node.SelectedImageKey = tcTypeName;
                    }
                    node.ContextMenuStrip = testCasesMenu;

                    ICommand command = new PasteCommand(e.TargetNode, true);
                    commandsHistory.Do(command);
                    OnScenarioChanged();
                }
            }
        }
Example #6
0
        private void Copy()
        {
            CopiedShapes.Clear();
            CopiedLines.Clear();
            foreach (IShape i in Selected)
            {
                foreach (LineViewModel l in Lines)
                {
                    // Copy the line if it is originating from a shape.
                    if (l.From.Shape.ID == i.ID)
                    {
                        foreach (IShape j in Selected)
                        {
                            if (l.To.Shape.ID == j.ID)
                            {
                                CopiedLines.Add(l);
                            }
                        }
                    }
                }

                CopiedShapes.Add(i);
            }
            _memoryOfCopy = GenericSerializer.SerializeToXMLInMemory(saving(CopiedShapes, CopiedLines));
            PasteCommand.RaiseCanExecuteChanged();
        }
Example #7
0
        public delegate EditingView Factory();        //autofac uses this


        public EditingView(EditingModel model, PageListView pageListView, TemplatePagesView templatePagesView,
                           CutCommand cutCommand, CopyCommand copyCommand, PasteCommand pasteCommand, UndoCommand undoCommand, DuplicatePageCommand duplicatePageCommand,
                           DeletePageCommand deletePageCommand, NavigationIsolator isolator)
        {
            _model                = model;
            _pageListView         = pageListView;
            _templatePagesView    = templatePagesView;
            _cutCommand           = cutCommand;
            _copyCommand          = copyCommand;
            _pasteCommand         = pasteCommand;
            _undoCommand          = undoCommand;
            _duplicatePageCommand = duplicatePageCommand;
            _deletePageCommand    = deletePageCommand;
            InitializeComponent();
            _browser1.Isolator   = isolator;
            _splitContainer1.Tag = _splitContainer1.SplitterDistance;            //save it
            //don't let it grow automatically
//            _splitContainer1.SplitterMoved+= ((object sender, SplitterEventArgs e) => _splitContainer1.SplitterDistance = (int)_splitContainer1.Tag);
            SetupThumnailLists();
            _model.SetView(this);
            _browser1.SetEditingCommands(cutCommand, copyCommand, pasteCommand, undoCommand);

            _browser1.GeckoReady += new EventHandler(OnGeckoReady);

            _menusToolStrip.Renderer = new FixedToolStripRenderer();

            //we're giving it to the parent control through the TopBarControls property
            Controls.Remove(_topBarPanel);
        }
Example #8
0
        private void PerformPaste(object obj)
        {
            var temps = new List <ShapeViewModel>();
            var doesShapesContainIntialNode = DoesShapesContainInitialNode();

            if (_storedElements.Count == 0)
            {
                return;
            }
            foreach (var shape in StoredElements)
            {
                if ((shape.Type == EShape.Initial) && doesShapesContainIntialNode)
                {
                    return;
                }

                var temp =
                    new ShapeViewModel(new UMLShape(shape.X, shape.Y, shape.Height, shape.Width, shape.Shape.Type));
                Shapes.Add(temp);
                temps.Add(temp);
            }
            IUndoRedoCommand cmd = new PasteCommand(this, temps);

            _undoRedo.InsertInUndoRedo(cmd);
        }
Example #9
0
        public MainHeaderViewModel(ProjectContext projectContext, StatusInfo statusInfo, UserInterface userInterface)
        {
            if (projectContext == null)
            {
                throw new ArgumentNullException(nameof(projectContext));
            }
            if (statusInfo == null)
            {
                throw new ArgumentNullException(nameof(statusInfo));
            }

            this.projectContext = projectContext;

            CopyCommand              = new CopyCommand(userInterface, projectContext);
            PasteCommand             = new PasteCommand(userInterface, projectContext);
            NumericalBaseRollCommand = new NumericalBaseRollCommand(projectContext, userInterface);
            StatusInfoCommand        = new StatusInfoCommand(statusInfo, userInterface);

            this.projectContext.Loaded                   += HandleProjectLoaded;
            this.projectContext.Unloaded                 += HandleProjectUnloaded;
            this.projectContext.FlagsNumberChanged       += HandleFlagsNumberChanged;
            this.projectContext.FlagsNumber.ValueChanged += HandleMainValueChanged;
            this.projectContext.NumericalBaseService.NumericalBaseChanged += HandleNumericalBaseChanged;

            UpdateMainValue();
            UpdateNumericalBaseText();
            IsEnabled = projectContext.IsLoaded;
        }
 private void MouseAndKeyboardHookService_HotKeyDetected(object sender, HotKeyEventArgs e)
 {
     if (PasteCommand.CanExecute(null))
     {
         Logger.Instance.Information($"The keyboard shortcut has hit.");
         e.Handled = true;
         _delayedPasteCommand.ResetAndTick();
     }
 }
Example #11
0
        /// <summary>
        /// Paste command executed.
        /// </summary>
        protected override void OnPasteCommandExecuted()
        {
            if (this.SelectedItemViewModel != null)
            {
                this.SelectedItemViewModel.OnPasteCommandExecuted();
            }

            PasteCommand.RaiseCanExecuteChanged();
        }
        void OnCopy()
        {
            var clause = SelectedClause;

            if (clause == null)
            {
                return;
            }
            Clipboard.SetDataObject(new CodeSentenceDataObject(clause.CodeSentence), true);
            PasteCommand.RaiseCanExecuteChanged();
        }
 public void ClearSelected()
 {
     foreach (FocusModel selected in SelectedFocuses)
     {
         selected.IsSelected = false;
         selected.IsWaiting  = false;
     }
     ModeType = RelationMode.None;
     SelectedFocuses.Clear();
     CopyCommand.RaiseCanExecuteChanged();
     PasteCommand.RaiseCanExecuteChanged();
 }
Example #14
0
        private void AfterDragEnded(object sender, NodeDraggedEventArgs e)
        {
            FolderTestCase testcase = e.TargetNode.Testcase as FolderTestCase;

            if (testcase != null)
            {
                ICommand command = new CutCommand(new QAliberTreeNode[] { (QAliberTreeNode)e.SourceNode });
                command.Do();
                command = new PasteCommand(e.TargetNode);
                commandsHistory.Do(command);
                OnScenarioChanged();
            }
        }
Example #15
0
 internal void MenuPasteClicked(object sender, EventArgs e)
 {
     if (scenarioTreeView.SelectedNode != null && TreeClipboard.Default.Nodes != null)
     {
         ICommand command = new PasteCommand((QAliberTreeNode)scenarioTreeView.SelectedNode);
         commandsHistory.Do(command);
         //Go through target recursively nodes and update context menu and icons
         foreach (QAliberTreeNode node in ((PasteCommand)command).insCommand.targetNodes)
         {
             UpdateContextMenusAndIconsRec(node);
         }
         OnScenarioChanged();
     }
 }
Example #16
0
        public MainWindowViewModel(UserInterface userInterface, StatusInfo statusInfo, OpenedProjects openedProjects)
        {
            if (userInterface == null)
            {
                throw new ArgumentNullException(nameof(userInterface));
            }
            if (statusInfo == null)
            {
                throw new ArgumentNullException(nameof(statusInfo));
            }
            if (openedProjects == null)
            {
                throw new ArgumentNullException(nameof(openedProjects));
            }

            this.userInterface  = userInterface;
            this.statusInfo     = statusInfo;
            this.openedProjects = openedProjects;

            // Create commands

            SelectAllFlagsCommand      = new SelectAllFlagsCommand(userInterface, openedProjects);
            SelectNoFlagsCommand       = new SelectNoFlagsCommand(userInterface, openedProjects);
            CopyCommand                = new CopyCommand(userInterface, openedProjects);
            PasteCommand               = new PasteCommand(userInterface, openedProjects);
            CreateProjectCommand       = new CreateProjectCommand(userInterface, openedProjects);
            CloseCurrentProjectCommand = new CloseCurrentProjectCommand(userInterface, openedProjects);
            DigitCommand               = new DigitCommand(userInterface, openedProjects);

            // Initialize everything

            IEnumerable <ProjectViewModel> projects = openedProjects
                                                      .Select(x => new ProjectViewModel(userInterface, statusInfo, openedProjects, x));

            Projects        = new ObservableCollection <ProjectViewModel>(projects);
            SelectedProject = Projects.FirstOrDefault();

            mainTitle          = new MainTitle(openedProjects);
            mainTitle.Changed += HandleMainTitleChanged;

            Title = mainTitle.ToString();

            this.openedProjects.CurrentProjectChanged += HandleCurrentProjectChanged;
            this.openedProjects.ProjectCreated        += HandleProjectCreated;
            this.openedProjects.ProjectClosed         += HandleProjectClosed;

            IsNoTabInfoVisible = Projects.Count == 0;
        }
Example #17
0
        private void ToolbarButton_Click(object sender, RoutedEventArgs e)
        {
            try {
                switch ((sender as FrameworkElement).Tag.ToString().Replace("toolbar.", ""))
                {
                case "new":
                    NewFileCommand.Execute(null);
                    break;

                case "open":
                    OpenFileCommand.Execute(null);
                    break;

                case "save":
                    SaveFileCommand.Execute(null);
                    break;

                case "cut":
                    CutCommand.Execute(null);
                    break;

                case "copy":
                    CopyCommand.Execute(null);
                    break;

                case "paste":
                    PasteCommand.Execute(null);
                    break;

                case "build":
                    BuildRunCommand.Execute(false);
                    break;

                case "buildrun":
                    BuildRunCommand.Execute(true);
                    break;

                case "close":
                    CloseTabCommand.Execute(null);
                    break;
                }
            } catch (Exception ex) {
                Debug.Fail(ex.Message);
            }
        }
Example #18
0
        private void SelectedItems_CollectionChanged(object sender, System.Collections.Specialized.NotifyCollectionChangedEventArgs e)
        {
            if (SelectedItems.Count == 1)
            {
                SelectedItem = SelectedItems.First();
            }
            else
            {
                SelectedItem = null;
            }

            CopyCommand.RaiseCanExecuteChanged();
            CutCommand.RaiseCanExecuteChanged();
            PasteCommand.RaiseCanExecuteChanged();
            CreateGroupCommand.RaiseCanExecuteChanged();
            MoveToGroupCommand.RaiseCanExecuteChanged();
            CreateNodeCommand.RaiseCanExecuteChanged();
        }
Example #19
0
 public static void Paste(User user)
 {
     try
     {
         WorldEditCommand command = new PasteCommand(user);
         if (command.Invoke())
         {
             user.Player.MsgLoc($"Paste done in {command.ElapsedMilliseconds}ms.");
         }
     }
     catch (WorldEditCommandException e)
     {
         user.Player.ErrorLocStr(e.Message);
     }
     catch (Exception e)
     {
         Log.WriteError(Localizer.Do($"{e}"));
     }
 }
Example #20
0
 /// <summary>
 /// Raises commands can execute event.
 /// </summary>
 public virtual void UpdateCommandsCanExecute()
 {
     if (this.DeleteCommand != null)
     {
         DeleteCommand.RaiseCanExecuteChanged();
     }
     if (this.CutCommand != null)
     {
         CutCommand.RaiseCanExecuteChanged();
     }
     if (this.CopyCommand != null)
     {
         CopyCommand.RaiseCanExecuteChanged();
     }
     if (this.PasteCommand != null)
     {
         PasteCommand.RaiseCanExecuteChanged();
     }
 }
Example #21
0
 public EditCommand(UndoCommand undoCommand, RedoCommand redoCommand, CutCommand cutCommand,
                    CopyCommand copyCommand, PasteCommand pasteCommand, SelectAllCommand selectAllCommand,
                    ExponentCommand exponentCommand)
     : base(MenuStrings.editToolStripMenuItem1_Text)
 {
     ChildrenCommands = new List <IToolbarCommand>
     {
         undoCommand,
         redoCommand,
         null,
         cutCommand,
         copyCommand,
         pasteCommand,
         null,
         selectAllCommand,
         null,
         exponentCommand
     };
 }
Example #22
0
        protected virtual bool OnDrop(DragEventArgs args)
        {
            SafeDataObject dataObject = new SafeDataObject(args.Data);

            if (PasteCommand.CanPasteData(dataObject))
            {
                using (SceneEditTransaction editTransaction = this.ActiveSceneViewModel.CreateEditTransaction(StringTable.UndoUnitPaste))
                {
                    ICollection <SceneNode> nodes = PasteCommand.PasteData(this.ActiveSceneViewModel, dataObject);
                    if (nodes.Count > 0)
                    {
                        this.ActiveSceneViewModel.ClearSelections();
                        this.ActiveSceneViewModel.SelectNodes(nodes);
                    }
                    editTransaction.Commit();
                }
            }
            return(false);
        }
Example #23
0
        /// <summary>
        /// Handles a massive codeblock.
        /// </summary>
        private async Task HandleMassiveCodeblock(SocketMessage s)
        {
            if (!(s is SocketUserMessage msg) || msg.Author.IsBot)
            {
                return;
            }

            // Ignore specific channels
            if (Data.Settings.Has("job-channel-ids"))
            {
                ulong[] ignoreChannelIds = Data.Settings.Get("job-channel-ids").Split(',').Select(id => ulong.Parse(id.Trim())).ToArray();
                if (ignoreChannelIds.Any(id => id == s.Channel.Id))
                {
                    return;
                }
            }

            await PasteCommand.PasteIfMassiveCodeblock(s);
        }
        public BaseDataModel()
        {
            // setup
            ContentScale     = 1;
            SelectedEntities = new ObservableCollection <IVisualElement>();
            SelectedEntities.CollectionChanged += SelectedEntities_CollectionChanged;
            CornerManipulators = new ObservableCollection <VisualCornerManipulator>();
            MapEntities        = new ObservableCollection <IVisualElement>();

            // commands
            UndoCommand            = new UndoCommand(this);
            RedoCommand            = new RedoCommand(this);
            CopyCommand            = new CopyCommand(this);
            PasteCommand           = new PasteCommand(this);
            DeleteCommand          = new DeleteCommand(this);
            DeselectAllCommand     = new DeselectAllCommand(this);
            EditEntityCommand      = new EditEntityCommand(this);
            CreateMarkerCommand    = new CreateMarkerCommand(this);
            ShowManipulationPoints = new ShowManipulationPoints(this);
            CreateWallCommand      = new CreateWallCommand(this);
            CreateDoorCommand      = new CreateDoorCommand(this);
        }
        private void MouseAndKeyboardHookService_MouseAction(object sender, MouseHookEventArgs e)
        {
            switch (Settings.Default.PasteBarPosition)
            {
            case PasteBarPosition.Top:
                if (e.WheelAction == MouseWheelAction.WheelDown)
                {
                    var activeScreen = Screen.FromPoint(new System.Drawing.Point(System.Windows.Forms.Cursor.Position.X, System.Windows.Forms.Cursor.Position.Y));
                    var screen       = SystemInfoHelper.GetAllScreenInfos().Single(s => s.DeviceName == activeScreen.DeviceName);

                    if (e.Coords.Y <= screen.Bounds.Top + 5 && PasteCommand.CanExecute(null))
                    {
                        e.Handled = true;
                        Logger.Instance.Information($"Mouse gesture detected at the top of the screen.");
                        _delayedPasteCommand.ResetAndTick();
                    }
                }
                break;

            case PasteBarPosition.Bottom:
                if (e.WheelAction == MouseWheelAction.WheelUp)
                {
                    var activeScreen = Screen.FromPoint(new System.Drawing.Point(System.Windows.Forms.Cursor.Position.X, System.Windows.Forms.Cursor.Position.Y));
                    var screen       = SystemInfoHelper.GetAllScreenInfos().Single(s => s.DeviceName == activeScreen.DeviceName);

                    if (e.Coords.Y >= screen.Bounds.Bottom + screen.Bounds.Top - 5 && PasteCommand.CanExecute(null))
                    {
                        e.Handled = true;
                        Logger.Instance.Information($"Mouse gesture detected at the bottom of the screen.");
                        _delayedPasteCommand.ResetAndTick();
                    }
                }
                break;

            default:
                throw new ArgumentOutOfRangeException();
            }
        }
Example #26
0
        public void Paste()
        {
            _nextInputInline = null;

            var cmds = new CompositeCommand();

            if (!_selection.IsEmpty)
            {
                /// 範囲選択されているならその範囲を削除
                var index = _selection.Offset;
                cmds.Children.Add(new RemoveCommand(_target, _selection.Offset, _selection.Length));
                CaretIndex = index;
                ClearSelection();
            }
            var paste = new PasteCommand(_target, _caretIndex);

            cmds.Children.Add(paste);
            _executor.Execute(cmds);
            if (paste != null)
            {
                ReflectExecutedRange(paste);
            }
        }
Example #27
0
        public Data()
        {
            //File
            NewProjectCommand  = new NewProjectCommand();
            OpenProjectCommand = new OpenProjectCommand();
            ExitCommand        = new ExitCommand();
            SaveCommand        = new SaveCommand();
            SaveAsCommand      = new SaveAsCommand();

            //Edit
            CopyCommand   = new CopyCommand();
            CutCommand    = new CutCommand();
            DeleteCommand = new DeleteCommand();
            PasteCommand  = new PasteCommand();
            RedoCommand   = new RedoCommand();
            UndoCommand   = new UndoCommand();

            //View
            StatusbarToggleCommand = new StatusbarToggleCommand();
            ToolboxToggleCommand   = new ToolboxToggleCommand();
            ZoomInCommand          = new ZoomInCommand();
            ZoomOutCommand         = new ZoomOutCommand();

            //Insert
            NewClassCommand      = new NewClassCommand();
            NewDependencyCommand = new NewDependencyCommand();
            NewTextBoxCommand    = new NewTextBoxCommand();

            //Help
            HelpCommand  = new HelpCommand();
            AboutCommand = new AboutCommand();

            //StatusBar
            resetStatusBar();
            StatusBarVisability = "Visible";
            ToolBoxVisability   = "Visible";
        }
        private void OnCanExecutePaste(object sender, CanExecuteRoutedEventArgs e)
        {
            var canExec = PasteCommand?.CanExecute(e.Parameter);

            e.CanExecute = canExec.GetValueOrDefault();
        }
 private void OnExecutePaste(object sender, ExecutedRoutedEventArgs e)
 {
     PasteCommand?.Execute(e.Parameter);
 }
 private void Copy()
 {
     CopyTempMemory = SelectedFocuses;
     PasteCommand.RaiseCanExecuteChanged();
 }
Example #31
0
        void WpfKeyDown(object sender, System.Windows.Input.KeyEventArgs e)
        {
            if (e.Key == System.Windows.Input.Key.Z &&
                (System.Windows.Input.Keyboard.Modifiers & System.Windows.Input.ModifierKeys.Control) != System.Windows.Input.ModifierKeys.None)
            {
                UndoBuff.UndoCommand();
                //SelectionManager.SelectObject(null);
            }
            else if (e.Key == System.Windows.Input.Key.Y &&
                     (System.Windows.Input.Keyboard.Modifiers & System.Windows.Input.ModifierKeys.Control) != System.Windows.Input.ModifierKeys.None)
            {
                UndoBuff.RedoCommand();
                //SelectionManager.SelectObject(null);
            }
            else if (e.Key == System.Windows.Input.Key.X &&
                     (System.Windows.Input.Keyboard.Modifiers & System.Windows.Input.ModifierKeys.Control) != System.Windows.Input.ModifierKeys.None)
            {
                if (_activeTool is SelectionTool && SelectionManager.SelectedObjects.Count > 0)
                {
                    var cmd = new CutCommand(this);
                    cmd.CheckApplicability();
                    cmd.Execute();
                    cmd.Dispose();
                }
            }
            else if (e.Key == System.Windows.Input.Key.C &&
                     (System.Windows.Input.Keyboard.Modifiers & System.Windows.Input.ModifierKeys.Control) != System.Windows.Input.ModifierKeys.None)
            {
                if (_activeTool is SelectionTool && SelectionManager.SelectedObjects.Count > 0)
                {
                    var cmd = new CopyCommand(this);
                    cmd.Execute();
                    cmd.Dispose();
                }
            }
            else if (e.Key == System.Windows.Input.Key.V &&
                     (System.Windows.Input.Keyboard.Modifiers & System.Windows.Input.ModifierKeys.Control) != System.Windows.Input.ModifierKeys.None)
            {
                if (_activeTool is SelectionTool)
                {
                    var cmd = new PasteCommand(this);
                    cmd.Execute();
                    cmd.Dispose();
                }
            }
            else if (e.Key == System.Windows.Input.Key.Delete)
            {
                if (SelectionManager.SelectedObjects.Count > 0)
                {
                    UndoBuff.AddCommand(new DeleteGraphicsObject(SelectionManager.SelectedObjects.Cast <FrameworkElement>().FirstOrDefault()));
                }
                else if (_activeTool is SelectionTool && SelectionManager.SelectedObjects.Count > 0)
                {
                    foreach (var el in SelectionManager.SelectedObjects.Cast <FrameworkElement>())
                    {
                        UndoBuff.AddCommand(new DeleteGraphicsObject(el));
                    }
                }
                SelectionManager.SelectObject(null);
            }
            else if (e.Key == System.Windows.Input.Key.Add && (System.Windows.Input.Keyboard.Modifiers & System.Windows.Input.ModifierKeys.Control) != System.Windows.Input.ModifierKeys.None)
            {
                DocumentCommands.First(c => c.command is ZoomInCommand).command.Execute();
            }
            else if (e.Key == System.Windows.Input.Key.Subtract && (System.Windows.Input.Keyboard.Modifiers & System.Windows.Input.ModifierKeys.Control) != System.Windows.Input.ModifierKeys.None)
            {
                DocumentCommands.First(c => c.command is ZoomOutCommand).command.Execute();
            }

            else if (e.Key == System.Windows.Input.Key.Escape)
            {
                //NotifySetCurrentTool(toolsList[0]);
            }
            else if (e.Key == System.Windows.Input.Key.F5)
            {
                UpdateCanvasByXaml();
            }
            else if (_activeTool is SelectionTool)
            {
                if (e.Key == System.Windows.Input.Key.Left)
                {
                    (_activeTool as SelectionTool).MoveHelper(-1, 0);
                }
                if (e.Key == System.Windows.Input.Key.Right)
                {
                    (_activeTool as SelectionTool).MoveHelper(1, 0);
                }
                if (e.Key == System.Windows.Input.Key.Up)
                {
                    (_activeTool as SelectionTool).MoveHelper(0, -1);
                }
                if (e.Key == System.Windows.Input.Key.Down)
                {
                    (_activeTool as SelectionTool).MoveHelper(0, 1);
                }
            }


            MainPanel.UpdateLayout();
        }
Example #32
0
        private void CreateCommands()
        {
            DocumentCommands.Clear();

            // Commands to ToolStrip
            ICommand copyCommand    = new CopyCommand(this);
            ICommand pasteCommand   = new PasteCommand(this);
            ICommand cutCommand     = new CutCommand(this);
            ICommand bindingCommand = new CommonBindingCommand(this);

            var blankBitmap = new System.Drawing.Bitmap(10, 10);

            // Commands to ToolStrip
            DocumentCommands.Add(new CommandInfo(new NullCommand((int)CommandManager.Priorities.EditCommands),
                                                 new string[] { "DocumentContext", PredefinedContexts.GlobalToolbar })); // Separator
            DocumentCommands.Add(new CommandInfo(_undoCommand = new UndoCommand(this),
                                                 new string[] { "DocumentContext", PredefinedContexts.GlobalToolbar }));
            DocumentCommands.Add(new CommandInfo(_redoCommand = new RedoCommand(this),
                                                 new string[] { "DocumentContext", PredefinedContexts.GlobalToolbar }));
            DocumentCommands.Add(new CommandInfo(new NullCommand((int)CommandManager.Priorities.EditCommands),
                                                 new string[] { "DocumentContext", PredefinedContexts.GlobalToolbar })); // Separator
            DocumentCommands.Add(new CommandInfo(cutCommand,
                                                 new string[] { "DocumentContext", PredefinedContexts.GlobalToolbar }));
            DocumentCommands.Add(new CommandInfo(copyCommand,
                                                 new string[] { "DocumentContext", PredefinedContexts.GlobalToolbar }));
            DocumentCommands.Add(new CommandInfo(pasteCommand,
                                                 new string[] { "DocumentContext", PredefinedContexts.GlobalToolbar }));
            DocumentCommands.Add(new CommandInfo(new NullCommand((int)CommandManager.Priorities.EditCommands),
                                                 new string[] { "DocumentContext", PredefinedContexts.GlobalToolbar })); // Separator
            DocumentCommands.Add(new CommandInfo(new XamlViewCommand(this),
                                                 new string[] { "DocumentContext", PredefinedContexts.GlobalToolbar }));
            DocumentCommands.Add(new CommandInfo(new GroupCommand(this),
                                                 new string[] { "DocumentContext", PredefinedContexts.GlobalToolbar }));
            DocumentCommands.Add(new CommandInfo(new UngroupCommand(this),
                                                 new string[] { "DocumentContext", PredefinedContexts.GlobalToolbar }));
            DocumentCommands.Add(new CommandInfo(new NullCommand((int)CommandManager.Priorities.EditCommands),
                                                 new string[] { "DocumentContext", PredefinedContexts.GlobalToolbar })); // Separator

            DocumentCommands.Add(new CommandInfo(new ZMoveTopCommand(this),
                                                 new string[] { "DocumentContext", PredefinedContexts.GlobalToolbar }));
            DocumentCommands.Add(new CommandInfo(new ZMoveBottomCommand(this),
                                                 new string[] { "DocumentContext", PredefinedContexts.GlobalToolbar }));
            DocumentCommands.Add(new CommandInfo(new NullCommand((int)CommandManager.Priorities.EditCommands),
                                                 new string[] { "DocumentContext", PredefinedContexts.GlobalToolbar })); // Separator
            DocumentCommands.Add(new CommandInfo(bindingCommand,
                                                 new string[] { "DocumentContext", PredefinedContexts.GlobalToolbar }));


            DocumentCommands.Add(new CommandInfo(new NullCommand((int)CommandManager.Priorities.ViewCommands),
                                                 new string[] { "ViewContext" }));
            DocumentCommands.Add(new CommandInfo(new ZoomLevelCommand(this),
                                                 new string[] { "ViewContext" }));
            DocumentCommands.Add(new CommandInfo(new ZoomOutCommand(this),
                                                 new string[] { "ViewContext" }));
            DocumentCommands.Add(new CommandInfo(new ZoomInCommand(this),
                                                 new string[] { "ViewContext" }));

            /*DocumentCommands.Add(new CommandInfo(cutCommand, _documentMenuContext));
             * DocumentCommands.Add(new CommandInfo(copyCommand, _documentMenuContext));
             * DocumentCommands.Add(new CommandInfo(pasteCommand, _documentMenuContext));
             * DocumentCommands.Add(new CommandInfo(bindingCommand, _documentMenuContext));
             * */
            DocumentCommands.Add(new CommandInfo(new ImportElementCommand(this),
                                                 new string[] { "FileContext" }));


            DocumentCommands.Add(new CommandInfo(
                                     new ToolCommand(this,
                                                     StringResources.ToolSelection,
                                                     StringResources.ToolEditorGroupName,
                                                     global::FreeSCADA.Designer.Resources.cursor,
                                                     typeof(SelectionTool)),
                                     new string[] { "ToolboxContext" }));

            DocumentCommands.Add(new CommandInfo(
                                     new ToolCommand(this,
                                                     StringResources.ToolRectangle,
                                                     StringResources.ToolGrphicsGroupName,
                                                     global::FreeSCADA.Designer.Resources.shape_square_add,
                                                     typeof(RectangleTool)),
                                     new string[] { "ViewContext" }));

            DocumentCommands.Add(new CommandInfo(
                                     new ToolCommand(this,
                                                     StringResources.ToolEllipse,
                                                     StringResources.ToolGrphicsGroupName,
                                                     global::FreeSCADA.Designer.Resources.shape_ellipse_add,
                                                     typeof(EllipseTool)),
                                     new string[] { "ToolboxContext" }));

            DocumentCommands.Add(new CommandInfo(
                                     new ToolCommand(this,
                                                     StringResources.ToolTextbox,
                                                     StringResources.ToolGrphicsGroupName,
                                                     global::FreeSCADA.Designer.Resources.textfield_add,
                                                     typeof(TextBoxTool)),
                                     new string[] { "ToolboxContext" }));

            DocumentCommands.Add(new CommandInfo(
                                     new ToolCommand(this,
                                                     StringResources.ToolPolyline,
                                                     StringResources.ToolGrphicsGroupName,
                                                     global::FreeSCADA.Designer.Resources.shape_line_add,
                                                     typeof(PolylineTool)),
                                     new string[] { "ToolboxContext" }));
            DocumentCommands.Add(new CommandInfo(
                                     new ToolCommand(this,
                                                     StringResources.ToolPolygon,
                                                     StringResources.ToolGrphicsGroupName,
                                                     global::FreeSCADA.Designer.Resources.shape_line_add,
                                                     typeof(PolygonTool)),
                                     new string[] { "ToolboxContext" }));

            /*DocumentCommands.Add(new CommandInfo(
             *  new ToolCommand(this,
             *      StringResources.ToolActionEdit,
             *      StringResources.ToolEditorGroupName,
             *      global::FreeSCADA.Designer.Resources.cog_edit,
             *      typeof(ActionEditTool)),
             *      CommandManager.toolboxContext));*/

            DocumentCommands.Add(new CommandInfo(
                                     new ToolCommand(this,
                                                     StringResources.ToolButton,
                                                     StringResources.ToolControlsGroupName,
                                                     blankBitmap,
                                                     typeof(ControlCreateTool <System.Windows.Controls.Button>)),
                                     new string[] { "ToolboxContext" }));

            DocumentCommands.Add(new CommandInfo(
                                     new ToolCommand(this,
                                                     StringResources.ToolToggleButton,
                                                     StringResources.ToolControlsGroupName,
                                                     blankBitmap,
                                                     typeof(ControlCreateTool <System.Windows.Controls.Primitives.ToggleButton>)),
                                     new string[] { "ToolboxContext" }));

            DocumentCommands.Add(new CommandInfo(
                                     new ToolCommand(this,
                                                     StringResources.ToolProgressbar,
                                                     StringResources.ToolControlsGroupName,
                                                     blankBitmap,
                                                     typeof(ControlCreateTool <System.Windows.Controls.ProgressBar>)),
                                     new string[] { "ToolboxContext" }));

            DocumentCommands.Add(new CommandInfo(
                                     new ToolCommand(this,
                                                     StringResources.ToolScrollbar,
                                                     StringResources.ToolControlsGroupName,
                                                     blankBitmap,
                                                     typeof(ControlCreateTool <System.Windows.Controls.Primitives.ScrollBar>)),
                                     new string[] { "ToolboxContext" }));

            DocumentCommands.Add(new CommandInfo(
                                     new ToolCommand(this,
                                                     StringResources.ToolImageControl,
                                                     StringResources.ToolControlsGroupName,
                                                     blankBitmap,
                                                     typeof(ControlCreateTool <FreeSCADA.Common.Schema.AnimatedImage>)),
                                     new string[] { "ToolboxContext" }));

            DocumentCommands.Add(new CommandInfo(
                                     new ToolCommand(this,
                                                     StringResources.ToolSlider,
                                                     StringResources.ToolControlsGroupName,
                                                     blankBitmap,
                                                     typeof(ControlCreateTool <System.Windows.Controls.Slider>)),
                                     new string[] { "ToolboxContext" }));

            DocumentCommands.Add(new CommandInfo(
                                     new ToolCommand(this,
                                                     StringResources.CheckBox,
                                                     StringResources.ToolControlsGroupName,
                                                     blankBitmap,
                                                     typeof(ControlCreateTool <System.Windows.Controls.CheckBox>)),
                                     new string[] { "ToolboxContext" }));

            DocumentCommands.Add(new CommandInfo(
                                     new ToolCommand(this,
                                                     StringResources.TextBox,
                                                     StringResources.ToolControlsGroupName,
                                                     blankBitmap,
                                                     typeof(ControlCreateTool <System.Windows.Controls.TextBox>)),
                                     new string[] { "ToolboxContext" }));

            DocumentCommands.Add(new CommandInfo(
                                     new ToolCommand(this,
                                                     StringResources.ToolChart,
                                                     StringResources.ToolControlsGroupName,
                                                     blankBitmap,
                                                     typeof(ControlCreateTool <TimeChartControl>)),
                                     new string[] { "ToolboxContext" }));
        }