예제 #1
0
        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);
            }
        }
예제 #2
0
        private void _contextMenuItem_Click(object sender, EventArgs args)
        {
            int rowIndex = _mouseLocation.RowIndex;

            if (rowIndex >= 0 && rowIndex < _formatsView.Rows.Count)
            {
                PaperFormat format = _formatsView.Rows[rowIndex].Tag as PaperFormat;
                if (format != null)
                {
                    CropManager.AddCropFormat(format.Name, format.Width, format.Height, true);
                }
            }
        }