Esempio n. 1
0
        /// <summary>
        /// Initializes a new instance of the <see cref="CreateFilesDialog"/> class.
        /// </summary>
        /// <param name="entry">The entry to edit it's settings.</param>
        public CreateFilesDialog(CreateFileEntry entry)
            : base("Create file settings")
        {
            _entry = entry ?? throw new ArgumentNullException();

            const float TotalWidth   = 520;
            const float EditorHeight = 250;

            Width = TotalWidth;

            // Header and help description
            var headerLabel = new Label(0, 0, TotalWidth, 40)
            {
                Text      = "Asset Options",
                DockStyle = DockStyle.Top,
                Parent    = this,
                Font      = new FontReference(Style.Current.FontTitle)
            };
            var infoLabel = new Label(10, headerLabel.Bottom + 5, TotalWidth - 20, 40)
            {
                Text = "Specify options for creating new asset",
                HorizontalAlignment = TextAlignment.Near,
                Margin    = new Margin(7),
                DockStyle = DockStyle.Top,
                Parent    = this
            };

            // Buttons
            const float ButtonsWidth  = 60;
            const float ButtonsMargin = 8;
            var         createButton  = new Button(TotalWidth - ButtonsMargin - ButtonsWidth, infoLabel.Bottom - 30, ButtonsWidth)
            {
                Text        = "Create",
                AnchorStyle = AnchorStyle.UpperRight,
                Parent      = this
            };

            createButton.Clicked += OnCreate;
            var cancelButton = new Button(createButton.Left - ButtonsMargin - ButtonsWidth, createButton.Y, ButtonsWidth)
            {
                Text        = "Cancel",
                AnchorStyle = AnchorStyle.UpperRight,
                Parent      = this
            };

            cancelButton.Clicked += OnCancel;

            // Panel for settings editor
            var panel = new Panel(ScrollBars.Vertical)
            {
                Y         = infoLabel.Bottom,
                Size      = new Vector2(TotalWidth, EditorHeight),
                DockStyle = DockStyle.Fill,
                Parent    = this
            };

            // Settings editor
            _settingsEditor = new CustomEditorPresenter(null);
            _settingsEditor.Panel.Parent = panel;

            Size = new Vector2(TotalWidth, panel.Bottom);

            _settingsEditor.Select(_entry.Settings);
        }
Esempio n. 2
0
        /// <summary>
        /// Initializes a new instance of the <see cref="CreateFilesDialog"/> class.
        /// </summary>
        /// <param name="entry">The entry to edit it's settings.</param>
        public CreateFilesDialog(CreateFileEntry entry)
            : base("Create file settings")
        {
            _entry = entry ?? throw new ArgumentNullException();

            const float TotalWidth   = 520;
            const float EditorHeight = 250;

            Width = TotalWidth;

            // Header and help description
            var headerLabel = new Label
            {
                Text         = "Asset Options",
                AnchorPreset = AnchorPresets.HorizontalStretchTop,
                Offsets      = new Margin(0, 0, 0, 40),
                Parent       = this,
                Font         = new FontReference(Style.Current.FontTitle)
            };
            var infoLabel = new Label
            {
                Text = "Specify options for creating new asset",
                HorizontalAlignment = TextAlignment.Near,
                Margin       = new Margin(7),
                AnchorPreset = AnchorPresets.HorizontalStretchTop,
                Offsets      = new Margin(10, -20, 45, 70),
                Parent       = this
            };

            // Buttons
            const float ButtonsWidth  = 60;
            const float ButtonsHeight = 24;
            const float ButtonsMargin = 8;
            var         createButton  = new Button
            {
                Text         = "Create",
                AnchorPreset = AnchorPresets.BottomRight,
                Offsets      = new Margin(-ButtonsWidth - ButtonsMargin, ButtonsWidth, -ButtonsHeight - ButtonsMargin, ButtonsHeight),
                Parent       = this
            };

            createButton.Clicked += OnCreate;
            var cancelButton = new Button
            {
                Text         = "Cancel",
                AnchorPreset = AnchorPresets.BottomRight,
                Offsets      = new Margin(-ButtonsWidth - ButtonsMargin - ButtonsWidth - ButtonsMargin, ButtonsWidth, -ButtonsHeight - ButtonsMargin, ButtonsHeight),
                Parent       = this
            };

            cancelButton.Clicked += OnCancel;

            // Panel for settings editor
            var panel = new Panel(ScrollBars.Vertical)
            {
                AnchorPreset = AnchorPresets.HorizontalStretchTop,
                Offsets      = new Margin(2, 2, infoLabel.Bottom + 2, EditorHeight),
                Parent       = this
            };

            // Settings editor
            _settingsEditor = new CustomEditorPresenter(null);
            _settingsEditor.Panel.Parent = panel;

            _dialogSize = new Vector2(TotalWidth, panel.Bottom);

            _settingsEditor.Select(_entry.Settings);
        }