Beispiel #1
0
 public TextPropertyEditor(IPropertyEditorParams editorParams) : base(editorParams)
 {
     EditorContainer.AddNode(new Widget {
         Layout = new HBoxLayout(),
         Nodes  =
         {
             (editor         = editorParams.EditBoxFactory()),
             Spacer.HSpacer(4),
             (button         = new ThemedButton {
                 Text        = "...",
                 MinMaxWidth =                             20,
                 LayoutCell  = new LayoutCell(Alignment.Center)
             })
         }
     });
     editor.LayoutCell = new LayoutCell(Alignment.Center);
     editor.Editor.EditorParams.MaxLines = maxLines;
     editor.MinHeight += editor.TextWidget.FontHeight * (maxLines - 1);
     editor.Submitted += text => SetProperty(text);
     editor.AddChangeWatcher(CoalescedPropertyValue(), v => editor.Text = v);
     button.Clicked += () => {
         var window = new TextEditorDialog(editorParams.DisplayName ?? editorParams.PropertyName, editor.Text, (s) => {
             SetProperty(s);
         });
     };
 }
        public DictionaryPropertyEditor(IPropertyEditorParams editorParams, Func <Type, PropertyEditorParams, Widget, object, IEnumerable <IPropertyEditor> > populateEditors) : base(editorParams)
        {
            if (EditorParams.Objects.Skip(1).Any())
            {
                EditorContainer.AddNode(new Widget()
                {
                    Layout = new HBoxLayout(),
                    Nodes  = { new ThemedSimpleText {
                                   Text = "Edit of dictionary properties isn't supported for multiple selection.", ForceUncutText = false
                               } },
                    Presenter = new WidgetFlatFillPresenter(Theme.Colors.WarningBackground)
                });
                return;
            }
            this.populateEditors = populateEditors;
            dictionary           = PropertyValue(EditorParams.Objects.First()).GetValue();
            var addButton = new ThemedAddButton {
                Clicked = () => {
                    if (dictionary == null)
                    {
                        var pi = EditorParams.PropertyInfo;
                        var o  = EditorParams.Objects.First();
                        pi.SetValue(o, dictionary = Activator.CreateInstance <TDictionary>());
                    }
                    if (dictionary.ContainsKey(keyValueToAdd.Key))
                    {
                        AddWarning($"Key \"{keyValueToAdd.Key}\" already exists.", ValidationResult.Warning);
                        return;
                    }
                    using (Document.Current.History.BeginTransaction()) {
                        InsertIntoDictionary <TDictionary, string, TValue> .Perform(dictionary, keyValueToAdd.Key,
                                                                                    keyValueToAdd.Value);

                        ExpandableContent.Nodes.Add(CreateDefaultKeyValueEditor(keyValueToAdd.Key,
                                                                                keyValueToAdd.Value));
                        Document.Current.History.CommitTransaction();
                    }
                    keyValueToAdd.Value = DefaultValue;
                    keyValueToAdd.Key   = string.Empty;
                },
                LayoutCell = new LayoutCell(Alignment.LeftCenter),
            };
            var keyEditorContainer = CreateKeyEditor(editorParams, keyValueToAdd, s => keyValueToAdd.Key = s, addButton);

            ExpandableContent.Nodes.Add(keyEditorContainer);
            ExpandableContent.Nodes.Add(CreateValueEditor(editorParams, keyValueToAdd, populateEditors));
            Rebuild();
            EditorContainer.Tasks.AddLoop(() => {
                if (dictionary != null && ((ICollection)dictionary).Count != pairs.Count)
                {
                    Rebuild();
                }
            });
            var current = PropertyValue(EditorParams.Objects.First());

            ContainerWidget.AddChangeWatcher(() => current.GetValue(), d => {
                dictionary = d;
                Rebuild();
            });
        }
Beispiel #3
0
        public Vector2PropertyEditor(IPropertyEditorParams editorParams) : base(editorParams)
        {
            EditorContainer.AddNode(new Widget {
                Layout = new HBoxLayout {
                    DefaultCell = new DefaultLayoutCell(Alignment.Center), Spacing = 4
                },
                Nodes =
                {
                    //new SimpleText { Text = "X" },
                    (editorX = editorParams.NumericEditBoxFactory()),
                    // new SimpleText { Text = "Y" },
                    (editorY = editorParams.NumericEditBoxFactory()),
                    Spacer.HStretch(),
                }
            });
            var currentX = CoalescedPropertyComponentValue(v => v.X);
            var currentY = CoalescedPropertyComponentValue(v => v.Y);

            editorX.Submitted += text => SetComponent(editorParams, 0, editorX, currentX.GetValue());
            editorY.Submitted += text => SetComponent(editorParams, 1, editorY, currentY.GetValue());
            editorX.AddChangeLateWatcher(currentX, v => editorX.Text = v.IsDefined ? v.Value.ToString("0.###") : ManyValuesText);
            editorY.AddChangeLateWatcher(currentY, v => editorY.Text = v.IsDefined ? v.Value.ToString("0.###") : ManyValuesText);
            ManageManyValuesOnFocusChange(editorX, currentX);
            ManageManyValuesOnFocusChange(editorY, currentY);
        }
Beispiel #4
0
        public ThicknessPropertyEditor(IPropertyEditorParams editorParams) : base(editorParams)
        {
            EditorContainer.AddNode(new Widget {
                Layout = new HBoxLayout {
                    DefaultCell = new DefaultLayoutCell(Alignment.Center), Spacing = 4
                },
                Nodes =
                {
                    (editorLeft   = editorParams.NumericEditBoxFactory()),
                    (editorRight  = editorParams.NumericEditBoxFactory()),
                    (editorTop    = editorParams.NumericEditBoxFactory()),
                    (editorBottom = editorParams.NumericEditBoxFactory()),
                    Spacer.HStretch(),
                }
            });
            var currentLeft   = CoalescedPropertyComponentValue(v => v.Left);
            var currentRight  = CoalescedPropertyComponentValue(v => v.Right);
            var currentTop    = CoalescedPropertyComponentValue(v => v.Top);
            var currentBottom = CoalescedPropertyComponentValue(v => v.Bottom);

            editorLeft.Submitted   += text => SetComponent(editorParams, 0, editorLeft, currentLeft.GetValue());
            editorRight.Submitted  += text => SetComponent(editorParams, 1, editorRight, currentRight.GetValue());
            editorTop.Submitted    += text => SetComponent(editorParams, 2, editorTop, currentTop.GetValue());
            editorBottom.Submitted += text => SetComponent(editorParams, 3, editorBottom, currentBottom.GetValue());
            editorLeft.AddChangeLateWatcher(currentLeft, v => editorLeft.Text       = v.IsDefined ? v.Value.ToString("0.###") : ManyValuesText);
            editorRight.AddChangeLateWatcher(currentRight, v => editorRight.Text    = v.IsDefined ? v.Value.ToString("0.###") : ManyValuesText);
            editorTop.AddChangeLateWatcher(currentTop, v => editorTop.Text          = v.IsDefined ? v.Value.ToString("0.###") : ManyValuesText);
            editorBottom.AddChangeLateWatcher(currentBottom, v => editorBottom.Text = v.IsDefined ? v.Value.ToString("0.###") : ManyValuesText);
            ManageManyValuesOnFocusChange(editorLeft, currentLeft);
            ManageManyValuesOnFocusChange(editorRight, currentRight);
            ManageManyValuesOnFocusChange(editorTop, currentTop);
            ManageManyValuesOnFocusChange(editorBottom, currentBottom);
        }
        public Vector3PropertyEditor(IPropertyEditorParams editorParams) : base(editorParams)
        {
            EditorContainer.AddNode(new Widget {
                Layout = new HBoxLayout {
                    DefaultCell = new DefaultLayoutCell(Alignment.Center), Spacing = 4
                },
                Nodes =
                {
                    (editorX = editorParams.NumericEditBoxFactory()),
                    (editorY = editorParams.NumericEditBoxFactory()),
                    (editorZ = editorParams.NumericEditBoxFactory()),
                    Spacer.HStretch(),
                }
            });
            var currentX = CoalescedPropertyComponentValue(v => v.X);
            var currentY = CoalescedPropertyComponentValue(v => v.Y);
            var currentZ = CoalescedPropertyComponentValue(v => v.Z);

            editorX.Submitted += text => SetComponent(editorParams, 0, editorX, currentX.GetValue());
            editorY.Submitted += text => SetComponent(editorParams, 1, editorY, currentY.GetValue());
            editorZ.Submitted += text => SetComponent(editorParams, 2, editorZ, currentZ.GetValue());
            editorX.AddChangeWatcher(currentX, v => editorX.Text = v.ToString("0.###"));
            editorY.AddChangeWatcher(currentY, v => editorY.Text = v.ToString("0.###"));
            editorZ.AddChangeWatcher(currentZ, v => editorZ.Text = v.ToString("0.###"));
        }
Beispiel #6
0
        public EnumPropertyEditor(IPropertyEditorParams editorParams) : base(editorParams)
        {
            Selector            = editorParams.DropDownListFactory();
            Selector.LayoutCell = new LayoutCell(Alignment.Center);
            EditorContainer.AddNode(Selector);
            var propType      = editorParams.PropertyInfo.PropertyType;
            var fields        = propType.GetFields(BindingFlags.Public | BindingFlags.Static);
            var allowedFields = fields.Where(f => !Attribute.IsDefined((MemberInfo)f, typeof(TangerineIgnoreAttribute)));

            foreach (var field in allowedFields)
            {
                Selector.Items.Add(new CommonDropDownList.Item(field.Name, field.GetValue(null)));
            }
            Selector.Changed += a => {
                if (a.ChangedByUser)
                {
                    SetProperty((T)Selector.Items[a.Index].Value);
                }
            };
            Selector.AddChangeLateWatcher(CoalescedPropertyValue(), v => {
                if (v.IsDefined)
                {
                    Selector.Value = v.Value;
                }
                else
                {
                    Selector.Text = ManyValuesText;
                }
            });
        }
Beispiel #7
0
 public TriggerPropertyEditor(IPropertyEditorParams editorParams, bool multiline = false) : base(editorParams)
 {
     comboBox = new ThemedComboBox {
         LayoutCell = new LayoutCell(Alignment.Center)
     };
     EditorContainer.AddNode(comboBox);
     EditorContainer.AddNode(Spacer.HStretch());
     comboBox.Changed += ComboBox_Changed;
     foreach (var obj in editorParams.Objects)
     {
         var node = (Node)obj;
         foreach (var a in node.Animations)
         {
             foreach (var m in a.Markers.Where(i => i.Action != MarkerAction.Jump && !string.IsNullOrEmpty(i.Id)))
             {
                 var id = a.Id != null ? m.Id + '@' + a.Id : m.Id;
                 if (!comboBox.Items.Any(i => i.Text == id))
                 {
                     comboBox.Items.Add(new DropDownList.Item(id));
                 }
             }
         }
     }
     comboBox.AddChangeWatcher(CoalescedPropertyValue(), v => comboBox.Text = v);
 }
Beispiel #8
0
        public void Update(Guid PageId, ApiCall call)
        {
            var page = call.WebSite.SiteDb().Pages.Get(PageId);

            if (page == null)
            {
                return;
            }

            call.Context.SetItem <Page>(page);

            // pageid,...updates...
            if (string.IsNullOrEmpty(call.Context.Request.Body))
            {
                return;
            }
            var model = Lib.Helper.JsonHelper.Deserialize <dynamic>(call.Context.Request.Body);

            List <IInlineModel> updatemodels = new List <IInlineModel>();

            foreach (var item in model.updates)
            {
                string editortype  = item.editorType;
                var    modeltype   = EditorContainer.GetModelType(editortype);
                var    updatemodel = ((JObject)item).ToObject(modeltype) as IInlineModel;
                if (updatemodel != null)
                {
                    updatemodels.Add(updatemodel);
                }
            }

            UpdateManager.Execute(call.Context, updatemodels);
        }
        public TextPropertyEditor(IPropertyEditorParams editorParams) : base(editorParams)
        {
            ThemedButton button;

            EditorContainer.AddNode(new Widget {
                Layout = new HBoxLayout(),
                Nodes  =
                {
                    (editor         = editorParams.EditBoxFactory()),
                    Spacer.HSpacer(4),
                    (button         = new ThemedButton {
                        Text        = "...",
                        MinMaxWidth =                             20,
                        LayoutCell  = new LayoutCell(Alignment.Center)
                    })
                }
            });
            editor.LayoutCell = new LayoutCell(Alignment.Center);
            editor.Editor.EditorParams.MaxLines = maxLines;
            editor.MinHeight += editor.TextWidget.FontHeight * (maxLines - 1);
            var first     = true;
            var submitted = false;
            var current   = CoalescedPropertyValue();

            editor.AddChangeLateWatcher(current, v => editor.Text = v.IsDefined ? v.Value : ManyValuesText);
            button.Clicked += () => {
                var window = new TextEditorDialog(editorParams.DisplayName ?? editorParams.PropertyName, editor.Text, (s) => {
                    SetProperty(s);
                });
            };
            editor.Submitted += text => Submit();
            editor.AddChangeLateWatcher(() => editor.Text, text => {
                if (first)
                {
                    first = false;
                    return;
                }
                if (!editor.IsFocused())
                {
                    return;
                }
                if (submitted)
                {
                    Document.Current.History.Undo();
                }
                submitted = true;
                Submit();
            });
            editor.AddChangeLateWatcher(() => editor.IsFocused(), focused => {
                if (submitted)
                {
                    Document.Current.History.Undo();
                }
                if (!focused)
                {
                    submitted = false;
                }
            });
            ManageManyValuesOnFocusChange(editor, current);
        }
Beispiel #10
0
            int IVsPersistDocData.Close()
            {
                if (EditorProcess != null)
                {
                    DetachEditorWindow();
                    var editorProcess = EditorProcess;
                    EditorProcess = null;
                    var editorWindow = EditorWindow;
                    EditorWindow = IntPtr.Zero;

                    // Close editor window
                    _ = System.Threading.Tasks.Task.Run(() =>
                    {
                        NativeAPI.SendMessage(editorWindow, NativeAPI.WM_CLOSE, 0, 0);
                        if (!editorProcess.WaitForExit(500))
                        {
                            NativeAPI.ShowWindow(editorWindow,
                                                 NativeAPI.SW_RESTORE);
                            NativeAPI.SetForegroundWindow(editorWindow);
                        }
                    });
                }

                if (EditorContainer == null)
                {
                    if (EditorContainer != null)
                    {
                        EditorContainer.Dispose();
                        EditorContainer = null;
                    }
                }
                return(VSConstants.S_OK);
            }
Beispiel #11
0
        public FontPropertyEditor(IPropertyEditorParams editorParams) : base(editorParams)
        {
            selector            = editorParams.DropDownListFactory();
            selector.LayoutCell = new LayoutCell(Alignment.Center);
            EditorContainer.AddNode(selector);
            var propType = editorParams.PropertyInfo.PropertyType;
            var items    = AssetBundle.Current.EnumerateFiles(defaultFontDirectory).
                           Where(i => i.EndsWith(".fnt") || i.EndsWith(".tft") || i.EndsWith(".cft")).
                           Select(i => new DropDownList.Item(FontPool.ExtractFontNameFromPath(i, defaultFontDirectory)));

            foreach (var i in items)
            {
                selector.Items.Add(i);
            }

            var current = CoalescedPropertyValue().GetValue();

            selector.Text     = current.IsDefined ? GetFontName(current.Value) : ManyValuesText;
            selector.Changed += a => {
                SetProperty(new SerializableFont((string)a.Value));
            };
            selector.AddChangeLateWatcher(CoalescedPropertyValue(), i => {
                selector.Text = i.IsDefined ? GetFontName(i.Value): ManyValuesText;
            });
        }
        public QuaternionPropertyEditor(IPropertyEditorParams editorParams) : base(editorParams)
        {
            EditorContainer.AddNode(new Widget {
                Layout = new HBoxLayout {
                    DefaultCell = new DefaultLayoutCell(Alignment.Center), Spacing = 4
                },
                Nodes =
                {
                    (editorX = editorParams.NumericEditBoxFactory()),
                    (editorY = editorParams.NumericEditBoxFactory()),
                    (editorZ = editorParams.NumericEditBoxFactory()),
                    Spacer.HStretch(),
                }
            });
            var current = CoalescedPropertyValue();

            editorX.Submitted += text => SetComponent(editorParams, 0, editorX, current.GetValue());
            editorY.Submitted += text => SetComponent(editorParams, 1, editorY, current.GetValue());
            editorZ.Submitted += text => SetComponent(editorParams, 2, editorZ, current.GetValue());
            editorX.AddChangeWatcher(current, v => {
                var ea       = v.ToEulerAngles() * Mathf.RadToDeg;
                editorX.Text = RoundAngle(ea.X).ToString("0.###");
                editorY.Text = RoundAngle(ea.Y).ToString("0.###");
                editorZ.Text = RoundAngle(ea.Z).ToString("0.###");
            });
        }
Beispiel #13
0
        /// <summary>
        /// Получить название колонки дерева или таблицы для отображения в форме кастомизации
        /// </summary>
        /// <param name="editor">Контрол</param>
        /// <param name="col">Колонка</param>
        /// <returns>Дружественное пользователю название</returns>
        public static string ColumnToString(this EditorContainer editor, object col)
        {
            var tree = editor as TreeList;

            if (tree != null)
            {
                var column = (DataColumnInfo)col;
                var result = column.Caption;
                return(String.IsNullOrEmpty(result) ? column.ColumnName : result);
            }
            var grid = editor as GridControl;

            if (grid != null)
            {
                var column = (GridColumn)col;
                var result = column.Caption;
                if (!Regex.IsMatch(result, "^[a-zA-Z0-9]*$"))
                {
                    return(String.IsNullOrEmpty(result) ? column.FieldName : result);
                }
                var table = grid.DataSource as DataTable;
                if (table != null)
                {
                    result = table.Columns[column.FieldName].Caption;
                }
                return(String.IsNullOrEmpty(result) ? column.FieldName : result);
            }
            throw new ArgumentException("Неизвестный тип контрола");
        }
Beispiel #14
0
        } // IsDataChanged

        #endregion

        protected void SetDataChanged()
        {
            IsDataChanged = true;
            if (EditorContainer != null)
            {
                EditorContainer.SetDataChanged();
            } // if
        }     // SetDataChanged
Beispiel #15
0
        protected FilePropertyEditor(IPropertyEditorParams editorParams, string[] allowedFileTypes) : base(editorParams)
        {
            EditorContainer.AddNode(new Widget {
                Layout = new HBoxLayout(),
                Nodes  =
                {
                    (editor         = editorParams.EditBoxFactory()),
                    Spacer.HSpacer(4),
                    (button         = new ThemedButton {
                        Text        = "...",
                        MinMaxWidth =                             20,
                        LayoutCell  = new LayoutCell(Alignment.Center)
                    })
                }
            });
            editor.LayoutCell = new LayoutCell(Alignment.Center);
            editor.Submitted += text => SetComponent(text);
            bool textValid = true;

            editor.AddChangeWatcher(() => editor.Text, text => textValid = IsValid(text));
            editor.CompoundPostPresenter.Add(new SyncDelegatePresenter <EditBox>(editBox => {
                if (!textValid)
                {
                    editBox.PrepareRendererState();
                    Renderer.DrawRect(Vector2.Zero, editBox.Size, Color4.Red.Transparentify(0.8f));
                }
            }));
            button.Clicked += () => {
                var dlg = new FileDialog {
                    AllowedFileTypes = allowedFileTypes,
                    Mode             = FileDialogMode.Open,
                    InitialDirectory = Directory.Exists(LastOpenedDirectory) ? LastOpenedDirectory : Project.Current.GetSystemDirectory(Document.Current.Path),
                };
                if (dlg.RunModal())
                {
                    SetFilePath(dlg.FileName);
                    LastOpenedDirectory = Project.Current.GetSystemDirectory(dlg.FileName);
                }
            };
            ExpandableContent.Padding = new Thickness(24, 10, 2, 2);
            var prefixEditor = new StringPropertyEditor(new PropertyEditorParams(ExpandableContent, prefix, nameof(PrefixData.Prefix))
            {
                LabelWidth = 180
            });

            prefix.Prefix = GetLongestCommonPrefix(GetPaths());
            ContainerWidget.AddChangeWatcher(() => prefix.Prefix, v => {
                string oldPrefix = GetLongestCommonPrefix(GetPaths());
                if (oldPrefix == v)
                {
                    return;
                }
                SetPathPrefix(oldPrefix, v);
                prefix.Prefix = v.Trim('/');
            });
        }
Beispiel #16
0
        public FloatPropertyEditor(IPropertyEditorParams editorParams) : base(editorParams)
        {
            editor = editorParams.NumericEditBoxFactory();
            EditorContainer.AddNode(editor);
            EditorContainer.AddNode(Spacer.HStretch());
            var current = CoalescedPropertyValue();

            editor.Submitted += text => SetComponent(text, current);
            editor.AddChangeWatcher(current, v => editor.Text = v.ToString("0.###"));
        }
Beispiel #17
0
 public StringPropertyEditor(IPropertyEditorParams editorParams, bool multiline = false) : base(editorParams)
 {
     editor            = editorParams.EditBoxFactory();
     editor.LayoutCell = new LayoutCell(Alignment.Center);
     editor.Editor.EditorParams.MaxLines = multiline ? maxLines : 1;
     editor.MinHeight += multiline ? editor.TextWidget.FontHeight * (maxLines - 1) : 0;
     EditorContainer.AddNode(editor);
     editor.Submitted += text => SetProperty(text);
     editor.AddChangeWatcher(CoalescedPropertyValue(), v => editor.Text = v);
 }
Beispiel #18
0
 public NodeIdPropertyEditor(IPropertyEditorParams editorParams, bool multiline = false) : base(editorParams)
 {
     editor            = editorParams.EditBoxFactory();
     editor.LayoutCell = new LayoutCell(Alignment.Center);
     editor.Editor.EditorParams.MaxLines = 1;
     EditorContainer.AddNode(editor);
     editor.Submitted += SetValue;
     editor.AddChangeLateWatcher(CoalescedPropertyValue(), v => editor.Text = v.IsDefined ? v.Value : ManyValuesText);
     ManageManyValuesOnFocusChange(editor, CoalescedPropertyValue());
 }
Beispiel #19
0
        public FloatPropertyEditor(IPropertyEditorParams editorParams) : base(editorParams)
        {
            editor = editorParams.NumericEditBoxFactory();
            EditorContainer.AddNode(editor);
            EditorContainer.AddNode(Spacer.HStretch());
            var current = CoalescedPropertyValue();

            editor.Submitted += text => SetComponent(text, current.GetValue());
            editor.AddChangeLateWatcher(current, v => editor.Text = v.IsDefined ? v.Value.ToString("0.###") : ManyValuesText);
            ManageManyValuesOnFocusChange(editor, current);
        }
 public BezierEasingPropertyEditor(IPropertyEditorParams editorParams) : base(editorParams)
 {
     EditorContainer.AddNode(new EasingEditorPanel(this, CoalescedPropertyValue(), (BezierEasing p) => SetProperty(p)).Widget);
     EditorContainer.Gestures.Add(new ClickGesture(1, () => {
         var reset = new Command("Reset", () => {
             DoTransaction(() => SetProperty <BezierEasing>(_ => BezierEasing.Default));
         });
         new Menu {
             reset
         }.Popup();
     }));
 }
        /// <summary>
        /// Создать настройки меню для сохранения и загрузки информации о внешнем виде таблиц и деревьев
        /// </summary>
        /// <param name="_editor">Таблица или дерево</param>
        /// <param name="_menu">Меню</param>
        public static void DXCreateLayoutMenuItems(EditorContainer _editor, ref DXPopupMenu _menu)
        {
            var layoutWorker = _editor as IShowLayoutWorkMenu;

            if (layoutWorker != null && !layoutWorker.GetShowLayoutWorkMenu())
            {
                return;
            }
            var instance = new DXCustomMenuCreator(_editor, ref _menu);

            instance.DXCreateLayoutMenuItems();
        }
Beispiel #22
0
 public RenderTexturePropertyEditor(IPropertyEditorParams editorParams) : base(editorParams)
 {
     editor            = editorParams.EditBoxFactory();
     editor.IsReadOnly = true;
     editor.LayoutCell = new LayoutCell(Alignment.Center);
     EditorContainer.AddNode(editor);
     editor.AddChangeWatcher(CoalescedPropertyValue(), v =>
                             editor.Text = v == null ?
                                           "RenderTexture (null)" :
                                           $"RenderTexture ({v.ImageSize.Width}x{v.ImageSize.Height})"
                             );
 }
		public AnchorsPropertyEditor(IPropertyEditorParams editorParams) : base(editorParams)
		{
			group = new Widget { Layout = new HBoxLayout { DefaultCell = new DefaultLayoutCell(Alignment.Center), Spacing = 4 } };
			EditorContainer.AddNode(group);
			firstButton = AddButton(Anchors.Left, "Anchor to the left");
			AddButton(Anchors.Right, "Anchor to the right");
			AddButton(Anchors.Top, "Anchor to the top");
			AddButton(Anchors.Bottom, "Anchor to the bottom");
			AddButton(Anchors.CenterH, "Anchor to the center horizontally");
			AddButton(Anchors.CenterV, "Anchor to the center vertically");
			group.AddNode(Spacer.HStretch());
		}
Beispiel #24
0
        public StringPropertyEditor(IPropertyEditorParams editorParams, bool multiline = false) : base(editorParams)
        {
            editor            = editorParams.EditBoxFactory();
            editor.LayoutCell = new LayoutCell(Alignment.Center);
            editor.Editor.EditorParams.MaxLines = multiline ? maxLines : 1;
            editor.MinHeight += multiline ? editor.TextWidget.FontHeight * (maxLines - 1) : 0;
            EditorContainer.AddNode(editor);
            editor.Submitted += text => SetProperty(text);
            var current = CoalescedPropertyValue();

            editor.AddChangeLateWatcher(current, v => editor.Text = v.IsDefined ? v.Value : ManyValuesText);
            ManageManyValuesOnFocusChange(editor, current);
        }
Beispiel #25
0
 protected override void Dispose(bool disposing)
 {
     try {
         if (disposing)
         {
             EditorContainer?.Dispose();
             EditorContainer = null;
             GC.SuppressFinalize(this);
         }
     } finally {
         base.Dispose(disposing);
     }
 }
Beispiel #26
0
 public AlignmentPropertyEditor(IPropertyEditorParams editorParams) : base(editorParams)
 {
     EditorContainer.AddNode(new Widget {
         Layout = new HBoxLayout {
             DefaultCell = new DefaultLayoutCell(Alignment.Center), Spacing = 4
         },
         Nodes =
         {
             (selectorH = editorParams.DropDownListFactory()),
             (selectorV = editorParams.DropDownListFactory())
         }
     });
     var items = new [] {
		public RenderTexturePropertyEditor(IPropertyEditorParams editorParams) : base(editorParams)
		{
			var editor = editorParams.EditBoxFactory();
			editor.IsReadOnly = true;
			editor.LayoutCell = new LayoutCell(Alignment.Center);
			EditorContainer.AddNode(editor);
			var current = CoalescedPropertyValue();
			editor.AddChangeLateWatcher(current, v =>
				editor.Text = v.Value == null ?
					"RenderTexture (null)" :
					$"RenderTexture ({v.Value.ImageSize.Width}x{v.Value.ImageSize.Height})"
			);
			ManageManyValuesOnFocusChange(editor, current);
		}
Beispiel #28
0
        public NodeReferencePropertyEditor(IPropertyEditorParams editorParams) : base(editorParams)
        {
            var propName = editorParams.PropertyName;

            if (propName.EndsWith("Ref"))
            {
                PropertyLabel.Text = propName.Substring(0, propName.Length - 3);
            }
            editor            = editorParams.EditBoxFactory();
            editor.LayoutCell = new LayoutCell(Alignment.Center);
            EditorContainer.AddNode(editor);
            editor.Submitted += text => SetComponent(text);
            editor.AddChangeWatcher(CoalescedPropertyValue(), v => editor.Text = v?.Id);
        }
Beispiel #29
0
        public Color4PropertyEditor(IPropertyEditorParams editorParams) : base(editorParams)
        {
            ColorBoxButton colorBox;
            var            panel        = new ColorPickerPanel();
            var            currentColor = CoalescedPropertyValue(Color4.White).DistinctUntilChanged();

            EditorContainer.AddNode(new Widget {
                Layout = new HBoxLayout {
                    DefaultCell = new DefaultLayoutCell(Alignment.Center)
                },
                Nodes =
                {
                    (editor   = editorParams.EditBoxFactory()),
                    Spacer.HSpacer(4),
                    (colorBox = new ColorBoxButton(currentColor)),
                    CreatePipetteButton(),
                    Spacer.HStretch(),
                },
            });
            ExpandableContent.AddNode(panel.Widget);
            panel.Widget.Padding = panel.Widget.Padding + new Thickness(right: 12.0f);
            panel.Widget.Tasks.Add(currentColor.Consume(v => {
                if (panel.Color != v)
                {
                    panel.Color = v;
                }
                Changed?.Invoke();
            }));
            panel.Changed += () => {
                EditorParams.History?.RollbackTransaction();
                SetProperty(panel.Color);
            };
            panel.DragStarted += () => {
                EditorParams.History?.BeginTransaction();
                lastColor = panel.Color;
            };
            panel.DragEnded += () => {
                if (panel.Color != lastColor)
                {
                    EditorParams.History?.CommitTransaction();
                }
                EditorParams.History?.EndTransaction();
            };
            colorBox.Clicked += () => Expanded = !Expanded;
            var currentColorString = currentColor.Select(i => i.ToString(Color4.StringPresentation.Dec));

            editor.Submitted += text => SetComponent(text, currentColorString);
            editor.Tasks.Add(currentColorString.Consume(v => editor.Text = v));
            editor.AddChangeWatcher(() => editor.Text, value => CheckEditorText(value, editor));
        }
Beispiel #30
0
        public SBytePropertyEditor(IPropertyEditorParams editorParams) : base(editorParams)
        {
            editor = editorParams.NumericEditBoxFactory();
            // TODO: move IsReadOnly to IPropertyEditor
            editor.IsReadOnly = editorParams.PropertyInfo.GetCustomAttribute <TangerineReadOnlyAttribute>(true) != null;
            editor.LayoutCell = new LayoutCell(Alignment.Center);
            EditorContainer.AddNode(editor);
            EditorContainer.AddNode(Spacer.HStretch());
            var current = CoalescedPropertyValue();

            editor.Submitted += text => SetComponent(text, current.GetValue());
            editor.AddChangeLateWatcher(current, v => editor.Text = v.IsDefined ? v.Value.ToString() : ManyValuesText);
            ManageManyValuesOnFocusChange(editor, current);
        }
Beispiel #31
0
 public QuickHideEdit(EditorContainer _editor)
 {
     editor = _editor;
     if (TreeList != null)
     {
         Properties.LookAndFeel.Assign(TreeList.ElementsLookAndFeel);
     }
     else if (GridControl != null)
     {
         Properties.LookAndFeel.Assign(GridControl.MainView.GetLookAndFeel());
     }
     MakeUnEnable();
     Size = new Size(EditorWidth, EditorHeight);
     BorderStyle = BorderStyles.Simple;
     CreatePopupControl();
 }
 private DXCustomMenuCreator(EditorContainer _editor, ref DXPopupMenu _menu)
 {
     editor = _editor;
     menu = _menu;
     controlForm = editor.FindForm();
     dxsmiSaved = new DXSubMenuItem("Сохраненные состояния")
     {
         Image = Resources.layout_save
     };
     bbiDeleteStates = new DXMenuItem("Удалить выбранные")
     {
         Image = Resources.Remove
     };
     dxsmiRemove = new DXSubMenuItem("Удалить состояния")
     {
         Image = Resources.layout_delete
     };
 }
 /// <summary>
 /// Создать настройки меню для сохранения и загрузки информации о внешнем виде таблиц и деревьев
 /// </summary>
 /// <param name="_editor">Таблица или дерево</param>
 /// <param name="_menu">Меню</param>
 public static void DXCreateLayoutMenuItems(EditorContainer _editor, ref DXPopupMenu _menu)
 {
     var layoutWorker = _editor as IShowLayoutWorkMenu;
     if (layoutWorker != null && !layoutWorker.GetShowLayoutWorkMenu())
     {
         return;
     }
     var instance = new DXCustomMenuCreator(_editor, ref _menu);
     instance.DXCreateLayoutMenuItems();
 }