コード例 #1
0
        protected virtual void InitListView(PropertyInfo beginGroup = null)
        {
            DirectivesViewer = new CommonGridViewControl()
            {
                ViewedType = ViewedType,
                TabIndex   = 2,
                Location   = new Point(panel1.Left, panel1.Top),
                Dock       = DockStyle.Fill
            };

            DirectivesViewer.MenuOpeningAction = () =>
            {
                if (DirectivesViewer.SelectedItems.Count <= 0)
                {
                    return;
                }
                if (_showWorkPackageOperationContextMenu)
                {
                    if (DirectivesViewer.SelectedItems.Count == 1)
                    {
                        _toolStripMenuItemComposeWorkPackage.Enabled = true;
                    }
                }

                if (_showOpenOperationContextMenu && DirectivesViewer.SelectedItem is NonRoutineJob)
                {
                    var nrj = DirectivesViewer.SelectedItem as NonRoutineJob;
                    if (nrj.AttachedFile == null)
                    {
                        _toolStripMenuItemShowTaskCard.Enabled = false;
                    }
                    else
                    {
                        _toolStripMenuItemShowTaskCard.Enabled = true;
                    }
                }
            };

            DirectivesViewer.AddMenuItems(new RadMenuItemBase[] { _toolStripMenuItemOpen,
                                                                  _toolStripMenuItemShowTaskCard,
                                                                  _toolStripSeparatorOpenOperation,
                                                                  _toolStripMenuItemHighlight,
                                                                  _toolStripSeparatorHighlightOperation,
                                                                  _toolStripMenuItemComposeWorkPackage,
                                                                  _toolStripMenuItemsWorkPackages });

            DirectivesViewer.SelectedItemsChanged += DirectivesViewerSelectedItemsChanged;
            panel1.Controls.Add(DirectivesViewer);
        }