Beispiel #1
0
        private static BrowserWindowUnderTest GetInstance(Type typePageDefinition, params object[] args)
        {
            var browserWindow = (BrowserWindowUnderTest)Activator.CreateInstance(typePageDefinition, args);

            browserWindow.SetWindowTitle(typePageDefinition.GetField("sWindowTitle").GetValue(browserWindow).ToString());

            FieldInfo[] finfo = browserWindow.GetType().GetFields();
            foreach (FieldInfo fieldinfo in finfo)
            {
                Type fieldType = fieldinfo.FieldType;

                if (fieldType.IsAssignableFrom(typeof(ComboBox)))
                {
                    ComboBox field = (ComboBox)fieldinfo.GetValue(browserWindow);
                    field.SetWindow(browserWindow);
                }
                else if (fieldType.GetInterfaces().Contains(typeof(IControlBase)))
                {
                    IControlBase field = (IControlBase)fieldinfo.GetValue(browserWindow);

                    if (field.SourceType.IsSubclassOf(typeof(CUITHtmlControls.HtmlControl)))
                    {
                        field.Wrap(Activator.CreateInstance(field.SourceType, browserWindow));
                    }
#if SILVERLIGHT_SUPPORT
                    else if ((field.SourceType == typeof(CUITSilverlightControls.SilverlightControl)) ||
                             (field.SourceType.IsSubclassOf(typeof(CUITSilverlightControls.SilverlightControl))))
                    {
                        field.Wrap(Activator.CreateInstance(field.SourceType, browserWindow.SlObjectContainer));
                    }
#endif
                }
            }
            return(browserWindow);
        }
Beispiel #2
0
 public static void UpdateProperty <T>(this IControlBase control, ref T value, in T newValue)
Beispiel #3
0
        private void SetupDesignTime(bool showAbout)
        {
            this.MainForm                            = new Form();
            this.MainForm.Text                       = this.MainPlugInTitle;
            this.MainForm.FormBorderStyle            = FormBorderStyle.FixedDialog;
            this.MainForm.StartPosition              = FormStartPosition.CenterScreen;
            this.MainForm.ShowInTaskbar              = false;
            this.MainForm.MaximizeBox                = false;
            this.MainForm.MinimizeBox                = false;
            this.m_ScaleRatio                        = (float)((int)Math.Ceiling((double)this.MainForm.Font.GetHeight()) / this.MainForm.AutoScaleBaseSize.Height);
            this.MainForm.AutoScaleMode              = AutoScaleMode.None;
            this.m_ControlPanel                      = new PlugInControlPanel();
            this.m_ControlPanel.Dock                 = DockStyle.Bottom;
            this.m_ControlPanel.OKButton.Click      += this.ControlPanel_OkButtonClick;
            this.m_ControlPanel.CancelButton.Click  += this.ControlPanel_CancelButtonClick;
            this.m_ControlPanel.ApplyButton.Click   += this.ControlPanel_ApplyButtonClick;
            this.m_ControlPanel.ResetButton.Click   += this.ResetButton_Click;
            this.m_ControlPanel.RestoreButton.Click += this.RestoreButton_Click;
            this.UpdateExtents(this.m_ControlPanel.RequiredWidthMin, 0);
            this.MainForm.Controls.Add(this.m_ControlPanel);
            this.m_WorkingInstance = GPFunctions.CreateInstance(this.m_OriginalInstance.GetType(), this.m_OriginalInstance.GetType().FullName);
            this.m_RestoreInstance = GPFunctions.CreateInstance(this.m_OriginalInstance.GetType(), this.m_OriginalInstance.GetType().FullName);
            this.m_ResetInstance   = GPFunctions.CreateInstance(this.m_OriginalInstance.GetType(), this.m_OriginalInstance.GetType().FullName);
            if (this.m_OriginalInstance is SubClassBase)
            {
                (this.m_OriginalInstance as ISubClassBase).ResetClone(this.m_ResetInstance as SubClassBase);
            }
            if (this.m_ResetInstance is IComponentBase)
            {
                (this.m_ResetInstance as IComponentBase).SetComponentDefaults();
            }
            if (this.m_ResetInstance is CollectionBase)
            {
                (this.m_ResetInstance as CollectionBase).Reset();
            }
            if (this.m_OriginalInstance is IControlBase)
            {
                this.I_ControlBase     = (this.m_OriginalInstance as IControlBase);
                this.m_SurrogateParent = new Label();
                if (this.I_ControlBase._Parent != null)
                {
                    this.m_SurrogateParent.BackColor = this.I_ControlBase._Parent.BackColor;
                    this.m_SurrogateParent.ForeColor = this.I_ControlBase._Parent.ForeColor;
                    this.m_SurrogateParent.Font      = this.I_ControlBase._Parent.Font;
                }
                (this.m_WorkingInstance as Control).Parent = this.m_SurrogateParent;
                (this.m_ResetInstance as Control).Parent   = this.m_SurrogateParent;
                (this.m_RestoreInstance as Control).Parent = this.m_SurrogateParent;
            }
            else if (this.m_OriginalInstance is ISubClassBase)
            {
                this.I_ControlBase = (this.m_OriginalInstance as ISubClassBase).ControlBase;
                (this.m_WorkingInstance as ISubClassBase).ControlBase  = this;
                (this.m_ResetInstance as ISubClassBase).ControlBase    = this;
                (this.m_RestoreInstance as ISubClassBase).ControlBase  = this;
                (this.m_WorkingInstance as ISubClassBase).AmbientOwner = (this.m_OriginalInstance as ISubClassBase).AmbientOwner;
                (this.m_ResetInstance as ISubClassBase).AmbientOwner   = (this.m_OriginalInstance as ISubClassBase).AmbientOwner;
                (this.m_RestoreInstance as ISubClassBase).AmbientOwner = (this.m_OriginalInstance as ISubClassBase).AmbientOwner;
            }
            else if (this.m_OriginalInstance is ICollectionBase)
            {
                (this.m_WorkingInstance as ICollectionBase).ComponentBase = (this.m_OriginalInstance as ICollectionBase).ComponentBase;
                (this.m_ResetInstance as ICollectionBase).ComponentBase   = (this.m_OriginalInstance as ICollectionBase).ComponentBase;
                (this.m_RestoreInstance as ICollectionBase).ComponentBase = (this.m_OriginalInstance as ICollectionBase).ComponentBase;
            }
            TabControl tabControl = new TabControl();

            this.MainForm.Controls.Add(tabControl);
            tabControl.Dock = DockStyle.Fill;
            if (this.m_OriginalInstance is SubClassBase)
            {
                this.MainPlugIn.TabName = "General";
            }
            else
            {
                this.MainPlugIn.TabName = "Control";
            }
            this.MainPlugIn.TabControl = tabControl;
            TabPage tabPage = new TabPage();

            tabPage.Text = "About";
            tabControl.Controls.Add(tabPage);
            this.m_TabPageBorderSize = 4;
            this.m_TabPageDockMargin = 8;
            this.m_TabHeight         = tabControl.Height - tabControl.DisplayRectangle.Height - 8;
            tabControl.Controls.Remove(tabPage);
            tabPage.Dispose();
            int tabPageBorderSize  = this.TabPageBorderSize;
            int tabPageBorderSize2 = this.TabPageBorderSize;
            int offsetTop          = this.TabHeight + this.TabPageBorderSize;
            int tabPageBorderSize3 = this.TabPageBorderSize;

            this.MainPlugIn.DoTabs(tabControl, true, tabPageBorderSize, tabPageBorderSize2, offsetTop, tabPageBorderSize3, this.m_ScaleRatio, this, this.MainPlugIn.ClassPlugIns);
            if (showAbout)
            {
                this.m_AboutPlugIn         = new AboutPlugIn();
                this.m_AboutPlugIn.TabName = "About";
                this.m_AboutPlugIn.DoTabs(tabControl, true, tabPageBorderSize, tabPageBorderSize2, offsetTop, tabPageBorderSize3, this.m_ScaleRatio, this, this.MainPlugIn.SubPlugIns);
            }
            this.MainPlugIn.WorkingInstance  = this.m_WorkingInstance;
            this.MainPlugIn.OriginalInstance = this.m_OriginalInstance;
            this.TransferAmbient(this.m_OriginalInstance, this.m_WorkingInstance);
            this.TransferAmbient(this.m_OriginalInstance, this.m_RestoreInstance);
            this.MainPlugIn.UploadDisplay();
            this.MainForm.ClientSize = new Size(this.m_MaxWidth, this.m_MaxHeight + this.m_ControlPanel.Height);
            tabControl.Dock          = DockStyle.None;
            tabControl.Height        = this.m_MaxHeight;
            tabControl.Width         = this.m_MaxWidth;
            this.MainPlugIn.FixupAlign();
            this.m_ControlPanel.Dock  = DockStyle.None;
            this.m_ControlPanel.Width = this.MainForm.ClientSize.Width;
            this.m_ControlPanel.Top   = this.MainForm.ClientSize.Height - this.m_ControlPanel.Height;
            this.m_ControlPanel.DoLayout();
            this.UpdateControlPanel();
        }
Beispiel #4
0
        private IControlBase WrapUtil(CUITControls.SilverlightControl control)
        {
            IControlBase _con = null;

            if (control.GetType() == typeof(CUITControls.SilverlightButton))
            {
                _con = new SilverlightButton();
            }
            else if (control.GetType() == typeof(CUITControls.SilverlightCalendar))
            {
                _con = new SilverlightCalendar();
            }
            else if (control.GetType() == typeof(CUITControls.SilverlightCell))
            {
                _con = new SilverlightCell();
            }
            else if (control.GetType() == typeof(CUITControls.SilverlightCheckBox))
            {
                _con = new SilverlightCheckBox();
            }
            else if (control.GetType() == typeof(CUITControls.SilverlightComboBox))
            {
                _con = new SilverlightComboBox();
            }
            else if (control.GetType() == typeof(CUITControls.SilverlightDataPager))
            {
                _con = new SilverlightDataPager();
            }
            else if (control.GetType() == typeof(CUITControls.SilverlightDatePicker))
            {
                _con = new SilverlightDatePicker();
            }
            else if (control.GetType() == typeof(CUITControls.SilverlightEdit))
            {
                _con = new SilverlightEdit();
            }
            else if (control.GetType() == typeof(CUITControls.SilverlightHyperlink))
            {
                _con = new SilverlightHyperlink();
            }
            else if (control.GetType() == typeof(CUITControls.SilverlightImage))
            {
                _con = new SilverlightImage();
            }
            else if (control.GetType() == typeof(CUITControls.SilverlightLabel))
            {
                _con = new SilverlightLabel();
            }
            else if (control.GetType() == typeof(CUITControls.SilverlightList))
            {
                _con = new SilverlightList();
            }
            else if (control.GetType() == typeof(CUITControls.SilverlightRadioButton))
            {
                _con = new SilverlightRadioButton();
            }
            else if (control.GetType() == typeof(CUITControls.SilverlightSlider))
            {
                _con = new SilverlightSlider();
            }
            else if (control.GetType() == typeof(CUITControls.SilverlightTab))
            {
                _con = new SilverlightTab();
            }
            else if (control.GetType() == typeof(CUITControls.SilverlightTabItem))
            {
                _con = new SilverlightTabItem();
            }
            else if (control.GetType() == typeof(CUITControls.SilverlightTable))
            {
                _con = new SilverlightTable();
            }
            else if (control.GetType() == typeof(CUITControls.SilverlightText))
            {
                _con = new SilverlightText();
            }
            else if (control.GetType() == typeof(CUITControls.SilverlightTree))
            {
                _con = new SilverlightTree();
            }
            else
            {
                throw new Exception(string.Format("WrapUtil: '{0}' is not supported.", control.GetType()));
            }

            _con.WrapReady(control);
            return(_con);
        }