public PBTTaskTreeControl(GLGui gui, Task <DataType> task, bool extended)
            : base(gui)
        {
            Render           += OnRender;
            HandleMouseEvents = false;
            AutoSize          = true;
            TaskControl       = Add(new PBTTaskControl <DataType>(gui, task, extended));

            horizontalFlow = Add(new GLGroupLayout(gui)
            {
                AutoSize          = true,
                HandleMouseEvents = false,
                Location          = new Point(0, TaskControl.Height + VSpace)
            });

            if (task is PBT.ParentTask <DataType> )
            {
                foreach (var subtask in ((PBT.ParentTask <DataType>)task).Subtasks)
                {
                    Subtrees.Add(horizontalFlow.Add(new PBTTaskTreeControl <DataType>(gui, subtask, extended)));
                }
            }
            else if (task is PBT.TaskDecorator <DataType> )
            {
                Subtrees.Add(horizontalFlow.Add(new PBTTaskTreeControl <DataType>(gui, ((PBT.TaskDecorator <DataType>)task).Subtask, extended)));
            }
            else if (task is PBT.LeafTasks.Reference <DataType> )
            {
                Subtrees.Add(horizontalFlow.Add(new PBTTaskTreeControl <DataType>(gui, ((PBT.LeafTasks.Reference <DataType>)task).Root, extended)));
            }
        }
示例#2
0
 public PBTOverviewControl(GLGui gui, PBTTreeContainer treeContainer)
     : base(gui)
 {
     TreeContainer = treeContainer;
     Render       += OnRender;
     MouseDown    += OnMouseDown;
     MouseUp      += OnMouseUp;
     MouseMove    += OnMouseMove;
 }
示例#3
0
        public GLContextMenuEntry(GLGui gui) : base(gui)
        {
            SkinEnabled  = Gui.Skin.ContextMenuEntryEnabled;
            SkinPressed  = Gui.Skin.ContextMenuEntryPressed;
            SkinHover    = Gui.Skin.ContextMenuEntryHover;
            SkinDisabled = Gui.Skin.ContextMenuEntryDisabled;

            Click += (s, e) => Gui.CloseContextMenu();
        }
        public PBTTreeContainer(GLGui gui)
            : base(gui)
        {
            Anchor = GLAnchorStyles.All;
            var skin = Skin;

            skin.BackgroundColor = System.Drawing.Color.FromArgb(96, 96, 96);
            skin.BorderColor     = gui.Skin.FormActive.BorderColor;
            Skin = skin;

            MouseDown += OnMouseDown;
            MouseUp   += OnMouseUp;
            MouseMove += OnMouseMove;
        }
示例#5
0
        public PBTDescriptionForm(GLGui gui, GLLabel descriptionLabel, Data.Task task)
            : base(gui)
        {
            this.task             = task;
            this.descriptionLabel = descriptionLabel;

            Title   = task.TaskType.Name + " Description";
            SizeMin = Size = new Size(200, 100);

            var descriptionBackup = task.Description;

            var text = Add(new GLTextBox(gui)
            {
                Text      = task.Description ?? "",
                Location  = new Point(4, 4),
                AutoSize  = false,
                Multiline = true,
                WordWrap  = true,
                Size      = new Size(InnerWidth - 8, InnerHeight - 27),
                Anchor    = GLAnchorStyles.All
            });

            text.Changed += (s, e) => descriptionLabel.Text = task.Description = text.Text;

            var ok = Add(new GLButton(gui)
            {
                Text     = "OK",
                Location = new Point(4, InnerHeight - 18),
                Anchor   = GLAnchorStyles.Bottom | GLAnchorStyles.Left
            });

            ok.Click += (s, e) => { if (text.Text == "")
                                    {
                                        task.Description = null;
                                    }
                                    Parent.Remove(this); };

            var abort = Add(new GLButton(gui)
            {
                Text     = "Abort",
                Location = new Point(InnerWidth - 79, InnerHeight - 19),
                Anchor   = GLAnchorStyles.Bottom | GLAnchorStyles.Right
            });

            abort.Click += (s, e) => { descriptionLabel.Text = (task.Description = descriptionBackup) ?? ""; Parent.Remove(this); };
        }
示例#6
0
        public PBTImpulseFilterForm(GLGui gui, PBTImpulseLogger <DataType, ImpulseType> logger)
            : base(gui)
        {
            Title = "Impulse Filter";
            var impulseNames  = Enum.GetNames(typeof(ImpulseType));
            var impulseValues = (ImpulseType[])Enum.GetValues(typeof(ImpulseType));

            SizeMin = Size = new Size(150, 40 + 15 * impulseNames.Length);

            var flow = Add(new GLFlowLayout(Gui)
            {
                Location      = new Point(4, 4),
                Size          = new Size(InnerWidth - 8, InnerHeight - 27),
                AutoSize      = false,
                Anchor        = GLAnchorStyles.All,
                FlowDirection = GLFlowDirection.TopDown
            });

            for (int j = 0; j < impulseNames.Length; j++)
            {
                int i  = j;
                var cb = flow.Add(new GLCheckBox(Gui)
                {
                    Text = impulseNames[j], AutoSize = true, Checked = logger.Enabled.Contains(impulseValues[j])
                });
                cb.Changed += (s, ev) => { if (cb.Checked)
                                           {
                                               logger.Enabled.Add(impulseValues[i]);
                                           }
                                           else
                                           {
                                               logger.Enabled.Remove(impulseValues[i]);
                                           } };
            }

            var ok = Add(new GLButton(gui)
            {
                Text     = "OK",
                Location = new Point(4, InnerHeight - 18),
                Anchor   = GLAnchorStyles.Bottom | GLAnchorStyles.Left
            });

            ok.Click += (s, e) => { Parent.Remove(this); };
        }
示例#7
0
        public PBTTaskControl(GLGui gui, PBTEditorControl editor, PBTTaskTreeControl taskTreeControl, Data.Task task)
            : base(gui)
        {
            Editor          = editor;
            TaskTreeControl = taskTreeControl;
            Task            = task;

            AutoSize      = true;
            FlowDirection = GLFlowDirection.TopDown;
            var skin = Skin;

            skin.Border          = new GLPadding(1);
            skin.BorderColor     = Color.FromArgb(32, 32, 32);
            skin.BackgroundColor = Color.FromArgb(48, 48, 48);
            Skin = skin;

            LoadCommon();

            AddContextMenu();
            AddContent();
        }
示例#8
0
        public GLDataControl(GLGui gui) : base(gui)
        {
            Render += (s, d) => UpdateData();

            horizontal = Add(new GLFlowLayout(gui)
            {
                FlowDirection = GLFlowDirection.LeftToRight, AutoSize = true
            });
            left = horizontal.Add(new GLFlowLayout(gui)
            {
                FlowDirection = GLFlowDirection.TopDown, AutoSize = true
            });
            var skin = left.Skin;

            skin.Space = 0;
            left.Skin  = skin;
            right      = horizontal.Add(new GLFlowLayout(gui)
            {
                FlowDirection = GLFlowDirection.TopDown, AutoSize = true
            });
            right.Skin = skin;

            labelSkin     = gui.Skin.LabelEnabled;
            linkLabelSkin = gui.Skin.LinkLabelEnabled;

            // defaults
            Hidden.Add(typeof(IEnumerable), new string[] {
                "_items", "_size", "_version", "_syncRoot",
                "m_buckets", "m_slots", "m_count", "m_lastIndex", "m_freeList", "m_comparer",
                "m_version", "m_siInfo", "m_collection", "m_boundedCapacity", "m_freeNodes",
                "m_occupiedNodes", "m_isDisposed", "m_ConsumersCancellationTokenSource",
                "m_ProducersCancellationTokenSource", "m_currentAdders",
                "buckets", "entries", "count", "version", "freeList", "freeCount", "comparer", "keys", "values",
                "IsFixedSize", "IsReadOnly", "IsSynchronized", "SyncRoot"
            });
            Hidden.Add(typeof(Array), new string[] { "LongLength", "Rank", "Count" });
            Hidden.Add(typeof(KeyValuePair <,>), new string[] { "key", "value" });
            Hidden.Add(typeof(Dictionary <,>), new string[] { "Keys", "Values" });
        }
示例#9
0
        public PBTTaskTreeControl(GLGui gui, PBTEditorControl editor, PBTTaskTreeControl parentTaskTreeControl, Data.Task task)
            : base(gui)
        {
            Editor = editor;
            ParentTaskTreeControl = parentTaskTreeControl;
            Render           += OnRender;
            HandleMouseEvents = false;
            AutoSize          = true;
            TaskControl       = Add(new PBTTaskControl(gui, editor, this, task));

            horizontalFlow = Add(new GLGroupLayout(gui)
            {
                AutoSize          = true,
                HandleMouseEvents = false,
                Location          = new Point(0, TaskControl.Height + VSpace)
            });

            foreach (var subtask in task.Subtasks)
            {
                Subtrees.Add(horizontalFlow.Add(new PBTTaskTreeControl(gui, editor, this, subtask)));
            }
        }
        public PBTTaskControl(GLGui gui, PBT.Task <DataType> task, bool extended)
            : base(gui)
        {
            Task = task;

            Render += OnRender;

            AutoSize             = true;
            FlowDirection        = GLFlowDirection.TopDown;
            skin                 = Skin;
            skin.Border          = new GLPadding(1);
            skin.BorderColor     = Color.FromArgb(32, 32, 32);
            skin.BackgroundColor = Color.FromArgb(48, 48, 48);
            Skin                 = skin;

            if (monospaceFont == null)
            {
                monospaceFont = new GLFont(new Font("Lucida Console", 6.5f));
                monospaceFont.Options.Monospacing = GLFontMonospacing.Yes;
            }

            // title
            title = Add(new GLLabel(Gui)
            {
                AutoSize = true, Text = Task.GetType().Name.TrimEnd('1', '2', '`')
            });
            var titleSkin = title.SkinEnabled;

            titleSkin.TextAlign = GLFontAlignment.Centre;
            titleSkin.Color     = Color.FromArgb(255, 255, 255);
            title.SkinEnabled   = titleSkin;
            title.AutoSize      = false;

            if (extended)
            {
                // content (quick and dirty)
                string contentString = "";
                var    fields        = task.GetType().GetFields(BindingFlags.Instance | BindingFlags.NonPublic);
                foreach (var f in fields)
                {
                    var v = f.GetValue(task);
                    if (v == null)
                    {
                        continue;
                    }
                    var ft = f.FieldType.Name.TrimEnd('1', '2', '`') + " " + f.Name + ":\n ";
                    if (v is string && f.Name == "impulse")
                    {
                        contentString += ft + v.ToString() + "\n\n";
                    }
                    else if (v is Expression || v.GetType().Name.Contains("Expression")) // i'm lazy right now :/
                    {
                        var codeField = v.GetType().GetField("code", BindingFlags.Instance | BindingFlags.NonPublic);
                        if (codeField == null)
                        { // must be ResultExpression
                            contentString += ft + v.ToString() + "\n\n";
                        }
                        else
                        {
                            var code = codeField.GetValue(v);
                            if (code != null)
                            {
                                contentString += ft + code.ToString().Replace("\n", "\n ") + "\n\n";
                            }
                            else
                            {
                                contentString += ft + "null\n\n";
                            }
                        }
                    }
                }
                contentString = contentString.TrimEnd('\n', '\t');
                if (contentString.Length > 0)
                {
                    var content = Add(new GLLabel(Gui)
                    {
                        AutoSize = true, Text = contentString, Multiline = true, WordWrap = false
                    });
                    var contentSkin = content.SkinEnabled;
                    contentSkin.Font    = monospaceFont;
                    content.SkinEnabled = contentSkin;
                }
            }
        }
示例#11
0
        private void OnLoad(object sender, EventArgs e)
        {
            VSync = false;             // vsync is nice, but you can't really measure performance while it's on

            glgui = new GLGui(this);

            var mainAreaControl = glgui.Add(new GLGroupLayout(glgui)
            {
                Size = new Size(ClientSize.Width, ClientSize.Height - 200), Anchor = GLAnchorStyles.All
            });
            // change background color:
            var mainSkin = mainAreaControl.Skin;

            mainSkin.BackgroundColor = glgui.Skin.FormActive.BackgroundColor;
            mainSkin.BorderColor     = glgui.Skin.FormActive.BorderColor;
            mainAreaControl.Skin     = mainSkin;

            var consoleScrollControl = glgui.Add(new GLScrollableControl(glgui)
            {
                Outer = new Rectangle(0, ClientSize.Height - 200, ClientSize.Width, 200), Anchor = GLAnchorStyles.Left | GLAnchorStyles.Right | GLAnchorStyles.Bottom
            });

            console = consoleScrollControl.Add(new GLLabel(glgui)
            {
                AutoSize = true, Multiline = true
            });

            fpsLabel = mainAreaControl.Add(new GLLabel(glgui)
            {
                Location = new Point(10, 10), AutoSize = true
            });
            // change font and background color:
            var skin = fpsLabel.SkinEnabled;

            skin.Font            = new GLFont(new Font("Arial", 12.0f));
            skin.BackgroundColor = glgui.Skin.TextBoxActive.BackgroundColor;
            fpsLabel.SkinEnabled = skin;

            var helloWorldForm = mainAreaControl.Add(new GLForm(glgui)
            {
                Title = "Hello World", Outer = new Rectangle(50, 100, 200, 150), AutoSize = false
            });

            helloWorldForm.Add(new GLForm(glgui)
            {
                Title = "Hello Form", Outer = new Rectangle(100, 32, 100, 100), AutoSize = false
            })
            .MouseMove += (s, w) => Console.WriteLine(w.Position.ToString());

            var flow = helloWorldForm.Add(new GLFlowLayout(glgui)
            {
                FlowDirection = GLFlowDirection.BottomUp, Location = new Point(10, 10), Size = helloWorldForm.InnerSize, AutoSize = true
            });

            for (int i = 0; i < 5; i++)
            {
                flow.Add(new GLButton(glgui)
                {
                    Text = "Button" + i, Size = new Size(150, 0)
                })
                .Click += (s, w) => Console.WriteLine(s + " pressed.");
            }
            flow.Add(new GLButton(glgui)
            {
                Text = "Hide Cursor", Size = new Size(150, 0)
            })
            .Click += (s, w) => glgui.Cursor = GLCursor.None;

            var loremIpsumForm = mainAreaControl.Add(new GLForm(glgui)
            {
                Title = "Lorem Ipsum", Location = new Point(600, 100), Size = new Size(300, 200)
            });

            loremIpsumForm.Add(new GLTextBox(glgui)
            {
                Text      = "Lorem ipsum dolor sit amet,\nconsetetur sadipscing elitr,\nsed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat,\nsed diam voluptua.\n\nAt vero eos et accusam et justo duo dolores et ea rebum. Stet clita kasd gubergren, no sea takimata sanctus est Lorem ipsum dolor sit amet. Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat, sed diam voluptua. At vero eos et accusam et justo duo dolores et ea rebum. Stet clita kasd gubergren, no sea takimata sanctus est Lorem ipsum dolor sit amet.",
                Multiline = true,
                WordWrap  = true,
                Outer     = new Rectangle(4, 4, loremIpsumForm.Inner.Width - 8, loremIpsumForm.Inner.Height - 8),
                Anchor    = GLAnchorStyles.All
            }).Changed += (s, w) => Console.WriteLine(s + " text length: " + ((GLTextBox)s).Text.Length);

            var fixedSizeForm = mainAreaControl.Add(new GLForm(glgui)
            {
                Title = "Fixed size Form", Location = new Point(64, 300), Size = new Size(100, 200), AutoSize = true
            });
            var fooBarFlow = fixedSizeForm.Add(new GLFlowLayout(glgui)
            {
                FlowDirection = GLFlowDirection.TopDown, AutoSize = true
            });

            fooBarFlow.Add(new GLCheckBox(glgui)
            {
                Text = "CheckBox A", AutoSize = true
            })
            .Changed += (s, w) => Console.WriteLine(s + ": " + ((GLCheckBox)s).Checked);
            fooBarFlow.Add(new GLCheckBox(glgui)
            {
                Text = "CheckBox B", AutoSize = true
            })
            .Changed += (s, w) => Console.WriteLine(s + ": " + ((GLCheckBox)s).Checked);
            fooBarFlow.Add(new GLCheckBox(glgui)
            {
                Text = "Totally different CheckBox", AutoSize = true
            })
            .Changed += (s, w) => Console.WriteLine(s + ": " + ((GLCheckBox)s).Checked);
            fooBarFlow.Add(new GLCheckBox(glgui)
            {
                Text = "Go away!", AutoSize = true
            })
            .Changed += (s, w) => Console.WriteLine(s + ": " + ((GLCheckBox)s).Checked);

            for (int i = 0; i < 3; i++)
            {
                var viewportForm = mainAreaControl.Add(new GLForm(glgui)
                {
                    Title = "Cube", Location = new Point(300 + i * 16, 64 + i * 16), Size = new Size(200, 200)
                });
                viewportForm.Add(new GLViewport(glgui)
                {
                    Size = viewportForm.InnerSize, Anchor = GLAnchorStyles.All
                })
                .RenderViewport += OnRenderViewport;
            }

            stopwatch = new Stopwatch();
            Resize   += (s, ev) => GL.Viewport(ClientSize);
            Paint    += OnRender;

            stopwatch.Start();
            Application.Idle += (s, ev) => Invalidate();
        }
示例#12
0
        private void OnLoad(object sender, EventArgs e)
        {
            MakeCurrent();
            MouseUp  += (s, ev) => { try { MakeCurrent(); } catch (GraphicsContextException) { } }; // workaround for correct context switching (mouseclicks might change the gui directly)
            KeyDown  += (s, ev) => { try { MakeCurrent(); } catch (GraphicsContextException) { } };
            KeyPress += (s, ev) => { try { MakeCurrent(); } catch (GraphicsContextException) { } };
            glGui     = new GLGui(this);

            var verticalSplitter = glGui.Add(new GLSplitLayout(glGui)
            {
                Size             = ClientSize,
                SplitterPosition = 0.85f,
                Orientation      = GLSplitterOrientation.Vertical,
                Anchor           = GLAnchorStyles.All
            });

            TreeContainer = verticalSplitter.Add(new PBTTreeContainer(glGui));

            var sidebarFlow = verticalSplitter.Add(new GLFlowLayout(glGui)
            {
                FlowDirection = GLFlowDirection.TopDown
            });
            var sidebarSkin = sidebarFlow.Skin;

            sidebarSkin.BackgroundColor = glGui.Skin.FormActive.BackgroundColor;
            sidebarFlow.Skin            = sidebarSkin;

            reload = sidebarFlow.Add(new GLButton(glGui)
            {
                Text = "Reload", Enabled = false
            });
            reload.Click += (s, ev) => ShowPBT(currentPBTName);
            save          = sidebarFlow.Add(new GLButton(glGui)
            {
                Text = "Save", Enabled = false
            });
            save.Click += (s, ev) => SavePBT();
            create      = sidebarFlow.Add(new GLButton(glGui)
            {
                Text = "New"
            });
            create.Click += (s, ev) => CreatePBT();

            var fileListTitle = sidebarFlow.Add(new GLLabel(glGui)
            {
                Text = "Load:", AutoSize = true
            });

            var horizontalSplitter = sidebarFlow.Add(new GLSplitLayout(glGui)
            {
                Orientation      = GLSplitterOrientation.Horizontal,
                SplitterPosition = 0.8f,
                Size             = new Size(sidebarFlow.InnerWidth, sidebarFlow.InnerHeight - fileListTitle.Outer.Bottom),
                Anchor           = GLAnchorStyles.All
            });

            var fileListScrollable = horizontalSplitter.Add(new GLScrollableControl(glGui));

            fileList = fileListScrollable.Add(new GLFlowLayout(glGui)
            {
                FlowDirection = GLFlowDirection.TopDown, AutoSize = true
            });
            UpdatePBTFileList();

            Overview = horizontalSplitter.Add(new PBTOverviewControl(glGui, TreeContainer));

            Resize += (s, ev) => { MakeCurrent(); GL.Viewport(ClientSize); };
            Paint  += OnRender;
            //Application.Idle += (s, ev) => Invalidate();
            Timer t = new Timer();

            t.Interval = 16;
            t.Tick    += (s, ev) => Invalidate();
            t.Start();
        }
        private void OnLoad(object sender, EventArgs e)
        {
            MakeCurrent();
            MouseUp += (s, ev) => { try { MakeCurrent(); } catch (GraphicsContextException) { } }; // workaround for correct context switching (mouseclicks might change the gui directly)
            glGui    = new GLGui(this);

            if (monospaceFont == null)
            {
                monospaceFont = new GLFont(new Font("Lucida Console", 6.5f));
                monospaceFont.Options.Monospacing = GLFontMonospacing.Yes;
            }

            var verticalSplitter = glGui.Add(new GLSplitLayout(glGui)
            {
                Size             = ClientSize,
                SplitterPosition = 0.7f,
                Orientation      = GLSplitterOrientation.Vertical,
                Anchor           = GLAnchorStyles.All
            });

            TreeContainer = verticalSplitter.Add(new PBTTreeContainer(glGui));
            TreeContainer.Add(new PBTTaskTreeControl <DataType>(glGui, Root.Root, true));

            var sidebar = verticalSplitter.Add(new GLFlowLayout(glGui)
            {
                FlowDirection = GLFlowDirection.TopDown
            });
            var sidebarSkin = sidebar.Skin;

            sidebarSkin.BackgroundColor = System.Drawing.Color.FromArgb(48, 48, 48);
            sidebar.Skin = sidebarSkin;

            var extended = sidebar.Add(new GLCheckBox(glGui)
            {
                Text = "extended view", Checked = true, AutoSize = true
            });

            extended.Changed += (s, ev) =>
            {
                MakeCurrent();
                TreeContainer.Clear();
                TreeContainer.Add(new PBTTaskTreeControl <DataType>(glGui, Root.Root, extended.Checked));
            };

            var filter = sidebar.Add(new GLButton(glGui)
            {
                Text = "Impulse Filter", AutoSize = true
            });

            var horizontalSplitter = sidebar.Add(new GLSplitLayout(glGui)
            {
                Size             = new Size(sidebar.InnerWidth, sidebar.InnerHeight - extended.Outer.Bottom),
                SplitterPosition = 0.5f,
                Orientation      = GLSplitterOrientation.Horizontal,
                Anchor           = GLAnchorStyles.All
            });

            dataControl = horizontalSplitter.Add(new GLDataControl(glGui));
            dataControl.SetData(Root.Context.Data);

            var horizontalSplitter2 = horizontalSplitter.Add(new GLSplitLayout(glGui)
            {
                Orientation      = GLSplitterOrientation.Horizontal,
                SplitterPosition = 0.5f
            });

            var impulseLogScroll = horizontalSplitter2.Add(new GLScrollableControl(glGui));

            impulseLog = impulseLogScroll.Add(new GLLabel(glGui)
            {
                Multiline = true, AutoSize = true
            });
            var impulseLogSkin = impulseLog.SkinEnabled;

            impulseLogSkin.Font    = monospaceFont;
            impulseLog.SkinEnabled = impulseLogSkin;

            impulseLogger    = new PBTImpulseLogger <DataType, ImpulseType>(new LabelWriter(impulseLog), Root.Context);
            HandleDestroyed += (s, ev) => impulseLogger.Dispose();
            filter.Click    += (s, ev) => glGui.Add(new PBTImpulseFilterForm <DataType, ImpulseType>(glGui, impulseLogger));

            Overview = horizontalSplitter2.Add(new PBTOverviewControl <DataType>(glGui, TreeContainer));

            Resize += (s, ev) => { MakeCurrent(); GL.Viewport(ClientSize); };
            Paint  += OnRender;
            //Application.Idle += (s, ev) => Invalidate();
            Timer t = new Timer();

            t.Interval = 16;
            t.Tick    += (s, ev) => Invalidate();
            t.Start();
        }
        public PBTEnumForm(GLGui gui, PBTTaskControl taskControl, int parameterIndex, GLButton parameterControl)
            : base(gui)
        {
            var task          = taskControl.Task;
            var parameterType = task.TaskType.Parameters[parameterIndex];
            var valueNames    = parameterType.EnumType.ValueNames;

            Title   = parameterType.ShortType + " " + parameterType.Name;
            SizeMin = Size = new Size(200, 100 + 15 * valueNames.Length);

            var valueBackup = task.ParameterValues[parameterIndex];

            var text = Add(new GLTextBox(gui)
            {
                Text      = valueBackup,
                Location  = new Point(4, 4),
                AutoSize  = false,
                Multiline = true,
                WordWrap  = true,
                Size      = new Size(InnerWidth - 8, InnerHeight - 27 - valueNames.Length * 15),
                Anchor    = GLAnchorStyles.All
            });

            text.Changed += (s, e) => task.ParameterValues[parameterIndex] = parameterControl.Text = text.Text;

            var parameterValue = Add(new GLOptions(Gui)
            {
                Location      = new Point(4, text.Outer.Bottom + 4),
                Size          = new Size(InnerWidth - 8, InnerHeight - 27 - text.Height),
                Anchor        = GLAnchorStyles.Left | GLAnchorStyles.Bottom,
                AutoSize      = false,
                FlowDirection = GLFlowDirection.TopDown
            });

            for (int j = 0; j < valueNames.Length; j++)
            {
                parameterValue.Add(new GLCheckBox(Gui)
                {
                    Text = valueNames[j], AutoSize = true
                });
            }
            var selectionIndex = Array.IndexOf(valueNames, task.ParameterValues[parameterIndex]);

            if (selectionIndex != -1)
            {
                parameterValue.Selection = (GLCheckBox)parameterValue.Controls.ElementAt(selectionIndex);
            }
            parameterValue.Changed += (s, e) => task.ParameterValues[parameterIndex] = parameterControl.Text = parameterValue.Selection.Text;

            var ok = Add(new GLButton(gui)
            {
                Text     = "OK",
                Location = new Point(4, InnerHeight - 18),
                Anchor   = GLAnchorStyles.Bottom | GLAnchorStyles.Left
            });

            ok.Click += (s, e) => { Parent.Remove(this); };

            var abort = Add(new GLButton(gui)
            {
                Text     = "Abort",
                Location = new Point(InnerWidth - 79, InnerHeight - 19),
                Anchor   = GLAnchorStyles.Bottom | GLAnchorStyles.Right
            });

            abort.Click += (s, e) => { task.ParameterValues[parameterIndex] = parameterControl.Text = valueBackup; Parent.Remove(this); };
        }
示例#15
0
        public PBTTaskBrowserForm(GLGui gui, PBTEditorControl editor, Action <Data.Task> callback, bool leafTasksSelectable, bool allowAborting = true)
            : base(gui)
        {
            this.callback = callback;

            Title   = "Task Browser";
            SizeMin = Size = new Size(400, 450);

            var splitter = Add(new GLSplitLayout(gui)
            {
                Size             = new Size(InnerWidth, InnerHeight - 23),
                Anchor           = GLAnchorStyles.All,
                SplitterPosition = 0.6f,
                Orientation      = GLSplitterOrientation.Horizontal
            });

            var taskScrollable = splitter.Add(new GLScrollableControl(gui));

            var horizontalFlow = taskScrollable.Add(new GLFlowLayout(gui)
            {
                FlowDirection = GLFlowDirection.LeftToRight,
                AutoSize      = true,
                Anchor        = GLAnchorStyles.All
            });

            var categories = editor.TaskTypes.TaskTypeCategories.ToDictionary(c => c.Name);

            var parentTasksFlow = horizontalFlow.Add(new GLFlowLayout(gui)
            {
                FlowDirection = GLFlowDirection.TopDown,
                AutoSize      = true
            });

            parentTasksFlow.Add(new GLLabel(gui)
            {
                Text = "ParentTasks", AutoSize = true
            });
            foreach (var taskType in categories["ParentTasks"].TaskTypes)
            {
                var ltt = taskType;
                parentTasksFlow.Add(new GLLinkLabel(gui)
                {
                    Text = ltt.Name, AutoSize = true
                }).Click += (s, e) => Select(ltt);
            }

            var decoratorsFlow = horizontalFlow.Add(new GLFlowLayout(gui)
            {
                FlowDirection = GLFlowDirection.TopDown,
                AutoSize      = true
            });

            decoratorsFlow.Add(new GLLabel(gui)
            {
                Text = "Decorators", AutoSize = true
            });
            foreach (var taskType in categories["Decorators"].TaskTypes)
            {
                var ltt = taskType;
                decoratorsFlow.Add(new GLLinkLabel(gui)
                {
                    Text = ltt.Name, AutoSize = true
                }).Click += (s, e) => Select(ltt);
            }

            if (leafTasksSelectable)
            {
                var leafTasksFlow = horizontalFlow.Add(new GLFlowLayout(gui)
                {
                    FlowDirection = GLFlowDirection.TopDown,
                    AutoSize      = true
                });
                leafTasksFlow.Add(new GLLabel(gui)
                {
                    Text = "LeafTasks", AutoSize = true
                });
                foreach (var taskType in categories["LeafTasks"].TaskTypes)
                {
                    var ltt = taskType;
                    leafTasksFlow.Add(new GLLinkLabel(gui)
                    {
                        Text = ltt.Name, AutoSize = true
                    }).Click += (s, e) => Select(ltt);
                }
            }

            var summaryScrollable = splitter.Add(new GLScrollableControl(gui));

            summary = summaryScrollable.Add(new GLLabel(gui)
            {
                Text      = "",
                AutoSize  = true,
                Multiline = true,
                WordWrap  = true,
                SizeMax   = new Size(summaryScrollable.InnerWidth - summaryScrollable.Vertical.Width, int.MaxValue)
            });

            ok = Add(new GLButton(gui)
            {
                Text     = "OK",
                Enabled  = false,
                Location = new Point(4, InnerHeight - 18),
                Anchor   = GLAnchorStyles.Bottom | GLAnchorStyles.Left
            });
            ok.Click += (s, ev) => callback(selection.Create());

            if (editor.Clipboard != null && (leafTasksSelectable || editor.Clipboard.TaskType.Category.Name != "LeafTasks"))
            {
                var paste = Add(new GLButton(gui)
                {
                    Text     = "Paste",
                    Location = new Point(ok.Outer.Right + 4, InnerHeight - 18),
                    Anchor   = GLAnchorStyles.Bottom | GLAnchorStyles.Left
                });
                paste.Click += (s, e) => callback(editor.Clipboard.DeepCopy());
            }

            if (allowAborting)
            {
                var abort = Add(new GLButton(gui)
                {
                    Text     = "Abort",
                    Location = new Point(InnerWidth - 79, InnerHeight - 19),
                    Anchor   = GLAnchorStyles.Bottom | GLAnchorStyles.Right
                });
                abort.Click += (s, e) => Parent.Remove(this);
            }
        }