// New private void btnAddNewPoint_Click(object sender, EventArgs e) { Data.Gradient gradient = getCurrentGradient(); float newPointsPosition = 0.5f; Data.Key rightestSelPoint = Utils.GetRightestKey(selection.Keys); if (rightestSelPoint != null) { // check if there is an unselected point to the right on the same color curve as the rightest point Data.Key rightNeighbour = gradient.FindFirstKeyRightOf(rightestSelPoint); if (rightNeighbour != null) { newPointsPosition = (rightestSelPoint.Position.X + rightNeighbour.Position.X) * 0.5f; } } //create point Data.Key[] newKeys = gradient.AddKeysAtPositionX(newPointsPosition, Color.FromArgb(255, 50, 150, 250)); // select new point selection.Clear(); selection.AddKeys(newKeys); ShowGradientPoint(selection, false, true); graphViewHandler.RefreshPicture(); }
public static Data.Key GetRightestKey(Data.Key[] keys) { Data.Key rightestSelPoint = null; foreach (Data.Key key in keys) { if (rightestSelPoint == null || key.Position.X > rightestSelPoint.Position.X) { rightestSelPoint = key; } } return(rightestSelPoint); }
public SelectInformation DeleteKey(Data.Key key) { key.IsSelected = false; U.RemoveFromArray(ref Keys, key); KeysAndAnchors.Remove(key); if (((Tag)key.Tag) == Tag.RED) { U.RemoveFromArray(ref RedKeys, key); } else if (((Tag)key.Tag) == Tag.GREEN) { U.RemoveFromArray(ref GreenKeys, key); } else if (((Tag)key.Tag) == Tag.BLUE) { U.RemoveFromArray(ref BlueKeys, key); } return(this); }
public SelectInformation AddKey(Data.Key key) { key.IsSelected = true; U.AddToArray(ref Keys, key); KeysAndAnchors.Add(key); if (((Tag)key.Tag) == Tag.RED) { U.AddToArray(ref RedKeys, key); } else if (((Tag)key.Tag) == Tag.GREEN) { U.AddToArray(ref GreenKeys, key); } else if (((Tag)key.Tag) == Tag.BLUE) { U.AddToArray(ref BlueKeys, key); } return(this); }