private void TrackBarFGControl_ValueChanged(object sender, EventArgs e) { if (this._ezdOriginalImage != null) { this.foregroundPictureBox.Image = PictureControl.Scale( this._ezdOriginalImage, new Size( this._ezdOriginalImageMaxSize - this.trackBarFGControl.Value, this._ezdOriginalImageMaxSize - this.trackBarFGControl.Value)); } }
private void TrackBarBGControl_ValueChanged(object sender, EventArgs e) { if (this._bgOriginalImage != null) { if (this.scale_bg) { this.backgroundPictureBox.Image = PictureControl.Scale( this._bgOriginalImage, new Size(this.trackBarBGControl.Value, this.trackBarBGControl.Value)); } else { this.backgroundPictureBox.Image = PictureControl.Zoom( this._bgOriginalImage, new Size(this.trackBarBGControl.Value, this.trackBarBGControl.Value)); } } }
private void Upload(UploadType type) { // take filter type var filter = type == UploadType.Ezd ? @"EZD file (*.ezd) | *.ezd" : @"Image files (*.jpg, *.jpeg, *.png) | *.jpg; *.jpeg; *.png"; using (var ofd = new OpenFileDialog { Multiselect = false, ValidateNames = true, Filter = filter }) { if (ofd.ShowDialog() == DialogResult.OK) { // take BG|FG image from fileName if (type == UploadType.Ezd) { try { this.LoadImage(ofd.FileName); } catch (Exception ex) { XtraMessageBox.Show(ex.Message, "Error", MessageBoxButtons.OK); } } else { var img = Image.FromFile(ofd.FileName); if (img.Width > ClientRectangle.Width) { var residue = img.Width - ClientRectangle.Width; int percent = (int)(decimal.Divide(residue, img.Width) * 100); img = PictureControl.Scale(img, new Size(percent, percent)); this.scale_bg = true; } else { this.scale_bg = false; } if (img.Height > ClientRectangle.Height) { var residue = img.Height - ClientRectangle.Height; var percent = (int)(decimal.Divide(residue, img.Height) * 100); img = PictureControl.Scale(img, new Size(percent, percent)); this.scale_bg = true; } this.backgroundPictureBox.Image = img; this.backgroundPictureBox.Width = img.Width; this.backgroundPictureBox.Height = img.Height; this._bgOriginalImage = img; this.bgFileLbl.Text = Path.GetFileName(ofd.FileName); this.InitialBGImage(); } } } }