Add() public method

Adds the specified component to the . The component is unnamed.

public Add ( IComponent component ) : void
component IComponent
return void
 protected FormLog()
 {
     InitializeComponent();
     repaintTimer = new Timer { Interval = 1000 };
     components = new Container();
     components.Add(repaintTimer);
     repaintTimer.Tick += (s, e) => UpdateLines();
     instance = this;
 }
Beispiel #2
0
 public Form1()
 {
     InitializeComponent();
     components = new Container();
     components.Add(_musicPlayer);
     _musicPlayer.PlaybackStopped += (s, args) =>
     {
         btnPlay.Enabled = btnStop.Enabled = btnPause.Enabled = false;
     };
 }
        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;
        }
Beispiel #4
0
 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;
     };
 }
        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);
        }
		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");
		}
		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");
		}
        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());
            }
        }
        //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;
            }
        }
Beispiel #10
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");
        }
Beispiel #11
0
		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");
		}
Beispiel #12
0
		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;
		}
Beispiel #13
0
		private Container FindComponents()
		{
			Container found = new Container();
			foreach(Form form in FormCollection)
			{
				found.Add(Find(name, form));
			}
			return found;
		}
 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 #15
0
        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);
            }
        }
Beispiel #16
0
			public Container CreateContainer ()
			{
				if (container != null)
					throw new InvalidOperationException ();
				container = new Container ();
				container.Add (new MyComponent ());
				container.Add (this);
				return container;
			}
		/// <summary>
		/// Initializes a new instance of the <see cref="NuGenGenericBase"/> class.
		/// </summary>
		public NuGenGenericBase()
		{
			_components = new Container();

			_counter = new PerformanceCounter();
			_counter.MachineName = Dns.GetHostName();
			_components.Add(_counter);

			_refreshTimer = new Timer();
			_refreshTimer.Enabled = true;
			_refreshTimer.Interval = 500;
			_refreshTimer.Tick += new EventHandler(refreshTimer_Tick);
			_components.Add(_refreshTimer);
			
			this.SetStyle(ControlStyles.AllPaintingInWmPaint, true);
			this.SetStyle(ControlStyles.DoubleBuffer, true);
			this.SetStyle(ControlStyles.SupportsTransparentBackColor, true);
			this.SetStyle(ControlStyles.UserMouse, false);
			this.SetStyle(ControlStyles.UserPaint, true);
			this.BackColor = Color.Transparent;
		}