Пример #1
0
        private void CellGUI(Rect cellRect, TreeViewItem <JObject> item, int column, ref RowGUIArgs args)
        {
            CenterRectUsingSingleLineHeight(ref cellRect);

            switch (column)
            {
            case 0:
                Rect toggleRect = cellRect;
                toggleRect.x += cellRect.width - 18;
                var toggle = GUI.Toggle(toggleRect, item.data["enabled"].Value <bool>(), "");
                if (toggle != item.data["enabled"].Value <bool>())
                {
                    RuleEnabledOrDisabled?.Invoke(item.data["id"].Value <string>(), !item.data["enabled"].Value <bool>());
                }
                break;

            case 1:
                var ruleNameStyle = EditorStyles.label;
                ruleNameStyle.wordWrap = false;
                GUI.Label(cellRect, item.displayName, ruleNameStyle);
                break;

            case 2:
                EditorGUI.BeginDisabledGroup(item.data["enabled"].Value <bool>());
                var newPriority = EditorGUI.IntField(cellRect, item.data["priority"].Value <int>());
                if (newPriority != item.data["priority"].Value <int>())
                {
                    var rule = item.data;
                    rule["priority"] = newPriority;
                    RuleAttributesChanged?.Invoke(item.data["id"].Value <string>(), rule);
                }
                EditorGUI.EndDisabledGroup();
                break;

            case 3:
                EditorGUI.LabelField(cellRect, item.data["type"].Value <string>());
                break;

            case 4:
                EditorGUI.BeginDisabledGroup(item.data["enabled"].Value <bool>());
                if (GUI.Button(cellRect, EditorGUIUtility.FindTexture("d_TreeEditor.Trash")))
                {
                    DeleteRule?.Invoke(item.data["id"].Value <string>());
                }
                EditorGUI.EndDisabledGroup();
                break;
            }
        }
Пример #2
0
 private void SwitchRuleEnabled()
 {
     try
     {
         var enabled = firewallService.SwitchEnabled(firewallRuleDto);
         pboxRule.Image = enabled ? icon : iconGrayScale;
     }
     catch (Exception exc)
     {
         if (MessageBox.Show(
                 "The following error occurred: \n" + exc.Message + "\nDelete this rule?", "Error",
                 MessageBoxButtons.YesNo, MessageBoxIcon.Error) == DialogResult.Yes)
         {
             DeleteRule?.Invoke(this, Rule);
         }
     }
 }
Пример #3
0
 private void RemoveRuleToolStripMenuItem_Click(object sender, EventArgs e)
 {
     DeleteRule?.Invoke(this, Rule);
     RaiseHideForm();
 }