Beispiel #1
0
 /// <summary>
 /// adds children to newly created clones
 /// </summary>
 /// <param name="menu">menu that has children to be coppied from</param>
 private void addChildOf(TreeMenu menu)
 {
     if (menu.child == null)
     {
         return;
     }
     child = new TreeMenu(SquareList.createSquareList(menu.child.children));
     child.addChildOf(menu.child);
 }
Beispiel #2
0
        /// <summary>
        /// removes subtrees after the keeping children has passed
        /// </summary>
        /// <param name="keeping">number of children to keep</param>
        /// <param name="parentCanvas">canvas to remove from</param>
        private void KeepChildren(int keeping, Canvas parentCanvas)
        {
            if (keeping > 0)
            {
                child.KeepChildren(keeping - 1, this.canvas);
                if (keeping == 1)
                {
                    child = null;
                }

                return;
            }
            else
            {
                if (child != null)
                {
                    child.KeepChildren(-1, this.canvas);
                    child = null;
                }
                parentCanvas.Children.Remove(this.canvas);

                return;
            }
        }
Beispiel #3
0
        /// <summary>
        /// Only to be used in the public addchild
        /// this is to ensure the breadcrumbs and parentlist is presevered
        /// </summary>
        /// <param name="grandChildren"></param>
        /// <returns></returns>
        private TreeMenu addChild(SquareList grandChildren)
        {
            if (child == null)
            {
                child = new TreeMenu(grandChildren);
                canvas.Children.Add(child.DrawMenu());

                return child;
            }
            else
            {
                TreeMenu gchild = child.addChild(grandChildren);
                return gchild;
            }
        }
Beispiel #4
0
 public void Delete()
 {
     if (!InHistory)
     {/*Deleting already deleted block*/
         foreach (Square block in children)
         {
             block.Delete();
         }
         breadCrumbs.Clear();
         breadCrumbs = null;
         if (child != null)
         {
             child.Delete();
         }
         child = null;
         canvas = null;
         myTimer.Stop();
         myTimer = null;
         return;
     }
     InHistory = false;
 }
Beispiel #5
0
        /// <summary>
        /// create a new tree menu based on 
        /// this treeMenu
        /// </summary>
        /// <returns></returns>
        public TreeMenu Clone()
        {
            TreeMenu newmenu = new TreeMenu(children, breadCrumbs, ParentList);
            newmenu.addChildOf(this);

            return newmenu;
        }
Beispiel #6
0
        /// <summary>
        /// Adds a child to the menu if the menu has a child a
        /// recursively trys to add the child until a leaf menu is found
        /// </summary>
        /// <param name="grandChildren">list used to populate the menu</param>
        /// <param name="creator">square that wants to create a treemenu</param>
        /// <returns></returns>
        public TreeMenu addChild(SquareList grandChildren, Square creator)
        {
            CreateCrumb(creator);
            TreeMenu NewChild;
            if (child == null)
            {
                child = NewChild = new TreeMenu(grandChildren);
                canvas.Children.Add(child.DrawMenu());
                child.ReDraw(width, height);
            }
            else
            {

                NewChild = child.addChild(grandChildren);
                NewChild.ReDraw(width, height);
            }
            NotifyChange("Source");
            NotifyChange("Name");
            return NewChild;
        }
        /// <summary>
        /// Creates a treeMap and places it in a scatterview item in the scatterview scatter
        /// the treemap will be facing the user
        /// </summary>
        /// <param name="fileName">the path to follow to the xml document to read</param>
        /// <param name="caller">the square linked with the button that made the event</param>
        /// <param name="angle">angle of the finger that raised the event</param>
        /// <param name="parent">the location of the button that raised the event</param>
        public void PlaceTreeMap(String fileName, Square caller, double angle, Point parent)
        {
            TreeMenu map = new TreeMenu(Catagory.ReadFile( fileName), caller, MenuList);

            map.AddUpListenerToButtons(TouchUpMenu);

            ScatterViewItem item = new ScatterViewItem();
            item.Center = findPosition(parent, angle);
            item.Orientation = angle + 90;
            item.MinHeight = MinHeightItem;
            item.MinWidth = MinWidthItem;
            item.MaxHeight = MaxHeightItem;
            item.MaxWidth = MaxWidthItem;
            item.ContainerManipulationDelta += new ContainerManipulationDeltaEventHandler(OnManipulation);
            item.ContainerManipulationCompleted += new ContainerManipulationCompletedEventHandler(AfterManipulationCompleted);
            item.Width = treeWidth;
            item.Height = treeHeight;
            item.Content = map.DrawMenu();
            item.ClipToBounds = false;
            scatter.Items.Add(item);
            MenuList.Add(map);

            ((IndividualMenu)FindTheMenu(caller.Button)).AddToHistory(map);
        }