コード例 #1
0
ファイル: TestWidgets.cs プロジェクト: Morbidous/DownUnder-UI
        public static Widget SerializeTest()
        {
            var result = new Widget();

            result.Add(CommonWidgets.Button("serialize", new RectangleF(10, 10, 100, 40)), out var button);
            result.Add(CommonWidgets.Label("Native:", new RectangleF(20, 70, 200, 200), DrawText.XTextPositioningPolicy.left, DrawText.YTextPositioningPolicy.top));
            result.Add(CommonWidgets.Label("Loaded from XML:", new RectangleF(20, 220, 200, 200), DrawText.XTextPositioningPolicy.left, DrawText.YTextPositioningPolicy.top));

            button.OnClick += (s, a) => {
                //var test = new TestSerializeClass() { NameProperty = "property name", name_field = "name field" };
                //test.w_list.Add(new Widget());
                //XmlHelper.ToXmlFile(test, @"C:\Users\jamie\Desktop\New folder\test.xml");
                var unserialized = new Widget(170, 70, 140, 140);
                unserialized.Add(new Widget(40, 40, 100, 40), out var added_widget);
                added_widget.UserResizePolicy = Widget.UserResizePolicyType.allow;
                added_widget.Behaviors.Add(new GridFormat(2, 2), out var grid);
                grid[0, 1].Behaviors.Add(new DrawText("stuff"));
                unserialized.Behaviors.Add(new DrawText("Serialize this"));
                unserialized.SaveToXML(@"C:\Users\jamie\Desktop\New folder\test.xml");
                var deserialized = Widget.LoadFromXML(@"C:\Users\jamie\Desktop\New folder\test.xml");
                result.Add(deserialized);
                result.Add(unserialized);
                deserialized.Position = new Point2(170, 220);
            };

            return(result);
        }
コード例 #2
0
ファイル: TestWidgets.cs プロジェクト: Morbidous/DownUnder-UI
        public static Widget BrokenStuff()
        {
            var result = new Widget();
            var inner  = new Widget();

            inner.Position = new Point2(50, 50);
            inner.Add(CommonWidgets.Label("Testgfd"));
            inner.Add(CommonWidgets.Label("Testfdasfdsa"));
            inner.Add(CommonWidgets.Label("Test"));
            inner.Add(CommonWidgets.Label("Test"));
            //inner.Add(CommonWidgets.Label("Test"));
            inner.Behaviors.Add(new GridFormat(1, inner.Count));
            result.Add(inner);
            return(result);
        }
コード例 #3
0
ファイル: TestWidgets.cs プロジェクト: Morbidous/DownUnder-UI
        public static Widget LoginWindow(
            Action <LoginSignal> confirm_handle,
            Action <CreateAccountSignal> handle_account_creation = null
            )
        {
            const int login_create_spacing = 8 / 2;

            var window = new Widget {
                Size = new Point2(400, 300), Name = "Login Window"
            };

            window.VisualSettings.VisualRole = GeneralVisualSettings.VisualRoleType.pop_up;

            window.Behaviors.Add(new CenterContent());
            window.Behaviors.Add(new PinWidget {
                Pin = InnerWidgetLocation.Centered
            });
            window.Behaviors.Add(new PopInOut(RectanglePart.Uniform(0.975f), RectanglePart.Uniform(0.5f))
            {
                OpeningMotion = InterpolationSettings.Fast, ClosingMotion = InterpolationSettings.Fast
            });

            var username_entry = CommonWidgets.SingleLineTextEntry("", DrawText.XTextPositioningPolicy.left, DrawText.YTextPositioningPolicy.center, 8f);
            var password_entry = CommonWidgets.SingleLineTextEntry("", DrawText.XTextPositioningPolicy.left, DrawText.YTextPositioningPolicy.center, 8f);

            username_entry.Area = new RectangleF(100, 0, 150, 40);
            password_entry.Area = new RectangleF(100, 60, 150, 40);

            var username_label = CommonWidgets.Label("Username:"******"Password:"******"Login");

            login_button.Area = handle_account_creation != null
                ? new RectangleF(125 + login_create_spacing, 120, 125 - login_create_spacing, 40)
                : new RectangleF(100, 120, 150, 40);

            window.Add(username_label);
            window.Add(password_label);
            window.Add(username_entry);
            window.Add(password_entry);
            window.Add(login_button);

            void handleResponse(WidgetResponse response)
            {
                if (response.Reply != WidgetResponse.ResponseType.reject)
                {
                    return;
                }

                window.ParentDWindow.ShowPopUpMessage("Could not log in.\n\nError: " + response.Message);
            }

            login_button.OnClick += (s, a) =>
                                    confirm_handle.Invoke(new LoginSignal(
                                                              username_entry.Behaviors.Common.DrawText.Text,
                                                              password_entry.Behaviors.Common.DrawText.Text,
                                                              handleResponse
                                                              ));

            if (handle_account_creation == null)
            {
                return(window);
            }

            var create_account_button = CommonWidgets.Button("Create Account");

            create_account_button.Area = new RectangleF(0, 120, 125 - login_create_spacing, 40);

            void handleCreationResponse(WidgetResponse r)
            {
                if (r.Reply != WidgetResponse.ResponseType.reject)
                {
                    return;
                }

                window.ParentDWindow.ShowPopUpMessage("Error creating account: " + r.Message);
            }

            create_account_button.OnClick += (s, a) =>
                                             handle_account_creation.Invoke(
                new CreateAccountSignal(
                    username_entry.Behaviors.Common.DrawText.Text,
                    password_entry.Behaviors.Common.DrawText.Text,
                    "",
                    handleCreationResponse
                    )
                );

            window.Add(create_account_button);

            return(window);
        }