private void _cropsView_CellValueChanged(object sender, DataGridViewCellEventArgs e) { if (_isLoaded && e.RowIndex >= 0) { CropFormat format = _cropsView.Rows[e.RowIndex].Tag as CropFormat; string newName = _cropsView["NameColumn", e.RowIndex].Value != null ? _cropsView["NameColumn", e.RowIndex].Value.ToString() : string.Empty; float newWidth = 0.0f; if (_cropsView["WidthColumn", e.RowIndex].Value != null) { float.TryParse(_cropsView["WidthColumn", e.RowIndex].Value.ToString(), out newWidth); } float newHeight = 0.0f; if (_cropsView["HeightColumn", e.RowIndex].Value != null) { float.TryParse(_cropsView["HeightColumn", e.RowIndex].Value.ToString(), out newHeight); } if (format != null) { format.Name = newName; format.Width = newWidth; format.Height = newHeight; } else { format = CropManager.AddCropFormat(newName, newWidth, newHeight, false); _cropsView.Rows[e.RowIndex].Tag = format; } ValidateCells(null); } }
public CropButton(CropFormat cropStruct, string cropTitle) { if (cropStruct.Width < 0 || cropStruct.Height <= 0) { _cropProportion = 0; } else { _cropProportion = (double)cropStruct.Width / (double)cropStruct.Height; } Style = (Style)FindResource("ImageEditorRadioButtonStyle"); Width = 100; Height = 70; Margin = new Thickness(9, 11, 9, 11); StackPanel panel = new StackPanel(); panel.VerticalAlignment = VerticalAlignment.Center; panel.HorizontalAlignment = HorizontalAlignment.Center; Aurigma.PhotoKiosk.OutlinedText cropOutliledText = new OutlinedText(cropStruct.Name, (Style)FindResource("CropParamsTextStyle")); cropOutliledText.HorizontalAlignment = HorizontalAlignment.Center; cropOutliledText.Margin = new Thickness(8, 0, 8, 0); panel.Children.Add(cropOutliledText); TextBlock cropTextBlock = new TextBlock(); cropTextBlock.Style = (Style)FindResource("ImageEditorButtonTextStyle"); cropTextBlock.HorizontalAlignment = HorizontalAlignment.Center; cropTextBlock.Text = cropTitle; panel.Children.Add(cropTextBlock); this.Content = panel; }
private void _cropsView_UserDeletedRow(object sender, DataGridViewRowEventArgs e) { CropFormat format = e.Row.Tag as CropFormat; CropManager.RemoveCropFormat(format); ValidateCells(null); _cropsView.AllowUserToAddRows = _cropsView.Rows.Count <= Constants.MaxCropsCount; }
private void _cropsView_DragDrop(object sender, DragEventArgs e) { var newFormats = new CropFormat[CropManager.CropFormats.Count]; for (int i = 0; i < _cropsView.Rows.Count; i++) { CropFormat type = _cropsView.Rows[i].Tag as CropFormat; if (type != null) { newFormats[i] = type; } } CropManager.UpdateCropFormats(newFormats); ValidateCells(null); }