当前位置: 首页>>代码示例>>C#>>正文


C# Container.Dispose方法代码示例

本文整理汇总了C#中System.ComponentModel.Container.Dispose方法的典型用法代码示例。如果您正苦于以下问题:C# Container.Dispose方法的具体用法?C# Container.Dispose怎么用?C# Container.Dispose使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在System.ComponentModel.Container的用法示例。


在下文中一共展示了Container.Dispose方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: ShowNotification

        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();
        }
开发者ID:pfn,项目名称:itunes-controller,代码行数:29,代码来源:iTunesC.cs

示例2: calculateButton_Click

        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();

//.........这里部分代码省略.........
开发者ID:suratovvlad,项目名称:NumericalIntegrationApplication,代码行数:101,代码来源:MainForm.cs

示例3: Clear

 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;
     }
 }
开发者ID:shankithegreat,项目名称:commanderdotnet,代码行数:28,代码来源:ContainerFilterControl.cs

示例4: Main


//.........这里部分代码省略.........

      // 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();
    }
开发者ID:astalavister,项目名称:IR-Server-Suite,代码行数:101,代码来源:Program.cs

示例5: OnLoad

        /// <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");
        }
开发者ID:emtfamen,项目名称:expemerent,代码行数:94,代码来源:MainForm.cs


注:本文中的System.ComponentModel.Container.Dispose方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。