Ejemplo n.º 1
0
            public MarkerRow(
                Model3DAttachment.MarkerData marker,
                ObservableCollection <Model3DAttachment.MarkerData> markers) : base(marker, markers)
            {
                Layout = new HBoxLayout();
                var markerIdPropEditor = new StringPropertyEditor(
                    Decorate(new PropertyEditorParams(
                                 Header,
                                 Source.Marker,
                                 nameof(Marker.Id))));

                markerIdPropEditor.ContainerWidget.MinMaxWidth = AttachmentMetrics.EditorWidth;

                new IntPropertyEditor(
                    Decorate(new PropertyEditorParams(
                                 Header,
                                 Source.Marker,
                                 nameof(Marker.Frame))));

                var actionPropEditor = new EnumPropertyEditor <MarkerAction>(
                    Decorate(new PropertyEditorParams(
                                 Header,
                                 Source.Marker,
                                 nameof(Marker.Action))));

                actionPropEditor.ContainerWidget.MinMaxWidth = AttachmentMetrics.ControlWidth;
                var jumpToPropEditor = new ThemedComboBox {
                    LayoutCell = new LayoutCell(Alignment.Center)
                };
                var previousMarkerId = Source.Marker.Id;

                jumpToPropEditor.Changed += args => {
                    if ((string)args.Value != Source.Marker.JumpTo)
                    {
                        history.DoTransaction(() => Core.Operations.SetProperty.Perform(Source.Marker, nameof(Marker.JumpTo), args.Value));
                    }
                };
                Header.AddNode(jumpToPropEditor);
                jumpToPropEditor.Clicked += () => {
                    jumpToPropEditor.Items.Clear();
                    foreach (var item in markers)
                    {
                        jumpToPropEditor.Items.Add(new CommonDropDownList.Item(item.Marker.Id));
                    }
                };
                jumpToPropEditor.AddChangeWatcher(() => Source.Marker.JumpTo, v => jumpToPropEditor.Text = v);
                jumpToPropEditor.AddChangeWatcher(() => Source.Marker.Id, v => {
                    foreach (var m in markers.Where(md => md.Marker.JumpTo == previousMarkerId).Select(md => md.Marker))
                    {
                        m.JumpTo = v;
                    }
                    previousMarkerId = v;
                });
                jumpToPropEditor.Value       = Source.Marker.JumpTo;
                jumpToPropEditor.MinMaxWidth = AttachmentMetrics.ControlWidth;
                Header.AddNode(new BlendingCell(Source, nameof(Model3DAttachment.MarkerData.Blending)));
            }
Ejemplo n.º 2
0
        public void Setup(EnumPropertyEditor editor)
        {
            this._editor      = editor;
            this.Caption.Text = editor.Caption;
            this.ToolTip      = editor.Tooltip;

            //this._editor.
            foreach (var kv in this._editor.Variants)
            {
                string[] kk = kv.Split('¦');

                ComboBoxItem cbi = new ComboBoxItem();
                cbi.Content = kk[0];
                if (kk.Length < 2)
                {
                    cbi.Tag = kk[0];
                }
                else
                {
                    cbi.Tag = kk[1];
                }

                EnumCB.Items.Add(cbi);

                if (kk.Length < 2)
                {
                    if (this._editor.CurrentValue == kk[0])
                    {
                        EnumCB.SelectedItem = cbi;
                    }
                }
                else
                {
                    if (this._editor.CurrentValue == kk[1])
                    {
                        EnumCB.SelectedItem = cbi;
                    }
                }
            }
        }
Ejemplo n.º 3
0
            public MeshRow(Model3DAttachment.MeshOption mesh, ObservableCollection <Model3DAttachment.MeshOption> options) : base(mesh, options)
            {
                Layout  = new VBoxLayout();
                Padding = new Thickness(AttachmentMetrics.Spacing);
                var meshIdPropEditor = new StringPropertyEditor(
                    Decorate(new PropertyEditorParams(
                                 Header,
                                 mesh,
                                 nameof(Model3DAttachment.MeshOption.Id))));

                meshIdPropEditor.ContainerWidget.MinMaxWidth = AttachmentMetrics.EditorWidth;

                var cullModePropEditor = new EnumPropertyEditor <CullMode>(
                    Decorate(new PropertyEditorParams(
                                 Header,
                                 mesh,
                                 nameof(Model3DAttachment.MeshOption.CullMode))));

                cullModePropEditor.ContainerWidget.MinMaxWidth = AttachmentMetrics.EditorWidth;

                var opaquePropEditor = new BooleanPropertyEditor(
                    Decorate(new PropertyEditorParams(
                                 Header,
                                 mesh,
                                 nameof(Model3DAttachment.MeshOption.Opaque))));

                opaquePropEditor.ContainerWidget.MinMaxWidth = AttachmentMetrics.ControlWidth;

                var hitPropEditor = new BooleanPropertyEditor(
                    Decorate(new PropertyEditorParams(
                                 Header,
                                 mesh,
                                 nameof(Model3DAttachment.MeshOption.HitTestTarget))));

                hitPropEditor.ContainerWidget.MinMaxWidth = AttachmentMetrics.ControlWidth;
                CompoundPresenter.Add(Presenters.StripePresenter);
            }
Ejemplo n.º 4
0
        public void RetiraOpcaoCanceladoEmAtrasoDomainSituacaoCiclo()
        {
            if (View is DetailView)
            {
                DetailView detail = View as DetailView;

                EnumPropertyEditor editor = detail.FindItem("CsSituacaoCiclo") as EnumPropertyEditor;

                if (editor != null && editor.CurrentObject != null)
                {
                    var control = editor.Control as DevExpress.XtraEditors.ComboBoxEdit;

                    if (Ciclo.CsSituacaoCiclo != CsSituacaoCicloDomain.Cancelado)
                    {
                        control.Properties.Items.RemoveAt(5);
                    }

                    if (Ciclo.CsSituacaoCiclo != CsSituacaoCicloDomain.EmAtraso)
                    {
                        control.Properties.Items.RemoveAt(4);
                    }
                }
            }
        }
Ejemplo n.º 5
0
            public PropertyEditor CreateEditor(Type baseType, ProviderContext context)
            {
                PropertyEditor e = null;

                // Basic numeric data types
                if (baseType == typeof(sbyte) || baseType == typeof(byte) ||
                    baseType == typeof(short) || baseType == typeof(ushort) ||
                    baseType == typeof(int) || baseType == typeof(uint) ||
                    baseType == typeof(long) || baseType == typeof(ulong) ||
                    baseType == typeof(float) || baseType == typeof(double) || baseType == typeof(decimal))
                    e = new NumericPropertyEditor();
                // Basic data type: Boolean
                else if (baseType == typeof(bool))
                    e = new BoolPropertyEditor();
                // Basic data type: Flagged Enum
                else if (baseType.IsEnum && baseType.GetCustomAttributes(typeof(FlagsAttribute), true).Any())
                    e = new FlaggedEnumPropertyEditor();
                // Basic data type: Other Enums
                else if (baseType.IsEnum)
                    e = new EnumPropertyEditor();
                // Basic data type: String
                else if (baseType == typeof(string))
                    e = new StringPropertyEditor();
                // IList
                else if (typeof(System.Collections.IList).IsAssignableFrom(baseType))
                    e = new IListPropertyEditor();
                // IList
                else if (typeof(System.Collections.IDictionary).IsAssignableFrom(baseType))
                    e = new IDictionaryPropertyEditor();
                // Unknown data type
                else
                {
                    // Ask around if any sub-editor can handle it and choose the most specialized
                    var availSubProviders =
                        from p in this.subProviders
                        where p.IsResponsibleFor(baseType, context) != EditorPriority_None
                        orderby p.IsResponsibleFor(baseType, context) descending
                        select p;
                    IPropertyEditorProvider subProvider = availSubProviders.FirstOrDefault();
                    if (subProvider != null)
                    {
                        e = subProvider.CreateEditor(baseType, context);
                        e.EditedType = baseType;
                        return e;
                    }

                    // If not, default to reflection-driven MemberwisePropertyEditor
                    e = new MemberwisePropertyEditor();
                }

                e.EditedType = baseType;
                return e;
            }
Ejemplo n.º 6
0
        private int AddAsset(string id, string meta, string tags, ProjectModel projectModel, out Asset_PropertyEditor outEditor, int y)
        {
            m_properties[id] = "null";
            Asset_PropertyEditor editor = null;

            if (m_type == SceneViewPlugin.AssetType.Texture)
            {
                editor = new Asset_PropertyEditor(m_properties, id, m_type,
                                                  new Asset_PropertyEditor.ItemEditorInfo[] {
                    new Asset_PropertyEditor.ItemEditorInfo("path", typeof(Path_PropertyEditor))
                },
                                                  new Asset_PropertyEditor.ItemEditorInfo[] {
                    new Asset_PropertyEditor.ItemEditorInfo("smooth", typeof(Bool_PropertyEditor)),
                    new Asset_PropertyEditor.ItemEditorInfo("repeated", typeof(Bool_PropertyEditor))
                }, id, meta, tags);
                Path_PropertyEditor pathEditor = editor == null ? null : editor.GetMetaEditor <Path_PropertyEditor>("path");
                if (pathEditor != null)
                {
                    pathEditor.FileFilter = "Texture files (*.png)|*.png";
                    if (projectModel != null)
                    {
                        pathEditor.RootPath = projectModel.WorkingDirectory + @"\" + projectModel.ActiveTargetWorkingDirectory;
                    }
                }
            }
            else if (m_type == SceneViewPlugin.AssetType.Shader)
            {
                editor = new Asset_PropertyEditor(m_properties, id, m_type,
                                                  new Asset_PropertyEditor.ItemEditorInfo[] {
                    new Asset_PropertyEditor.ItemEditorInfo("vspath", typeof(Path_PropertyEditor)),
                    new Asset_PropertyEditor.ItemEditorInfo("fspath", typeof(Path_PropertyEditor))
                }, null, id, meta, tags);
                Path_PropertyEditor vspathEditor = editor == null ? null : editor.GetMetaEditor <Path_PropertyEditor>("vspath");
                if (vspathEditor != null)
                {
                    vspathEditor.FileFilter = "Vertex shader files (*.vs)|*.vs";
                    if (projectModel != null)
                    {
                        vspathEditor.RootPath = projectModel.WorkingDirectory + @"\" + projectModel.ActiveTargetWorkingDirectory;
                    }
                }
                Path_PropertyEditor fspathEditor = editor == null ? null : editor.GetMetaEditor <Path_PropertyEditor>("fspath");
                if (fspathEditor != null)
                {
                    fspathEditor.FileFilter = "Fragment shader files (*.fs)|*.fs";
                    if (projectModel != null)
                    {
                        fspathEditor.RootPath = projectModel.WorkingDirectory + @"\" + projectModel.ActiveTargetWorkingDirectory;
                    }
                }
            }
            else if (m_type == SceneViewPlugin.AssetType.Sound)
            {
                editor = new Asset_PropertyEditor(m_properties, id, m_type,
                                                  new Asset_PropertyEditor.ItemEditorInfo[] {
                    new Asset_PropertyEditor.ItemEditorInfo("path", typeof(Path_PropertyEditor))
                }, null, id, meta, tags);
                Path_PropertyEditor pathEditor = editor == null ? null : editor.GetMetaEditor <Path_PropertyEditor>("path");
                if (pathEditor != null)
                {
                    pathEditor.FileFilter = "Sound files (*.mp3)|*.mp3";
                    if (projectModel != null)
                    {
                        pathEditor.RootPath = projectModel.WorkingDirectory + @"\" + projectModel.ActiveTargetWorkingDirectory;
                    }
                }
            }
            else if (m_type == SceneViewPlugin.AssetType.Music)
            {
                editor = new Asset_PropertyEditor(m_properties, id, m_type,
                                                  new Asset_PropertyEditor.ItemEditorInfo[] {
                    new Asset_PropertyEditor.ItemEditorInfo("path", typeof(Path_PropertyEditor))
                }, null, id, meta, tags);
                Path_PropertyEditor pathEditor = editor == null ? null : editor.GetMetaEditor <Path_PropertyEditor>("path");
                if (pathEditor != null)
                {
                    pathEditor.FileFilter = "Music files (*.mp3)|*.mp3";
                    if (projectModel != null)
                    {
                        pathEditor.RootPath = projectModel.WorkingDirectory + @"\" + projectModel.ActiveTargetWorkingDirectory;
                    }
                }
            }
            else if (m_type == SceneViewPlugin.AssetType.Font)
            {
                editor = new Asset_PropertyEditor(m_properties, id, m_type,
                                                  new Asset_PropertyEditor.ItemEditorInfo[] {
                    new Asset_PropertyEditor.ItemEditorInfo("path", typeof(Path_PropertyEditor))
                }, null, id, meta, tags);
                Path_PropertyEditor pathEditor = editor == null ? null : editor.GetMetaEditor <Path_PropertyEditor>("path");
                if (pathEditor != null)
                {
                    pathEditor.FileFilter = "Font files (*.ttf)|*.ttf";
                    if (projectModel != null)
                    {
                        pathEditor.RootPath = projectModel.WorkingDirectory + @"\" + projectModel.ActiveTargetWorkingDirectory;
                    }
                }
            }
            else if (m_type == SceneViewPlugin.AssetType.CustomAsset)
            {
                editor = new Asset_PropertyEditor(m_properties, id, m_type,
                                                  new Asset_PropertyEditor.ItemEditorInfo[] {
                    new Asset_PropertyEditor.ItemEditorInfo("type", typeof(EnumPropertyEditor)),
                    new Asset_PropertyEditor.ItemEditorInfo("path", typeof(Path_PropertyEditor))
                }, null, id, meta, tags);
                EnumPropertyEditor typeEditor = editor == null ? null : editor.GetMetaEditor <EnumPropertyEditor>("type");
                if (typeEditor != null)
                {
                    List <string> values = SceneViewPlugin.ListCustomAssets();
                    typeEditor.ValuesSource = values == null ? null : values.ToArray();
                }
                Path_PropertyEditor pathEditor = editor == null ? null : editor.GetMetaEditor <Path_PropertyEditor>("path");
                if (pathEditor != null)
                {
                    pathEditor.FileFilter = "Custom asset files (*.*)|*.*";
                    if (projectModel != null)
                    {
                        pathEditor.RootPath = projectModel.WorkingDirectory + @"\" + projectModel.ActiveTargetWorkingDirectory;
                    }
                }
            }
            if (editor != null)
            {
                editor.Text = id;
                editor.UpdateEditorValue();
                editor.Top    = y;
                editor.Width  = Width;
                editor.Anchor = AnchorStyles.Top | AnchorStyles.Left | AnchorStyles.Right;
                Controls.Add(editor);
                editor.EditorJsonValueChangedCallback = this;
                y = editor.Bottom;
            }
            outEditor = editor;
            return(y + DEFAULT_SEPARATOR + DEFAULT_SEPARATOR);
        }
Ejemplo n.º 7
0
        HelpInfo IHelpProvider.ProvideHoverHelp(Point localPos, ref bool captured)
        {
            // A dropdown is opened. Provide dropdown help.
            IPopupControlHost dropdownEdit = this.FocusEditor as IPopupControlHost;

            if (dropdownEdit != null && dropdownEdit.IsDropDownOpened)
            {
                EnumPropertyEditor           enumEdit           = dropdownEdit as EnumPropertyEditor;
                FlaggedEnumPropertyEditor    enumFlagEdit       = dropdownEdit as FlaggedEnumPropertyEditor;
                ObjectSelectorPropertyEditor objectSelectorEdit = dropdownEdit as ObjectSelectorPropertyEditor;

                // Its able to provide help. Redirect.
                if (dropdownEdit is IHelpProvider)
                {
                    captured = true;
                    Point dropdownEditorPos = this.GetEditorLocation(dropdownEdit as PropertyEditor, true);
                    return((dropdownEdit as IHelpProvider).ProvideHoverHelp(new Point(localPos.X - dropdownEditorPos.X, localPos.Y - dropdownEditorPos.Y), ref captured));
                }
                // Special case: Its a known basic dropdown.
                else if (enumEdit != null)
                {
                    captured = true;
                    if (enumEdit.DropDownHoveredName != null)
                    {
                        return(HelpInfo.FromMember(enumEdit.EditedType.GetField(enumEdit.DropDownHoveredName, ReflectionHelper.BindAll)));
                    }
                    else
                    {
                        FieldInfo field = enumEdit.EditedType.GetField(enumEdit.DisplayedValue.ToString(), ReflectionHelper.BindAll);
                        if (field != null)
                        {
                            return(HelpInfo.FromMember(field));
                        }
                    }
                }
                else if (enumFlagEdit != null)
                {
                    captured = true;
                    if (enumFlagEdit.DropDownHoveredItem != null)
                    {
                        return(HelpInfo.FromMember(enumFlagEdit.EditedType.GetField(enumFlagEdit.DropDownHoveredItem.Caption, ReflectionHelper.BindAll)));
                    }
                    else
                    {
                        FieldInfo field = enumFlagEdit.EditedType.GetField(enumFlagEdit.DisplayedValue.ToString(), ReflectionHelper.BindAll);
                        if (field != null)
                        {
                            return(HelpInfo.FromMember(field));
                        }
                    }
                }
                else if (objectSelectorEdit != null)
                {
                    captured = true;
                    if (objectSelectorEdit.DropDownHoveredObject != null)
                    {
                        return(HelpInfo.FromObject(objectSelectorEdit.DropDownHoveredObject.Value));
                    }
                    else
                    {
                        return(HelpInfo.FromObject(objectSelectorEdit.DisplayedValue));
                    }
                }

                // No help available.
                return(null);
            }
            captured = false;

            // Pick an editor and see if it has access to an actual IHelpProvider
            PropertyEditor pickedEditor = this.PickEditorAt(localPos.X, localPos.Y, true);
            PropertyEditor helpEditor   = pickedEditor;

            while (helpEditor != null)
            {
                Point helpEditorPos = this.GetEditorLocation(helpEditor, true);
                if (helpEditor is IHelpProvider)
                {
                    IHelpProvider localProvider = helpEditor as IHelpProvider;
                    HelpInfo      localHelp     = localProvider.ProvideHoverHelp(new Point(localPos.X - helpEditorPos.X, localPos.Y - helpEditorPos.Y), ref captured);
                    if (localHelp != null)
                    {
                        return(localHelp);
                    }
                }
                helpEditor = helpEditor.ParentEditor;
            }

            // If not, default to member or type information
            if (pickedEditor != null)
            {
                if (!string.IsNullOrEmpty(pickedEditor.PropertyDesc))
                {
                    return(HelpInfo.FromText(pickedEditor.PropertyName, pickedEditor.PropertyDesc));
                }
                else if (pickedEditor.EditedMember != null)
                {
                    return(HelpInfo.FromMember(pickedEditor.EditedMember));
                }
                else if (pickedEditor.EditedType != null)
                {
                    return(HelpInfo.FromMember(pickedEditor.EditedType));
                }
            }

            return(null);
        }
Ejemplo n.º 8
0
            public PropertyEditor CreateEditor(Type baseType, ProviderContext context)
            {
                PropertyEditor e = null;

                // Basic numeric data types
                if (baseType == typeof(sbyte) || baseType == typeof(byte) ||
                    baseType == typeof(short) || baseType == typeof(ushort) ||
                    baseType == typeof(int) || baseType == typeof(uint) ||
                    baseType == typeof(long) || baseType == typeof(ulong) ||
                    baseType == typeof(float) || baseType == typeof(double) || baseType == typeof(decimal))
                {
                    e = new NumericPropertyEditor();
                }
                // Basic data type: Boolean
                else if (baseType == typeof(bool))
                {
                    e = new BoolPropertyEditor();
                }
                // Basic data type: Flagged Enum
                else if (baseType.IsEnum && baseType.GetCustomAttributes(typeof(FlagsAttribute), true).Any())
                {
                    e = new FlaggedEnumPropertyEditor();
                }
                // Basic data type: Other Enums
                else if (baseType.IsEnum)
                {
                    e = new EnumPropertyEditor();
                }
                // Basic data type: String
                else if (baseType == typeof(string))
                {
                    e = new StringPropertyEditor();
                }
                // IList
                else if (typeof(System.Collections.IList).IsAssignableFrom(baseType))
                {
                    e = new IListPropertyEditor();
                }
                // IList
                else if (typeof(System.Collections.IDictionary).IsAssignableFrom(baseType))
                {
                    e = new IDictionaryPropertyEditor();
                }
                // Unknown data type
                else
                {
                    // Ask around if any sub-editor can handle it and choose the most specialized
                    var availSubProviders =
                        from p in this.subProviders
                        where p.IsResponsibleFor(baseType, context) != EditorPriority_None
                        orderby p.IsResponsibleFor(baseType, context) descending
                        select p;

                    IPropertyEditorProvider subProvider = availSubProviders.FirstOrDefault();
                    if (subProvider != null)
                    {
                        e            = subProvider.CreateEditor(baseType, context);
                        e.EditedType = baseType;
                        return(e);
                    }

                    // If not, default to reflection-driven MemberwisePropertyEditor
                    e = new MemberwisePropertyEditor();
                }

                e.EditedType = baseType;
                return(e);
            }
Ejemplo n.º 9
0
        /// <summary>
        /// Returns a set of property editors that can be used to edit the given property type.
        /// </summary>
        private static PropertyEditorChain GetCachedEditors(Type propertyType, ICustomAttributeProvider attributes)
        {
            var cachedType = new CachedType {
                EditedType       = propertyType,
                EditedAttributes = attributes
            };

            PropertyEditorChain chain;

            if (_cachedPropertyEditors.TryGetValue(cachedType, out chain) == false)
            {
                chain = new PropertyEditorChain();
                _cachedPropertyEditors[cachedType] = chain;

                IPropertyEditor editor;

                if ((editor = AttributePropertyEditor.TryCreate(propertyType, attributes)) != null)
                {
                    chain.AddEditor(editor);
                }

                // arrays always need special handling; we don't support overriding them
                if ((editor = ArrayPropertyEditor.TryCreate(propertyType, attributes)) != null)
                {
                    chain.AddEditor(editor);
                }

                // support layout editors above custom editors
                // notably this enables the layout editor to be the highest-priority, ie, above inherited editors
                if ((editor = tkControlPropertyEditor.TryCreate(propertyType, attributes)) != null)
                {
                    chain.AddEditor(editor);
                }

                // user-defined property editors
                var added = new List <IPropertyEditor>();
                foreach (Type editorType in _editorTypes)
                {
                    editor = PropertyEditorTools.TryCreateEditor(propertyType, editorType, attributes, false);
                    if (editor != null)
                    {
                        added.Add(editor);
                    }
                }
                SortByPropertyTypeRelevance(added);
                foreach (IPropertyEditor toAdd in added)
                {
                    chain.AddEditor(toAdd);
                }

                // no user-defined editors so let's try to see if we can integrate a PropertyDrawer
                if (added.Count == 0)
                {
                    if ((editor = fiGenericPropertyDrawerPropertyEditorManager.TryCreate(propertyType)) != null)
                    {
                        chain.AddEditor(editor);
                    }
                }

                // enums come after generic & inherited to allow them to be overridden
                if ((editor = EnumPropertyEditor.TryCreate(propertyType)) != null)
                {
                    chain.AddEditor(editor);
                }

                // try and create an editor for nullable types
                if ((editor = NullablePropertyEditor.TryCreate(propertyType, attributes)) != null)
                {
                    chain.AddEditor(editor);
                }

                // try and create an editor for abstract/interface type
                if ((editor = AbstractTypePropertyEditor.TryCreate(propertyType)) != null)
                {
                    chain.AddEditor(editor);
                }

                // try and create a reflected editor; will only fail for arrays or collections,
                // which should be covered by the array editor
                if ((editor = ReflectedPropertyEditor.TryCreate(propertyType, attributes)) != null)
                {
                    chain.AddEditor(editor);
                }
            }

            return(chain);
        }