Example #1
0
        public static SquareList createSquareList(SquareList simpleList)
        {
            SquareList newList = new SquareList();
            for (int i = simpleList.Count() - 1; i >= 0; i--)
            {
                Square cat = simpleList.Get(i);

                Square square = new Square(SurfaceWindow1.treeArea * cat.Ratio, cat.Name);
                square.setBackGround(cat.BackGroundColor);
                if (cat.TextColor == null)
                    square.setTextColor(Colors.Black);
                else
                    square.setTextColor(cat.TextColor);
                square.Ratio = cat.Ratio;
                if (cat.SubFile != null && !cat.SubFile.Equals(""))
                {
                    square.SubFile = cat.SubFile;
                }
                if (cat.Explanation != null && !cat.Explanation.Equals(""))
                {
                    square.Explanation = cat.Explanation;
                }

                if (cat.VideoString != null && !cat.VideoString.Equals(""))
                {
                    square.VideoString = cat.VideoString;
                }
                if(cat.ImageString !=null && !cat.ImageString.Equals("")){
                    square.ImageString = cat.ImageString;
                }
                newList.Add(square);
            }
            return newList;
        }
Example #2
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;
            }
        }
Example #3
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;
        }
Example #4
0
        /// <summary>
        /// Only to be used in the public addchild
        /// this is to ensure the breadcrumbs and parentlist is presevered
        /// </summary>
        /// <param name="children">list used to fill the menu</param>
        private TreeMenu(SquareList children)
            : base(children)
        {
            breadCrumbs = new List<SurfaceButton>();
            InHistory = false;
            Initialize();

            FillDrawing();
        }
Example #5
0
        /// <summary>
        /// used in the cloning process
        /// </summary>
        /// <param name="children">children that are to be cloned</param>
        /// <param name="oldCrumbs">crumbs in the other treemenu</param>
        /// <param name="ParentList">the list of menus that this new menu will be added to</param>
        private TreeMenu(SquareList children, List<SurfaceButton> oldCrumbs, List<Menu.Menu> ParentList)
            : base(children)
        {
            breadCrumbs = new List<SurfaceButton>();
            this.children = SquareList.createSquareList(children);

            Initialize();
            this.ParentList = ParentList;
            InHistory = true;
            foreach (SurfaceButton oldc in oldCrumbs)
            {
                SurfaceButton crumb = new SurfaceButton();
                crumb.Height = 0.15 * height;
                crumb.Background = oldc.Background;

                TextBlock block = new TextBlock();
                block.Text = ((TextBlock)oldc.Content).Text;
                block.FontSize = 13;

                crumb.Content = block;
                crumb.Foreground = oldc.Foreground;
                crumb.PreviewTouchUp += new EventHandler<TouchEventArgs>(RetraceToBreadCrumb);
                breadCrumbs.Add(crumb);
                canvas.Children.Add(crumb);
            }
            CreateExit();
            SizeCrumbs();
            myTimer.Tick += new EventHandler(myTimer_Tick);
            interactive = true;
            FillDrawing();
        }
Example #6
0
        /// <summary>
        /// Creates new treeMenu
        /// </summary>
        /// <param name="children">list used to populate the menu</param>
        /// <param name="creator">the square that is linked with the button that created the treemenu</param>
        /// <param name="ParentList">the list of menus this treemenu will be placed in</param>
        public TreeMenu(SquareList children, Square creator, List<Menu.Menu> ParentList)
            : base(children)
        {
            breadCrumbs = new List<SurfaceButton>();
            this.height = SurfaceWindow1.treeHeight;
            Initialize();
            InHistory = true;
            this.ParentList = ParentList;

            CreateExit();
            CreateCrumb(creator);
            SizeCrumbs();
            myTimer.Tick += new EventHandler(myTimer_Tick);
            interactive = true;
            FillDrawing();
        }
Example #7
0
 public SquareList sublist(int start, int count)
 {
     SquareList sublist = new SquareList();
     for (int i = 0; i < count && i + start < list.Count(); i++)
     {
         sublist.Add(list[start + i]);
     }
     return sublist;
 }
Example #8
0
 public StartMenu(SquareList list)
     : base(list)
 {
     children = list;
     baseAngle = 2 * Math.PI / (list.Count()-1) ;
 }
        /// <summary>
        /// Event Handler finds and executes the correct response to menu Surfacebutton that 
        /// raised an event
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        public void TouchUpMenu(object sender, TouchEventArgs e)
        {
            if (sender is SurfaceButton && e.TouchDevice.GetIsFingerRecognized())
            {
                SurfaceButton button = (SurfaceButton)sender;
                Menu.Menu menu = FindTheMenu(button);

                if (menu == null)
                {
                    return;
                }
                Log.Interaction(this, e.TouchDevice, menu.Get((SurfaceButton)sender), menu);
                menu.interactive = true;
                string file = menu.FileToOpen(button);
                if (menu is TreeMenu)
                {
                    TreeMenu map = (TreeMenu)menu;
                    if (file != null && !file.Equals(""))
                    {
                        TreeMenu childAdded = map.addChild(Catagory.ReadFile( file), map.Get(button));
                        childAdded.AddUpListenerToButtons(TouchUpMenu);
                    }
                    else
                    {
                        if (map.HasExplanation(button))
                        {
                            /*
                             * Creates a new TreeMenu from the information stored in the Square
                             * selected
                             */
                            SquareList list = new SquareList();
                            Square sqr = new Square(1, map.Get(button).Explanation);
                            if (map.Get(button).VideoString != null)
                            {
                                sqr.VideoString = map.Get(button).VideoString;
                            }
                            if (map.Get(button).ImageString != null)
                            {
                                sqr.ImageString = map.Get(button).ImageString;
                            }

                            sqr.setBackGround(map.Get(button).BackGroundColor);
                            sqr.setTextColor((map.Get(button).TextColor));
                            sqr.singleImage = map.Get(button).singleImage;
                            sqr.Slides = map.Get(button).Slides;
                            sqr.Ratio = 1;
                            list.Add(sqr);
                            map.addChild(list, map.Get(button));
                        }

                    }
                    map.ReDraw();
                }
                else//non tree menu
                {
                    if (((IndividualMenu)menu).IsAnimating())
                    {
                        ((IndividualMenu)menu).StopAnimation();
                    }
                    else
                    {
                        if (MenuList.Count < MaxMenus)
                        {
                            TouchDevice c = (TouchDevice)e.TouchDevice;
                            PlaceTreeMap(menu.FileToOpen(button), menu.Get(button), c.GetOrientation(this), c.GetPosition(this));

                        }
                    }
                }
            }
        }
Example #10
0
        /// <summary>
        /// creates a SqruarList based on simpleList
        /// </summary>
        /// <param name="simpleList">list of catagories typically popullated by a xml reader</param>
        /// <returns></returns>
        public static SquareList createSquareList(List<Catagory> simpleList)
        {
            SquareList newList=new SquareList();
            for(int i=simpleList.Count()-1;i>=0;i--)
            {
                Catagory cat = simpleList[i];
                 Square square = new Square(SurfaceWindow1.treeArea * cat.Ratio, cat.Title);

                // stated in the xsd that all catagories must have at least name ratio and backGroundColor
                square.setBackGround(cat.BackGroundColor);
                square.Ratio = cat.Ratio;

                //set file to open if this square is followed
                if (cat.SubCatagoryFile!=null && !cat.SubCatagoryFile.Equals(""))
                {
                    square.SubFile = @"Resources/Information/" + cat.SubCatagoryFile;
                }

                //provide text explanation if no file is provided to follow
                if (cat.Explanation != null && !cat.Explanation.Equals(""))
                {
                    square.Explanation = cat.Explanation;
                }

                //if the text color is not set
                //set the text color to the inverse of the background color
                //so the text is at least visible
                if (cat.TextColor==null || cat.TextColor.A == 0)
                {
                    Color textColor = new Color();
                    textColor.ScA = 1;
                    textColor.ScR = 1 - cat.BackGroundColor.ScR;
                    textColor.ScG = 1 - cat.BackGroundColor.ScG;
                    textColor.ScB = 1 - cat.BackGroundColor.ScB;
                    square.setTextColor(textColor);
                }
                else
                {
                    square.setTextColor(cat.TextColor);
                }

                //Images for explanation
                if (cat.Image!=null && !cat.Image.Equals(""))
                {
                    square.ImageString = @"Resources/Images/" + cat.Image;
                }
                if (cat.Slides != null && cat.Slides.Count>0)
                {
                    square.Slides = cat.Slides;
                }
                if (cat.ImageSetup != null)
                {
                    square.singleImage = cat.ImageSetup;
                    square.singleImage.Path = @"Resources/Images/" + square.singleImage.Path;
                }
                //video for explanation
                if (cat.Video!=null && !cat.Video.Equals(""))
                {
                    square.VideoString = @"Resources/Videos/" + cat.Video;
                }
                //background image to use instead of backgroundcolor
                if (cat.BackGroundImage!=null && !cat.BackGroundImage.Equals(""))
                {
                    square.setBackGround(cat.BackGroundImage);
                }
                newList.Add(square);
            }

            return newList;
        }