protected override void OnPreviewKeyDown(KeyEventArgs e)
        {
            if (!isFilterActive &&
                ((e.Key > Key.A && e.Key < Key.Z) ||
                 (e.Key > Key.OemSemicolon && e.Key < Key.Oem102)))
            {
                // Start activating the filter on the first key stroke.
                isFilterActive = true;
            }
            else if (isFilterActive && e.Key == Key.Return)
            {
                // When the filter is active and the user press return we handle it
                // by closing the drop-down and select the whole text.
                // If the auto-complete feature of the combo box had select an item this
                // item will be left selected, otherwise the text the user enter will
                // remain in the editable text box.
                // If we do not handle this case the combo box will clear the combo box because
                // during filtering no item is selected in the drop-down so the combo box does
                // not use auto-complete's selected item.
                object selectedValue = SelectedValue;
                ClearFilter();
                e.Handled      = true;
                IsDropDownOpen = false;
                EditableTextBox.SelectAll();
                SelectedValue = selectedValue;
                return;
            }

            base.OnPreviewKeyDown(e);
        }
Пример #2
0
 public void CursorToEnd(bool closeDropDown = true)
 {
     EditableTextBox.Select(this.EditableTextBox.Text.Length, 0);
     if (closeDropDown)
     {
         IsDropDownOpen = false;
     }
 }
Пример #3
0
 private void EditableTextBox_GotKeyboardFocus(object sender, RoutedEventArgs e)
 {
     if (ignoreFocus)
     {
         ignoreFocus = false;
     }
     else
     {
         EditableTextBox.SelectAll();
     }
 }
Пример #4
0
        protected override void CreateInnerControls(ExolutioCanvas canvas)
        {
            base.CreateInnerControls(canvas);

            foldingButton = new FoldingButton();
            MainNode.InnerConnectorControl.Children.Add(foldingButton);
            Canvas.SetBottom(foldingButton, -15);
            foldingButton.Click += delegate { this.ViewHelper.IsFolded = !this.ViewHelper.IsFolded; };

            #region main node content components
            border = new Border
            {
                BorderBrush     = ViewToolkitResources.NodeBorderBrush,
                BorderThickness = ViewToolkitResources.Thickness1,
                Background      = ViewToolkitResources.NoInterpretationBrush,
                Opacity         = ViewToolkitResources.LittleOpaque,
                Padding         = ViewToolkitResources.Thickness0,
                CornerRadius    = new CornerRadius(15)
            };
            MainNode.InnerContentControl.Content = border;
            MainNode.MinWidth = 50;

            stackPanel = new StackPanel
            {
                Orientation = Orientation.Vertical
            };
            border.Child = stackPanel;

            tbContentModelHeader = new EditableTextBox
            {
                FontWeight    = FontWeights.Bold,
                TextAlignment = TextAlignment.Center,
                Background    = ViewToolkitResources.TransparentBrush,
                FontSize      = 15,
            };

            stackPanel.Children.Add(tbContentModelHeader);

            #endregion

            ExolutioContextMenu exolutioContextMenu = MenuHelper.GetContextMenu(ScopeAttribute.EScope.PSMContentModel, this.DiagramView.Diagram);
            ContextMenu = exolutioContextMenu;

#if SILVERLIGHT
            ContextMenuService.SetContextMenu(tbContentModelHeader, ContextMenu);
#endif
        }
        protected override void OnPreviewKeyDown(KeyEventArgs e)
        {
            if (!_isFilterActive &&
                ((e.Key >= Key.A && e.Key <= Key.Z) ||
                 (e.Key > Key.OemSemicolon && e.Key < Key.Oem102)))
            {
                _isFilterActive = true;
            }
            else if (_isFilterActive && e.Key == Key.Return)
            {
                var selectedValue = SelectedValue;
                ClearFilter();
                e.Handled      = true;
                IsDropDownOpen = false;
                EditableTextBox.SelectAll();
                SelectedValue = selectedValue;
                return;
            }

            base.OnPreviewKeyDown(e);
        }
        private void OnTextChanged(object sender, EventArgs e)
        {
            if (!IsTextSearchEnabled && _silenceEvents == 0)
            {
                RefreshFilter();

                if (Text.Length > 0)
                {
                    foreach (var item in CollectionViewSource.GetDefaultView(ItemsSource))
                    {
                        var itemText = GetItemText(item);
                        int text = itemText.Length, prefix = Text.Length;
                        SelectedItem = item;

                        _silenceEvents++;
                        EditableTextBox.Text = itemText;
                        EditableTextBox.Select(prefix, text - prefix);
                        _silenceEvents--;
                        break;
                    }
                }
            }
        }
        private void OnTextChanged(object sender, EventArgs e)
        {
            if (!_textSaved)
            {
                _savedText = Text;
                _textSaved = true;
            }

            if (IsTextSearchEnabled || _silenceEvents != 0)
            {
                return;
            }

            RefreshFilter();

            // Manually simulate the automatic selection that would have been
            // available if the IsTextSearchEnabled dependency property was set.
            if (Text.Length <= 0)
            {
                return;
            }
            var prefix = Text.Length;

            _collView = CollectionViewSource.GetDefaultView(ItemsSource);
            foreach (var item in _collView)
            {
                var text = item.ToString().Length;
                SelectedItem = item;

                SilenceEvents();
                EditableTextBox.Text = item.ToString();
                EditableTextBox.Select(prefix, text - prefix);
                UnSilenceEvents();
                break;
            }
        }
 private void RestoreSavedText()
 {
     Text = _textSaved ? _savedText : "";
     EditableTextBox.SelectAll();
 }
Пример #9
0
        private void CreateCommonLayout()
        {
            string keyLine   = Keys[0][_charSetUsed];
            int    keyWidth  = (_width - (keyLine.Length + 1) * _uiMargin) / keyLine.Length;
            int    keyHeight = (_height / 2 - 5 * _uiMargin) / 4;

            int widthRemaining = _width - ((keyLine.Length + 1) * _uiMargin + keyLine.Length * keyWidth);

            int x = _uiMargin + widthRemaining / 2,
                y = _uiMargin;

            _editLabel = new Label(string.Empty, x, y, _width - 2 * _uiMargin - widthRemaining, StyleManager.CurrentStyle.LabelFont.Height);
            base.AddChild(_editLabel);

            _editTextbox = new EditableTextBox(string.Empty, x, y, _editLabel._width, _height / 4 - 2 * _uiMargin);
            base.AddChild(_editTextbox);

            #region done/cancel buttons
            x = _editTextbox.ScreenRight - 2 * keyWidth - _uiMargin;
            y = _editTextbox.ScreenBottom + _uiMargin;

            _doneButton = new TextButton("Done", x, y, 2 * keyWidth + _uiMargin, keyHeight);
            _doneButton.ButtonPressed += (sender) => { Close(); };
            base.AddChild(_doneButton);

            x -= keyWidth * 2 + _uiMargin * 2;
            TextButton _cancelButton = new TextButton("Cancel", x, y, keyWidth * 2 + _uiMargin, keyHeight);
            _cancelButton.ButtonPressed += (sender) =>
            {
                _editTextbox.Text = _initialText;
                if (_allowCloseOnlyWhenValid)
                {
                    if (_editTextbox.Valid)
                    {
                        Close();
                    }
                }
                else
                {
                    Close();
                }
            };
            base.AddChild(_cancelButton);
            #endregion

            #region left/right/clear buttons
            Color  transparentColor = ColorUtility.ColorFromRGB(255, 0, 255);
            Bitmap leftImg          = Resources.Images.GetBitmap(Resources.Images.BitmapResources.arrowLeft);

            x = _uiMargin + widthRemaining / 2;
            y = _editTextbox.Height + 2 * _uiMargin;

            leftImg.MakeTransparent(transparentColor);
            _leftBut = new ImageButton(leftImg, x, y, keyHeight, keyHeight);
            _leftBut.RepeatKeyPress = true;
            _leftBut.ButtonPressed += (sender) =>
            {
                if (_editTextbox.CarretPosition != 0)
                {
                    _editTextbox.CarretPosition--;
                    RemakeButtonsEnabled();
                }
            };
            _leftBut.Enabled = false;
            x += _leftBut.Width + _uiMargin;
            base.AddChild(_leftBut);

            Bitmap rightImg = Resources.Images.GetBitmap(Resources.Images.BitmapResources.arrowRight);
            rightImg.MakeTransparent(transparentColor);
            _rightBut = new ImageButton(rightImg, x, y, keyHeight, keyHeight);
            _rightBut.RepeatKeyPress = true;
            _rightBut.ButtonPressed += (sender) =>
            {
                if (_editTextbox.CarretPosition != _editTextbox.Text.Length)
                {
                    _editTextbox.CarretPosition++;
                    RemakeButtonsEnabled();
                }
            };
            _rightBut.Enabled = false;
            x += _rightBut.Width + _uiMargin;
            base.AddChild(_rightBut);

            Bitmap clearImg = Resources.Images.GetBitmap(Resources.Images.BitmapResources.clear);
            clearImg.MakeTransparent(transparentColor);
            _clearBut = new ImageButton(clearImg, x, y, keyHeight, keyHeight);
            _clearBut.ButtonPressed += (sender) =>
            {
                if (_editTextbox.Text.Length != 0)
                {
                    _editTextbox.Text = string.Empty;
                    RemakeButtonsEnabled();
                }
            };
            _clearBut.Enabled = false;
            base.AddChild(_clearBut);
            #endregion
        }
Пример #10
0
        protected override void CreateInnerControls(ExolutioCanvas canvas)
        {
            base.CreateInnerControls(canvas);

            foldingButton = new FoldingButton();
            MainNode.InnerConnectorControl.Children.Add(foldingButton);
            Canvas.SetBottom(foldingButton, -15);
            foldingButton.Click += delegate { this.ViewHelper.IsFolded = !this.ViewHelper.IsFolded; };

            #region main node content components
            border = new Border
            {
                BorderBrush       = ViewToolkitResources.NodeBorderBrush,
                BorderThickness   = ViewToolkitResources.Thickness1,
                VerticalAlignment = VerticalAlignment.Stretch,
                Opacity           = ViewToolkitResources.LittleOpaque
            };
            MainNode.InnerContentControl.Content = border;

            stackPanel = new StackPanel
            {
                Orientation = Orientation.Vertical
            };
            border.Child = stackPanel;

            Border headerBorder = new Border
            {
                Background      = ViewToolkitResources.NoInterpretationBrush,
                BorderThickness = ViewToolkitResources.Thickness0,
                Padding         = ViewToolkitResources.Thickness2,
                BorderBrush     = ViewToolkitResources.BlackBrush
            };

            tbClassHeader = new EditableTextBox
            {
                FontWeight    = FontWeights.Bold,
                TextAlignment = TextAlignment.Center,
                Background    = ViewToolkitResources.NoInterpretationBrush,
                FontSize      = 15,
            };

            headerBorder.Child = tbClassHeader;
            stackPanel.Children.Add(headerBorder);

            Border attributesBorder = new Border
            {
                BorderBrush = ViewToolkitResources.BlackBrush,
                Visibility  = Visibility.Collapsed,
                Background  = ViewToolkitResources.ClassBody
            };
            StackPanel attributesSection = new StackPanel
            {
                Background = ViewToolkitResources.ClassBody
            };
            attributesBorder.Child = attributesSection;

            stackPanel.Children.Add(attributesBorder);
            //Border operationsBorder = new Border
            //{
            //    BorderBrush = ViewToolkitResources.BlackBrush,
            //    Visibility = Visibility.Collapsed,
            //    Background = ViewToolkitResources.SeaShellBrush
            //};

            //StackPanel operationsSection = new StackPanel
            //{
            //    Background = ViewToolkitResources.SeaShellBrush
            //};
            //operationsBorder.Child = operationsSection;
            //stackPanel.Children.Add(operationsBorder);

            //Border[] stackBorders = new Border[] { headerBorder, attributesBorder };
            //ITextBoxContainer[] stackContainers = new ITextBoxContainer[] { attributesContainer };
            //attributesContainer.StackBorders = stackBorders;
            //attributesContainer.StackContainers = stackContainers;
            //classOperations.StackBorders = stackBorders;
            //classOperations.StackContainers = stackContainers;

            #endregion

            ExolutioContextMenu exolutioContextMenu = MenuHelper.GetContextMenu(ScopeAttribute.EScope.PSMSchemaClass, this.DiagramView.Diagram);
            exolutioContextMenu.ScopeObject = PSMSchemaClass;
            exolutioContextMenu.Diagram     = DiagramView.Diagram;
            ContextMenu = exolutioContextMenu;

#if SILVERLIGHT
            ContextMenuService.SetContextMenu(headerBorder, ContextMenu);
#else
            headerBorder.ContextMenu  = ContextMenu;
            tbClassHeader.MouseEnter += tbClassHeader_MouseEnter;
            tbClassHeader.MouseLeave += tbClassHeader_MouseLeave;
#endif
        }
Пример #11
0
        public void SetSelection(Component component, bool focusComponent = false)
        {
            ClearSelection(false);
            ComponentViewBase view;

            RepresentantsCollection.TryGetValue(component, out view);
            bool textboxfound = false;

            if (view == null)
            {
                EditableTextBox t = null;
                if (component is PIMAttribute)
                {
                    view = RepresentantsCollection[((PIMAttribute)component).PIMClass];
                    t    = ((PIMClassView)view).AttributeTextBoxes.FirstOrDefault(tb => tb.PIMAttribute == component);
                }
                if (component is ModelOperation)
                {
                    view = RepresentantsCollection[((ModelOperation)component).PIMClass];
                    t    = ((PIMClassView)view).OperationTextBoxes.FirstOrDefault(tb => tb.ModelOperation == component);
                }
                if (component is PSMAttribute)
                {
                    view = RepresentantsCollection[((PSMAttribute)component).PSMClass];
                    t    = ((PSMClassView)view).FirstOrDefault(tb => tb.PSMAttribute == component);
                }
                if (t != null)
                {
                    t.Selected   = true;
                    textboxfound = true;
                }
            }
            if (view != null)
            {
                if (!textboxfound)
                {
                    view.SelectAndSelectCreatedControls();
                }
                if (focusComponent)
                {
                    //view.Focus();
                    double x = 0;
                    double y = 0;
                    if (view is INodeComponentViewBase)
                    {
                        x = Canvas.GetLeft(((INodeComponentViewBase)view).MainNode);
                        y = Canvas.GetTop(((INodeComponentViewBase)view).MainNode);
                    }
                    if (view is IConnectorViewBase)
                    {
                        x = ((IConnectorViewBase)view).Connector.GetBounds().Left;
                        y = ((IConnectorViewBase)view).Connector.GetBounds().Top;
                    }

#if SILVERLIGHT
#else
                    ScrollViewer scrollViewer = ExolutioCanvasWithZoomer.scrollViewer;
                    if (!double.IsNaN(x))
                    {
                        scrollViewer.ScrollToHorizontalOffset(x);
                    }
                    if (!double.IsNaN(y))
                    {
                        scrollViewer.ScrollToVerticalOffset(y);
                    }
#endif
                }
            }
            InvokeSelectionChanged();
        }
Пример #12
0
 public void Setup(EditableStatus status)
 {
     _textBoxWrapper           = A.Fake <ITextBoxWrapper>();
     _swappableTextboxStrategy = A.Fake <ISwappableTextboxStrategy>();
     _editableTextBox          = new EditableTextBox(_textBoxWrapper, _swappableTextboxStrategy, status);
 }
Пример #13
0
        protected override void CreateInnerControls(ExolutioCanvas canvas)
        {
            base.CreateInnerControls(canvas);
            #region main node content components
            border = new Border
            {
                BorderBrush       = ViewToolkitResources.NodeBorderBrush,
                BorderThickness   = ViewToolkitResources.Thickness1,
                VerticalAlignment = VerticalAlignment.Stretch,
                Opacity           = ViewToolkitResources.LittleOpaque
            };
            MainNode.InnerContentControl.Content = border;

            stackPanel = new StackPanel
            {
                Orientation = Orientation.Vertical
            };
            border.Child = stackPanel;

            Border headerBorder = new Border
            {
                Background      = ViewToolkitResources.ClassHeader,
                BorderThickness = ViewToolkitResources.Thickness0,
                Padding         = ViewToolkitResources.Thickness2,
                BorderBrush     = ViewToolkitResources.BlackBrush
            };

            tbClassHeader = new EditableTextBox
            {
                FontWeight    = FontWeights.Bold,
                TextAlignment = TextAlignment.Center,
                Background    = ViewToolkitResources.ClassHeader,
                FontSize      = 15,
            };

            headerBorder.Child = tbClassHeader;
            stackPanel.Children.Add(headerBorder);

            Border attributesBorder = new Border
            {
                BorderBrush = ViewToolkitResources.BlackBrush,
                Visibility  = Visibility.Collapsed,
                Background  = ViewToolkitResources.ClassBody
            };
            Border operationsBorder = new Border
            {
                BorderBrush = ViewToolkitResources.BlackBrush,
                Visibility  = Visibility.Collapsed,
                Background  = ViewToolkitResources.ClassBody
            };
            StackPanel attributesSection = new StackPanel
            {
                Background = ViewToolkitResources.ClassBody
            };
            StackPanel operationsSection = new StackPanel
            {
                Background = ViewToolkitResources.ClassBody
            };
            attributesBorder.Child = attributesSection;
            operationsBorder.Child = operationsSection;
            attributesContainer    = new PIMAttributesContainer(attributesSection, canvas, DiagramView);
            operationsContainer    = new PIMOperationsContainer(operationsSection, canvas, DiagramView);

            stackPanel.Children.Add(attributesBorder);
            stackPanel.Children.Add(operationsBorder);

            Border[]            stackBorders    = new Border[] { headerBorder, attributesBorder, operationsBorder };
            ITextBoxContainer[] stackContainers = new ITextBoxContainer[] { attributesContainer, operationsContainer };
            attributesContainer.StackBorders    = stackBorders;
            attributesContainer.StackContainers = stackContainers;
            operationsContainer.StackBorders    = stackBorders;
            operationsContainer.StackContainers = stackContainers;

            #endregion

            ExolutioContextMenu exolutioContextMenu = MenuHelper.GetContextMenu(ScopeAttribute.EScope.PIMClass, this.DiagramView.Diagram);
            ContextMenu = exolutioContextMenu;

#if SILVERLIGHT
            ContextMenuService.SetContextMenu(tbClassHeader, ContextMenu);
            DoubleClickSupplement dc = new DoubleClickSupplement();
            tbClassHeader.MouseLeftButtonDown += dc.Click;
            dc.DoubleClickW += tbClassHeader_MouseDoubleClick;
#else
            tbClassHeader.MouseDoubleClick += tbClassHeader_MouseDoubleClick;
#endif
        }