Exemplo n.º 1
0
            /// <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;
                                }

                                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;
            }
Exemplo n.º 2
0
		internal TableLayoutSettings (TableLayoutPanel panel)
		{
			this.column_styles = new TableLayoutColumnStyleCollection (panel);
			this.row_styles = new TableLayoutRowStyleCollection (panel);
			this.grow_style = TableLayoutPanelGrowStyle.AddRows;
			this.column_count = 0;
			this.row_count = 0;
			this.columns = new Dictionary<object, int> ();
			this.column_spans = new Dictionary<object, int> ();
			this.rows = new Dictionary<object, int> ();
			this.row_spans = new Dictionary<object, int> ();
			this.panel = panel;
		}
 internal TableLayoutSettings(IArrangedContainer panel)
 {
     this.column_styles = new TableLayoutColumnStyleCollection(panel);
     this.row_styles    = new TableLayoutRowStyleCollection(panel);
     this.grow_style    = TableLayoutPanelGrowStyle.AddRows;
     this.column_count  = 0;
     this.row_count     = 0;
     this.columns       = new Dictionary <object, int> ();
     this.column_spans  = new Dictionary <object, int> ();
     this.rows          = new Dictionary <object, int> ();
     this.row_spans     = new Dictionary <object, int> ();
     this.panel         = panel;
 }
Exemplo n.º 4
0
        public Main()
        {
            InitializeComponent();

            // Load options from Options.FILENAME file
            // If the file doesn't exist, or broken, options will be Default
            options = Options.getOption();

            // Initialize some other controls might depends on options
            InitializeOtherControls();

            InitDrawingComponent();
            InitEventAnnoComponent();

            //Load images to imageList
            //loadImages();

            //comboBox1.SelectedIndex = 0;
            //Just for sample GUI test
            setMinimumFrameTrackBar(0);
            setMaximumFrameTrackBar(100);

            previousSize = this.Size;
            rowStyles = annotateTableLayoutPanel.RowStyles;
            columnStyles = annotateTableLayoutPanel.ColumnStyles;

            originalRowStyles = new RowStyle[rowStyles.Count];
            originalColumnStyles = new ColumnStyle[columnStyles.Count];

            for (int i = 0; i < rowStyles.Count; i++)
            {
                originalRowStyles[i] = new RowStyle(rowStyles[i].SizeType, rowStyles[i].Height);
            }

            for (int i = 0; i < columnStyles.Count; i++)
            {
                originalColumnStyles[i] = new ColumnStyle(columnStyles[i].SizeType, columnStyles[i].Width);
            }

            for (int i = 0; i < rowStyles.Count; i++)
            {
                Console.WriteLine("Row " + i + " " + annotateTableLayoutPanel.GetRowHeights()[i]);
            }

            for (int i = 0; i < columnStyles.Count; i++)
            {
                Console.WriteLine("Column " + i + " " + annotateTableLayoutPanel.GetColumnWidths()[i]);
            }

            Thread.CurrentThread.CurrentCulture = CultureInfo.GetCultureInfo("en-US");
        }
Exemplo n.º 5
0
		private TableLayoutSettings (SerializationInfo serializationInfo, StreamingContext context)
		{
			TypeConverter converter = TypeDescriptor.GetConverter (this);
			string text = serializationInfo.GetString ("SerializedString");
			if (!string.IsNullOrEmpty (text) && (converter != null)) {
				TableLayoutSettings settings = converter.ConvertFromInvariantString (text) as TableLayoutSettings;
				this.column_styles = settings.column_styles;
				this.row_styles = settings.row_styles;
				this.grow_style = settings.grow_style;
				this.column_count = settings.column_count;
				this.row_count = settings.row_count;
				this.columns = settings.columns;
				this.column_spans = settings.column_spans;
				this.rows = settings.rows;
				this.row_spans = settings.row_spans;
				this.panel = settings.panel;
				this.isSerialized = true;
			}
		}
        private TableLayoutSettings(SerializationInfo serializationInfo, StreamingContext context)
        {
            TypeConverter converter = TypeDescriptor.GetConverter(this);
            string        text      = serializationInfo.GetString("SerializedString");

            if (!string.IsNullOrEmpty(text) && (converter != null))
            {
                TableLayoutSettings settings = converter.ConvertFromInvariantString(text) as TableLayoutSettings;
                this.column_styles = settings.column_styles;
                this.row_styles    = settings.row_styles;
                this.grow_style    = settings.grow_style;
                this.column_count  = settings.column_count;
                this.row_count     = settings.row_count;
                this.columns       = settings.columns;
                this.column_spans  = settings.column_spans;
                this.rows          = settings.rows;
                this.row_spans     = settings.row_spans;
                this.panel         = settings.panel;
                this.isSerialized  = true;
            }
        }
 internal TableLayoutSettings(IArrangedContainer panel, TableLayoutSettings settings)
 {
     this.column_styles = new TableLayoutColumnStyleCollection(panel);
     this.row_styles    = new TableLayoutRowStyleCollection(panel);
     this.grow_style    = settings.grow_style;
     this.column_count  = settings.column_count;
     this.row_count     = settings.row_count;
     this.columns       = new Dictionary <object, int> (settings.columns);
     this.column_spans  = new Dictionary <object, int> (settings.column_spans);
     this.rows          = new Dictionary <object, int> (settings.rows);
     this.row_spans     = new Dictionary <object, int> (settings.row_spans);
     this.panel         = panel;
     foreach (ColumnStyle column_style in settings.column_styles)
     {
         this.column_styles.Add(new ColumnStyle(column_style.SizeType, column_style.Width));
     }
     foreach (RowStyle row_style in settings.row_styles)
     {
         this.row_styles.Add(new RowStyle(row_style.SizeType, row_style.Height));
     }
 }
Exemplo n.º 8
0
            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;
            }
 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;
 }
            /// <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;
                
            }
		static void Assert_AreEqual(TableLayoutRowStyleCollection expected, TableLayoutRowStyleCollection actual, String message)
		{
			for (int i = 0; i < Math.Min(expected.Count, actual.Count); ++i) {
				RowStyle expectedCur = expected[i];
				RowStyle actualCur = actual[i];
				Assert_AreEqual(expectedCur, actualCur, "TableLayoutRowStyleCollection[" + i + "] -- " + message);
			}
			// Check this *after*, so that if the initial values in the lists don't match 
			// that's reported instead -- it makes it more obvious what is being mis-parsed.
			Assert.AreEqual(expected.Count, actual.Count, "TableLayoutRowStyleCollection.Count -- " + message);
		}
Exemplo n.º 12
0
 public ContainerInfo(ContainerInfo containerInfo) {
     _cellBorderWidth = containerInfo.CellBorderWidth;
     _maxRows = containerInfo.MaxRows;
     _maxColumns = containerInfo.MaxColumns;
     _growStyle = containerInfo.GrowStyle;
     _container = containerInfo.Container;
     _rowStyles = containerInfo.RowStyles;
     _colStyles = containerInfo.ColumnStyles;
 }
Exemplo n.º 13
0
 private void annotateTableLayoutPanel_MouseDown(object sender, MouseEventArgs e)
 {
     if (e.Button == System.Windows.Forms.MouseButtons.Left)
     {
         rowStyles = annotateTableLayoutPanel.RowStyles;
         columnStyles = annotateTableLayoutPanel.ColumnStyles;
         resizing = true;
     }
 }
Exemplo n.º 14
0
        private void EditCount_TextChanged(object sender, EventArgs e)
        {
            if (XLayoutPanel.Controls.Count != 0)
            {
                XLayoutPanel.Controls.Clear();
                YLayoutPanel.Controls.Clear();
                ZLayoutPanel.Controls.Clear();
                WLayoutPanel.Controls.Clear();
            }

            int size;
            try
            {
                size = int.Parse(EditCount.Text);
            }
            catch(Exception)
            {
                return;
            }

            for (int i = 0; i < size; i++)
            {
                TextBox Xtext = new TextBox();
                TextBox Ytext = new TextBox();
                TextBox Ztext = new TextBox();
                TextBox Wtext = new TextBox();

                Xtext.Text = 0.ToString();
                Xtext.TextAlign = HorizontalAlignment.Center;
                Ytext.Text = 0.ToString();
                Ytext.TextAlign = HorizontalAlignment.Center;
                Ztext.Text = 0.ToString();
                Ztext.TextAlign = HorizontalAlignment.Center;
                Wtext.Text = 1.ToString();
                Wtext.TextAlign = HorizontalAlignment.Center;

                XLayoutPanel.Controls.Add(Xtext);
                YLayoutPanel.Controls.Add(Ytext);
                ZLayoutPanel.Controls.Add(Ztext);
                WLayoutPanel.Controls.Add(Wtext);
            }

            TableLayoutRowStyleCollection[] styles = new TableLayoutRowStyleCollection[4];
            styles[0] = XLayoutPanel.RowStyles;
            styles[1] = YLayoutPanel.RowStyles;
            styles[2] = ZLayoutPanel.RowStyles;
            styles[3] = WLayoutPanel.RowStyles;

            for (int i = 0; i < 4; i++)
            {
                foreach(RowStyle style in styles[i])
                {
                    style.SizeType = SizeType.Percent;
                    style.Height = 1.0f / size;
                }
            }
        }