public void SetStatusBarText(string s) { if (!statusBar1.InvokeRequired) { statusBar1.Text = s; } else //We are on a non GUI thread. { SetStatusBarTextDelegate ssbtDel = new SetStatusBarTextDelegate(SetStatusBarText); statusBar1.Invoke(ssbtDel, new object[] { s }); } }
/// <summary> /// Main form loads - sets up UI for drawing and starts connection wizard /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void MainForm_Load(object sender, System.EventArgs e) { int iPenWidth = 1; // obtain and show version version = Application.ProductVersion; version = version.Substring(0,version.LastIndexOf(".")); version = version.Substring(0,version.LastIndexOf(".")); this.Text = "InkTalk " + version; try { // read configuration file variables connectionPort = Convert.ToInt32(ConfigurationSettings.AppSettings["Port"]); connectionIPAddress = ConfigurationSettings.AppSettings["IP"]; iPenWidth = Convert.ToInt32(ConfigurationSettings.AppSettings["PenWidth"]); } catch (Exception ex) { MessageBox.Show(this,"Missing or invalid configuration file: " + Environment.NewLine + ex.Message,"InkTalk " + version, MessageBoxButtons.OK, MessageBoxIcon.Error); Application.Exit(); } // create start up form startupForm = new StartupForm(version, connectionIPAddress); // set delegate addInkMessageDelegate = new AddInkMessageDelegate(addInkMessage); setMainFormVisibilityDelegate = new SetMainFormVisibilityDelegate(setMainFormVisibility); setStatusBarTextDelegate = new SetStatusBarTextDelegate(setStatusBarText); setSendButtonStateDelegate = new SetSendButtonStateDelegate(setSendButtonState); // set up input ink collector inputInkCollector = new InkCollector(inputBox.Handle); inputInkCollector.DefaultDrawingAttributes.Width = iPenWidth; inputInkCollector.Enabled = true; // set up chat ink output chatInkOverlay = new InkOverlay(chatPanel.Handle); chatInkOverlay.Renderer.GetViewTransform(ref unmodifiedMatrix); chatInkOverlay.EditingMode = InkOverlayEditingMode.Select; chatInkOverlay.Enabled = true; // start connection wizard newConnectionWizard(); }