/// <summary> /// Добавление фото. /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void BtnAdd_Click(object sender, EventArgs e) { if (OpenImage.ShowDialog() == DialogResult.OK) { phonoPictureBox.Load(OpenImage.FileName); } }
/// <summary> /// Initialise convex calculator with strategies of image loading, /// convex hull find, output and executes all this actions /// </summary> /// <param name="openImage">Strategy of image loading</param> /// <param name="convexHullScan">Strategy of convex hull find</param> /// <param name="output">Strategy of output</param> public ConvexHullControl(IOpenImage openImage, IConvexHullScan convexHullScan, IOutput output = null) { Contract.Requires(OpenImage != null); Contract.Requires(ConvexHullScan != null); OpenImage = openImage ?? throw new ArgumentNullException(nameof(openImage)); ConvexHullScan = convexHullScan ?? throw new ArgumentNullException(nameof(convexHullScan)); Output = output; try { SourcePoints = OpenImage.OpenImage(); Output?.OutputPoints(SourcePoints); } catch (Exception e) { throw new Exception("The image loading failed", e); } try { ConvexHull = ConvexHullScan.ConvexHullScan(SourcePoints); Output?.OutputHull(ConvexHull); } catch (Exception e) { throw new Exception("The convex hull scan failed", e); } }
private void btnUpLoad_Click(object sender, RoutedEventArgs e) { if (OpenImage != null) { OpenImage.Invoke(); } }
private void LoadImage_Click(object sender, EventArgs e) { if (OpenImage.ShowDialog() == DialogResult.OK) { LoadedImage = true; ImagePath = OpenImage.FileName; pictureBox1.Image = Rescale(new Bitmap(ImagePath), 128, 128); } }
private void loadNewImageToolStripMenuItem_Click(object sender, EventArgs e) { if (OpenImage.ShowDialog() == DialogResult.OK) { SelectedImage = new Bitmap(OpenImage.FileName); FinalImage = new Bitmap(OpenImage.FileName); picPreview.Image = SelectedImage; menuReload.Enabled = true; } }
private void AddImageButton_Click(object sender, EventArgs e) { DialogResult result = OpenImage.ShowDialog(); if (result == DialogResult.OK) { OpenPath = OpenImage.FileName; OpenFileName = OpenImage.SafeFileName; SavePath = @"data\book\pic\" + OpenImage.SafeFileName; NewImageBox.Image = Image.FromFile(OpenPath); OpenImage.InitialDirectory = OpenPath.Substring(0, OpenPath.Length - OpenImage.SafeFileName.Length); } }
private void OpenMI_Click(object sender, EventArgs e) { if (OpenImage.ShowDialog() == DialogResult.OK) { bool success = true; foreach (string path in OpenImage.FileNames) { try { Bitmap image; using (FileStream stream = new FileStream(path, FileMode.Open)) image = new Bitmap(stream); if (!image.RawFormat.Equals(ImageFormat.Bmp) && !image.RawFormat.Equals(ImageFormat.Jpeg)) { Message.Warning("Incorrect image format!", Text); } else { images.Add(counter, new BitmapPair(image)); //picture PictureBox picture = new PictureBox(); picture.Name = "PB" + counter; picture.SizeMode = PictureBoxSizeMode.Zoom; picture.Dock = DockStyle.Fill; picture.Image = image; picture.ContextMenuStrip = ImageMenu; //tabpage for picture TabPage page = new TabPage(Path.GetFileName(path)); page.Name = "TP" + counter; page.Controls.Add(picture); Tabs.TabPages.Add(page); ++counter; } } catch (Exception exception) { Log.Append(exception.Message + Environment.NewLine + exception.StackTrace); success = false; } } if (!success) { Message.Warning("Failed to open some images!", Text); } UpdateUI(); } }
private void AddImageButton_Click(object sender, EventArgs e) { DialogResult result = OpenImage.ShowDialog(); if (result == DialogResult.OK) { string path = OpenImage.FileName; if (!File.Exists(@"data\book\pic\" + OpenImage.SafeFileName)) { System.IO.File.Copy(path, @"data\book\pic\" + OpenImage.SafeFileName, true); } else { tmp = 1; } SavePath = @"data\book\pic\" + OpenImage.SafeFileName; BookImagePictureBox.Image = Image.FromFile(path); OpenImage.InitialDirectory = path.Substring(0, path.Length - OpenImage.SafeFileName.Length); } }
protected virtual void OnOpenImage(ImageOpenEventArgs e) { OpenImage?.Invoke(this, e); }
public CriminalInfo(Criminal criminal) { InitializeComponent(); Criminal = criminal; nameBox.Text = Criminal.Name; CriminalImage.Image = Criminal.Image; surnameBox.Text = Criminal.Surname; aliasBox.Text = Criminal.Alias; heightBox.Value = Criminal.Height; ageBox.Text = Criminal.Age.ToString(); genderBox.SelectedItem = Criminal.Gender; nationalityBox.SelectedItem = Criminal.Nationality; birthdayBox.Value = Criminal.BirthDay; professionBox.Text = Criminal.Description; countryWhereWantedBox.SelectedItem = Criminal.CountryWhereWanted; ganglabel.Text = Criminal.Gang != null ? Criminal.Gang.Name : "None"; if (Criminal.Adress != null) { cityBox.Text = Criminal.Adress.City; streetBox.Text = Criminal.Adress.Street; houseBox.Text = Criminal.Adress.House; } if (Criminal.LastAdress != null) { lastcityBox.Text = Criminal.LastAdress.City; lastStreetBox.Text = Criminal.LastAdress.Street; lastHouseBox.Text = Criminal.LastAdress.House; } // если текущий пользователь программы это обычный пользователь // то от него скрываются все елементы управления которые служат для изменения информации if (User.Role == UserRole.User) { foreach (Control i in Controls) { if (i is TextBox t) { t.ReadOnly = true; } if (i is ComboBox c) { c.Enabled = false; } if (i is NumericUpDown n) { n.Enabled = false; } if (i is DateTimePicker d) { d.Enabled = false; } if (i is GroupBox g) { foreach (Control j in g.Controls) { if (j is TextBox tb) { tb.ReadOnly = true; } if (j is RichTextBox rb) { rb.ReadOnly = true; } } } } label.Hide(); IdLable.Hide(); OpenImage.Hide(); saveButton.Hide(); chooseButton.Hide(); } else { label.Show(); IdLable.Show(); IdLable.Text = Criminal.Id.ToString(); } }