Esempio n. 1
0
        public override void InitElements()
        {
            base.InitElements();

            //window's attr
            Window.SetBackground(45, 45, 45);

            //title
            TitleBar title = new TitleBar("Adding a new member");

            title.SetFont(DefaultsService.GetDefaultFont(14));
            title.GetMinimizeButton().SetVisible(false);
            title.GetMaximizeButton().SetVisible(false);

            VerticalStack layout = new VerticalStack();

            layout.SetMargin(0, title.GetHeight(), 0, 0);
            layout.SetPadding(6, 15, 6, 6);
            layout.SetSpacing(vertical: 30);
            layout.SetBackground(255, 255, 255, 20);

            //message
            _input.EventKeyRelease += OnKeyRelease;

            //ok
            _add.SetBackground(255, 181, 111);
            _add.SetStyle(Styles.GetButtonStyle());
            _add.SetShadow(5, 0, 4, Color.FromArgb(150, 0, 0, 0));
            _add.EventMouseClick += (sender, args) =>
            {
                InputResult = _input.GetText();
                Close();
            };

            //adding items
            Window.AddItems(
                title,
                layout
                );
            layout.AddItems(
                _input,
                _add
                );

            title.GetCloseButton().EventMouseClick  = null;
            title.GetCloseButton().EventMouseClick += (sender, args) =>
            {
                Close();
            };
        }
Esempio n. 2
0
        public override void InitWindow()
        {
            //Window attr
            SetParameters(nameof(MainWindow), nameof(CustomChance), 360, 500, false);
            SetMinSize(350, 500);
            SetBackground(45, 45, 45);
            EventKeyRelease += (sender, args) => OnKeyRelease(sender, args);
            EventClose       = () =>
            {
                CommonLogic.GetInstance().TrySerialize();
                Close();
            };

            //icons
            var big   = new Bitmap(Assembly.GetExecutingAssembly().GetManifestResourceStream("CustomChance.icon_big.png"));
            var small = new Bitmap(Assembly.GetExecutingAssembly().GetManifestResourceStream("CustomChance.icon_small.png"));

            SetIcon(big, small);

            //title
            TitleBar title = new TitleBar("Custom Chance");

            title.SetIcon(small, 16, 16);
            title.SetFont(DefaultsService.GetDefaultFont(14));
            title.GetMaximizeButton().SetVisible(false);

            //layout
            VerticalStack layout = new VerticalStack();

            layout.SetMargin(0, title.GetHeight(), 0, 0);
            layout.SetPadding(3, 3, 3, 3);
            layout.SetSpacing(vertical: 5);
            layout.SetBackground(255, 255, 255, 20);

            //listBox
            _listBox = new ListBox();
            _listBox.SetBackground(52, 52, 52);
            _listBox.SetHScrollBarPolicy(VisibilityPolicy.Never);
            _listBox.SetVScrollBarPolicy(VisibilityPolicy.Never);
            _listBox.SetSelectionVisible(false);

            //AddButton
            AddButton = new ButtonStand("Add a Member!");
            AddButton.SetStyle(Styles.GetButtonStyle());
            AddButton.SetMargin(0, 5, 0, 5);
            AddButton.SetShadow(5, 0, 4, Color.FromArgb(150, 0, 0, 0));
            AddButton.EventMouseClick += (sender, args) =>
            {
                InputDialog dialog = new InputDialog();

                dialog.OnCloseDialog += () =>
                {
                    String result = dialog.InputResult;
                    //add member
                    if (CommonLogic.GetInstance().AddMember(CommonLogic.GetInstance().Storage.Members, result))
                    {
                        //add member to ui
                        MemberItem member = new MemberItem();
                        member.MemberName.SetText(result);
                        member.Index = CommonLogic.GetInstance().Storage.Members.Count - 1;
                        _listBox.AddItem(member);
                    }
                };
                dialog.Show(this);
            };

            //StartButton
            StartButton = new ButtonStand("Make a Chance!");
            StartButton.SetStyle(Styles.GetButtonStyle());
            StartButton.SetMargin(0, 5, 0, 5);
            StartButton.SetShadow(5, 0, 4, Color.FromArgb(150, 0, 0, 0));
            StartButton.EventMouseClick += (sender, args) =>
            {
                if (CommonLogic.GetInstance().Storage.Members == null || CommonLogic.GetInstance().Storage.Members.Count == 0)
                {
                    return;
                }
                CommonLogic.GetInstance().StartRandom(CommonLogic.GetInstance().Storage.Members);
                UpdateUI();
            };

            //adding
            AddItems(
                title,
                layout
                );
            layout.AddItems(
                AddButton,
                _listBox,
                StartButton
                );

            //load save file
            if (CommonLogic.GetInstance().Storage.Members.Count > 0)
            {
                RestoreItems();
            }
        }