public DocumentSchemaDesignerElement(View view)
            : base(view)
        {
            var mainPanel = new StackPanelElement(view);

            // TreeView
            var treeView = new TreeViewElement(view);

            treeView.SetKeyProperty("Key");
            treeView.SetParentProperty("Parent");
            treeView.SetImageProperty("Image");
            treeView.SetDisplayProperty("Tag.Text");
            treeView.SetShowNodeImages(true);
            treeView.OnDoubleClick += OnEditPropertyHandler;
            mainPanel.AddItem(treeView);

            // ToolBar
            var toolBar = new ToolBarElement(view);

            mainPanel.AddItem(toolBar);

            // ContextMenu
            var contextMenu = new ContextMenuElement(view);

            treeView.SetContextMenu(contextMenu);

            // Add

            var addButton = new ToolBarPopupButtonItem(view);

            addButton.SetText(Resources.DocumentSchemaDesignerAddButton);
            addButton.SetImage("Actions/Add_16x16");
            addButton.SetHotkey("Ctrl+N");
            toolBar.AddItem(addButton);

            var addMenuButton = new ContextMenuItem(view);

            addMenuButton.SetText(Resources.DocumentSchemaDesignerAddButton);
            addMenuButton.SetImage("Actions/Add_16x16");
            addMenuButton.SetHotkey("Ctrl+N");
            contextMenu.AddItem(addMenuButton);

            // Edit

            var editButton = new ToolBarButtonItem(view);

            editButton.SetText(Resources.DocumentSchemaDesignerEditButton);
            editButton.SetImage("Actions/Edit_16x16");
            editButton.SetHotkey("Ctrl+O");
            editButton.OnClick += OnEditPropertyHandler;
            toolBar.AddItem(editButton);

            var editMenuButton = new ContextMenuItem(view);

            editMenuButton.SetText(Resources.DocumentSchemaDesignerEditButton);
            editMenuButton.SetImage("Actions/Edit_16x16");
            editMenuButton.SetHotkey("Ctrl+O");
            editMenuButton.OnClick += OnEditPropertyHandler;
            contextMenu.AddItem(editMenuButton);

            // Delete

            var deleteButton = new ToolBarButtonItem(view);

            deleteButton.SetText(Resources.DocumentSchemaDesignerDeleteButton);
            deleteButton.SetImage("Actions/Delete_16x16");
            deleteButton.SetHotkey("Ctrl+Delete");
            deleteButton.OnClick += OnDeletePropertyHandler;
            toolBar.AddItem(deleteButton);

            var deleteMenuButton = new ContextMenuItem(view);

            deleteMenuButton.SetText(Resources.DocumentSchemaDesignerDeleteButton);
            deleteMenuButton.SetImage("Actions/Delete_16x16");
            deleteMenuButton.SetHotkey("Ctrl+Delete");
            deleteMenuButton.OnClick += OnDeletePropertyHandler;
            contextMenu.AddItem(deleteMenuButton);

            // Separator1

            var separator1 = new ToolBarSeparatorItem(view);

            toolBar.AddItem(separator1);

            var menuSeparator1 = new ContextMenuItemSeparator(view);

            contextMenu.AddItem(menuSeparator1);

            // Cut

            var cutButton = new ToolBarButtonItem(view);

            cutButton.SetToolTip(Resources.DocumentSchemaDesignerCutButtonToolTip);
            cutButton.SetImage("Actions/Cut_16x16");
            cutButton.SetHotkey("Ctrl+X");
            cutButton.OnClick += OnCutPropertyHandler;
            toolBar.AddItem(cutButton);

            var cutMenuButton = new ContextMenuItem(view);

            cutMenuButton.SetText(Resources.DocumentSchemaDesignerCutButton);
            cutMenuButton.SetImage("Actions/Cut_16x16");
            cutMenuButton.SetHotkey("Ctrl+X");
            cutMenuButton.OnClick += OnCutPropertyHandler;
            contextMenu.AddItem(cutMenuButton);

            // Copy

            var copyButton = new ToolBarButtonItem(view);

            copyButton.SetToolTip(Resources.DocumentSchemaDesignerCopyButtonToolTip);
            copyButton.SetImage("Actions/Copy_16x16");
            copyButton.SetHotkey("Ctrl+C");
            copyButton.OnClick += OnCopyPropertyHandler;
            toolBar.AddItem(copyButton);

            var copyMenuButton = new ContextMenuItem(view);

            copyMenuButton.SetText(Resources.DocumentSchemaDesignerCopyButton);
            copyMenuButton.SetImage("Actions/Copy_16x16");
            copyMenuButton.SetHotkey("Ctrl+C");
            copyMenuButton.OnClick += OnCopyPropertyHandler;
            contextMenu.AddItem(copyMenuButton);

            // Paste

            var pasteButton = new ToolBarButtonItem(view);

            pasteButton.SetToolTip(Resources.DocumentSchemaDesignerPasteButtonToolTip);
            pasteButton.SetImage("Actions/Paste_16x16");
            pasteButton.SetHotkey("Ctrl+V");
            pasteButton.OnClick += OnPastePropertyHandler;
            toolBar.AddItem(pasteButton);

            var pasteMenuButton = new ContextMenuItem(view);

            pasteMenuButton.SetText(Resources.DocumentSchemaDesignerPasteButton);
            pasteMenuButton.SetImage("Actions/Paste_16x16");
            pasteMenuButton.SetHotkey("Ctrl+V");
            pasteMenuButton.OnClick += OnPastePropertyHandler;
            contextMenu.AddItem(pasteMenuButton);

            // Separator2

            var separator2 = new ToolBarSeparatorItem(view);

            toolBar.AddItem(separator2);

            var menuSeparator2 = new ContextMenuItemSeparator(view);

            contextMenu.AddItem(menuSeparator2);

            // MoveUp

            var moveUpButton = new ToolBarButtonItem(view);

            moveUpButton.SetToolTip(Resources.DocumentSchemaDesignerMoveUpButtonToolTip);
            moveUpButton.SetImage("Actions/MoveUp_16x16");
            moveUpButton.SetHotkey("Alt+Up");
            moveUpButton.OnClick += OnMoveUpPropertyHandler;
            toolBar.AddItem(moveUpButton);

            var moveUpMenuButton = new ContextMenuItem(view);

            moveUpMenuButton.SetText(Resources.DocumentSchemaDesignerMoveUpButton);
            moveUpMenuButton.SetImage("Actions/MoveUp_16x16");
            moveUpMenuButton.SetHotkey("Alt+Up");
            moveUpMenuButton.OnClick += OnMoveUpPropertyHandler;
            contextMenu.AddItem(moveUpMenuButton);

            // MoveDown

            var moveDownButton = new ToolBarButtonItem(view);

            moveDownButton.SetToolTip(Resources.DocumentSchemaDesignerMoveDownButtonToolTip);
            moveDownButton.SetImage("Actions/MoveDown_16x16");
            moveDownButton.SetHotkey("Alt+Down");
            moveDownButton.OnClick += OnMoveDownPropertyHandler;
            toolBar.AddItem(moveDownButton);

            var moveDownMenuButton = new ContextMenuItem(view);

            moveDownMenuButton.SetText(Resources.DocumentSchemaDesignerMoveDownButton);
            moveDownMenuButton.SetImage("Actions/MoveDown_16x16");
            moveDownMenuButton.SetHotkey("Alt+Down");
            moveDownMenuButton.OnClick += OnMoveDownPropertyHandler;
            contextMenu.AddItem(moveDownMenuButton);

            _treeView      = treeView;
            _addButton     = addButton;
            _addMenuButton = addMenuButton;

            Control.Content = mainPanel.GetControl();

            // Пустое дерево модели данных
            SetValue(null);
        }
        public MenuDesignerElement(View view)
            : base(view)
        {
            var mainPanel = new StackPanelElement(view);

            // TreeView
            var treeView = new TreeViewElement(view);

            treeView.SetKeyProperty("Key");
            treeView.SetParentProperty("Parent");
            treeView.SetDisplayProperty("Tag.Text");
            treeView.SetImageProperty("Tag.Image");
            treeView.SetShowNodeImages(true);
            treeView.OnDoubleClick += OnEditItemHandler;
            mainPanel.AddItem(treeView);

            // Root Node
            var rootNode = CreateRootNode();

            // Main Menu
            var toolBar = new ToolBarElement(view);

            mainPanel.AddItem(toolBar);

            // ContextMenu
            var contextMenu = new ContextMenuElement(view);

            treeView.SetContextMenu(contextMenu);

            // Add

            var addButton = new ToolBarButtonItem(view);

            addButton.SetText(Resources.MenuDesignerAddButton);
            addButton.SetImage("Actions/Add_16x16");
            addButton.SetHotkey("Ctrl+N");
            addButton.OnClick += OnAddItemHandler;
            toolBar.AddItem(addButton);

            var addMenuButton = new ContextMenuItem(view);

            addMenuButton.SetText(Resources.MenuDesignerAddButton);
            addMenuButton.SetImage("Actions/Add_16x16");
            addMenuButton.SetHotkey("Ctrl+N");
            addMenuButton.OnClick += OnAddItemHandler;
            contextMenu.AddItem(addMenuButton);

            // Edit

            var editButton = new ToolBarButtonItem(view);

            editButton.SetText(Resources.MenuDesignerEditButton);
            editButton.SetImage("Actions/Edit_16x16");
            editButton.SetHotkey("Ctrl+O");
            editButton.OnClick += OnEditItemHandler;
            toolBar.AddItem(editButton);

            var editMenuButton = new ContextMenuItem(view);

            editMenuButton.SetText(Resources.MenuDesignerEditButton);
            editMenuButton.SetImage("Actions/Edit_16x16");
            editMenuButton.SetHotkey("Ctrl+O");
            editMenuButton.OnClick += OnEditItemHandler;
            contextMenu.AddItem(editMenuButton);

            // Delete

            var deleteButton = new ToolBarButtonItem(view);

            deleteButton.SetText(Resources.MenuDesignerDeleteButton);
            deleteButton.SetImage("Actions/Delete_16x16");
            deleteButton.SetHotkey("Ctrl+Delete");
            deleteButton.OnClick += OnDeleteItemHandler;
            toolBar.AddItem(deleteButton);

            var deleteMenuButton = new ContextMenuItem(view);

            deleteMenuButton.SetText(Resources.MenuDesignerDeleteButton);
            deleteMenuButton.SetImage("Actions/Delete_16x16");
            deleteMenuButton.SetHotkey("Ctrl+Delete");
            deleteMenuButton.OnClick += OnDeleteItemHandler;
            contextMenu.AddItem(deleteMenuButton);

            // Separator1

            var separator1 = new ToolBarSeparatorItem(view);

            toolBar.AddItem(separator1);

            var menuSeparator1 = new ContextMenuItemSeparator(view);

            contextMenu.AddItem(menuSeparator1);

            // Cut

            var cutButton = new ToolBarButtonItem(view);

            cutButton.SetToolTip(Resources.MenuDesignerCutButtonToolTip);
            cutButton.SetImage("Actions/Cut_16x16");
            cutButton.SetHotkey("Ctrl+X");
            cutButton.OnClick += OnCutItemHandler;
            toolBar.AddItem(cutButton);

            var cutMenuButton = new ContextMenuItem(view);

            cutMenuButton.SetText(Resources.MenuDesignerCutButton);
            cutMenuButton.SetImage("Actions/Cut_16x16");
            cutMenuButton.SetHotkey("Ctrl+X");
            cutMenuButton.OnClick += OnCutItemHandler;
            contextMenu.AddItem(cutMenuButton);

            // Copy

            var copyButton = new ToolBarButtonItem(view);

            copyButton.SetToolTip(Resources.MenuDesignerCopyButtonToolTip);
            copyButton.SetImage("Actions/Copy_16x16");
            copyButton.SetHotkey("Ctrl+C");
            copyButton.OnClick += OnCopyItemHandler;
            toolBar.AddItem(copyButton);

            var copyMenuButton = new ContextMenuItem(view);

            copyMenuButton.SetText(Resources.MenuDesignerCopyButton);
            copyMenuButton.SetImage("Actions/Copy_16x16");
            copyMenuButton.SetHotkey("Ctrl+C");
            copyMenuButton.OnClick += OnCopyItemHandler;
            contextMenu.AddItem(copyMenuButton);

            // Paste

            var pasteButton = new ToolBarButtonItem(view);

            pasteButton.SetToolTip(Resources.MenuDesignerPasteButtonToolTip);
            pasteButton.SetImage("Actions/Paste_16x16");
            pasteButton.SetHotkey("Ctrl+V");
            pasteButton.OnClick += OnPasteItemHandler;
            toolBar.AddItem(pasteButton);

            var pasteMenuButton = new ContextMenuItem(view);

            pasteMenuButton.SetText(Resources.MenuDesignerPasteButton);
            pasteMenuButton.SetImage("Actions/Paste_16x16");
            pasteMenuButton.SetHotkey("Ctrl+V");
            pasteMenuButton.OnClick += OnPasteItemHandler;
            contextMenu.AddItem(pasteMenuButton);

            // Separator2

            var separator2 = new ToolBarSeparatorItem(view);

            toolBar.AddItem(separator2);

            var menuSeparator2 = new ContextMenuItemSeparator(view);

            contextMenu.AddItem(menuSeparator2);

            // MoveUp

            var moveUpButton = new ToolBarButtonItem(view);

            moveUpButton.SetToolTip(Resources.MenuDesignerMoveUpButtonToolTip);
            moveUpButton.SetImage("Actions/MoveUp_16x16");
            moveUpButton.SetHotkey("Alt+Up");
            moveUpButton.OnClick += OnMoveUpItemHandler;
            toolBar.AddItem(moveUpButton);

            var moveUpMenuButton = new ContextMenuItem(view);

            moveUpMenuButton.SetText(Resources.MenuDesignerMoveUpButton);
            moveUpMenuButton.SetImage("Actions/MoveUp_16x16");
            moveUpMenuButton.SetHotkey("Alt+Up");
            moveUpMenuButton.OnClick += OnMoveUpItemHandler;
            contextMenu.AddItem(moveUpMenuButton);

            // MoveDown

            var moveDownButton = new ToolBarButtonItem(view);

            moveDownButton.SetToolTip(Resources.MenuDesignerMoveDownButtonToolTip);
            moveDownButton.SetImage("Actions/MoveDown_16x16");
            moveDownButton.SetHotkey("Alt+Down");
            moveDownButton.OnClick += OnMoveDownItemHandler;
            toolBar.AddItem(moveDownButton);

            var moveDownMenuButton = new ContextMenuItem(view);

            moveDownMenuButton.SetText(Resources.MenuDesignerMoveDownButton);
            moveDownMenuButton.SetImage("Actions/MoveDown_16x16");
            moveDownMenuButton.SetHotkey("Alt+Down");
            moveDownMenuButton.OnClick += OnMoveDownItemHandler;
            contextMenu.AddItem(moveDownMenuButton);

            _rootNode = rootNode;
            _treeView = treeView;

            Control.Content = mainPanel.GetControl();

            SetItems(new List <object>());
        }
Esempio n. 3
0
        public FindAndReplaceElement(View view)
            : base(view)
        {
            // Main Panel
            var mainPanel = new GridPanelElement(view);

            mainPanel.SetColumns(12);

            // Rows
            var findWhatRow    = mainPanel.AddRow();
            var replaceWithRow = mainPanel.AddRow();
            var settingsRow    = mainPanel.AddRow();

            // Find What
            var findWhatTextCell = findWhatRow.AddCell(10);
            var findWhatText     = new TextBoxElement(view);

            findWhatText.SetPlaceholder(Resources.FindAndReplaceElementFindWhat);
            findWhatText.OnKeyDown += OnFindWhatTextKeyDownHandler;
            findWhatTextCell.AddItem(findWhatText);

            // Find Menu
            var findWhatMenuCell = findWhatRow.AddCell(2);
            var findWhatMenu     = new ToolBarElement(view);

            findWhatMenuCell.AddItem(findWhatMenu);

            // Find Previous
            var findPreviousButton = new ToolBarButtonItem(view);

            findPreviousButton.SetImage("Actions/FindPrevious_16x16");
            findPreviousButton.SetToolTip(Resources.FindAndReplaceElementFindPreviousButtonToolTip);
            findPreviousButton.SetHotkey("Shift+F3");
            findPreviousButton.OnClick += OnFindPreviousHandler;
            findWhatMenu.AddItem(findPreviousButton);

            // Find Next
            var findNextButton = new ToolBarButtonItem(view);

            findNextButton.SetImage("Actions/FindNext_16x16");
            findNextButton.SetToolTip(Resources.FindAndReplaceElementFindNextButtonToolTip);
            findNextButton.SetHotkey("F3");
            findNextButton.OnClick += OnFindNextHandler;
            findWhatMenu.AddItem(findNextButton);

            // Replace With
            var replaceWithTextCell = replaceWithRow.AddCell(10);
            var replaceWithText     = new TextBoxElement(view);

            replaceWithText.SetPlaceholder(Resources.FindAndReplaceElementReplaceWith);
            replaceWithTextCell.AddItem(replaceWithText);

            // Replace Menu
            var replaceWithMenuCell = replaceWithRow.AddCell(2);
            var replaceWithMenu     = new ToolBarElement(view);

            replaceWithMenuCell.AddItem(replaceWithMenu);

            // Replace
            var replaceButton = new ToolBarButtonItem(view);

            replaceButton.SetImage("Actions/Replace_16x16");
            replaceButton.SetToolTip(Resources.FindAndReplaceElementReplaceButtonToolTip);
            replaceButton.SetHotkey("Alt+R");
            replaceButton.OnClick += OnReplaceHandler;
            replaceWithMenu.AddItem(replaceButton);

            // Replace All
            var replaceAllButton = new ToolBarButtonItem(view);

            replaceAllButton.SetImage("Actions/ReplaceAll_16x16");
            replaceAllButton.SetToolTip(Resources.FindAndReplaceElementReplaceAllButtonToolTip);
            replaceAllButton.SetHotkey("Alt+A");
            replaceAllButton.OnClick += OnReplaceAllHandler;
            replaceWithMenu.AddItem(replaceAllButton);

            // Match Case
            var matchCaseCell  = settingsRow.AddCell(2);
            var matchCaseCheck = new CheckBoxElement(view);

            matchCaseCheck.SetText(Resources.FindAndReplaceElementMatchCase);
            matchCaseCheck.SetHorizontalAlignment(ElementHorizontalAlignment.Left);
            matchCaseCell.AddItem(matchCaseCheck);

            // Whole Word
            var wholeWordCell  = settingsRow.AddCell(2);
            var wholeWordCheck = new CheckBoxElement(view);

            wholeWordCheck.SetText(Resources.FindAndReplaceElementWholeWord);
            wholeWordCheck.SetHorizontalAlignment(ElementHorizontalAlignment.Left);
            wholeWordCell.AddItem(wholeWordCheck);

            _setReplaceMode = replaceMode =>
            {
                replaceWithText.SetVisible(replaceMode);
                replaceButton.SetVisible(replaceMode);
                replaceAllButton.SetVisible(replaceMode);
            };

            _findWhatText    = findWhatText;
            _replaceWithText = replaceWithText;
            _matchCaseCheck  = matchCaseCheck;
            _wholeWordCheck  = wholeWordCheck;

            Control.Content = mainPanel.GetControl();
        }
        public CodeEditorElement(View view)
            : base(view)
        {
            // Main Menu
            var menuBar = new ToolBarElement(view);

            // Format
            var formatButton = new ToolBarButtonItem(view);

            formatButton.SetImage("Actions/FormatText_16x16");
            formatButton.SetToolTip(Resources.CodeEditorControlFormatButtonToolTip);
            formatButton.SetHotkey("Ctrl+Shift+F");
            formatButton.OnClick += OnFormatButtonClick;
            menuBar.AddItem(formatButton);

            // Separator0
            var separator0 = new ToolBarSeparatorItem(view);

            menuBar.AddItem(separator0);

            // Undo
            var undoButton = new ToolBarButtonItem(view);

            undoButton.SetImage("Actions/Undo_16x16");
            undoButton.SetToolTip(Resources.CodeEditorControlUndoButtonToolTip);
            undoButton.SetHotkey("Ctrl+Z");
            undoButton.OnClick += OnUndoButtonClick;
            menuBar.AddItem(undoButton);

            // Redo
            var redoButton = new ToolBarButtonItem(view);

            redoButton.SetImage("Actions/Redo_16x16");
            redoButton.SetToolTip(Resources.CodeEditorControlRedoButtonToolTip);
            redoButton.SetHotkey("Ctrl+Y");
            redoButton.OnClick += OnRedoButtonClick;
            menuBar.AddItem(redoButton);

            // Separator1
            var separator1 = new ToolBarSeparatorItem(view);

            menuBar.AddItem(separator1);

            // Cut
            var cutButton = new ToolBarButtonItem(view);

            cutButton.SetImage("Actions/Cut_16x16");
            cutButton.SetToolTip(Resources.CodeEditorControlCutButtonToolTip);
            cutButton.SetHotkey("Ctrl+X");
            cutButton.OnClick += OnCutButtonClick;
            menuBar.AddItem(cutButton);

            // Copy
            var copyButton = new ToolBarButtonItem(view);

            copyButton.SetImage("Actions/Copy_16x16");
            copyButton.SetToolTip(Resources.CodeEditorControlCopyButtonToolTip);
            copyButton.SetHotkey("Ctrl+C");
            copyButton.OnClick += OnCopyButtonClick;
            menuBar.AddItem(copyButton);

            // Paste
            var pasteButton = new ToolBarButtonItem(view);

            pasteButton.SetImage("Actions/Paste_16x16");
            pasteButton.SetToolTip(Resources.CodeEditorControlPasteButtonToolTip);
            pasteButton.SetHotkey("Ctrl+V");
            pasteButton.OnClick += OnPasteButtonClick;
            menuBar.AddItem(pasteButton);

            // Separator2
            var separator2 = new ToolBarSeparatorItem(view);

            menuBar.AddItem(separator2);

            // Find
            var findButton = new ToolBarButtonItem(view);

            findButton.SetImage("Actions/FindAndReplace_16x16");
            findButton.SetToolTip(Resources.CodeEditorControlFindButtonToolTip);
            findButton.SetHotkey("Ctrl+F");
            findButton.OnClick += OnFindButtonClick;
            menuBar.AddItem(findButton);

            // FindAndReplace
            var findAndReplace = new FindAndReplaceElement(view);

            findAndReplace.OnFindPrevious += OnFindPreviousClick;
            findAndReplace.OnFindNext     += OnFindNextClick;
            findAndReplace.OnReplace      += OnReplaceClick;
            findAndReplace.OnReplaceAll   += OnReplaceAllClick;

            // Elements

            Control.MenuBar             = menuBar.GetControl <UIElement>();
            Control.Dialog              = findAndReplace.GetControl <UIElement>();
            Control.OnEditValueChanged += OnEditValueChangedHandler;

            _findAndReplace = findAndReplace;
        }