Beispiel #1
0
        //キャンバスのコンテキストメニュー表示
        public void CheckContextMenuOfCanvas()
        {
            int      maxColumn = Grid.GetColumnSpan(canvas);
            bool     isLast    = (maxColumn - 1 == clickedColumn);
            int      myRow     = rowIndex;
            MenuItem item;

            clickedColumn = (int)(Mouse.GetPosition(canvas).X / Division.width);

            canvas.ContextMenu.Items.Clear();
            item = new MenuItem()
            {
                Header = virtualName + " - " + parent.getDivisionName(clickedColumn), IsEnabled = false
            };
            canvas.ContextMenu.Items.Add(item);

            /*
             * canvas.ContextMenu.Items.Add(new Separator());
             * item = new MenuItem() { Header="Edit Value"};
             * item.Click += ((object s, RoutedEventArgs arg) => this.editNode(clickedColumn));
             * canvas.ContextMenu.Items.Add(item);
             */
            item = new MenuItem()
            {
                Header = "Save WaveForm"
            };
            item.Click += ((object s, RoutedEventArgs arg) => this.saveWaveForm());
            canvas.ContextMenu.Items.Add(item);

            canvas.ContextMenu.Items.Add(new Separator());

            MenuItem itemHead;

            itemHead = new MenuItem()
            {
                Header = "Edit Sequence"
            };
            {
                item = new MenuItem()
                {
                    Header = "Insert Division to ←"
                };
                item.Click += ((object s, RoutedEventArgs arg) => parent.insertDivision(clickedColumn));
                itemHead.Items.Add(item);
                item = new MenuItem()
                {
                    Header = "Inert Channel to ↓"
                };
                item.Click += ((object s, RoutedEventArgs arg) => parent.insertChannel(myRow));
                itemHead.Items.Add(item);
                item = new MenuItem()
                {
                    Header = "Remove This Division", IsEnabled = !isLast
                };
                item.Click += ((object s, RoutedEventArgs arg) => parent.removeDivision(clickedColumn));
                itemHead.Items.Add(item);
                item = new MenuItem()
                {
                    Header = "Remove This Channel"
                };
                item.Click += ((object s, RoutedEventArgs arg) => parent.removeChannel(myRow));
                itemHead.Items.Add(item);
            }
            canvas.ContextMenu.Items.Add(itemHead);
        }