Example #1
0
        public DXInputWindow(string message, string caption)
        {
            HasFooter = true;

            TitleLabel.Text = caption;

            Parent = ActiveScene;
            MessageBoxList.Add(this);


            Label = new DXLabel
            {
                AutoSize   = false,
                Location   = new Point(10, 35),
                Parent     = this,
                Text       = message,
                DrawFormat = TextFormatFlags.VerticalCenter | TextFormatFlags.WordBreak | TextFormatFlags.HorizontalCenter
            };
            Label.Size = new Size(300, DXLabel.GetHeight(Label, 300).Height);

            ValueTextBox = new DXTextBox
            {
                Parent    = this,
                Size      = new Size(200, 20),
                Location  = new Point(60, 45 + Label.Size.Height),
                KeepFocus = true,
            };
            ValueTextBox.SetFocus();
            ValueTextBox.TextBox.TextChanged += TextBox_TextChanged;
            ValueTextBox.TextBox.KeyPress    += (o, e) => OnKeyPress(e);


            SetClientSize(new Size(300, Label.Size.Height + 30));
            Label.Location = ClientArea.Location;

            ConfirmButton = new DXButton
            {
                Location = new Point((Size.Width) / 2 - 80 - 10, Size.Height - 43),
                Size     = new Size(80, DefaultHeight),
                Parent   = this,
                Label    = { Text = "Confirm" }
            };
            ConfirmButton.MouseClick += (o, e) => Dispose();

            CancelButton = new DXButton
            {
                Location = new Point(Size.Width / 2 + 10, Size.Height - 43),
                Size     = new Size(80, DefaultHeight),
                Parent   = this,
                Label    = { Text = "Cancel" }
            };
            CancelButton.MouseClick += (o, e) => Dispose();

            Location = new Point((ActiveScene.DisplayArea.Width - DisplayArea.Width) / 2, (ActiveScene.DisplayArea.Height - DisplayArea.Height) / 2);
        }
        /// <summary>
        ///     Shows a metro message box containing a list of items in it.
        /// </summary>
        /// <param name="title">The title of the Message Box</param>
        /// <param name="message">The message to be displayed in the Message Box</param>
        /// <param name="items">The items to be displayed in the message box.</param>
        public static bool Show(string title, string message, IEnumerable <object> items)
        {
            var msgBox = new MessageBoxList(title, message, items)
            {
                Owner = App.AssemblyStorage.AssemblySettings.HomeWindow,
                WindowStartupLocation = WindowStartupLocation.CenterOwner
            };

            msgBox.ShowDialog();
            return(msgBox.DialogResult ?? false);
        }
Example #3
0
        public DXItemAmountWindow(string caption, ClientUserItem item)
        {
            HasFooter = true;

            TitleLabel.Text = caption;
            SetClientSize(new Size(200, DXItemCell.CellHeight + 10));

            Parent = ActiveScene;
            MessageBoxList.Add(this);
            Modal = true;

            Location = new Point((ActiveScene.DisplayArea.Width - DisplayArea.Width) / 2, (ActiveScene.DisplayArea.Height - DisplayArea.Height) / 2);

            ConfirmButton = new DXButton
            {
                Location = new Point(Size.Width / 2 + 10, Size.Height - 43),
                Size     = new Size(80, DefaultHeight),
                Parent   = this,
                Label    = { Text = "Confirm" }
            };
            ConfirmButton.MouseClick += (o, e) => Dispose();

            AmountBox = new DXNumberBox
            {
                Parent   = this,
                MaxValue = item.Count,
                Change   = Math.Max(1, item.Count / 5),
            };

            AmountBox.ValueTextBox.ValueChanged += (o, e) =>
            {
                Amount = AmountBox.Value;

                if (Amount <= 0)
                {
                    AmountBox.ValueTextBox.BorderColour = Color.Red;
                }
                else if (Amount == AmountBox.MaxValue)
                {
                    AmountBox.ValueTextBox.BorderColour = Color.Orange;
                }
                else
                {
                    AmountBox.ValueTextBox.BorderColour = Color.Green;
                }

                ConfirmButton.Enabled = Amount > 0;

                if (item.Info.Effect == ItemEffect.Gold)
                {
                    item.Count = Amount;
                    ItemCell.RefreshItem();
                }
            };

            ItemCell = new DXItemCell
            {
                Location    = new Point(ClientArea.Location.X + (ClientArea.Width - DXItemCell.CellWidth - AmountBox.Size.Width - 5) / 2, ClientArea.Location.Y + 5),
                Parent      = this,
                FixedBorder = true,
                Border      = true,
                ItemGrid    = new[] { item },
                Slot        = 0,
                GridType    = GridType.None,
                ReadOnly    = true,
            };

            AmountBox.Location = new Point(ItemCell.Location.X + ItemCell.Size.Width + 10, ItemCell.Location.Y + (ItemCell.Size.Height - AmountBox.Size.Height) / 2);

            AmountBox.Value = 1;
            AmountBox.ValueTextBox.KeepFocus = true;
            AmountBox.ValueTextBox.SetFocus();
            AmountBox.ValueTextBox.TextBox.KeyPress += AmountBox_KeyPress;
        }
Example #4
0
        public DXMessageBox(string message, string caption, DXMessageBoxButtons buttons = DXMessageBoxButtons.OK)
        {
            Buttons   = buttons;
            Modal     = true;
            HasFooter = true;

            TitleLabel.Text = caption;

            Parent = ActiveScene;
            MessageBoxList.Add(this);


            Label = new DXLabel
            {
                AutoSize   = false,
                Location   = new Point(10, 35),
                Parent     = this,
                Text       = message,
                DrawFormat = TextFormatFlags.VerticalCenter | TextFormatFlags.HorizontalCenter
            };
            Label.Size = new Size(380, DXLabel.GetSize(message, Label.Font, Label.Outline).Height);
            SetClientSize(Label.Size);
            Label.Location = ClientArea.Location;

            Location = new Point((ActiveScene.DisplayArea.Width - DisplayArea.Width) / 2, (ActiveScene.DisplayArea.Height - DisplayArea.Height) / 2);


            switch (Buttons)
            {
            case DXMessageBoxButtons.OK:
                OKButton = new DXButton
                {
                    Location = new Point((Size.Width - 80) / 2, Size.Height - 43),
                    Size     = new Size(80, DefaultHeight),
                    Parent   = this,
                    Label    = { Text = "OK" }
                };
                OKButton.MouseClick += (o, e) => Dispose();
                break;

            case DXMessageBoxButtons.YesNo:
                YesButton = new DXButton
                {
                    Location = new Point((Size.Width) / 2 - 80 - 10, Size.Height - 43),
                    Size     = new Size(80, DefaultHeight),
                    Parent   = this,
                    Label    = { Text = "Yes" }
                };
                YesButton.MouseClick += (o, e) => Dispose();
                NoButton              = new DXButton
                {
                    Location = new Point(Size.Width / 2 + 10, Size.Height - 43),
                    Size     = new Size(80, DefaultHeight),
                    Parent   = this,
                    Label    = { Text = "No" }
                };
                NoButton.MouseClick += (o, e) => Dispose();
                break;

            case DXMessageBoxButtons.Cancel:
                CancelButton = new DXButton
                {
                    Location = new Point((Size.Width - 80) / 2, Size.Height - 43),
                    Size     = new Size(80, DefaultHeight),
                    Parent   = this,
                    Label    = { Text = "Cancel" }
                };
                CancelButton.MouseClick += (o, e) => Dispose();
                break;
            }

            BringToFront();
        }
Example #5
0
        protected override void Dispose(bool disposing)
        {
            base.Dispose(disposing);

            if (disposing)
            {
                if (Label != null)
                {
                    if (!Label.IsDisposed)
                    {
                        Label.Dispose();
                    }
                    Label = null;
                }

                if (OKButton != null)
                {
                    if (!OKButton.IsDisposed)
                    {
                        OKButton.Dispose();
                    }
                    OKButton = null;
                }

                if (CancelButton != null)
                {
                    if (!CancelButton.IsDisposed)
                    {
                        CancelButton.Dispose();
                    }
                    CancelButton = null;
                }

                if (NoButton != null)
                {
                    if (!NoButton.IsDisposed)
                    {
                        NoButton.Dispose();
                    }
                    NoButton = null;
                }

                if (YesButton != null)
                {
                    if (!YesButton.IsDisposed)
                    {
                        YesButton.Dispose();
                    }
                    YesButton = null;
                }

                if (HiddenBox != null)
                {
                    DXTextBox.ActiveTextBox = HiddenBox;
                    HiddenBox = null;
                }

                Buttons = DXMessageBoxButtons.None;
                MessageBoxList.Remove(this);
            }
        }