private void btnOpenTestImage_Click(object sender, EventArgs e) { MyOpenFileDialogControl dlgLoad = new MyOpenFileDialogControl(); dlgLoad.FileDlgInitialDirectory = "./"; dlgLoad.FileDlgCaption = "Select file to add to test set..."; dlgLoad.FileDlgFilter = "Image Files (*.png,*.jpg,*.bmp,*.ppm)|*.png;*.jpg;*.bmp;*.ppm"; DialogResult r = dlgLoad.ShowDialog(); if (r == DialogResult.OK) { testImageFilename = dlgLoad.FileDlgFileName; //SourceItem item = new SourceItem(controlex.Filename, 0); //ListViewItem newItem = lstInputs.Items.Add(new ListViewItem(item.GetStringValues())); //sourceItems.Add(newItem.GetHashCode(), item); } currentSource = new SourceItem(testImageFilename, cmbSampleType.SelectedIndex); redrawPipeline(); calculateFitness(); }
private void MySaveDialogControl_Load(object sender, EventArgs e) { if (!DesignMode) { FileInfo fi = new FileInfo(_imageFile); _lblOriginalFileLen.Text = string.Format("Original File Size: {0} bytes", fi.Length); } _horizontal.Minimum = _pbChanged.MinimumSize.Width; _horizontal.Maximum = _pbChanged.MaximumSize.Width / 2; _vertical.Minimum = _pbChanged.MinimumSize.Height; _vertical.Maximum = _pbChanged.MaximumSize.Height / 2; _horizontal.Value = _pbChanged.MaximumSize.Width / 2; _vertical.Value = _pbChanged.MaximumSize.Height / 2; _groupBox2.Text = System.IO.Path.GetFileName(_imageFile); _groupBox1.Text = "New Image"; _rotateflip.DataSource = Enum.GetNames(typeof(RotateFlipType)); _rotateFlipOriginal.DataSource = Enum.GetNames(typeof(RotateFlipType)); _cbxOriginalMode.DataSource = Enum.GetNames(typeof(System.Windows.Forms.PictureBoxSizeMode)); _cbxNewViewMode.DataSource = Enum.GetNames(typeof(System.Windows.Forms.PictureBoxSizeMode)); _cbxNewViewMode.SelectedIndex = (int)PictureBoxSizeMode.Zoom; _cbxOriginalMode.SelectedIndex = (int)PictureBoxSizeMode.Zoom; _pbChanged.SizeMode = PictureBoxSizeMode.Zoom; _pbOriginal.SizeMode = PictureBoxSizeMode.Zoom; _pbChanged.MaximumSize = _pbChanged.Size; _pbOriginal.MaximumSize = _pbOriginal.Size; if (_originalImage != null && !DesignMode) { _pbOriginal.Image = _originalImage; _format = _originalImage.RawFormat; _lblOrigInfo.Text = string.Format("Colors: {0}\nSize: {1} X {2} pixels\nHorizontal Resolution {3}\nVertical resolution: {4}", MyOpenFileDialogControl.GetColorsCountFromImage(_pbOriginal.Image), _originalImage.Width, _originalImage.Height, _originalImage.HorizontalResolution, _originalImage.VerticalResolution); Display(); } }
public MySaveDialogControl(string originalfile, IWin32Window parent) { try { _imageFile = originalfile; _originalImage = Image.FromFile(originalfile); } catch { _imageFile = null; } if (_imageFile == null || _imageFile.Length == 0) { MyOpenFileDialogControl openDialog = new MyOpenFileDialogControl(); try { if (parent == null) { parent = Application.OpenForms[0]; } if (openDialog.ShowDialog(parent) == DialogResult.OK) { _imageFile = openDialog.MSDialog.FileName; _originalImage = Image.FromFile(_imageFile); InitializeComponent(); } else { Dispose(); } } finally { if (openDialog != null) { openDialog.Dispose(); } openDialog = null; GC.Collect(); GC.WaitForPendingFinalizers(); } } else { InitializeComponent(); } }
public MySaveDialogControl(string originalfile, IWin32Window parent) { try { _imageFile = originalfile; _originalImage = Image.FromFile(originalfile); } catch { _imageFile = null; } if (_imageFile == null || _imageFile.Length == 0) { MyOpenFileDialogControl openDialog = new MyOpenFileDialogControl(); try { if (parent == null) parent = Application.OpenForms[0]; if (openDialog.ShowDialog(parent) == DialogResult.OK) { _imageFile = openDialog.MSDialog.FileName; _originalImage = Image.FromFile(_imageFile); InitializeComponent(); } else { Dispose(); } } finally { if (openDialog != null) openDialog.Dispose(); openDialog = null; GC.Collect(); GC.WaitForPendingFinalizers(); } } else { InitializeComponent(); } }
private void btnGetFERETImages_Click(object sender, EventArgs e) { using (MyOpenFileDialogControl dlgLoad = new MyOpenFileDialogControl()) { dlgLoad.FileDlgCaption = "Select a ERun file..."; dlgLoad.FileDlgFilter = "ENFORM Set File (*.eset)|*.eset|Text File (*.txt) |*.txt|Any file (*.*)|*.*"; if (dlgLoad.ShowDialog() == DialogResult.OK) { if ((dlgLoad.MSDialog as OpenFileDialog).FileNames.Length > 0) { using (StreamReader r = new StreamReader(dlgLoad.FileDlgFileName)) { while (!r.EndOfStream) { string[] s = r.ReadLine().Split(','); string use = s[1].Trim(); string filename = s[3]; if (use == "1") { SourceItem item = new SourceItem(filename, dlgLoad.SampleType); ListViewItem newItem = lstInputs.Items.Add(new ListViewItem(item.GetStringValues())); sourceItems.Add(newItem.GetHashCode(), item); } } } } //SourceItem item = new SourceItem(controlex.Filename, 0); //ListViewItem newItem = lstInputs.Items.Add(new ListViewItem(item.GetStringValues())); //sourceItems.Add(newItem.GetHashCode(), item); } } }
private void button1_Click(object sender, EventArgs e) { using (MyOpenFileDialogControl dlgLoad = new MyOpenFileDialogControl()) { dlgLoad.FileDlgCaption = "Select a ERun file..."; dlgLoad.FileDlgFilter = "ENFORM Set File (*.eset)|*.eset|Text File (*.txt) |*.txt|Any file (*.*)|*.*"; if (dlgLoad.ShowDialog() == DialogResult.OK) { if ((dlgLoad.MSDialog as OpenFileDialog).FileNames.Length > 0) { double total = 0.0; int count = 0; using (StreamReader r = new StreamReader(dlgLoad.FileDlgFileName)) { while (!r.EndOfStream) { string[] s = r.ReadLine().Split(','); string use = s[2].Trim(); string filename = s[3]; if (use == "1") { try { SourceItem item = new SourceItem(filename, dlgLoad.SampleType); currentSource = item; total += calculateFitness(); count++; } catch (Exception) { } } } } MessageBox.Show("Average fitness = " + (total / (double) count).ToString()); } //SourceItem item = new SourceItem(controlex.Filename, 0); //ListViewItem newItem = lstInputs.Items.Add(new ListViewItem(item.GetStringValues())); //sourceItems.Add(newItem.GetHashCode(), item); } } }
private void btnLoadImages_Click(object sender, EventArgs e) { /* OpenFileDialog dlgOpen = new OpenFileDialog(); dlgOpen.InitialDirectory = "./"; dlgOpen.Multiselect = true; dlgOpen.Title = "Select file to add to test set..."; dlgOpen.Filter = "Image Files |*.png;*.jpg;*.bmp"; DialogResult r = dlgOpen.ShowDialog(this); if (r == DialogResult.OK) { if (dlgOpen.FileNames.Length > 0) { foreach (String s in dlgOpen.FileNames) { SourceItem item = new SourceItem(s, 0); ListViewItem newItem = lstInputs.Items.Add(new ListViewItem(item.GetStringValues())); sourceItems.Add(newItem.GetHashCode(),item); } } } * * / * */ MyOpenFileDialogControl dlgLoad = new MyOpenFileDialogControl(); dlgLoad.FileDlgInitialDirectory = "./"; dlgLoad.FileDlgCaption = "Select file to add to test set..."; dlgLoad.FileDlgFilter = "Image Files (*.png,*.jpg,*.bmp,*.ppm)|*.png;*.jpg;*.bmp;*.ppm"; DialogResult r = dlgLoad.ShowDialog(); if (r == DialogResult.OK) { if ((dlgLoad.MSDialog as OpenFileDialog).FileNames.Length > 0) { foreach (String s in (dlgLoad.MSDialog as OpenFileDialog).FileNames) { SourceItem item = new SourceItem(s, dlgLoad.SampleType); ListViewItem newItem = lstInputs.Items.Add(new ListViewItem(item.GetStringValues())); sourceItems.Add(newItem.GetHashCode(), item); } } //SourceItem item = new SourceItem(controlex.Filename, 0); //ListViewItem newItem = lstInputs.Items.Add(new ListViewItem(item.GetStringValues())); //sourceItems.Add(newItem.GetHashCode(), item); } //controlex.Dispose(); if (lstInputs.SelectedItems.Count == 0 && lstInputs.Items.Count > 0) { lstInputs.Focus(); lstInputs.Items[0].Selected = true; } }
private void button1_Click(object sender, EventArgs e) { if (sender.Equals(_btnSelect)) { using (MyOpenFileDialogControl openDialog = new MyOpenFileDialogControl()) { if (openDialog.ShowDialog(this) == DialogResult.OK) { lblFilePath.Text = openDialog.MSDialog.FileName; } } } else if (sender.Equals(_btnSave)) { using (MySaveDialogControl saveDialog = new MySaveDialogControl(lblFilePath.Text, this)) { if (saveDialog.ShowDialog(this) == DialogResult.OK) { lblFilePath.Text = saveDialog.MSDialog.FileName; } } } else if (sender.Equals(this._btnExtension)) { using (MyOpenFileDialogControl openDialogCtrl = new MyOpenFileDialogControl()) { openDialogCtrl.FileDlgInitialDirectory = Environment.GetFolderPath(Environment.SpecialFolder.MyPictures); OpenFileDialog openDialog = new OpenFileDialog(); openDialog.InitialDirectory = Environment.GetFolderPath(Environment.SpecialFolder.MyPictures); openDialog.AddExtension = true; openDialog.Filter = "Image Files(*.bmp)|*.bmp |Image Files(*.JPG)|*.JPG|Image Files(*.jpeg)|*.jpeg|Image Files(*.GIF)|*.GIF|Image Files(*.emf)|*emf.|Image Files(*.ico)|*.ico|Image Files(*.png)|*.png|Image Files(*.tif)|*.tif|Image Files(*.wmf)|*.wmf|Image Files(*.exif)|*.exif"; openDialog.FilterIndex = 2; openDialog.CheckFileExists = true; openDialog.DefaultExt = "jpg"; openDialog.FileName = "Select Picture"; openDialog.DereferenceLinks = true; //openDialog.ShowHelp = true; if (Environment.OSVersion.Version.Major < 6) openDialog.SetPlaces(new object[] { @"c:\", (int)Places.MyComputer, (int)Places.Favorites, (int)Places.Printers, (int)Places.Fonts }); if (openDialog.ShowDialog(openDialogCtrl, this) == DialogResult.OK) { lblFilePath.Text = openDialog.FileName; } } } else if (sender.Equals(_btnSaveExt)) { using (SaveFileDialog saveDialog = new SaveFileDialog()) { MySaveDialogControl saveDialogCtrl = new MySaveDialogControl(lblFilePath.Text, this); saveDialogCtrl.FileDlgInitialDirectory = Environment.GetFolderPath(Environment.SpecialFolder.MyPictures); saveDialog.InitialDirectory = Environment.GetFolderPath(Environment.SpecialFolder.MyPictures); saveDialog.AddExtension = true; saveDialog.Filter = "Image Files(*.bmp)|*.bmp |Image Files(*.JPG)|*.JPG|Image Files(*.jpeg)|*.jpeg|Image Files(*.GIF)|*.GIF|Image Files(*.emf)|*emf.|Image Files(*.ico)|*.ico|Image Files(*.png)|*.png|Image Files(*.tif)|*.tif|Image Files(*.wmf)|*.wmf|Image Files(*.exif)|*.exif"; saveDialog.FilterIndex = 2; saveDialog.CheckFileExists = true; saveDialog.DefaultExt = "jpg"; saveDialog.FileName = "Change Picture"; saveDialog.DereferenceLinks = true; //saveDialog.ShowHelp = true; if (Environment.OSVersion.Version.Major < 6) saveDialog.SetPlaces(new object[] { (int)Places.Desktop, (int)Places.Printers, (int)Places.Favorites, (int)Places.Programs, (int)Places.Fonts, }); if (saveDialog.ShowDialog(saveDialogCtrl, this) == DialogResult.OK) { lblFilePath.Text = saveDialog.FileName; } } } else if (sender.Equals(_btnExit)) this.Close(); System.GC.Collect(); GC.WaitForPendingFinalizers(); }
private void button1_Click(object sender, EventArgs e) { if (sender.Equals(_btnSelect)) { using (MyOpenFileDialogControl openDialog = new MyOpenFileDialogControl()) { if (openDialog.ShowDialog(this) == DialogResult.OK) { lblFilePath.Text = openDialog.MSDialog.FileName; } } } else if (sender.Equals(_btnSave)) { using (MySaveDialogControl saveDialog = new MySaveDialogControl(lblFilePath.Text, this)) { if (saveDialog.ShowDialog(this) == DialogResult.OK) { lblFilePath.Text = saveDialog.MSDialog.FileName; } } } else if (sender.Equals(this._btnExtension)) { using (MyOpenFileDialogControl openDialogCtrl = new MyOpenFileDialogControl()) { openDialogCtrl.FileDlgInitialDirectory = Environment.GetFolderPath(Environment.SpecialFolder.MyPictures); OpenFileDialog openDialog = new OpenFileDialog(); openDialog.InitialDirectory = Environment.GetFolderPath(Environment.SpecialFolder.MyPictures); openDialog.AddExtension = true; openDialog.Filter = "Image Files(*.bmp)|*.bmp |Image Files(*.JPG)|*.JPG|Image Files(*.jpeg)|*.jpeg|Image Files(*.GIF)|*.GIF|Image Files(*.emf)|*emf.|Image Files(*.ico)|*.ico|Image Files(*.png)|*.png|Image Files(*.tif)|*.tif|Image Files(*.wmf)|*.wmf|Image Files(*.exif)|*.exif"; openDialog.FilterIndex = 2; openDialog.CheckFileExists = true; openDialog.DefaultExt = "jpg"; openDialog.FileName = "Select Picture"; openDialog.DereferenceLinks = true; //openDialog.ShowHelp = true; if (Environment.OSVersion.Version.Major < 6) { openDialog.SetPlaces(new object[] { @"c:\", (int)Places.MyComputer, (int)Places.Favorites, (int)Places.Printers, (int)Places.Fonts }); } if (openDialog.ShowDialog(openDialogCtrl, this) == DialogResult.OK) { lblFilePath.Text = openDialog.FileName; } } } else if (sender.Equals(_btnSaveExt)) { using (SaveFileDialog saveDialog = new SaveFileDialog()) { MySaveDialogControl saveDialogCtrl = new MySaveDialogControl(lblFilePath.Text, this); saveDialogCtrl.FileDlgInitialDirectory = Environment.GetFolderPath(Environment.SpecialFolder.MyPictures); saveDialog.InitialDirectory = Environment.GetFolderPath(Environment.SpecialFolder.MyPictures); saveDialog.AddExtension = true; saveDialog.Filter = "Image Files(*.bmp)|*.bmp |Image Files(*.JPG)|*.JPG|Image Files(*.jpeg)|*.jpeg|Image Files(*.GIF)|*.GIF|Image Files(*.emf)|*emf.|Image Files(*.ico)|*.ico|Image Files(*.png)|*.png|Image Files(*.tif)|*.tif|Image Files(*.wmf)|*.wmf|Image Files(*.exif)|*.exif"; saveDialog.FilterIndex = 2; saveDialog.CheckFileExists = true; saveDialog.DefaultExt = "jpg"; saveDialog.FileName = "Change Picture"; saveDialog.DereferenceLinks = true; //saveDialog.ShowHelp = true; if (Environment.OSVersion.Version.Major < 6) { saveDialog.SetPlaces(new object[] { (int)Places.Desktop, (int)Places.Printers, (int)Places.Favorites, (int)Places.Programs, (int)Places.Fonts, }); } if (saveDialog.ShowDialog(saveDialogCtrl, this) == DialogResult.OK) { lblFilePath.Text = saveDialog.FileName; } } } else if (sender.Equals(_btnExit)) { this.Close(); } System.GC.Collect(); GC.WaitForPendingFinalizers(); }