コード例 #1
0
ファイル: NotebookTab.cs プロジェクト: ryancheung/Steropes.UI
        public NotebookTab(IUIStyle style) : base(style)
        {
            activationRequestedSupport = new EventSupport <EventArgs>();
            closeRequestedSupport      = new EventSupport <EventArgs>();

            emptyContent = new Label(UIStyle)
            {
                Anchor = AnchoredRect.CreateHorizontallyStretched()
            };

            closeButton = new Button(UIStyle);
            closeButton.AddStyleClass(CloseButtonStyleClass);
            closeButton.Anchor           = AnchoredRect.CreateCentered();
            closeButton.ActionPerformed += OnCloseButtonOnClicked;

            InternalContent = new DockPanel(UIStyle);
            InternalContent.LastChildFill = true;
            InternalContent.Add(closeButton, DockPanelConstraint.Right);
            InternalContent.Add(emptyContent, DockPanelConstraint.Left);

            KeyPressed   += OnKeyPressed;
            MouseClicked += OnMouseClick;

            Focusable = true;
        }
コード例 #2
0
        public void MeasureTwoElementsLeftFill()
        {
            var p = new DockPanel(LayoutTestStyle.Create());

            p.LastChildFill = true;
            p.Add(LayoutTestWidget.FixedSize(100, 50), DockPanelConstraint.Left);
            p.Add(LayoutTestWidget.FixedSize(100, 50), DockPanelConstraint.Left);

            p.Measure(Size.Auto);
            p.DesiredSize.Should().Be(new Size(200, 50));
        }
コード例 #3
0
        public void LayoutTwoElementsLeftFill()
        {
            var p = new DockPanel(LayoutTestStyle.Create());

            p.LastChildFill = true;
            p.Add(LayoutTestWidget.FixedSize(100, 50), DockPanelConstraint.Left);
            p.Add(LayoutTestWidget.FixedSize(100, 50), DockPanelConstraint.Left);

            p.Arrange(new Rectangle(10, 20, 500, 300));
            p.LayoutRect.Should().Be(new Rectangle(10, 20, 500, 300));
            p[0].LayoutRect.Should().Be(new Rectangle(10, 20, 100, 300));
            p[1].LayoutRect.Should().Be(new Rectangle(110, 20, 400, 300));
        }
コード例 #4
0
        public void ArrangeNonZeroOffset()
        {
            var p = new DockPanel(LayoutTestStyle.Create());

            p.LastChildFill = true;
            p.Add(LayoutTestWidget.FixedSize(100, 50), DockPanelConstraint.Top);
            p.Add(LayoutTestWidget.FixedSize(100, 50), DockPanelConstraint.Bottom);

            p.Arrange(new Rectangle(10, 20, 800, 600));
            p.DesiredSize.Should().Be(new Size(100, 100));
            p.LayoutRect.Should().Be(new Rectangle(10, 20, 800, 600));
            p[0].LayoutRect.Should().Be(new Rectangle(10, 20, 800, 50));
            p[1].LayoutRect.Should().Be(new Rectangle(10, 70, 800, 550));
        }
コード例 #5
0
        public JsonResponseVisualizer()
        {
            treeView = new RestlessTreeView <IRxObject>();

            filterTextBox.VerticalContentAlignment = VerticalAlignment.Center;
            Placeholder.SetPlaceholder(filterTextBox, "Type here and press enter to filter the results");
            filterTextBox.KeyDown += (sender, args) =>
            {
                if (args.Key == Key.Enter)
                {
                    Filter();
                }
            };

            var filterButton = new Button
            {
                Content   = Icons.Get(IconResources.Filter),
                Focusable = false,
                ToolTip   = "Apply Filter"
            };

            filterButton.Click += (sender, args) => Filter();

            var clearFilterButton = new Button
            {
                Content   = Icons.Get(IconResources.RemoveFilter),
                Focusable = false,
                ToolTip   = "Clear Filter"
            };

            clearFilterButton.Click += (sender, args) => ClearFilter();

            var toolBar = new DockPanel();

            toolBar.Add(clearFilterButton, Dock.Right);
            toolBar.Add(filterButton, Dock.Right);
            toolBar.Add(filterTextBox);
            this.Add(toolBar, Dock.Top);

            this.Add(treeView);

            this.Bind(x => x.Response).To(response =>
            {
                if (response != null)
                {
                    AddRootToken(Model.JsonResponse);
                }
            });
        }
コード例 #6
0
        public void LayoutHorizontallyOpposingElementTopNoFill()
        {
            var p = new DockPanel(LayoutTestStyle.Create());

            p.Add(LayoutTestWidget.FixedSize(100, 50), DockPanelConstraint.Top);
            p.Add(LayoutTestWidget.FixedSize(100, 50), DockPanelConstraint.Bottom);

            p.Measure(Size.Auto);
            p.DesiredSize.Should().Be(new Size(100, 100));

            p.Arrange(new Rectangle(10, 20, 500, 300));
            p.LayoutRect.Should().Be(new Rectangle(10, 20, 500, 300));
            p[0].LayoutRect.Should().Be(new Rectangle(10, 20, 500, 50));
            p[1].LayoutRect.Should().Be(new Rectangle(10, 270, 500, 50));
        }
コード例 #7
0
        public void ArrangeWithLargeElement()
        {
            //// Shows that large elements will make the content overflow.

            var p = new DockPanel(LayoutTestStyle.Create());

            p.LastChildFill = true;
            p.Add(LayoutTestWidget.FixedSize(100, 50), DockPanelConstraint.Top);
            p.Add(LayoutTestWidget.FixedSize(100, 850), DockPanelConstraint.Bottom);

            p.Arrange(new Rectangle(10, 20, 800, 600));
            p.DesiredSize.Should().Be(new Size(100, 900));
            p.LayoutRect.Should().Be(new Rectangle(10, 20, 800, 600));
            p[0].LayoutRect.Should().Be(new Rectangle(10, 20, 800, 50));
            p[1].LayoutRect.Should().Be(new Rectangle(10, 70, 800, 850));
        }
コード例 #8
0
        protected override ControlsContainer CreateUI()
        {
            _stateManager = DreamOfStarsCorePlugin._singularityAdapter.Container.GetInstance <IStateManager>();

            this.IsFullScreen = true;
            DockPanel root = new DockPanel()
            {
                Margin = new Border(5),
                Size   = new Size(200)
            };

            StackPanel stackV = new StackPanel()
            {
                Docking   = Dock.Right,
                Direction = Direction.UpToDown,
                Margin    = new Border(5),
                Size      = new Size(200)
            };

            MyButtons.CreateButtonInContainer("New Game", stackV, () => StartNewGame());
            var slotNumbers = _stateManager.GetSaveSlotsNumbers();

            foreach (var slot in slotNumbers)
            {
                MyButtons.CreateButtonInContainer($"Load Game Slot {slot}", stackV, () => LoadSelectedGameSlot(slot));
            }


            MyButtons.CreateButtonInContainer("Exit", stackV, () => DualityApp.Terminate());

            root.Add(stackV);
            root.ApplySkin(Skin.YAUI_DARK);
            return(root);
        }
コード例 #9
0
 public void AddCommand(string text, ICommand command, UIIcon icon)
 {
     DockPanel.Add <Button>(x =>
     {
         x.ToIconButton(icon, command).Text(text);
         x.VerticalAlignment   = VerticalAlignment.Stretch;
         x.HorizontalAlignment = HorizontalAlignment.Right;
     });
 }
コード例 #10
0
ファイル: SharedExtensions.cs プロジェクト: larsw/storyteller
 public static DockPanel Add <T>(this DockPanel panel, Action <T> configure, Dock dock) where T : UIElement, new()
 {
     panel.Add <T>(element =>
     {
         configure(element);
         DockPanel.SetDock(element, dock);
     });
     return(panel);
 }
コード例 #11
0
        public LayoutView()
        {
            var dock = new DockPanel();

            Content = dock;

            Header = new ViewRegion
            {
                Border  = new Thickness(1),
                Padding = new Thickness(2, 1)
            };
            dock.Add(Header, Dock.Top, 15);

            Body = new ViewRegion
            {
                Padding = new Thickness(2, 1)
            };
            dock.Add(Body, Dock.Fill);
        }
コード例 #12
0
        public void LayoutAllFilledElementTopNoFill()
        {
            var p = new DockPanel(LayoutTestStyle.Create());

            p.Add(LayoutTestWidget.FixedSize(100, 50), DockPanelConstraint.Left);
            p.Add(LayoutTestWidget.FixedSize(100, 50), DockPanelConstraint.Right);
            p.Add(LayoutTestWidget.FixedSize(100, 50), DockPanelConstraint.Top);
            p.Add(LayoutTestWidget.FixedSize(100, 50), DockPanelConstraint.Bottom);

            p.Measure(Size.Auto);
            p.DesiredSize.Should().Be(new Size(200, 150));

            p.Arrange(new Rectangle(10, 20, 500, 300));
            p.LayoutRect.Should().Be(new Rectangle(10, 20, 500, 300));
            p[0].LayoutRect.Should().Be(new Rectangle(10, 70, 100, 200));
            p[1].LayoutRect.Should().Be(new Rectangle(410, 70, 100, 200));
            p[2].LayoutRect.Should().Be(new Rectangle(10, 20, 500, 50));
            p[3].LayoutRect.Should().Be(new Rectangle(10, 270, 500, 50));
        }
コード例 #13
0
        public void LayoutSingleElementTopFill()
        {
            var p = new DockPanel(LayoutTestStyle.Create());

            p.LastChildFill = true;
            p.Add(LayoutTestWidget.FixedSize(100, 50), DockPanelConstraint.Top);

            p.Measure(Size.Auto);
            p.DesiredSize.Should().Be(new Size(100, 50));

            p.Arrange(new Rectangle(10, 20, 500, 300));
            p.LayoutRect.Should().Be(new Rectangle(10, 20, 500, 300));
            p[0].LayoutRect.Should().Be(new Rectangle(10, 20, 500, 300));
        }
コード例 #14
0
ファイル: SharedExtensions.cs プロジェクト: larsw/storyteller
 public static DockPanel Right <T>(this DockPanel panel, Action <T> configure) where T : UIElement, new()
 {
     return(panel.Add(configure, Dock.Right));
 }
コード例 #15
0
ファイル: SampleOverlay.cs プロジェクト: OkashiKami/Odyssey
        public static Overlay New(IServiceRegistry services)
        {
            var settings = services.GetService <IDirectXDeviceSettings>();

            var overlay = new Overlay(services)
            {
                Width  = settings.PreferredBackBufferWidth,
                Height = settings.PreferredBackBufferHeight
            };

            // signal that we are starting to design the UI
            overlay.BeginDesign();

            var canvas = new Canvas();
            var border = new Border()
            {
                StyleClass = "Panel", Position = LayoutManager.Point(2, 2), Width = LayoutManager.Units(30), Height = LayoutManager.Units(20)
            };

            var fpsCounter = new FpsCounter {
                Position = LayoutManager.Point(0.5f, 0.5f)
            };
            var dockPanel = new DockPanel {
            };

            var label = new TextBlock {
                Text = "This is a Dockpanel.", Margin = new Thickness(8)
            };

            label.DependencyProperties.Add(DockPanel.DockPropertyKey, Dock.Top);

            var stackPanel1 = new StackPanel()
            {
                Orientation = Orientation.Vertical
            };

            stackPanel1.DependencyProperties.Add(DockPanel.DockPropertyKey, Dock.Bottom);

            var listBox = new ListBox
            {
                Padding     = new Thickness(4),
                Margin      = new Thickness(8),
                ItemsSource = new[]
                { "This is a Listbox", "bound to a string array.", "Its itemtemplate specifies that each entry", "will be bound to a TextBlock" }
            };

            // The size of the button comes from the Defaul.oxil theme file
            var button = new Button
            {
                Content = new TextBlock {
                    Text = "Button", HorizontalAlignment = HorizontalAlignment.Center, VerticalAlignment = VerticalAlignment.Center
                },
                HorizontalAlignment = HorizontalAlignment.Center,
                VerticalAlignment   = VerticalAlignment.Center,
            };

            button.Tap += (s, eventArgs) => ((TextBlock)button.Content).Text = "It works!";

            stackPanel1.Add(button);

            dockPanel.Add(stackPanel1);
            dockPanel.Add(label);
            dockPanel.Add(listBox);
            border.Content = dockPanel;
            canvas.Add(border);
            canvas.Add(fpsCounter);

            overlay.Content = canvas;

            // we're done: BeginDesign() and EndDesign() are required for correct initialization
            overlay.EndDesign();

            return(overlay);
        }
コード例 #16
0
        public ApiPanel()
        {
            var sendButton = new Button {
                Content = Icons.Get(IconResources.Send, 22, 18), Focusable = false, ToolTip = "Send the request to the server"
            };
            var resetButton = new Button {
                Content = Icons.Get(IconResources.Reset, 22, 14), Focusable = false, ToolTip = "Reset transient data back to their default state", Padding = new Thickness(3)
            };

            var buttonsPanel = new StackPanel
            {
                Orientation = Orientation.Horizontal
            };

            buttonsPanel.Children.Add(sendButton);
            buttonsPanel.Children.Add(resetButton);

            var statusLabel     = new Label();
            var statusCodeLabel = new Label();
            var statusPanel     = new StackPanel
            {
                Orientation         = Orientation.Horizontal,
                HorizontalAlignment = HorizontalAlignment.Right
            };

            statusPanel.Children.Add(statusCodeLabel);
            statusPanel.Children.Add(statusLabel);

            var buttonsAndStatusPanel = new DockPanel();

            buttonsAndStatusPanel.Add(buttonsPanel, Dock.Left);
            buttonsAndStatusPanel.Add(statusPanel);

            var apiDetailsPanel = new TabControl();

//            SetIsSharedSizeScope(apiDetailsPanel, true);
            foreach (var requestVisualizer in requestVisualizers)
            {
                var item = new TabItem {
                    Header = requestVisualizer.Title, Content = requestVisualizer
                };
                requestVisualizer.InitializeTab(item);
                apiDetailsPanel.Items.Add(item);
            }

            var topPanel = new DockPanel();

            topPanel.Add(buttonsAndStatusPanel, Dock.Bottom);
            topPanel.Add(apiDetailsPanel);

            topPanel.Measure(new Size(double.PositiveInfinity, double.PositiveInfinity));

            var preferredHeight = topPanel.DesiredSize.Height + 10;

            var topRow = this.AddRow(preferredHeight);

            this.AddRow(4);
            this.AddRow(new GridLength(1, GridUnitType.Star));
            topRow.MinHeight = preferredHeight;
            this.Add(topPanel, 0, 0);
            this.AddHorizontalSplitter(200, 200);

            this.Bind(x => x.Send).To(x => sendButton.Command   = x);
            this.Bind(x => x.Reset).To(x => resetButton.Command = x);
            this.Bind(x => x.Response).To(x =>
            {
                if (currentApiResponsePanel == null)
                {
                    currentApiResponsePanel = new ApiResponsePanel();
                    this.Add(currentApiResponsePanel, 2, 0);
                }
                currentApiResponsePanel.Model = x;
            });
            this.Bind(x => x.Response).To(x => statusPanel.Visibility             = x == null ? Visibility.Hidden : Visibility.Visible);
            this.Bind(x => x.Response.StatusCode).To(x => statusCodeLabel.Content = x);
            this.Bind(x => x.Response.Status).To(x => statusLabel.Content         = x);
            this.Bind(x => x.MainWindow.ApiSplitterPosition).Mate(topRow, RowDefinition.HeightProperty);

            foreach (var requestVisualizer in requestVisualizers)
            {
                this.Bind(x => x).To(x => requestVisualizer.Model = x);
            }
        }
コード例 #17
0
ファイル: MainWindow.cs プロジェクト: kswoll/restless
        public MainWindow()
        {
            SnapsToDevicePixels = true;
            Icon      = BitmapFrame.Create(Application.GetResourceStream(new Uri("/Icon.ico", UriKind.Relative)).Stream);
            MinWidth  = 600;
            MinHeight = 480;

            ConfigureWindowStateAndPosition();

            var apiList = new RestlessTreeView <ApiItemModel>();

            grid = new Grid();

            grid.AddColumn(300);
            grid.AddColumn(4);
            grid.AddColumn(1, GridUnitType.Star);

            grid.AddRow(1, GridUnitType.Star);
            grid.Add(apiList, 0, 0);
            grid.AddVerticalSplitter(200, 400);
            var apiListContextMenu = new ContextMenu();

            var addChildApiMenuItem           = apiListContextMenu.Add("Add Child _Api");
            var addChildApiCollectionMenuItem = apiListContextMenu.Add("Add Child Api _Collection");
            var apiDeleteMenuItem             = apiListContextMenu.Add("_Delete");

            apiList.ContextMenu = apiListContextMenu;

            var menu = new Menu();

            var fileMenu             = menu.Add("_File");
            var newApiMenuItem       = fileMenu.Add("New _Api");
            var newApiCollectionItem = fileMenu.Add("New Api _Collection");
            var exportAllMenuItem    = fileMenu.Add("_Export");
            var importMenuItem       = fileMenu.Add("_Import");

            var editMenu      = menu.Add("_Edit");
            var copyMenuItem  = editMenu.Add("_Copy");
            var pasteMenuItem = editMenu.Add("_Paste");

            var content = new DockPanel {
                LastChildFill = true
            };

            content.Add(menu, Dock.Top);
            content.Add(grid);

            Content = content;

            var apiPanel           = new ApiPanel();
            var apiCollectionPanel = new ApiCollectionPanel();

            var treeViewItemStyle = new TreeViewItemStyle();

            treeViewItemStyle.AddSetter(x => x.IsSelected, apiList.Bind(x => x.IsSelected));
            treeViewItemStyle.AddSetter(x => x.IsExpanded, apiList.Bind(x => x.IsExpanded));
            apiList.ItemContainerStyle = treeViewItemStyle;

            this.Bind(x => x.Title).To(this, (window, title) => window.Title = title ?? "");
            this.Bind(x => x.Items).To(apiList, x => x.Items, typeof(Item));
            this.Bind(x => x.DeleteSelectedItem).To(x => apiDeleteMenuItem.Command = x);

            var selectedItemChange        = this.Bind(x => x.SelectedItem).ObserveModelPropertyChange();
            var selectedItemNotNullChange = selectedItemChange.Where(x => x != null);

            selectedItemChange.Where(x => x == null).Subscribe(x => HideContent());
            selectedItemNotNullChange.OfType <ApiModel>().Subscribe(x =>
            {
                apiPanel.Model = x;
                ShowContent(apiPanel);
            });
            selectedItemNotNullChange.OfType <ApiCollectionModel>().Subscribe(x =>
            {
                apiCollectionPanel.Model = x;
                if (x != null)
                {
                    ShowContent(apiCollectionPanel);
                }
                else
                {
                    HideContent();
                }
            });

            this.Bind(x => x.SplitterPosition).Mate(grid.ColumnDefinitions[0], ColumnDefinition.WidthProperty);

            Action <ApiModel> onAddApi = apiModel =>
            {
                Model.SelectedItem = apiModel;
                ((ApiPanel)this.content).InitNew();
            };

            var addChildApi = this.Bind(x => x.AddChildApi);

            addChildApi.To(x => addChildApiMenuItem.Command = x);
            addChildApi.ObserveModelPropertyChange().SelectMany(x => x).Subscribe(onAddApi);

            var addChildApiCollection = this.Bind(x => x.AddChildApiCollection);

            addChildApiCollection.To(x => addChildApiCollectionMenuItem.Command = x);
            addChildApiCollection.ObserveModelPropertyChange().SelectMany(x => x).Subscribe(collectionModel =>
            {
                Model.SelectedItem = collectionModel;
            });

            var addApi = this.Bind(x => x.AddApi);

            addApi.To(x => newApiMenuItem.Command = x);
            addApi.ObserveModelPropertyChange().SelectMany(x => x).Subscribe(onAddApi);
            this.Bind(x => x.AddApiCollection).To(x => newApiCollectionItem.Command = x);

            this.Bind(x => x.Export).To(x => exportAllMenuItem.Command = x);
            this.Bind(x => x.Import).To(x => importMenuItem.Command    = x);
        }
コード例 #18
0
ファイル: SharedExtensions.cs プロジェクト: larsw/storyteller
 public static T Bottom <T>(this DockPanel panel) where T : UIElement, new()
 {
     return(panel.Add <T>(x => DockPanel.SetDock(x, Dock.Bottom)));
 }