Example #1
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); };
        }
        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();
        }