public bool HaveSameSegmentType() { if (Keys.Length == 0) { return(true); } Data.SegmentKind segmentType = Keys[0].getSegmentType(); for (int i = 1; i < Keys.Length; i++) { if (Keys[i].getSegmentType() != Data.SegmentKind.None) // ignore the leftest keys of a curve because the have no segmentInfo { if (Keys[i].getSegmentType() != segmentType) { return(false); } } } return(true); }
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; }