// Show gradient (enable/disable controls) public void ShowGradientPoint(SelectInformation selectInformation, bool updateListBoxSelection, bool refillListBox = false) { if (refillListBox) { updatingPoint = true; PointGridHandler.RefillGridPoints(grdPoints, getCurrentGradient()); updatingPoint = false; } if (refillListBox || updateListBoxSelection) { updatingPoint = true; grdPoints.ClearSelection(); PointGridHandler.SelectGridCellsFromSelection(grdPoints, selectInformation); grdPoints.Refresh(); updatingPoint = false; } if (selectInformation.Keys.Length == 0) { UpdatePictureGraphics(); NoPointInputs(); return; } AllowPointInputs(); FillGradientPointControls(selectInformation); UpdatePictureGraphics(); }
SelectInformation selection; // shortcut to graphViewHandler.getSelection(); public FrmGradient() { InitializeComponent(); graphViewHandler = new Graph.GraphViewHandler(this, picGraph); colorBand = new Graph.ShowGradientAsColorbeamInView(); graphViewHandler.Addplugin(colorBand); selection = graphViewHandler.Selection; }
public static void SelectGridCellsFromSelection(DataGridView grdPoints, SelectInformation selectInformation) { foreach (DataGridViewRow row in grdPoints.Rows) { foreach (DataGridViewCell cell in row.Cells) { if (cell.Tag != null) { foreach (Data.Key key in ((Data.Key[])cell.Tag)) { if (selectInformation.KeysAndAnchors.Contains(key)) { cell.Selected = true; } } } } } }
public static void SelectInformationFromCells(DataGridView grdPoints, SelectInformation selectInformation) { selectInformation.Clear(); foreach (DataGridViewRow row in grdPoints.Rows) { foreach (DataGridViewCell cell in row.Cells) { if (cell.Selected) { if (cell.Tag != null) { // only R, G, B cells have tag pointing to key foreach (Data.Key key in ((Data.Key[])cell.Tag)) { selectInformation.AddKey(key); } } } } } }
private void FillGradientPointControls(SelectInformation selectInformation) { updatingPoint = true; if (selectInformation.HaveSamePosX()) { float pos = selectInformation.Keys[0].Position.X; txtPosition.Text = pos.ToString("0.000"); if ((pos >= 0) && (pos <= 1.0)) { tbrPosition.Value = (int)(pos * 1000); } } else { txtPosition.Text = "multi"; tbrPosition.Value = 0; } if (selectInformation.redKeysHaveSameRedValue()) { if (selectInformation.RedKeys.Length > 0) { txtRed.Enabled = true; picRed.Enabled = true; float r = selectInformation.RedKeys[0].Position.Y; txtRed.Text = ((byte)(r * 255)).ToString(); } else { txtRed.Enabled = false; picRed.Enabled = false; } } if (selectInformation.greenKeysHaveSameRedValue()) { if (selectInformation.GreenKeys.Length > 0) { txtGreen.Enabled = true; picGreen.Enabled = true; float r = selectInformation.GreenKeys[0].Position.Y; txtGreen.Text = ((byte)(r * 255)).ToString(); } else { txtGreen.Enabled = false; picGreen.Enabled = false; } } if (selectInformation.blueKeysHaveSameRedValue()) { if (selectInformation.BlueKeys.Length > 0) { txtBlue.Enabled = true; picBlue.Enabled = true; float r = selectInformation.BlueKeys[0].Position.Y; txtBlue.Text = ((byte)(r * 255)).ToString(); } else { txtBlue.Enabled = false; picBlue.Enabled = false; } } if (selectInformation.Keys.Length == 0) { cboSegment.Enabled = false; } else { if (selectInformation.HaveSameSegmentType()) { if (selectInformation.Keys[0].getSegmentType() == Data.SegmentKind.None) { cboSegment.Enabled = false; } else { cboSegment.Enabled = true; foreach (Data.Key key in selectInformation.Keys) { Data.SegmentKind tpye = key.getSegmentType(); if (tpye != Data.SegmentKind.None) { // look for a key with a valid segment if (tpye == Data.SegmentKind.UseLeft) { cboSegment.SelectedItem = Constants.Left; } if (tpye == Data.SegmentKind.UseRight) { cboSegment.SelectedItem = Constants.Right; } if (tpye == Data.SegmentKind.Line) { cboSegment.SelectedItem = Constants.Line; } if (tpye == Data.SegmentKind.Bezier) { cboSegment.SelectedItem = Constants.Bezier; } break; } } } } else { cboSegment.Enabled = false; } } updatingPoint = false; }