Beispiel #1
0
        protected virtual void RunWhenEndNodeClicked(RtwTreeNode endNode, Actions action)
        {
            if ((action & Actions.CheckBoxClick) > 0)
            {
                //endNode.Checked = endNode.Checked;
                if (endNode.Checked == true)
                {
                    endNode.Checked = false;
                }
                else if (endNode.Checked == false)
                {
                    endNode.Checked = true;
                }
                else //null
                {
                    endNode.Checked = true;
                }
            }
            if ((action & Actions.ContextMenuOpened) > 0)
            {
                _selectedTreeNode = endNode;
                U_ContextMenuParentNode.HorizontalOffset = 10;
                U_ContextMenuParentNode.VerticalOffset   = 10;

                U_ContextMenuParentNode.IsOpen = true;
            }
            if ((action & Actions.CopyNameToClipBaord) > 0)
            {
                System.Windows.Clipboard.SetDataObject(endNode.Text, false); //클릭시 저장함.
            }


            //if (endNode.Parent != null)
            //   endNode.Parent.CheckSelf();
        }
Beispiel #2
0
 public void AddChild(RtwTreeNode child)
 {
     _children.Add(child);
     child.Parent          = this;
     Tag                   = "Parent";
     child.E_CheckChanged += new TreeNodeCheckChangedHandler(child_E_CheckChanged);
 }
Beispiel #3
0
        private void EventTrigger_Selected(object sender, RoutedEventArgs e)
        {
            VerifyAccess();
            TreeViewItem item = sender as TreeViewItem;
            RtwTreeNode  tr   = item.Header as RtwTreeNode;

            tr.Checked = true;
        }
Beispiel #4
0
 public TreeNodeClickEventArg(List <String> treePath, List <int> treeIndexPath, Object checkedState, RtwTreeNode node, TreeViewItem item, ContentPresenter p)
 {
     TreePath         = treePath;
     TreeIndexPath    = treeIndexPath;
     Checked          = checkedState;
     NodeSource       = node;
     Item             = item;
     ContentPresenter = p;
 }
Beispiel #5
0
        void Test()
        {
            VerifyAccess();
            for (int j = 0; j < 4; j++)
            {
                RtwTreeNode model = new RtwTreeNode("model" + j, false);
                for (int i = 0; i < 4; i++)
                {
                    model.AddChild(new RtwTreeNode("var" + i, false));
                }

                this.Items.Add(model);
            }
        }
Beispiel #6
0
 public void init(String name, String text, bool?Checked, String objName, Object relativeObject, RtwTreeNode parent)
 {
     _name                 = name;
     _parent               = parent;
     _isChecked            = (Checked == null) ? this._isChecked = false : _isChecked = Checked;
     _relativeObj[objName] = relativeObject;
     Tag        = "Child";//기본값은 Child, 자식이 생기면 Parent
     Text       = text;
     UserDisign = new UserControl();
     _enabled   = true;
     if (parent != null)
     {
         ToolTipText = PathNameStr;
     }
 }
Beispiel #7
0
 protected virtual void RunWhenEndNodeClicked(RtwTreeNode endNode)
 {
     if (endNode.Checked == true)
     {
         endNode.Checked = false;
     }
     else if (endNode.Checked == false)
     {
         endNode.Checked = true;
     }
     else //null
     {
         endNode.Checked = true;
     }
 }
Beispiel #8
0
        public RtwTreeNode getNodeByText(String TextPath, String seperator = ".")
        {
            String[]    texts = TextPath.Split(seperator.ToCharArray());
            int         depth = 0;
            RtwTreeNode node  = null;

            if (Items.Count > 0)
            {
                for (int i = 0; i < Items.Count; i++)
                {
                    if (Items[i].Text.Equals(texts[depth]))
                    {
                        depth++;
                        node = Items[i];
                        break;
                    }
                }
                if (node == null)
                {
                    return(null);
                }
            }
            else
            {
                return(null);
            }

            while (node.Children.Count > 0 && texts.Length > depth)
            {
                for (int i = 0; i < node.Children.Count; i++)
                {
                    if (node.Children[i].Text.Equals(texts[depth]))
                    {
                        depth++;
                        node = node.Children[i];
                        break;
                    }
                }
            }
            if (texts.Length == depth)
            {
                return(node);
            }
            else
            {
                return(null);
            }
        }
Beispiel #9
0
        /*
         * Boolean _mouseOverDispatched = false;
         * void MouseEnter(Object sender, RoutedEventArgs e)
         * {
         *  _clickSender = sender;
         *  _clickEventArg = e;
         *  DelFunc func = OnMouseOver;
         *  Dispatcher.Invoke(DispatcherPriority.Normal, new Action(func));
         *  if (_mouseOverDispatched == false) OnMouseOver();
         *  _mouseOverDispatched = false;
         * }
         *
         * void OnMouseOver()
         * {
         *  object sender = _clickSender;
         *  RoutedEventArgs e = _clickEventArg;
         *
         *  ContentPresenter p = null;
         *  TreeViewItem item = null;
         *  TreeNode up = null;
         *  try
         *  {
         *      if (e.OriginalSource is TextBlock)
         *      {
         *          //p = (e.OriginalSource as TextBlock).TemplatedParent as ContentPresenter;
         *          p = (e.OriginalSource as TextBlock).TemplatedParent as ContentPresenter;
         *      }
         *      else if (e.OriginalSource is Rectangle)
         *      {
         *          if ((e.OriginalSource as Rectangle).TemplatedParent is ContentPresenter)
         *          {
         *              p = (e.OriginalSource as Rectangle).TemplatedParent as ContentPresenter;
         *          }
         *          else
         *          {
         *              item = (e.OriginalSource as Rectangle).TemplatedParent as TreeViewItem;
         *          }
         *      }
         *      else if(e.OriginalSource is TreeViewItem)
         *      {
         *          item = e.OriginalSource as TreeViewItem;
         *      }else if(e.OriginalSource is TreeView){
         *          TreeView view = (e.OriginalSource as TreeView);
         *      }else{
         *          return;
         *      }
         *      if (item != null)
         *      {
         *          up = item.Header as TreeNode;
         *          (item.Parent as Grid).Children[0].Visibility = System.Windows.Visibility.Hidden;
         *      }
         *      else
         *      {
         *          up = p.Content as TreeNode;
         *          (p.Parent as Grid).Children[0].Visibility = System.Windows.Visibility.Hidden;
         *      }
         *  }
         *  catch
         *  {
         *
         *  }
         *  finally
         *  {
         *      _mouseOverDispatched = true;
         *  }
         * }
         */



        void addItemForTest()
        {
            //VerifyAccess();
            List <RtwTreeNode> newlist = new List <RtwTreeNode>(this.Items);

            for (int j = 0; j < 1; j++)
            {
                RtwTreeNode model = new RtwTreeNode("Tree" + j, false);
                for (int i = 0; i < 2; i++)
                {
                    model.AddChild(new RtwTreeNode("TreeNode" + i, false));
                }

                newlist[0].AddChild(model);
            }
            this.Items = newlist;
        }
Beispiel #10
0
        protected virtual void RunWhenParentNodeClicked(RtwTreeNode parentNode, Actions action)
        {
            //addItemForTest(); //forTest

            if ((action & Actions.CheckBoxClick) > 0)
            {
                //endNode.Checked = endNode.Checked;
                if (parentNode.Checked == true)
                {
                    parentNode.Checked = false;
                }
                else if (parentNode.Checked == false)
                {
                    parentNode.Checked = true;
                }
                else //null
                {
                    parentNode.Checked = true;
                }
            }
            if ((action & Actions.ContextMenuOpened) > 0)
            {
                _selectedTreeNode = parentNode;
                U_ContextMenuParentNode.HorizontalOffset = 10;
                U_ContextMenuParentNode.VerticalOffset   = 10;

                U_ContextMenuParentNode.IsOpen = true;
            }
            if ((action & Actions.CopyNameToClipBaord) > 0)
            {
                System.Windows.Clipboard.SetDataObject(parentNode.Text, false); //클릭시 저장함.
            }
            if ((action & Actions.OpenChildren) > 0)
            {
            }
        }
Beispiel #11
0
 public TreeNodeCheckChangedArgs(RtwTreeNode node, bool?checkState, bool?beforeCheckState)
 {
     CheckState       = checkState;
     BeforeCheckState = beforeCheckState;
     Node             = node;
 }
Beispiel #12
0
 public RtwTreeNode(String name, String text, bool?Checked, String objName, Object relativeObject, RtwTreeNode parent = null)
 {
     init(name, text, Checked, objName, relativeObject, parent);
 }
Beispiel #13
0
 public int IndexOfChild(RtwTreeNode node)
 {
     return(_children.IndexOf(node));
 }
Beispiel #14
0
        void CheckBoxClicked(object sender, RoutedEventArgs e)
        {
            VerifyAccess();
            if (_isChecking || RtwTreeNode.IsChecking())
            {
                return;
            }
            _isChecking = true; //무한루프를 막기위함..
            CheckBox         c = sender as CheckBox;
            ContentPresenter p = c.TemplatedParent as ContentPresenter;
            RtwTreeNode      treeNode;
            TreeViewItem     item = null;// = WpfFinder.getParentFromTemplate(c, DependencyObjectType.FromSystemType(typeof(TreeViewItem))) as TreeViewItem;

            //try
            //{
            if (p == null)
            {
                item     = c.TemplatedParent as TreeViewItem;
                treeNode = item.Header as RtwTreeNode;
            }
            else
            {
                treeNode = p.Content as RtwTreeNode;
            }

            /*
             * if (treeNode.Enabled && treeNode.Children.Count > 0)
             * {
             *  if (treeNode.Checked != null)
             *  {
             *      treeNode.CheckRecursive(c.IsChecked);
             *  }
             *  else
             *  {
             *      treeNode.CheckRecursive(true);
             *  }
             *  //if (treeNode.Parent != null) treeNode.Parent.CheckSelf();
             * }
             */



            //L_Title.Content = c.Name;
            //MessageBox.Show(c.Name);
            List <RtwTreeNode> Added    = new List <RtwTreeNode>();
            List <RtwTreeNode> Removed  = new List <RtwTreeNode>();
            List <RtwTreeNode> Selected = new List <RtwTreeNode>();

            if (treeNode.Children.Count == 0 && treeNode.Parent != null)     //endNode
            {
                if (BeforeClickedParent != treeNode.Parent)
                {
                    BeforeClickedParent = null;
                    BeforeClickedRow    = -1;
                }

                int row_index = treeNode.Parent.IndexOfChild(treeNode);
                if (E_OnNodeDoubleClicked != null && treeNode.Enabled == true && _isEventEnabled)
                {
                    E_OnNodeDoubleClicked(this, new TreeNodeClickEventArg(treeNode.Path, treeNode.IndexPath, treeNode.Checked, treeNode, item, p));
                }


                if ((System.Windows.Input.Keyboard.GetKeyStates(Key.LeftShift) & KeyStates.Down) == KeyStates.Down)
                {
                    if (BeforeClickedRow >= 0)
                    {
                        int min = (BeforeClickedRow < row_index) ? BeforeClickedRow : row_index;
                        int max = (BeforeClickedRow < row_index) ? row_index : BeforeClickedRow;


                        for (int i = min; i <= max; i++)
                        {
                            RtwTreeNode child = treeNode.Parent.Children[i];
                            if (child.Enabled)
                            {
                                if (E_OnNodeChecked != null && _isEventEnabled && child.Checked != true)
                                {
                                    Added.Add(child);
                                }

                                treeNode.Parent.Children[i].Checked = true;
                            }
                        }
                        if (E_OnNodeChecked != null && _isEventEnabled)
                        {
                            Selected = treeNode.SelectedSiblings;
                        }
                        if (E_OnNodeChecked != null && _isEventEnabled)
                        {
                            E_OnNodeChecked(this, new TreeNodeCheckedEventArg(Selected, Added, Removed));
                        }
                    }
                }
                else if ((System.Windows.Input.Keyboard.GetKeyStates(Key.LeftCtrl) & KeyStates.Down) == KeyStates.Down)
                {
                    if (BeforeClickedRow >= 0)
                    {
                        int min = (BeforeClickedRow < row_index) ? BeforeClickedRow : row_index;
                        int max = (BeforeClickedRow < row_index) ? row_index : BeforeClickedRow;

                        for (int i = min; i <= max; i++)
                        {
                            RtwTreeNode child = treeNode.Parent.Children[i];
                            if (child.Enabled)
                            {
                                if (E_OnNodeChecked != null && _isEventEnabled && child.Checked != false)
                                {
                                    Removed.Add(child);
                                }

                                treeNode.Parent.Children[i].Checked = false;
                            }
                        }
                        if (E_OnNodeChecked != null && _isEventEnabled)
                        {
                            Selected = treeNode.SelectedSiblings;
                        }
                        if (E_OnNodeChecked != null && _isEventEnabled)
                        {
                            E_OnNodeChecked(this, new TreeNodeCheckedEventArg(Selected, Added, Removed));
                        }
                    }
                }
                else
                {
                    BeforeClickedRow    = row_index;
                    BeforeClickedParent = treeNode.Parent;
                    if (treeNode.Checked == true)
                    {
                        Added.Add(treeNode);
                    }
                    else if (treeNode.Checked == false)
                    {
                        Removed.Add(treeNode);
                    }
                    if (E_OnNodeChecked != null && _isEventEnabled)
                    {
                        Selected = treeNode.SelectedSiblings;
                    }
                    if (E_OnNodeChecked != null && _isEventEnabled)
                    {
                        E_OnNodeChecked(this, new TreeNodeCheckedEventArg(Selected, Added, Removed));
                    }
                }
            }
            else     //부모노드일때
            {
                treeNode.CheckRecursive(treeNode.Checked, Added, Removed, Selected);
                if (E_OnNodeChecked != null && _isEventEnabled)
                {
                    E_OnNodeChecked(this, new TreeNodeCheckedEventArg(Selected, Added, Removed));
                }
            }
            treeNode.CheckSelf();
            //RunWhenEndNodeClicked(treeNode);
            //}
            //catch
            //{
            //    _isChecking = false;
            //    return;
            //}

            _isChecking = false;
        }
Beispiel #15
0
        void OnClick() //this function is called by Timer..
        {
            //VerifyAccess();



            object          sender = clickArg.Sender;
            RoutedEventArgs e      = clickArg.MouseBtnArgs;

            ContentPresenter p        = null;
            TreeViewItem     item     = null;
            RtwTreeNode      treeNode = null;

            FrameworkElement fe = e.OriginalSource as FrameworkElement;

            if (fe.TemplatedParent is ContentPresenter)
            {
                p = fe.TemplatedParent as ContentPresenter;
            }
            else if (fe.TemplatedParent is TreeViewItem)
            {
                item = fe.TemplatedParent as TreeViewItem;
            }
            else
            {
                return;
            }

            /*
             * if (e.OriginalSource is TextBlock)
             * {
             *  //p = (e.OriginalSource as TextBlock).TemplatedParent as ContentPresenter;
             *  p = (e.OriginalSource as TextBlock).TemplatedParent as ContentPresenter;
             *
             * }
             * else if (e.OriginalSource is Rectangle)
             * {
             *  if ((e.OriginalSource as Rectangle).TemplatedParent is ContentPresenter)
             *  {
             *      p = (e.OriginalSource as Rectangle).TemplatedParent as ContentPresenter;
             *  }
             *  else
             *  {
             *      item = (e.OriginalSource as Rectangle).TemplatedParent as TreeViewItem;
             *  }
             * }
             * else
             * {
             *  return;
             * }
             */


            //try
            {
                if (item != null)
                {
                    if (item.Items.Count > 0)
                    {
                        item.Tag = "Parent";
                    }
                    treeNode = item.Header as RtwTreeNode;
                }
                else
                {
                    treeNode = p.Content as RtwTreeNode;
                }



                if (treeNode.Enabled)
                {
                    if (clickArg.PressedButton == MouseButton.Left)
                    {
                        if (clickArg.Count == 2) //doubleclicked
                        {
                            if (treeNode.Children.Count > 0)
                            {
                                //(p.Parent as Grid).Children[0].Visibility = System.Windows.Visibility.Hidden;
                                RunWhenParentNodeClicked(treeNode, ActionOnParentNodeDoubleClicked);
                            }
                            else
                            {
                                RunWhenEndNodeClicked(treeNode, ActionOnEndNodeDoubleClicked);
                            }



                            if (E_OnNodeDoubleClicked != null && _isEventEnabled)
                            {
                                E_OnNodeDoubleClicked(this, new TreeNodeClickEventArg(treeNode.Path, treeNode.IndexPath, treeNode.Checked, treeNode, item, p));
                            }
                        }
                        else if (clickArg.Count == 1)
                        {
                            if (treeNode.Children.Count > 0)
                            {
                                //(p.Parent as Grid).Children[0].Visibility = System.Windows.Visibility.Hidden;
                                RunWhenParentNodeClicked(treeNode, ActionOnParentNodeClicked);
                            }
                            else
                            {
                                RunWhenEndNodeClicked(treeNode, ActionOnEndNodeClicked);
                            }

                            if (E_OnNodeClicked != null && _isEventEnabled)
                            {
                                E_OnNodeClicked(this, new TreeNodeClickEventArg(treeNode.Path, treeNode.IndexPath, treeNode.Checked, treeNode, item, p));
                            }
                        }
                        else
                        {
                        }
                    }
                    else if (clickArg.PressedButton == MouseButton.Right)
                    {
                        if (clickArg.Count == 1)
                        {
                            if (treeNode.Children.Count > 0)
                            {
                                //(p.Parent as Grid).Children[0].Visibility = System.Windows.Visibility.Hidden;
                                RunWhenParentNodeClicked(treeNode, ActionOnParentNodeDoubleClicked);
                            }
                            else
                            {
                                RunWhenEndNodeClicked(treeNode, ActionOnEndNodeDoubleClicked);
                            }

                            if (E_OnNodeRightClicked != null && _isEventEnabled)
                            {
                                E_OnNodeRightClicked(this, new TreeNodeClickEventArg(treeNode.Path, treeNode.IndexPath, treeNode.Checked, treeNode, item, p));
                            }
                        }
                        else
                        {
                        }
                    }
                }
            }
            //catch { }
        }
Beispiel #16
0
 protected virtual void RunWhenParentNodeClicked(RtwTreeNode parentNode)
 {
 }