Commercial & open source. Find your way forward.Compare editions
OCS NETWORKS INC / OSS

IntelliDispatch OSS MIT License

The open-source edition. An MIT-licensed core, with optional paid, licensed plugins.

Code About this workspace LicenseRead-only source browser
Public files
frmMain.cs
9.8 KB · 270 linesModified Nov 6, 2026 UTC
1using System;2using System.Drawing;3using System.Collections;4using System.ComponentModel;5using System.Windows.Forms;6using System.Data;7using IntelliDispatch;8using PluginInterface;910namespace IntelliDispatch11{12	/// <summary>13	/// Summary description for Form1.14	/// </summary>15	public class frmMain : Form16	{17		private System.Windows.Forms.MainMenu mainMenu;18		private System.Windows.Forms.MenuItem menuItem1;19        private System.Windows.Forms.MenuItem menuItem2;20        private SplitContainer splitContainer1;21        private ToolStrip toolStrip1;22        private IContainer components;23        private MenuItem menuItem3;24        private MenuItem menuItem4;2526		public frmMain()27		{28			//29			// Required for Windows Form Designer support30			//31			InitializeComponent();32            33            34		}3536        37       38394041		/// <summary>42		/// Clean up any resources being used.43		/// </summary>44		protected override void Dispose( bool disposing )45		{46			if( disposing )47			{48				if (components != null) 49				{50					components.Dispose();51				}52			}53			base.Dispose( disposing );54		}5556		#region Windows Form Designer generated code57		/// <summary>58		/// Required method for Designer support - do not modify59		/// the contents of this method with the code editor.60		/// </summary>61		private void InitializeComponent()62		{63            this.components = new System.ComponentModel.Container();64            System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(frmMain));65            this.mainMenu = new System.Windows.Forms.MainMenu(this.components);66            this.menuItem1 = new System.Windows.Forms.MenuItem();67            this.menuItem2 = new System.Windows.Forms.MenuItem();68            this.menuItem3 = new System.Windows.Forms.MenuItem();69            this.menuItem4 = new System.Windows.Forms.MenuItem();70            this.splitContainer1 = new System.Windows.Forms.SplitContainer();71            this.toolStrip1 = new System.Windows.Forms.ToolStrip();72            ((System.ComponentModel.ISupportInitialize)(this.splitContainer1)).BeginInit();73            this.splitContainer1.Panel1.SuspendLayout();74            this.splitContainer1.SuspendLayout();75            this.SuspendLayout();76            // 77            // mainMenu78            // 79            this.mainMenu.MenuItems.AddRange(new System.Windows.Forms.MenuItem[] {80            this.menuItem1,81            this.menuItem3});82            // 83            // menuItem184            // 85            this.menuItem1.Index = 0;86            this.menuItem1.MenuItems.AddRange(new System.Windows.Forms.MenuItem[] {87            this.menuItem2});88            this.menuItem1.Text = "&File";89            // 90            // menuItem291            // 92            this.menuItem2.Index = 0;93            this.menuItem2.Text = "&Exit";94            this.menuItem2.Click += new System.EventHandler(this.menuItem2_Click);95            // 96            // menuItem397            // 98            this.menuItem3.Index = 1;99            this.menuItem3.MenuItems.AddRange(new System.Windows.Forms.MenuItem[] {100            this.menuItem4});101            this.menuItem3.Text = "Help";102            // 103            // menuItem4104            // 105            this.menuItem4.Index = 0;106            this.menuItem4.Text = "About IntelliDispatch";107            this.menuItem4.Click += new System.EventHandler(this.menuItem4_Click);108            // 109            // splitContainer1110            // 111            this.splitContainer1.AllowDrop = true;112            this.splitContainer1.Dock = System.Windows.Forms.DockStyle.Fill;113            this.splitContainer1.FixedPanel = System.Windows.Forms.FixedPanel.Panel1;114            this.splitContainer1.IsSplitterFixed = true;115            this.splitContainer1.Location = new System.Drawing.Point(0, 10);116            this.splitContainer1.Margin = new System.Windows.Forms.Padding(0);117            this.splitContainer1.Name = "splitContainer1";118            // 119            // splitContainer1.Panel1120            // 121            this.splitContainer1.Panel1.Controls.Add(this.toolStrip1);122            this.splitContainer1.Panel1MinSize = 60;123            // 124            // splitContainer1.Panel2125            // 126            this.splitContainer1.Panel2.BackgroundImage = ((System.Drawing.Image)(resources.GetObject("splitContainer1.Panel2.BackgroundImage")));127            this.splitContainer1.Panel2.BackgroundImageLayout = System.Windows.Forms.ImageLayout.Stretch;128            this.splitContainer1.Size = new System.Drawing.Size(776, 596);129            this.splitContainer1.SplitterDistance = 75;130            this.splitContainer1.SplitterWidth = 1;131            this.splitContainer1.TabIndex = 0;132            // 133            // toolStrip1134            // 135            this.toolStrip1.BackColor = System.Drawing.Color.Transparent;136            this.toolStrip1.Dock = System.Windows.Forms.DockStyle.Fill;137            this.toolStrip1.GripStyle = System.Windows.Forms.ToolStripGripStyle.Hidden;138            this.toolStrip1.LayoutStyle = System.Windows.Forms.ToolStripLayoutStyle.VerticalStackWithOverflow;139            this.toolStrip1.Location = new System.Drawing.Point(0, 0);140            this.toolStrip1.Name = "toolStrip1";141            this.toolStrip1.RenderMode = System.Windows.Forms.ToolStripRenderMode.Professional;142            this.toolStrip1.Size = new System.Drawing.Size(75, 596);143            this.toolStrip1.TabIndex = 0;144            this.toolStrip1.Text = "Menu";145            this.toolStrip1.ItemClicked += new System.Windows.Forms.ToolStripItemClickedEventHandler(this.toolStrip1_ItemClicked);146            // 147            // frmMain148            // 149            this.AutoScaleBaseSize = new System.Drawing.Size(5, 13);150            this.ClientSize = new System.Drawing.Size(776, 606);151            this.Controls.Add(this.splitContainer1);152            this.Menu = this.mainMenu;153            this.MinimumSize = new System.Drawing.Size(575, 400);154            this.Name = "frmMain";155            this.Padding = new System.Windows.Forms.Padding(0, 10, 0, 0);156            this.Text = "IntelliDispatch";157            this.WindowState = System.Windows.Forms.FormWindowState.Maximized;158            this.Closing += new System.ComponentModel.CancelEventHandler(this.frmMain_Closing);159            this.Load += new System.EventHandler(this.frmMain_Load);160            this.splitContainer1.Panel1.ResumeLayout(false);161            this.splitContainer1.Panel1.PerformLayout();162            ((System.ComponentModel.ISupportInitialize)(this.splitContainer1)).EndInit();163            this.splitContainer1.ResumeLayout(false);164            this.ResumeLayout(false);165166		}167		#endregion168169170        private void frmMain_Load(object sender, System.EventArgs e)171		{172173            Cursor.Current = Cursors.WaitCursor;174            //LoaderForm.TopLevel = true;175            //LoaderForm.Show();176177            Loader objLoader = new Loader();178            if (objLoader.ShowDialog() == DialogResult.OK)179            {180                LoadPlugins();181            }182            else183            {184185            }186187            //Global.Plugins.FindPlugins(Application.StartupPath + @"\Plugins");188189		}190191       192        private void LoadPlugins()193        {194195            toolStrip1.ImageScalingSize = new System.Drawing.Size(40, 40);196197            //Add each plugin to the treeview198199            //toolStrip1.Items.Clear();200201            foreach (Types.AvailablePlugin pluginOn in Global.Plugins.AvailablePlugins)202            {203                //TreeNode newNode = new TreeNode(pluginOn.Instance.Name);204                //this.tvwPlugins.Nodes.Add(newNode);205                //newNode = null;206207                ToolStripMenuItem NewMenuItem = new ToolStripMenuItem(pluginOn.Instance.Name.Replace(" ", "\n"), null, null, pluginOn.Instance.Name);208                NewMenuItem.Image = Image.FromFile(@"images\" + pluginOn.Instance.Name + ".png");209                NewMenuItem.TextImageRelation = System.Windows.Forms.TextImageRelation.ImageAboveText;210                toolStrip1.Items.Add(NewMenuItem);211212213            }214            Cursor.Current = Cursors.Default;215216        }217218     219		private void menuItem2_Click(object sender, System.EventArgs e)220		{221			this.Close(); //User clicked File > Exit222		}223224		private void frmMain_Closing(object sender, System.ComponentModel.CancelEventArgs e)225		{226			//Lets call the close for all the plugins before we truly exit!227			Global.Plugins.ClosePlugins();228		}229230        private void toolStrip1_ItemClicked(object sender, ToolStripItemClickedEventArgs e)231        {232            Cursor.Current = Cursors.WaitCursor;233234            //Make sure there's a selected Plugin235            if (e.ClickedItem.Name != null)236            {237                foreach (ToolStripMenuItem item in toolStrip1.Items)238                {239                    item.BackColor = SystemColors.Control;240                }241242                e.ClickedItem.BackColor = Color.LightGreen;243244                //Get the selected Plugin245                Types.AvailablePlugin selectedPlugin = Global.Plugins.AvailablePlugins.Find(e.ClickedItem.Name.ToString());246                this.Text = "IntelliDispatch - " + e.ClickedItem.Name.ToString();247248                if (selectedPlugin != null)249                {250                    this.splitContainer1.Panel2.Controls.Clear();251252                    selectedPlugin.Instance.MainInterface.Dock = DockStyle.Fill;253254                    this.splitContainer1.Panel2.Controls.Add(selectedPlugin.Instance.MainInterface);255256                }257258            }259            Cursor.Current = Cursors.Default;260        }261262        private void menuItem4_Click(object sender, EventArgs e)263        {264            var About = new About();265            About.ShowDialog();266        }267268269	}270}