private void points_view_FormClosing(object sender, FormClosingEventArgs e) { if (Form1.Image_ID > -1) { Form1 f_main = Application.OpenForms["Form1"] as Form1; f_main.GCP_draw(Form1.gcp_collected[Form1.Image_ID]); f_main.GCP_draw(Form1.gcp_collected[Form1.Image_ID]); } if (formgcp.Form_active == true) { formgcp f_gcp = Application.OpenForms["formgcp"] as formgcp; f_gcp.dzy_main(); } if (GeoTransform.form_active == true) { GeoTransform geo = Application.OpenForms["GeoTransform"] as GeoTransform; geo.image_dzyn(); } }
/// <summary> /// this method is for opening or changing the image. /// </summary> /// <param name="href_open">image filename</param> /// <param name="empty">true=no image / false=have image</param> /// <param name="new_img">true= new image / false= change image</param> public void open_Image(string href_open, bool empty, bool new_img) { try { OpenFileDialog opendio = new OpenFileDialog(); opendio.FileName = href_open; href_open = opendio.SafeFileName; Form1 form = Application.OpenForms["Form1"] as Form1; int bit = 0, channels = 0; string format = null; if (empty != true) { imginfo(opendio.FileName, out bit, out channels, out format); } form.ımageBox1.Image = null; form.ımageBox2.Image = null; Bitmap mini_bmp = null; if (new_img == true) { Form1.Image_ID = form.treeView1.Nodes[Form1.Project_ID].Nodes.Count; Array.Resize <int>(ref Form1.main_width, Form1.main_width.Length + 1); Array.Resize <int>(ref Form1.main_height, Form1.main_height.Length + 1); Form1.gcp_count = 0; Form1.icp_count = 0; } if (empty == true) { if (new_img == true) { Form1.main_width[Form1.Image_ID] = Empty_image.emp_Width; Form1.main_height[Form1.Image_ID] = Empty_image.emp_Height; } Image <Rgb, byte> main_Image = main_Image = new Image <Rgb, byte>(Form1.main_width[Form1.Image_ID], Form1.main_height[Form1.Image_ID], new Rgb(Empty_image.empty_page_clr)); form.ımageBox1.Image = main_Image; Form1.Main_Bants = main_Image.Split(); mini_bmp = new Bitmap(main_Image.Bitmap); opendio.FileName = "empty"; } else { if (bit == 16) { if (channels >= 3) { Image <Gray, ushort>[] bit_bants_16 = bantsimg_16(opendio.FileName); Form1.Main_Bants = new Image <Gray, Byte> [channels]; int i; for (i = 0; i < channels; i++) { Form1.Main_Bants[i] = bit_bants_16[i].Convert <Gray, byte>(); } Image <Gray, byte>[] rgb = { Form1.Main_Bants[0], Form1.Main_Bants[1], Form1.Main_Bants[2] }; Image <Rgb, byte> main_Image = new Image <Rgb, byte>(rgb); form.ımageBox1.Image = main_Image; mini_bmp = new Bitmap(main_Image.Bitmap); } if (channels < 3) { Image <Gray, ushort>[] bit_bants_16 = bantsimg_16(opendio.FileName); Form1.Main_Bants = new Image <Gray, Byte> [channels]; int i; for (i = 0; i < channels; i++) { Form1.Main_Bants[i] = bit_bants_16[i].Convert <Gray, byte>(); } form.ımageBox1.Image = Form1.Main_Bants[0]; mini_bmp = new Bitmap(Form1.Main_Bants[0].Bitmap); } } if (bit == 8) { if (channels >= 3) { Form1.Main_Bants = bantsimg_8(opendio.FileName); Image <Gray, byte>[] rgb = { Form1.Main_Bants[0], Form1.Main_Bants[1], Form1.Main_Bants[2] }; Image <Rgb, byte> main_Image = new Image <Rgb, byte>(rgb); form.ımageBox1.Image = main_Image; mini_bmp = new Bitmap(main_Image.Bitmap); } if (channels < 3) { Form1.Main_Bants = bantsimg_8(opendio.FileName); form.ımageBox1.Image = Form1.Main_Bants[0]; mini_bmp = new Bitmap(Form1.Main_Bants[0].Bitmap); } } } if (new_img == true) { Form1.bants_img_count.Add(channels); treenodes_add_img(href_open, channels, true); form.treeView1.SelectedNode = form.treeView1.Nodes[Form1.Project_ID].Nodes[Form1.Image_ID]; Form1.Imagelist.Add(opendio.FileName); } Form1.main_width[Form1.Image_ID] = Form1.Main_Bants[0].Width; Form1.main_height[Form1.Image_ID] = Form1.Main_Bants[0].Height; form.decrease(mini_bmp); Form1.zoom = 1; Form1.cnt_zoom = 0; form.follow_window(); form.ımageBox1.HorizontalScrollBar.Value = 0; form.ımageBox1.VerticalScrollBar.Value = 0; form.zoom_in(new Point(0, 0)); form.zoom_out(new Point(0, 0)); form.radioButton1.Checked = true; Form1.Save_Control = 1; Button_control(); if (formgcp.Form_active == true) { formgcp ff = Application.OpenForms["formgcp"] as formgcp; ff.dzy_main(); } } catch (Exception mistake) { MessageBox.Show(mistake.Message.ToString()); } }