private void InitColorItems(List <int> availableColors) { _itemList = new List <ColorItem>(); for (int i = 0; i < availableColors.Count; i++) { ColorCfg cfg = DatabaseManager.BulletDatabase.GetColorCfgByColorId(availableColors[i]); GameObject item = ResourceManager.GetInstance().GetPrefab("Prefabs/Views/EditViews", "BulletColorItem"); RectTransform itemTf = item.GetComponent <RectTransform>(); itemTf.SetParent(_itemContainerTf, false); // 初始化StyleItem结构 ColorItem colorItem = new ColorItem(); colorItem.colorId = availableColors[i]; colorItem.itemGo = item; colorItem.btn = itemTf.Find("BtnBg").gameObject; colorItem.selectImgGo = itemTf.Find("SelectImg").gameObject; // 设置选中 colorItem.selectImgGo.SetActive(cfg.colorId == _colorId); // 设置子弹图像 Image colorImg = itemTf.Find("ColorImg").GetComponent <Image>(); colorImg.sprite = ResourceManager.GetInstance().GetSprite(cfg.packName, cfg.resName); // 添加事件监听 UIEventListener.Get(colorItem.btn).AddClick(() => { OnColorItemClickHandler(cfg.colorId); }); _itemList.Add(colorItem); } }
public static async Task ReplaceColorAsync(this IColorMatrix sourceColorMatrix, ColorItem oldColorItem, Color newColor, bool convertToBackground = false) { Color oldColor = oldColorItem; for (uint row = 0; row < sourceColorMatrix.Height; row++) { for (uint column = 0; column < sourceColorMatrix.Width; column++) { if (sourceColorMatrix.ColorItems[row, column] == oldColor && sourceColorMatrix.ColorItems[row, column].ItemType == oldColorItem.ItemType) { ColorItem newItem = new ColorItem() { A = newColor.A, R = newColor.R, G = newColor.G, B = newColor.B, ItemType = convertToBackground ? ColorItem.ColorItemType.Background : sourceColorMatrix.ColorItems[row, column].ItemType }; await sourceColorMatrix.SetItem(row, column, newItem); } } } }
public static bool Register(this ColorItem colorItem) { if (colorItem.Color == null) { return(false); } Assembly assembly = typeof(ColorPicker).Assembly; Type colorUtilityType = assembly.GetType("Xceed.Wpf.Toolkit.Core.Utilities.ColorUtilities"); if (colorUtilityType == null) { return(false); } FieldInfo fieldInfo = colorUtilityType.GetField("KnownColors"); if (fieldInfo == null) { return(false); } Dictionary <string, Color> knownColors = fieldInfo.GetValue(null) as Dictionary <string, Color>; if (knownColors == null) { return(false); } if (knownColors.ContainsKey(colorItem.Name)) { return(false); } knownColors.Add(colorItem.Name, (Color)colorItem.Color); return(true); }
private void colorList_SelectionChanged(object sender, SelectionChangedEventArgs e) { if (e.AddedItems.Count == 0) { return; } ColorItem item = e.AddedItems[0] as ColorItem; if (item != null) { SelectedColor = item.Color; } else { if (e.RemovedItems.Count != 0) { colorList.SelectedValue = e.RemovedItems[0]; } else { int nextItemIndex = -1; for (int i = 0; i < colorList.Items.Count; i++) { if (colorList.Items[i] is ColorItem) { nextItemIndex = i; break; } } colorList.SelectedIndex = nextItemIndex; } } }
public ColorPicker(ColorItem BindColor) : base() { Canceled = true; this.InitializeComponent(); SetTemplate(BindColor); }
private void GetColorItemsList(string query = "") { colorItemsList.Clear(); var colorInstance = new Color(); var colorNamesList = colorInstance.GetType().GetProperties(BindingFlags.Public | BindingFlags.Static) .Where(x => x.PropertyType == typeof(Color)) .Select(x => x.Name); if (query != string.Empty) { colorNamesList = colorNamesList.Where(x => x.ToLower().Contains(query.ToLower())); } foreach (var colorName in colorNamesList) { var colorProperty = (Color)colorInstance.GetType().GetProperty(colorName).GetValue(null); var colorItem = new ColorItem() { Color = colorProperty, ColorName = colorName, Code = "R: " + colorProperty.R.ToString() + " G: " + colorProperty.G.ToString() + " B: " + colorProperty.B.ToString() }; colorItemsList.Add(colorItem); } }
private void SetSelectedThumb(Thumb thumb) { ColorItem colorItem = thumb.DataContext as ColorItem; colorCollectionItem.SelectedIndex = colorCollectionItem.Colors.IndexOf(colorItem); gridSelected.Margin = new Thickness(Canvas.GetLeft(thumb) + 19, 0, 0, 27); }
private void OnDropEnd(GameObject go) { ColorItem selectedItem = null; foreach (var elem in m_ColorList) { if (elem.obj == go) { selectedItem = elem; break; } } selectedItem.obj.SetActive(false); Color res = Color.white; for (int i = 0; i < m_ColorList.Count; ++i) { if (!m_ColorList[i].obj.activeSelf) { res = ColorCombine(res, m_ColorList[i].color); } } //combine color m_ColorPanel.color = res; }
public override void OnInit() { base.OnInit(); m_ColorList = new List <ColorItem>(); for (int i = 0; i < 5; ++i) { ColorItem elem = new ColorItem(); elem.obj = FindChild("Sprite_Color" + (i)); UIEventListener.Get(elem.obj).onClick = OnDropEnd; var texture = ComponentTool.FindChildComponent <UITexture>("Sprite_Color", elem.obj); elem.color = texture.color; m_ColorList.Add(elem); } m_FireworkPlanList = new List <FireworkPlanElement>(); for (int i = 0; i < 7; ++i) { var objRoot = FindChild("Type_" + i); FireworkPlanElement elem = new FireworkPlanElement(objRoot); elem.SetStatus(true, ItemManager.Instance.IsExistItem(i)); m_FireworkPlanList.Add(elem); UIEventListener.Get(objRoot).onClick = OnClickFire;; } m_ColorPanel = FindChildComponent <UISprite>("Sprite_ColorPanel"); m_BlockBg = FindChild("BlockBg"); AddChildElementClickEvent(OnClickExit, "Button_Exit"); }
public async Task <IActionResult> PutByNumber(int key, [FromBody] ColorItem uColorItem) { var Message = "Not found ColorItem data."; try { if (uColorItem != null) { // add hour to DateTime to set Asia/Bangkok uColorItem = helpers.AddHourMethod(uColorItem); uColorItem.ModifyDate = DateTime.Now; uColorItem.Modifyer = uColorItem.Modifyer ?? "Someone"; var UpdateData = await this.repository.UpdateAsync(uColorItem, key); if (UpdateData != null) { return(new JsonResult(UpdateData, this.DefaultJsonSettings)); } } } catch (Exception ex) { Message = $"Has error {ex.ToString()}"; } return(NotFound(new { Error = Message })); }
private static int alphaSort(ColorItem x, ColorItem y) { if (x == null) { if (y == null) { return(0); } else { return(-1); } } else { if (y == null) { return(1); } else { return(x.Name.CompareTo(y.Name)); } } }
private void Copy(object sender, RoutedEventArgs e) { Button button = (Button)sender; ColorItem colorItem = ViewModel.SelectedItem; string textToCopy = ""; switch (button.Name) { case "buttonCopyHex": textToCopy = ColorConverters.ColorToHex(colorItem.Color); break; case "buttonCopyRGB": textToCopy = ColorConverters.ColorToRGB(colorItem.Color); break; case "buttonCopyHSL": textToCopy = ColorConverters.ColorToHSL(colorItem.Color); break; } DataPackage dataPackage = new DataPackage(); dataPackage.SetText(textToCopy); dataPackage.RequestedOperation = DataPackageOperation.Copy; Clipboard.SetContent(dataPackage); }
private void PopulateCollectionColors(ColorCollection Collection) { listViewColors.BeginUpdate(); listViewColors.Items.Clear(); listViewColors.LargeImageList = new ImageList(); listViewColors.LargeImageList.ColorDepth = ColorDepth.Depth32Bit; listViewColors.LargeImageList.ImageSize = new Size(48, 48); foreach (Color ColorItem in Collection.Color) { Bitmap result = new Bitmap(48, 48); Graphics gfx = Graphics.FromImage(result); using (SolidBrush brush = new SolidBrush(ColorItem)) { gfx.FillRectangle(brush, 0, 0, 48, 48); gfx.DrawRectangle(new Pen(Color.Black, 2), 0, 0, 48, 48); } listViewColors.LargeImageList.Images.Add(ColorItem.ToString(), result); ListViewItem item = new ListViewItem(); //item.Text = ColorItem.Name; item.ToolTipText = string.Format("R: {0} G: {1} B: {2}", ColorItem.R, ColorItem.G, ColorItem.B); item.ImageKey = ColorItem.ToString(); item.Tag = ColorItem; listViewColors.Items.Add(item); } listViewColors.EndUpdate(); btnAddColor.Enabled = true; }
private void UpgradeVersion() { if (!IsolatedStorageSettings.ApplicationSettings.Contains("MigratedScheduler") && ScheduledActionService.Find("PeriodicAgent") as PeriodicTask != null) { //1.0.x대의 스케쥴러 삭제 RemoveAgent("PeriodicAgent"); IsolatedStorageSettings.ApplicationSettings["MigratedScheduler"] = true; //새로운 스케쥴러 등록 StartPeriodicAgent(); } //2.4 버전 색상값 변경 관련 if (SettingHelper.ContainsKey(Constants.LOCKSCREEN_BACKGROUND_COLOR)) { ColorItem colorItem = SettingHelper.Get(Constants.LOCKSCREEN_BACKGROUND_COLOR) as ColorItem; if (colorItem.Color == Colors.Transparent) { SettingHelper.Set(Constants.LOCKSCREEN_BACKGROUND_COLOR, new ColorItem() { Text = AppResources.ColorChrome, Color = ColorItem.ConvertColor(0xFF1F1F1F) }, false); SettingHelper.Set(Constants.LOCKSCREEN_BACKGROUND_OPACITY, 0, false); SettingHelper.Save(); } } }
public async Task <IActionResult> Post([FromBody] ColorItem nColorItem) { if (nColorItem != null) { var template = await this.repository.GetAllAsQueryable() .Where(x => x.ColorName.ToLower().Trim().Equals(nColorItem.ColorName.ToLower().Trim())) .FirstOrDefaultAsync(); if (template == null) { nColorItem.CreateDate = DateTime.Now; nColorItem.Creator = nColorItem.Creator ?? "Someone"; var Runing = await this.repository.GetAllAsQueryable().CountAsync(x => x.CreateDate.Value.Year == nColorItem.CreateDate.Value.Year) + 1; nColorItem.ColorCode = $"{nColorItem.CreateDate.Value.ToString("yy")}/{Runing.ToString("0000")}"; return(new JsonResult(await this.repository.AddAsync(nColorItem), this.DefaultJsonSettings)); } else { return(new JsonResult(template, this.DefaultJsonSettings)); } } return(NotFound(new { Error = "Not found ColorItem data !!!" })); }
protected void Upload(ColorItem item) { try { if (FileUploadControl.HasFile) { string directory = Server.MapPath("~/images/palette/"); if (!Directory.Exists(directory)) { Directory.CreateDirectory(directory); } string newFileName = String.Format("{0}{1}{2}", directory, item.ColorID, Path.GetExtension(FileUploadControl.FileName)); if (File.Exists(newFileName)) { File.Delete(newFileName); } FileUploadControl.SaveAs(newFileName); } } catch (Exception ex) { ProcessException(ex); } }
protected void AddButton_Click(object sender, EventArgs e) { if (Page.IsValid && IsValidUpload()) { try { SpecificationAttributeOption sao = null; if (IsColor) { int colorArgb = -1; if (!String.IsNullOrEmpty(txtColorArgb.Text)) { colorArgb = Int32.Parse(txtColorArgb.Text, System.Globalization.NumberStyles.AllowHexSpecifier); } ColorManager.InsertColor(txtNewOptionName.Text, colorArgb); ColorItem colorItem = ColorManager.GetColorByColorName(txtNewOptionName.Text); Upload(colorItem); } sao = SpecificationAttributeManager.InsertSpecificationAttributeOption(SpecificationAttributeID, txtNewOptionName.Text, txtNewOptionDisplayOrder.Value); Response.Redirect("SpecificationAttributeDetails.aspx?SpecificationAttributeID=" + sao.SpecificationAttributeID.ToString()); } catch (Exception exc) { ProcessException(exc); } } }
public ColorPicker( ColorItem BindColor ) : base() { Canceled = true; this.InitializeComponent(); SetTemplate( BindColor ); }
private void OnColorComboSelectedIndexChanged(object sender, EventArgs e) { if (this.comboColor.SelectedItem == null) { return; } ColorItem selColorItem = this.comboColor.SelectedItem as ColorItem; if (selColorItem.text == null) { ColorDialog colorDlg = new ColorDialog(); colorDlg.AllowFullOpen = true; colorDlg.SolidColorOnly = true; DialogResult dlgRet = colorDlg.ShowDialog(); if (dlgRet == DialogResult.OK) { lcColor color = lcColor.FromColor(colorDlg.Color); _lastColor = color; this.SetColorComboValue(color); } else { this.SetColorComboValue(_lastColor); } } else { _lastColor = selColorItem.color; } }
public void SetUp() { colorItem = new ColorItem() { Color = Color.Gold, Name = "Gold" }; }
public override void OnInit() { base.OnInit(); m_ColorList = new List<ColorItem>(); for (int i = 0; i < 5; ++i) { ColorItem elem = new ColorItem(); elem.obj = FindChild("Sprite_Color"+(i)); UIEventListener.Get(elem.obj).onClick = OnDropEnd; var texture = ComponentTool.FindChildComponent<UITexture>("Sprite_Color", elem.obj); elem.color = texture.color; m_ColorList.Add(elem); } m_FireworkPlanList = new List<FireworkPlanElement>(); for (int i = 0; i < 7; ++i) { var objRoot = FindChild("Type_" + i); FireworkPlanElement elem = new FireworkPlanElement(objRoot); elem.SetStatus(true, i<3); m_FireworkPlanList.Add(elem); UIEventListener.Get(objRoot).onClick = OnClickFire; ; } m_ColorPanel = FindChildComponent<UISprite>("Sprite_ColorPanel"); m_BlockBg = FindChild("BlockBg"); AddChildElementClickEvent(OnClickExit,"Button_Exit"); }
private void SetColorComboValue(lcColor color) { int index = -1; for (int i = 0; i < this.comboColor.Items.Count; ++i) { ColorItem colorItem = this.comboColor.Items[i] as ColorItem; if (colorItem.text != null) { if (colorItem.color == color) { index = i; break; } } } if (index == -1) { ColorItem colorItem = new ColorItem(); colorItem.color = color; this.comboColor.Items.Insert(_indexToInsertCustomColor, colorItem); index = _indexToInsertCustomColor; } this.comboColor.SelectedIndex = index; }
private void InitializeSetting() { items = new List <ColorItem>(); items.Add(new ColorItem() { Text = AppResources.ColorChrome, Color = ColorItem.ConvertColor(0xFF1F1F1F), Desc = AppResources.ColorChrome }); items.Add(new ColorItem() { Text = AppResources.ColorLightGray, Color = ColorItem.ConvertColor(0xFFD3D3D3) /*, Desc = AppResources.ColorLightGray*/ }); items.Add(new ColorItem() { Text = AppResources.AccentColor, Color = (Color)App.Current.Resources["PhoneAccentColor"] /*, Desc = AppResources.AccentColor*/ }); for (int i = 0; i < ColorItem.UintColors.Length; i++) { if (!((Color)App.Current.Resources["PhoneAccentColor"]).Equals(ColorItem.ConvertColor(ColorItem.UintColors[i]))) { items.Add(new ColorItem() { Color = ColorItem.ConvertColor(ColorItem.UintColors[i]) }); } } ; }
private void UpdateColor(ColorItem C) { IList <ColorItem> Presets = (IList <ColorItem>)PresetColors.ItemsSource; try { ColorItem PreSelected = PresetColors.SelectedItem as ColorItem; ColorItem Selected = Presets.First( (C1) => { return(C1.R == C.R && C1.G == C.G && C1.B == C.B ); } ); if (PreSelected != Selected) { PresetAutoUpdate = true; PresetColors.SelectedItem = Selected; } } catch (Exception) { PresetColors.SelectedItem = null; } SectionData = new ColorPickerSection(new ColorItem(C.ColorTag, C.TColor)); MainView.DataContext = SectionData; }
private void UpdateColor( ColorItem C ) { IList<ColorItem> Presets = ( IList<ColorItem> ) PresetColors.ItemsSource; try { ColorItem PreSelected = PresetColors.SelectedItem as ColorItem; ColorItem Selected = Presets.First( ( C1 ) => { return C1.R == C.R && C1.G == C.G && C1.B == C.B ; } ); if ( PreSelected != Selected ) { PresetAutoUpdate = true; PresetColors.SelectedItem = Selected; } } catch ( Exception ) { PresetColors.SelectedItem = null; } SectionData = new ColorPickerSection( new ColorItem( C.ColorTag, C.TColor ) ); MainView.DataContext = SectionData; }
private void OnSelectionChangedColortPicker(object sender, SelectionChangedEventArgs e) { if (e.AddedItems.Count > 0 && e.RemovedItems.Count > 0) { string key = Constants.LOCKSCREEN_BACKGROUND_COLOR; switch ((sender as ListPicker).Name) { case "LivetileCalendarColorPicker": key = Constants.LIVETILE_CALENDAR_BACKGROUND_COLOR; break; case "LivetileWeatherColorPicker": key = Constants.LIVETILE_WEATHER_BACKGROUND_COLOR; break; case "LivetileBatteryColorPicker": key = Constants.LIVETILE_BATTERY_BACKGROUND_COLOR; break; case "SkinColorPicker": key = Constants.CHAMELEON_SKIN_BACKGROUND_COLOR; break; } ColorItem colorItem = e.AddedItems[0] as ColorItem; SettingHelper.Set(key, colorItem, false); } }
private static void AddRow(IXLWorksheet worksheet, ColorItem colorItem, int row) { worksheet.Cell(row, 1).Value = GetIdentifier(colorItem); worksheet.Cell(row, 2).Style.Fill.PatternType = XLFillPatternValues.Solid; worksheet.Cell(row, 2).Style.Fill.BackgroundColor = ToXLColor(colorItem.Colors["light"]); worksheet.Cell(row, 3).Style.Fill.PatternType = XLFillPatternValues.Solid; worksheet.Cell(row, 3).Style.Fill.BackgroundColor = ToXLColor(colorItem.Colors["dark"]); worksheet.Cell(row, 4).Style.Fill.PatternType = XLFillPatternValues.Solid; worksheet.Cell(row, 4).Style.Fill.BackgroundColor = ToXLColor(colorItem.Colors["blue"]); worksheet.Cell(row, 5).Value = ToHexARGB(colorItem.Colors["light"]); worksheet.Cell(row, 6).Value = ToHexARGB(colorItem.Colors["dark"]); worksheet.Cell(row, 7).Value = ToHexARGB(colorItem.Colors["blue"]); worksheet.Cell(row, 8).Value = ToRGB(colorItem.Colors["light"]); worksheet.Cell(row, 9).Value = ToRGB(colorItem.Colors["dark"]); worksheet.Cell(row, 10).Value = ToRGB(colorItem.Colors["blue"]); worksheet.Cell(row, 11).Value = ToCategoryName(colorItem.Category); worksheet.Cell(row, 12).Value = colorItem.KeyType.ToString(); }
private async void NumericInput(object sender, RoutedEventArgs e) { TextBox InputBox = sender as TextBox; string Input = InputBox.Text.Trim(); string[] Param = InputBox.Tag.ToString().Split(','); string PropName = Param[0]; int Max = int.Parse(Param[1]); bool Pass = true; // Empty String if (Pass && string.IsNullOrEmpty(Input)) { Pass = false; } // Not a number if (Pass && !global::GR.GSystem.Utils.Numberstring(Input)) { Pass = false; await InvalidFormat(); } int Value = 0; int.TryParse(Input, out Value); // Out of range if (Pass && (Value < 0 || Max < Value)) { Pass = false; await OutOfRange(Value, 0, Max); } Type p = typeof(ColorItem); PropertyInfo PInfo = p.GetProperty(PropName); int OValue = ( int )PInfo.GetValue(SectionData.CColor); if (!Pass) { InputBox.Text = OValue.ToString(); InputBox.Focus(FocusState.Keyboard); return; } // Unchanged if (Value == OValue) { return; } // All tests passed ColorItem C = SectionData.CColor; PInfo.SetValue(C, Value); UpdateColor(C); }
public System_Color UpdateBase(System_Color systemColor, ColorItem ColorItem) { systemColor.Name = ColorItem.Name; systemColor.Value = ColorItem.Value; systemColor.Description = ColorItem.Description; systemColor.IsShow = ColorItem.IsShow; return(systemColor); }
public void UpdateViewModel() { box.Columns .Connect() .AutoRefresh() .Filter(x => x.BoardId == board.Id) .Sort(SortExpressionComparer <ColumnViewModel> .Ascending(x => x.Order)) .Bind(out ReadOnlyObservableCollection <ColumnViewModel> temp) .Subscribe(); AvailableColumns = temp; box.Rows .Connect() .AutoRefresh() .Filter(x => x.BoardId == board.Id) .Sort(SortExpressionComparer <RowViewModel> .Ascending(x => x.Order)) .Bind(out ReadOnlyObservableCollection <RowViewModel> temp2) .Subscribe(); AvailableRows = temp2; SelectedColumn = AvailableColumns.First(); SelectedRow = AvailableRows.First(); if (Card == null) { Head = null; Body = null; SelectedColor = ColorItems.First(); if (requestedColumnId != 0) { SelectedColumn = AvailableColumns.First(c => c.Id == requestedColumnId); } if (requestedRowId != 0) { SelectedRow = AvailableRows.First(c => c.Id == requestedRowId); } Result = CardEditResult.Created; } else { Head = Card.Header; Body = Card.Body; SelectedColumn = AvailableColumns.First(c => c.Id == Card.ColumnDeterminant); SelectedRow = AvailableRows.First(r => r.Id == Card.RowDeterminant); SelectedColor = ColorItems. FirstOrDefault(c => c.SystemName == Card.Color) ?? ColorItems.First(); Result = CardEditResult.Modified; } }
private static void SetColor(ColorItem item, Dictionary <string, Color> colors) { Color value; if (colors.TryGetValue(item.name, out value)) { item.color = value; } }
private static string GetIdentifier(ColorItem colorItem) { if (colorItem.Key == null) { return(colorItem.Name); } return(colorItem.Key.ToString()); }
private void Update() { if (lastItem != selectItem) { Debug.Log("ChangeColor " + selectItem.color.ToString()); GameUI.instance.paintInfo.color = selectItem.color; lastItem = selectItem; } }
private void SetTemplate( ColorItem BindColor ) { StringResources stx = new StringResources( "Message" ); PrimaryButtonText = stx.Str( "OK" ); SecondaryButtonText = stx.Str( "Cancel" ); // PresetColors PresetColors.ItemsSource = global::wenku8.System.ThemeManager.PresetColors(); UpdateColor( BindColor ); }
public override object BindModel(ControllerContext controllerContext, ModelBindingContext bindingContext) { ((ColorSwatchPickerPreValueModel)bindingContext.Model).Colors = new List<ColorItem>(); if (!string.IsNullOrEmpty(controllerContext.HttpContext.Request["colors.Index"])) { foreach (string index in controllerContext.HttpContext.Request["colors.Index"].Split(',')) { string val = controllerContext.HttpContext.Request[string.Format("colors[{0}].HexValue", index)]; if (!string.IsNullOrEmpty(val)) { ColorItem col = new ColorItem(); col.HexValue = val; ((ColorSwatchPickerPreValueModel)bindingContext.Model).Colors.Add(col); } } } return base.BindModel(controllerContext, bindingContext); }
/// <summary> /// Get the color information for a specific item /// </summary> /// <param name="itemIndex">The index of an item in the category /// used to create the ColorRetriever</param> /// <returns>ColorItem structure</returns> public ColorItem GetColorItem(int itemIndex) { ColorItem retVal = new ColorItem(); EnsureStorage(); ColorableItemInfo item = new ColorableItemInfo(); myGetItemParam[0] = item; ErrorHandler.ThrowOnFailure(myStorage.GetItem(myIndexConverter(itemIndex), myGetItemParam)); item = myGetItemParam[0]; retVal.FontStyle = (item.bFontFlagsValid != 0) ? GetFontStyleFromFontFlags((FONTFLAGS)item.dwFontFlags) : FontStyle.Regular; retVal.ForeColor = (item.bForegroundValid != 0) ? TranslateColorValue(item.crForeground) : Color.Empty; retVal.BackColor = (item.bBackgroundValid != 0) ? TranslateColorValue(item.crBackground) : Color.Empty; return retVal; }
public ColorItemViewHolder(ColorItem colorItem) : base(colorItem) { this.ColorItem = colorItem; }
/// <summary> /// Draw a color entry. /// </summary> protected override void OnDrawItem(DrawItemEventArgs e) { int idx = e.Index; // Nothing selected? if (idx < 0) return; object obj = Items[idx]; if (obj is ColorItem) { ColorItem item = (ColorItem)obj; // Is custom color? if (idx == 0) { string name; if (_color.IsEmpty) name = "custom"; else name = _crm.ToColorName(_color); item = new ColorItem(_color, name); } XColor clr = item.Color; Graphics gfx = e.Graphics; Rectangle rect = e.Bounds; Brush textbrush = SystemBrushes.ControlText; if ((e.State & DrawItemState.Selected) == 0) { gfx.FillRectangle(SystemBrushes.Window, rect); textbrush = SystemBrushes.ControlText; } else { gfx.FillRectangle(SystemBrushes.Highlight, rect); textbrush = SystemBrushes.HighlightText; } // Draw color box if (!clr.IsEmpty) { Rectangle box = new Rectangle(rect.X + 3, rect.Y + 1, rect.Height * 2, rect.Height - 3); gfx.FillRectangle(new SolidBrush(clr.ToGdiColor()), box); gfx.DrawRectangle(Pens.Black, box); } StringFormat format = new StringFormat(StringFormat.GenericDefault); format.Alignment = StringAlignment.Near; format.LineAlignment = StringAlignment.Center; rect.X += rect.Height * 2 + 3 + 3; gfx.DrawString(item.Name, Font, textbrush, rect, format); } }