Dispose() public method

Disposes of the .

public Dispose ( ) : void
return void
Beispiel #1
0
        static void ShowNotification(string text, string title)
        {
            var container = new Container();
            var wait = new ManualResetEvent(false);
            var trayicon = new NotifyIcon(container);
            EventHandler done = null;
            done = delegate {
                wait.Set();
                trayicon.BalloonTipClosed  -= done;
                trayicon.BalloonTipClicked -= done;
            };
            trayicon.BalloonTipClicked += done;
            trayicon.BalloonTipClosed  += done;
            trayicon.BalloonTipTitle = title;
            trayicon.BalloonTipText = text;
            var exe = Environment.GetFolderPath(
                            Environment.SpecialFolder.ProgramFilesX86) +
                            @"\iTunes\iTunes.exe";
            var icon = Icon.ExtractAssociatedIcon(exe);
            trayicon.Icon = new Icon(icon, 16, 16);

            trayicon.Visible = true;
            trayicon.ShowBalloonTip(5000);
            wait.WaitOne(10000);
            trayicon.Visible = false;
            trayicon.Dispose();
            icon.Dispose();
            container.Dispose();
        }
Beispiel #2
0
 /// <summary>
 /// Clean up any resources being used.
 /// </summary>
 protected override void Dispose(bool disposing)
 {
     if (disposing)
     {
         components?.Dispose();
     }
     base.Dispose(disposing);
 }
Beispiel #3
0
 /// <summary>
 /// Clean up any resources being used.
 /// </summary>
 protected override void Dispose(bool disposing)
 {
     if (disposing)
     {
         components?.Dispose();
         nodeLayer.RemoveAllChildren();
         edgeLayer.RemoveAllChildren();
         backLayer.RemoveAllChildren();
         zoomController.Dispose();
     }
     base.Dispose(disposing);
 }
Beispiel #4
0
        protected override void Dispose(bool disposing)
        {
            if (disposing)
            {
                _prototypes.Clear();

                foreach (TabPage page in StrokeTabs.TabPages)
                {
                    page.Dispose();
                }

                if (components != null)
                {
                    components.Dispose();
                }
            }
            base.Dispose(disposing);
        }
Beispiel #5
0
	/// <summary>
	/// Clean up any resources being used.
	/// </summary>
	protected override void Dispose( bool disposing )
	{
		mThreadRunning = false;

		if( disposing )
		{
			if (components != null) 
			{
				components.Dispose();
			}
		}

		if (this.btsession != null)
			this.btsession.Dispose();
		this.btsession = null;

		base.Dispose( disposing );
	}
        // </snippet340>

        // <snippet350>
        protected override void Dispose(bool disposing)
        {
            if (disposing)
            {
                // Be sure to unhook event handlers
                // to prevent "lapsed listener" leaks.
                this.squarePanel.Click -=
                    new EventHandler(squarePanel_Click);
                this.circlePanel.Click -=
                    new EventHandler(circlePanel_Click);

                if (components != null)
                {
                    components.Dispose();
                }
            }
            base.Dispose(disposing);
        }
Beispiel #7
0
        /// -----------------------------------------------------------------------------------
        /// <summary>
        /// Clean up any resources being used.
        /// </summary>
        /// <param name="disposing"><c>true</c> to release both managed and unmanaged
        /// resources; <c>false</c> to release only unmanaged resources.
        /// </param>
        /// -----------------------------------------------------------------------------------
        protected override void Dispose(bool disposing)
        {
            //Debug.WriteLineIf(!disposing, "****************** " + GetType().Name + " 'disposing' is false. ******************");
            // Must not be run more than once.
            if (IsDisposed)
            {
                return;
            }

            if (disposing)
            {
                if (components != null)
                {
                    components.Dispose();
                }
            }
            base.Dispose(disposing);
        }
Beispiel #8
0
        protected override void Dispose(bool disposing)
        {
            if (disposing)
            {
                if (dibhand != IntPtr.Zero)
                {
                    GlobalFree(dibhand);
                    dibhand = IntPtr.Zero;
                }

                if (components != null)
                {
                    components.Dispose();
                }
            }

            base.Dispose(disposing);
        }
        /// ------------------------------------------------------------------------------------
        /// <summary>
        /// Clean up any resources being used.
        /// </summary>
        /// <param name="disposing"><c>true</c> to release both managed and unmanaged
        /// resources; <c>false</c> to release only unmanaged resources.
        /// </param>
        /// ------------------------------------------------------------------------------------
        protected override void Dispose(bool disposing)
        {
            System.Diagnostics.Debug.WriteLineIf(!disposing, "****** Missing Dispose() call for " + GetType().Name + ". ****** ");
            // Must not be run more than once.
            if (IsDisposed)
            {
                return;
            }

            if (disposing)
            {
                if (components != null)
                {
                    components.Dispose();
                }
            }
            base.Dispose(disposing);
        }
 /// <summary>
 /// Clean up any resources being used. and stop events
 /// </summary>
 protected override void Dispose(bool disposing)
 {
     if (bNowExiting)
     {
         eWaitForInput.Set();
     }
     if (bTextMode)
     {
         caretThread.Abort();
     }
     if (disposing)
     {
         if (components != null)
         {
             components.Dispose();
         }
     }
     base.Dispose(disposing);
 }
Beispiel #11
0
        /// <summary>
        /// Clean up any resources being used.
        /// </summary>
        protected override void Dispose(bool disposing)
        {
            if (this.evapAndDryingSystem != null)
            {
                this.evapAndDryingSystem.SystemChanged      -= new SystemChangedEventHandler(evapAndDryingSystem_SystemChanged);
                this.evapAndDryingSystem.CalculationStarted -= new CalculationStartedEventHandler(evapAndDryingSystem_CalculationStarted);
                this.evapAndDryingSystem.CalculationEnded   -= new CalculationEndedEventHandler(evapAndDryingSystem_CalculationEnded);
                this.evapAndDryingSystem.NameChanged        -= new NameChangedEventHandler(evapAndDryingSystem_NameChanged);
            }

            if (disposing)
            {
                if (components != null)
                {
                    components.Dispose();
                }
            }
            base.Dispose(disposing);
        }
Beispiel #12
0
        /// <summary>
        /// Clean up any resources being used.
        /// </summary>
        protected override void Dispose(bool disposing)
        {
            if (disposing)
            {
                if (components != null)
                {
                    components.Dispose();
                    components = null;
                }

                if (this.thumbnailManager != null)
                {
                    this.thumbnailManager.Dispose();
                    this.thumbnailManager = null;
                }
            }

            base.Dispose(disposing);
        }
Beispiel #13
0
        /// <summary>
        /// Nettoyage des ressources utilisées.
        /// </summary>
        protected override void Dispose(bool disposing)
        {
            if (disposing)
            {
                if (components != null)
                {
                    components.Dispose();
                }
            }

            // Clean-up DirectShow interfaces
            CloseInterfaces();

            // Dispose Managed Direct3D objects
            surface.Dispose();
            device.Dispose();

            base.Dispose(disposing);
        }
Beispiel #14
0
 /// <summary>
 /// Clean up any resources being used.
 /// </summary>
 protected override void Dispose(bool disposing)
 {
     if (disposing)
     {
         if (components != null)
         {
             components.Dispose();
         }
         if (origOut != null)
         {
             Console.SetOut(origOut);
         }
         if (origErr != null)
         {
             Console.SetError(origErr);
         }
     }
     base.Dispose(disposing);
 }
Beispiel #15
0
        /// <summary>
        /// Clean up any resources being used.
        /// </summary>
        protected override void Dispose(bool disposing)
        {
            if (disposing)
            {
                if (components != null)
                {
                    components.Dispose();
                }

                Thread worker = m_worker;
                if (worker != null)
                {
                    worker.Abort();
                    worker.Join();
                }

                Disconnect();
            }
            base.Dispose(disposing);
        }
Beispiel #16
0
        /// <summary>
        /// Clean up any resources being used.
        /// </summary>
        protected override void Dispose(bool disposing)
        {
            if (_rebar != null)
            {
                _rebar.DestroyHandle();
            }
            if (_imageList != null)
            {
                _imageList.Dispose();
            }
            if (disposing)
            {
                if (components != null)
                {
                    components.Dispose();
                }
            }

            base.Dispose(disposing);
        }
Beispiel #17
0
        }         // End CreateHandle()

        // ******************************************************************

        /// <summary>
        /// Clean up any resources being used.
        /// </summary>
        protected override void Dispose(bool disposing)
        {
            // Make sure the animation is stopped and closed.
            Close();

            // Should we cleanup the library?
            if (m_hShellModule != 0)
            {
                NativeMethods.FreeLibrary(m_hShellModule);
                m_hShellModule = 0;
            }             // End if we should free the library handle.

            // Should we dispose of the container?
            if (disposing && components != null)
            {
                components.Dispose();
            }

            base.Dispose(disposing);
        }         // End Dispose()
        /// <summary>
        /// Clean up any resources being used.
        /// </summary>
        protected override void Dispose(bool disposing)
        {
            if (disposing)
            {
                try
                {
                    this._informationPanel.Marquee.IsScrolling = false;
                }
                catch (System.Exception systemException)
                {
                    System.Diagnostics.Trace.WriteLine(systemException);
                }

                if (components != null)
                {
                    components.Dispose();
                }
            }
            base.Dispose(disposing);
        }
        /// <summary>
        /// Clean up any resources being used.
        /// </summary>
        protected override void Dispose(bool disposing)
        {
            if (disposing)
            {
                if (components != null)
                {
                    components.Dispose();
                }

                if (m_AutoRotateTimer != null && m_AutoRotateTimer.Enabled)
                {
                    m_AutoRotateTimer.Stop();
                }

                if (m_AutoRotateTimer != null)
                {
                    m_AutoRotateTimer.Dispose();
                }
            }
            base.Dispose(disposing);
        }
Beispiel #20
0
        protected override void Dispose(bool disposing)
        {
            if (disposing)
            {
                if (components != null)
                {
                    components.Dispose();

                    m_topLeftRgn.Dispose();
                    m_topRightRgn.Dispose();
                    m_centerRgn.Dispose();
                    m_bottomLeftRgn.Dispose();
                    m_bottomRightRgn.Dispose();
                    m_leftCenterRgn.Dispose();
                    m_rightCenterRgn.Dispose();
                    m_topCenterRgn.Dispose();
                    m_bottomCenterRgn.Dispose();
                }
            }
            base.Dispose(disposing);
        }
Beispiel #21
0
        /// <summary>
        /// Clean up any resources being used.
        /// </summary>
        protected override void Dispose(bool disposing)
        {
            if (disposing)
            {
                if (components != null)
                {
                    components.Dispose();
                }

                if (_lgb != null)
                {
                    _lgb.Dispose();
                }

                if (_rlgb != null)
                {
                    _rlgb.Dispose();
                }
            }
            base.Dispose(disposing);
        }
Beispiel #22
0
        /// <summary>
        /// Clean up any resources being used.
        /// </summary>
        protected override void Dispose(bool disposing)
        {
            if (disposing)
            {
                if (components != null)
                {
                    components.Dispose();
                }

                if (this.channel != null)
                {
                    this.channel.Close();
                }
                if (this.Channels != null)
                {
                    this.Channels.Dispose();
                }
                this.eventClose.Dispose();
            }
            base.Dispose(disposing);
        }
Beispiel #23
0
        /// <summary>
        /// Clean up any resources being used.
        /// </summary>
        protected override void Dispose(bool disposing)
        {
            IDictionaryEnumerator en = this.hashtableGraphPlot.GetEnumerator();

            while (en.MoveNext())
            {
                Plot2DGraph p2dGraph = (Plot2DGraph)en.Key;
                Plot2D      p2d      = (Plot2D)en.Value;
                p2dGraph.PlotSelected -= new PlotSelectedEventHandler(p2dGraph_PlotSelected);
                p2d.Plot2DChanged     -= new Plot2DChangedEventHandler(p2d_Plot2DChanged);
            }

            if (disposing)
            {
                if (components != null)
                {
                    components.Dispose();
                }
            }
            base.Dispose(disposing);
        }
Beispiel #24
0
 /// <summary>
 /// Clean up any resources being used.
 /// </summary>
 protected override void Dispose(bool disposing)
 {
     if (disposing)
     {
         if (components != null)
         {
             if (disabledBackBrush != null)
             {
                 disabledBackBrush.Dispose();
                 disabledTextBrush.Dispose();
                 alertBackBrush.Dispose();
                 alertFont.Dispose();
                 alertTextBrush.Dispose();
                 currentRowFont.Dispose();
                 currentRowBackBrush.Dispose();
             }
             components.Dispose();
         }
     }
     base.Dispose(disposing);
 }
Beispiel #25
0
        /// <summary>
        /// Clean up any resources being used.
        /// </summary>
        protected override void Dispose(bool disposing)
        {
            if (this._RegKey != null)
            {
                this._RegKey.Close();
            }

            if (this._RegShareKey != null)
            {
                this._RegShareKey.Close();
            }

            if (disposing)
            {
                if (components != null)
                {
                    components.Dispose();
                }
            }
            base.Dispose(disposing);
        }
        /// <summary>
        /// Clean up any resources being used.
        /// </summary>
        protected override void Dispose(bool disposing)
        {
            try
                           {
                       socket.Close();    //释放资源

                       mythread.Abort( ); //中止线程

                     
                }
                        catch { }

            if (disposing)
            {
                if (components != null)
                {
                    components.Dispose();
                }
            }
            base.Dispose(disposing);
        }
Beispiel #27
0
        /// <summary>
        /// Clean up any resources being used.
        /// </summary>
        protected override void Dispose(bool disposing)
        {
            //Debug.WriteLineIf(!disposing, "****************** " + GetType().Name + " 'disposing' is false. ******************");
            // Must not be run more than once.
            if (IsDisposed)
            {
                return;
            }

            if (disposing)
            {
                if (m_mainPOSPopupTreeManager != null)
                {
                    m_mainPOSPopupTreeManager.AfterSelect -= new TreeViewEventHandler(m_mainPOSPopupTreeManager_AfterSelect);
                    m_mainPOSPopupTreeManager.Dispose();
                }
                m_mainPOSPopupTreeManager = null;
                if (m_secPOSPopupTreeManager != null)
                {
                    m_secPOSPopupTreeManager.AfterSelect -= new TreeViewEventHandler(m_secPOSPopupTreeManager_AfterSelect);
                    m_secPOSPopupTreeManager.Dispose();
                }
                if (components != null)
                {
                    components.Dispose();
                }
            }
            m_parentForm             = null;
            m_mediator               = null;
            m_secPOSPopupTreeManager = null;
            m_lAfxType               = null;
            m_fwcbAffixTypes         = null;
            m_lSLots         = null;
            m_fwcbSlots      = null;
            m_tcSecondaryPOS = null;
            m_ctrlAssistant  = null;

            base.Dispose(disposing);
        }
        /// <summary>
        /// Disposes of the resources (other than memory) used by
        /// the <see cref="T:System.Windows.Forms.Form"/>
        /// .
        /// </summary>
        /// <param name="disposing"><see langword="true"/> to release both managed and unmanaged resources; <see langword="false"/> to release only unmanaged resources.</param>
        protected override void Dispose(bool disposing)
        {
            if (disposing)
            {
                if (components != null)
                {
                    components.Dispose();
                }
            }
            WebDownload.DebugCallback -= new DownloadCompleteHandler(Update);

            foreach (WebDownload dl in retryDownloads)
            {
                if (dl != null)
                {
                    dl.Dispose();
                }
            }
            retryDownloads.Clear();

            base.Dispose(disposing);
        }
Beispiel #29
0
        /// <summary>
        /// Clean up any resources being used.
        /// </summary>
        protected override void Dispose(bool disposing)
        {
            System.Diagnostics.Debug.WriteLineIf(!disposing, "****** Missing Dispose() call for " + GetType().Name + ". ****** ");
            // Must not be run more than once.
            if (IsDisposed)
            {
                return;
            }

            if (disposing)
            {
                RemoveFilter();                 // Disposes m_fwPopupMessageFilter, among other things.
                if (m_treeView != null)
                {
                    EnableAfterAndBeforeSelectHandling(false);
#if !__MonoCS__ // FWNX-399
                    m_treeView.MouseDown -= new MouseEventHandler(m_treeView_MouseDown);
                    m_treeView.MouseUp   -= new MouseEventHandler(m_treeView_MouseUp);
#endif
                    m_treeView.KeyDown -= new KeyEventHandler(m_treeView_KeyDown);
                    if (!Controls.Contains(m_treeView))
                    {
                        m_treeView.Dispose();
                    }
                }

                if (components != null)
                {
                    components.Dispose();
                }
            }
            m_fwPopupMessageFilter = null;
            m_treeView             = null;
            m_tnMouseDown          = null;
            // m_selectedNodeAction = null; // Can't null it, since it is a value type.
            m_tabStopControl = null;

            base.Dispose(disposing);
        }
        /// <summary>
        /// Clean up any resources being used.
        /// </summary>
        protected override void Dispose(bool disposing)
        {
            if (disposing)
            {
                Application.Idle -= new EventHandler(Application_Idle);

                if (components != null)
                {
                    components.Dispose();
                }
                if (_formTable != null)
                {
                    foreach (Entry entry in _formTable.Values)
                    {
                        entry.Dispose();
                    }
                    _formTable = null;
                }
                _depForms.Dispose();
            }
            base.Dispose(disposing);
        }
Beispiel #31
0
        /// <summary>
        /// Clean up any resources being used.
        /// </summary>
        protected override void Dispose(bool disposing)
        {
            //Debug.WriteLineIf(!disposing, "****************** " + GetType().Name + " 'disposing' is false. ******************");
            // Must not be run more than once.
            if (IsDisposed)
            {
                return;
            }

            if (disposing)
            {
                RemoveFilter();                 // Disposes m_fwPopupMessageFilter, among other things.
                if (m_treeView != null)
                {
                    m_treeView.AfterSelect  -= new TreeViewEventHandler(m_treeView_AfterSelect);
                    m_treeView.BeforeSelect -= new TreeViewCancelEventHandler(m_treeView_BeforeSelect);
                    m_treeView.MouseDown    -= new MouseEventHandler(m_treeView_MouseDown);
                    m_treeView.MouseUp      -= new MouseEventHandler(m_treeView_MouseUp);
                    m_treeView.KeyDown      -= new KeyEventHandler(m_treeView_KeyDown);
                    if (!Controls.Contains(m_treeView))
                    {
                        m_treeView.Dispose();
                    }
                }

                if (components != null)
                {
                    components.Dispose();
                }
            }
            m_fwPopupMessageFilter = null;
            m_treeView             = null;
            m_tnMouseDown          = null;
            // m_selectedNodeAction = null; // Can't null it, since it is a value type.
            m_tabStopControl = null;

            base.Dispose(disposing);
        }
Beispiel #32
0
        /// <summary>
        /// Form initialization
        /// </summary>
        protected override void OnLoad(EventArgs args)
        {
            base.OnLoad(args);
            AutoValidate = AutoValidate.EnablePreventFocusChange;

            var options = new TestOptions()
            {
                DatabasePath = GetDefaultDatabasePath(),
                RecordsCount = 1000
            };

            var container = new Container();
            Disposed += (s, evt) => container.Dispose();

            // Update window title
            DocumentComplete += (s, evt) => Text = String.IsNullOrEmpty(Text) ? RootElement.Find("title").Text : Text;

            var providers_list = new BindingSource();

            var providers = new ListBoxControl() { Selector = "#database_provider", DataSource = providers_list };
            providers.Format += (s, e) => e.Value = ((Type)e.Value).Name;

            var new_database = new CheckBoxControl() { Selector = "#new_database" };
            new_database.DataBindings.Add("Checked", options, "CreateDatabase");

            var records_count = new TextBoxControl() { Selector = "#records_count" };
            records_count.DataBindings.Add("Text", options, "RecordsCount", true);

            var records_count_binding = records_count.DataBindings["Text"];
            records_count_binding.BindingComplete += (s, e) =>
            {
                if (options.RecordsCount < 0)
                {
                    records_count.Attributes["error"] = "true";
                    e.Cancel = true;
                }
                else
                    records_count.Attributes["error"] = null;
            };

            var selection_test = new CheckBoxControl() { Selector = "#selection_test" };
            selection_test.DataBindings.Add("Checked", options, "SelectionTest");

            var resultset_test = new CheckBoxControl() { Selector = "#resultset_test" };
            resultset_test.DataBindings.Add("Checked", options, "ResultSetTest");

            var metrics_grid = new DataGridControl() { Selector = "#metrics_grid" };
            var start_button = new ButtonControl() { Selector = "#start_tests" };
            start_button.Click += delegate
            {
                if (PerformValidation())
                {
                    metrics_grid.DataSource = Enumerable.Empty<Metric>();
                    metrics_grid.Element.Update(true);

                    var metricResults = RunProviderTests((Type)providers_list.Current, options);
                    metrics_grid.DataSource = metricResults;
                }
            };

            providers_list.CurrentItemChanged += (s, e) =>
            {
                var exists = IsDatabaseExists((Type)providers_list.Current, options);
                if (exists)
                {
                    new_database.IsEnabled = true;
                }
                else
                {
                    options.CreateDatabase = true;
                    new_database.IsEnabled = false;
                }
            };
            providers_list.DataSource = new Type[]
            {
                typeof(Provider.SqlCe.SqlCeProviderTest),
                typeof(Provider.SQLite.SQLiteProviderTest)
            };

            container.Add(providers_list);

            SciterControls.Add(records_count);
            SciterControls.Add(new_database);
            SciterControls.Add(selection_test);
            SciterControls.Add(resultset_test);
            SciterControls.Add(metrics_grid);
            SciterControls.Add(providers);
            SciterControls.Add(start_button);

            LoadHtmlResource<MainForm>("Html/Default.htm");
        }
 public void Clear()
 {
     base.CanRaiseFilterChanged = false;
     try
     {
         this.tsmiConditionAll.PerformClick();
         if (this.flpFilters.Controls.Count > 1)
         {
             this.flpFilters.SuspendLayout();
             IContainer container = new Container();
             foreach (Control control in this.flpFilters.Controls)
             {
                 if (control != this.tsNewCondition)
                 {
                     container.Add(control);
                 }
             }
             this.flpFilters.Controls.Clear();
             this.flpFilters.Controls.Add(this.tsNewCondition);
             container.Dispose();
             this.flpFilters.ResumeLayout();
         }
     }
     finally
     {
         base.CanRaiseFilterChanged = true;
     }
 }
Beispiel #34
0
    private static void Main(string[] args)
    {
      _connectionFailures = 0;
      _configFile = DefaultConfigFile;

      if (args.Length > 0)
      {
        try
        {
          if (ProcessCommandLine(args))
            return;
        }
        catch (CommandExecutionException ex)
        {
          MessageBox.Show(ex.Message, "Translator", MessageBoxButtons.OK, MessageBoxIcon.Error);
        }
        catch (CommandStructureException ex)
        {
          MessageBox.Show(ex.Message, "Translator", MessageBoxButtons.OK, MessageBoxIcon.Error);
        }
        catch (Exception ex)
        {
          MessageBox.Show(ex.ToString(), "Translator - Error processing command line", MessageBoxButtons.OK,
                          MessageBoxIcon.Error);
        }
      }

      // Check for multiple instances.
      if (Process.GetProcessesByName(Process.GetCurrentProcess().ProcessName).Length != 1)
      {
        CopyDataWM.SendCopyDataMessage(Common.CmdPrefixShowTrayIcon);
        return;
      }

      Application.EnableVisualStyles();
      Application.SetCompatibleTextRenderingDefault(false);

      IrssLog.LogLevel = IrssLog.Level.Debug;
      IrssLog.Open("Translator.log");

      Application.ThreadException += Application_ThreadException;

      // Initialize Variable List.
      _variables = new VariableList();

      // Load configuration ...
      _config = Configuration.Load(_configFile);
      if (_config == null)
      {
        IrssLog.Warn("Failed to load configuration file ({0}), creating new configuration", _configFile);
        _config = new Configuration();
      }

      // Adjust process priority ...
      AdjustPriority(_config.ProcessPriority);


      //foreach (ProgramSettings progSettings in _config.Programs)
      //{
      //  AppProfile profile = new AppProfile();

      //  profile.Name = progSettings.Name;
      //  profile.MatchType = AppProfile.DetectionMethod.Executable;
      //  profile.MatchParameters = progSettings.FileName;
      //  profile.ButtonMappings.AddRange(progSettings.ButtonMappings);

      //  AppProfile.Save(profile, "C:\\" + profile.Name + ".xml");
      //}


      // Setup notify icon ...
      _container = new Container();
      _notifyIcon = new NotifyIcon(_container);
      _notifyIcon.ContextMenuStrip = new ContextMenuStrip();
      _notifyIcon.Icon = Resources.Icon16Connecting;
      _notifyIcon.Text = "Translator - Connecting ...";
      _notifyIcon.DoubleClick += ClickSetup;
      _notifyIcon.Visible = !_config.HideTrayIcon;

      // Setup the main form ...
      _mainForm = new MainForm();

      // Start server communications ...
      bool clientStarted = false;

      IPAddress serverIP = Network.GetIPFromName(_config.ServerHost);
      IPEndPoint endPoint = new IPEndPoint(serverIP, Server.DefaultPort);

      try
      {
        clientStarted = StartClient(endPoint);
      }
      catch (Exception ex)
      {
        IrssLog.Error(ex);
        clientStarted = false;
      }

      if (clientStarted)
      {
        // Setup event notification ...
        SystemEvents.SessionEnding += SystemEvents_SessionEnding;
        SystemEvents.PowerModeChanged += SystemEvents_PowerModeChanged;

        try
        {
          _copyDataWM = new CopyDataWM();
          _copyDataWM.Start();
        }
        catch (Win32Exception ex)
        {
          IrssLog.Error("Error enabling CopyData messages: {0}", ex.ToString());
        }

        Application.Run();

        if (_copyDataWM != null)
        {
          _copyDataWM.Dispose();
          _copyDataWM = null;
        }

        SystemEvents.SessionEnding -= SystemEvents_SessionEnding;
        SystemEvents.PowerModeChanged -= SystemEvents_PowerModeChanged;

        StopClient();
      }
      else
      {
        MessageBox.Show("Failed to start IR Server communications, refer to log file for more details.",
                        "Translator - Error", MessageBoxButtons.OK, MessageBoxIcon.Error);

        _inConfiguration = true;

        _mainForm.ShowDialog();

        _inConfiguration = false;
      }

      // Dispose NotifyIcon ...
      _notifyIcon.Visible = false;
      _notifyIcon.Dispose();
      _notifyIcon = null;

      // Dispose Container ...
      _container.Dispose();
      _container = null;

      Application.ThreadException -= Application_ThreadException;

      IrssLog.Close();
    }
        private void calculateButton_Click(object sender, EventArgs e)
        {
            try
            {
                string method = MethodsComboBox.SelectedItem.ToString();

                string function = UserFunctionTextBox.Text;

                PostfixNotationExpression parser = new PostfixNotationExpression();
                parser.ToPostfixNotation(function);

                decimal a = Convert.ToDecimal(ParamATextBox.Text);
                decimal b = Convert.ToDecimal(ParamBTextBox.Text);
                decimal n = 1000;
                decimal error = Convert.ToDecimal(ErrorTextBox.Text);

                parser.CalculatePoint(a, b, n);

                List<decimal> Xs = parser.GetXsList();
                List<decimal> Ys = parser.GetYsList();

                Differentiation differentiationComponent = new Differentiation(Xs, Ys);

                List<decimal> Dys = differentiationComponent.GetFirstDervative();
                    //= differentiationComponent.CalculateDerivativeByFiniteDifferencies(Xs, Ys);
                List<decimal> D2ys = differentiationComponent.GetSecondDervative();
                    //= differentiationComponent.CalculateDerivativeByFiniteDifferencies(Xs, Dys);
                List<decimal> D3ys = differentiationComponent.GetThirdDervative();
                    //= differentiationComponent.CalculateDerivativeByFiniteDifferencies(Xs, D2ys);
                List<decimal> D4ys = differentiationComponent.GetFourthDervative();
                    //= differentiationComponent.CalculateDerivativeByFiniteDifferencies(Xs, D3ys);

                decimal result = 0;
                decimal partitionCount = 0;

                switch (method)
                {
                    case "Rectangle Method":
                        {
                            /// Rectangle Method
                            RectangleMethod rectangleMethodComponent = new RectangleMethod();
                            partitionCount = rectangleMethodComponent.CalculatePartitionCount(a, b, error, D2ys.Max());

                            if (partitionCount == 0)
                            {
                                partitionCount = n;
                            }

                            parser.CalculatePoint(a, b, partitionCount);
                            List<decimal> FunctionHalfValues = parser.GetYsHalfList();
                            result = rectangleMethodComponent.Calculate(a, b, partitionCount, FunctionHalfValues);
                            MessageBox.Show(result.ToString(), "Rectangle Method");
                            rectangleMethodComponent.Dispose();
                            break;
                        }
                    case "Trapezoidal Rule":
                        {
                            /// Trapezoidal Rule
                            TrapezoidalRule trapezoidalRuleComponent = new TrapezoidalRule();
                            partitionCount = trapezoidalRuleComponent.CalculatePartitionCount(a, b, error, D2ys.Max());

                            if (partitionCount == 0)
                            {
                                partitionCount = n;
                            }

                            parser.CalculatePoint(a, b, partitionCount);
                            List<decimal> FunctionValues = parser.GetYsList();
                            result = trapezoidalRuleComponent.Calculate(a, b, partitionCount, FunctionValues);
                            MessageBox.Show(result.ToString(), "Trapezoidal Rule");
                            trapezoidalRuleComponent.Dispose();
                            break;
                        }
                    case "Simpson's Rule":
                        {
                            /// Simpson's Rule
                            SimpsonsRule simpsonsRuleComponent = new SimpsonsRule();
                            partitionCount = simpsonsRuleComponent.CalculatePartitionCount(a, b, error, D4ys.Max());

                            if (partitionCount == 0)
                            {
                                partitionCount = n;
                            }

                            parser.CalculatePoint(a, b, partitionCount);
                            List<decimal> FunctionHalfValues = parser.GetYsHalfList();
                            List<decimal> FunctionValues = parser.GetYsList();
                            result = simpsonsRuleComponent.Calculate(a, b, partitionCount, FunctionValues, FunctionHalfValues);
                            MessageBox.Show(result.ToString(), "Simpson's Rule");
                            simpsonsRuleComponent.Dispose();
                            break;
                        }
                    case "All of these methods":
                        {
                            Container container = new Container();

                            RectangleMethod rectangleMethodComponent = new RectangleMethod();
                            TrapezoidalRule trapezoidalRuleComponent = new TrapezoidalRule();
                            SimpsonsRule simpsonsRuleComponent = new SimpsonsRule();

                            container.Add(rectangleMethodComponent, "Rectangle Method");
                            container.Add(trapezoidalRuleComponent, "Trapezoidal Rule");
                            container.Add(simpsonsRuleComponent, "Simpson's Rule");

                            string message = "";

                            /// Rectangle Method
                            partitionCount = rectangleMethodComponent.CalculatePartitionCount(a, b, error, D2ys.Max());

                            if (partitionCount == 0)
                            {
                                partitionCount = n;
                            }

                            parser.CalculatePoint(a, b, partitionCount);
                            List<decimal> FunctionHalfValues = parser.GetYsHalfList();
                            result = rectangleMethodComponent.Calculate(a, b, partitionCount, FunctionHalfValues);

                            message += rectangleMethodComponent.Site.Name + ":\n" + result.ToString() + "\n";

                            /// Trapezoidal Rule
                            partitionCount = trapezoidalRuleComponent.CalculatePartitionCount(a, b, error, D2ys.Max());

                            if (partitionCount == 0)
                            {
                                partitionCount = n;
                            }

                            parser.CalculatePoint(a, b, partitionCount);
                            List<decimal> FunctionValues = parser.GetYsList();
                            result = trapezoidalRuleComponent.Calculate(a, b, partitionCount, FunctionValues);

                            message += trapezoidalRuleComponent.Site.Name + ":\n" + result.ToString() + "\n";

                            /// Simpson's Rule
                            partitionCount = simpsonsRuleComponent.CalculatePartitionCount(a, b, error, D4ys.Max());

                            if (partitionCount == 0)
                            {
                                partitionCount = n;
                            }

                            parser.CalculatePoint(a, b, partitionCount);
                            FunctionHalfValues = parser.GetYsHalfList();
                            FunctionValues = parser.GetYsList();
                            result = simpsonsRuleComponent.Calculate(a, b, partitionCount, FunctionValues, FunctionHalfValues);

                            message += simpsonsRuleComponent.Site.Name + ":\n" + result.ToString();
                            MessageBox.Show(message, "All methods");

                            container.Dispose();
                            break;
                        }
                    default:
                        {
                            MessageBox.Show("Choose method", "Warning");
                            break;
                        }
                }

                differentiationComponent.Dispose();
                parser.Dispose();
            }
            catch (Exception exception)
            {
                MessageBox.Show(exception.ToString());
            }
        }