123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135 |
- #region Using directives
- using System;
- using System.Windows.Forms;
- #endregion
- namespace WinHtmlEditor
- {
-
-
-
-
- internal partial class TablePropertyForm : Form
- {
-
- private HtmlTableProperty tableProperties;
-
- private const byte MAXIMUM_CELL_ROW = 250;
- private const byte MAXIMUM_CELL_COL = 50;
- private const byte MAXIMUM_CELL_PAD = 25;
- private const byte MAXIMUM_BORDER = 25;
- private const ushort MAXIMUM_WIDTH_PERCENT = 100;
- private const ushort MAXIMUM_WIDTH_PIXEL = 2500;
- private const ushort WIDTH_INC_DIV = 20;
-
-
-
- public TablePropertyForm()
- {
-
-
-
- InitializeComponent();
-
- this.listCaptionAlignment.Items.AddRange(Enum.GetNames(typeof(HorizontalAlignOption)));
- this.listCaptionLocation.Items.AddRange(Enum.GetNames(typeof(VerticalAlignOption)));
- this.listTextAlignment.Items.AddRange(Enum.GetNames(typeof(HorizontalAlignOption)));
-
- this.listCaptionAlignment.SelectedIndex = 0;
- this.listCaptionLocation.SelectedIndex = 0;
- this.listTextAlignment.SelectedIndex = 0;
-
- this.numericBorderSize.Maximum = MAXIMUM_BORDER;
- this.numericCellPadding.Maximum = MAXIMUM_CELL_PAD;
- this.numericCellSpacing.Maximum = MAXIMUM_CELL_PAD;
- this.numericRows.Maximum = MAXIMUM_CELL_ROW;
- this.numericColumns.Maximum = MAXIMUM_CELL_COL;
- this.numericTableWidth.Maximum = MAXIMUM_WIDTH_PIXEL;
-
- this.TableProperties = new HtmlTableProperty(true);
-
- }
-
-
-
-
-
- public HtmlTableProperty TableProperties
- {
- get
- {
-
- tableProperties.CaptionText = this.textTableCaption.Text;
- tableProperties.CaptionAlignment = (HorizontalAlignOption)this.listCaptionAlignment.SelectedIndex;
- tableProperties.CaptionLocation = (VerticalAlignOption)this.listCaptionLocation.SelectedIndex;
-
- tableProperties.BorderSize = (byte)Math.Min(this.numericBorderSize.Value, this.numericBorderSize.Maximum);
- tableProperties.TableAlignment = (HorizontalAlignOption)this.listTextAlignment.SelectedIndex;
-
- tableProperties.TableRows = (byte)Math.Min(this.numericRows.Value, this.numericRows.Maximum);
- tableProperties.TableColumns = (byte)Math.Min(this.numericColumns.Value, this.numericColumns.Maximum);
- tableProperties.CellPadding = (byte)Math.Min(this.numericCellPadding.Value, this.numericCellPadding.Maximum);
- tableProperties.CellSpacing = (byte)Math.Min(this.numericCellSpacing.Value, this.numericCellSpacing.Maximum);
- tableProperties.TableWidth = (ushort)Math.Min(this.numericTableWidth.Value, this.numericTableWidth.Maximum);
- tableProperties.TableWidthMeasurement = (this.radioWidthPercent.Checked) ? MeasurementOption.Percent : MeasurementOption.Pixel;
-
- return tableProperties;
- }
- set
- {
-
- tableProperties = value;
-
- this.textTableCaption.Text = tableProperties.CaptionText;
- this.listCaptionAlignment.SelectedIndex = (int)tableProperties.CaptionAlignment;
- this.listCaptionLocation.SelectedIndex = (int)tableProperties.CaptionLocation;
-
- this.numericBorderSize.Value = Math.Min(tableProperties.BorderSize, MAXIMUM_BORDER);
- this.listTextAlignment.SelectedIndex = (int)tableProperties.TableAlignment;
-
- this.numericRows.Value = Math.Min(tableProperties.TableRows, MAXIMUM_CELL_ROW);
- this.numericColumns.Value = Math.Min(tableProperties.TableColumns, MAXIMUM_CELL_COL);
- this.numericCellPadding.Value = Math.Min(tableProperties.CellPadding, MAXIMUM_CELL_PAD);
- this.numericCellSpacing.Value = Math.Min(tableProperties.CellSpacing, MAXIMUM_CELL_PAD);
- this.radioWidthPercent.Checked = (tableProperties.TableWidthMeasurement == MeasurementOption.Percent);
- this.radioWidthPixel.Checked = (tableProperties.TableWidthMeasurement == MeasurementOption.Pixel);
- this.numericTableWidth.Value = Math.Min(tableProperties.TableWidth, this.numericTableWidth.Maximum);
- }
- }
-
-
-
- private void MeasurementOptionChanged(object sender, System.EventArgs e)
- {
-
- if (this.radioWidthPercent.Checked)
- {
- this.numericTableWidth.Maximum = MAXIMUM_WIDTH_PERCENT;
- this.numericTableWidth.Increment = MAXIMUM_WIDTH_PERCENT / WIDTH_INC_DIV;
- }
-
- if (this.radioWidthPixel.Checked)
- {
- this.numericTableWidth.Maximum = MAXIMUM_WIDTH_PIXEL;
- this.numericTableWidth.Increment = MAXIMUM_WIDTH_PIXEL / WIDTH_INC_DIV;
- }
- }
- }
- }
|