public ColorPalette(ColorUI colorUI, Color[] customColors) { if (!isScalingInitialized) { if (DpiHelper.IsScalingRequired) { cellSizeX = DpiHelper.LogicalToDeviceUnitsX(CELL_SIZE); cellSizeY = DpiHelper.LogicalToDeviceUnitsY(CELL_SIZE); marginX = DpiHelper.LogicalToDeviceUnitsX(MARGIN); marginY = DpiHelper.LogicalToDeviceUnitsY(MARGIN); } isScalingInitialized = true; } this.colorUI = colorUI; SetStyle(ControlStyles.Opaque, true); BackColor = SystemColors.Control; Size = new Size(CELLS_ACROSS * (cellSizeX + marginX) + marginX + 2, CELLS_DOWN * (cellSizeY + marginY) + marginY + 2); staticColors = new Color[CELLS - CELLS_CUSTOM]; for (int i = 0; i < staticCells.Length; i++) { staticColors[i] = ColorTranslator.FromOle(staticCells[i]); } CustomColors = customColors; }
/// <summary> /// Edits the given object value using the editor style provided by ColorEditor.GetEditStyle. /// </summary> public override object EditValue(ITypeDescriptorContext context, IServiceProvider provider, object value) { if (provider == null) { return(value); } if (!(provider.GetService(typeof(IWindowsFormsEditorService)) is IWindowsFormsEditorService edSvc)) { return(value); } if (_colorUI == null) { _colorUI = new ColorUI(this); } _colorUI.Start(edSvc, value); edSvc.DropDownControl(_colorUI); if (_colorUI.Value is Color colorValue && colorValue != Color.Empty) { value = colorValue; } _colorUI.End(); return(value); }
public override object EditValue(ITypeDescriptorContext context, IServiceProvider provider, object value) { object returnValue = value; if (provider != null) { IWindowsFormsEditorService edSvc = (IWindowsFormsEditorService)provider.GetService(typeof(IWindowsFormsEditorService)); if (edSvc != null) { if (colorUI == null) { colorUI = new ColorUI(this); } colorUI.Start(edSvc, value); edSvc.DropDownControl(colorUI); if (colorUI.Value != null && ((Color)colorUI.Value) != Color.Empty) { value = colorUI.Value; } colorUI.End(); } } return(value); }
public ColorPalette(ColorUI colorUI, Color[] customColors) { if (!s_isScalingInitialized) { if (DpiHelper.IsScalingRequired) { s_cellSizeX = DpiHelper.LogicalToDeviceUnitsX(CellSize); s_cellSizeY = DpiHelper.LogicalToDeviceUnitsY(CellSize); s_marginX = DpiHelper.LogicalToDeviceUnitsX(MarginWidth); s_marginY = DpiHelper.LogicalToDeviceUnitsY(MarginWidth); } s_isScalingInitialized = true; } _colorUI = colorUI; SetStyle(ControlStyles.Opaque, true); BackColor = SystemColors.Control; Size = new Size( CellsAcross * (s_cellSizeX + s_marginX) + s_marginX + 2, CellsDown * (s_cellSizeY + s_marginY) + s_marginY + 2); _staticColors = new Color[TotalCells - CellsCustom]; for (int i = 0; i < s_staticCells.Length; i++) { _staticColors[i] = ColorTranslator.FromOle(s_staticCells[i]); } CustomColors = customColors; }
void Awake() { entityList = new List <AKillable>(); if (colorUI == null) { colorUI = GameObject.FindObjectOfType <ColorUI>(); } }
public override object EditValue(ITypeDescriptorContext context, IServiceProvider provider, object value) { if (provider != null) { IWindowsFormsEditorService edSvc = (IWindowsFormsEditorService) provider.GetService(typeof(IWindowsFormsEditorService)); if (edSvc == null) { return value; } if (this.colorUI == null) { this.colorUI = new ColorUI(this); } this.colorUI.Start(edSvc, value); edSvc.DropDownControl(this.colorUI); if ((this.colorUI.Value != null) && (((Color) this.colorUI.Value) != Color.Empty)) { value = this.colorUI.Value; } this.colorUI.End(); } return value; }
private void SetupClientUIs() { if (Main.netMode == 2) { return; } //Activation of the UIs colorUI = new ColorUI(); hammerUI = new HammerUI(); blockUI = new BlockUI(); mossUI = new MossUI(); colorUI.Activate(); hammerUI.Activate(); blockUI.Activate(); mossUI.Activate(); colorUserInterface = new UserInterface(); hammerUserInterface = new UserInterface(); blockUserInterface = new UserInterface(); mossUserInterface = new UserInterface(); blockUserInterface.SetState(blockUI); colorUserInterface.SetState(colorUI); hammerUserInterface.SetState(hammerUI); mossUserInterface.SetState(mossUI); }