コード例 #1
0
        private void buildPanesCore()
        {
            if (m_Series == null || m_NeedRebuildPanes)
            {
                foreach (var ctl in m_Panes)
                {
                    m_ChartPanel.Controls.Remove(ctl);
                    ctl.Dispose();
                }

                m_Panes.Clear();

                //todo ubit shkalu X vnizy
                if (m_Series == null)
                {
                    return;
                }
            }

            var paneNames = m_Series.GetPaneNames().ToArray();

            //1. Delete panes that are no longer in series
            var toDelete = m_Panes.Select(p => p.Name).Except(paneNames);

            foreach (var pn in toDelete)
            {
                var ctl = m_Panes[pn];
                if (ctl != null)
                {
                    m_Panes.Unregister(ctl);
                    m_ChartPanel.Controls.Remove(ctl);
                    ctl.Dispose();
                }
            }

            var totPanes = paneNames.Length;
            var i        = 0;

            int      controlHeight = m_ChartPanel.Height;
            PlotPane lastPane      = null;

            //2. Add panes
            foreach (var pn in paneNames.Reverse())
            {
                var pane = m_Panes[pn];
                if (pane != null)
                {
                    pane.UpdateZoom(m_Zoom);
                    pane.DeleteAllElements(); //Clear the pane
                    if (lastPane == null)
                    {
                        lastPane = pane;
                    }
                    continue; //pane already exists
                }
                //Add pane
                pane         = new PlotPane(this, pn, m_Panes.Count + 1);
                pane.TabStop = false;
                pane.Cursor  = Cursors.Cross;
                pane.Height  = (int)(controlHeight * GetPaneVProportion(pn));
                SetPaneVProportion(pn, pane.Height / (float)(controlHeight > 0 ? controlHeight : 1));

                pane.Parent = m_ChartPanel;
                pane.UpdateZoom(m_Zoom);
                pane.Dock = DockStyle.Top;

                lastPane = pane;

                //ctl.BackColor = Color.HotPink;
                m_Panes.Register(pane);

                if (i < totPanes - 1)
                {
                    // Build splitter
                    //   pane.Dock = DockStyle.Top;
                    if (pane.m_Splitter != null)
                    {
                        continue;
                    }
                    pane.m_Splitter = new Splitter
                    {
                        Parent      = m_ChartPanel,
                        Dock        = DockStyle.Top,
                        Height      = SPLITTER_HEIGHT,
                        BackColor   = SplitterStyle.BGColor,
                        BorderStyle = BorderStyle.FixedSingle
                    };
                    //this.Controls.SetChildIndex(pane.m_Splitter, this.Controls.GetChildIndex(pane));
                    //todo Splitter moving - suspend update?
                    pane.m_Splitter.SplitterMoved += delegate(object sender, SplitterEventArgs e)
                    {
                        this.NotifySeriesChange(false);
                        int height = m_ChartPanel.Height;
                        foreach (var p in m_Panes)
                        {
                            SetPaneVProportion(p.Name, p.Height / (float)(height > 0 ? height : 1));
                        }
                    };
                }
            }
            // This must be the last Dock command
            if (lastPane != null)
            {
                lastPane.Dock = DockStyle.Fill;
            }
        }
コード例 #2
0
ファイル: TimeSeriesChart.cs プロジェクト: rioka/nfx
        private void buildPanesCore()
        {
            if (m_Series == null || m_NeedRebuildPanes)
            {
                foreach (var ctl in m_Panes)
                {
                    this.Controls.Remove(ctl);
                    ctl.Dispose();
                }

                m_Panes.Clear();

                //todo ubit shkalu X vnizy
                if (m_Series == null)
                {
                    return;
                }
            }

            var paneNames = m_Series.GetPaneNames().ToArray();

            //1. Delete panes that are no longer in series
            var toDelete = m_Panes.Select(p => p.Name).Except(paneNames);

            foreach (var pn in toDelete)
            {
                var ctl = m_Panes[pn];
                if (ctl != null)
                {
                    m_Panes.Unregister(ctl);
                    this.Controls.Remove(ctl);
                    ctl.Dispose();
                }
            }

            //2. Add panes
            foreach (var pn in paneNames.Reverse())
            {
                var ctl = m_Panes[pn];
                if (ctl != null)
                {
                    ctl.UpdateZoom(m_Zoom);
                    ctl.DeleteAllElements(); //Clear the pane
                    continue;                //pane already exists
                }
                //Add pane
                ctl         = new PlotPane(this, pn, m_Panes.Count + 1);
                ctl.TabStop = false;
                ctl.Cursor  = Cursors.Cross;
                ctl.Height  = (int)(this.Height * GetPaneVProportion(pn));
                SetPaneVProportion(pn, ctl.Height / (float)(this.Height > 0 ? this.Height : 1));

                ctl.Parent = this;
                ctl.Dock   = DockStyle.Top;
                ctl.UpdateZoom(m_Zoom);

                //ctl.BackColor = Color.HotPink;
                m_Panes.Register(ctl);
            }


            //3. Build splitters
            var ilast = m_Panes.Count() - 1;

            for (var i = 0; i <= ilast; i++)
            {
                var pane = m_Panes[i];

                {
                    //   pane.Dock = DockStyle.Top;
                    if (pane.m_Splitter == null)
                    {
                        pane.m_Splitter        = new Splitter();
                        pane.m_Splitter.Parent = this;
                        this.Controls.SetChildIndex(pane.m_Splitter, this.Controls.GetChildIndex(pane));
                        pane.m_Splitter.Dock        = DockStyle.Top;
                        pane.m_Splitter.Height      = SPLITTER_HEIGHT;
                        pane.m_Splitter.BackColor   = Color.Silver;
                        pane.m_Splitter.BorderStyle = BorderStyle.FixedSingle;
                        //todo Splitter moving - suspend update?
                        pane.m_Splitter.SplitterMoved += delegate(object sender, SplitterEventArgs e)
                        {
                            this.NotifySeriesChange(false);
                            foreach (var p in m_Panes)
                            {
                                SetPaneVProportion(p.Name, p.Height / (float)(this.Height > 0 ? this.Height : 1));
                            }
                        };
                    }
                }
            }
        }