private void PictureBoxDoubleClick(object sender, System.EventArgs e) { myPictureBox pictureBox = (myPictureBox)sender; // MessageBox.Show("dd" + ((myImage)pictureBox.my_image).instrumentName); //Sessions session = (Sessions)this.parentForm; activeInstrument = ((myImage)pictureBox.my_image); DialogResult = DialogResult.OK; this.Close(); }
private void comboBoxCategory_SelectedIndexChanged(object sender, System.EventArgs e) { ArrayList instCategList = ((InstrumentManager)this.parentForm).instCategList; string currentCategory = this.comboBoxCategory.Text; comboBoxSubCategory.Items.Clear(); this.comboBoxSubCategory.Text = ""; comboBoxSubCategory.BeginUpdate(); comboBoxName.Items.Clear(); for (int categoryCounter = 0; categoryCounter < instCategList.Count; categoryCounter++) { Category category = (Category)instCategList[categoryCounter]; if (category.SubCategoryList.Count > 0 && currentCategory == category.CategoryName) { ArrayList subCategoryList = (ArrayList)category.SubCategoryList; for (int subCategoryCounter = 0; subCategoryCounter < subCategoryList.Count; subCategoryCounter++) { SubCategory subCategory = (SubCategory)subCategoryList[subCategoryCounter]; comboBoxSubCategory.Items.Add("" + subCategory.SubCategoryName); ArrayList imageList = (ArrayList)subCategory.ImageList; for (int imageCounter = 0; imageCounter < imageList.Count; imageCounter++) { myImage my_image = (myImage)imageList[imageCounter]; comboBoxName.Items.Add(my_image.instrumentName); } } } else if (currentCategory == category.CategoryName) { ArrayList imageList = (ArrayList)category.ImageList; for (int imageCounter = 0; imageCounter < imageList.Count; imageCounter++) { myImage my_image = (myImage)imageList[imageCounter]; comboBoxName.Items.Add(my_image.instrumentName); } } } comboBoxSubCategory.EndUpdate(); }
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(); }
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 = ((MainForm)((Sessions)this.parentForm).ParentForm).mainFormDocument.upBorderHeight; //50; int heightOfPicture = ((MainForm)((Sessions)this.parentForm).ParentForm).mainFormDocument.HeightOfInstrumentPicture; // 66;//ss int widthOfPicture = ((MainForm)((Sessions)this.parentForm).ParentForm).mainFormDocument.WidthOfInstrumentPicture; int sidesBorderWidth = ((MainForm)((Sessions)this.parentForm).ParentForm).mainFormDocument.sidesBorderWidth; // 200; int verticalIntervalBetweenPictures = ((MainForm)((Sessions)this.parentForm).ParentForm).mainFormDocument.verticalIntervalBetweenPictures; // 50; int HorizontalIntervalBetweenPictures = ((MainForm)((Sessions)this.parentForm).ParentForm).mainFormDocument.HorizontalIntervalBetweenPictures; // 10; int heighOfCategoryAndSubCategoryLable = ((MainForm)((Sessions)this.parentForm).ParentForm).mainFormDocument.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, heighOfCategoryAndSubCategoryLable /*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, heighOfCategoryAndSubCategoryLable /*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]; if (my_image.instrumentImage == null) { Bitmap image = new Bitmap(my_image.instrumentImage); my_image.pictureBox.Image = image; } else { my_image.pictureBox.Image = my_image.instrumentImage; } 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.BackColor = Color.Red; instrumentName.TextAlign = ContentAlignment.MiddleCenter; instrumentName.Text = my_image.instrumentName; // רגיל instrumentName.Size = new Size(/*100,70*/ widthOfPicture, verticalIntervalBetweenPictures /*15*/); instrumentName.Location = new Point(/*x*/ counterOfPicturesInLine * widthOfPicture + sidesBorderWidth + counterOfPicturesInLine * HorizontalIntervalBetweenPictures, upBorderHeight + (counterOfPictureLines + 1) * heightOfPicture + counterOfPictureLines * verticalIntervalBetweenPictures + (globalCategoryAnsSubCategoryLineCounter + 1) * heighOfCategoryAndSubCategoryLable); ///*y*//*105*/upBorderHeight+(counterOfPictureLines+1)*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, heighOfCategoryAndSubCategoryLable /*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); if (my_image.instrumentImage == null) { Bitmap image = new Bitmap(my_image.instrumentImage); my_image.pictureBox.Image = image; } else { my_image.pictureBox.Image = my_image.instrumentImage; } my_image.categoryName = category.CategoryName; my_image.subCategoryName = subCategory.SubCategoryName; 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.BackColor = Color.Salmon; instrumentName.TextAlign = ContentAlignment.MiddleCenter; instrumentName.Text = my_image.instrumentName; instrumentName.Size = new Size(/*100,70*/ widthOfPicture, verticalIntervalBetweenPictures /*15*/); instrumentName.Location = new Point(/*x*/ counterOfPicturesInLine * widthOfPicture + sidesBorderWidth + counterOfPicturesInLine * HorizontalIntervalBetweenPictures, upBorderHeight + (counterOfPictureLines + 1) * heightOfPicture + counterOfPictureLines * verticalIntervalBetweenPictures + (globalCategoryAnsSubCategoryLineCounter + 2) * heighOfCategoryAndSubCategoryLable); ////*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 globalCategoryAnsSubCategoryLineCounter++; } //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]); } }
// 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++; }