public TableLayoutPanel ()
		{
			settings = new TableLayoutSettings(this);
			cell_border_style = TableLayoutPanelCellBorderStyle.None;
			column_widths = new int[0];
			row_heights = new int[0];
		}
 internal void ApplySettings(TableLayoutSettings settings)
 {
     if (settings.IsStub)
     {
         if (!this.IsStub)
         {
             settings._stub.ApplySettings(this);
         }
         else
         {
             this._stub = settings._stub;
         }
     }
 }
 public override object ConvertFrom(ITypeDescriptorContext context, CultureInfo culture, object value)
 {
     if (value is string)
     {
         XmlDocument document = new XmlDocument();
         document.LoadXml(value as string);
         TableLayoutSettings settings = new TableLayoutSettings();
         this.ParseControls(settings, document.GetElementsByTagName("Control"));
         this.ParseStyles(settings, document.GetElementsByTagName("Columns"), true);
         this.ParseStyles(settings, document.GetElementsByTagName("Rows"), false);
         return settings;
     }
     return base.ConvertFrom(context, culture, value);
 }
 private void SetControlInformation(object controlName, TableLayoutSettings.ControlInformation info)
 {
     if (this.controlsInfo == null)
     {
         this.controlsInfo = new Dictionary<object, TableLayoutSettings.ControlInformation>();
     }
     this.controlsInfo[controlName] = info;
 }
 internal void ApplySettings(TableLayoutSettings settings)
 {
     TableLayout.ContainerInfo containerInfo = TableLayout.GetContainerInfo(settings.Owner);
     Control container = containerInfo.Container as Control;
     if ((container != null) && (this.controlsInfo != null))
     {
         foreach (object obj2 in this.controlsInfo.Keys)
         {
             TableLayoutSettings.ControlInformation information = this.controlsInfo[obj2];
             foreach (Control control2 in container.Controls)
             {
                 if (control2 != null)
                 {
                     string str = null;
                     PropertyDescriptor descriptor = TypeDescriptor.GetProperties(control2)["Name"];
                     if ((descriptor != null) && (descriptor.PropertyType == typeof(string)))
                     {
                         str = descriptor.GetValue(control2) as string;
                     }
                     if (WindowsFormsUtils.SafeCompareStrings(str, obj2 as string, false))
                     {
                         settings.SetRow(control2, information.Row);
                         settings.SetColumn(control2, information.Column);
                         settings.SetRowSpan(control2, information.RowSpan);
                         settings.SetColumnSpan(control2, information.ColumnSpan);
                         break;
                     }
                 }
             }
         }
     }
     containerInfo.RowStyles = this.rowStyles;
     containerInfo.ColumnStyles = this.columnStyles;
     this.columnStyles = null;
     this.rowStyles = null;
     this.isValid = false;
 }
 public TableLayoutPanel()
 {
     this._tableLayoutSettings = TableLayout.CreateSettings(this);
 }
            /// <devdoc> ApplySettings - applies settings from the stub into a full-fledged
            ///          TableLayoutSettings.
            ///
            ///          NOTE: this is a one-time only operation - there is data loss to the stub
            ///          as a result of calling this function. we hand as much over to the other guy
            ///          so we dont have to reallocate anything
            /// </devdoc>
            internal void ApplySettings(TableLayoutSettings settings) {
                //
                // apply row,column,rowspan,colspan
                //
                TableLayout.ContainerInfo containerInfo = TableLayout.GetContainerInfo(settings.Owner);
                Control appliedControl = containerInfo.Container as Control;
                if (appliedControl != null && controlsInfo != null) {

                    // we store the control names, look up the controls 
                    // in the appliedControl's control collection and apply the row,column settings.
                    foreach (object controlName in controlsInfo.Keys){
                        ControlInformation controlInfo = controlsInfo[controlName];

                        // Look for the control in our table, we have to go through
                        // PropertyDescriptor rather than just going using appliedControl.Controls[controlName]
                        // because the Name property is shadowed at design time
                        foreach (Control tableControl in appliedControl.Controls) {
                            if (tableControl != null) {
                                string name = null;
                                PropertyDescriptor prop = TypeDescriptor.GetProperties(tableControl)["Name"];
                                if (prop != null && prop.PropertyType == typeof(string)) {
                                    name = prop.GetValue(tableControl) as string;
                                }
                                else {
                                    Debug.Fail("Name property missing on control");
                                }
                                if (WindowsFormsUtils.SafeCompareStrings(name, controlName as string, /* ignoreCase = */ false)) {
                                    settings.SetRow(tableControl, controlInfo.Row);
                                    settings.SetColumn(tableControl, controlInfo.Column);
                                    settings.SetRowSpan(tableControl, controlInfo.RowSpan);
                                    settings.SetColumnSpan(tableControl, controlInfo.ColumnSpan);
                                    break;
                                }
                            }
                        }
                    }
                }

                //
                // assign over the row and column styles
                // 
                containerInfo.RowStyles = rowStyles;
                containerInfo.ColumnStyles = columnStyles;

                // since we've given over the styles to the other guy, null out.
                columnStyles = null;
                rowStyles = null;

                // set a flag for assertion detection.
                isValid = false;
                
            }
 internal void ApplySettings(TableLayoutSettings settings) {
     if (settings.IsStub) {
         if (!IsStub) {
            // we're the real-live thing here, gotta walk through and touch controls
            settings._stub.ApplySettings(this);
         }
         else {
            // we're just copying another stub into us, just replace the member
            _stub = settings._stub;
         }
     }
    
 }
Exemple #9
0
 /// <include file='doc\TableLayoutPanel.uex' path='docs/doc[@for="TableLayoutPanel.TableLayoutPanel"]/*' />
 public TableLayoutPanel()
 {
     _tableLayoutSettings = TableLayout.CreateSettings(this);
 }
			public TestRow(TableLayoutSettings settings, String xmlContent, String name, Directions directions)
			{
				this.Name = name;
				this.Settings = settings;
				this.XmlContent = xmlContent;
				this.Directions = directions;
			}
 private void ParseStyles(TableLayoutSettings settings, XmlNodeList controlXmlFragments, bool columns)
 {
     foreach (XmlNode node in controlXmlFragments)
     {
         string attributeValue = this.GetAttributeValue(node, "Styles");
         System.Type enumType = typeof(SizeType);
         if (!string.IsNullOrEmpty(attributeValue))
         {
             int num2;
             for (int i = 0; i < attributeValue.Length; i = num2)
             {
                 float num3;
                 num2 = i;
                 while (char.IsLetter(attributeValue[num2]))
                 {
                     num2++;
                 }
                 SizeType sizeType = (SizeType) Enum.Parse(enumType, attributeValue.Substring(i, num2 - i), true);
                 while (!char.IsDigit(attributeValue[num2]))
                 {
                     num2++;
                 }
                 StringBuilder builder = new StringBuilder();
                 while ((num2 < attributeValue.Length) && char.IsDigit(attributeValue[num2]))
                 {
                     builder.Append(attributeValue[num2]);
                     num2++;
                 }
                 builder.Append('.');
                 while ((num2 < attributeValue.Length) && !char.IsLetter(attributeValue[num2]))
                 {
                     if (char.IsDigit(attributeValue[num2]))
                     {
                         builder.Append(attributeValue[num2]);
                     }
                     num2++;
                 }
                 if (!float.TryParse(builder.ToString(), NumberStyles.Float, (IFormatProvider) CultureInfo.InvariantCulture.NumberFormat, out num3))
                 {
                     num3 = 0f;
                 }
                 if (columns)
                 {
                     settings.ColumnStyles.Add(new ColumnStyle(sizeType, num3));
                 }
                 else
                 {
                     settings.RowStyles.Add(new RowStyle(sizeType, num3));
                 }
             }
         }
     }
 }
 private void ParseControls(TableLayoutSettings settings, XmlNodeList controlXmlFragments)
 {
     foreach (XmlNode node in controlXmlFragments)
     {
         string attributeValue = this.GetAttributeValue(node, "Name");
         if (!string.IsNullOrEmpty(attributeValue))
         {
             int row = this.GetAttributeValue(node, "Row", -1);
             int num2 = this.GetAttributeValue(node, "RowSpan", 1);
             int column = this.GetAttributeValue(node, "Column", -1);
             int num4 = this.GetAttributeValue(node, "ColumnSpan", 1);
             settings.SetRow(attributeValue, row);
             settings.SetColumn(attributeValue, column);
             settings.SetRowSpan(attributeValue, num2);
             settings.SetColumnSpan(attributeValue, num4);
         }
     }
 }
Exemple #13
0
        // This utility method initializes the TableLayoutPanel
        // which contains the ToolStripButton controls.
        private void InitializeTableLayoutSettings()
        {
            // Specify the numbers of rows and columns in the GridStrip control.
            this.tableSettings = base.LayoutSettings as TableLayoutSettings;
            this.tableSettings.ColumnCount = this.rows;
            this.tableSettings.RowCount = this.columns;

            // Create a dummy bitmap with the dimensions of each tile.
            // The GridStrip control sizes itself based on these dimensions.
            Bitmap b = new Bitmap(tileSize.Width, tileSize.Height);

            // Populate the GridStrip control with ToolStripButton controls.
            for (int i = 0; i < this.tableSettings.ColumnCount; i++)
            {
                for (int j = 0; j < this.tableSettings.RowCount; j++)
                {
                    // Create a new ToolStripButton control.
                    ToolStripButton btn = new ToolStripButton();
                    btn.DisplayStyle = ToolStripItemDisplayStyle.Image;
                    btn.Image = b;
                    btn.ImageAlign = ContentAlignment.MiddleCenter;
                    btn.ImageScaling = ToolStripItemImageScaling.None;
                    btn.Margin = Padding.Empty;
                    btn.Padding = Padding.Empty;

                    // Add the new ToolStripButton control to the GridStrip.
                    this.Items.Add(btn);

                    // Set the cell position of the ToolStripButton control.
                    TableLayoutPanelCellPosition cellPos = new TableLayoutPanelCellPosition(i, j);
                    this.tableSettings.SetCellPosition(btn, cellPos);

                    // If this is the ToolStripButton control at cell (0,0),
                    // assign it as the empty cell button.
                    if (i == 0 && j == 0)
                    {
                        btn.Text = "Empty Cell";
                        btn.Image = b;
                        this.emptyCellButton = btn;
                    }
                }
            }
        }
Exemple #14
0
        /// <devdoc>
        /// Override this function if you want to do custom table layouts for the
        /// StatusStrip.  The default layoutstyle is tablelayout, and we need to play
        /// with the row/column styles
        /// </devdoc>
        protected virtual void OnSpringTableLayoutCore()
        {
            if (this.LayoutStyle == ToolStripLayoutStyle.Table)
            {
                state[stateCalledSpringTableLayout] = true;

                this.SuspendLayout();

                if (lastOrientation != Orientation)
                {
                    TableLayoutSettings settings = this.TableLayoutSettings;
                    settings.RowCount    = 0;
                    settings.ColumnCount = 0;
                    settings.ColumnStyles.Clear();
                    settings.RowStyles.Clear();
                }
                lastOrientation = Orientation;

                if (Orientation == Orientation.Horizontal)
                {
                    //
                    // Horizontal layout
                    //
                    TableLayoutSettings.GrowStyle = TableLayoutPanelGrowStyle.AddColumns;

                    int originalColumnCount = this.TableLayoutSettings.ColumnStyles.Count;

                    // iterate through the elements which are going to be displayed.
                    for (int i = 0; i < this.DisplayedItems.Count; i++)
                    {
                        if (i >= originalColumnCount)
                        {
                            // add if it's necessary.
                            this.TableLayoutSettings.ColumnStyles.Add(new ColumnStyle());
                        }

                        // determine if we "spring" or "autosize" the column
                        ToolStripStatusLabel panel = DisplayedItems[i] as ToolStripStatusLabel;
                        bool spring = (panel != null && panel.Spring);
                        DisplayedItems[i].Anchor = (spring) ? AllAnchor : VerticalAnchor;

                        // spring is achieved by using 100% as the column style
                        ColumnStyle colStyle = this.TableLayoutSettings.ColumnStyles[i];
                        colStyle.Width    = 100; // this width is ignored in AutoSize.
                        colStyle.SizeType = (spring) ? SizeType.Percent : SizeType.AutoSize;
                    }

                    if (TableLayoutSettings.RowStyles.Count > 1 || TableLayoutSettings.RowStyles.Count == 0)
                    {
                        TableLayoutSettings.RowStyles.Clear();
                        TableLayoutSettings.RowStyles.Add(new RowStyle());
                    }
                    TableLayoutSettings.RowCount = 1;

                    TableLayoutSettings.RowStyles[0].SizeType = SizeType.Absolute;
                    TableLayoutSettings.RowStyles[0].Height   = Math.Max(0, this.DisplayRectangle.Height);
                    TableLayoutSettings.ColumnCount           = DisplayedItems.Count + 1; // add an extra cell so it fills the remaining space

                    // dont remove the extra column styles, just set them back to autosize.
                    for (int i = DisplayedItems.Count; i < TableLayoutSettings.ColumnStyles.Count; i++)
                    {
                        this.TableLayoutSettings.ColumnStyles[i].SizeType = SizeType.AutoSize;
                    }
                }
                else
                {
                    //
                    // Vertical layout
                    //

                    TableLayoutSettings.GrowStyle = TableLayoutPanelGrowStyle.AddRows;

                    int originalRowCount = this.TableLayoutSettings.RowStyles.Count;

                    // iterate through the elements which are going to be displayed.
                    for (int i = 0; i < this.DisplayedItems.Count; i++)
                    {
                        if (i >= originalRowCount)
                        {
                            // add if it's necessary.
                            this.TableLayoutSettings.RowStyles.Add(new RowStyle());
                        }

                        // determine if we "spring" or "autosize" the row
                        ToolStripStatusLabel panel = DisplayedItems[i] as ToolStripStatusLabel;
                        bool spring = (panel != null && panel.Spring);
                        DisplayedItems[i].Anchor = (spring) ? AllAnchor : HorizontalAnchor;

                        // spring is achieved by using 100% as the row style
                        RowStyle rowStyle = this.TableLayoutSettings.RowStyles[i];
                        rowStyle.Height   = 100; // this width is ignored in AutoSize.
                        rowStyle.SizeType = (spring) ? SizeType.Percent : SizeType.AutoSize;
                    }
                    TableLayoutSettings.ColumnCount = 1;

                    if (TableLayoutSettings.ColumnStyles.Count > 1 || TableLayoutSettings.ColumnStyles.Count == 0)
                    {
                        TableLayoutSettings.ColumnStyles.Clear();
                        TableLayoutSettings.ColumnStyles.Add(new ColumnStyle());
                    }

                    TableLayoutSettings.ColumnCount = 1;
                    TableLayoutSettings.ColumnStyles[0].SizeType = SizeType.Absolute;
                    TableLayoutSettings.ColumnStyles[0].Width    = Math.Max(0, this.DisplayRectangle.Width);

                    TableLayoutSettings.RowCount = DisplayedItems.Count + 1; // add an extra cell so it fills the remaining space

                    // dont remove the extra column styles, just set them back to autosize.
                    for (int i = DisplayedItems.Count; i < TableLayoutSettings.RowStyles.Count; i++)
                    {
                        this.TableLayoutSettings.RowStyles[i].SizeType = SizeType.AutoSize;
                    }
                }

                this.ResumeLayout(false);
            }
        }
Exemple #15
0
        // Create the drop-down, subscribe to the events we care about.
        void CreateDropdown(int columns)
        {
            // Create a new dropdown.
            dropdown = new ToolStripDropDown();
            dropdown.LayoutStyle = ToolStripLayoutStyle.Table;
            dropdown.ShowItemToolTips = false;
            tableLayoutSettings = (TableLayoutSettings)(dropdown.LayoutSettings);
            tableLayoutSettings.ColumnCount = columns;

            // Subscribe to events on the dropdown.
            dropdown.Opened += OpenedDropdown;
            dropdown.Closed += ClosedDropdown;
            dropdown.LayoutCompleted += LayoutCompleted;
            dropdown.ItemClicked += ItemClicked;
        }
Exemple #16
0
        // If the current dropdown still exists, dispose it and null out variables.
        private void DisposeCurrentDropdown()
        {
            if (dropdown != null) {
                dropdown.Close();
                // We are getting occasional crash reports with drop downs being disposed. Removing this call
                // to see if they go away.
                //dropdown.Dispose();
                dropdown = null;
            }

            infoLabel = null;
            tableLayoutSettings = null;
            textbox = null;
            separator = null;
        }
		//--------
		static void Assert_AreEqual(TableLayoutSettings expected, TableLayoutSettings actual, String message)
		{
			Assert_AreEqual(expected.ColumnStyles, actual.ColumnStyles, "ColumnStyles -- " + message);
			Assert_AreEqual(expected.RowStyles, actual.RowStyles, "RowStyles -- " + message);
		}