예제 #1
0
 protected override void OnMouseDown(System.Windows.Forms.MouseEventArgs e)
 {
     if (this.RootBlock == null || this.RootBlock.MyRootControl == null)
     {
         return;
     }
     using (Redrawer a = new Redrawer(this.RootBlock))
     {
         base.OnMouseDown(e);
     }
 }
예제 #2
0
        private void lstItems_KeyDown(object sender, KeyEventArgs e)
        {
            bool shouldRaiseEvent = false;
            bool needToHide       = false;

            switch (e.KeyCode)
            {
            case Keys.Tab:
            case Keys.Return:
                PerformClick(new ItemClickReason(e.KeyCode));
                break;

            case Keys.Up:
            case Keys.Down:
            case Keys.PageUp:
            case Keys.PageDown:
                matchFound = true;
                break;

            case Keys.Escape:
                HideList();
                break;

            case Keys.Back:
            case Keys.Delete:
                shouldRaiseEvent = true;
                break;

            case Keys.Left:
            case Keys.Right:
            case Keys.Home:
            case Keys.End:
                shouldRaiseEvent = true;
                needToHide       = true;
                break;

            default:
                break;
            }

            if (shouldRaiseEvent && DefaultKeyHandler != null)
            {
                using (Redrawer r = new Redrawer(CurrentList.HostBlock.Root))
                {
                    if (needToHide)
                    {
                        Hide();
                    }
                    DefaultKeyHandler.OnKeyDown(e);
                }
            }
        }
예제 #3
0
 private void lstItems_KeyPress(object sender, KeyPressEventArgs e)
 {
     if (this.CommittingChars.Contains(e.KeyChar))
     {
         using (Redrawer r = new Redrawer(CurrentList.HostBlock.Root))
         {
             PerformClick(new ItemClickReason(e.KeyChar));
             DefaultKeyHandler.OnKeyPress(e);
         }
     }
     else if (DefaultKeyHandler != null && !char.IsControl(e.KeyChar))
     {
         DefaultKeyHandler.OnKeyPress(e);
     }
     e.Handled = true;
 }
예제 #4
0
 protected override void OnKeyPress(object sender, System.Windows.Forms.KeyPressEventArgs e)
 {
     base.OnKeyPress(sender, e);
     if (char.IsLetterOrDigit(e.KeyChar) && !e.Handled)
     {
         Block b = this.FindFirstFocusableChild();
         if (b != null && b.MyControl != null)
         {
             using (Redrawer r = new Redrawer(this.Root))
             {
                 b.SetCursorToTheEnd();
                 b.MyControl.OnKeyPress(e);
             }
             e.Handled = true;
         }
     }
 }
예제 #5
0
 private void PerformClick(ItemClickReason reason)
 {
     using (Redrawer r = new Redrawer(CurrentList.HostBlock.Root))
     {
         CompletionListItem ActiveItem = GetActiveItem();
         HideList();
         if (ActiveItem != null && matchFound)
         {
             ActiveItem.Reason = reason;
             ActiveItem.Click(CurrentList);
             if (CurrentList != null)
             {
                 CurrentList.RaiseItemClicked(ActiveItem);
             }
         }
     }
 }
예제 #6
0
        protected override void AppendNewToken(string prefix)
        {
            if (!Container.Completion.CanShow())
            {
                return;
            }

            using (Redrawer a = new Redrawer(this.Root))
            {
                TemporaryCompletionBlock empty = new TemporaryCompletionBlock(Container.Completion);
                empty.MyControl.Box.Padding.Right = ShapeStyle.DefaultFontSize;

                this.Parent.Children.Append(this, empty);

                empty.Text = prefix;
                empty.SetCursorToTheEnd();
                empty.Completion.ShowCompletionList(empty, prefix);
            }
        }
예제 #7
0
        private bool hidingList = false;         // guard
        public void HideList()
        {
            if (hidingList || CurrentList == null)
            {
                return;
            }
            hidingList = true;

            using (Redrawer r = new Redrawer(CurrentList.HostBlock.Root))
            {
                ViewWindow v = ParentControl as ViewWindow;

                if (v != null)
                {
                    v.ShouldRedrawOnWindowPaint = false;
                }

                ParentControl.Focus();
                Hide();
                Application.DoEvents();

                if (v != null)
                {
                    v.ShouldRedrawOnWindowPaint = true;
                }

                if (CurrentList != null)
                {
                    CurrentList.RaiseVisibleChanged(false);
                }
            }

//			lstItems.BeginUpdate();
//			lstItems.Items.Clear();
//			lstItems.EndUpdate();

            hidingList = false;
        }
예제 #8
0
        protected override void OnKeyDownReturn(System.Windows.Forms.KeyEventArgs e)
        {
            if (this.Prev != null && this.Next == null && this.Text == "")
            {
                using (Redrawer r = new Redrawer(Root))
                {
                    this.RemoveFocus(MoveFocusDirection.SelectNextInChain);
                    this.Delete();
                }
                return;
            }

            if (e.Control
                && ParentParent != null
                && ParentParent.Next != null)
            {
                ParentParent.Next.SetFocus();
            }
            else
            {
                base.OnKeyDownReturn(e);
            }
        }
예제 #9
0
        private void lstItems_KeyDown(object sender, KeyEventArgs e)
        {
            bool shouldRaiseEvent = false;
            bool needToHide = false;

            switch (e.KeyCode)
            {
                case Keys.Tab:
                case Keys.Return:
                    PerformClick(new ItemClickReason(e.KeyCode));
                    break;
                case Keys.Up:
                case Keys.Down:
                case Keys.PageUp:
                case Keys.PageDown:
                    matchFound = true;
                    break;
                case Keys.Escape:
                    HideList();
                    break;
                case Keys.Back:
                case Keys.Delete:
                    shouldRaiseEvent = true;
                    break;
                case Keys.Left:
                case Keys.Right:
                case Keys.Home:
                case Keys.End:
                    shouldRaiseEvent = true;
                    needToHide = true;
                    break;
                default:
                    break;
            }

            if (shouldRaiseEvent && DefaultKeyHandler != null)
            {
                using (Redrawer r = new Redrawer(CurrentList.HostBlock.Root))
                {
                    if (needToHide)
                    {
                        Hide();
                    }
                    DefaultKeyHandler.OnKeyDown(e);
                }
            }
        }
예제 #10
0
 void mSetter_Deleted(Block itemChanged)
 {
     using (Redrawer r = new Redrawer(this.Root))
     {
         if (mSetter != null)
         {
             mSetter.Deleted -= mSetter_Deleted;
             mSetter = null;
         }
         Empty.Hidden = false;
         Empty.SetFocus();
     }
 }
예제 #11
0
 //protected override void OnKeyPress(object sender, System.Windows.Forms.KeyPressEventArgs e)
 //{
 //    if (this.MyControl.IsFocused && !char.IsControl(e.KeyChar))
 //    {
 //        Completion.ShowCompletionList(this);
 //    }
 //}
 //protected override void OnTextHasChanged(ITextProvider changedControl, string oldText, string newText)
 //{
 //    base.OnTextHasChanged(changedControl, oldText, newText);
 //    if (Text.Length > 0)
 //    {
 //        Completion.ShowCompletionList(this, Text);
 //    }
 //    else
 //    {
 //        Completion.HideCompletionList();
 //    }
 //}
 protected override void OnMouseUpRight(GuiLabs.Canvas.Events.MouseWithKeysEventArgs e)
 {
     using (Redrawer r = new Redrawer(Root))
     {
         SetFocus();
         Completion.ShowCompletionList(this);
     }
     e.Handled = true;
 }
예제 #12
0
 protected void UnIndent()
 {
     using (Redrawer r = new Redrawer(this.Root))
     {
         this.RemoveFocus(MoveFocusDirection.SelectNextInChain);
         this.Delete();
     }
 }
예제 #13
0
 protected override void OnKeyDown(object sender, System.Windows.Forms.KeyEventArgs e)
 {
     if (e.KeyCode == System.Windows.Forms.Keys.Tab)
     {
         using (Redrawer r = new Redrawer(this.Root))
         {
             ToggleOrientation();
         }
         return;
     }
     base.OnKeyDown(sender, e);
 }
예제 #14
0
 public SingleRedrawTransaction(Block block, bool isDelayed)
     : base(block.ActionManager, isDelayed)
 {
     redrawer = new Redrawer(block.Root, true);
 }
예제 #15
0
        protected override void OnMouseUp(MouseWithKeysEventArgs e)
        {
            if (e.Handled == true)
            {
                return;
            }

            bool shouldShowPopupMenu = e.IsRightButtonPressed;

            using (Redrawer r = new Redrawer(Root))
            {
                if (DragState != null)
                {
                    if (DragState.Result != null)
                    {
                        DragState.Query.ShouldCopyInsteadOfMove = e.IsCtrlPressed;
                        DragState.Result.DropTargetContainer.AcceptBlocks(
                            DragState.Query,
                            DragState.Result);
                        shouldShowPopupMenu = false;
                        e.Handled = true;
                    }
                    else
                    {
                        if (DragState.DragStarted)
                        {
                            shouldShowPopupMenu = false;
                            e.Handled = true;
                        }
                    }
                    DragState = null;
                }

                if (shouldShowPopupMenu && e.IsRightButtonPressed)
                {
                    Block rightClicked = FindBlockAtPoint(e.X, e.Y);
                    if (rightClicked != null
                        && rightClicked.Menu != null
                        && rightClicked.MyControl.HitTest(e.X, e.Y))
                    {
                        if (rightClicked.CanGetFocus)
                        {
                            rightClicked.SetFocus();
                        }
                        MyRootControl.ShowPopupMenu(rightClicked.Menu, e.Location);
                        e.Handled = true;
                    }
                }
            }
        }
예제 #16
0
        protected bool CtrlEnter(bool shouldDeleteCurrent)
        {
            Block ParentParentNext = ParentParent != null ? ParentParent.Next : null;
            TextBoxBlock NextText = ParentParentNext as TextBoxBlock;
            shouldDeleteCurrent = shouldDeleteCurrent && this.Text == "" && this.Prev != null;

            if (this.Next != null || ParentParent == null)
            {
                return false;
            }

            if (NextText != null && NextText.Text == "")
            {
                using (Redrawer r = new Redrawer(this.Root))
                {
                    NextText.SetFocus();
                    if (shouldDeleteCurrent)
                    {
                        this.Delete();
                    }
                }
                return true;
            }
            else
            {
                ContainerBlock containingControlStructure = FindNearestControlStructureParent();
                if (shouldDeleteCurrent)
                {
                    this.MoveAfterBlock(ParentParent);
                    return true;
                }
                else if (containingControlStructure != null)
                {
                    containingControlStructure.AppendBlocks(CreateNewTextLine());
                    return true;
                }
            }

            return false;
        }
예제 #17
0
        public void HideList()
        {
            if (hidingList || CurrentList == null)
            {
                return;
            }
            hidingList = true;

            using (Redrawer r = new Redrawer(CurrentList.HostBlock.Root))
            {
                ViewWindow v = ParentControl as ViewWindow;

                if (v != null)
                {
                    v.ShouldRedrawOnWindowPaint = false;
                }

                ParentControl.Focus();
                Hide();
                Application.DoEvents();

                if (v != null)
                {
                    v.ShouldRedrawOnWindowPaint = true;
                }

                if (CurrentList != null)
                {
                    CurrentList.RaiseVisibleChanged(false);
                }
            }

            //			lstItems.BeginUpdate();
            //			lstItems.Items.Clear();
            //			lstItems.EndUpdate();

            hidingList = false;
        }
예제 #18
0
 private void lstItems_KeyPress(object sender, KeyPressEventArgs e)
 {
     if (this.CommittingChars.Contains(e.KeyChar))
     {
         using (Redrawer r = new Redrawer(CurrentList.HostBlock.Root))
         {
             PerformClick(new ItemClickReason(e.KeyChar));
             DefaultKeyHandler.OnKeyPress(e);
         }
     }
     else if (DefaultKeyHandler != null && !char.IsControl(e.KeyChar))
     {
         DefaultKeyHandler.OnKeyPress(e);
     }
     e.Handled = true;
 }
예제 #19
0
 private void PerformClick(ItemClickReason reason)
 {
     using (Redrawer r = new Redrawer(CurrentList.HostBlock.Root))
     {
         CompletionListItem ActiveItem = GetActiveItem();
         HideList();
         if (ActiveItem != null && matchFound)
         {
             ActiveItem.Reason = reason;
             ActiveItem.Click(CurrentList);
             if (CurrentList != null)
             {
                 CurrentList.RaiseItemClicked(ActiveItem);
             }
         }
     }
 }
예제 #20
0
        protected override void OnKeyDownBack(System.Windows.Forms.KeyEventArgs e)
        {
            if (this.MyTextBox.CaretPosition == 0 && Multiline)
            {
                TextLine previous = this.Prev as TextLine;

                if (previous != null)
                {
                    previous.JoinWithNext();
                    e.Handled = true;
                }
                else if (this.Prev != null)
                {
                    using (Redrawer a = new Redrawer(this.Root))
                    {
                        Block p = this.FindPrevFocusableBlock();
                        if (p != null)
                        {
                            p.SetCursorToTheEnd();
                        }
                        else
                        {
                            this.RemoveFocus(MoveFocusDirection.SelectPrev);
                        }
                        if (this.Text == "")
                        {
                            base.Delete();
                        }
                        e.Handled = true;
                    }
                }
                else
                {
                    using (new Redrawer(Root, true))
                    {
                        Block p = this.FindPrevFocusableBlockInChain();
                        if (p != null)
                        {
                            p.SetCursorToTheEnd();
                            e.Handled = true;
                        }
                    }
                }
            }
            if (!e.Handled)
            {
                base.OnKeyDownBack(e);
            }
        }
예제 #21
0
        protected override void OnKeyPress(object sender, System.Windows.Forms.KeyPressEventArgs e)
        {
            if (!char.IsLetterOrDigit(e.KeyChar))
            {
                return;
            }

            using (Redrawer r = new Redrawer(this.Root))
            {
                ModifierSeparatorBlock prev = this.Prev as ModifierSeparatorBlock;
                this.Delete();
                if (prev != null)
                {
                    prev.MyControl.OnKeyPress(e);
                }
            }
        }