Esempio n. 1
0
        void Form1_Load(object sender, EventArgs e)
        {
            try
            {
                SimpleTest = AS.MfcHost.MfcAppAdapter.GetMfcAppAdapter(AS.SimpleTest.ModuleState.GetModuleState(), this.Handle);
            }
            catch (Exception ex)
            {
                if (ex is System.IO.FileNotFoundException || ex is System.FormatException)
                {
                    MessageBoxButtons buttons = MessageBoxButtons.YesNo;

                    DialogResult res = MessageBox.Show("Not critical error: " + ex.Message + ". Do you want continue?", "", buttons);

                    if (res != DialogResult.Yes)
                    {
                        // terminated
                        throw ex;
                    }
                }
                else
                {
                    MessageBox.Show("Critical error: " + ex.Message + ". Application would be terminated.");
                    // terminated
                    throw ex;
                }
            }
        }
 public void Dispose()
 {
     // Only if all attached ViewCtrl controls are closed to this time we can carefull terminate
     // Legacy Application !!!
     if (_MfcAppAdapter != null)
     {
         _MfcAppAdapter.Dispose();
         _MfcAppAdapter = null;
     }
 }
Esempio n. 3
0
        internal void InitMfc(Form host)
        {
            _Host         = host;
            _Host.Closed += new EventHandler(form_Closed);

            //// if FrameMenu and DocumentMenu defined, we have to support update menu
            //_Host.Load+=new EventHandler(menu_Update);

            // start  init of MFC application.
            _MfcAppAdapter = AS.MfcHost.MfcAppAdapter.GetMfcAppAdapter(AS.DlgEditor.ModuleState.GetModuleState(), host.Handle);
        }
Esempio n. 4
0
        void Form1_Load(object sender, EventArgs e)
        {
            Application.Idle += new EventHandler(OnUpdateUI);
            this.panel1.SuspendLayout();
            try
            {
                Size prefSize;

                DlgEditor = AS.MfcHost.MfcAppAdapter.GetMfcAppAdapter(AS.DlgEditor.ModuleState.GetModuleState(), this.Handle);
                DlgEditor.OpenDocument("DLGEDI1.dlg", 1);
                ctrl2 = new ViewCtrl();
                ctrl2.BuildWindow(DlgEditor.GetModuleState(), DlgEditor.GetCreatedView());
                this.Closing  += ctrl2.ClosingDelegate;
                ctrl2.AutoSize = true;
                ctrl2.Dock     = DockStyle.Top;
                this.panel1.Controls.Add(ctrl2);
                prefSize          = ctrl2.GetPreferredSize(new Size(0, 0));
                ctrl2.ClientSize  = new Size(prefSize.Width, prefSize.Height);
                ctrl2.MaximumSize = ctrl2.Size;
                ctrl2.MinimumSize = ctrl2.Size;


                richTextBox2 = new RichTextBox();
                richTextBox2.LoadFile("FormsDemo2.rtf");
                richTextBox2.ScrollBars       = RichTextBoxScrollBars.None;
                richTextBox2.ContentsResized += new ContentsResizedEventHandler(richTextBox_ContentsResized);
                richTextBox2.Dock             = DockStyle.Top;
                richTextBox2.BorderStyle      = BorderStyle.None;
                this.panel1.Controls.Add(richTextBox2);

                UmlEditor = AS.MfcHost.MfcAppAdapter.GetMfcAppAdapter(AS.UmlEditor.ModuleState.GetModuleState(), this.Handle);
                UmlEditor.OpenDocument("UMLEDI1.uml", 1);
                ctrl1 = new ViewCtrl();
                ctrl1.BuildWindow(UmlEditor.GetModuleState(), UmlEditor.GetCreatedView());
                this.Closing  += ctrl1.ClosingDelegate;
                ctrl1.AutoSize = true;
                ctrl1.Dock     = DockStyle.Top;
                this.panel1.Controls.Add(ctrl1);
                prefSize          = ctrl1.GetPreferredSize(new Size(0, 0));
                ctrl1.ClientSize  = new Size(prefSize.Width, prefSize.Height);
                ctrl1.MaximumSize = ctrl1.Size;
                ctrl1.MinimumSize = ctrl1.Size;

                richTextBox1 = new RichTextBox();
                richTextBox1.LoadFile("FormsDemo1.rtf");
                richTextBox1.ScrollBars       = RichTextBoxScrollBars.None;
                richTextBox1.ContentsResized += new ContentsResizedEventHandler(richTextBox_ContentsResized);
                richTextBox1.Dock             = DockStyle.Top;
                richTextBox1.BorderStyle      = BorderStyle.None;
                this.panel1.Controls.Add(richTextBox1);
            }
            catch (Exception ex)
            {
                if (ex is System.IO.FileNotFoundException || ex is System.FormatException)
                {
                    MessageBoxButtons buttons = MessageBoxButtons.YesNo;

                    DialogResult res = MessageBox.Show("Not critical error: " + ex.Message + ". Do you want continue?", "", buttons);

                    if (res != DialogResult.Yes)
                    {
                        // terminated
                        throw ex;
                    }
                }
                else
                {
                    MessageBox.Show("Critical error: " + ex.Message + ". Application would be terminated.");
                    // terminated
                    throw ex;
                }
            }
            this.panel1.ResumeLayout(false);
            this.panel1.PerformLayout();
        }
Esempio n. 5
0
 void Form1_Load(object sender, EventArgs e)
 {
     m_MfcAppAdapter   = MfcAppAdapter.GetMfcAppAdapter(ModuleState.GetModuleState(), this.Handle);
     Application.Idle += new EventHandler(m_MfcAppAdapter.OnIdle);
 }