public override void gameWindowSizeChanged(Rectangle oldBounds, Rectangle newBounds) { this.ItemsToGrabMenu.gameWindowSizeChanged(oldBounds, newBounds); this.organizeButton = new ClickableTextureComponent("", new Rectangle(this.xPositionOnScreen + this.width, this.yPositionOnScreen + this.height / 3 - 64, 64, 64), "", Game1.content.LoadString("Strings\\UI:ItemGrab_Organize"), Game1.mouseCursors, new Rectangle(162, 440, 16, 16), 4f, false); this.chestColorPicker = new DiscreteColorPicker(this.xPositionOnScreen, this.yPositionOnScreen - 64 - IClickableMenu.borderWidth * 2, 0, (Item)null); this.chestColorPicker.colorSelection = this.chestColorPicker.getSelectionFromColor((Color)((NetFieldBase <Color, NetColor>)(this.sourceItem as Chest).playerChoiceColor)); }
public MachineInventory(Revitalize.Objects.Machines.Machine Machine, List <Item> InputInventory, List <Item> OutputInventory, int rows, bool reverseGrab, bool showReceivingMenu, InventoryMenu.highlightThisItem highlightFunction, MachineInventory.behaviorOnItemSelect behaviorOnItemSelectFunction, string message, MachineInventory.behaviorOnItemSelect behaviorOnItemGrab = null, bool snapToBottom = false, bool canBeExitedWithKey = false, bool playRightClickSound = true, bool allowRightClick = true, bool showOrganizeButton = false, int source = 0, Item sourceItem = null) : base(highlightFunction, true, true, 0, 0) { this.machine = Machine; this.source = source; this.message = message; this.reverseGrab = reverseGrab; this.showReceivingMenu = showReceivingMenu; this.playRightClickSound = playRightClickSound; this.allowRightClick = allowRightClick; this.inventory.showGrayedOutSlots = true; this.sourceItem = sourceItem; this.Rows = rows; if (source == 1 && sourceItem != null && sourceItem is Chest) { this.chestColorPicker = new DiscreteColorPicker(this.xPositionOnScreen, this.yPositionOnScreen - Game1.tileSize - IClickableMenu.borderWidth * 2, 0, new Chest(true)); this.chestColorPicker.colorSelection = this.chestColorPicker.getSelectionFromColor((sourceItem as Chest).playerChoiceColor); (this.chestColorPicker.itemToDrawColored as Chest).playerChoiceColor = this.chestColorPicker.getColorFromSelection(this.chestColorPicker.colorSelection); this.colorPickerToggleButton = new ClickableTextureComponent(new Rectangle(this.xPositionOnScreen + this.width, this.yPositionOnScreen + Game1.tileSize + Game1.pixelZoom * 5, 16 * Game1.pixelZoom, 16 * Game1.pixelZoom), Game1.mouseCursors, new Rectangle(119, 469, 16, 16), (float)Game1.pixelZoom, false) { hoverText = Game1.content.LoadString("Strings\\UI:Toggle_ColorPicker", new object[0]) }; } if (snapToBottom) { base.movePosition(0, Game1.viewport.Height - (this.yPositionOnScreen + this.height - IClickableMenu.spaceToClearTopBorder)); this.snappedtoBottom = true; } this.inputInventory = new InventoryMenu(this.xPositionOnScreen + Game1.tileSize / 2, this.yPositionOnScreen, false, InputInventory, highlightFunction, 9, 3, 0, 0, true); this.outputInventory = new StardewValley.Menus.InventoryMenu(this.xPositionOnScreen + Game1.tileSize * 8, this.yPositionOnScreen, false, OutputInventory, null, 9, 3, 0, 0, true); //Log.AsyncM(this.inputInventory.actualInventory.Capacity); this.inputInventory.capacity = 9; this.inputInventory.capacity = 9; this.inputInventory.actualInventory.Capacity = 9; this.outputInventory.actualInventory.Capacity = 9; this.behaviorFunction = behaviorOnItemSelectFunction; this.behaviorOnItemGrab = behaviorOnItemGrab; this.canExitOnKey = canBeExitedWithKey; if (showOrganizeButton) { this.organizeButton = new ClickableTextureComponent("", new Rectangle(this.xPositionOnScreen + this.width, this.yPositionOnScreen + this.height / 3 - Game1.tileSize, Game1.tileSize, Game1.tileSize), "", Game1.content.LoadString("Strings\\UI:ItemGrab_Organize", new object[0]), Game1.mouseCursors, new Rectangle(162, 440, 16, 16), (float)Game1.pixelZoom, false); } if ((Game1.isAnyGamePadButtonBeingPressed() || !Game1.lastCursorMotionWasMouse) && this.inputInventory.actualInventory.Count > 0 && Game1.activeClickableMenu == null) { Game1.setMousePosition(this.inventory.inventory[0].bounds.Center); } TextureDataNode d; Dictionaries.spriteFontList.TryGetValue("leftArrow", out d); TextureDataNode f; Dictionaries.spriteFontList.TryGetValue("rightArrow", out f); this.LeftButton = new ClickableTextureComponent(new Rectangle(this.xPositionOnScreen + Game1.tileSize / 3, this.yPositionOnScreen / 4, Game1.tileSize, Game1.tileSize), d.texture, new Rectangle(0, 0, 16, 16), 4f, false); this.RightButton = new ClickableTextureComponent(new Rectangle(this.xPositionOnScreen + Game1.tileSize, this.yPositionOnScreen / 4, Game1.tileSize, Game1.tileSize), f.texture, new Rectangle(0, 0, 16, 16), 4f, false); }
public ColorComponent(string name, int color, Settings settings) { // literally does not even use third argument to set starting color ColorPicker = new DiscreteColorPicker(1, 1) { visible = false, colorSelection = color }; this.settings = settings; this.name = name; }
public override Object ShowDialog(PropertyItem propertyItem, Object propertyValue, IInputElement commandSource) { HashSet <Color> discreteColors = GetDiscreteColors(propertyItem.Component); Color colorValue; if (propertyValue != null) { colorValue = (Color)propertyValue; } else { colorValue = discreteColors.Any() ? discreteColors.First() : Color.White; } DialogResult result; if (discreteColors.Any()) { using (DiscreteColorPicker dcp = new DiscreteColorPicker()) { dcp.ValidColors = discreteColors; dcp.SingleColorOnly = true; dcp.SelectedColors = new List <Color> { colorValue }; dcp.Text = propertyItem.DisplayName; result = dcp.ShowDialog(); if (result == DialogResult.OK) { propertyValue = !dcp.SelectedColors.Any() ? discreteColors.First() : dcp.SelectedColors.First(); } } } else { using (ColorPicker cp = new ColorPicker()) { cp.LockValue_V = true; cp.Color = XYZ.FromRGB(colorValue); cp.Text = propertyItem.DisplayName; result = cp.ShowDialog(); if (result == DialogResult.OK) { propertyValue = cp.Color.ToRGB().ToArgb(); } } } return(propertyValue); }
public void setSourceItem(Item item) { this.sourceItem = item; this.chestColorPicker = null; this.colorPickerToggleButton = null; if (this.source == 1 && this.sourceItem != null && this.sourceItem is Chest) { this.chestColorPicker = new DiscreteColorPicker(this.xPositionOnScreen, this.yPositionOnScreen - Game1.tileSize - IClickableMenu.borderWidth * 2, 0, new Chest(true)); this.chestColorPicker.colorSelection = this.chestColorPicker.getSelectionFromColor((this.sourceItem as Chest).playerChoiceColor); (this.chestColorPicker.itemToDrawColored as Chest).playerChoiceColor = this.chestColorPicker.getColorFromSelection(this.chestColorPicker.colorSelection); this.colorPickerToggleButton = new ClickableTextureComponent(new Rectangle(this.xPositionOnScreen + this.width, this.yPositionOnScreen + Game1.tileSize + Game1.pixelZoom * 5, 16 * Game1.pixelZoom, 16 * Game1.pixelZoom), Game1.mouseCursors, new Rectangle(119, 469, 16, 16), (float)Game1.pixelZoom, false) { hoverText = Game1.content.LoadString("Strings\\UI:Toggle_ColorPicker", new object[0]) }; } }
public void setSourceItem(Item item) { this.sourceItem = item; this.chestColorPicker = (DiscreteColorPicker)null; this.colorPickerToggleButton = (ClickableTextureComponent)null; if (this.sourceItem == null) { return; } this.chestColorPicker = new DiscreteColorPicker(this.xPositionOnScreen, this.yPositionOnScreen - 64 - IClickableMenu.borderWidth * 2, 0, (Item) new Chest(true)); this.chestColorPicker.colorSelection = this.chestColorPicker.getSelectionFromColor((Color)((NetFieldBase <Color, NetColor>)(this.sourceItem as Chest).playerChoiceColor)); (this.chestColorPicker.itemToDrawColored as Chest).playerChoiceColor.Value = this.chestColorPicker.getColorFromSelection(this.chestColorPicker.colorSelection); this.colorPickerToggleButton = new ClickableTextureComponent(new Rectangle(this.xPositionOnScreen + this.width, this.yPositionOnScreen + 64 + 20, 64, 64), Game1.mouseCursors, new Rectangle(119, 469, 16, 16), 4f, false) { hoverText = Game1.content.LoadString("Strings\\UI:Toggle_ColorPicker") }; }
private Tuple <DialogResult, System.Drawing.Color> ChooseColor(List <ElementNode> selectedNodes, System.Drawing.Color color) { var returnColor = color; var colors = ValidDiscreteColors(selectedNodes); DialogResult result = DialogResult.Abort; if (colors.Any()) { using (DiscreteColorPicker dcp = new DiscreteColorPicker()) { dcp.ValidColors = colors; dcp.SingleColorOnly = true; dcp.SelectedColors = new List <System.Drawing.Color> { color }; result = dcp.ShowDialog(); if (result == DialogResult.OK) { if (!dcp.SelectedColors.Any()) { returnColor = System.Drawing.Color.White; } else { returnColor = dcp.SelectedColors.First(); } } } } else { using (ColorPicker cp = new ColorPicker()) { cp.LockValue_V = false; cp.Color = XYZ.FromRGB(color); result = cp.ShowDialog(); if (result == DialogResult.OK) { returnColor = cp.Color.ToRGB(); } } } return(new Tuple <DialogResult, System.Drawing.Color>(result, returnColor)); }
public ShowcaseContainer( Showcase showcase, List <Item> items, int capacity, int rows, InventoryMenu.highlightThisItem isItemEnabled, bool allowColoring) : base(items, capacity, rows, null, isItemEnabled) { Items = items; this.SetFieldValue <behaviorOnItemChange>(ItemChangeBehaviorField, ProcessItemChanged); ItemsToGrabMenu.movePosition(0, (3 - rows) * Game1.tileSize); if (!allowColoring) { return; } ColorPicker = new ShowcaseColorPicker(xPositionOnScreen, yPositionOnScreen - Game1.tileSize - borderWidth * 2, showcase); }
public override void gameWindowSizeChanged(Rectangle oldBounds, Rectangle newBounds) { if (this.snappedtoBottom) { base.movePosition((newBounds.Width - oldBounds.Width) / 2, Game1.viewport.Height - (this.yPositionOnScreen + this.height - IClickableMenu.spaceToClearTopBorder)); } if (this.ItemsToGrabMenu != null) { this.ItemsToGrabMenu.gameWindowSizeChanged(oldBounds, newBounds); } if (this.organizeButton != null) { this.organizeButton = new ClickableTextureComponent("", new Rectangle(this.xPositionOnScreen + this.width, this.yPositionOnScreen + this.height / 3 - Game1.tileSize, Game1.tileSize, Game1.tileSize), "", Game1.content.LoadString("Strings\\UI:ItemGrab_Organize", new object[0]), Game1.mouseCursors, new Rectangle(162, 440, 16, 16), (float)Game1.pixelZoom, false); } if (this.source == 1 && this.sourceItem != null && this.sourceItem is Chest) { this.chestColorPicker = new DiscreteColorPicker(this.xPositionOnScreen, this.yPositionOnScreen - Game1.tileSize - IClickableMenu.borderWidth * 2, 0, null); this.chestColorPicker.colorSelection = this.chestColorPicker.getSelectionFromColor((this.sourceItem as Chest).playerChoiceColor); } }
public ItemGrabMenu(List <Item> inventory, int rows, bool reverseGrab, bool showReceivingMenu, InventoryMenu.highlightThisItem highlightFunction, ItemGrabMenu.behaviorOnItemSelect behaviorOnItemSelectFunction, string message, ItemGrabMenu.behaviorOnItemSelect behaviorOnItemGrab = null, bool snapToBottom = false, bool canBeExitedWithKey = false, bool playRightClickSound = true, bool allowRightClick = true, bool showOrganizeButton = false, int source = 0, Item sourceItem = null) : base(highlightFunction, true, true, 0, 0) { this.source = source; this.message = message; this.reverseGrab = reverseGrab; this.showReceivingMenu = showReceivingMenu; this.playRightClickSound = playRightClickSound; this.allowRightClick = allowRightClick; this.inventory.showGrayedOutSlots = true; this.sourceItem = sourceItem; this.Rows = rows; if (source == 1 && sourceItem != null && sourceItem is Chest) { this.chestColorPicker = new DiscreteColorPicker(this.xPositionOnScreen, this.yPositionOnScreen - Game1.tileSize - IClickableMenu.borderWidth * 2, 0, new Chest(true)); this.chestColorPicker.colorSelection = this.chestColorPicker.getSelectionFromColor((sourceItem as Chest).playerChoiceColor); (this.chestColorPicker.itemToDrawColored as Chest).playerChoiceColor = this.chestColorPicker.getColorFromSelection(this.chestColorPicker.colorSelection); this.colorPickerToggleButton = new ClickableTextureComponent(new Rectangle(this.xPositionOnScreen + this.width, this.yPositionOnScreen + Game1.tileSize + Game1.pixelZoom * 5, 16 * Game1.pixelZoom, 16 * Game1.pixelZoom), Game1.mouseCursors, new Rectangle(119, 469, 16, 16), (float)Game1.pixelZoom, false) { hoverText = Game1.content.LoadString("Strings\\UI:Toggle_ColorPicker", new object[0]) }; } if (snapToBottom) { base.movePosition(0, Game1.viewport.Height - (this.yPositionOnScreen + this.height - IClickableMenu.spaceToClearTopBorder)); this.snappedtoBottom = true; } this.ItemsToGrabMenu = new InventoryMenu(this.xPositionOnScreen + Game1.tileSize / 2, this.yPositionOnScreen, false, inventory, highlightFunction, inventory.Capacity, Rows, 0, 0, true); this.behaviorFunction = behaviorOnItemSelectFunction; this.behaviorOnItemGrab = behaviorOnItemGrab; this.canExitOnKey = canBeExitedWithKey; if (showOrganizeButton) { this.organizeButton = new ClickableTextureComponent("", new Rectangle(this.xPositionOnScreen + this.width, this.yPositionOnScreen + this.height / 3 - Game1.tileSize, Game1.tileSize, Game1.tileSize), "", Game1.content.LoadString("Strings\\UI:ItemGrab_Organize", new object[0]), Game1.mouseCursors, new Rectangle(162, 440, 16, 16), (float)Game1.pixelZoom, false); } if ((Game1.isAnyGamePadButtonBeingPressed() || !Game1.lastCursorMotionWasMouse) && this.ItemsToGrabMenu.actualInventory.Count > 0 && Game1.activeClickableMenu == null) { Game1.setMousePosition(this.inventory.inventory[0].bounds.Center); } }
private void panelColor_Click(object sender, EventArgs e) { if (_discreteColors) { using (DiscreteColorPicker dcp = new DiscreteColorPicker()) { dcp.ValidColors = _validDiscreteColors; dcp.SingleColorOnly = true; dcp.SelectedColors = new List <Color> { Color }; DialogResult result = dcp.ShowDialog(); if (result == DialogResult.OK) { if (dcp.SelectedColors.Count() == 0) { Color = Color.White; } else { RGBColor = dcp.SelectedColors.First(); } } } } else { using (ColorPicker cp = new ColorPicker()) { cp.LockValue_V = true; cp.Color = XYZ.FromRGB(Color); DialogResult result = cp.ShowDialog(); if (result == DialogResult.OK) { RGBColor = cp.Color.ToRGB(); } } } }
private void ShowColorPicker() { //Logging.Debug("Enter color picker"); var value = GetColorGradientValue(); if (value == null) { return; } var selectedIndex = SelectedIndex; if (selectedIndex < 0) { return; } var handle = _points[selectedIndex]; var colorPointIndexes = (List <int>)handle.Tag; ColorGradient holdValue; if (IsDiscrete) { holdValue = new ColorGradient(value); List <Color> selectedColors = new List <Color>(); List <ColorPoint> colorPoints = new List <ColorPoint>(); foreach (int index in colorPointIndexes) { ColorPoint pt = holdValue.Colors[index]; if (pt == null) { continue; } colorPoints.Add(pt); selectedColors.Add(pt.Color.ToRGB().ToArgb()); } using (DiscreteColorPicker picker = new DiscreteColorPicker()) { picker.ValidColors = ValidColors; picker.SelectedColors = selectedColors; if (picker.ShowDialog() == DialogResult.OK) { if (!picker.SelectedColors.Any()) { DeletePoint(); } else { double position = colorPoints.First().Position; foreach (var colorPoint in colorPoints) { holdValue.Colors.Remove(colorPoint); } foreach (Color selectedColor in picker.SelectedColors) { ColorPoint newPoint = new ColorPoint(selectedColor, position); holdValue.Colors.Add(newPoint); } SetColorGradientValue(holdValue); } } } } else { if (colorPointIndexes.Count > 1) { //messageBox Arguments are (Text, Title, No Button Visible, Cancel Button Visible) MessageBoxForm.msgIcon = SystemIcons.Error; //this is used if you want to add a system icon to the message form. var messageBox = new MessageBoxForm("Non-discrete color gradient, >1 selected point. oops! please report it.", "Delete library gradient?", false, false); messageBox.ShowDialog(); } holdValue = new ColorGradient(value); ColorPoint pt = holdValue.Colors[colorPointIndexes.FirstOrDefault()]; if (pt == null) { return; } using (ColorPicker frm = new ColorPicker(_mode, _fader)) { frm.LockValue_V = false; frm.Color = pt.Color; if (frm.ShowDialog() == DialogResult.OK) { pt.Color = frm.Color; _mode = frm.SecondaryMode; _fader = frm.PrimaryFader; SetColorGradientValue(holdValue); } } } //Logging.Debug("Exit normally color picker"); }
// edits the selected color in the 'edit' control private void editSelectedPoints() { if (edit.Gradient == null || edit.FocusSelection) { return; } if (DiscreteColors) { List <Color> selectedColors = new List <Color>(); foreach (ColorGradient.Point point in edit.Selection) { ColorPoint pt = point as ColorPoint; if (pt == null) { continue; } selectedColors.Add(pt.Color.ToRGB().ToArgb()); } using (DiscreteColorPicker picker = new DiscreteColorPicker()) { picker.ValidColors = ValidDiscreteColors; picker.SelectedColors = selectedColors; if (picker.ShowDialog() == DialogResult.OK) { if (picker.SelectedColors.Count() == 0) { DeleteColor(); } else if (picker.SelectedColors.Count() == selectedColors.Count) { int i = 0; foreach (Color selectedColor in picker.SelectedColors) { ColorPoint pt = edit.Selection[i] as ColorPoint; pt.Color = XYZ.FromRGB(selectedColor); } } else { double position = edit.Selection.First().Position; foreach (ColorGradient.Point point in edit.Selection) { edit.Gradient.Colors.Remove(point as ColorPoint); } foreach (Color selectedColor in picker.SelectedColors) { ColorPoint newPoint = new ColorPoint(selectedColor, position); edit.Gradient.Colors.Add(newPoint); } } } } } else { if (edit.Selection.Count > 1) { //messageBox Arguments are (Text, Title, No Button Visible, Cancel Button Visible) MessageBoxForm.msgIcon = SystemIcons.Error; //this is used if you want to add a system icon to the message form. var messageBox = new MessageBoxForm("Non-discrete color gradient, >1 selected point. oops! please report it.", "Delete library gradient?", false, false); messageBox.ShowDialog(); } ColorPoint pt = edit.Selection.FirstOrDefault() as ColorPoint; if (pt == null) { return; } using (ColorPicker frm = new ColorPicker(_mode, _fader)) { frm.LockValue_V = LockColorEditorHSV_Value; frm.Color = _xyz; if (frm.ShowDialog(this.FindForm()) == DialogResult.OK) { pt.Color = _xyz = frm.Color; lblColorSelect.Color = _xyz.ToRGB().ToArgb(); _mode = frm.SecondaryMode; _fader = frm.PrimaryFader; } } } }
public ExpandedFridgeMenu(ExpandedFridgeHub fridgeHub) : base(InventoryMenu.highlightAllItems, true, true, 0, 0) { this.fridgeHub = fridgeHub; { int i = 0; int labelX = this.xPositionOnScreen + Game1.tileSize / 2; int labelY = (int)(this.yPositionOnScreen + Game1.tileSize * 3.3F); foreach (Chest c in fridgeHub.connectedChests) { if (c == fridgeHub.selectedChest) { this.selectedTabIndex = i; this.selectedTab = new ClickableComponent(new Rectangle(labelX + Game1.tileSize * i++, labelY, Game1.tileSize, Game1.tileSize), (i).ToString(), (i).ToString()); this.selectedTabColor = c.playerChoiceColor.Value; } else { this.chestTabs.Add(new ClickableComponent(new Rectangle(labelX + Game1.tileSize * i++, labelY, Game1.tileSize, Game1.tileSize), (i).ToString(), (i).ToString())); this.chestTabsColors.Add(c.playerChoiceColor.Value); } } } this.inventory.showGrayedOutSlots = true; this.sourceItem = fridgeHub.selectedChest; { this.chestColorPicker = new DiscreteColorPicker(this.xPositionOnScreen, this.yPositionOnScreen - 64 - IClickableMenu.borderWidth * 2, 0, (Item) new Chest(true)); this.chestColorPicker.colorSelection = this.chestColorPicker.getSelectionFromColor((Color)((NetFieldBase <Color, NetColor>)fridgeHub.selectedChest.playerChoiceColor)); (this.chestColorPicker.itemToDrawColored as Chest).playerChoiceColor.Value = this.chestColorPicker.getColorFromSelection(this.chestColorPicker.colorSelection); ClickableTextureComponent textureComponent = new ClickableTextureComponent(new Rectangle(this.xPositionOnScreen + this.width, this.yPositionOnScreen + 64 + 20, 64, 64), Game1.mouseCursors, new Rectangle(119, 469, 16, 16), 4f, false); textureComponent.hoverText = Game1.content.LoadString("Strings\\UI:Toggle_ColorPicker"); textureComponent.myID = 27346; textureComponent.downNeighborID = 106;//5948; textureComponent.leftNeighborID = 11; this.colorPickerToggleButton = textureComponent; } this.ItemsToGrabMenu = new InventoryMenu(this.xPositionOnScreen + 32, this.yPositionOnScreen, false, this.fridgeHub.selectedChest.items, InventoryMenu.highlightAllItems, -1, 3, 0, 0, true); if (Game1.options.SnappyMenus) { this.ItemsToGrabMenu.populateClickableComponentList(); for (int index = 0; index < this.ItemsToGrabMenu.inventory.Count; ++index) { if (this.ItemsToGrabMenu.inventory[index] != null) { this.ItemsToGrabMenu.inventory[index].myID += 53910; this.ItemsToGrabMenu.inventory[index].upNeighborID += 53910; this.ItemsToGrabMenu.inventory[index].rightNeighborID += 53910; this.ItemsToGrabMenu.inventory[index].downNeighborID = -7777; this.ItemsToGrabMenu.inventory[index].leftNeighborID += 53910; this.ItemsToGrabMenu.inventory[index].fullyImmutable = true; } } } { ClickableTextureComponent textureComponent = new ClickableTextureComponent("", new Rectangle(this.xPositionOnScreen + this.width, this.yPositionOnScreen + this.height / 3 - 64, 64, 64), "", Game1.content.LoadString("Strings\\UI:ItemGrab_Organize"), Game1.mouseCursors, new Rectangle(162, 440, 16, 16), 4f, false); textureComponent.myID = 106; textureComponent.upNeighborID = 27346; textureComponent.downNeighborID = 5948; this.organizeButton = textureComponent; } if ((Game1.isAnyGamePadButtonBeingPressed() || !Game1.lastCursorMotionWasMouse) && (this.ItemsToGrabMenu.actualInventory.Count > 0 && Game1.activeClickableMenu == null)) { Game1.setMousePosition(this.inventory.inventory[0].bounds.Center); } if (!Game1.options.snappyMenus || !Game1.options.gamepadControls) { return; } this.discreteColorPickerCC = new List <ClickableComponent>(); for (int index = 0; index < this.chestColorPicker.totalColors; ++index) { this.discreteColorPickerCC.Add(new ClickableComponent(new Rectangle(this.chestColorPicker.xPositionOnScreen + IClickableMenu.borderWidth / 2 + index * 9 * 4, this.chestColorPicker.yPositionOnScreen + IClickableMenu.borderWidth / 2, 36, 28), "") { myID = index + 4343, rightNeighborID = index < this.chestColorPicker.totalColors - 1 ? index + 4343 + 1 : -1, leftNeighborID = index > 0 ? index + 4343 - 1 : -1, downNeighborID = this.ItemsToGrabMenu == null || this.ItemsToGrabMenu.inventory.Count <= 0 ? 0 : 53910 }); } for (int index = 0; index < 12; ++index) { if (this.inventory != null && this.inventory.inventory != null && this.inventory.inventory.Count >= 12) { this.inventory.inventory[index].upNeighborID = (this.discreteColorPickerCC == null || this.ItemsToGrabMenu == null || this.ItemsToGrabMenu.inventory.Count > index ? (this.ItemsToGrabMenu.inventory.Count > index ? 53910 + index : 53910) : 4343); } if (this.discreteColorPickerCC != null && this.ItemsToGrabMenu != null && this.ItemsToGrabMenu.inventory.Count > index) { this.ItemsToGrabMenu.inventory[index].upNeighborID = 4343; } } for (int index = 0; index < 36; ++index) { if (this.inventory != null && this.inventory.inventory != null && this.inventory.inventory.Count > index) { this.inventory.inventory[index].upNeighborID = -7777; this.inventory.inventory[index].upNeighborImmutable = true; } } if (this.trashCan != null && this.inventory.inventory.Count >= 12 && this.inventory.inventory[11] != null) { this.inventory.inventory[11].rightNeighborID = 5948; } if (this.trashCan != null) { this.trashCan.leftNeighborID = 11; } if (this.okButton != null) { this.okButton.leftNeighborID = 11; } this.populateClickableComponentList(); this.snapToDefaultClickableComponent(); }
// edits the selected color in the 'edit' control private void editSelectedPoints() { if (edit.Gradient == null || edit.FocusSelection) { return; } if (DiscreteColors) { List <Color> selectedColors = new List <Color>(); foreach (ColorGradient.Point point in edit.Selection) { ColorPoint pt = point as ColorPoint; if (pt == null) { continue; } selectedColors.Add(pt.Color.ToRGB().ToArgb()); } using (DiscreteColorPicker picker = new DiscreteColorPicker()) { picker.ValidColors = ValidDiscreteColors; picker.SelectedColors = selectedColors; if (picker.ShowDialog() == DialogResult.OK) { if (picker.SelectedColors.Count() == 0) { DeleteColor(); } else if (picker.SelectedColors.Count() == selectedColors.Count) { int i = 0; foreach (Color selectedColor in picker.SelectedColors) { ColorPoint pt = edit.Selection[i] as ColorPoint; pt.Color = XYZ.FromRGB(selectedColor); } } else { double position = edit.Selection.First().Position; foreach (ColorGradient.Point point in edit.Selection) { edit.Gradient.Colors.Remove(point as ColorPoint); } foreach (Color selectedColor in picker.SelectedColors) { ColorPoint newPoint = new ColorPoint(selectedColor, position); edit.Gradient.Colors.Add(newPoint); } } } } } else { if (edit.Selection.Count > 1) { MessageBox.Show("Non-discrete color gradient, >1 selected point. oops! please report it."); } ColorPoint pt = edit.Selection.FirstOrDefault() as ColorPoint; if (pt == null) { return; } using (ColorPicker frm = new ColorPicker(_mode, _fader)) { frm.LockValue_V = LockColorEditorHSV_Value; frm.Color = _xyz; if (frm.ShowDialog(this.FindForm()) == DialogResult.OK) { pt.Color = _xyz = frm.Color; lblColorSelect.Color = _xyz.ToRGB().ToArgb(); _mode = frm.SecondaryMode; _fader = frm.PrimaryFader; } } } }