コード例 #1
0
 public void HidePopover(IPopover popover)
 {
     if (popover != null && popover is View)
     {
         popover.IsPopoverVisible = false;
         Children.Remove(_backing);
         Children.Remove((View)popover);
     }
 }
コード例 #2
0
ファイル: MainWindow.cs プロジェクト: yongaru/fuse-studio
        static IControl CreateTopBar(
            IPopover popover,
            IProperty <bool> selectionEnabled,
            IProperty <Mode> mode,
            Command addViewport,
            CodeView codeView)
        {
            var isCompact  = mode.Convert(m => m == Mode.Compact, m => m ? Mode.Compact : Mode.Normal);
            var toggleMode = isCompact.Toggle();

            return
                (Layout.Layer(
                     Layout
                     .StackFromLeft(
                         codeView.Create(popover)
                         .HideWhen(isCompact),

                         Control.Empty.WithWidth(16),

                         Layout
                         .StackFromLeft(CreateHeaderControl(
                                            icon: Fuse.Icons.AddViewport(),
                                            tooltipText: "Click to add a new Viewport",
                                            buttonText: "Add Viewport",
                                            command: addViewport,
                                            labelColor: Theme.DefaultText),
                                        Control.Empty.WithWidth(16)
                                        )
                         .HideWhen(isCompact),

                         CreateHeaderControl(
                             icon: MinimizeAndMaximizeIcon.Create(mode),
                             tooltipText: "Switch between normal and compact mode. Click to switch mode.",
                             buttonText: "Compact",
                             labelColor: Theme.DefaultText,
                             command: toggleMode)
                         .HideWhen(isCompact),

                         CreateCompactSelectionControl(mode, selectionEnabled, toggleMode)
                         .ShowWhen(isCompact)
                         .Center(),

                         Control.Empty.WithWidth(4))
                     .DockRight(),
                     CreateFullSelectionControl(selectionEnabled)
                     .HideWhen(isCompact)
                     .CenterHorizontally())
                 .WithHeight(37)
                 .WithPadding(new Thickness <Points>(8, 0, 8, 0))
                 .WithBackground(Theme.PanelBackground));
        }
コード例 #3
0
        public void ShowPopover(IPopover popover, ShowPopoverArgs showPopoverArgs)
        {
            if (popover != null && popover is View)
            {
                Children.Add(_backing);
                Children.Add((View)popover);

                double xTransition = default(double);
                double yTransition = default(double);

                switch (showPopoverArgs.PopoverLayoutingStrategy)
                {
                case PopoverLayoutingStrategy.LeftOverlay:
                    xTransition = showPopoverArgs.DropDownSelectrorRectangle.Left;
                    yTransition = showPopoverArgs.DropDownSelectrorRectangle.Top;
                    break;

                case PopoverLayoutingStrategy.LeftBottom:
                    xTransition = showPopoverArgs.DropDownSelectrorRectangle.Left;
                    yTransition = showPopoverArgs.DropDownSelectrorRectangle.Top + showPopoverArgs.DropDownSelectrorRectangle.Height + PopoverKeeper._BOTTOM_BASED_POPOVER_Y_OFFSET;
                    break;

                case PopoverLayoutingStrategy.RightOverlay:
                    xTransition = showPopoverArgs.DropDownSelectrorRectangle.Left + (showPopoverArgs.DropDownSelectrorRectangle.Width - ((View)popover).Width);
                    yTransition = showPopoverArgs.DropDownSelectrorRectangle.Top;
                    break;

                case PopoverLayoutingStrategy.RightBottom:
                    xTransition = showPopoverArgs.DropDownSelectrorRectangle.Left + (showPopoverArgs.DropDownSelectrorRectangle.Width - ((View)popover).Width);
                    yTransition = showPopoverArgs.DropDownSelectrorRectangle.Top + showPopoverArgs.DropDownSelectrorRectangle.Height + PopoverKeeper._BOTTOM_BASED_POPOVER_Y_OFFSET;
                    break;

                default:
                    throw new InvalidOperationException("PopoverKeeperControl ShowPopover invalid PopoverLayoutingStrategy");
                }

                ((View)popover).TranslationX = xTransition;
                ((View)popover).TranslationY = yTransition;

                if (popover.IsHaveSameWidth)
                {
                    ((View)popover).WidthRequest = showPopoverArgs.DropDownSelectrorRectangle.Width;
                }

                popover.IsPopoverVisible = true;
            }
        }
コード例 #4
0
 public static IControl Create(IPopover popover, Code code, Optional <IPAddress> endpoint, IControl qrCode)
 {
     return(popover.CreatePopover(
                RectangleEdge.Top,
                state =>
     {
         return
         Button.Create(state.IsVisible.Toggle(), s =>
                       Layout.StackFromLeft(
                           Control.Empty.WithWidth(4),
                           Icons.DevicesIcon(),
                           Control.Empty.WithWidth(4),
                           Label.Create(
                               text: "Devices",
                               color: Theme.DefaultText,
                               font: Theme.DescriptorFont)
                           .CenterVertically(),
                           Control.Empty.WithWidth(4))
                       .SetToolTip("Connect this project to a device with the Fuse Preview App installed on it.")
                       .WithBackground(
                           background: Observable.CombineLatest(
                               s.IsEnabled, s.IsHovered,
                               (enabled, hovering) =>
                               hovering
                                                                                                 ? Theme.FaintBackground
                                                                                                 : Color.Transparent)
                           .Switch()));
     },
                state =>
     {
         return Layout.StackFromTop(
             qrCode,
             TextView("IP address:", endpoint.Select(e => e.ToString()).Or("Failed to find IP")),
             TextView("Code:", code.ToString())
             )
         .WithWidth(200)
         .CenterHorizontally()
         .WithPadding(new Thickness <Points>(0, 8, 0, 16))
         .WithWidth(250);
     }));
 }
コード例 #5
0
ファイル: Expression.cs プロジェクト: yongaru/fuse-studio
        public static IControl CreateButton <T>(IObservable <object> elementChanged, IAttribute <T> property, IPopover popover)
        {
            return(popover.CreatePopover(
                       RectangleEdge.Bottom,
                       content: state =>
                       Button.Create(clicked: state.IsVisible.Toggle(), content: button =>
            {
                var circleColor = Observable.CombineLatest(
                    button.IsHovered,
                    state.IsVisible,
                    (hovering, visible) =>
                    visible
                                                                                        ? Theme.Active
                                                                                        : (hovering ? Theme.Active : Theme.FieldFocusStroke.Brush))
                                  .Switch();

                return Layout.StackFromTop(
                    Enumerable.Range(0, 3).Select(
                        i => Shapes.Circle(fill: circleColor)
                        .WithSize(new Size <Points>(2, 2))
                        .WithPadding(new Thickness <Points>(1))))
                .WithPadding(new Thickness <Points>(3));
            }),
                       popover: state =>
            {
                var result = Layout.Dock()
                             .Bottom(Button.Create(state.IsVisible.Update(false), bs =>
                                                   Layout.Dock()
                                                   .Left(Icons.Confirm(Theme.Active).CenterVertically())
                                                   .Left(Spacer.Small)
                                                   .Fill(Theme.Header("Done"))
                                                   .Center()
                                                   .WithHeight(30)))
                             .Bottom(Separator.Medium)
                             .Top(Spacer.Medium)
                             .Top(Label.Create(
                                      text: "Expression Editor",
                                      textAlignment: TextAlignment.Center,
                                      font: Theme.DefaultFont,
                                      color: Theme.DefaultText))
                             .Top(Spacer.Small)
                             .Top(Label.Create(
                                      text: "You can write expressions here instead \n of using an explicit value",
                                      textAlignment: TextAlignment.Center,
                                      font: Theme.DescriptorFont,
                                      color: Theme.DescriptorText))
                             .Top(Spacer.Medium)
                             .Left(Spacer.Medium)
                             .Right(Spacer.Medium)
                             .Bottom(Spacer.Medium)
                             .Fill(
                    TextBox.Create(
                        text: property.StringValue.Deferred(),
                        foregroundColor: Theme.DefaultText,
                        doWrap: true)
                    .WithPadding(new Thickness <Points>(1))
                    .WithBackground(Theme.FieldBackground)
                    .WithOverlay(Shapes.Rectangle(stroke: Theme.FieldStroke))
                    .WithHeight(74))
                             .WithWidth(279);

                elementChanged.ConnectWhile(result.IsRooted).Subscribe(id => state.IsVisible.OnNext(false));

                return result;
            })
                   .CenterVertically());
        }
コード例 #6
0
ファイル: Factory.cs プロジェクト: yongaru/fuse-studio
 public Factory(IObservable <object> elementChanged, IPopover popover)
 {
     _elementChanged = elementChanged;
     _popover        = popover;
 }
コード例 #7
0
        public static IControl Create(IElement element, IProject project, IEditorFactory editors, IPopover popover)
        {
            return(Layout.StackFromTop(
                       popover.CreatePopover(RectangleEdge.Bottom,
                                             dialog => Button.Create(
                                                 dialog.IsVisible.Toggle(),
                                                 state => Layout.StackFromTop(
                                                     Spacer.Medium,
                                                     Layout.StackFromLeft(
                                                         element.MediumIcon(Theme.IconPrimary, Theme.IconSecondary)
                                                         .CenterVertically(),
                                                         Spacer.Small,
                                                         Label.Create(element.Name.AsText(), color: Theme.DefaultText, font: Theme.HeaderFont)
                                                         .CenterVertically(),
                                                         Spacer.Small,
                                                         Layout.StackFromTop(
                                                             Arrow.WithoutShaft(RectangleEdge.Top, SymbolSize.Small),
                                                             Spacer.Smaller,
                                                             Arrow.WithoutShaft(RectangleEdge.Bottom, SymbolSize.Small))
                                                         .CenterVertically())
                                                     .CenterHorizontally(),
                                                     Spacer.Medium)),
                                             dialog =>
            {
                var result = Layout.Dock()
                             .Bottom(Button.Create(Command.Enabled(() => dialog.IsVisible.OnNext(false)), bs =>
                                                   Layout.Dock()
                                                   .Left(Icons.Confirm(Theme.Active).CenterVertically())
                                                   .Left(Spacer.Small)
                                                   .Fill(Theme.Header("Done"))
                                                   .Center()
                                                   .WithHeight(30)))
                             .Bottom(Separator.Medium)
                             .Top(Spacer.Medium)
                             .Top(Label.Create(text: "Replace element", textAlignment: TextAlignment.Center, font: Theme.DefaultFont, color: Theme.DefaultText))
                             .Top(Spacer.Small)
                             .Top(Label.Create(text: "Enter a new element type to replace \n the current element type", textAlignment: TextAlignment.Center, font: Theme.DescriptorFont, color: Theme.DescriptorText))
                             .Top(Spacer.Medium)
                             .Left(Spacer.Medium)
                             .Right(Spacer.Medium)
                             .Bottom(Spacer.Medium)
                             .Fill(
                    TextBox.Create(
                        text: element.Name.Deferred(),
                        foregroundColor: Theme.DefaultText)
                    .WithPadding(new Thickness <Points>(1))
                    .WithBackground(Theme.FieldBackground)
                    .WithOverlay(Shapes.Rectangle(stroke: Theme.FieldStroke)))
                             .WithWidth(279);

                var elementChanged = element.SimulatorId;
                elementChanged.ConnectWhile(result.IsRooted).Subscribe(id => dialog.IsVisible.OnNext(false));

                return result;
            }),

                       Separator.Weak, Spacer.Medium,

                       editors.NameRow("Instance Name", element.UxName(), deferEdit: true)
                       .WithInspectorPadding(),

                       Spacer.Medium, Separator.Weak,

                       ContextualSections(element, project, editors)));
        }
コード例 #8
0
 public IControl Create(IPopover popover)
 {
     return(Create(popover, _code, _endpoint, _qrCode));
 }