public void SetUpFixture()
        {
            RubyComponentWalker walker = new RubyComponentWalker(componentCreator);

            form        = walker.CreateComponent(RubyCode) as Form;
            userControl = form.Controls[0] as DoublePropertyUserControl;
        }
Esempio n. 2
0
        private void FillForm()
        {
            this.scrollPanel1.Clear();

            this.Text = _item.DisplayName;

            int y = 20;

            foreach (Property property in _item.Properties)
            {
                if (property.UIImportance != UIImportance.Hidden || MainForm.ShowHiddenProperties)
                {
                    PropertyUserControl uc;
                    if (property.TranslationId == "PropertyBasicUserSid")
                    {
                        ConfigurationItem[] users = _configApiClient.GetChildItems("/" + ItemTypes.BasicUserFolder);
                        uc = new SidPropertyUserControl(property, users);
                    }
                    else
                    {
                        switch (property.ValueType)
                        {
                        case ValueTypes.IntType:
                            uc = new IntPropertyUserControl(property);
                            break;

                        case ValueTypes.DoubleType:
                            uc = new DoublePropertyUserControl(property);
                            break;

                        case ValueTypes.TickType:
                            uc = new TickPropertyUserControl(property);
                            break;

                        case ValueTypes.EnumType:
                            uc = new EnumPropertyUserControl(property);
                            break;

                        case ValueTypes.SliderType:
                            uc = new SliderPropertyUserControl(property);
                            break;

                        case ValueTypes.ProgressType:
                            ProgressPropertyUserControl progressuc = new ProgressPropertyUserControl(property);
                            uc = progressuc;
                            break;

                        case ValueTypes.Path:
                            uc = new PathPropertyUserControl(property, _configApiClient);
                            break;

                        case ValueTypes.PathList:
                            uc = new PathListPropertyUserControl(property, _configApiClient);
                            break;

                        case ValueTypes.DateTimeType:
                        case "Time":
                        case "Date":
                            if (property.IsSettable)
                            {
                                uc = new DateTimePickerPropertyUserControl(property);
                            }
                            else
                            {
                                uc = new DateTimeDisplayPropertyUserControl(property);
                            }
                            break;

                        case ValueTypes.SeparatorType:
                            uc = new SeperatorPropertyUserControl(property);
                            break;

                        case ValueTypes.StringType:
                        default:
                            uc = new StringPropertyUserControl(property);
                            break;
                        }
                    }
                    uc.Location      = new Point(0, y);
                    uc.Tag           = property;
                    uc.Anchor        = AnchorStyles.Left | AnchorStyles.Top | AnchorStyles.Right;
                    uc.ValueChanged += new EventHandler(ValueChangedHandler);
                    if (property.ToolTipTranslationId != null)
                    {
                        uc.ToolTip = _configApiClient.Translate(property.ToolTipTranslationId);
                    }

                    if (property.UIImportance == 3)
                    {
                        uc.Enabled = false;
                    }

                    if (property.Key == "SessionDataId")
                    {
                        SessionDataId = property.Value;
                    }

                    scrollPanel1.Add(uc);
                    y += uc.Height;
                }
            }

            if (_item.Children != null && _item.Children.Any())
            {
                if (_item.Children[0].ItemType == ItemTypes.Task)
                {
                    UserControl folderUC = new TaskUserControl(_item, _item.Children, _configApiClient)
                    {
                        Location = new Point(0, y), Size = new Size(this.Width, this.Height - y)
                    };
                    scrollPanel1.Add(folderUC);
                }
                else
                {
                    UserControl folderUC = new FolderUserControl(_item, _item.Children)
                    {
                        Location = new Point(0, y), Size = new Size(this.Width, this.Height - y)
                    };
                    scrollPanel1.Add(folderUC);
                }
            }

            panelMain.Anchor = AnchorStyles.Left | AnchorStyles.Right | AnchorStyles.Top | AnchorStyles.Bottom;

            int x = this.Width - 24;

            if (_item.MethodIds != null)
            {
                for (int i = _item.MethodIds.Length - 1; i > -1; i--)
                {
                    MethodInfo mi = _configApiClient.AllMethodInfos[_item.MethodIds[i]];
                    if (mi == null)
                    {
                        MessageBox.Show("Method is missing:" + _item.MethodIds[i]);
                        timer1.Stop();
                        this.Close();
                    }
                    Button b = new Button()
                    {
                        Text = mi.DisplayName, Tag = mi, UseVisualStyleBackColor = true
                    };
                    b.Size     = new System.Drawing.Size(150, 24);
                    x         -= 150;
                    b.Location = new Point(x, 6);
                    x         -= 24;
                    b.Click   += PerformAction;
                    panelActions.Controls.Add(b);
                }
            }
            string text   = _item.MethodIds == null || _item.MethodIds.Length == 0 ? "Close" : "Cancel";
            Button cancel = new Button()
            {
                Text = text, UseVisualStyleBackColor = true
            };

            cancel.Size     = new System.Drawing.Size(100, 24);
            x              -= 100;
            cancel.Location = new Point(x, 6);
            cancel.Click   += PerformCancel;
            panelActions.Controls.Add(cancel);

            Property pathProperty = _item.Properties.FirstOrDefault <Property>(p => p.Key == InvokeInfoProperty.Path);

            if (pathProperty != null)
            {
                if (pathProperty.Value.StartsWith("Task"))
                {
                    taskPath = pathProperty.Value;
                    timer1.Start();
                }
            }
        }