Exemple #1
0
        private void OnAreaHoverChanged(object sender, TrackingEventArgs <object> e)
        {
            switch (e.Index)
            {
            case 0:
                if (!e.IsTracked)
                {
                    LeftButtons.OnMouseLeave();
                }
                break;

            case 1:
                if (!e.IsTracked)
                {
                    _tabHover.Drop();
                }
                break;

            case 2:
                if (!e.IsTracked)
                {
                    RightButtons.OnMouseLeave();
                }
                break;
            }
        }
Exemple #2
0
 public virtual void CheckMRUButton()
 {
     if ((LeftButtons.Count > 0) || (RightButtons.Count > 0))
     {
         if (FilterPanel.AllowMRU)
         {
             bool?isNeedToDrawMRU;
             if ((RightButtons.Count > 0) && (LeftButtons.Count > 0))
             {
                 isNeedToDrawMRU = IsRightBoundCollidesLeft(
                     new Rectangle(RightButtons.Last().Bounds.X - RightButtons.Last().Bounds.Width, 0, 0, 0),
                     new Rectangle(LeftButtons.Last().Bounds.X, 0, GetButtonWidth(LeftButtons.Last().Bounds), 0));
                 if (isNeedToDrawMRU != null)
                 {
                     drawMRU = isNeedToDrawMRU.GetValueOrDefault();
                 }
             }
             else
             {
                 if ((RightButtons.Count == 0) && (LeftButtons.Count > 0))
                 {
                     if (FilterPanel.ShowCustomizeButton)
                     {
                         isNeedToDrawMRU = IsRightBoundCollidesLeft(
                             new Rectangle(FilterPanel.CustomizeButtonInfo.Bounds.X - SizeOfButton.Width, 0, 0, 0),
                             new Rectangle(LeftButtons.Last().Bounds.X, 0, GetButtonWidth(LeftButtons.Last().Bounds), 0));
                     }
                     else
                     {
                         isNeedToDrawMRU = IsRightBoundCollidesLeft(
                             new Rectangle(FilterPanel.Bounds.X - SizeOfButton.Width, 0, 0, 0),
                             new Rectangle(LeftButtons.Last().Bounds.X, 0, GetButtonWidth(LeftButtons.Last().Bounds), 0));
                     }
                     if (isNeedToDrawMRU != null)
                     {
                         drawMRU = isNeedToDrawMRU.GetValueOrDefault();
                     }
                 }
                 else
                 {
                     isNeedToDrawMRU = IsRightBoundCollidesLeft(
                         new Rectangle(RightButtons.Last().Bounds.X - RightButtons.Last().Bounds.Width, 0, 0, 0),
                         new Rectangle(FilterPanel.TextBounds.X + FilterPanel.TextBounds.Width, 0, RightButtons.Last().Bounds.Width, 0));
                     if (isNeedToDrawMRU != null)
                     {
                         drawMRU = isNeedToDrawMRU.GetValueOrDefault();
                     }
                 }
             }
         }
     }
 }
Exemple #3
0
 void GetButtonStates(List <ObjectState> states)
 {
     foreach (EditorButton button in controlView.CustomFilterPanelButtons)
     {
         if (button.IsLeft)
         {
             states.Add(LeftButtons.ToList().Find(p => p.Button == button).State);
         }
         else
         {
             states.Add(RightButtons.ToList().Find(p => p.Button == button).State);
         }
     }
 }
Exemple #4
0
        /// <summary>Raises the <see cref="E:System.Windows.Forms.Control.MouseDown"/> event.</summary>
        /// <param name="e">A <see cref="T:System.Windows.Forms.MouseEventArgs"/> that contains the event data.</param>
        protected override void OnMouseDown(MouseEventArgs e)
        {
            _mdX = e.X;
            _mdY = e.Y;
            Rectangle bounds;

            _areaMouseDown = HitTestArea(e.X, e.Y);
            switch (_areaMouseDown)
            {
            case 0:
                LeftButtons.OnMouseDown(e.X, e.Y, e.Button);
                break;

            case 1:
                int tabId = HitTestTab(_mdX, _mdY, out bounds);
                if (tabId != -1)
                {
                    _floatId = tabId;
                    int x   = e.X - bounds.X;
                    int y   = e.Y - bounds.Y;
                    var tab = _tabs[tabId];
                    _tabs[tabId].OnMouseDown(x, y, e.Button);
                    if (_tabs.Count <= tabId || _tabs[tabId] != tab)
                    {
                        _floatId = -1;
                    }
                    else
                    {
                        _readyToFloat = e.Button == MouseButtons.Left &&
                                        _tabs[tabId].Buttons.PressedButton == null;
                    }
                }
                else
                {
                    ViewHost.Focus();
                }
                break;

            case 2:
                RightButtons.OnMouseDown(e.X - (Width - RightButtons.Width), e.Y, e.Button);
                break;

            default:
                ViewHost.Focus();
                break;
            }
            base.OnMouseDown(e);
        }
Exemple #5
0
        public virtual void CalcButtons()
        {
            List <ObjectState> buttonStates = new List <ObjectState>();

            if (controlView.CustomFilterPanelButtons.Count == LeftButtons.Count + RightButtons.Count)
            {
                GetButtonStates(buttonStates);
            }
            ClearButtons();
            for (int n = 0; n < controlView.CustomFilterPanelButtons.Count; n++)
            {
                EditorButton currentButton = controlView.CustomFilterPanelButtons[n];
                if (!currentButton.Visible)
                {
                    continue;
                }
                EditorButtonObjectInfoArgs currentButtonInfo = CreateButtonInfo(currentButton, n);
                if (buttonStates.Count != 0)
                {
                    currentButtonInfo.State = buttonStates[n];
                }
                else
                {
                    currentButtonInfo.State = ObjectState.Normal;
                }
                currentButtonInfo.Bounds = GetButtonBounds(currentButton, controlView);
                if (currentButton.IsLeft)
                {
                    LeftButtons.Add(currentButtonInfo);
                }
                else
                {
                    RightButtons.Add(currentButtonInfo);
                }
            }
            int buttonWidth = GetCustomButtonWidth();

            if (buttonWidth > 0)
            {
                сustomButtonsCountToDraw = (FilterPanel.Bounds.Width - GetCurrentActiveFilterButtonsWidth()) / buttonWidth;
            }
            else
            {
                сustomButtonsCountToDraw = 0;
            }
        }
Exemple #6
0
        public ExceptionDialogViewModel(CoreException exception, IAppService appService)
        {
            CloseCommand   = Make.UICommand.Do(() => Close());
            CopyCommand    = Make.UICommand.Do(() => appService.CopyToClipBoard(Detail));
            RestartCommand = Make.UICommand.Do(() => appService.Restart());
            ExitCommand    = Make.UICommand.Do(() => appService.Exit());
            ReportCommand  = Make.UICommand.Do(() => appService.SendMail(exception.Description, Detail));

            RightButtons.Add(new UICore.Buttons.ButtonViewModel(CloseCommand, "Continue"));
            RightButtons.Add(new UICore.Buttons.ButtonViewModel(RestartCommand, "Restart"));
            RightButtons.Add(new UICore.Buttons.ButtonViewModel(ExitCommand, "Exit"));

            LeftButtons.Add(new UICore.Buttons.ButtonViewModel(CopyCommand, "Copy"));
            LeftButtons.Add(new UICore.Buttons.ButtonViewModel(ReportCommand, "Report"));

            Detail = exception.Exception.Message + "\n" + exception.Exception.GetBaseException().StackTrace;
        }
Exemple #7
0
        /// <summary>Raises the <see cref="E:System.Windows.Forms.Control.MouseUp"/> event.</summary>
        /// <param name="e">A <see cref="T:System.Windows.Forms.MouseEventArgs"/> that contains the event data.</param>
        protected override void OnMouseUp(MouseEventArgs e)
        {
            switch (_areaMouseDown)
            {
            case 0:
                LeftButtons.OnMouseUp(e.X, e.Y, e.Button);
                break;

            case 1:
                if (_floatId != -1)
                {
                    var offset = GetTabOffset(_floatId);
                    int x      = e.X;
                    int y      = e.Y;
                    switch (Side)
                    {
                    case AnchorStyles.Top:
                    case AnchorStyles.Bottom:
                        x -= offset;
                        break;

                    case AnchorStyles.Left:
                    case AnchorStyles.Right:
                        y -= offset;
                        break;
                    }
                    _tabs[_floatId].OnMouseUp(x, y, e.Button);
                }
                _readyToFloat = false;
                _floatId      = -1;
                break;

            case 2:
                RightButtons.OnMouseUp(e.X - (Width - RightButtons.Width), e.Y, e.Button);
                break;
            }
            _areaMouseDown = -1;
            base.OnMouseUp(e);
        }
Exemple #8
0
 private void MoreButton_MouseLeftButtonDown(object sender, MouseButtonEventArgs e)
 {
     if (rightsidevisible)
     {
         StartAnimation("HideNotification", RightButtons);
         Storyboard sb    = (Storyboard)FindResource("OpacityDown");
         Storyboard clone = sb.Clone();
         clone.Completed += (s, ev) => {
             NotificationArea.Visibility = Visibility.Hidden;
         };
         clone.Begin(NotificationArea);
         rightsidevisible = false;
     }
     else
     {
         double             rightMargin = CustomContent.Children.Count == 1 ? Int32.Parse(CustomContent.Children[0].GetValue(ActualWidthProperty).ToString()) + 50 : 50;
         ThicknessAnimation animation   = new ThicknessAnimation(new Thickness(0, 0, rightMargin, 0), new TimeSpan(0, 0, 0, 0, 250));
         RightButtons.BeginAnimation(MarginProperty, animation);
         NotificationArea.Visibility = Visibility.Visible;
         StartAnimation("OpacityUp", NotificationArea);
         rightsidevisible = true;
     }
 }
        protected override Rectangle CalcButtons(GraphicsCache cache)
        {
            bool autoFit = Item.TextEditStyle == TextEditStyles.HideTextEditor;
            EditorButtonCollection inpButtons = new EditorButtonCollection();

            if (this.OwnerEdit != null)
            {
                inpButtons = Item.Buttons;
            }
            else
            {
                inpButtons = ButtonsFromEditValue();
                //LeftButtons.Clear();
            }
            for (int n = 0; n < inpButtons.Count; n++)
            {
                EditorButton btn = inpButtons[n];
                if (!btn.Visible)
                {
                    continue;
                }
                EditorButtonObjectInfoArgs info = CreateButtonInfo(btn, n);
                info.FillBackground = FillBackground;
                CalcButtonState(info, n);
                info.Cache = cache;
                LeftButtons.Add(info);
            }
            CustomCalc targs = CreateCustomCalcButtonsRectsArgs(ClientRect);

            targs.UseAutoFit = false;
            targs.ViewInfo   = this;
            targs.Calc();
            RightButtons.SetCache(null);
            LeftButtons.SetCache(null);
            return(targs.ClientRect);
        }
Exemple #10
0
        /// <summary>Raises the <see cref="E:System.Windows.Forms.Control.Paint"/> event.</summary>
        /// <param name="e">A <see cref="T:System.Windows.Forms.PaintEventArgs"/> that contains the event data.</param>
        protected override void OnPaint(PaintEventArgs e)
        {
            var graphics    = e.Graphics;
            var width       = Width;
            int space       = width;
            var maxTabWidth = GetMaxTabWidth();

            graphics.TextRenderingHint = GraphicsUtility.TextRenderingHint;
            graphics.TextContrast      = GraphicsUtility.TextContrast;

            Renderer.RenderViewHostTabsBackground(this, e);

            var tabHeight = Renderer.TabHeight;
            var rect      = new Rectangle(0, 0, width, tabHeight);

            if (ViewHost.IsDocumentWell)
            {
                if (LeftButtons != null)
                {
                    var lbw = LeftButtons.Width;
                    if (lbw != 0)
                    {
                        rect.X += lbw + ViewConstants.TabHeaderButtonSpacing;
                        space  -= lbw + ViewConstants.TabHeaderButtonSpacing;
                        var buttonsRect = new Rectangle(0, 0, lbw, tabHeight);
                        LeftButtons.OnPaint(graphics, buttonsRect, ViewHost.IsActive);
                    }
                }
                if (RightButtons != null)
                {
                    var rbw = RightButtons.Width;
                    if (rbw != 0)
                    {
                        space -= rbw + ViewConstants.TabHeaderButtonSpacing;
                        var buttonsRect = new Rectangle(width - rbw, 0, rbw, tabHeight);
                        RightButtons.OnPaint(graphics, buttonsRect, ViewHost.IsActive);
                    }
                }
            }
            int dx = 0, dy = 0;

            graphics.SetClip(new Rectangle(rect.X, rect.Y, space, rect.Height));
            for (int i = _firstTabIndex; i < _tabs.Count; ++i)
            {
                var length = _tabs[i].Length;
                if (length > maxTabWidth)
                {
                    length = maxTabWidth;
                }
                space -= length;
                if (!_viewHost.IsDocumentWell)
                {
                    if (maxTabWidth != int.MaxValue && space < 3)
                    {
                        length += space;
                    }
                }
                switch (Side)
                {
                case AnchorStyles.Top:
                case AnchorStyles.Bottom:
                    rect.Width = length;
                    dx         = length;
                    break;

                case AnchorStyles.Left:
                case AnchorStyles.Right:
                    rect.Height = length;
                    dy          = length;
                    break;

                default:
                    throw new ApplicationException(
                              string.Format("Unknown AnchorStyle value: {0}", Side));
                }
                _tabs[i].OnPaint(graphics, rect);
                if (space <= 0)
                {
                    break;
                }
                rect.Offset(dx, dy);
            }
        }
Exemple #11
0
 public FindESPViewModel()
 {
     CloseCommand = Make.UICommand.Do(() => Close());
     RightButtons.Add(new UICore.Buttons.ButtonViewModel(CloseCommand, "Close"));
 }
Exemple #12
0
        /// <summary>Raises the <see cref="E:System.Windows.Forms.Control.MouseMove"/> event.</summary>
        /// <param name="e">A <see cref="T:System.Windows.Forms.MouseEventArgs"/> that contains the event data.</param>
        protected override void OnMouseMove(MouseEventArgs e)
        {
            if (_readyToFloat)
            {
                if (Math.Abs(_mdX - e.X) >= ViewConstants.ViewFloatDragMargin ||
                    Math.Abs(_mdY - e.Y) >= ViewConstants.ViewFloatDragMargin)
                {
                    var form = ViewHost.GetRootOwnerForm();
                    _readyToFloat = false;
                    var tab = _tabs[_floatId];
                    ViewHost.RemoveView(tab.View);
                    var host         = new ViewHost(ViewHost.Grid, false, false, new[] { tab.View });
                    var floatingForm = host.PrepareFloatingMode();
                    Capture = false;
                    ViewHost.Focus();
                    floatingForm.Show(form);
                    floatingForm.Shown += (sender, args) =>
                                          ((ViewHost)((Form)sender).Controls[0]).StartMoving(e.X, e.Y);
                    _floatId = -1;
                }
            }
            int areaId = _areaMouseDown;
            int tabId;
            int offset;

            if (areaId == -1)
            {
                areaId = HitTestArea(e.X, e.Y);
            }
            if (areaId == -1)
            {
                _areaHover.Drop();
            }
            else
            {
                _areaHover.Track(areaId, null);
            }
            if (areaId == -1)
            {
                _areaHover.Drop();
                tabId  = -1;
                offset = 0;
            }
            else
            {
                if (_floatId == -1)
                {
                    if (areaId == 1)
                    {
                        tabId = HitTestTab(e.X, e.Y, out var bounds);
                        if (tabId == -1)
                        {
                            _tabHover.Drop();
                        }
                        offset = bounds.X;
                    }
                    else
                    {
                        tabId  = -1;
                        offset = 0;
                    }
                }
                else
                {
                    areaId = 1;
                    tabId  = _floatId;
                    offset = GetTabOffset(_floatId);
                }
            }
            switch (areaId)
            {
            case 0:
                LeftButtons.OnMouseMove(e.X, e.Y, e.Button);
                break;

            case 1:
                if (tabId != -1)
                {
                    _tabHover.Track(tabId, _tabs[tabId]);
                    int x = e.X;
                    int y = e.Y;
                    switch (Side)
                    {
                    case AnchorStyles.Top:
                    case AnchorStyles.Bottom:
                        x -= offset;
                        break;

                    case AnchorStyles.Left:
                    case AnchorStyles.Right:
                        y -= offset;
                        break;
                    }
                    _tabs[tabId].OnMouseMove(x, y, e.Button);
                }
                break;

            case 2:
                RightButtons.OnMouseMove(e.X - (Width - RightButtons.Width), e.Y, e.Button);
                break;
            }
            base.OnMouseMove(e);
        }
Exemple #13
0
 private void ResetButtons()
 {
     if (ViewHost.IsDocumentWell)
     {
         var viewButtonSize = ViewManager.Renderer.ViewButtonSize;
         var space          = Width;
         space -= LeftButtons.Width + viewButtonSize +
                  2 * ViewConstants.TabHeaderButtonSpacing;
         var length = 0;
         if (FirstTabIndex == 0)
         {
             length = _length;
         }
         else
         {
             if (_length < space)
             {
                 FirstTabIndex = 0;
             }
             else
             {
                 if (FirstTabIndex >= _tabs.Count)
                 {
                     FirstTabIndex = _tabs.Count - 1;
                 }
                 for (int i = FirstTabIndex; i < _tabs.Count; ++i)
                 {
                     length += _tabs[i].Length;
                 }
                 int free = 0;
                 for (int i = FirstTabIndex - 1; i >= 0; --i)
                 {
                     free += _tabs[i].Length;
                     if (free + length > space)
                     {
                         FirstTabIndex = i + 1;
                         length       += free - _tabs[i].Length;
                         break;
                     }
                 }
             }
         }
         if (FirstTabIndex != 0)
         {
             if (LeftButtons.Count == 0)
             {
                 LeftButtons.SetAvailableButtons(ViewButtonType.ScrollTabsLeft);
             }
         }
         else
         {
             if (LeftButtons.Count == 1)
             {
                 LeftButtons.SetAvailableButtons(null);
             }
         }
         if (length > space)
         {
             bool needRightScroll = (FirstTabIndex != _tabs.Count - 1);
             if (needRightScroll)
             {
                 if (RightButtons.Count == 1)
                 {
                     RightButtons.SetAvailableButtons(
                         ViewButtonType.ScrollTabsRight,
                         ViewButtonType.TabsScrollMenu);
                 }
             }
             else
             {
                 if (RightButtons.Count == 2)
                 {
                     RightButtons.SetAvailableButtons(
                         ViewButtonType.TabsScrollMenu);
                 }
             }
         }
         else
         {
             if (RightButtons.Count == 2)
             {
                 if (FirstTabIndex == 0)
                 {
                     RightButtons.SetAvailableButtons(ViewButtonType.TabsMenu);
                 }
                 else
                 {
                     RightButtons.SetAvailableButtons(ViewButtonType.TabsScrollMenu);
                 }
             }
             else if (RightButtons.Count == 1)
             {
                 if (FirstTabIndex == 0)
                 {
                     if (RightButtons[0].Type == ViewButtonType.TabsScrollMenu)
                     {
                         RightButtons.SetAvailableButtons(ViewButtonType.TabsMenu);
                     }
                 }
                 else
                 {
                     if (RightButtons[0].Type == ViewButtonType.TabsMenu)
                     {
                         RightButtons.SetAvailableButtons(ViewButtonType.TabsScrollMenu);
                     }
                 }
             }
         }
     }
 }