/// <summary> /// ツリー選択 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> public void UserItem_Selected(object sender, System.Windows.RoutedEventArgs e) { // todo 編集後にこの関数を呼ばせる TreeViewItem item = (TreeViewItem)sender; DbItem iteminfo = (DbItem)item.Tag; if (iteminfo.ecsm) { List <UserData> ulist = iteminfo.getUserlist(); dbwindow.UserEvent.Items.Clear(); foreach (UserData d in ulist) { dbwindow.UserEvent.Items.Add(d); // コンテキストメニューは生成しない } dbwindow.UserEvent.Tag = new UserEventTag() { ecsm = true }; return; } UserData udata = iteminfo.getUserdata(); dbwindow.UserEvent.Items.Clear(); dbwindow.UserEvent.Items.Add(udata); dbwindow.UserEvent.Tag = new UserEventTag() { ecsm = false, udata = udata }; if (udata.userevent == null) { return; } int i = 0; udata.userevent.ForEach(ev => { dbwindow.UserEvent.Items.Add(createEventData(ev, iteminfo.fileName, i)); i++; }); ContextMenu context = new ContextMenu(); MenuItem newItem = new MenuItem { Header = "表示" }; newItem.Click += dbwindow.disp_Click; context.Items.Add(newItem); MenuItem addEventItem = new MenuItem { Header = "イベント追加" }; addEventItem.Click += dbwindow.addEvent_Click; context.Items.Add(addEventItem); MenuItem editEventItem = new MenuItem { Header = "イベント編集" }; editEventItem.Click += dbwindow.editEvent_Click; context.Items.Add(editEventItem); MenuItem deleteEventItem = new MenuItem { Header = "イベント削除" }; deleteEventItem.Click += dbwindow.deleteEvent_Click; context.Items.Add(deleteEventItem); MenuItem returnEventItem = new MenuItem { Header = "回帰計算" }; returnEventItem.Click += dbwindow.returnEvent_Click; context.Items.Add(returnEventItem); dbwindow.UserEvent.ContextMenu = context; dbwindow.UserEvent.MouseDoubleClick += dbwindow.userEvent_DoubleClick; dbwindow.UserEvent.SelectedIndex = 0; UserData data = (UserData)dbwindow.UserEvent.Items[0]; Memo = data.memo; }