public MainForm()
 {
     InitializeComponent();
     // Create and add the CustomUserControl manually and not from ToolBox
     customUserControl = new CustomUserControl(this);
     this.Controls.Add(customUserControl);
 }
        /// <summary>
        /// contains the recipe that says that each UI interface in this app must have a header,
        /// a mainContent and a footer,
        /// the content of this elements can vary but their locations and dimensions must be always the same
        /// header is located on the top of the page
        /// footer is located on the bottom of the page
        /// body is located between header and footer
        /// </summary>
        public GenericUI() : base()
        {
            this.VerticalAlignment = System.Windows.VerticalAlignment.Top;
            _header  = GetHeader();
            _footer  = GetFooter();
            _content = GetMainContent();
            _content.HorizontalAlignment = HorizontalAlignment.Stretch;
            _content.VerticalAlignment   = VerticalAlignment.Stretch;

            _content.OnPageContentChange  += new CustomUserControl.ChangePageContentHandler(ChangePageContent);
            _content.OnWindowLayoutChange += new CustomUserControl.ChangeWindowLayoutHandler(ChangeWindowLayout);
            _header.OnWindowLayoutChange  += new CustomUserControl.ChangeWindowLayoutHandler(ChangeWindowLayout);
            this.RowDefinitions.Add(new RowDefinition());
            this.RowDefinitions.Add(new RowDefinition());
            this.RowDefinitions.Add(new RowDefinition());

            this.RowDefinitions[0].Height = new GridLength(50);
            this.RowDefinitions[1].Height = new GridLength(1, GridUnitType.Star);
            this.RowDefinitions[2].Height = new GridLength(30);
            Grid.SetRow(_header, 0);
            Grid.SetColumn(_header, 0);
            Grid.SetRow(_content, 1);
            Grid.SetColumn(_content, 0);
            Grid.SetRow(_footer, 2);
            Grid.SetColumn(_footer, 0);

            this.Children.Add(_header);
            this.Children.Add(_content);
            this.Children.Add(_footer);
        }
示例#3
0
    protected override void Paint(Graphics graphics, Rectangle clipBounds, Rectangle cellBounds, int rowIndex, DataGridViewElementStates cellState, object value, object formattedValue, string errorText, DataGridViewCellStyle cellStyle, DataGridViewAdvancedBorderStyle advancedBorderStyle, DataGridViewPaintParts paintParts)
    {
        CustomUserControl ctrl = (CustomUserControl)value;
        Bitmap            img  = new Bitmap(cellBounds.Width, cellBounds.Height);

        ctrl.DrawToBitmap(img, new Rectangle(0, 0, ctrl.Width, ctrl.Height));
        graphics.DrawImage(img, cellBounds.Location);
    }
        public FormLoader(CustomUserControl <T> uc)
        {
            child_uc = uc as CustomUserControl <T>;
            InitializeComponent();
            UpdateSize();

            pnlMain.LoadUC(child_uc);

            StartPosition = FormStartPosition.CenterScreen;
        }
示例#5
0
        void CustomInitialize()
        {
            // Test if derived controls automatically get visuals from their base if the derived doesn't exist...
            control = new CustomUserControl();
            control.Visual.AddToManagers();


            TestRadioButtonSelected();

            TestListBoxSelected();
        }
示例#6
0
        private void OpenWinformsView()
        {
            var control = new CustomUserControl();
            var frm     = new Form();

            frm.Controls.Add(control);
            frm.Width     = 600;
            frm.Height    = 400;
            frm.BackColor = System.Drawing.Color.White;
            frm.Show();
        }
        private void frmSchedule_Shown(object sender, EventArgs e)
        {
            CustomUserControl clr = (CustomUserControl)((Control)mainPanel.Controls[0]);

            this.Width             = clr.Width + 40;
            this.Height            = clr.Height + 40;
            mainPanel.Width        = clr.Width + 20;
            mainPanel.Height       = clr.Height + 20;
            this.AutoSize          = true;
            this.AutoSizeMode      = AutoSizeMode.GrowAndShrink;
            mainPanel.AutoSize     = true;
            mainPanel.AutoSizeMode = AutoSizeMode.GrowAndShrink;
        }
        private void frmClipBoard_Shown(object sender, EventArgs e)
        {
            CustomUserControl clr = (CustomUserControl)((Control)mainPanel.Controls[0]);

            this.Width             = clr.Width + 40;
            this.Height            = clr.Height + 40;
            mainPanel.Width        = clr.Width + 20;
            mainPanel.Height       = clr.Height + 20;
            this.AutoSize          = true;
            this.AutoSizeMode      = AutoSizeMode.GrowAndShrink;
            mainPanel.AutoSize     = true;
            mainPanel.AutoSizeMode = AutoSizeMode.GrowAndShrink;
            this.Location          = new Point((Screen.PrimaryScreen.WorkingArea.Width - this.Width) / 2,
                                               (Screen.PrimaryScreen.WorkingArea.Height - this.Height) / 2);
        }
示例#9
0
    protected override void OnClick(DataGridViewCellEventArgs e)
    {
        List <InfoObject> objs = this.DataGridView.DataSource as List <InfoObject>;

        if (objs != null)
        {
            if (e.RowIndex >= 0 && e.RowIndex < objs.Count)
            {
                CustomUserControl ctrl = objs[e.RowIndex].Ctrl;
                // Take any action - I will just change the color for now.
                ctrl.BackColor = Color.Red;
                ctrl.Refresh();
                this.DataGridView.InvalidateCell(e.ColumnIndex, e.RowIndex);
            }
        }
    }
        private void frmSchedule_Load(object sender, EventArgs e)
        {
            string panelName       = "mainPanel";
            string userControlName = "ucSchedule";

            Control[] controls = this.Controls.Find(panelName, true);
            if (controls[0].Controls.Count > 0)
            {
                if (controls[0].Controls[0] is CustomUserControl)
                {
                    ((CustomUserControl)controls[0].Controls[0]).Dispose();
                }
            }

            CustomUserControl cu = (CustomUserControl)Loader.GetReferenceUserControl(userControlName);

            controls[0].Controls.Add(cu);
        }
        public static void AddToPanelWithParameters(Zone zone, Form frm, string userControlName, params string[] parameters)
        {
            string panelName = string.Empty;

            switch (zone)
            {
            case Zone.Left:
                panelName = "pnlLeft";
                break;

            case Zone.Middle:
                panelName = "pnlMiddle";
                break;

            case Zone.Right:
                panelName = "pnlRight";
                break;

            case Zone.Modal_Profile:
                panelName = "pnlProfiles";
                break;
            }

            panelName = panelName.ToLower();

            Control[] controls = frm.Controls.Find(panelName, true);
            if (controls[0].Controls.Count > 0)
            {
                if (controls[0].Controls[0] is CustomUserControl)
                {
                    ((CustomUserControl)controls[0].Controls[0]).Dispose();
                }
            }

            CustomUserControl cu = (CustomUserControl)Loader.GetReferenceUserControl(userControlName);

            cu.Parameters = parameters;
            controls[0].Controls.Add(cu);
        }
        public void SetUpFixture()
        {
            using (DesignSurface designSurface = new DesignSurface(typeof(Form))) {
                IDesignerHost        host = (IDesignerHost)designSurface.GetService(typeof(IDesignerHost));
                IEventBindingService eventBindingService = new MockEventBindingService(host);
                Form form = (Form)host.RootComponent;
                form.ClientSize = new Size(200, 300);

                PropertyDescriptorCollection descriptors            = TypeDescriptor.GetProperties(form);
                PropertyDescriptor           namePropertyDescriptor = descriptors.Find("Name", false);
                namePropertyDescriptor.SetValue(form, "MainForm");

                // Add custom control
                CustomUserControl userControl = (CustomUserControl)host.CreateComponent(typeof(CustomUserControl), "userControl1");
                userControl.Location   = new Point(0, 0);
                userControl.ClientSize = new Size(200, 100);

                DesignerSerializationManager  designerSerializationManager = new DesignerSerializationManager(host);
                IDesignerSerializationManager serializationManager         = (IDesignerSerializationManager)designerSerializationManager;
                using (designerSerializationManager.CreateSession()) {
                    FooItem fooItem = (FooItem)serializationManager.CreateInstance(typeof(FooItem), new object[] { "aa" }, "fooItem1", false);
                    userControl.FooItems.Add(fooItem);
                    fooItem = (FooItem)serializationManager.CreateInstance(typeof(FooItem), new object[] { "bb" }, "fooItem2", false);
                    userControl.FooItems.Add(fooItem);

                    BarItem barItem = (BarItem)serializationManager.CreateInstance(typeof(BarItem), new object[] { "cc" }, "barItem1", false);
                    userControl.ParentComponent.ParentBarItems.Add(barItem);
                    barItem = (BarItem)serializationManager.CreateInstance(typeof(BarItem), new object[] { "dd" }, "barItem2", false);
                    userControl.ParentComponent.ParentBarItems.Add(barItem);
                    form.Controls.Add(userControl);

                    PythonCodeDomSerializer serializer = new PythonCodeDomSerializer("    ");
                    generatedPythonCode = serializer.GenerateInitializeComponentMethodBody(host, serializationManager, String.Empty, 1);
                }
            }
        }
示例#13
0
 /// <summary>
 /// Initializes a new instance of the <see cref="InterJetFormHandler"/> class.
 /// </summary>
 /// <param name="userControl">The user control.</param>
 protected InterJetFormHandler(CustomUserControl userControl)
 {
     this.CurrentUserControl = userControl;
 }
        public static void AddToPanel(Zone zone, CustomUserControl uc, string userControlName)
        {
            Form frm = uc.ParentForm;

            AddToPanel(zone, frm, userControlName);
        }
        public static void AddToPanelWithParameters(Zone zone, CustomUserControl uc, string userControlName, params string[] parameters)
        {
            Form frm = uc.ParentForm;

            AddToPanelWithParameters(zone, frm, userControlName, parameters);
        }