///<summary>Call this BEFORE calling Invalidate(true).</summary> private void ResizeCubicles() { if (this.Controls == null || this.Controls.Count <= 0) { return; } for (int i = 0; i < this.Controls.Count; i++) { if (this.Controls[i] == null) { continue; } else if (this.Controls[i] is MapAreaRoomControl) { MapAreaRoomControl cubicle = (MapAreaRoomControl)this.Controls[i]; cubicle.Location = GetScreenLocation(cubicle.MapAreaItem.XPos, cubicle.MapAreaItem.YPos, this.PixelsPerFoot); cubicle.Size = GetScreenSize(cubicle.MapAreaItem.Width, cubicle.MapAreaItem.Height, this.PixelsPerFoot); } else if (this.Controls[i] is MapAreaDisplayLabelControl) { MapAreaDisplayLabelControl displayLabel = (MapAreaDisplayLabelControl)this.Controls[i]; displayLabel.Location = GetScreenLocation(displayLabel.MapAreaItem.XPos, displayLabel.MapAreaItem.YPos, this.PixelsPerFoot); displayLabel.Size = MapAreaDisplayLabelControl.GetDrawingSize(displayLabel, this.PixelsPerFoot); //draw labels on top of all other controls displayLabel.BringToFront(); } } }
///<summary>Make the control just tall enough to fit the font and the lesser of the user defined width vs the actual width.</summary> public static Size GetDrawingSize(MapAreaDisplayLabelControl displayLabel, int pixelsPerFoot) { Size controlSize = MapAreaPanel.GetScreenSize(displayLabel.MapAreaItem.Width, displayLabel.MapAreaItem.Height, pixelsPerFoot); Size textSize = TextRenderer.MeasureText(displayLabel.MapAreaItem.Description, displayLabel.Font); return(new Size(Math.Min(controlSize.Width, textSize.Width), textSize.Height)); }
///<summary>Add a display label to the panel.</summary> public void AddDisplayLabel(MapArea displayLabel) { MapAreaDisplayLabelControl label = new MapAreaDisplayLabelControl( displayLabel, this.FontLabel, this.ForeColor, this.FloorColor, //This is effective the BackColor of this panel so set DisplayLabel controls BackColor to match. GetScreenLocation(displayLabel.XPos, displayLabel.YPos, this.PixelsPerFoot), this.PixelsPerFoot, this.AllowDragging, this.AllowEditing); label.DragDone += mapAreaControl_DragDone; label.MapAreaDisplayLabelChanged += mapAreaControl_Changed; this.Controls.Add(label); }
///<summary>Make the control just tall enough to fit the font and the lesser of the user defined width vs the actual width.</summary> public static Size GetDrawingSize(MapAreaDisplayLabelControl displayLabel,int pixelsPerFoot) { Size controlSize=MapAreaPanel.GetScreenSize(displayLabel.MapAreaItem.Width,displayLabel.MapAreaItem.Height,pixelsPerFoot); Size textSize=TextRenderer.MeasureText(displayLabel.MapAreaItem.Description,displayLabel.Font); return new Size(Math.Min(controlSize.Width,textSize.Width),textSize.Height); }
///<summary>Add a display label to the panel.</summary> public void AddDisplayLabel(MapArea displayLabel) { MapAreaDisplayLabelControl label=new MapAreaDisplayLabelControl( displayLabel, this.FontLabel, this.ForeColor, this.FloorColor, //This is effective the BackColor of this panel so set DisplayLabel controls BackColor to match. GetScreenLocation(displayLabel.XPos,displayLabel.YPos,this.PixelsPerFoot), this.PixelsPerFoot, this.AllowDragging, this.AllowEditing); label.DragDone+=mapAreaControl_DragDone; label.MapAreaDisplayLabelChanged+=mapAreaControl_Changed; this.Controls.Add(label); }