Exemple #1
0
        private void MainForm_Load(object sender, EventArgs e)
        {
            // Instantiate a new SerialCommandProcessor object and init the members
            serialCommProc = new SerialCommandProcessor(hexImage, targetInfo, OpenCOMportButton);

            // Instantiate a new DisplayManager object and init the members with the data destinations and sources.
            displayManager = new DisplayManager(EventLogRichTextBox, InfoBlockDataGridView, hexImage, serialCommProc);

            // Simple substitute for an About box:
            Version ver = System.Reflection.Assembly.GetExecutingAssembly().GetName().Version;

            displayManager.PostToTextDisplayBox(DisplayManager.OutputStyle.Status,
                                                DisplayManager.OutputLevel.AlwaysShow,
                                                "Silicon Labs MCU Serial Bootloader DataSource v" + ver.Major.ToString()
                                                + "." + ver.Minor.ToString() + "." + Environment.NewLine);

            // Simple substitute for a Help button:
            displayManager.PostToTextDisplayBox(DisplayManager.OutputStyle.Status,
                                                DisplayManager.OutputLevel.AlwaysShow,
                                                "Please select a Hex file and then open the COM port."
                                                + Environment.NewLine + Environment.NewLine);

            // Subscribe the handler in DisplayManager to the Event published
            // by SerialCommandProcessor
            serialCommProc.SubScribeUpdateDisplayEvent(
                new UpdateDisplayDelegate(displayManager.HandleUpdateDisplayEvent));

            // Make Verbose checked by default
            VerboseCheckBox.Checked = true;
            displayManager.Verbose  = VerboseCheckBox.Checked;

            // Fill up the combo boxes
            ListSerialPortOptions();
        }
        /// <summary>
        /// Constructor
        /// </summary>
        public DisplayManager(RichTextBox rtb, DataGridView dgv, HexImage hi, SerialCommandProcessor scp)
        {
            mTextDisplayBox = rtb;
            mGridDisplayBox = dgv;
            mHexImage       = hi;
            mSerialCommProc = scp;

            InitGridDisplayBox();
        }