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


C# Container.Add方法代码示例

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


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

示例1: FormLog

 protected FormLog()
 {
     InitializeComponent();
     repaintTimer = new Timer { Interval = 1000 };
     components = new Container();
     components.Add(repaintTimer);
     repaintTimer.Tick += (s, e) => UpdateLines();
     instance = this;
 }
开发者ID:GoogleFrog,项目名称:Zero-K-Infrastructure,代码行数:9,代码来源:FormLog.cs

示例2: Form1

 public Form1()
 {
     InitializeComponent();
     components = new Container();
     components.Add(_musicPlayer);
     _musicPlayer.PlaybackStopped += (s, args) =>
     {
         btnPlay.Enabled = btnStop.Enabled = btnPause.Enabled = false;
     };
 }
开发者ID:hoangduit,项目名称:cscore,代码行数:10,代码来源:Form1.cs

示例3: DeviceNotifierApplicationContext

        public DeviceNotifierApplicationContext()
        {
            _components = new Container();
            _notifyIcon = new NotifyIcon(_components)
            {
                ContextMenuStrip = new ContextMenuStrip(),
                Icon = SystemIcons.Application, // TODO: Fix
                Text = @"Device Notifications",
                Visible = true
            };

            _notifyIcon.ContextMenuStrip.Opening += ContextMenuStripOnOpening;
            _notifyIcon.DoubleClick += (sender, args) => _notifyIcon.ContextMenuStrip.Show();

            var timer = new Timer(_components);
            var messagesForm = new MessagesForm();
            _components.Add(messagesForm);
            var mainForm = new MainForm(_notifyIcon, messagesForm, timer);
            _components.Add(mainForm);
            MainForm = mainForm;
        }
开发者ID:rossipedia,项目名称:DeviceNotifier,代码行数:21,代码来源:DeviceNotifierApplicationContext.cs

示例4: Form1

 public Form1()
 {
     InitializeComponent();
     components = new Container();
     components.Add(_musicPlayer);
     _musicPlayer.PlaybackStopped += (s, args) =>
     {
         //WasapiOut uses SynchronizationContext.Post to raise the event
         //There might be already a new WasapiOut-instance in the background when the async Post method brings the PlaybackStopped-Event to us.
         if(_musicPlayer.PlaybackState != PlaybackState.Stopped)
             btnPlay.Enabled = btnStop.Enabled = btnPause.Enabled = false;
     };
 }
开发者ID:opcon,项目名称:cscore,代码行数:13,代码来源:Form1.cs

示例5: RpcServiceContext

        public RpcServiceContext(IRpcService service)
        {
            if (service == null)
                throw new ArgumentNullException("service");

            _service = service;
            _contextServices = new ServiceContainer();
            _contextServices.AddService(typeof(IRpcService), service);
            _container = new Container(this);

            IComponent component = service as IComponent;

            if (component != null)
                _container.Add(component);
        }
开发者ID:BackupTheBerlios,项目名称:jayrock-svn,代码行数:15,代码来源:RpcServiceContext.cs

示例6: ConvertTo

		public void ConvertTo ()
		{
			ReferenceConverter converter = new ReferenceConverter (typeof(ITestInterface));
			string referenceName = "reference name";

			Assert.AreEqual ("(none)", (string)converter.ConvertTo (null, null, null, typeof(string)), "#1");

			TestComponent component = new TestComponent();

			// no context
			Assert.AreEqual (String.Empty, (string)converter.ConvertTo (null, null, component, typeof(string)), "#2");

			// context with IReferenceService
			TestReferenceService referenceService = new TestReferenceService ();
			referenceService.AddReference (referenceName, component);
			TestTypeDescriptorContext context = new TestTypeDescriptorContext (referenceService);
			Assert.AreEqual (referenceName, (string)converter.ConvertTo (context, null, component, typeof(string)), "#3");
			
			// context with Component without IReferenceService
			Container container = new Container ();
			container.Add (component, referenceName);
			context = new TestTypeDescriptorContext ();
			context.Container = container;
			Assert.AreEqual (referenceName, (string)converter.ConvertTo (context, null, component, typeof(string)), "#4");
		}
开发者ID:nlhepler,项目名称:mono,代码行数:25,代码来源:ReferenceConverterTest.cs

示例7: ConvertFrom

		public void ConvertFrom ()
		{
			ReferenceConverter converter = new ReferenceConverter (typeof(ITestInterface));
			string referenceName = "reference name";
			// no context
			Assert.IsNull (converter.ConvertFrom (null, null, referenceName), "#1");

			TestComponent component = new TestComponent();

			// context with IReferenceService
			TestReferenceService referenceService = new TestReferenceService ();
			referenceService.AddReference (referenceName, component);
			TestTypeDescriptorContext context = new TestTypeDescriptorContext (referenceService);
			Assert.AreSame (component, converter.ConvertFrom (context, null, referenceName), "#2");
			
			// context with Component without IReferenceService
			Container container = new Container ();
			container.Add (component, referenceName);
			context = new TestTypeDescriptorContext ();
			context.Container = container;
			Assert.AreSame (component, converter.ConvertFrom (context, null, referenceName), "#3");
		}
开发者ID:nlhepler,项目名称:mono,代码行数:22,代码来源:ReferenceConverterTest.cs

示例8: calculateButton_Click


//.........这里部分代码省略.........
                            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";
开发者ID:suratovvlad,项目名称:NumericalIntegrationApplication,代码行数:67,代码来源:MainForm.cs

示例9: btAddContainer_Click

        //Add container to the database
        private void btAddContainer_Click(object sender, EventArgs e)
        {
            Container container = new Container();
            ContainerType containerType = new ContainerType();
            string error = string.Empty;
            lbError.Text = string.Empty;

            //Check if all fields have input
            if(costumer.id == 0)
            {
                error += "Geen bedrijf geselecteerd \n";
            }

            //Check if a type or destination is selected
            containerType = containerTypes[cbType.SelectedIndex];
            destination = destinations[cbDestination.SelectedIndex];

            if(containerType.id == 0)
            {
                error += "Geen type geselecteerd \n";
            }

            if (destination.id == 0)
            {
                error += "Geen bestemming geselecteerd \n";
            }

            //check if weight is a number
            try
            {
                additionalWeight = Convert.ToInt16(NUPWeight.Value);
            }
            catch(Exception ex)
            {
                error += "Geen correct gewicht nummer \n";
            }

            //check if weight is not 0
            if (additionalWeight < 1)
            {
                error += "Gewicht mag niet nul zijn \n";
            }

            //DEBUG
            //if (error != string.Empty)

            //If there are no errors add the container to the database
            if (error == string.Empty)
            {
                //In case of database failure check result
                bool succes = container.Add(costumer, containerType, destination, additionalWeight);

                //if succes empty form
                if (succes)
                {
                    lbError.Text = string.Empty;
                    NUPWeight.Value = 0;
                    cbType.SelectedIndex = -1;
                    cbDestination.SelectedIndex = -1;
                }
                else
                {
                    //Show errors
                    error += "Er is iets fout gegaan bij het wegschijven";
                    lbError.Text = error;
                }

            }
            else
            {
                //Show errors
                lbError.Text = error;
            }
        }
开发者ID:BSpartan,项目名称:Container-Shipping-Company,代码行数:75,代码来源:containerForm.cs

示例10: 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

示例11: NameTest

		public void NameTest ()
		{
			Container container = new Container ();
			Component owner = new Component ();
			container.Add (owner, "OwnerName");
			NestedContainerTest nestedContainer = new NestedContainerTest (owner);
			Component nestedComponent = new Component ();
			nestedContainer.Add (nestedComponent, "NestedComponentName");

			Assert.AreEqual ("OwnerName", nestedContainer.OwnerName, "#1");
			Assert.AreEqual ("OwnerName.NestedComponentName", ((INestedSite)nestedComponent.Site).FullName, "#2");
			// Prooves that MSDN is wrong.
			Assert.AreEqual ("NestedComponentName", nestedComponent.Site.Name, "#3");

			container.Remove (owner);
			Assert.AreEqual (null, nestedContainer.OwnerName, "#4");
			Assert.AreEqual ("NestedComponentName", ((INestedSite)nestedComponent.Site).FullName, "#5");
		}
开发者ID:nlhepler,项目名称:mono,代码行数:18,代码来源:NestedContainerTest.cs

示例12: Find

		private IComponent Find(string name, Component Component)
		{
			Container results = new Container();
			foreach(Component c in Component.Container.Components)
			{
				results.Add(Find(name,c));
			}
				if(Matches(name, Component))
			{
				//results.Add(Component);
				return Component;
			}
			else
			{
				throw new ApplicationException("Code is not complete, yet.");
			}

			//TODO : Control c in Control.Components kan, maar waarschijnlijk kan
			//een Component geen andere Components bevatten.
			//foreach(Component c in Component.Components)
			//{
			//    results.Add(Find(name, c));
			//}

			//return results;
		}
开发者ID:bbriggs,项目名称:wesay,代码行数:26,代码来源:ComponentFinder.cs

示例13: FindComponents

		private Container FindComponents()
		{
			Container found = new Container();
			foreach(Form form in FormCollection)
			{
				found.Add(Find(name, form));
			}
			return found;
		}
开发者ID:bbriggs,项目名称:wesay,代码行数:9,代码来源:ComponentFinder.cs

示例14: 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

示例15: Integrate_Click

        private void Integrate_Click(object sender, EventArgs e)
        {
            String function="";
            double from = 0;
            double to = 0;
            double error = 0;
            Char variable = ' ';
            if (!GetInputs(ref function, ref from, ref to, ref error, ref variable))
                return;

            Parser parser = new Parser();
            Parser.IManyArgumentsFunction f_many_arguments = parser.ParseString(function);

            Dictionary<char, double> args = new Dictionary<char, double>();
            args.Add(variable, 0);

            FunctionContainer functionContainer = new FunctionContainer();
            FunctionContainer.IFunction f_one_argument = functionContainer.CreateOneArgumentFunction(f_many_arguments.GetValue, args, variable);

            Derivator derivator = new Derivator();
            if (RadioRectangle.Checked)
            {
                Derivator.IManyArgumentsDerivative d_2_many_arguments = derivator.Derivate(function, variable, 2);
                FunctionContainer.IFunction d_2_one_argument = functionContainer.CreateOneArgumentFunction(d_2_many_arguments.GetValue, args, variable);

                IntegrationLib.Integrators.RectanglesIntegrator rectanglesIntegrator = new IntegrationLib.Integrators.RectanglesIntegrator();
                MessageBox.Show(rectanglesIntegrator.Integrate(f_one_argument.GetValue, d_2_one_argument.GetValue, from, to, error).ToString());
            }
            else
            if (RadioTrapeze.Checked)
            {
                Derivator.IManyArgumentsDerivative d_2_many_arguments = derivator.Derivate(function, variable, 2);
                FunctionContainer.IFunction d_2_one_argument = functionContainer.CreateOneArgumentFunction(d_2_many_arguments.GetValue, args, variable);

                IntegrationLib.Integrators.TrapezeIntegrator trapezeIntegrator = new IntegrationLib.Integrators.TrapezeIntegrator();
                MessageBox.Show(trapezeIntegrator.Integrate(f_one_argument.GetValue, d_2_one_argument.GetValue, from, to, error).ToString());
            }
            else
            if (RadioSimpsons.Checked)
            {
                Derivator.IManyArgumentsDerivative d_4_many_arguments = derivator.Derivate(function, variable, 4);
                FunctionContainer.IFunction d_4_one_argument = functionContainer.CreateOneArgumentFunction(d_4_many_arguments.GetValue, args, variable);

                IntegrationLib.Integrators.SimpsonsIntegrator simpsonsIntegrator = new IntegrationLib.Integrators.SimpsonsIntegrator();
                MessageBox.Show(simpsonsIntegrator.Integrate(f_one_argument.GetValue, d_4_one_argument.GetValue, from, to, error).ToString());
            }
            else
            {
                Derivator.IManyArgumentsDerivative d_2_many_arguments = derivator.Derivate(function, variable, 2);
                Derivator.IManyArgumentsDerivative d_4_many_arguments = derivator.Derivate(function, variable, 4);

                FunctionContainer.IFunction d_2_one_argument = functionContainer.CreateOneArgumentFunction(d_2_many_arguments.GetValue, args, variable);
                FunctionContainer.IFunction d_4_one_argument = functionContainer.CreateOneArgumentFunction(d_4_many_arguments.GetValue, args, variable);

                IntegrationLib.Integrators.RectanglesIntegrator rectanglesIntegrator = new IntegrationLib.Integrators.RectanglesIntegrator();
                IntegrationLib.Integrators.TrapezeIntegrator trapezeIntegrator = new IntegrationLib.Integrators.TrapezeIntegrator();
                IntegrationLib.Integrators.SimpsonsIntegrator simpsonsIntegrator = new IntegrationLib.Integrators.SimpsonsIntegrator();

                Container cnt = new Container();
                cnt.Add(rectanglesIntegrator, "Rectangles");
                cnt.Add(trapezeIntegrator, "Trapeze");
                cnt.Add(simpsonsIntegrator, "Simpsons");

                String result = "Прямоугольники:\t" + rectanglesIntegrator.Integrate(f_one_argument.GetValue, d_2_one_argument.GetValue, from, to, error).ToString() + "\n";
                result += "Трапеции:\t" + trapezeIntegrator.Integrate(f_one_argument.GetValue, d_2_one_argument.GetValue, from, to, error).ToString() + "\n";
                result += "Симпсон:\t\t" + simpsonsIntegrator.Integrate(f_one_argument.GetValue, d_2_one_argument.GetValue, from, to, error).ToString() + "\n";

                MessageBox.Show(result);
            }
        }
开发者ID:puninvv,项目名称:university,代码行数:70,代码来源:MainForm.cs


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