コード例 #1
0
        public void Test_create_returns_valid_component()
        {
            // Arrange.
            const string file      = "fileName";
            var          component = _componentCreator.CreateComponent(_messageHub, file);

            // Act.
            // Assert.
            component.Should().NotBeNull("the creator should return a valid component.");
        }
コード例 #2
0
        /// <summary>
        /// Creates a form from the dialog element and sets its properties, but
        /// does not add any controls to it.
        /// </summary>
        /// <remarks>
        /// We set the ClientSize of the form rather than the Size since the Height
        /// and Width attributes seem to refer to the client area height and width.
        /// </remarks>
        Form CreateForm(IComponentCreator componentCreator)
        {
            string     dialogId      = dialogElement.GetAttribute("Id");
            IComponent formComponent = componentCreator.CreateComponent(typeof(Form), dialogId);
            Form       dialog        = (Form)formComponent;

            dialog.Name            = dialogId;
            dialog.Text            = dialogElement.GetAttribute("Title");
            dialog.FormBorderStyle = FormBorderStyle.FixedDialog;
            dialog.ClientSize      = GetControlSize(dialogElement);
            dialog.MaximizeBox     = false;
            dialog.MinimizeBox     = IsMinimizeButtonEnabled(dialogElement);

            return(dialog);
        }
コード例 #3
0
        /// <summary>
        /// Uses the creator to create a component, and then add that component to the list.
        /// </summary>
        /// <param name="creator"> The specific component creator. </param>
        /// <param name="fileName"> The filename (location) that the component uses to read from. </param>
        /// <returns></returns>
        public bool RegisterComponent(IComponentCreator creator, string fileName)
        {
            var response = false;

            // Contract requirements.
            if (creator != null && !string.IsNullOrWhiteSpace(fileName))
            {
                var component = creator.CreateComponent(Hub, fileName);
                Hub.Subscribe <string>(async(s) => await component.Processor.ProcessAsync(fileName).ConfigureAwait(false));
                Components.Add(component);
                response = true;
            }

            return(response);
        }
コード例 #4
0
 public override bool Walk(FunctionDefinition node)
 {
     if (IsInitializeComponentMethod(node))
     {
         Type type = GetComponentType();
         component = componentCreator.CreateComponent(type, componentName);
         IResourceReader reader = componentCreator.GetResourceReader(CultureInfo.InvariantCulture);
         if (reader != null)
         {
             reader.Dispose();
         }
         node.Body.Walk(this);
     }
     return(false);
 }
コード例 #5
0
        /// <summary>
        /// Creates a control of the given type. This is a common routine that creates
        /// and sets up various control properties that the Wix Control element defines and
        /// are common across control types.
        /// </summary>
        /// <param name="type">The type of control to create (e.g. Button)</param>
        /// <param name="controlElement">The Wix Control element.</param>
        /// <param name="componentCreator">The object to use to create the control.</param>
        /// <param name="name">The name of the component to create.</param>
        Control CreateControl(Type type, XmlElement controlElement, IComponentCreator componentCreator, string name)
        {
            Control control = (Control)componentCreator.CreateComponent(type, name);

            // Disabling controls does not seem to work. In the designer they are still
            // enabled. The XML forms designer has the same problem even back as far as
            // SharpDevelop 1.1
            control.Enabled  = !IsDisabled(controlElement);
            control.Name     = name;
            control.Text     = GetControlText(controlElement);
            control.Location = GetControlLocation(controlElement);
            control.Size     = GetControlSize(controlElement);
            control.Font     = GetFont(control.Text, control.Font);

            return(control);
        }
コード例 #6
0
        protected override void Walk(MethodDefinition node)
        {
            if (IsInitializeComponentMethod(node))
            {
                Type type = GetComponentType();
                component = componentCreator.CreateComponent(type, componentName);

                IResourceReader reader = componentCreator.GetResourceReader(CultureInfo.InvariantCulture);
                if (reader != null)
                {
                    reader.Dispose();
                }

                WalkMethodStatements(node.Body.Statements);
            }
        }
コード例 #7
0
ファイル: WixDialog.cs プロジェクト: Bombadil77/SharpDevelop
		/// <summary>
		/// Creates a control of the given type. This is a common routine that creates 
		/// and sets up various control properties that the Wix Control element defines and
		/// are common across control types.
		/// </summary>
		/// <param name="type">The type of control to create (e.g. Button)</param>
		/// <param name="controlElement">The Wix Control element.</param>
		/// <param name="componentCreator">The object to use to create the control.</param>
		/// <param name="name">The name of the component to create.</param>
		Control CreateControl(Type type, XmlElement controlElement, IComponentCreator componentCreator, string name)
		{
			Control control = (Control)componentCreator.CreateComponent(type, name);
			
			// Disabling controls does not seem to work. In the designer they are still
			// enabled. The XML forms designer has the same problem even back as far as
			// SharpDevelop 1.1
			control.Enabled = !IsDisabled(controlElement);
			control.Name = name;
			control.Text = GetControlText(controlElement);
			control.Location = GetControlLocation(controlElement);
			control.Size = GetControlSize(controlElement);
			control.Font = GetFont(control.Text, control.Font);
			
			return control;
		}
コード例 #8
0
ファイル: WixDialog.cs プロジェクト: Bombadil77/SharpDevelop
		/// <summary>
		/// Creates a form from the dialog element and sets its properties, but 
		/// does not add any controls to it.
		/// </summary>
		/// <remarks>
		/// We set the ClientSize of the form rather than the Size since the Height
		/// and Width attributes seem to refer to the client area height and width.
		/// </remarks>
		Form CreateForm(IComponentCreator componentCreator)
		{
			string dialogId = dialogElement.GetAttribute("Id");
			IComponent formComponent = componentCreator.CreateComponent(typeof(Form), dialogId);
			Form dialog = (Form)formComponent;
			dialog.Name = dialogId;
			dialog.Text = dialogElement.GetAttribute("Title");
			dialog.FormBorderStyle = FormBorderStyle.FixedDialog;
			dialog.ClientSize = GetControlSize(dialogElement);
			dialog.MaximizeBox = false;
			dialog.MinimizeBox = IsMinimizeButtonEnabled(dialogElement);
			
			return dialog;
		}