public static Image GetImageFromTool(ToolListItem item) { if (Cache.TryGetValue(item.Icon, out Image value)) { return(value); } else { Image image = new Image(GetImageUri(item.Icon)); Cache.Add(item.Icon, image); return(image); } }
private void ToolListButton_Click(object sender, RoutedEventArgs e) { ToolListItem item = sender as ToolListItem; if (json != null && json.list != null) { Cell c = json.list[item.INDEX - 1]; TBoxName.Text = c.name; priviousName = c.name; TBoxAVO.Text = c.avo.ToString(); TBoxDEF.Text = c.def.ToString(); TBoxALT.Text = c.alt.ToString(); TBoxOTHER.Text = c.other; } }
private void ButtonSelecte(ToolButton btn) { if (CellListBox.SelectedIndex == -1) { return; } int index = CellListBox.SelectedIndex; // 处理一下颜色问题 ToolListItem item = CellListBox.SelectedItem as ToolListItem; Binding binding = new Binding(); binding.Source = item.indexer; binding.Path = new System.Windows.PropertyPath(BorderBrushProperty); btn.SetBinding(BackgroundProperty, binding); // 数据层 btn.C = json.list[index]; isChangedMap = 1; }
private void ReloadCellList() { IList <Cell> list = json.list; if (list != null) { if (CellListBox.Items.Count != 0) { CellListBox.Items.Clear(); } int index = 1; foreach (Cell item in list) { var listItem = new ToolListItem(item, index); item.idx = index; listItem.Selected += ToolListButton_Click; CellListBox.Items.Add(listItem); index++; } } listName.Content = json.name; }