Exemple #1
0
        private void buildPanes()
        {
            if (m_Series == null)
            {
                foreach (var ctl in m_Panes)
                {
                    ctl.Dispose();
                }
                m_Panes.Clear();
                //todo ubit shkalu X vnizy
                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);
                    ctl.Dispose();
                }
            }

            //2. Add panes
            foreach (var pn in paneNames)
            {
                var ctl = m_Panes[pn];
                if (ctl != null)
                {
                    ctl.DeleteAllElements(); //Clear the pane
                    continue;                //pane already exists
                }
                //Add pane
                ctl         = new PlotPane(this, pn, m_Panes.Count + 1);
                ctl.TabStop = false;
                ctl.Height  = 100;//todo CONFIG
                ctl.Parent  = this;
                ctl.Dock    = DockStyle.Top;
                //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];

                //      if (i==ilast)
                //      {
                //       if (pane.m_Splitter!=null)
                //       {
                //         pane.m_Splitter.Dispose();
                //         pane.m_Splitter = null;
                //       }
                //    //   this.Controls.SetChildIndex( pane, 1000);
                ////       pane.Dock = DockStyle.Left;
                //      }
                //      else
                {
                    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      = 6;
                        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();
                        };
                    }
                }
            }
        }
Exemple #2
0
        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));
                            }
                        };
                    }
                }
            }
        }