Esempio n. 1
0
 public static void addHistoryObject(Object obj, EventArgs e)
 {
     HistoryObject historyObject = new HistoryObject();
      historyObject.obj = obj;
      historyObject.e = e;
      historyObjectList.Add(historyObject);
 }
Esempio n. 2
0
        private void fillInGeneralCategoryNavigationPanel()
        {
            List<GeneralCategory> genCatList = categoryDAO.getGeneralCategory();
            List<Category> catList = categoryDAO.getAllCategories();

            genCategorySwitch = new bool[genCatList.Count];

            int counter = 0;
            //two loops. One to fill in the general categories data and the second one, nested, to fill in the simple categories data
            foreach (GeneralCategory genCat in genCatList)
            {
                //counter++;
                LinkLabel tempCurrentLinkLabel = new LinkLabel();
                tempCurrentLinkLabel.Text = genCat.name;
                tempCurrentLinkLabel.AutoSize = false;
                tempCurrentLinkLabel.Width = 250;
                tempCurrentLinkLabel.Font = new System.Drawing.Font("Microsoft Sans Serif", 7F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(161)));
                tempCurrentLinkLabel.Size = new Size(300, 0);
                tempCurrentLinkLabel.AutoSize = true;
                tempCurrentLinkLabel.Name = "GenCatLinkLabel-" + counter + "-" + genCat.id;
                tempCurrentLinkLabel.LinkColor = System.Drawing.Color.Black;
                tempCurrentLinkLabel.Margin = new System.Windows.Forms.Padding(16, 3, 3, 3);
                //fix the bottom margin only at the last general category linklabel
                if (counter == genCatList.Count() - 1) tempCurrentLinkLabel.Margin = new System.Windows.Forms.Padding(16, 3, 3, 23);

                /*the initial page has to be added to the history objects' list, however it is not produced by a click event,that's the use of the counter. So we add it "manually"*/
                if (counter == 0)
                {
                    //sets the color of the first general category linklabel to scrollbar
                    previousLink = tempCurrentLinkLabel;
                    tempCurrentLinkLabel.BackColor = System.Drawing.SystemColors.ScrollBar;
                    var historyObject = new HistoryObject();
                    historyObject.obj = tempCurrentLinkLabel;
                    historyObject.e = new LinkLabelLinkClickedEventArgs(null,MouseButtons.Left);
                    Globals.historyObjectList.Add(historyObject);
                }
                counter++;

                flowNavigationPanel.Controls.Add(tempCurrentLinkLabel);
                //subscribe a handler to the event LinkClicked
                tempCurrentLinkLabel.LinkClicked += new System.Windows.Forms.LinkLabelLinkClickedEventHandler(this.linkLabel_LinkClicked);

                /*********end of single item general category input**********/

                /*we iterate ALL the categories array each time, to be sure that everything will run smoothly, that's why we use a for loop and not a while loop with a break statement*/
                for (int i = 0; i < catList.Count(); i++)
                {   //if the gen category id of the simple category is the same with the current general category
                    if (Int32.Parse(tempCurrentLinkLabel.Name.Split('-').Last()) == catList[i].generalCategory)
                    {
                        innerLinkLabel.Add(new LinkLabel());
                        LinkLabel currentItem = innerLinkLabel.Last();
                        //LinkLabel currentItem = new LinkLabel();
                        currentItem.Text = catList[i].name;
                        currentItem.AutoSize = false;
                        currentItem.Width = 250;
                        currentItem.Font = new System.Drawing.Font("Microsoft Sans Serif", 7F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(161)));
                        currentItem.Size = new Size(300, 0);
                        currentItem.AutoSize = true;
                        currentItem.Padding = new System.Windows.Forms.Padding(25, 0, 0, 0);
                        currentItem.Name = "innerLinkLabel-" + catList[i].generalCategory + "-" + catList[i].id;
                        currentItem.LinkColor = System.Drawing.Color.Black;
                        currentItem.Hide();
                        flowNavigationPanel.Controls.Add(currentItem);

                        /*the first parameter, child, has to be already a child of the flowNavigationPanel, before resetting its index*/
                        //int positionOfCorrespondingGeneralCategory = flowNavigationPanel.Controls.IndexOf((LinkLabel)sender);//gets the position of the genCategory linklabel that was clicked
                        //flowNavigationPanel.Controls.SetChildIndex(currentItem, positionOfCorrespondingGeneralCategory + 1 + j);
                        //j++;

                        //subscribe a handler to the event LinkClicked
                        currentItem.LinkClicked += new System.Windows.Forms.LinkLabelLinkClickedEventHandler(this.innerLinkLabel_LinkClicked);
                    }
                }

            }
        }