Пример #1
0
        //チャンネルラベルのコンテキストメニュー表示
        public void CheckContextMenuOfLabel()
        {
            Text_rowIndex.ContextMenu.Items.Clear();
            Text_rowIndex.ContextMenu.Items.Add(new MenuItem()
            {
                Header = String.Format("{0} {1} - {2}", ADCombo.Text, IOCombo.Text, channelName), IsEnabled = false
            });
            Text_rowIndex.ContextMenu.Items.Add(new MenuItem()
            {
                Header = String.Format("Voltage {0}V-{1}V", minVoltage, maxVoltage), IsEnabled = false
            });
            int myRow = rowIndex;

            MenuItem item;

            item = new MenuItem()
            {
                Header = "Edit Channel"
            };
            item.Click += (object sender, RoutedEventArgs arg) => editChannel();
            Text_rowIndex.ContextMenu.Items.Add(item);
            item = new MenuItem()
            {
                Header = "Move Up"
            };
            item.Click += (object sender, RoutedEventArgs arg) => parent.moveUp(myRow);
            if (myRow == 0)
            {
                item.IsEnabled = false;
            }
            Text_rowIndex.ContextMenu.Items.Add(item);
            item = new MenuItem()
            {
                Header = "Move Down"
            };
            item.Click += (object sender, RoutedEventArgs arg) => parent.moveDown(myRow);
            if (myRow + 1 == parent.getChannelCount())
            {
                item.IsEnabled = false;
            }
            Text_rowIndex.ContextMenu.Items.Add(item);
            item = new MenuItem()
            {
                Header = "Remove This Channel"
            };
            item.Click += (object sender, RoutedEventArgs arg) => parent.removeChannel(myRow);
            Text_rowIndex.ContextMenu.Items.Add(item);
        }