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;
        }
        /// <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 #3
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 #4
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;
        }