コード例 #1
0
        public override void AddedToContainer()
        {
            base.AddedToContainer();

            var builder = new FieldBuilder();

            builder.BuildSessionStart(this);

            var templateNameTextField = builder.AddTextField("Template Name: ");

            templateNameTextField.Text = template.TemplateName;

            var panel = new Panel();

            panel.Initialize();
            builder.AddDrawBoxAsField(panel, DrawBoxAlignment.GetFull());

            var guiMethod   = template.Creature.GetType().GetMethod("GUI_Edit");
            var isReadyFunc = (Func <bool>)guiMethod.Invoke(template.Creature, new object[] { panel });

            panel.Width = builder.FieldWidth;

            Wrap();

            var okButton = new ResizableButton();

            okButton.Initialize();
            AddDrawBox(okButton);
            okButton.Title = "OK";
            okButton.FitToText();
            okButton.X      = builder.FieldWidth - okButton.Width;
            okButton.Y      = Height + 5;
            okButton.Click += delegate(object sender)
            {
                if (isReadyFunc())
                {
                    template.TemplateName = templateNameTextField.Text;
                    Close();
                }
                else
                {
                    AlertForm.ShowDialogue(Parent, null, "All fields have not been filled out.");
                }
            };

            builder.BuildSessionEnd();

            okButton.Alignment = DrawBoxAlignment.GetRightBottom();

            X = (Parent.Width / 2) - (Width / 2);
            Y = (Parent.Height / 2) - (Height / 2);

            CanResizeFormVertically = true;
        }
コード例 #2
0
ファイル: FileForm.cs プロジェクト: lukastk/TakaGUI
        public override void AddedToContainer()
        {
            const int buttonMinSize = 50;

            selector = new FileSelector();
            selector.Initialize(null, file);
            AddDrawBox(selector);
            selector.Width  = 200;
            selector.Height = 100;

            cancelButton = new ResizableButton();
            cancelButton.Initialize(null, file);
            AddDrawBox(cancelButton);
            cancelButton.Title = "Cancel";
            cancelButton.FitToText();
            cancelButton.Width = Math.Max(cancelButton.Width, buttonMinSize);
            cancelButton.X     = 0;
            cancelButton.Y     = selector.Height + 3;

            okButton = new ResizableButton();
            okButton.Initialize(null, file);
            AddDrawBox(okButton);
            switch (OperationType)
            {
            case OperationTypes.Open:
                okButton.Title = "Open";
                break;

            case OperationTypes.Save:
                okButton.Title = "Save";
                break;

            case OperationTypes.Select:
                okButton.Title = "Select";
                break;
            }
            okButton.FitToText();
            okButton.Width = Math.Max(okButton.Width, buttonMinSize);
            okButton.X     = selector.Width - cancelButton.Width;
            okButton.Y     = selector.Height + 3;

            Wrap();

            selector.Alignment     = DrawBoxAlignment.GetFull();
            okButton.Alignment     = DrawBoxAlignment.GetRightBottom();
            cancelButton.Alignment = DrawBoxAlignment.GetLeftBottom();

            okButton.Click     += new DefaultEvent(okButton_Click);
            cancelButton.Click += new DefaultEvent(cancelButton_Click);
        }