public void AddEditorUI(string id, ITreeNodeView view, IProperty property)
        {
            _property = property;
            _nullBox  = BoolPropertyEditor.CreateCheckbox(view.TreeItem, _factory, id + "_NullBox");
            refreshChecked();

            _nullBox.OnCheckChanged.Subscribe(args =>
            {
                Type underlying = Nullable.GetUnderlyingType(property.PropertyType) ??
                                  throw new Exception($"Underlying type for {property.PropertyType.Name} returned null");
                object val = args.Checked ? Activator.CreateInstance(underlying) : null;

                if (args.UserInitiated)
                {
                    _actions.RecordAction(new PropertyAction(property, val, _model));
                }
                else
                {
                    property.Value = new ValueModel(val, type: property.PropertyType);
                }

                _editor.OnNullChanged(!_nullBox.Checked);
            });

            _editor.AddEditorUI(id, view, property);
            _editor.OnNullChanged(!_nullBox.Checked);
        }
Exemplo n.º 2
0
        public void AddEditorUI(string id, ITreeNodeView view, IProperty property)
        {
            _property = property;
            var label = view.TreeItem;
            var panel = _factory.UI.GetPanel(id, 0f, 0f, 0f, 0f, label.TreeNode.Parent);

            _combobox = SelectEditor.GetCombobox($"{id}_Combobox", _factory, panel, 200f);
            _text     = _combobox.TextBox;
            _combobox.DropDownPanelList.MinWidth = 200f;
            _combobox.DropDownPanelList.Items.AddRange(_colorList);
            _combobox.Z = label.Z;

            _colorLabel             = _factory.UI.GetLabel($"{id}_ColorLabel", "", 50f, 25f, 250f, 0f, panel);
            _colorLabel.TextVisible = false;

            var layout = view.HorizontalPanel.GetComponent <ITreeTableRowLayoutComponent>();

            if (layout != null)
            {
                layout.RestrictionList.RestrictionList.AddRange(new List <string> {
                    panel.ID
                });
            }

            RefreshUI();
            _text.OnPressingKey.Subscribe(onTextboxPressingKey);
            _combobox.SuggestMode = ComboSuggest.Suggest;
            _combobox.DropDownPanelList.OnSelectedItemChanged.Subscribe(args =>
            {
                setColor(Color.FromHexa(NamedColorsMap.NamedColors[args.Item.Text]));
            });
        }
Exemplo n.º 3
0
        public void AddEditorUI(string id, ITreeNodeView view, IProperty property)
        {
            _property = property;
            var label    = view.TreeItem;
            var combobox = _factory.GetComboBox(id, null, null, null, label.TreeNode.Parent, defaultWidth: 100f, defaultHeight: 25f);

            _text = combobox.TextBox;
            _text.TextBackgroundVisible = false;
            var  list     = new List <IStringItem>();
            Type enumType = property.PropertyType;

            foreach (var option in Enum.GetValues(enumType))
            {
                list.Add(new AGSStringItem {
                    Text = option.ToString()
                });
            }
            combobox.DropDownPanelList.Items.AddRange(list);
            combobox.Z            = label.Z;
            combobox.TextBox.Text = property.ValueString;
            combobox.TextBox.TextConfig.AutoFit = AutoFit.LabelShouldFitText;
            if (list.Count > 5) //If more than 5 items in the dropdown, let's have it with textbox suggestions as user might prefer to type for filtering the dropdown
            {
                combobox.SuggestMode = ComboSuggest.Enforce;
            }
            combobox.DropDownPanelList.OnSelectedItemChanged.Subscribe(args =>
            {
                if (_actions.ActionIsExecuting)
                {
                    return;
                }
                _actions.RecordAction(new PropertyAction(property, Enum.Parse(enumType, args.Item.Text), _model));
            });
        }
Exemplo n.º 4
0
        public void AddEditorUI(string id, ITreeNodeView view, InspectorProperty property)
        {
            _property = property;
            var           label   = view.TreeItem;
            AGSTextConfig config  = new AGSTextConfig(autoFit: AutoFit.LabelShouldFitText);
            var           textbox = _factory.GetTextBox(id,
                                                        label.X, label.Y, label.TreeNode.Parent,
                                                        "", config, width: 100f, height: 20f);

            textbox.Text = property.Value;
            textbox.TextBackgroundVisible = false;
            _textbox            = textbox;
            textbox.RenderLayer = label.RenderLayer;
            textbox.Z           = label.Z;
            HoverEffect.Add(textbox, Colors.Transparent, Colors.DarkSlateBlue);
            textbox.OnPressingKey.Subscribe(args =>
            {
                if (args.PressedKey != Key.Enter)
                {
                    return;
                }
                args.ShouldCancel = true;
                textbox.IsFocused = false;
                property.Prop.SetValue(property.Object, textbox.Text);
            });
        }
Exemplo n.º 5
0
        public void AddEditorUI(string id, ITreeNodeView view, InspectorProperty property)
        {
            _property = property;
            var label   = view.TreeItem;
            var config  = _enabled ? GameViewColors.TextConfig : GameViewColors.ReadonlyTextConfig;
            var textbox = _factory.UI.GetTextBox(id,
                                                 label.X, label.Y, label.TreeNode.Parent,
                                                 "", config, width: 100f, height: 20f);

            textbox.Text = property.Value;
            textbox.TextBackgroundVisible = false;
            textbox.Enabled = _enabled;
            if (_enabled)
            {
                GameViewColors.AddHoverEffect(textbox);
            }
            _textbox            = textbox;
            textbox.RenderLayer = label.RenderLayer;
            textbox.Z           = label.Z;
            HoverEffect.Add(textbox, Colors.Transparent, Colors.DarkSlateBlue);
            textbox.OnPressingKey.Subscribe(args =>
            {
                if (args.PressedKey != Key.Enter)
                {
                    return;
                }
                args.ShouldCancel = true;
                textbox.IsFocused = false;
                property.Prop.SetValue(property.Object, textbox.Text);
            });
            textbox.LostFocus.Subscribe(args => {
                property.Prop.SetValue(property.Object, textbox.Text);
            });
        }
Exemplo n.º 6
0
        public void BeforeDisplayingNode(ITreeStringNode item, ITreeNodeView nodeView,
                                         bool isCollapsed, bool isHovered, bool isSelected)
        {
            var textConfig = isHovered ? item.HoverTextConfig : item.IdleTextConfig;
            var label      = nodeView.TreeItem as ITextComponent;

            if (label != null)
            {
                label.TextConfig            = textConfig;
                label.Text                  = item.Text;
                label.TextBackgroundVisible = isSelected;
            }
            nodeView.TreeItem.Tint = isSelected ? Colors.DarkSlateBlue : Colors.Transparent;
            var expandButton = nodeView.ExpandButton;

            if (expandButton != null)
            {
                var expandTextConfig = textConfig;
                if (item.TreeNode.ChildrenCount == 0)
                {
                    expandTextConfig = AGSTextConfig.ChangeColor(textConfig, textConfig.Brush.Color.WithAlpha(0), textConfig.OutlineBrush.Color, textConfig.OutlineWidth);
                }
                expandButton.TextConfig = expandTextConfig;
                expandButton.Text       = isCollapsed ? "+" : "-";
                expandButton.Enabled    = expandButton.TextVisible;
            }
        }
Exemplo n.º 7
0
        public void BeforeDisplayingNode(ITreeStringNode item, ITreeNodeView nodeView,
                                         bool isCollapsed, bool isHovered, bool isSelected)
        {
            var textConfig = isHovered ? item.HoverTextConfig : item.IdleTextConfig;
            var label      = nodeView.TreeItem as ITextComponent;

            if (label != null)
            {
                label.TextConfig            = textConfig;
                label.Text                  = item.Text;
                label.TextBackgroundVisible = isSelected;
                item.PropertyChanged       += (sender, e) =>
                {
                    if (e.PropertyName != nameof(ITreeStringNode.Text))
                    {
                        return;
                    }
                    label.Text = item.Text;
                };
            }
            nodeView.TreeItem.Tint = isSelected ? Colors.DarkSlateBlue : Colors.Transparent;
            var expandButton = nodeView.ExpandButton;

            if (expandButton != null)
            {
                expandButton.TextConfig  = textConfig;
                expandButton.Text        = isCollapsed ? "+" : "-";
                expandButton.TextVisible = item.TreeNode.ChildrenCount > 0;
                expandButton.Enabled     = expandButton.TextVisible;
            }
        }
Exemplo n.º 8
0
        public void AddEditorUI(string id, ITreeNodeView view, InspectorProperty property)
        {
            _property = property;
            var label    = view.TreeItem;
            var combobox = _factory.GetComboBox(id, null, null, null, label.TreeNode.Parent, defaultWidth: 100f, defaultHeight: 25f);

            _text = combobox.TextBox;
            _text.TextBackgroundVisible = false;
            var  list     = new List <IStringItem>();
            Type enumType = property.Prop.PropertyType;

            foreach (var option in Enum.GetValues(enumType))
            {
                list.Add(new AGSStringItem {
                    Text = option.ToString()
                });
            }
            combobox.DropDownPanelList.Items.AddRange(list);
            combobox.Z            = label.Z;
            combobox.TextBox.Text = property.Value;
            combobox.TextBox.TextConfig.AutoFit = AutoFit.LabelShouldFitText;
            combobox.DropDownPanelList.OnSelectedItemChanged.Subscribe(args =>
            {
                property.Prop.SetValue(property.Object, Enum.Parse(enumType, args.Item.Text));
            });
        }
Exemplo n.º 9
0
        private void displayCategoryRow(ITreeNodeView nodeView, bool isSelected)
        {
            nodeView.TreeItem.Tint        = Colors.Transparent;
            nodeView.HorizontalPanel.Tint = isSelected ? Colors.DarkSlateBlue : Colors.Gray.WithAlpha(50);
            var subscriber = _resizeSubscribers.GetOrAdd(nodeView, view => new ResizeSubscriber(view));

            subscriber.Subscribe(_onResize);
            subscriber.Resize(_rowWidth);
        }
Exemplo n.º 10
0
        public void BeforeDisplayingNode(ITreeStringNode item, ITreeNodeView nodeView, bool isCollapsed, bool isHovered, bool isSelected)
        {
            isHovered |= item.Properties.Bools.GetValue(FOLDER_HOVERED);
            _inner.BeforeDisplayingNode(item, nodeView, isCollapsed, isHovered, isSelected);
            var folderIcon = (ILabel)nodeView.ExpandButton.TreeNode.Children.First(c => c.ID.StartsWith("FolderIcon", StringComparison.InvariantCulture));

            folderIcon.Text             = isSelected ? FontIcons.FolderOpen : FontIcons.Folder;
            folderIcon.TextConfig.Brush = isHovered ? GameViewColors.HoveredTextBrush : GameViewColors.TextBrush;
        }
        public void BeforeDisplayingNode(ITreeStringNode item, ITreeNodeView nodeView, bool isCollapsed, bool isHovered, bool isSelected)
        {
            _provider.BeforeDisplayingNode(item, nodeView, isCollapsed, isHovered, isSelected);
            var parent = item.TreeNode.Parent;

            if (parent != null && parent.TreeNode.Parent == null)
            {
                displayCategoryRow(nodeView, isSelected);
            }
        }
Exemplo n.º 12
0
        public void AddEditorUI(string id, ITreeNodeView view, IProperty property)
        {
            _property = property;
            var label    = view.TreeItem;
            var combobox = _factory.UI.GetComboBox(id, null, null, null, label.TreeNode.Parent, defaultWidth: 200f, defaultHeight: 25f);

            _dropDownButton             = combobox.DropDownButton;
            _text                       = combobox.TextBox;
            _text.TextBackgroundVisible = false;
            var list = new List <IStringItem>();

            foreach (var field in typeof(Colors).GetTypeInfo().DeclaredFields)
            {
                list.Add(new AGSStringItem {
                    Text = field.Name
                });
                Color color = (Color)field.GetValue(null);
                _namedColors[field.Name]          = color.Value;
                _namedColorsReversed[color.Value] = field.Name;
            }
            combobox.DropDownPanelList.Items.AddRange(list);
            combobox.Z = label.Z;

            _colorLabel             = _factory.UI.GetLabel($"{id}_ColorLabel", "", 50f, 25f, combobox.Width + 10f, 0f, label.TreeNode.Parent);
            _colorLabel.TextVisible = false;

            var layout = view.HorizontalPanel.GetComponent <ITreeTableRowLayoutComponent>();

            if (layout != null)
            {
                layout.RestrictionList.RestrictionList.AddRange(new List <string> {
                    combobox.ID, _colorLabel.ID
                });
            }

            RefreshUI();
            _text.TextConfig.AutoFit    = AutoFit.TextShouldFitLabel;
            _text.TextConfig.Alignment  = Alignment.MiddleLeft;
            _text.TextBackgroundVisible = true;
            _text.Border = _factory.Graphics.Borders.SolidColor(Colors.White, 2f);
            var whiteBrush  = _text.TextConfig.Brush;
            var yellowBrush = _factory.Graphics.Brushes.LoadSolidBrush(Colors.Yellow);

            _text.MouseEnter.Subscribe(_ => { _text.TextConfig.Brush = yellowBrush; });
            _text.MouseLeave.Subscribe(_ => { _text.TextConfig.Brush = whiteBrush; });
            _text.OnPressingKey.Subscribe(onTextboxPressingKey);
            combobox.SuggestMode = ComboSuggest.Suggest;
            combobox.DropDownPanelList.OnSelectedItemChanged.Subscribe(args =>
            {
                setColor(Color.FromHexa(_namedColors[args.Item.Text]));
            });
        }
Exemplo n.º 13
0
        public void AddEditorUI(string id, ITreeNodeView view, InspectorProperty property)
        {
            _property = property;
            var label    = view.TreeItem;
            var checkbox = CreateCheckbox(label, _factory, id);

            _checkbox        = checkbox;
            checkbox.Checked = bool.Parse(property.Value);
            checkbox.OnCheckChanged.Subscribe(args =>
            {
                property.Prop.SetValue(property.Object, args.Checked);
            });
        }
        private void setupCategoryRow(ITreeNodeView view)
        {
            var inspectorJump = _inspectorPanel.AddComponent <IJumpOffsetComponent>();
            var rowJump       = view.HorizontalPanel.AddComponent <IJumpOffsetComponent>();

            inspectorJump.PropertyChanged += (sender, args) =>
            {
                if (args.PropertyName != nameof(IJumpOffsetComponent.JumpOffset))
                {
                    return;
                }
                rowJump.JumpOffset = new PointF(-inspectorJump.JumpOffset.X, 0f);
            };
        }
Exemplo n.º 15
0
        public void BeforeDisplayingNode(ITreeStringNode item, ITreeNodeView nodeView, bool isCollapsed, bool isHovered, bool isSelected)
        {
            _provider.BeforeDisplayingNode(item, nodeView, isCollapsed, isHovered, isSelected);
            var parent = item.TreeNode.Parent;

            if (parent == null)
            {
                return;
            }
            if (item is IInspectorTreeNode node && !node.IsCategory)
            {
                return;
            }
            displayCategoryRow(nodeView, isSelected);
        }
Exemplo n.º 16
0
        public void AddEditorUI(string id, ITreeNodeView view, IProperty property)
        {
            _property = property;
            var label  = view.TreeItem;
            var config = _enabled ? GameViewColors.TextboxTextConfig : GameViewColors.ReadonlyTextConfig;

            if (!_enabled)
            {
                var layout = view.HorizontalPanel.GetComponent <ITreeTableRowLayoutComponent>();
                if (layout != null)
                {
                    layout.RestrictionList.RestrictionList.Add(id);
                }
            }
            var textbox = _factory.UI.GetTextBox(id,
                                                 label.X, label.Y, label.TreeNode.Parent,
                                                 "", config, width: 100f, height: 20f);

            textbox.Text = property.ValueString;
            textbox.TextBackgroundVisible = true;
            textbox.Enabled = _enabled;
            if (_enabled)
            {
                GameViewColors.AddHoverEffect(textbox);
            }
            else
            {
                textbox.TextBackgroundVisible = false;
            }
            _textbox            = textbox;
            textbox.RenderLayer = label.RenderLayer;
            textbox.Z           = label.Z;
            textbox.OnPressingKey.Subscribe(args =>
            {
                if (args.PressedKey != Key.Enter)
                {
                    return;
                }
                args.ShouldCancel = true;
                textbox.IsFocused = false;
                setString();
            });
            textbox.LostFocus.Subscribe(args =>
            {
                textbox.IsFocused = false;
                setString();
            });
        }
Exemplo n.º 17
0
        public int AddChild(ITreeNodeView node, bool focus = false, bool expand = false)
        {
            var ctrl = (TreeNode)node;
            int indx = this.Nodes.Add(ctrl);

            if (focus)
            {
                TreeView.Focus();
            }
            if (expand)
            {
                ctrl.Parent.Expand();
            }

            return(indx);
        }
Exemplo n.º 18
0
        public void AddEditorUI(string id, ITreeNodeView view, IProperty property)
        {
            _property = property;
            var label    = view.TreeItem;
            var checkbox = CreateCheckbox(label, _factory, id);

            _checkbox        = checkbox;
            checkbox.Checked = bool.Parse(property.ValueString);
            checkbox.OnCheckChanged.Subscribe(args =>
            {
                if (_actions.ActionIsExecuting)
                {
                    return;
                }
                _actions.RecordAction(new PropertyAction(property, args.Checked, _model));
            });
        }
Exemplo n.º 19
0
        public void AddEditorUI(string id, ITreeNodeView view, IProperty property)
        {
            _property = property;
            var label    = view.TreeItem;
            var combobox = GetCombobox(id, _factory, label.TreeNode.Parent);

            _text = combobox.TextBox;

            var list = _getOptions(property);

            combobox.DropDownPanelList.Items.AddRange(list);
            combobox.Z            = label.Z;
            combobox.TextBox.Text = property.ValueString.Humanize();
            if (list.Count > 5) //If more than 5 items in the dropdown, let's have it with textbox suggestions as user might prefer to type for filtering the dropdown
            {
                combobox.SuggestMode = ComboSuggest.Enforce;
            }
            var layout = view.HorizontalPanel.GetComponent <ITreeTableRowLayoutComponent>();

            if (layout != null)
            {
                layout.RestrictionList.RestrictionList.AddRange(new List <string> {
                    combobox.ID
                });
            }
            Action closeCombobox = () => (combobox.DropDownPanel.ScrollingPanel ?? combobox.DropDownPanel.ContentsPanel).Visible = false;

            combobox.DropDownPanelList.OnSelectedItemChanging.SubscribeToAsync(async args =>
            {
                if (_actions.ActionIsExecuting)
                {
                    return;
                }
                var returnValue = await _getValue(args.Item, property, closeCombobox);
                if (returnValue.ShouldCancel)
                {
                    args.ShouldCancel = true;
                    return;
                }
                _actions.RecordAction(new PropertyAction(property, returnValue.Value, _model));
            });
        }
Exemplo n.º 20
0
        private void setupCategoryRow(ITreeNodeView view)
        {
            var inspectorJump = _inspectorPanel.AddComponent <IJumpOffsetComponent>();
            var rowJump       = view.HorizontalPanel.AddComponent <IJumpOffsetComponent>();
            PropertyChangedEventHandler onPropertyChanged = (sender, args) =>
            {
                if (args.PropertyName != nameof(IJumpOffsetComponent.JumpOffset))
                {
                    return;
                }
                rowJump.JumpOffset = new PointF(-inspectorJump.JumpOffset.X, 0f);
            };

            inspectorJump.PropertyChanged += onPropertyChanged;
            view.ParentPanel.OnDisposed(() =>
            {
                inspectorJump.PropertyChanged -= onPropertyChanged;
                if (_resizeSubscribers.TryGetValue(view, out var subscriber))
                {
                    subscriber.Unsubscribe(_onResize);
                    _resizeSubscribers.Remove(view);
                }
            });
        }
Exemplo n.º 21
0
 public ResizeSubscriber(ITreeNodeView nodeView)
 {
     _nodeView       = nodeView;
     _resizeCallback = Resize;
 }
Exemplo n.º 22
0
 public void AddEditorUI(string id, ITreeNodeView view, IProperty property)
 {
     _editor.AddEditorUI(id, view, property);
 }
Exemplo n.º 23
0
 public ResizeSubscriber(ITreeNodeView nodeView)
 {
     _nodeView       = nodeView;
     _resizeCallback = new Action <float>(Resize);
 }
Exemplo n.º 24
0
 public int AddRoot(ITreeNodeView node)
 {
     return(tvRules.Nodes.Add(node as TreeNode));
 }
Exemplo n.º 25
0
 public void BeforeDisplayingNode(ITreeStringNode item, ITreeNodeView nodeView, bool isCollapsed, bool isHovered, bool isSelected)
 {
     _provider.BeforeDisplayingNode(item, nodeView, isCollapsed, isHovered, isSelected);
 }
 public ResizeSubscriber(ITreeNodeView nodeView)
 {
     _nodeView = nodeView;
 }