示例#1
0
        static void Main()
        {
            IWin32Window vissimHandle = null;

            Process[] processes = Process.GetProcessesByName("vissim");
            if (processes.Length > 0) vissimHandle = new Classes.WindowWrapper(processes[0].MainWindowHandle);

            if (vissimHandle != null && vissimHandle.Handle != IntPtr.Zero)
            {
                Settings.Default.SettingChanging += new System.Configuration.SettingChangingEventHandler(Default_SettingChanging);

                Application.EnableVisualStyles();
                Application.SetCompatibleTextRenderingDefault(false);
                frmMain = new MainForm(vissimHandle);

                switch (Settings.Default.windowModeIndex)
                {
                    case 0: // Standalone
                        frmMain.ShowInTaskbar = true;
                        frmMain.Show();
                        break;
                    case 1: // Modeless
                        frmMain.Show(vissimHandle);
                        break;
                    case 2: // Modal
                        frmMain.ShowDialog(vissimHandle);
                        break;
                    case 3: // Topmost
                        frmMain.ShowInTaskbar = true;
                        frmMain.TopMost = true;
                        frmMain.Show();
                        break;
                }

                Application.Run();
            }
            else
            {
                MessageBox.Show(
                    "Please, start VISSIM 5.3 with [/Automation] parameter first!\nVisLab application will be closed!",
                    "Warning!",
                    MessageBoxButtons.OK,
                    MessageBoxIcon.Warning);
            }
        }
示例#2
0
        private void cboWindowMode_SelectedIndexChanged(object sender, EventArgs e)
        {
            if (Settings.Default.windowModeIndex != cboWindowMode.SelectedIndex)
            {
                Settings.Default.windowModeIndex = cboWindowMode.SelectedIndex;
                Settings.Default.Save();

                var f = new MainForm(vissimHandle);
                f.Location = this.Location;
                f.Size = this.Size;

                switch (cboWindowMode.SelectedIndex)
                {
                    case 0: // Standalone
                        f.ShowInTaskbar = true;
                        f.Show();
                        break;
                    case 1: // Modeless
                        f.ShowInTaskbar = false;
                        f.Show(vissimHandle);
                        break;
                    case 2: // Modal
                        f.ShowInTaskbar = false;
                        this.Hide();
                        f.ShowDialog(vissimHandle);
                        break;
                    case 3: // Topmost
                        f.ShowInTaskbar = true;
                        f.TopMost = true;
                        f.Show();
                        break;
                }

                this.Close();
            }
        }