static IControl CreateGradientRow(IElement linearGradient, IEditorFactory editors)
        {
            var name = linearGradient.UxName();

            var stops = linearGradient.Children
                        .Where(e => e.Is("Fuse.Drawing.GradientStop"));

            return(Layout.StackFromTop(
                       editors.NameRow("Gradient Name", name),

                       Spacer.Medium,

                       stops
                       .PoolPerElement((index, gradientStop) =>
                                       CreateGradientStopRow(index, gradientStop.Switch(), editors))
                       .StackFromTop(separator: () => Spacer.Small),

                       Spacer.Medium,

                       Buttons.DefaultButton(
                           text: "Remove Gradient Stop",
                           cmd: stops
                           .Select(s =>
                                   s.LastOrNone().MatchWith(
                                       some: stop => Command.Enabled(() => stop.Cut()),
                                       none: () => Command.Disabled))
                           .Switch()),

                       Spacer.Small,

                       Buttons.DefaultButton(
                           text: "Add Gradient Stop",
                           cmd: Command.Enabled(() => linearGradient.Paste(SourceFragment.FromString("<GradientStop Offset=\"1\"/>"))))));
        }
        static IControl CreateGradientStopRow(int index, IElement gradientStop, IEditorFactory editors)
        {
            var stopName   = gradientStop.UxName();
            var stopOffset = gradientStop.GetDouble("Offset", 0.0);
            var stopColor  = gradientStop.GetColor("Color", Color.White);

            var colorEditor  = editors.Color(stopColor);
            var offsetEditor = editors.Field(stopOffset, deferEdit: true);
            var nameEditor   = editors.Field(stopName, placeholderText: "Stop name");

            IControl colorControl  = colorEditor;
            IControl offsetControl = offsetEditor;
            IControl nameControl   = nameEditor;

            if (index == 0)
            {
                colorControl  = colorEditor.WithLabelAbove("Color");
                offsetControl = offsetEditor.WithLabelAbove("Offset");
                nameControl   = nameEditor.WithLabelAbove("Name");
            }

            return(Layout.Dock()
                   .Left(colorControl)
                   .Left(Spacer.Small)
                   .Left(offsetControl.WithWidth(CellLayout.HalfCellWidth))
                   .Left(Spacer.Small)
                   .Fill(nameControl));
        }
Beispiel #3
0
        public static IControl Create(IProject project, IElement element, IEditorFactory editors)
        {
            var file        = element.GetString("File", "");
            var stretchMode = element.GetEnum("StretchMode", StretchMode.Uniform);

            var stretchDirection = element.GetEnum("StretchDirection", StretchDirection.Both);
            var stretchSizing    = element.GetEnum("StretchSizing", StretchSizing.Zero);

            return(Layout.StackFromTop(
                       Spacer.Medium,

                       editors.FilePath(
                           attribute: file,
                           projectRoot: project.RootDirectory,
                           fileFilters: new[] { new FileFilter("Image Files", ".png", ".jpg", ".jpeg") },
                           placeholderText: "Path to image file")
                       .WithInspectorPadding(),

                       Spacer.Medium,

                       editors.Dropdown(stretchMode)
                       .WithLabel("Stretch Mode")
                       .WithInspectorPadding(),

                       Spacer.Medium,

                       Layout.Dock()
                       .Left(editors.Dropdown(stretchDirection).WithLabelAbove("Stretch Direction"))
                       .Right(editors.Dropdown(stretchSizing).WithLabelAbove("Stretch Sizing"))
                       .Fill().WithInspectorPadding(),

                       Spacer.Medium)
                   .MakeCollapsable(RectangleEdge.Bottom, element.Is("Fuse.Controls.Image")));
        }
Beispiel #4
0
        static IControl Create <T>(
            IAttribute <T> attribute,
            IProperty <object> objectValue,
            IObservable <IEnumerable <object> > objectValues,
            IEditorFactory editors,
            Text placeholderText = default(Text))
        {
            var stroke     = Theme.FieldStroke;
            var arrowBrush = attribute.IsReadOnly.Select(ro => ro ? Theme.FieldStroke.Brush : Theme.Active).Switch();

            return(Layout.Dock()
                   .Right(editors.ExpressionButton(attribute))
                   .Fill(DropDown.Create(objectValue, objectValues, nativeLook: false)
                         .WithOverlay(
                             Layout.Dock()
                             .Right(Arrow
                                    .WithoutShaft(RectangleEdge.Bottom, SymbolSize.Small, arrowBrush)
                                    .Center().WithWidth(21)
                                    .WithBackground(Theme.PanelBackground))
                             .Right(Separator.Line(stroke))
                             .Fill(TextBox.Create(
                                       attribute.StringValue,
                                       foregroundColor: Theme.DefaultText)
                                   .WithPlaceholderText(attribute.HasLocalValue(), placeholderText)
                                   .WithBackground(Theme.FieldBackground))
                             .WithPadding(new Thickness <Points>(1))
                             .WithOverlay(Shapes.Rectangle(stroke: stroke)))
                         .WithHeight(CellLayout.DefaultCellHeight)
                         .WithWidth(CellLayout.FullCellWidth)));
        }
Beispiel #5
0
        static IControl CreateShadowRow(IElement shadow, IEditorFactory editors)
        {
            var name     = shadow.UxName();
            var angle    = shadow.GetAngle("Angle", 90);
            var color    = shadow.GetColor("Color", Color.Black);
            var distance = shadow.GetPoints("Distance", 0);
            var size     = shadow.GetPoints("Size", 5);

            return(Layout.StackFromTop(
                       editors.NameRow("Shadow Name", name),

                       Spacer.Medium,

                       Layout.Dock()
                       .Left(editors.Color(color).WithLabelAbove("Color"))
                       // TODO: Changing from Background to PerPixel crashes fuselibs at runtime (09-05-2017)
                       //.Right(editors.Dropdown(mode).WithLabelAbove("Mode"))
                       .Right(editors.Field(distance).WithLabelAbove("Distance").WithWidth(CellLayout.HalfCellWidth))
                       .Right(Spacer.Medium)
                       .Right(editors.Field(size).WithLabelAbove("Size").WithWidth(CellLayout.HalfCellWidth))
                       .Fill(Spacer.Medium),

                       Spacer.Medium,
                       Layout.Dock()
                       .Left(editors.Label("Angle", angle))
                       .Left(Spacer.Medium)
                       .Right(editors.Field(angle).WithWidth(CellLayout.HalfCellWidth))
                       .Right(Spacer.Medium)
                       .Fill(editors.Slider(angle, min: 0.0, max: 360.0))));
        }
Beispiel #6
0
        public static IControl Create(IElement element, IEditorFactory editors)
        {
            element = element.As("Fuse.Elements.Element");

            var snapMin = element.GetBoolean("SnapMinTransform", false);
            var snapMax = element.GetBoolean("SnapMaxTransform", false);
            var origin  = element.GetEnum("TransformOrigin", TransformOrigin.Center);

            return(Layout.StackFromTop(
                       Separator.Weak,
                       Spacer.Medium,

                       editors.Dropdown(origin).WithLabel("Transform Origin")
                       .WithInspectorPadding(),

                       Spacer.Medium,

                       Layout.StackFromTop(
                           editors.Switch(snapMin).WithLabel("Snap to Min Transform"),
                           Spacer.Medium,
                           editors.Switch(snapMax).WithLabel("Snap to Max Transform"),
                           Spacer.Medium)
                       .MakeCollapsable(RectangleEdge.Top, element.Is("Fuse.Controls.ScrollViewBase"))
                       .WithInspectorPadding(),

                       RotationSection.Create(element, editors),
                       Separator.Weak));
        }
Beispiel #7
0
        static IControl CreateSolidColorRow(IElement solidColor, IEditorFactory editors)
        {
            var name    = solidColor.UxName();
            var color   = solidColor.GetColor("Color", Color.White);
            var opacity = solidColor.GetDouble("Opacity", 1.0);

            //var mode = solidColor.GetEnum("BlendMode", BlendMode.Normal);

            return(Layout.StackFromTop(
                       editors.NameRow("Brush Name", name),

                       Spacer.Medium,

                       Layout.Dock()
                       .Left(editors.Color(color).WithLabelAbove("Color"))
                       //.Right(editors.Dropdown(mode).WithLabelAbove("Blend Mode"))
                       .Fill(Spacer.Medium),

                       Spacer.Medium,

                       Layout.Dock()
                       .Left(editors.Label("Opacity", opacity))
                       .Left(Spacer.Medium)
                       .Right(editors.Field(opacity).WithWidth(CellLayout.HalfCellWidth))
                       .Right(Spacer.Medium)
                       .Fill(editors.Slider(opacity, min: 0.0, max: 1.0))));
        }
Beispiel #8
0
        public static IControl Create <T>(
            IEditorFactory editors,
            IAttribute <T> property,
            Optional <Command> onFocused = default(Optional <Command>),
            Text placeholderText         = default(Text),
            Text toolTip   = default(Text),
            bool deferEdit = false)
        {
            var stringValue = property.StringValue;
            var hasValue    = property.HasLocalValue();

            if (deferEdit)
            {
                stringValue = stringValue.Deferred();
                hasValue    = stringValue.Select(s => s != "");
            }

            return(Layout.Dock()
                   .Right(editors.ExpressionButton(property))
                   .Fill(TextBox.Create(
                             stringValue,
                             onFocused: onFocused,
                             foregroundColor: Theme.DefaultText)
                         .WithPlaceholderText(hasValue, placeholderText)
                         .SetToolTip(toolTip).WithBorderAndSize())
                   );
        }
 public PropertiesPanelViewModel(IEditorFactory editorFactory)
     : base("Properties")
 {
     _editorFactory = editorFactory;
     RuleProperties = new BindableCollection <IEditor>();
     IsExpanded     = true;
 }
Beispiel #10
0
 public static IControl NameRow(this IEditorFactory editors, string name, IAttribute <string> property, bool deferEdit = false)
 {
     return(Layout.Dock()
            .Left(editors.Label(name, property).WithWidth(CellLayout.FullCellWidth))
            .Left(Spacer.Small)
            .Fill(editors.Field(property, placeholderText: "Add name here", deferEdit: deferEdit)));
 }
Beispiel #11
0
        public static IControl Create(IElement element, IEditorFactory editors)
        {
            var spacing = element.GetPoints("CellSpacing", 0.0);
            var order   = element.GetEnum("ChildOrder", GridChildOrder.RowMajor);

            return(Layout.StackFromTop(
                       Spacer.Medium,

                       Layout.StackFromLeft(
                           editors.Field(spacing).WithLabelAbove("Cell Spacing"),
                           Spacer.Medium,
                           editors.Dropdown(order).WithLabelAbove("Child Order"))
                       .WithInspectorPadding(),

                       Spacer.Medium, Separator.Weak, Spacer.Medium,

                       Dimension(element, editors, "Row"),

                       Spacer.Medium, Separator.Weak, Spacer.Medium,

                       Dimension(element, editors, "Column"),

                       Spacer.Medium)
                   .MakeCollapsable(RectangleEdge.Bottom, element.Is("Fuse.Controls.Grid")));
        }
Beispiel #12
0
        public static IControl Create(IProject project, IElement element, IEditorFactory editors)
        {
            var placeholder      = element.GetString("PlaceholderText", "");
            var placeholdercolor = element.GetColor("PlaceholderColor", Color.Black);

            return(Layout.StackFromTop(
                       Spacer.Medium,

                       TextSection.CreateEditors(project, element, editors)
                       .WithInspectorPadding(),

                       Spacer.Medium,

                       editors.Field(placeholder)
                       .WithLabel("Placeholder")
                       .WithInspectorPadding(),

                       Spacer.Medium,

                       editors.Color(placeholdercolor)
                       .WithLabel("Placeholder Color")
                       .WithInspectorPadding(),

                       Spacer.Medium)
                   .MakeCollapsable(RectangleEdge.Bottom, element.Is("Fuse.Controls.TextInput")));
        }
Beispiel #13
0
 public static IControl Create(IElement element, IEditorFactory editors)
 {
     return(editors.ElementList(
                "Shadow", element,
                SourceFragment.FromString("<Shadow/>"),
                shadow => CreateShadowRow(shadow, editors)
                .WithInspectorPadding()));
 }
Beispiel #14
0
 public static IControl Create(IProject project, IElement element, IEditorFactory editors)
 {
     return(Layout.StackFromTop(
                Spacer.Medium,
                CreateEditors(project, element, editors).WithInspectorPadding(),
                Spacer.Medium)
            .MakeCollapsable(RectangleEdge.Bottom, element.Is("Fuse.Controls.TextControl")));
 }
Beispiel #15
0
 public static IControl Create(IElement element, IEditorFactory editors)
 {
     return(editors.ElementList(
                "Solid Color", element,
                SourceFragment.FromString("<SolidColor/>"),
                solidColor => CreateSolidColorRow(solidColor, editors)
                .WithInspectorPadding()));
 }
Beispiel #16
0
 public static IControl Create(IElement element, IEditorFactory editors)
 {
     return(editors.ElementList(
                "Rotation", element,
                SourceFragment.FromString("<Rotation/>"),
                rotation => CreateRotationRow(rotation, editors)
                .WithInspectorPadding()));
 }
Beispiel #17
0
 static IControl Pane(string name, IEditorFactory editorFactory, Func <IEditorFactory, IControl> content)
 {
     return(Pane(name, editorFactory, content, lazy: false,
                 // Store expanded state as "Expand <name>" : "true", remove from settings when false
                 expanded: UserSettings
                 .Bool("Expand " + name)
                 .OrFalse()));
 }
Beispiel #18
0
 static IControl Pane(string name, IEditorFactory editorFactory, Func <IEditorFactory, IControl> content, IObservable <object> collapse)
 {
     return(Pane(name, editorFactory, content, lazy: true,
                 // Create a new backing store for expanded value each time collapse emits a value
                 expanded: collapse
                 .Select(_ => Property.Create(false))
                 .Switch()));
 }
Beispiel #19
0
        public static IControl Create <T>(IAttribute <T> property, IEditorFactory editors)
            where T : struct
        {
            var objectProperty  = property.Convert(t => (object)t, s => (s is T ? (T)s : default(T)));
            var objectValues    = Observable.Return(Enum.GetValues(typeof(T)).OfType <object>());
            var placeholderText = property.Select(v => v.ToString()).AsText();

            return(Create(property, objectProperty, objectValues, editors, placeholderText));
        }
Beispiel #20
0
 public static IControl Create(IElement element, IEditorFactory editors)
 {
     return(editors.ElementList(
                "Stroke", element,
                SourceFragment.FromString("<Stroke Width=\"3\" Color=\"#f00\"/>"),
                stroke => CreateStrokeRow(stroke, editors)
                .WithInspectorPadding())
            .MakeCollapsable(RectangleEdge.Top, element.Is("Fuse.Controls.Shape")));
 }
Beispiel #21
0
 private void InitEditorInstance(ITextBuffer textBuffer)
 {
     if (ServiceManager.GetService <IEditorInstance>(textBuffer) == null)
     {
         ContentTypeImportComposer <IEditorFactory> importComposer = new ContentTypeImportComposer <IEditorFactory>(_shell.CompositionService);
         IEditorFactory  factory        = importComposer.GetImport(textBuffer.ContentType.TypeName);
         IEditorInstance editorInstance = factory.CreateEditorInstance(textBuffer, new RDocumentFactory(_shell));
     }
 }
Beispiel #22
0
 public FacultyViewModel(IRestConnection restConnection)
 {
     this.restConnection = restConnection;
     this.editorFactory  = new DataFormEditorFactory <FacultyEditor>();
     Items         = new ObservableCollection <FacultyModel>();
     QueryCommand  = new DelegateCommand(QueryOp);
     AddCommand    = new DelegateCommand(AddOp);
     EditCommand   = new DelegateCommand(EditOp);
     DeleteCommand = new DelegateCommand(DeleteOp);
 }
 public ClassroomBuildingViewModel(RestConnection restConnection)
 {
     this.restConnection = restConnection;
     this.editorFactory  = new DataFormEditorFactory <ClassroomBuildingEditor>();
     Items         = new ObservableCollection <ClassroomBuilding>();
     QueryCommand  = new DelegateCommand(QueryOp);
     AddCommand    = new DelegateCommand(AddOp);
     EditCommand   = new DelegateCommand(EditOp);
     DeleteCommand = new DelegateCommand(DeleteOp);
 }
Beispiel #24
0
        public static IControl Create(
            IAttribute <string> property,
            IObservable <string[]> values,
            IEditorFactory editors,
            Text placeholderText = default(Text))
        {
            var objectProperty = property.Convert(p => (object)p, o => (o as string) ?? "");
            var objectValues   = (IObservable <IEnumerable <object> >)values;

            return(Create(property, objectProperty, objectValues, editors, placeholderText));
        }
 public ClassAndGradeViewModel(IRestConnection restConnection)
 {
     this.restConnection = restConnection;
     this.editorFactory  = new DataFormEditorFactory <ClassAndGradeEditor>();
     Items         = new ObservableCollection <ClassAndGradeModel>();
     QueryCommand  = new DelegateCommand(QueryOp);
     AddCommand    = new DelegateCommand(AddOp);
     EditCommand   = new DelegateCommand(EditOp);
     DeleteCommand = new DelegateCommand(DeleteOp);
     GetAllFaculties();
 }
Beispiel #26
0
        public static IControl Create(IElement element, IEditorFactory editors)
        {
            var margin  = element.GetThickness("Margin", new Thickness <Points>(0, 0, 0, 0));
            var padding = element.GetThickness("Padding", new Thickness <Points>(0, 0, 0, 0));

            return(Layout.StackFromTop(
                       ThicknessEditor(margin, editors).WithLabel("Margin"),
                       Spacer.Small,
                       ThicknessEditor(padding, editors).WithLabel("Padding"))
                   .WithInspectorPadding());
        }
 public static IControl Create(IElement element, IEditorFactory editors)
 {
     return(editors.ElementList(
                "Linear Gradient", element,
                SourceFragment.FromString(
                    "<LinearGradient>\n" +
                    "\t<GradientStop Offset=\"0\" Color=\"#ADDDAB\"/>\n" +
                    "\t<GradientStop Offset=\"1\" Color=\"#6DC0D2\"/>\n" +
                    "</LinearGradient>\n"),
                linearGradient => CreateGradientRow(linearGradient, editors)
                .WithInspectorPadding()));
 }
Beispiel #28
0
 public static IControl Create(IElement element, IEditorFactory editors)
 {
     return(Layout.StackFromTop(
                Separator.Shadow,
                Separator.Weak,
                Pane("Layout", editors, e => LayoutSection.Create(element, e)),
                Pane("Size / Position", editors, e => SizePositionSection.Create(element, e)),
                Pane("Style", editors, e => StyleSection.Create(element, e)),
                Pane("Transform", editors, e => TransformSection.Create(element, e)),
                Pane("Visibility", editors, e => VisibilitySection.Create(element, e)),
                Pane("Attributes", editors, e => AttributesSection.Create(element, e), collapse: element.SimulatorId)));
 }
Beispiel #29
0
        static IControl Pane(string name, IEditorFactory editorFactory, Func <IEditorFactory, IControl> content, bool lazy, IProperty <bool> expanded)
        {
            var attributes = new AttributeIntercepter(editorFactory);

            var labelColor = lazy
                                ? Theme.DefaultText
                                : attributes.AllReadOnly
                             .Select(r => r ? Theme.DisabledText : Theme.DefaultText)
                             .Switch();

            var height = new Points(31);

            var label = Label.Create(name, font: Theme.DefaultFontBold, color: labelColor)
                        .CenterVertically();

            var expandedArrow  = Arrow.WithoutShaft(RectangleEdge.Bottom, SymbolSize.Small);
            var collapsedArrow = Arrow.WithoutShaft(RectangleEdge.Right, SymbolSize.Small);

            var arrow = expanded
                        .Select(expanded1 => expanded1 ? expandedArrow : collapsedArrow)
                        .Switch()
                        .Center()
                        .WithSize(Size.Create <Points>(13, 13))
                        .OnMouse(pressed: expanded.Toggle())
                        .CenterVertically();

            var circle = Shapes.Circle(fill: Theme.Active)
                         .WithSize(Spacer.Small.DesiredSize)
                         .CenterVertically()
                         .ShowWhen(attributes.AnyHasValue);

            return(Layout.StackFromTop(
                       Button.Create(
                           clicked: expanded.Toggle(),
                           content: s =>
                           Layout.Dock()
                           .Left(label)
                           .Left(Spacer.Small)
                           .Left(
                               circle
                               .WithHeight(height)
                               .MakeCollapsable(RectangleEdge.Top, expanded.IsFalse(), lazy: false)
                               .DockBottom())
                           .Right(arrow)
                           .Fill()
                           .WithHeight(height)
                           .WithInspectorPadding()),
                       Separator.Medium,
                       Layout.StackFromTop(
                           content(attributes),
                           Separator.Medium)
                       .MakeCollapsable(RectangleEdge.Bottom, expanded, lazy: lazy, unrootWhenCollapsed: lazy)));
        }
Beispiel #30
0
        /// <summary>
        ///     Crea el editor.
        /// </summary>
        protected virtual Control CreateEditor(string name, ErrorProvider errorProvider)
        {
            IFormModel formModel = this.FormModel;

            PropertyDescription propDescription = formModel.GetDescription(name);
            Type tipo = formModel.GetPropertyType(name);

            // Se busca la fabrica de editores.
            IEditorFactory editorFactory = propDescription.EditorFactory ?? this.DefaultEditorFactory;

            Contract.Assert(editorFactory != null);

            ViewProperties[] viewProperties  = formModel.GetViewProperties(name).ToArray();
            IServiceProvider serviceProvider = this.GetServiceProvider();

            // Se crea el control mediante la fabrica de editores.
            Control editor = (Control)editorFactory.Create(tipo, viewProperties, serviceProvider);

            if (editor == null)
            {
                Log <FormViewControl <TControl> > .ErrorFormat("No se encuentra mapeo para la propiedad de formulario {0} [{1}]", formModel, name);

                editor      = new System.Windows.Forms.Label();
                editor.Text = "<ERROR>";
            }

            //editor.Site = mySite;
            editor.Name     = name;
            editor.Enabled  = true;
            editor.AutoSize = this.EditorAutoSize;
            editor.Anchor   = this.EditorAnchor;
            editor.Dock     = this.EditorDock;
            editor.Padding  = this.EditorPadding;
            editor.Margin   = this.EditorMargin;

            string description = propDescription.Description;

            if (!string.IsNullOrEmpty(description))
            {
                ToolTip toolTip = new ToolTip();
                toolTip.SetToolTip(editor, description);
            }

            ControlExchange exchange = ControlExchange.Get(editor);

            if (exchange != null)
            {
                exchange.PopertyName = name;
            }

            return(editor);
        }
 public MainForm(IEditorFactory editorFactory)
 {
     this.editorFactory = editorFactory;
     this.editors = new List<IEditorPresenter>();
     InitializeComponent();
 }