コード例 #1
0
ファイル: Plotter.cs プロジェクト: SiGenixDave/PtuPCNew
        /// <summary>
        /// Clean up the resources used by the user control.
        /// </summary>
        /// <param name="disposing">True, to release both managed and unmanaged resources; false to release only unmanaged resources.</param>
        protected override void Cleanup(bool disposing)
        {
            try
            {
                // Clear all controls from the selected control list.
                m_SelectedControlList.Clear();

                if (disposing)
                {
                    // Method called by consumer code. Call the Dispose method of any managed data members that implement the dispose method.
                    // Cleanup managed objects by calling their Dispose() methods.
                    if (components != null)
                    {
                        components.Dispose();
                    }

                    // Check each of the channels in the channel collection.
                    if (m_ChannelCollection != null)
                    {
                        // Dispose of each channel in the collection.
                        foreach (Channel channel in m_ChannelCollection)
                        {
                            channel.Dispose();
                        }

                        m_ChannelCollection.Clear();
                        m_ChannelCollection = null;
                    }
                }

                // Whether called by consumer code or the garbage collector free all unmanaged resources and set the value of managed data 
                // members to null.
                m_Gridline = null;
                m_AxisLineXandY = null;

                #region  - [Detach the event handler methods.] -
                this.m_HScrollBar.Scroll -= new System.Windows.Forms.ScrollEventHandler(this.m_HScrollBar_Scroll);
                this.m_ToolStripMenuItemResetRange.Click -= new EventHandler(m_ToolStripMenuItemResetTimeSpan_Click);
                this.m_ToolStripMenuItemChangeRange.Click -= new EventHandler(m_ToolStripMenuItemNewTimeSpan_Click);
                this.m_ToolStripMenuItemZoom.Click -= new EventHandler(m_ToolStripMenuItemZoom_Click);
                this.m_ToolStripMenuItemCancel.Click -= new EventHandler(m_ToolStripMenuItemCancel_Click);
                this.m_ToolStripMenuItemNextChannel.Click -= new EventHandler(m_ToolStripMenuItemNextChannel_Click);
                this.m_ToolStripMenuItemPreviousChannel.Click -= new EventHandler(m_ToolStripMenuItemPreviousChannel_Click);
                this.m_ToolStripMenuItemResetAxis.Click -= new EventHandler(m_ToolStripMenuItemResetAxis_Click);
                this.MouseDown -= new System.Windows.Forms.MouseEventHandler(Plotter_MouseDown);
                this.MouseUp -= new System.Windows.Forms.MouseEventHandler(Plotter_MouseUp);
                this.MouseLeave -= new EventHandler(Plotter_MouseLeave);
                this.MouseMove -= new System.Windows.Forms.MouseEventHandler(Plotter_MouseMove);
                this.Leave -= new EventHandler(Plotter_Leave);
                this.GotFocus -= new EventHandler(Plotter_GotFocus);
                Plotter.MultiCursorMouseMove -= new System.Windows.Forms.MouseEventHandler(Plotter_MultiCursorMouseMove);
                #endregion  - [Detach the event handler methods.] -

                #region - [Component Designer Variables] -
                this.m_HScrollBar = null;
                this.m_ContextMenuStrip = null;
                this.m_ToolStripMenuItemResetRange = null;
                this.m_ToolStripMenuItemChangeRange = null;
                this.m_ToolStripMenuItemZoom = null;
                this.m_ToolStripMenuItemCancel = null;
                this.m_ToolStripSeparatorCancel = null;
                this.m_ToolStripMenuItemNextChannel = null;
                this.m_ToolStripMenuItemPreviousChannel = null;
                this.m_ToolStripMenuItemResetAxis = null;
                #endregion - [Component Designer Variables] -
            }
            catch (Exception)
            {
                // Don't do anything, just ensure that an exception is not thrown.
            }
            finally
            {
                base.Cleanup(disposing);
            }
        }
コード例 #2
0
ファイル: Plotter.cs プロジェクト: SiGenixDave/PtuPCNew
        /// <summary>
        /// Creates and initializes a new plotter component.
        /// </summary>
        public Plotter()
        {   
            InitializeComponent();

            m_InvalidData = false;

            // Keep track of the initial plot interval.
            m_InitialPlotIntervalMs = m_PlotIntervalMs;

            // Set the GraphAreaColour to the default value.
            m_GraphAreaColor = m_GraphAreaNormalColor;

            // Keep track of the time span selection process.
            m_XRangeSelection = new PlotterRangeSelection();
            m_XRangeSelection.PlotterRangeSelectionState = PlotterRangeSelectionState.InitialState;

            // Add the default channel definitions.
            m_ChannelCollection = new ChannelCollection();

            // Add a channel to the collection.
            Channels.Add(new Channel(Channel.DefaultMinValue, Channel.DefaultMaxValue, "", true, Color.ForestGreen));

            // Add a further two channels to the collection for triple analogue plots.
            if (m_AnalogueIOType == AnalogueType.TripleAnalogue)
            {
                Channels.Add(new Channel(Channel.DefaultMinValue, Channel.DefaultMaxValue, "", true, Color.Blue));
                Channels.Add(new Channel(Channel.DefaultMinValue, Channel.DefaultMaxValue, "", false, Color.Red));
            }

            // Instantiate the Gridline and AxisLine references.
            m_Gridline = new Gridline(this);
            m_AxisLineXandY = new AxisLine(this);

            // Set the Style of the UserControl.
            this.SetStyle(ControlStyles.DoubleBuffer | ControlStyles.UserPaint | ControlStyles.AllPaintingInWmPaint, true);
            this.UpdateStyles();

            // Calculate the available graph area of the UserControl.
            CalculateGraphArea();

            Debug.Assert(m_GraphArea.Height == (m_GraphArea.Bottom - m_GraphArea.Top), "Problem Ctor");

            m_PlotterPenPosition = new TimeSpan((long)(m_XRange.Duration().Ticks * 0.9));

            // Evaluate the range, in ms, of the plot and set up the horizontal scroll bar accordingly.
            int xRangeInMs = (int)(m_XRange.Duration().Ticks / TimeSpan.TicksPerMillisecond);
            m_HScrollBar.Maximum = xRangeInMs / PlotIntervalMs;
            m_HScrollBar.Value = xRangeInMs / PlotIntervalMs;
            m_HScrollBar.Visible = false;

            m_RightDisplayLimit = xRangeInMs + m_LeftDisplayLimit;
            m_SavedXRange = m_XRange;

            // Register the event handler for the MultiCursorMouseMove event.
            Plotter.MultiCursorMouseMove += new MouseEventHandler(Plotter_MultiCursorMouseMove);

            // Register the event handlers for the Leave and GotFocus events.
            Leave += new EventHandler(Plotter_Leave);
            GotFocus += new EventHandler(Plotter_GotFocus);
        }