void wTree_MouseLeave(object sender, EventArgs e)
 {
     RollOverNode = null;
     if ((BasicDrawing & BasicDrawings.RollOver) == BasicDrawings.RollOver)
     {
         DrawHandler.ReDrawTree(false);
     }
 }
Esempio n. 2
0
        void _control_MouseDown(object sender, MouseEventArgs e)
        {
            SelectionHandler.SelectedNode = _ownerNode;


            // SelectionHandler.SelectedItem = this;
            DrawHandler.ReDrawTree(false);
            SelectionHandler.SetNodeSelected(_ownerNode, this);
            //if (E_ItemSelected != null) E_ItemSelected(_ownerNode, this, e);
        }
Esempio n. 3
0
        /// <summary>
        /// item을 위해서 textboxeditor를 보여준다.
        /// </summary>
        /// <param name="item"></param>
        public override void ShowEditorFor(wTreeNodeItem item, Rectangle area)
        {
            if (SelectionHandler.SelectedNode != item.OwnerNode)
            {
                SelectionHandler.SelectedNode = item.OwnerNode;
                DrawHandler.ReDrawTree(false);
            }
            EditorControl.Text = item.Value.ToString();

            base.ShowEditorFor(item, area);
        }
Esempio n. 4
0
        /// <summary>
        /// 상속받은 에디터는 Value 를 수정한 뒤에는 이 함수를 호출해야 한다.
        /// </summary>
        /// <param name="oldValue"></param>
        /// <param name="newValue"></param>
        internal void OnEditorValueChanged(object oldValue, object newValue, bool callOnce = false)
        {
            if (_isValueChanged)
            {
                return;
            }
            if (callOnce)
            {
                _isValueChanged = true;
            }
            if (oldValue.Equals(newValue))
            {
                return;                           //editor value is not changed...
            }
            wEditorValueChangingArgs args = new wEditorValueChangingArgs(oldValue, newValue);

            if (E_EditorValueChanging != null)
            {
                E_EditorValueChanging(_itemToEdit, args);
            }
            if (args.IsCanceled)
            {
                if (E_EditorValueChangeCanceled != null)
                {
                    E_EditorValueChangeCanceled(ItemToEdit.OwnerNode, ItemToEdit);
                }
            }
            else
            {
                newValue = args.NewValue;

                if (oldValue.Equals(newValue) == false)
                {
                    _itemToEdit.SetValue(newValue);
                    _itemToEdit.OwnerNode.DrawBuffer();
                    DrawHandler.ReDrawTree(false);
                    if (E_EditorValueChanged != null)
                    {
                        E_EditorValueChanged(ItemToEdit, oldValue, newValue);
                    }
                }
                else
                {
                    if (E_EditorValueChangeCanceled != null)
                    {
                        E_EditorValueChangeCanceled(ItemToEdit.OwnerNode, ItemToEdit);
                    }
                }
            }
        }
        /// <summary>
        /// item을 위해서 textboxeditor를 보여준다.
        /// </summary>
        /// <param name="item"></param>
        public override void ShowEditorFor(wTreeNodeItem item, Rectangle area)
        {
            base.ShowEditorFor(item, area);
            ImageSelectorDialog dlg    = new ImageSelectorDialog();
            DialogResult        result = dlg.ShowDialog(item.Image, item._imageWidth, item._imageHeight);

            if (result == DialogResult.Abort || result == DialogResult.Cancel)
            {
                return;
            }
            item.Image        = dlg.NewImage;
            item._imageWidth  = dlg.ImageWidth;
            item._imageHeight = dlg.ImageHeight;
            item.OwnerNode.DrawBuffer();
            DrawHandler.ReDrawTree(false);
        }
        /// <summary>
        /// 마우스 키를 눌렀을 때
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        void wTree_MouseDown(object sender, MouseEventArgs e)
        {
            Point     pt;
            wTreeNode selectedNode = GetNodeFromPoint(e.Location, out pt);
            //int index = 0;
            wTreeNodeItemMouseArgs args = new wTreeNodeItemMouseArgs(new MouseEventArgs(e.Button, e.Clicks, pt.X, pt.Y, e.Delta));
            wTreeNodeItem          item = (selectedNode == null) ? null : selectedNode.GetItemFromPoint(pt);

            if (E_TreeNodeMouseDown != null)
            {
                E_TreeNodeMouseDown(selectedNode, item, args);
            }
            if (args.IsCanceled)
            {
                return;
            }

            _pressedNode = selectedNode;
            _pressedItem = item;
            if (_pressedItem != null && _pressedItem.ItemType == wTreeNodeItemTypes.CheckBox)
            {
            }
            else
            {
                if ((ModifierKeys & Keys.Control) != Keys.Control)//Control을 안눌렀다면 이전의 선택부분을 모두 지움..
                {
                    if ((ModifierKeys & Keys.Shift) == Keys.Shift)
                    {
                        if (_isShiftDown)//이전에 shift를 누른 채 떼지 않았다면..
                        {
                            //_pressedNode = _lastMouseUp;//이전에 클릭했던 지점부터 시작..

                            //SelectedNode = _lastMouseUp;
                            int tempSelecting = VisibleNodes.IndexOf(selectedNode);
                            SelectionHandler.drawSelectingNodes(VisibleNodes.IndexOf(_lastMouseUpNode), tempSelecting);
                            _isShiftDown = true;
                        }
                        else
                        {
                            SelectionHandler.ClearAllSelections();

                            //_pressedNode = _lastMouseUp;//이전에 클릭했던 지점부터 시작..

                            //SelectedNode = _lastMouseUp;
                            int tempSelectingStart = VisibleNodes.IndexOf(_lastMouseUpNode);
                            int tempSelecting      = VisibleNodes.IndexOf(selectedNode);
                            SelectionHandler.drawSelectingNodes(tempSelectingStart, tempSelecting);
                            _isShiftDown = true;
                        }
                        DrawHandler.ReDrawTree(false);
                    }
                    else
                    {
                        SelectionHandler.ClearAllSelections();

                        //SetNodeSelected(selectedNode, pt);
                        DrawHandler.ReDrawTree(false);
                    }

                    //this.Focus();
                }
            }
            if (EditorHandler.ActivatedEditor != null || _ownerTree.Focused == false)
            {
                ReleaseFocus();
            }
        }
        /// <summary>
        /// 마우스키를 뗐을 때..
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        void wTree_MouseUp(object sender, MouseEventArgs e)
        {
            if (_doubleClicked)
            {
                _doubleClicked = false;
                return;
            }


            Point pt;
            //= new Point(e.X - Margin.Left, e.Y - Margin.Top);
            wTreeNode mouseUpNode = GetNodeFromPoint(e.Location, out pt);// _pressedNode;

            //Point pt;
            //wTreeNode clickedNode = GetNodeFromPoint(e.Location, out pt);// _pressedNode;
            //wTreeNodeItem item = clickedNode.GetItemFromPoint(pt);
            //wTreeNodeItemMouseArgs args = new wTreeNodeItemMouseArgs(e);
            //if (E_TreeNodeDoubleClicked != null) E_TreeNodeDoubleClicked(clickedNode, item, args);

            wTreeNodeItem item = (mouseUpNode == null)? null : mouseUpNode.GetItemFromPoint(pt);

            wTreeNodeItemMouseArgs args = new wTreeNodeItemMouseArgs(new MouseEventArgs(e.Button, e.Clicks, pt.X, pt.Y, e.Delta));


            if (E_TreeNodeMouseUp != null)
            {
                E_TreeNodeMouseUp(mouseUpNode, mouseUpNode.GetItemFromPoint(pt), args);
            }
            if (args.IsCanceled)
            {
                return;
            }

            SelectionHandler.FixSelections();

            if (_pressedNode != null && mouseUpNode != null)
            {
                bool isDragging;
                if (_pressedNode != mouseUpNode)
                {
                    isDragging = true;
                }
                else
                {
                    isDragging = false;
                }
                if (EditorHandler.ActivatedEditor != null && EditorHandler.ActivatedEditor.ItemToEdit != item)
                {
                    EditorHandler.HideEditor();
                }

                if (e.Button == System.Windows.Forms.MouseButtons.Left)
                {
                    if ((ModifierKeys & Keys.Control) == Keys.Control)
                    {
                        if (isDragging)//selection
                        {
                        }
                        else //제자리 클릭..
                        {
                        }
                    }
                    else if ((ModifierKeys & Keys.Shift) == Keys.Shift)
                    {
                    }
                    else
                    {
                    }
                }
                if (item != null && isDragging == false)                    //item clicked or right clicked
                {
                    if (e.Button == System.Windows.Forms.MouseButtons.Left) //item clicked
                    {
                        if (Control.ModifierKeys == Keys.None)
                        {//click
                        }
                        else if ((Control.ModifierKeys & Keys.Control) == Keys.Control)
                        {
                        }
                        else if ((Control.ModifierKeys & Keys.Shift) == Keys.Shift)
                        {
                        }
                        else if ((Control.ModifierKeys & Keys.Alt) == Keys.Alt)
                        {
                        }
                    }
                }
            }

            _pressedNode = null;
            SelectionHandler.ReleaseTempSelection();

            _lastMouseUpNode = mouseUpNode;
            _lastMouseUpItem = item;
            DrawHandler.ReDrawTree(false);
            //SetNodeSelected(selectedNode, pt);
            //this.Focus();
        }
        /// <summary>
        /// 마우스커서가 움직일 때..
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        void wTree_MouseMove(object sender, MouseEventArgs e)
        {
            bool isRollOver = (DrawHandler.BasicDrawing & BasicDrawings.RollOver) != BasicDrawings.None;
            bool isMultipleSelection //drag&drop 가능시 drag로 multiple selection은 활성화되면 안된다.
                = IsDragAndDropEnabled == false && (DrawHandler.BasicDrawing & BasicDrawings.MultiSelections) != BasicDrawings.None;


            if (isMultipleSelection ||
                E_TreeNodeMouseDragging != null
                )
            {
                if (Control.MouseButtons == System.Windows.Forms.MouseButtons.Left)
                {
                    wTreeNode hoveredNode = null;
                    Point     pt;
                    //= new Point(e.X - Margin.Left, e.Y - Margin.Top);
                    hoveredNode = GetNodeFromPoint(e.Location, out pt);// _pressedNode;
                    wTreeNodeItem item = (hoveredNode == null)? null : hoveredNode.GetItemFromPoint(pt);

                    if (_pressedNode != null)
                    {
                        wTreeNodeItemMouseArgs args = new wTreeNodeItemMouseArgs(new MouseEventArgs(e.Button, e.Clicks, pt.X, pt.Y, e.Delta));
                        bool isNewArea = (RollOverNode == null || RollOverNode.Equals(hoveredNode) == false);
                        if (E_TreeNodeMouseDragging != null)
                        {
                            E_TreeNodeMouseDragging(hoveredNode, item, isNewArea, args);
                        }
                        if (args.IsCanceled)
                        {
                            return;
                        }


                        if (hoveredNode != null && isNewArea)
                        {
                            int tempSelecting      = VisibleNodes.IndexOf(hoveredNode);
                            int tempSelectingStart = VisibleNodes.IndexOf(_pressedNode);
                            SelectionHandler.drawSelectingNodes(tempSelectingStart, tempSelecting);
                            wTreeNode oldRollOver = RollOverNode;
                            RollOverNode = hoveredNode;
                            if ((BasicDrawing & BasicDrawings.RollOver) == BasicDrawings.RollOver)
                            {
                                hoveredNode.DrawBuffer();
                            }


                            DrawHandler.ReDrawTree(false);
                            //if(oldRollOver!=null) ReDrawNode(oldRollOver);
                            //if(RollOverNode!=null) ReDrawNode(RollOverNode);
                        }
                    }
                }
            }
            else if (E_TreeNodeMouseMove != null ||
                     isRollOver
                     )//이벤트가 구현되었을 때만 들어가도록..
            {
                wTreeNode hoveredNode = null;
                Point     pt;
                //= new Point(e.X - Margin.Left, e.Y - Margin.Top);
                hoveredNode = GetNodeFromPoint(e.Location, out pt);// _pressedNode;

                //if (hoveredNode == null) return;

                wTreeNodeItem item = (hoveredNode == null) ? null : hoveredNode.GetItemFromPoint(pt);

                wTreeNodeItemMouseArgs args = new wTreeNodeItemMouseArgs(new MouseEventArgs(e.Button, e.Clicks, pt.X, pt.Y, e.Delta));
                bool isNewArea = (RollOverNode == null || RollOverNode.Equals(hoveredNode) == false);
                if (E_TreeNodeMouseMove != null)
                {
                    E_TreeNodeMouseMove(SelectionHandler.SelectedNode, item, isNewArea, args);
                }
                if (args.IsCanceled)
                {
                    return;
                }

                if (hoveredNode != null && isNewArea)
                {//selectedNode가 null이 아니고, 이전 _rollOverNode가 아닐 때, 혹은 처음 rollOver되었을 때..
                 //selectedNode.IsExpaned = !selectedNode.IsExpaned;



                    wTreeNode oldRollOver = RollOverNode;
                    RollOverNode = hoveredNode;

                    //SelectedNode = selectedNode;
                    if ((BasicDrawing & BasicDrawings.RollOver) == BasicDrawings.RollOver)
                    {
                        hoveredNode.DrawBuffer();
                    }

                    //wTreeNodeItem item = hoveredNode.GetItemFromPoint(pt);

                    if ((BasicDrawing & BasicDrawings.RollOver) == BasicDrawings.RollOver)
                    {
                        DrawHandler.ReDrawTree(false);
                    }
                    //if (oldRollOver != null) ReDrawNode(oldRollOver);
                    //if (RollOverNode != null) ReDrawNode(RollOverNode);
                }
            }
            else if (_pressedNode != null && IsDragAndDropEnabled)
            {
                if (E_TreeNodeDraggedOut != null)
                {
                    E_TreeNodeDraggedOut(_pressedNode, null, null);
                }
                _pressedNode = null;
                _pressedItem = null;
            }
        }
Esempio n. 9
0
        /// <summary>
        /// 노드를 그리기 위한 버퍼. 노드 자체적으로 가지는 버퍼를 그린다.
        /// </summary>
        internal void DrawBuffer()
        {
            Size drawSize             = new Size(0, 0);
            wTreeNodeDrawingArgs args = null;
            bool isUserDrawn          = false;

            if (DrawHandler.UseCustomDrawing)
            {
                args = new wTreeNodeDrawingArgs(this, 0, 0);
                DrawHandler.CustomDrawing(args);
                if (args.UserDrawn)
                {
                    _drawnByUser   = true;
                    _imgToDrawNode = args.DrawnBuffer;
                    drawSize       = args.DrawnSize;
                    isUserDrawn    = true;
                    _lineHeight.Clear();
                    _lineHeight[0] = _imgToDrawNode.Height;
                }
            }
            if (isUserDrawn)
            {
                //drawItemsInBuffer();
                return;//이미 그렸으므로 지나감.
            }

            _drawnByUser = false;
            Graphics g = Graphics.FromImage(DrawHandler.ImageTempBufferToDrawForTree);
            //단순히 크기 가져오는 것이므로 버퍼는 그냥 전체버퍼를 사용.
            int wid = 0;
            //int wid = 0;
            int moveY = 0;

            int  maxHeight = 0;
            int  maxWid    = 0;
            Size itemSize;

            _lineHeight = new Dictionary <int, int>(); //첫 줄의 높이.
            int lineNum = 0;                           //줄바꿈이 있을 경우,줄의 번호..0부터 시작.

            foreach (wTreeNodeItem item in this.Items)
            {
                itemSize = item.GetItemSize();

                if (item.ItemType == wTreeNodeItemTypes.WhiteSpace)
                {
                    if ((WhiteSpaceTypes)item.Value == WhiteSpaceTypes.Return)
                    //if (itemSize.Width < 0)//다음줄로 넘어감..whiteSpace가 Return일 때..
                    {
                        moveY    += maxHeight;
                        maxHeight = 0;
                        wid       = 0;
                        lineNum++;
                    }
                    else
                    {
                        wid += itemSize.Width;//Space크기..
                    }
                }
                else
                {
                    wid                 += itemSize.Width;                     //item왼쪽의 margin
                    maxHeight            = getMax(maxHeight, itemSize.Height); //item 위쪽의 margin이다.
                    _lineHeight[lineNum] = maxHeight + ItemYMargin;            //각 줄의 높이를 구한다.//최대에서 ItemYMargin만큼 키운다.
                }
                maxWid = getMax(maxWid, wid);                                  //줄이바뀌어도 maxWid는 가장 큰 wid를 유지해야 함..
            }

            int totalHeight = 0;

            foreach (int lineHeight in _lineHeight.Values)
            {
                totalHeight += lineHeight;
            }


            Size buffSize = new Size(maxWid + moveX, totalHeight);// maxHeight + moveY);//버퍼크기를 정하고..(x margin은 2, ymargin은 4)

            if (ImageBufferToDraw == null || ImageBufferToDraw.Width != buffSize.Width || ImageBufferToDraw.Height != buffSize.Height)
            {//크기가 다르거나버퍼 없을 경우 다시 버퍼를 만들어줌..
                _imgToDrawNode = new Bitmap(buffSize.Width, buffSize.Height, System.Drawing.Imaging.PixelFormat.Format32bppArgb);
            }



            drawItemsInBuffer();
        }