Example #1
0
        /// <summary>
        /// Shows a simple number input prompt, but for a pointer
        /// </summary>
        public static Pointer ShowPointerArrayBoxDialog(string text, string caption)
        {
            Label label = new Label()
            {
                Text      = text,
                Left      = 25,
                Top       = 15,
                AutoSize  = false,
                Size      = new Size(250, 30),
                TextAlign = ContentAlignment.MiddleCenter
            };
            Form dialog = new Form()
            {
                Width           = 300,
                Height          = 100 + label.Height,
                Text            = caption,
                FormBorderStyle = FormBorderStyle.FixedDialog,
                StartPosition   = FormStartPosition.CenterScreen
            };
            Button confirm = new Button()
            {
                Text         = "OK",
                Left         = dialog.Width - 100,
                Top          = 25 + label.Height,
                Width        = 60,
                DialogResult = DialogResult.OK
            };

            confirm.Click += (sender, e) => { dialog.Close(); };
            PointerArrayBox input = new PointerArrayBox()
            {
                Left    = 20,
                Top     = 25 + label.Height,
                Width   = 160,
                Maximum = new GBA.Pointer(Core.CurrentROMSize),
            };

            input.Load("Chapter Unit Pointers.txt");
            dialog.Controls.Add(input);
            dialog.Controls.Add(confirm);
            dialog.Controls.Add(label);
            dialog.AcceptButton = confirm;

            return(dialog.ShowDialog() == DialogResult.OK ? input.Value : new GBA.Pointer());
        }
Example #2
0
        /// <summary>
        /// Returns the control associated with this module property
        /// </summary>
        public Control GetControl()
        {
            Control control;
            long    max = (long)Math.Pow(2, Length);

            switch (ControlType)
            {
            case PropertyType.BOOL: control = new CheckBox()
            {
                    Size = new Size(20, 20),
            }; break;

            case PropertyType.TEXT: control = new TextBox()
            {
                    Size      = new Size(100, 20),
                    MaxLength = Length >> 3,
            }; break;

            case PropertyType.HEXT: control = new HexBox()
            {
                    Size = new Size(200, 50),
                    VScrollBarVisible = true
            }; break;

            case PropertyType.HEXU: control = new NumericUpDown()
            {
                    Size        = new Size(32 + Length, 20),
                    Minimum     = 0,
                    Maximum     = max,
                    Hexadecimal = true,
            }; break;

            case PropertyType.NUMU: control = new NumericUpDown()
            {
                    Size        = new Size(40 + Length, 20),
                    Minimum     = 0,
                    Maximum     = max,
                    Hexadecimal = false,
            }; break;

            case PropertyType.NUMS: control = new NumericUpDown()
            {
                    Size        = new Size(40 + Length, 20),
                    Minimum     = (max / 2) * -1,
                    Maximum     = (max / 2),
                    Hexadecimal = false,
            }; break;

            case PropertyType.LIST:
                if (FileName == null)
                {
                    control = new ByteBox()
                    {
                    }
                }
                ;
                else
                {
                    control = new ByteArrayBox()
                    {
                        AutoSize = true
                    };
                    ((ByteArrayBox)control).Load(FileName);
                } break;

            case PropertyType.POIN:
                if (FileName == null)
                {
                    control = new PointerBox()
                    {
                    }
                }
                ;
                else
                {
                    control = new PointerArrayBox()
                    {
                        AutoSize = true
                    };
                    ((PointerArrayBox)control).Load(FileName);
                } break;

            default: return(null);
            }
            control.Anchor = AnchorStyles.Left;
            return(control);
        }