/// <summary> /// Initializes a new instance of the <see cref="Table"/> class. Uses the /// <see cref="TableStyle"/> value provided. Allows the user to define which <see cref="BorderStyle"/> /// value to use, which <see cref="CellStyle"/> to use, which <see cref="Shapes.ShadeVertices"/> /// method to use and which <see cref="ColorArray"/> too use. /// </summary> /// <param name="id">The id.</param> /// <param name="rowCount">The row count.</param> /// <param name="columnCount">The column count.</param> /// <param name="position">The position.</param> /// <param name="cellStyle">The cell style.</param> /// <param name="tableStyle">The style.</param> /// <param name="cellBorders">The cell borders.</param> /// <param name="shadeMode">The shade mode.</param> /// <param name="colorArray">The color array.</param> public Table(string id, int rowCount, int columnCount, Vector2 position, BorderStyle borderStyle, TableStyle tableStyle, CellStyle cellStyle, Shapes.ShadingMode shadeMode, ColorArray colorArray) : base(id, position, ComputeStandardSize(DefaultBorderSize, rowCount, columnCount, tableStyle), Shape.Custom, borderStyle, shadeMode, colorArray) { this.rowCount = rowCount; this.columnCount = columnCount; style = tableStyle; cells = new Cell[rowCount, columnCount]; applyStatusChanges = false; for (int r = 0; r < rowCount; r++) { for (int c = 0; c < columnCount; c++) { Cell cell = new Cell(id + string.Format("_Cell:R{0}C{1}", r.ToString("00"), c.ToString("00")), CellPosition(r, c), new Size(tableStyle.ColumnWidth, tableStyle.RowHeight), BorderStyle.Flat, cellStyle, Shapes.ShadeNone, defaultColors ); cells[r, c] = cell; Add(cell); } } }
public CheckBox(string id, string text, Vector2 position, Color labelColor, Shape shape, Shapes.ShadingMode shadeMode) : base(id, position, Size.Empty, shape, BorderStyle.Raised, shadeMode, defaultColors) { Vector2 labelPosition = new Vector2(DefaultCheckBoxLabelOffset, 0); label = new Label(id + "_Label", text, LabelSize.Small, Alignment.Left, Alignment.Top, labelPosition, labelColor); // Compute individual size areas Size checkBoxSize = new Size(DefaultCheckBoxSize, DefaultCheckBoxSize); Size labelSize = label.Area.Size; // Compute total size size = new Size(checkBoxSize.Width + DefaultCheckOffset + labelSize.Width, checkBoxSize.Height); checkTopLeftPosition = new Vector2(DefaultCheckOffset, DefaultCheckBoxSize / 2); checkBottomPosition = new Vector2(DefaultCheckBoxSize / 2, DefaultCheckBoxSize - DefaultCheckOffset); checkTopRightPosition = new Vector2(DefaultCheckBoxSize - DefaultCheckOffset, DefaultCheckOffset); IsFocusable = false; }
public OptionButton(string id, int index, string text, Vector2 position, Size size, Shape shape, Shapes.ShadingMode shadeMode) : base(id, position, size, shape, BorderStyle.Flat, shadeMode, defaultColors) { center = new Vector2(position.X + DefaultOptionButtonOutlineRadius, position.Y + DefaultOptionButtonOutlineRadius); Vector2 labelPosition = new Vector2(DefaultOptionButtonLabelOffset, position.Y ); radius = DefaultOptionButtonSelectedRadius; outlineRadius = DefaultOptionButtonOutlineRadius; slices = DefaultOptionButtonSlices; borderSize = DefaultOptionButtonSize; optionIndex = index; label = new Label(id + "_Label", text, LabelSize.Small, Alignment.Left, Alignment.Top, labelPosition, Label.DefaultColor); }
public TextBox(string id, Vector2 position, Size size, int fontSize, Color labelColor, Shape shape, Shapes.ShadingMode shadeMode, ColorArray colorArray) : base(id, position, size, shape, BorderStyle.Sunken, shadeMode, colorArray) { borderStyle = BorderStyle.Sunken; textLabel = new Label(id + "_textLabel", string.Empty, fontSize, Alignment.Left, Alignment.Top, new Vector2(DefaultTextBoxLabelOffset, DefaultTextBoxLabelOffset), labelColor); textBoxInnerWidth = size.Width - 2 * DefaultTextBoxLabelOffset; }
public ContainerControl(string id, Vector2 location, Size size, Shape shape, BorderStyle style, Shapes.ShadingMode shadeMode, ColorArray colorArray) : base(id, location, size, shape, style, shadeMode, colorArray) { controls = new ControlCollection(this); internalControls = new ControlCollection(this); isFocusable = false; applyStatusChanges = false; }
public Cell(string id, Vector2 position, Size size, BorderStyle borderStyle, CellStyle cellStyle, Shapes.ShadingMode shadeMode, ColorArray colorArray) : base(id, position, size, Shape.Rectangle, borderStyle, shadeMode, colorArray) { style = cellStyle; textLabel = new Label(id + "_Label", string.Empty, new Vector2(style.PaddingLeft, style.PaddingTop), style.TextStyle); textLabel.Parent = this; applyStatusChanges = false; shapeDescriptors = new ShapeDescriptor[1]; }
/// <summary> /// Initializes a new instance of the <see cref="RenderableControl"/> class. /// </summary> /// <param name="id">The id.</param> /// <param name="position">The position.</param> /// <param name="size">The size.</param> /// <param name="shape">The shape.</param> /// <param name="style">The style.</param> /// <param name="shadeMode">The shading method to use.</param> /// <param name="colorArray">The color array.</param> public RenderableControl(string id, Vector2 position, Size size, Shape shape, BorderStyle style, Shapes.ShadingMode shadeMode, ColorArray colorArray) : base(id, position, size) { this.shape = shape; borderStyle = style; this.colorArray = colorArray; shadingMode = shadeMode; innerAreaColor = colorArray.Enabled; borderColor = colorArray.BorderEnabled; }
public Panel(string id, Vector2 location, Size size, Shape shape, BorderStyle style, Shapes.ShadingMode shadeMode, ColorArray colorArray) : base(id, location, size, shape, style, shadeMode, colorArray) { }
public DefaultShapeControl(string id, Vector2 position, Size size, Shape shape, BorderStyle style, Shapes.ShadingMode shadeMode, ColorArray colorArray) : base(id, position, size, shape, style, shadeMode, colorArray) { shapeDescriptors = new ShapeDescriptor[1]; }
/// <summary> /// Creates a button control /// </summary> /// <param name="id">Id of the control</param> /// <param name="text">String to be displayed</param> /// <param name="position">Position vector in screen coordinates</param> /// <param name="size">Size of the control</param> /// <param name="shape">Shape of the control</param> /// <param name="colorArray">Color array to be used</param> public Button(string id, string text, Vector2 position, Size size, Shape shape, Shapes.ShadingMode shadeMode, ColorArray colorArray) : base(id, position, size, shape, BorderStyle.Raised, shadeMode, colorArray) { Vector2 labelPosition; switch (shape) { default: case Shape.Rectangle: case Shape.RightTrapezoidDownside: case Shape.RightTrapezoidUpside: labelPosition = Vector2.Empty; break; case Shape.LeftTrapezoidDownside: case Shape.LeftTrapezoidUpside: labelPosition = new Vector2(TabPanel.DefaultTabTriangleWidth, 0); break; } label = new Label(id + "_Label", text, LabelSize.Normal, Alignment.Center, Alignment.Center, labelPosition, RenderableControls.Label.DefaultColor ); label.Outline = true; label.OutlineColor = Color.Black; IsFocusable = false; }
/// <summary> /// Allows user to specify every parameter. /// </summary> /// <param name="id"></param> /// <param name="optionList"></param> /// <param name="position"></param> /// <param name="size"></param> /// <param name="boxColors"></param> /// <param name="buttonColors"></param> /// <param name="labelEnabled"></param> /// <param name="labelHighlighted"></param> /// <param name="style"></param> public DropDownList(string id, string[] optionList, Vector2 position, Size size, BorderStyle style, Color labelEnabled, Color labelHighlighted, Shapes.ShadingMode shadeMode, ColorArray boxColors, ColorArray buttonColors) : base(id, position, size, Shape.Custom, style, shadeMode, boxColors) { applyStatusChanges = true; isFocusable = true; shapeDescriptors = new ShapeDescriptor[1]; // In the future a constructor will allow to specify the size of the font used in the control fontSize = StyleManager.NormalFontSize; // Define sub-parts sizes boxSize = new Size(size.Width - DropDownButton.DefaultDropDownButtonWidth + DefaultBorderSize, size.Height); dropDownButtonSize = new Size(DropDownButton.DefaultDropDownButtonWidth, DropDownButton.DefaultDropDownButtonHeight); itemSize = new Size(size.Width, fontSize + DefaultListLabelOffsetY); // Define sub-parts relative positions dropDownButtonPosition = new Vector2(boxSize.Width - DefaultBorderSize, 0); labelListPosition = new Vector2(DefaultListLabelOffsetX, borderSize + DefaultListLabelOffsetY); selectedLabelPosition = new Vector2(DefaultListLabelOffsetX, (DropDownButton.DefaultDropDownButtonHeight - fontSize) / 2); listPosition = new Vector2(0, boxSize.Height); listSize = new Size(itemSize.Width, itemSize.Height * optionList.Length + 2 * borderSize); expandedSize = new Size(size.Width, size.Height + listSize.Height); // Define sub-parts colors buttonColorArray = buttonColors; buttonInnerArea = buttonColorArray[ColorIndex.Enabled]; buttonBorderColor = buttonColorArray[ColorIndex.BorderEnabled]; labelEnabledColor = labelEnabled; labelHighlightedColor = labelHighlighted; // Create child-controls dropDownButton = new DropDownButton(id + "_Button", dropDownButtonPosition, dropDownButtonSize, buttonColorArray); dropDownButton.IsSubComponent = true; dropDownButton.CanRaiseEvents = false; listPanel = new Panel(id + "_Panel", listPosition, listSize, Shape.Rectangle, BorderStyle.Raised, Shapes.ShadeTopToBottom, defaultColors); listPanel.IsFocusable = false; listPanel.IsVisible = false; listPanel.IsSubComponent = true; listPanel.MouseMove += delegate(BaseControl ctl, MouseEventArgs e) { highlightedLabelIndex = (int) ((e.Location.Y - listPanel.AbsolutePosition.Y + borderSize) / (itemSize.Height + 1)); if (highlightedLabelIndex >= listPanel.Controls.Count) { return; } DebugManager.LogToScreen(highlightedLabelIndex.ToString()); for (int i = 0; i < listPanel.Controls.Count; i++) { Label label = listPanel.Controls[i] as Label; if (i != highlightedLabelIndex) { label.SetHighlight(false); } else { label.SetHighlight(true); } } }; listPanel.MouseDown += delegate(BaseControl ctl, MouseEventArgs e) { Select(highlightedLabelIndex); }; listPanel.MouseUp += delegate(BaseControl ctl, MouseEventArgs e) { dropDownButton.IsHighlighted = false; Select(highlightedLabelIndex); }; // Create label list for (int i = 0; i < optionList.Length; i++) { Vector2 labelPosition = Vector2.Add(labelListPosition, new Vector2(0, i * (itemSize.Height + 1))); Label label = new Label(id + "_l" + i.ToString(), optionList[i], fontSize, Alignment.Left, Alignment.Top, labelPosition, labelEnabledColor, labelHighlightedColor); // let the panel handle highlights label.Style.ApplyHighlight = false; listPanel.Add(label); } // Assign needed depth info listPanel.Depth = new Depth(0, 1, 0, 0); Add(dropDownButton); Add(listPanel); // Create a copy of the currently selected label selectedLabel = (listPanel.Controls[0] as Label).Clone(id + "_ls"); //selectedLabel = new Label(id + "_ls", optionList[0], // Alignment.Left, Alignment.Top, selectedLabelPosition, Label.DefaultColor); }