Beispiel #1
0
        private void drawInstrument(string startCategoryName, string startCategoryParent, bool showAll)
        {
            instCategList = ((MainForm)((Sessions)this.parentForm).ParentForm).instrumentCategorylist;
            int numOfCategories                    = instCategList.Count;
            int counterOfPicturesInLine            = 0;
            int counterOfPictureLines              = 0;
            int numOfPictureInLine                 = ((MainForm)((Sessions)this.parentForm).ParentForm).mainFormDocument.numOfInstrumentsInLine;
            int upBorderHeight                     = 50;
            int heightOfPicture                    = 100;
            int widthOfPicture                     = 100;
            int sidesBorderWidth                   = 200;
            int verticalIntervalBetweenPictures    = 50;
            int HorizontalIntervalBetweenPictures  = 10;
            int heighOfCategoryAndSubCategoryLable = 50;

            Label topicLable = new Label();
            Font  myFont     = new System.Drawing.Font("Arial", 18, FontStyle.Bold);

            topicLable.Text      = "Instrument Manager";
            topicLable.ForeColor = Color.Blue;
            topicLable.Font      = myFont;
            topicLable.Location  = new Point(10 + sidesBorderWidth, 0);
            topicLable.Size      = new Size(1000, 50);
            this.Controls.Add(topicLable);
            int globalCategoryAnsSubCategoryLineCounter = 0;

            //treeView1.SelectedNode = null;
            bool startPointIsACategory;

            if (startCategoryParent == "Instrument")
            {
                startPointIsACategory = true;
            }
            else
            {
                startPointIsACategory = false;
            }

            for (int CategoryCount = 0; CategoryCount < instCategList.Count; CategoryCount++)
            {
                Category category = (Category)instCategList[CategoryCount];

                if (startPointIsACategory && !showAll)
                {
                    if (category.CategoryName != startCategoryName)
                    {
                        continue;
                    }
                }
                else                 //start point is a sub category
                {
                    if (category.CategoryName != startCategoryParent && !showAll)
                    {
                        continue;
                    }
                }
                Label categoryLable = new Label();
                categoryLable.Text     = "Category: " + category.CategoryName;
                categoryLable.Size     = new Size(5000, 50);
                categoryLable.Location = new Point(10 + sidesBorderWidth, upBorderHeight + counterOfPictureLines * heightOfPicture + counterOfPictureLines * verticalIntervalBetweenPictures + globalCategoryAnsSubCategoryLineCounter * heighOfCategoryAndSubCategoryLable);
                categoryLable.Font     = myFont;
                this.lableArrayList.Add(categoryLable);

                if (category.SubCategoryList.Count == 0)
                {
                    ArrayList imageList = (ArrayList)category.ImageList;
                    for (int imageCounter = 0; imageCounter < imageList.Count; imageCounter++)
                    {
                        myImage my_image = (myImage)imageList[imageCounter];
                        Bitmap  image    = new Bitmap(my_image.instrumentImage);
                        my_image.pictureBox.Image    = image;
                        my_image.categoryName        = category.CategoryName;
                        my_image.subCategoryName     = "";
                        my_image.pictureBox.Location = new Point(/*x*/ counterOfPicturesInLine * widthOfPicture + sidesBorderWidth + counterOfPicturesInLine * HorizontalIntervalBetweenPictures,
                                                                 /*y*/ upBorderHeight + counterOfPictureLines * heightOfPicture + counterOfPictureLines * verticalIntervalBetweenPictures + (globalCategoryAnsSubCategoryLineCounter + 1) * heighOfCategoryAndSubCategoryLable);
                        my_image.pictureBox.DoubleClick += new System.EventHandler(PictureBoxDoubleClick);
                        instrumentManagerToolTip.SetToolTip(my_image.pictureBox, my_image.instrumentInfo.Description);
                        this.pictureArrayList.Add(my_image.pictureBox);
                        Label instrumentName = new Label();
                        instrumentName.Text     = my_image.instrumentName;
                        instrumentName.Size     = new Size(70, 15);
                        instrumentName.Location = new Point(/*x*/ counterOfPicturesInLine * widthOfPicture + sidesBorderWidth + counterOfPicturesInLine * HorizontalIntervalBetweenPictures + 15,
                                                            /*y*/ 105 + upBorderHeight + counterOfPictureLines * heightOfPicture + counterOfPictureLines * verticalIntervalBetweenPictures + (globalCategoryAnsSubCategoryLineCounter + 1) * heighOfCategoryAndSubCategoryLable);
                        this.instrumentLableList.Add(instrumentName);

                        //this.Controls.Add(my_image.pictureBox);
                        if (counterOfPicturesInLine < numOfPictureInLine)
                        {
                            counterOfPicturesInLine++;
                        }
                        else
                        {
                            counterOfPicturesInLine = 0;
                            counterOfPictureLines++;
                        }
                    }
                    counterOfPictureLines++;
                    counterOfPicturesInLine = 0;
                    globalCategoryAnsSubCategoryLineCounter++;
                }
                else                 //has a sub catagory
                {
                    ArrayList subCategoryList = (ArrayList)category.SubCategoryList;

                    for (int subCategoryCounter = 0; subCategoryCounter < subCategoryList.Count; subCategoryCounter++)
                    {
                        SubCategory subCategory = (SubCategory)subCategoryList[subCategoryCounter];
                        if (!startPointIsACategory)
                        {
                            if (subCategory.SubCategoryName != startCategoryName && !showAll)
                            {
                                continue;
                            }
                        }
                        //categoryNode.Nodes.Add(subCategory.SubCategoryName);
                        Label subCategoryLable = new Label();
                        subCategoryLable.Text      = "Sub Category: " + subCategory.SubCategoryName;
                        subCategoryLable.Size      = new Size(5000, 50);
                        subCategoryLable.Location  = new Point(20 + sidesBorderWidth, upBorderHeight + counterOfPictureLines * heightOfPicture + counterOfPictureLines * verticalIntervalBetweenPictures + (globalCategoryAnsSubCategoryLineCounter + 1) * heighOfCategoryAndSubCategoryLable);
                        subCategoryLable.Font      = myFont;
                        subCategoryLable.ForeColor = Color.Gray;
                        this.lableArrayList.Add(subCategoryLable);
                        //this.Controls.Add(subCategoryLable);

                        ArrayList imageList = (ArrayList)subCategory.ImageList;
                        for (int imageCounter = 0; imageCounter < imageList.Count; imageCounter++)
                        {
                            myImage my_image = (myImage)imageList[imageCounter];
                            Bitmap  image    = new Bitmap(my_image.instrumentImage);
                            my_image.categoryName        = category.CategoryName;
                            my_image.subCategoryName     = subCategory.SubCategoryName;
                            my_image.pictureBox.Image    = image;
                            my_image.pictureBox.Location = new Point(/*x*/ counterOfPicturesInLine * widthOfPicture + sidesBorderWidth + counterOfPicturesInLine * HorizontalIntervalBetweenPictures,
                                                                     /*y*/ upBorderHeight + counterOfPictureLines * heightOfPicture + counterOfPictureLines * verticalIntervalBetweenPictures + (globalCategoryAnsSubCategoryLineCounter + 2) * heighOfCategoryAndSubCategoryLable);
                            my_image.pictureBox.DoubleClick += new System.EventHandler(PictureBoxDoubleClick);
                            instrumentManagerToolTip.SetToolTip(my_image.pictureBox, "s,dfhsdjfshjk");
                            this.pictureArrayList.Add(my_image.pictureBox);
                            Label instrumentName = new Label();
                            instrumentName.Text     = my_image.instrumentName;
                            instrumentName.Size     = new Size(70, 15);
                            instrumentName.Location = new Point(/*x*/ counterOfPicturesInLine * widthOfPicture + sidesBorderWidth + counterOfPicturesInLine * HorizontalIntervalBetweenPictures + 15,
                                                                /*y*/ 105 + upBorderHeight + counterOfPictureLines * heightOfPicture + counterOfPictureLines * verticalIntervalBetweenPictures + (globalCategoryAnsSubCategoryLineCounter + 2) * heighOfCategoryAndSubCategoryLable);
                            this.instrumentLableList.Add(instrumentName);

                            if (counterOfPicturesInLine < numOfPictureInLine)
                            {
                                counterOfPicturesInLine++;
                            }
                            else
                            {
                                counterOfPicturesInLine = 0;
                                counterOfPictureLines++;
                            }
                        }                        //for
                        counterOfPictureLines++;
                        globalCategoryAnsSubCategoryLineCounter++;
                        counterOfPicturesInLine = 0;
                    }            //for of sub catefories
                }                //has has sub category
                                 //counterOfPictureLines++;
                                 //counterOfPicturesInLine=0;
                                 //globalCategoryAnsSubCategoryLineCounter++;
            }
            counterOfPictureLines++;
            //	this.Show();
            for (int x = 0; x < this.pictureArrayList.Count; x++)
            {
                this.Controls.Add((PictureBox)this.pictureArrayList[x]);
            }
            for (int x = 0; x < this.lableArrayList.Count; x++)
            {
                this.Controls.Add((Label)this.lableArrayList[x]);
            }
            for (int x = 0; x < this.instrumentLableList.Count; x++)
            {
                this.Controls.Add((Label)this.instrumentLableList[x]);
            }
        }
Beispiel #2
0
        private void ClearAllListAndMemoryOfPictures()
        {
            //clear local list instCategList od class InstrumentManager
            for (int categoryCounter = 0; categoryCounter < instCategList.Count; categoryCounter++)
            {
                Category category = (Category)instCategList[categoryCounter];
                if (category.SubCategoryList.Count > 0)
                {
                    ArrayList subCategoryList = (ArrayList)category.SubCategoryList;
                    for (int subCategoryCounter = 0; subCategoryCounter < subCategoryList.Count; subCategoryCounter++)
                    {
                        SubCategory subCategory = (SubCategory)subCategoryList[subCategoryCounter];
                        ArrayList   imageList   = (ArrayList)subCategory.ImageList;
                        for (int imageCounter = 0; imageCounter < imageList.Count; imageCounter++)
                        {
                            myImage my_image = (myImage)imageList[imageCounter];
                            my_image.pictureBox.Image.Dispose();
                            my_image.instrumentImage.Dispose();

                            //comboBoxName.Items.Add(my_image.instrumentName);
                        }
                    }
                }
                else
                {
                    ArrayList imageList = (ArrayList)category.ImageList;
                    for (int imageCounter = 0; imageCounter < imageList.Count; imageCounter++)
                    {
                        myImage my_image = (myImage)imageList[imageCounter];
                        my_image.pictureBox.Image.Dispose();
                        my_image.instrumentImage.Dispose();

                        //comboBoxName.Items.Add(my_image.instrumentName);
                    }
                }
            }
            // clear list of MainForm instrumentCategorylist
            instCategList = ((MainForm)((Sessions)this.parentForm).ParentForm).instrumentCategorylist;
            for (int categoryCounter = 0; categoryCounter < instCategList.Count; categoryCounter++)
            {
                Category category = (Category)instCategList[categoryCounter];
                if (category.SubCategoryList.Count > 0)
                {
                    ArrayList subCategoryList = (ArrayList)category.SubCategoryList;
                    for (int subCategoryCounter = 0; subCategoryCounter < subCategoryList.Count; subCategoryCounter++)
                    {
                        SubCategory subCategory = (SubCategory)subCategoryList[subCategoryCounter];
                        ArrayList   imageList   = (ArrayList)subCategory.ImageList;
                        for (int imageCounter = 0; imageCounter < imageList.Count; imageCounter++)
                        {
                            myImage my_image = (myImage)imageList[imageCounter];
                            my_image.pictureBox.Image.Dispose();
                            my_image.instrumentImage.Dispose();
                        }
                    }
                }
                else
                {
                    ArrayList imageList = (ArrayList)category.ImageList;
                    for (int imageCounter = 0; imageCounter < imageList.Count; imageCounter++)
                    {
                        myImage my_image = (myImage)imageList[imageCounter];
                        my_image.pictureBox.Image.Dispose();
                        my_image.instrumentImage.Dispose();

                        //comboBoxName.Items.Add(my_image.instrumentName);
                    }
                }
            }

            this.instCategList.Clear();
            //clear pictureArrayList
            for (int x = 0; x < this.pictureArrayList.Count; x++)
            {
                PictureBox ff = (PictureBox)this.pictureArrayList[x];
                ff.Dispose();
                this.Controls.Remove((PictureBox)this.pictureArrayList[x]);
            }
            this.pictureArrayList.Clear();

            for (int x = 0; x < this.lableArrayList.Count; x++)
            {
                this.Controls.Remove((Label)this.lableArrayList[x]);
            }
            this.lableArrayList.Clear();

            for (int x = 0; x < this.instrumentLableList.Count; x++)
            {
                this.Controls.Remove((Label)this.instrumentLableList[x]);
            }
            this.instrumentLableList.Clear();

            ((MainForm)((Sessions)this.parentForm).ParentForm).instrumentCategorylist.Clear();
            this.instrumentManagerToolTip.RemoveAll();
            treeView1.Nodes.Clear();
        }
Beispiel #3
0
        //  ListView instrumentListView;

        private void Legend_Load(object sender, EventArgs e)
        {
            // instrumentListView = new ListView();
            //instrumentListView.
            instrumentListView.LargeImageList           = new ImageList();
            instrumentListView.LargeImageList.ImageSize = new Size(32, 32);
            instrumentListView.SmallImageList           = new ImageList();
            instrumentListView.SmallImageList.ImageSize = new Size(16, 16);

            instrumentListView.View = View.List;

            instrumentListView.Columns.Add("Name", 120, HorizontalAlignment.Left);
            instrumentListView.Columns.Add("Category", 120, HorizontalAlignment.Left);
            instrumentListView.Columns.Add("Sub-category", 120, HorizontalAlignment.Left);
            instrumentListView.Columns.Add("Description", 120, HorizontalAlignment.Right);

            ArrayList instCategList;

            instCategList = ((MainForm)(this.parentForm)).instrumentCategorylist;
            int numOfCategories   = instCategList.Count;
            int imageIndexCounter = 0;

            for (int CategoryCount = 0; CategoryCount < instCategList.Count; CategoryCount++)
            {
                Category category = (Category)instCategList[CategoryCount];

                if (category.SubCategoryList.Count == 0)
                {
                    ArrayList imageList = (ArrayList)category.ImageList;
                    for (int imageCounter = 0; imageCounter < imageList.Count; imageCounter++)
                    {
                        myImage my_image = (myImage)imageList[imageCounter];
                        Bitmap  image    = new Bitmap(my_image.instrumentImage, new Size(32, 32));
                        instrumentListView.LargeImageList.Images.Add(image);
                        ListViewItem instrumentListItem = instrumentListView.Items.Add(my_image.instrumentName, imageIndexCounter);
                        image = new Bitmap(my_image.instrumentImage, new Size(16, 16));
                        instrumentListView.SmallImageList.Images.Add(image);

                        instrumentListItem.SubItems.Add(my_image.instrumentInfo.Category);
                        instrumentListItem.SubItems.Add(my_image.instrumentInfo.SubCategory);
                        instrumentListItem.SubItems.Add(((MainForm)(this.parentForm)).getInstrumentInfo(my_image.instrumentInfo.Category, "", my_image.instrumentInfo.Name)); //my_image.instrumentInfo.SubCategory);
                        imageIndexCounter++;
                    }
                }
                else //has a sub catagory
                {
                    ArrayList subCategoryList = (ArrayList)category.SubCategoryList;

                    for (int subCategoryCounter = 0; subCategoryCounter < subCategoryList.Count; subCategoryCounter++)
                    {
                        SubCategory subCategory = (SubCategory)subCategoryList[subCategoryCounter];

                        ArrayList imageList = (ArrayList)subCategory.ImageList;
                        for (int imageCounter = 0; imageCounter < imageList.Count; imageCounter++)
                        {
                            myImage my_image = (myImage)imageList[imageCounter];
                            Bitmap  image    = new Bitmap(my_image.instrumentImage, new Size(32, 32));
                            instrumentListView.LargeImageList.Images.Add(my_image.instrumentImage);
                            image = new Bitmap(my_image.instrumentImage, new Size(16, 16));
                            instrumentListView.SmallImageList.Images.Add(image);

                            ListViewItem instrumentListItem = instrumentListView.Items.Add(my_image.instrumentName, imageIndexCounter);
                            instrumentListItem.SubItems.Add(my_image.instrumentInfo.Category);
                            instrumentListItem.SubItems.Add(my_image.instrumentInfo.SubCategory);
                            instrumentListItem.SubItems.Add(my_image.instrumentInfo.Description);
                            imageIndexCounter++;


//
                        } //for
                    }     //for of sub catefories
                }         //has has sub category
            }
            //counterOfPictureLines++;
        }