Exemple #1
0
        private void OnThreatTypeMitigationAdded(IThreatTypeMitigationsContainer container, IThreatTypeMitigation mitigation)
        {
            if (container is IThreatType threatType)
            {
                var filterSpecial = EnumExtensions.GetEnumValue <ThreatTypeListFilter>((string)_specialFilter.SelectedItem);
                if (IsSelected(threatType, _filter.Text, filterSpecial))
                {
                    var row = GetRow(threatType);
                    if (row == null)
                    {
                        row = AddGridRow(threatType, _grid.PrimaryGrid);
                    }

                    var scenarioPanel = row.Rows.OfType <GridPanel>()
                                        .FirstOrDefault(x => string.CompareOrdinal(x.Name, "Mitigations") == 0);
                    if (scenarioPanel != null)
                    {
                        AddGridRow(mitigation, scenarioPanel);
                    }
                    else
                    {
                        scenarioPanel = CreateMitigationsPanel(threatType);
                        if (scenarioPanel != null)
                        {
                            row.Rows.Add(scenarioPanel);
                        }
                    }

                    UpdateMitigationLevel(threatType, row);
                }
            }
        }
Exemple #2
0
        private void ThreatTypeMitigationRemoved([NotNull] IThreatTypeMitigationsContainer container, [NotNull] IThreatTypeMitigation threatTypeMitigation)
        {
            var row = GetRow(threatTypeMitigation);

            if (row != null)
            {
                RemoveEventSubscriptions(row);
                row.GridPanel.Rows.Remove(row);
            }
        }
Exemple #3
0
        private void ThreatTypeMitigationAdded([NotNull] IThreatTypeMitigationsContainer container, [NotNull] IThreatTypeMitigation threatTypeMitigation)
        {
            var row = GetRow(threatTypeMitigation);

            if (row == null)
            {
                var mitigationRow = GetRow(threatTypeMitigation.Mitigation);
                if (mitigationRow != null)
                {
                    var panel = mitigationRow.Rows.OfType <GridPanel>()
                                .FirstOrDefault(x => string.CompareOrdinal("ThreatTypes", x.Name) == 0);
                    AddGridRow(threatTypeMitigation, panel);
                }
            }
        }
Exemple #4
0
        private void OnThreatTypeMitigationRemoved(IThreatTypeMitigationsContainer container, IThreatTypeMitigation mitigation)
        {
            if (container is IThreatType threatType)
            {
                var row = GetRow(threatType);

                var panel       = row?.Rows.OfType <GridPanel>().FirstOrDefault(x => string.CompareOrdinal(x.Name, "Mitigations") == 0);
                var scenarioRow = panel?.Rows.OfType <GridRow>()
                                  .FirstOrDefault(x =>
                                                  (x.Tag is IThreatTypeMitigation typeMitigation) && typeMitigation == mitigation);
                if (scenarioRow != null)
                {
                    panel.Rows.Remove(scenarioRow);

                    if (panel.Rows.Count == 0)
                    {
                        row.Rows.Remove(panel);
                    }

                    UpdateMitigationLevel(threatType, row);
                }
            }
        }
Exemple #5
0
 private void Update(IThreatTypeMitigationsContainer arg1, IThreatTypeMitigation arg2)
 {
     UpdateInfo?.Invoke(this.GetExtensionId(), CurrentStatus);
 }