Exemple #1
0
        /// <summary>
        /// Clean up any resources being used.
        /// </summary>
        /// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
        protected override void Dispose(bool disposing)
        {
            GridTextBoxDropDownEditControl ddc = _grid.PrimaryGrid.Columns["Name"].EditControl as GridTextBoxDropDownEditControl;

            if (ddc != null)
            {
                ddc.ButtonClearClick -= DdcButtonClearClick;
            }
            ddc = _grid.PrimaryGrid.Columns["Description"].EditControl as GridTextBoxDropDownEditControl;
            if (ddc != null)
            {
                ddc.ButtonClearClick -= DdcButtonClearClick;
            }

            var rows = _grid.PrimaryGrid.Rows.OfType <GridRow>().ToArray();

            if (rows.Any())
            {
                foreach (var row in rows)
                {
                    RemoveEventSubscriptions(row);
                }
            }

            if (disposing && (components != null))
            {
                components.Dispose();
            }
            base.Dispose(disposing);
        }
Exemple #2
0
        //public IActionDefinition ActionDefinition => new ActionDefinition(Id, "ThreatActorList", "Threat Actor List",
        //    Resources.actor_big, Resources.actor);

        private void InitializeGrid()
        {
            lock (_grid)
            {
                // TODO: Add here the new columns.

                GridPanel panel = _grid.PrimaryGrid;
                panel.ShowTreeButtons    = false;
                panel.AllowRowDelete     = false;
                panel.AllowRowInsert     = false;
                panel.ShowRowDirtyMarker = false;
                panel.ShowRowHeaders     = false;
                panel.InitialActiveRow   = RelativeRow.None;

                panel.Columns.Add(new GridColumn("Name")
                {
                    HeaderText   = "Name",
                    AutoSizeMode = ColumnAutoSizeMode.Fill,
                    DataType     = typeof(string),
                    EditorType   = typeof(GridTextBoxDropDownEditControl),
                    AllowEdit    = true
                });
                GridTextBoxDropDownEditControl ddc = panel.Columns["Name"].EditControl as GridTextBoxDropDownEditControl;
                if (ddc != null)
                {
                    ddc.ButtonClear.Visible = true;
                    ddc.ButtonClearClick   += DdcButtonClearClick;
                }
            }
        }
Exemple #3
0
        /// <summary>
        /// Initializes the default state of the grid
        /// </summary>
        private void InitializeGrid()
        {
            GridPanel panel = superGridControl1.PrimaryGrid;

            string[] orderArray = { "Asterids", "Eudicots", "Rosids" };

            // Set the ComboBoxEx column EditorType to our FragrantComboBox
            // and set the EditorParams to our created orderArray.
            //
            // The EditorParams property holds the parameters that will be
            // sent to the like defined EditorControl constructor when the
            // grid creates the EditControl.  The EditorParams can be any
            // array of objects, but must match in type and order to the
            // associated constructor.

            panel.Columns["ComboBoxEx"].EditorType   = typeof(FragrantComboBox);
            panel.Columns["ComboBoxEx"].EditorParams = new object[] { orderArray };

            // Set the ButtonX column EditorType to our FlowerButton
            // and set the EditorParams to our created flowerImageList.

            panel.Columns["ButtonX"].EditorType   = typeof(FlowerButton);
            panel.Columns["ButtonX"].EditorParams = new object[] { flowerImageList };

            // Enable the Clear button on the TextBoxDropDown edit control

            GridTextBoxDropDownEditControl ddc =
                panel.Columns["TextBoxDropDown"].EditControl as GridTextBoxDropDownEditControl;

            if (ddc != null)
            {
                ddc.ButtonClear.Visible = true;
                ddc.ButtonClearClick   += DdcButtonClearClick;
            }

            // Set the Mask on the MaskedTextBox edit control

            GridMaskedTextBoxEditControl mtb =
                panel.Columns["MaskedTextBox"].EditControl as GridMaskedTextBoxEditControl;

            if (mtb != null)
            {
                mtb.Mask = ">LL->L-000";
            }

            // Now lets change the DirtyMarkerBackground on every
            // other row - just to demonstrate the operation

            for (int i = 0; i < panel.Rows.Count; i++)
            {
                if (i % 2 == 0)
                {
                    GridRow row = (GridRow)panel.Rows[i];

                    row.RowStyles.Default.RowHeaderStyle.DirtyMarkerBackground =
                        new Background(Color.Crimson, Color.Gainsboro, BackFillType.VerticalCenter);
                }
            }
        }
        private void InitializeGrid()
        {
            lock (_grid)
            {
                // TODO: Add here the new columns.

                GridPanel panel = _grid.PrimaryGrid;
                panel.ShowTreeButtons    = false;
                panel.AllowRowDelete     = false;
                panel.AllowRowInsert     = false;
                panel.ShowRowDirtyMarker = false;
                panel.ShowRowHeaders     = false;
                panel.InitialActiveRow   = RelativeRow.None;

                panel.Columns.Add(new GridColumn("Name")
                {
                    HeaderText   = "Name",
                    AutoSizeMode = ColumnAutoSizeMode.Fill,
                    DataType     = typeof(string),
                    EditorType   = typeof(GridTextBoxDropDownEditControl),
                    AllowEdit    = true
                });
                GridTextBoxDropDownEditControl ddc = panel.Columns["Name"].EditControl as GridTextBoxDropDownEditControl;
                if (ddc != null)
                {
                    ddc.ButtonClear.Visible = true;
                    ddc.ButtonClearClick   += DdcButtonClearClick;
                }

                panel.Columns.Add(new GridColumn("Source")
                {
                    HeaderText = "Source",
                    DataType   = typeof(string),
                    AllowEdit  = false,
                    Width      = 250
                });

                panel.Columns.Add(new GridColumn("Target")
                {
                    HeaderText = "Target",
                    DataType   = typeof(string),
                    AllowEdit  = false,
                    Width      = 250
                });

                panel.Columns.Add(new GridColumn("FlowType")
                {
                    HeaderText   = "Flow Type",
                    DataType     = typeof(string),
                    EditorType   = typeof(EnumComboBox),
                    EditorParams = new object[] { EnumExtensions.GetEnumLabels <FlowType>() },
                    AllowEdit    = true,
                    Width        = 150
                });
            }
        }
        void DdcButtonClearClick(object sender, CancelEventArgs e)
        {
            GridTextBoxDropDownEditControl ddc =
                sender as GridTextBoxDropDownEditControl;

            if (ddc != null)
            {
                ddc.Text = null;
                e.Cancel = true;
            }
        }
        private void InitializeGrid()
        {
            GridPanel panel = _grid.PrimaryGrid;

            panel.ShowTreeButtons    = true;
            panel.ShowTreeLines      = true;
            panel.AllowRowDelete     = false;
            panel.AllowRowInsert     = false;
            panel.AllowRowResize     = true;
            panel.ShowRowDirtyMarker = false;
            panel.InitialActiveRow   = RelativeRow.None;

            panel.Columns.Add(new GridColumn("First")
            {
                HeaderText = "First Entity",
                Width      = 200,
                DataType   = typeof(string),
                AllowEdit  = false
            });

            panel.Columns.Add(new GridColumn("Second")
            {
                HeaderText = "Second Entity",
                Width      = 200,
                DataType   = typeof(string),
                AllowEdit  = false
            });

            panel.Columns.Add(new GridColumn("Name")
            {
                HeaderText = "Flow Name",
                Width      = 350,
                DataType   = typeof(string),
                EditorType = typeof(GridTextBoxDropDownEditControl),
                AllowEdit  = true
            });
            GridTextBoxDropDownEditControl ddc = panel.Columns["Name"].EditControl as GridTextBoxDropDownEditControl;

            if (ddc != null)
            {
                ddc.ButtonClear.Visible = true;
                ddc.ButtonClearClick   += DdcButtonClearClick;
            }

            panel.Columns.Add(new GridColumn("Ignore")
            {
                HeaderText = "Ignore",
                DataType   = typeof(bool),
                AllowEdit  = true,
                Width      = 75,
                EditorType = typeof(GridSwitchButtonEditControl),
            });
        }
        /// <summary>
        /// Clean up any resources being used.
        /// </summary>
        /// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
        protected override void Dispose(bool disposing)
        {
            GridTextBoxDropDownEditControl ddc = _grid.PrimaryGrid.Columns["Name"].EditControl as GridTextBoxDropDownEditControl;
            if (ddc != null)
            {
                ddc.ButtonClearClick -= DdcButtonClearClick;
            }

            if (disposing && (components != null))
            {
                components.Dispose();
            }
            base.Dispose(disposing);
        }
Exemple #8
0
        private void RemoveEventSubscriptions(GridRow row)
        {
            if (row?.Tag is IMitigation mitigation)
            {
                for (int i = 0; i < row.Cells.Count; i++)
                {
                    row.Cells[i].PropertyChanged -= OnMitigationCellChanged;
                }
                ((INotifyPropertyChanged)mitigation).PropertyChanged -= OnMitigationPropertyChanged;

                var panel    = row.Rows.OfType <GridPanel>().FirstOrDefault();
                var children = panel?.Rows.OfType <GridRow>().ToArray();
                if (children?.Any() ?? false)
                {
                    foreach (var child in children)
                    {
                        RemoveEventSubscriptions(child);
                    }
                }

                GridTextBoxDropDownEditControl ddc = panel.Columns["Name"].EditControl as GridTextBoxDropDownEditControl;
                if (ddc != null)
                {
                    ddc.ButtonClearClick -= DdcButtonClearClick;
                }
            }
            else if (row?.Tag is IThreatEventMitigation tem)
            {
                if (tem.ThreatEvent?.Parent != null)
                {
                    ((INotifyPropertyChanged)tem.ThreatEvent.Parent).PropertyChanged -=
                        OnThreatEventMitigationParentPropertyChanged;
                    if (tem.ThreatEvent.Parent is IEntity entity)
                    {
                        entity.ImageChanged -= OnImageChanged;
                    }
                }
                for (int i = 0; i < row.Cells.Count; i++)
                {
                    row.Cells[i].PropertyChanged -= OnThreatEventMitigationCellChanged;
                }

                ((INotifyPropertyChanged)tem).PropertyChanged -= OnThreatEventMitigationPropertyChanged;
                tem.ThreatEvent.ThreatEventMitigationAdded    -= OnThreatEventMitigationAdded;
                tem.ThreatEvent.ThreatEventMitigationRemoved  -= OnThreatEventMitigationRemoved;

                RemoveSuperTooltipProvider(row.Cells["Parent"]);
            }
        }
Exemple #9
0
        /// <summary>
        /// Handles Clear button clicks
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        void DdcButtonClearClick(object sender, CancelEventArgs e)
        {
            GridTextBoxDropDownEditControl ddc =
                sender as GridTextBoxDropDownEditControl;

            if (ddc != null)
            {
                // Just set the text to an "unknown" value and
                // tell the control that we handled it

                ddc.Text = "(unknown)";

                e.Cancel = true;
            }
        }
        /// <summary>
        /// Clean up any resources being used.
        /// </summary>
        /// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
        protected override void Dispose(bool disposing)
        {
            _grid.CellActivated  -= _grid_CellActivated;
            _grid.CellMouseDown  -= _grid_CellMouseDown;
            _grid.CellMouseLeave -= _grid_CellMouseLeave;
            _grid.CellMouseMove  -= _grid_CellMouseMove;
            _grid.RowActivated   -= _grid_RowActivated;
            _grid.MouseClick     -= _grid_MouseClick;

            _properties.OpenDiagram -= OpenDiagram;
            _properties.Item         = null;

            GridTextBoxDropDownEditControl ddc = _grid.PrimaryGrid.Columns["Name"].EditControl as GridTextBoxDropDownEditControl;

            if (ddc != null)
            {
                ddc.ButtonClearClick -= DdcButtonClearClick;
            }

            if (_model != null)
            {
                _model.ChildRemoved                   -= ModelChildRemoved;
                _model.ThreatEventAdded               -= OnThreatEventAdded;
                _model.ThreatEventRemoved             -= OnThreatEventRemoved;
                _model.ThreatEventAddedToEntity       -= OnThreatEventAdded;
                _model.ThreatEventRemovedFromEntity   -= OnThreatEventRemoved;
                _model.ThreatEventAddedToDataFlow     -= OnThreatEventAdded;
                _model.ThreatEventRemovedFromDataFlow -= OnThreatEventRemoved;
            }

            var rows = _grid.PrimaryGrid.Rows.OfType <GridRow>().ToArray();

            if (rows.Any())
            {
                foreach (var row in rows)
                {
                    RemoveEventSubscriptions(row);
                }
            }

            if (disposing && (components != null))
            {
                components.Dispose();
            }
            base.Dispose(disposing);
        }
Exemple #11
0
        private void InitializeGrid()
        {
            lock (_grid)
            {
                GridPanel panel = _grid.PrimaryGrid;
                panel.ShowTreeButtons    = true;
                panel.ShowTreeLines      = true;
                panel.AllowRowDelete     = false;
                panel.AllowRowInsert     = false;
                panel.AllowRowResize     = true;
                panel.ShowRowDirtyMarker = false;
                panel.ShowRowHeaders     = false;
                panel.InitialActiveRow   = RelativeRow.None;
                panel.DefaultVisualStyles.CellStyles.ReadOnly.TextColor = Color.Black;
                panel.ReadOnly = _executionMode == ExecutionMode.Management;

                panel.Columns.Add(new GridColumn("Name")
                {
                    HeaderText   = "Threat Type Name",
                    AutoSizeMode = ColumnAutoSizeMode.Fill,
                    DataType     = typeof(string),
                    EditorType   = typeof(GridTextBoxDropDownEditControl),
                    AllowEdit    = true
                });
                GridTextBoxDropDownEditControl ddc = panel.Columns["Name"].EditControl as GridTextBoxDropDownEditControl;
                if (ddc != null)
                {
                    ddc.ButtonClear.Visible = true;
                    ddc.ButtonClearClick   += DdcButtonClearClick;
                }

                panel.Columns.Add(new GridColumn("Severity")
                {
                    HeaderText   = "Max Severity",
                    DataType     = typeof(ISeverity),
                    EditorType   = typeof(SeverityComboBox),
                    EditorParams = new object[] { _model.Severities?.Where(x => x.Visible) },
                    AllowEdit    = false,
                    Width        = 100
                });
            }
        }
        private void InitializeGrid()
        {
            lock (_grid)
            {
                GridPanel panel = _grid.PrimaryGrid;
                panel.ShowTreeButtons    = true;
                panel.ShowTreeLines      = true;
                panel.AllowRowDelete     = false;
                panel.AllowRowInsert     = false;
                panel.AllowRowResize     = true;
                panel.ShowRowDirtyMarker = false;
                panel.ShowRowHeaders     = false;
                panel.InitialActiveRow   = RelativeRow.None;

                panel.Columns.Add(new GridColumn("Name")
                {
                    HeaderText   = "Weakness Name",
                    AutoSizeMode = ColumnAutoSizeMode.Fill,
                    DataType     = typeof(string),
                    EditorType   = typeof(GridTextBoxDropDownEditControl),
                    AllowEdit    = true
                });
                GridTextBoxDropDownEditControl ddc = panel.Columns["Name"].EditControl as GridTextBoxDropDownEditControl;
                if (ddc != null)
                {
                    ddc.ButtonClear.Visible = true;
                    ddc.ButtonClearClick   += DdcButtonClearClick;
                }

                panel.Columns.Add(new GridColumn("Severity")
                {
                    HeaderText   = "Severity",
                    DataType     = typeof(ISeverity),
                    EditorType   = typeof(SeverityComboBox),
                    EditorParams = new object[] { _model.Severities?.Where(x => x.Visible) },
                    AllowEdit    = true,
                    Width        = 75
                });
            }
        }
Exemple #13
0
        private void AddSubPanel2()
        {
            GridPanel panel = superGridControl1.FindGridPanel("GridPanel2", true);

            if (panel != null)
            {
                GridTextBoxDropDownEditControl ddc =
                    panel.Columns["TextBoxDropDown"].EditControl as GridTextBoxDropDownEditControl;

                if (ddc != null)
                {
                    ddc.ButtonClear.Visible = true;
                    ddc.ButtonClearClick   += DdcButtonClearClick;
                }

                GridColumn col = panel.Columns["Slider"];
                col.EditorType = typeof(MyGridSliderEditControl);

                foreach (GridRow row in panel.Rows)
                {
                    object[] data = GetGridPanel2RowData();

                    for (int i = 0; i < data.Length; i++)
                    {
                        row.Cells[i].Value = data[i];
                    }
                }

                for (int i = 0; i < 10; i++)
                {
                    panel.Rows.Add(
                        new GridRow(GetGridPanel2RowData()));
                }

                col = panel.Columns["TextBoxDropDown"];
                col.DisplayIndex = 0;

                panel.SetGroup(col);
            }
        }
Exemple #14
0
        /// <summary>
        /// Clean up any resources being used.
        /// </summary>
        /// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
        protected override void Dispose(bool disposing)
        {
            _grid.CellActivated -= _grid_CellActivated;
            _grid.RowActivated  -= _grid_RowActivated;
            _grid.MouseClick    -= _grid_MouseClick;

            GridTextBoxDropDownEditControl ddc = _grid.PrimaryGrid.Columns["Name"].EditControl as GridTextBoxDropDownEditControl;

            if (ddc != null)
            {
                ddc.ButtonClearClick -= DdcButtonClearClick;
            }

            _properties.Item = null;

            if (_model != null)
            {
                _model.ChildCreated -= ModelChildCreated;
                _model.ChildRemoved -= ModelChildRemoved;
            }

            var rows = _grid.PrimaryGrid.Rows.OfType <GridRow>().ToArray();

            if (rows.Any())
            {
                foreach (var row in rows)
                {
                    RemoveEventSubscriptions(row);
                }
            }

            if (disposing && (components != null))
            {
                components.Dispose();
            }
            base.Dispose(disposing);
        }
Exemple #15
0
        private void InitializeGrid()
        {
            lock (_grid)
            {
                // TODO: Add here the new columns.

                GridPanel panel = _grid.PrimaryGrid;
                panel.ShowTreeButtons    = false;
                panel.AllowRowDelete     = false;
                panel.AllowRowInsert     = false;
                panel.ShowRowDirtyMarker = false;
                panel.ShowRowHeaders     = false;
                panel.InitialActiveRow   = RelativeRow.None;

                panel.Columns.Add(new GridColumn("Id")
                {
                    HeaderText = "Id",
                    Width      = 50,
                    DataType   = typeof(int),
                    EditorType = typeof(GridIntegerInputEditControl),
                    AllowEdit  = false
                });

                panel.Columns.Add(new GridColumn("Name")
                {
                    HeaderText = "Name",
                    Width      = 200,
                    DataType   = typeof(string),
                    EditorType = typeof(GridTextBoxDropDownEditControl),
                    AllowEdit  = true
                });
                GridTextBoxDropDownEditControl ddc = panel.Columns["Name"].EditControl as GridTextBoxDropDownEditControl;
                if (ddc != null)
                {
                    ddc.ButtonClear.Visible = true;
                    ddc.ButtonClearClick   += DdcButtonClearClick;
                }

                panel.Columns.Add(new GridColumn("Description")
                {
                    HeaderText   = "Description",
                    AutoSizeMode = ColumnAutoSizeMode.Fill,
                    DataType     = typeof(string),
                    EditorType   = typeof(GridTextBoxDropDownEditControl),
                    AllowEdit    = true
                });
                panel.Columns["Description"].CellStyles.Default.AllowMultiLine = Tbool.True;
                ddc = panel.Columns["Description"].EditControl as GridTextBoxDropDownEditControl;
                if (ddc != null)
                {
                    ddc.ButtonClear.Visible = true;
                    ddc.ButtonClearClick   += DdcButtonClearClick;
                }

                panel.Columns.Add(new GridColumn("Visible")
                {
                    HeaderText = "Visible",
                    Width      = 100,
                    DataType   = typeof(bool),
                    EditorType = typeof(GridSwitchButtonEditControl),
                    AllowEdit  = true
                });

                panel.Columns.Add(new GridColumn("TextColor")
                {
                    HeaderText = "Text",
                    Width      = 120,
                    DataType   = typeof(string),
                    EditorType = typeof(GridColorCombo),
                    AllowEdit  = true
                });

                panel.Columns.Add(new GridColumn("BackColor")
                {
                    HeaderText = "Background",
                    Width      = 120,
                    DataType   = typeof(string),
                    EditorType = typeof(GridColorCombo),
                    AllowEdit  = true
                });
            }
        }
Exemple #16
0
        private GridPanel CreateThreatEventsPanel([NotNull] IMitigation mitigation, [NotNull] IList <IThreatEventMitigation> threatEventMitigations)
        {
            GridPanel result = null;

            if (!string.IsNullOrWhiteSpace(mitigation.Name))
            {
                result = new GridPanel
                {
                    Name               = "ThreatEventMitigations",
                    AllowRowDelete     = false,
                    AllowRowInsert     = false,
                    AllowRowResize     = true,
                    ShowRowDirtyMarker = false,
                    ShowTreeButtons    = false,
                    ShowTreeLines      = false,
                    ShowRowHeaders     = false,
                    InitialSelection   = RelativeSelection.None,
                    ReadOnly           = _executionMode == ExecutionMode.Management
                };
                result.DefaultVisualStyles.CellStyles.ReadOnly.TextColor = Color.Black;

                result.Columns.Add(new GridColumn("Name")
                {
                    HeaderText   = "Threat Event Name",
                    AutoSizeMode = ColumnAutoSizeMode.Fill,
                    DataType     = typeof(string),
                    EditorType   = typeof(GridTextBoxDropDownEditControl),
                    AllowEdit    = true
                });
                GridTextBoxDropDownEditControl ddc = result.Columns["Name"].EditControl as GridTextBoxDropDownEditControl;
                if (ddc != null)
                {
                    ddc.ButtonClear.Visible = true;
                    ddc.ButtonClearClick   += DdcButtonClearClick;
                }

                result.Columns.Add(new GridColumn("Parent")
                {
                    HeaderText = "Associated To",
                    DataType   = typeof(string),
                    AllowEdit  = false,
                    Width      = 250
                });

                result.Columns.Add(new GridColumn("Severity")
                {
                    HeaderText   = "Severity",
                    DataType     = typeof(ISeverity),
                    EditorType   = typeof(SeverityComboBox),
                    EditorParams = new object[] { _model.Severities?.Where(x => x.Visible) },
                    AllowEdit    = true,
                    Width        = 75
                });

                result.Columns.Add(new GridColumn("Strength")
                {
                    HeaderText   = "Strength",
                    DataType     = typeof(IStrength),
                    EditorType   = typeof(StrengthComboBox),
                    EditorParams = new object[] { _model.Strengths?.Where(x => x.Visible) },
                    AllowEdit    = true,
                    Width        = 75
                });

                result.Columns.Add(new GridColumn("Status")
                {
                    HeaderText   = "Status",
                    DataType     = typeof(string),
                    EditorType   = typeof(EnumComboBox),
                    EditorParams = new object[] { EnumExtensions.GetEnumLabels <MitigationStatus>() },
                    AllowEdit    = true,
                    Width        = 75
                });

                foreach (var tem in threatEventMitigations)
                {
                    AddGridRow(tem, result);
                }
            }

            return(result);
        }