private void treeView_AfterLabelEdit(object sender, NodeLabelEditEventArgs e) { this.Cursor = Cursors.WaitCursor; try { this.treeView.AfterLabelEdit -= treeView_AfterLabelEdit; if (e.Node.Level != 0) { MessageDialog.ShowWarning("Cannot change serial on tree view."); e.CancelEdit = true; return; } var category = e.Node.Tag as SocketBoxSpecificCategory; if (category == null) { category = new SocketBoxSpecificCategory(); category.Id = 0; } if (string.IsNullOrEmpty(e.Label)) { e.Node.Text = category.Name; return; } category.Name = e.Label; using (var service = new SocketPlanService()) { category.Id = service.RegisterSocketBoxSpecificCategory(category); } this.UpdateCategoryCombo(); UnitWiring.Masters.UpdateSocketBoxSpecificCategories(); MessageDialog.ShowInformation(this, "Updated category successfully."); } catch (Exception exp) { MessageDialog.ShowError(exp); } finally { this.treeView.AfterLabelEdit += treeView_AfterLabelEdit; this.Cursor = Cursors.Default; } }
private void categoryListView_SelectedIndexChanged(object sender, EventArgs e) { try { var items = this.categoryListView.SelectedItems; if (items.Count == 0) { return; } this.specificListView.Items.Clear(); //複数選択できないようプロパティを設定しているので、複数選択のケアはしない SocketBoxSpecificCategory category = items[0].Tag as SocketBoxSpecificCategory; foreach (var specific in category.Specifics) { var imagePath = specific.ImagePath; if (!File.Exists(imagePath)) { imagePath = Path.Combine(Properties.Settings.Default.ImageDirectory, "NotFound.png"); } ListViewItem item = new ListViewItem(); item.Text = specific.Serial; item.Tag = specific; item.ImageKey = imagePath; this.specificListView.Items.Add(item); if (!this.imageList.Images.ContainsKey(imagePath)) { this.imageList.Images.Add(imagePath, Image.FromFile(imagePath)); } } if (this.specificListView.Items.Count != 0) { this.UpdateRelatedList(this.specificListView.Items[0].Tag as SocketBoxSpecific); } } catch (Exception ex) { MessageDialog.ShowError(ex); } }