private void DrawVerticalScroll(Canvas c) { float pct = (float)this._v_scroll_rect.Height / (float)_control.DocumentHeight; _v_scroll_thumb = _v_scroll_rect; _v_scroll_thumb.Width -= 3; _v_scroll_thumb.X += 2; if (pct < 1) { _v_scroll_thumb.Height = pct * _v_scroll_rect.Height; _v_scroll_thumb.Y += Math.Abs(_control.DocumentPositionY) * pct; } if (_v_scroll_thumb.Bottom <= _v_scroll_rect.Bottom) { CanVScroll = true; } else { CanVScroll = false; _v_scroll_thumb.Height = _v_scroll_rect.Bottom - _v_scroll_thumb.Top; } // Scrollbar background c.DrawFillRect(_v_scroll_rect, _scroll_background_material); // Scrollbar thumb c.DrawFillRect(_v_scroll_thumb, _scroll_color_material); c.DrawRect(_v_scroll_rect, BorderColor); }
private void DrawHorizontalScroll(Canvas c) { float pct = (float)this._h_scroll_rect.Width / (float)_control.DocumentWidth; _h_scroll_thumb = _h_scroll_rect; _h_scroll_thumb.Height -= 3; _h_scroll_thumb.Y += 2; if (pct < 1) { _h_scroll_thumb.Width = pct * _h_scroll_rect.Width; _h_scroll_thumb.X += _control.DocumentPositionX * pct; } if (_h_scroll_thumb.Right < _h_scroll_rect.Right) { CanHScroll = true; } else { CanHScroll = false; _h_scroll_thumb.Width = _h_scroll_rect.Right - _h_scroll_thumb.Left; } // Scrollbar background c.DrawFillRect(_h_scroll_rect, _scroll_background_material); // Scrollbar thumb c.DrawFillRect(_h_scroll_thumb, _scroll_color_material); c.DrawRect(_h_scroll_rect, BorderColor); }
public void DrawObjectID(Canvas canvas, Microsoft.DirectX.Direct3D.Font font) { if (ID != string.Empty) { _text_rect = font.MeasureString(null, ID, DrawTextFormat.Center, TextColor); _text_rect.X = (SpriteArea.X + ((SpriteArea.Width - _text_rect.Width) / 2)) - 5; _text_rect.Y = SpriteArea.Bottom; _text_rect.Width += 10; canvas.DrawFillRect(_text_rect, _textbox_color_material); font.DrawText(null, ID, _text_rect, DrawTextFormat.Center, TextColor); } }
public void DrawHeading(Canvas canvas) { if (IsPathCalculatorRunning()) { Vector2 destination = ToScreenCoordinates(_destination.X, _destination.Y); float center_x = _overlay_rect.X + (_overlay_rect.Width / 2); float center_y = _overlay_rect.Y + (_overlay_rect.Height / 2); canvas.DrawLine(HeadingColor, 1, center_x, center_y, destination.X, destination.Y); _destination_area.X = destination.X - 3; _destination_area.Y = destination.Y - 3; _destination_area.Height = 6; _destination_area.Width = 6; canvas.DrawFillRect(this._destination_area, _heading_color_material); } }
public override void OnRender(Canvas canvas) { _background.X = 0; _background.Y = 0; _background.Width = canvas.Size.Width; _background.Height = canvas.Size.Height; bounding_rect = font_large.MeasureString(null, Message, DrawTextFormat.NoClip, Color.Yellow); bounding_rect.X = (_background.Width - bounding_rect.Width) / 2; bounding_rect.Y = (int)(_background.Height - (2 * bounding_rect.Height)); canvas.DrawFillRect(_background, _background_color_material); canvas.DrawRect(_background, Color.White); font_large.DrawText(null, Message, bounding_rect, DrawTextFormat.None, MsgColor); base.OnRender(canvas); }
public override void OnRender(Canvas canvas) { if (!PauseRendering) { Rectangle PlayfieldRect = canvas.TargetControl.ClientRectangle; _playfield.ClientArea = PlayfieldRect; int bottom_left = (PlayfieldRect.Y + PlayfieldRect.Height); Rectangle SpriteRect = Rectangle.Empty; if (Map != null) { SpriteRect = Map.ToRectangle(); // Prevent black from appearing on sides of map. if (!SpriteRect.Contains(PlayfieldRect)) { int right = (int)(Map.Position.X + (Map.TextureWidth * _playfield.Scale)); int bottom = (int)(Map.Position.Y + (Map.TextureHeight * _playfield.Scale)); if (right < PlayfieldRect.Width) { Pan(PlayfieldRect.Width - right, 0); } if (bottom < PlayfieldRect.Height) { Pan(0, PlayfieldRect.Height - bottom); } if (Map.Position.Y > PlayfieldRect.Y) { Pan(0, -(Map.Position.Y)); } if (Map.Position.X > PlayfieldRect.X) { Pan(-(Map.Position.X), 0); } } } switch (MapScrollState) { case MapPlayfieldScrollState.UP: Pan(0, -10); break; case MapPlayfieldScrollState.DOWN: Pan(0, 10); break; case MapPlayfieldScrollState.LEFT: Pan(-10, 0); break; case MapPlayfieldScrollState.RIGHT: Pan(10, 0); break; } _playfield.OnRender(canvas); if (WBRoom != null) { // Draw Whiteboard information from other selected rooms List<string> otherWBNames = WBRoom.GetOtherWBRoomNames(); if (otherWBNames != null) { foreach (string otherWBName in otherWBNames) { DrawWhiteboardRoomObjects(WBRoom.GetOtherWBRoom(otherWBName), canvas); } } // Draw Whiteboard information from current room DrawWhiteboardRoomObjects(WBRoom, canvas); // Draw any commands in progress if ((WBRoom.DrawMode == DrawModes.Line) && (DrawDistanceLine == true) && (WhiteboardDrawing == true)) { if ((WBRoom.DrawText != null) && (WBRoom.DrawText.Length > 0)) { int lineTextSize = LineTextSize; DrawShortenedLine(canvas, WBRoom.DrawColor, WBRoom.DrawPointSize, LineStartLocation.X, LineStartLocation.Y, LineEndLocation.X, LineEndLocation.Y, 1f); if (lineTextSize > MaxFontSize) { lineTextSize = MaxFontSize; } if (lineTextSize < 1) { lineTextSize = 1; } if (wbFonts[lineTextSize] == null) { wbFonts[lineTextSize] = canvas.CreateFont(new System.Drawing.Font("Arial", lineTextSize, FontStyle.Bold, GraphicsUnit.Pixel)); } DrawCenteredText(wbFonts[lineTextSize], WBRoom.DrawText, LineEndLocation.X, LineEndLocation.Y, WBRoom.DrawColor); } else { canvas.DrawLine(WBRoom.DrawColor, WBRoom.DrawPointSize, LineStartLocation.X, LineStartLocation.Y, LineEndLocation.X, LineEndLocation.Y); } } else if ((WBRoom.DrawMode == DrawModes.Circle) && (DrawDistanceLine == true) && (WhiteboardDrawing == true)) { canvas.DrawCircle(WBRoom.DrawColor, WBRoom.DrawPointSize, LineStartLocation.X, LineStartLocation.Y, LineEndLocation.X, LineEndLocation.Y); } else if ((WBRoom.DrawMode == DrawModes.Arrow) && (DrawDistanceLine == true) && (WhiteboardDrawing == true)) { canvas.DrawArrow(WBRoom.DrawColor, WBRoom.DrawPointSize, LineStartLocation.X, LineStartLocation.Y, LineEndLocation.X, LineEndLocation.Y); } else if ((WBRoom.DrawMode == DrawModes.Text) && (DrawDistanceLine == true) && (WhiteboardDrawing == true)) { if ((WBRoom.DrawText != null) && (WBRoom.DrawText.Length > 0)) { int drawPointSize = WBRoom.DrawPointSize + 7; if (drawPointSize > MaxFontSize) { drawPointSize = MaxFontSize; } if (wbFonts[drawPointSize] == null) { wbFonts[drawPointSize] = canvas.CreateFont(new System.Drawing.Font("Arial", drawPointSize, FontStyle.Bold, GraphicsUnit.Pixel)); } DrawCenteredText(wbFonts[drawPointSize], WBRoom.DrawText, LineEndLocation.X, LineEndLocation.Y, WBRoom.DrawColor); } } else if ((WBRoom.DrawMode == DrawModes.Selection) && (DrawDistanceLine == true) && (WhiteboardDrawing == true)) { RectangleF selectionRect; int selectionX = Math.Min(LineStartLocation.X, LineEndLocation.X); int selectionY = Math.Min(LineStartLocation.Y, LineEndLocation.Y); selectionRect = new RectangleF((float)selectionX, (float)selectionY, (float)Math.Abs(LineStartLocation.X - LineEndLocation.X), (float)Math.Abs(LineStartLocation.Y - LineEndLocation.Y)); canvas.DrawRect(selectionRect, Color.Orange); } } // Draw Mini map _bottom_status_bar.Height = 35; _bottom_status_bar.Width = PlayfieldRect.Width; _bottom_status_bar.X = PlayfieldRect.X; _bottom_status_bar.Y = bottom_left - _bottom_status_bar.Height; canvas.DrawFillRect(_bottom_status_bar, _mini_map_background); if (true) //check DDD_Global or playfield { if (_rangeFinderFont == null && this.Fonts.ContainsKey("RangeRing")) { _rangeFinderFont = this.Fonts["RangeRing"]; } string rangeText = DDD_Global.Instance.GetRangeFinderDisplayString(); if (_rangeFinderFont != null && rangeText.Trim() != string.Empty) { _mouseoverRangeFinderDisplay = _rangeFinderFont.MeasureString(null, rangeText, DrawTextFormat.Center, Color.White); _mouseoverRangeFinderDisplay.X = Convert.ToInt32(DDD_Global.Instance.RangeFinderXDisplay);// 500; _mouseoverRangeFinderDisplay.Y = Convert.ToInt32(DDD_Global.Instance.RangeFinderYDisplay);// 400; _mouseoverRangeFinderDisplay.Width += 10; canvas.DrawFillRect(_mouseoverRangeFinderDisplay, _mini_map_background);//_rangeFinderMaterial); _rangeFinderFont.DrawText(null, rangeText, _mouseoverRangeFinderDisplay, DrawTextFormat.Center, Color.White); //DRAW LINE FROM OBJECT TO CURSOR float objX = 0f; float objY = 0f; DDDObjects obj = _playfield.GetSelectedObject(); if (obj != null) { objX = obj.ScreenCoordinates.X; objY = obj.ScreenCoordinates.Y; canvas.DrawLine(Color.Black, 3, _mouseoverRangeFinderDisplay.X - 10, _mouseoverRangeFinderDisplay.Y - 15, objX, objY); } } } if (!MiniMapOverride) { if ((!Map_IsContained_Horizontal(PlayfieldRect)) && (!Map_IsContained_Vertical(PlayfieldRect))) { ShowMiniMap = false; } else { ShowMiniMap = true; } if (WBRoom != null) { ShowMiniMap = true; } if (ShowMiniMap) { _mini_map.X = (PlayfieldRect.X + PlayfieldRect.Width) - _mini_map.Width; _mini_map.Y = 0; _mini_map.Height = (int)((Map.TextureHeight / Map.TextureWidth) * (float)_mini_map.Width); _mini_map_thumb.X = (int)(-(Map.Position.X / (Map.TextureWidth * _playfield.Scale)) * (float)_mini_map.Width) + _mini_map.X; _mini_map_thumb.Y = (int)(-(Map.Position.Y / (Map.TextureHeight * _playfield.Scale)) * (float)_mini_map.Height) + _mini_map.Y; _mini_map_thumb.Width = (int)(_mini_map.Width * ((float)PlayfieldRect.Width / (Map.TextureWidth * _playfield.Scale))); _mini_map_thumb.Height = (int)(_mini_map.Height * ((float)PlayfieldRect.Height / (Map.TextureHeight * _playfield.Scale))); canvas.DrawFillRect(_mini_map, _mini_map_background); // Draw rect for other users in a whiteboard room if (wbRoom != null) { int originX = 0; int originY = 0; int screenSizeWidth = 0; int screenSizeHeight = 0; double screenZoom = 0.0; foreach (string wbUser in wbRoom.MembershipList) { if (string.Compare(wbUser, DDD_Global.Instance.PlayerID) == 0) { continue; } if (wbRoom.GetScreenViewInfo(wbUser, ref originX, ref originY, ref screenSizeWidth, ref screenSizeHeight, ref screenZoom)) { Rectangle userMiniMapRect = Rectangle.Empty; Vector2 _metersPerPixelValues = new Vector2(); Vector2 userPosition = new Vector2(); _metersPerPixelValues.X = UTM_Mapping.HorizonalMetersPerPixel; _metersPerPixelValues.Y = UTM_Mapping.VerticalMetersPerPixel; userPosition.X = (float) originX / _metersPerPixelValues.X; userPosition.Y = (float)originY / _metersPerPixelValues.Y; userMiniMapRect.X = (int)((userPosition.X / (Map.TextureWidth)) * (float)_mini_map.Width) + _mini_map.X; userMiniMapRect.Y = (int)((userPosition.Y / (Map.TextureHeight)) * (float)_mini_map.Height) + _mini_map.Y; userMiniMapRect.Width = (int)((float)screenSizeWidth / _metersPerPixelValues.X / Map.TextureWidth * (float)_mini_map.Width); userMiniMapRect.Height = (int)((float)screenSizeHeight / _metersPerPixelValues.Y / Map.TextureHeight * (float)_mini_map.Height); // Draw rect for this a whiteboard user if (DMColorMap.ContainsKey(wbUser)) { canvas.DrawRect(userMiniMapRect, Color.FromArgb(DMColorMap[wbUser])); } else { canvas.DrawRect(userMiniMapRect, Color.DarkBlue); } } } } // Draw rect for this user if ((wbRoom != null) && DMColorMap.ContainsKey(DDD_Global.Instance.PlayerID)) { canvas.DrawRect(_mini_map_thumb, Color.FromArgb(DMColorMap[DDD_Global.Instance.PlayerID])); } else { canvas.DrawRect(_mini_map_thumb, Color.Red); } lock (this) { DDDObjects selected = GetSelectedObject(); foreach (string obj_name in _playfield.PlayfieldObjects) { DDDObjects obj = (DDDObjects)_playfield.GetMappableObject(obj_name); if (obj != null) { _mini_map_track.X = (int)(((_mini_map.Width / Map.TextureWidth) * obj.Position.X) + _mini_map.X) - (int)(.5 * _mini_map_track.Width); _mini_map_track.Y = (int)(((_mini_map.Height / Map.TextureHeight) * obj.Position.Y) + _mini_map.Y) - (int)(.5 * _mini_map_track.Height); if (selected != null) { if ((selected.ID == obj.ID) && !ShowUnitColorOnMiniMap) { canvas.DrawTri(_mini_map_track, Color.Yellow, DIRECTION.UP); continue; } } if (!ShowUnitColorOnMiniMap) { canvas.DrawTri(_mini_map_track, Color.DodgerBlue, DIRECTION.UP); } else { canvas.DrawTri(_mini_map_track, obj.TextBoxColor, DIRECTION.UP); } } } foreach (string obj_name in _playfield.PlayfieldObjects) { DDDObjects obj = (DDDObjects)_playfield.GetMappableObject(obj_name); if (obj != null) { _mini_map_track.X = (int)(((_mini_map.Width / Map.TextureWidth) * obj.Position.X) + _mini_map.X) - (int)(.5 * _mini_map_track.Width); _mini_map_track.Y = (int)(((_mini_map.Height / Map.TextureHeight) * obj.Position.Y) + _mini_map.Y) - (int)(.5 * _mini_map_track.Height); if (obj.IsBeingAttacked) { if (GameFramework.ElapsedSeconds(AnimationTimer, AnimationCycle)) { AnimationTimer = GameFramework.QueryPerformanceTimer(); } if (GameFramework.ElapsedSeconds(AnimationTimer, BlinkCycle)) { canvas.DrawTri(_mini_map_track, Color.White, DIRECTION.UP); continue; } } } } } } } if (ShowPosition) { DDDObjects obj = _playfield.GetSelectedObject(); if (obj != null) { if (obj.IsPathCalculatorRunning()) { canvas.DrawFillRect(_bottom_status_bar, _mini_map_background); SizeF size = obj.DrawIcon(canvas, PlayfieldRect.X, _bottom_status_bar.Y, 30, 30); int font_height = (Fonts["Arial8B"].MeasureString(null, obj.FullVelocityStr, DrawTextFormat.None, Color.White)).Height; Fonts["Arial8B"].DrawText(null, obj.FullVelocityStr, PlayfieldRect.X + (int)size.Width + 2, _bottom_status_bar.Y, Color.White); Fonts["Arial8B"].DrawText(null, obj.FullTTDStr, PlayfieldRect.X + (int)size.Width + 2, (_bottom_status_bar.Y + font_height), Color.White); Fonts["Arial8B"].DrawText(null, obj.FullDestinationStr, PlayfieldRect.X + (int)size.Width + 2, (_bottom_status_bar.Y + (2 * font_height)), Color.White); } else { SizeF size = obj.DrawIcon(canvas, PlayfieldRect.X, _bottom_status_bar.Y, 30, 30); int font_height = (Fonts["Arial10B"].MeasureString(null, obj.ObjectID, DrawTextFormat.None, Color.White)).Height; Fonts["Arial10B"].DrawText(null, obj.ObjectID, PlayfieldRect.X + (int)size.Width, (_bottom_status_bar.Bottom - font_height), Color.White); } } } int width; String str = String.Empty; if (!IsPaused) { if (DDD_Global.Instance.IsForkReplay) { str = String.Format("Fork Replay {0}", Time); } else { str = Time; } } else { str = "Paused"; } width = (Fonts["Arial10B"].MeasureString(null, str, DrawTextFormat.None, Color.Yellow)).Width + 5; Fonts["Arial10B"].DrawText(null, str, _bottom_status_bar.X + (_bottom_status_bar.Width - width), _bottom_status_bar.Y + 5, Color.Yellow); //if (!IsPaused) //{ // if (DDD_Global.Instance.IsForkReplay) // { // width = (Fonts["Arial10B"].MeasureString(null, Time, DrawTextFormat.None, Color.Yellow)).Width + 5; // Fonts["Arial10B"].DrawText(null, String.Format("Fork Replay {0}",Time), _bottom_status_bar.X + (_bottom_status_bar.Width - width), _bottom_status_bar.Y + 5, Color.Yellow); // } // else // { // width = (Fonts["Arial10B"].MeasureString(null, Time, DrawTextFormat.None, Color.Yellow)).Width + 5; // Fonts["Arial10B"].DrawText(null, Time, _bottom_status_bar.X + (_bottom_status_bar.Width - width), _bottom_status_bar.Y + 5, Color.Yellow); // } //} //else //{ // width = (Fonts["Arial10B"].MeasureString(null, Time, DrawTextFormat.None, Color.Yellow)).Width + 5; // Fonts["Arial10B"].DrawText(null, "Paused", _bottom_status_bar.X + (_bottom_status_bar.Width - width), _bottom_status_bar.Y + 5, Color.Yellow); //} } }
public void DrawObjectID(Canvas canvas, Microsoft.DirectX.Direct3D.Font font) { if (ID != string.Empty) { _text_rect = font.MeasureString(null, ID, DrawTextFormat.Center, TextColor); _text_rect.X = (SpriteArea.X + ((SpriteArea.Width - _text_rect.Width) / 2)) - 5; _text_rect.Y = SpriteArea.Bottom; _text_rect.Width += 10; canvas.DrawFillRect(_text_rect, _textbox_color_material); font.DrawText(null, ID, _text_rect, DrawTextFormat.Center, TextColor); } }
public void DrawHeading(Canvas canvas) { if (IsPathCalculatorRunning()) { Vector2 destination = ToScreenCoordinates(_destination.X, _destination.Y); float center_x = _overlay_rect.X + (_overlay_rect.Width / 2); float center_y = _overlay_rect.Y + (_overlay_rect.Height / 2); canvas.DrawLine(HeadingColor, 1, center_x, center_y, destination.X, destination.Y); _destination_area.X = destination.X - 3; _destination_area.Y = destination.Y - 3; _destination_area.Height = 6; _destination_area.Width = 6; canvas.DrawFillRect(this._destination_area, _heading_color_material); } }
public override void DrawSpecial(Microsoft.DirectX.Direct3D.Font font, RectangleF overlay_rect, Rectangle text_rect, Canvas canvas) { _overlay_rect = overlay_rect; _text_rect = text_rect; _progressbar_rect = text_rect; _border_rect = text_rect; if ((OwnerID == DDD_Global.Instance.PlayerID) && (DrawProgressBar)) { _progressbar_rect.Y += text_rect.Height; _progressbar_rect.Height = _ProgressBarHeight_; _progressbar_rect.Width = _ProgressBarWidth_; _progressbar_rect.X += ((text_rect.Width - _progressbar_rect.Width) / 2); _border_rect.Height = _ProgressBarHeight_ + _text_rect.Height + 2; canvas.DrawFillRect(_border_rect, _textbox_color_material); DrawObjectID(canvas, font); canvas.DrawRect(_border_rect, BorderColor); if (FuelCapacity > 0) { canvas.DrawProgressBar(_progressbar_rect, progress_bar_background_material, progress_bar_foreground_material, FuelAmount / FuelCapacity); } else { canvas.DrawProgressBar(_progressbar_rect, progress_bar_background_material, progress_bar_foreground_material, 0); } } else { if (DrawUnmanagedAssetLabel) { DrawObjectID(canvas, font); canvas.DrawRect(_border_rect, BorderColor); } } foreach (DDDObjects attacker in Attackers) { float _destinationX = attacker.SpriteArea.X + (attacker.SpriteArea.Width / 2); float _destinationY = attacker.SpriteArea.Y + (attacker.SpriteArea.Height / 2); canvas.DrawLine(Color.Red, 1, SpriteArea.X + (SpriteArea.Width / 2), SpriteArea.Y + (SpriteArea.Height / 2), _destinationX, _destinationY ); //engagment_rect.X = (int)(_destinationX - 3); //engagment_rect.Y = (int)(_destinationY - 3); //engagment_rect.Height = 6; //engagment_rect.Width = 6; //canvas.DrawFillRect(engagment_rect, red_material); } if (IsBeingAttacked) { engagment_rect = font.MeasureString(null, _engagementTimeStr, DrawTextFormat.Center | DrawTextFormat.VerticalCenter, Color.Red); engagment_rect.Width += 10; engagment_rect.X = (int)(_overlay_rect.X + (_overlay_rect.Width - engagment_rect.Width) / 2); engagment_rect.Y = (int)(_overlay_rect.Y + (_overlay_rect.Height - engagment_rect.Height) / 2); canvas.DrawFillRect(engagment_rect, black_material); canvas.DrawRect(engagment_rect, Color.Red); font.DrawText(null, _engagementTimeStr, engagment_rect, DrawTextFormat.Center | DrawTextFormat.VerticalCenter, Color.Red); } // Draw object "Tags" if (Tag != string.Empty && (DDD_Global.Instance.TagPosition != TagPositionEnum.INVISIBLE)) { Rectangle tag_rect = font.MeasureString(null, Tag, DrawTextFormat.Center, Color.Black); switch (DDD_Global.Instance.TagPosition) { case TagPositionEnum.ABOVE: tag_rect.Y = (int)(overlay_rect.Y - tag_rect.Height); tag_rect.X = (int)(overlay_rect.X + ((overlay_rect.Width - tag_rect.Width) * .5f)); break; case TagPositionEnum.BELOW: if (!DrawUnmanagedAssetLabel && (OwnerID != DDD_Global.Instance.PlayerID)) { tag_rect.Y = (int)(overlay_rect.Bottom + 1); tag_rect.X = (int)(overlay_rect.X + ((overlay_rect.Width - tag_rect.Width) * .5f)); } else { tag_rect.Y = (int)(_border_rect.Bottom + 2); tag_rect.X = (int)(overlay_rect.X + ((overlay_rect.Width - tag_rect.Width) * .5f)); } break; case TagPositionEnum.CENTER: //tag_rect.Y = (int)(overlay_rect.Y + ((overlay_rect.Height - tag_rect.Height) * .5f)); tag_rect.Y = (int)(overlay_rect.Bottom - tag_rect.Height - 2); tag_rect.X = (int)(overlay_rect.X + ((overlay_rect.Width - tag_rect.Width) * .5f)); break; } canvas.DrawFillRect(tag_rect, tag_material); font.DrawText(null, Tag, tag_rect, DrawTextFormat.VerticalCenter | DrawTextFormat.Center, Color.Black); } }
public void OnRender(Canvas c) { if (State != WindowState.HIDE) { _shade_btn = _caption_bar; _shade_btn.Width = 12; _shade_btn.Height = 12; _shade_btn.X = _caption_bar.Right - 28; _shade_btn.Y += 7; _v_scroll_rect.X = _client_area.Right - ScrollWidth; _v_scroll_rect.Y = _caption_bar.Bottom; _v_scroll_rect.Height = _client_area.Height - (ScrollWidth + _caption_bar.Height); _v_scroll_rect.Width = ScrollWidth - 1; _h_scroll_rect.X = _client_area.X; _h_scroll_rect.Y = _client_area.Bottom - ScrollWidth; _h_scroll_rect.Width = _client_area.Width - ScrollWidth; _h_scroll_rect.Height = ScrollWidth - 1; _v_scroll_thumb = _v_scroll_rect; _h_scroll_thumb = _h_scroll_rect; c.DrawFillRect(_main_panel.ClientArea, _background_color_material); _main_panel.OnRender(c); if (HasScrollBars) { if (this._ShowHorizontalScroll) { DrawHorizontalScroll(c); } if (this._ShowVerticalScroll) { DrawVerticalScroll(c); } } c.DrawRect(_client_area, BorderColor); if (CaptionText != string.Empty) { c.DrawFillRect(_caption_bar, _caption_color_material); if (Font != null) { Font.DrawText(null, CaptionText, _caption_bar, DrawTextFormat.VerticalCenter | DrawTextFormat.Center, CaptionForeground); } if (AllowShade) { switch (State) { case WindowState.MINIMIZED: c.DrawFillTri(_shade_btn, _caption_foreground_material, DIRECTION.UP); c.DrawTri(_shade_btn, BorderColor, DIRECTION.UP); break; case WindowState.MAXIMIZED: c.DrawFillTri(_shade_btn, _caption_foreground_material, DIRECTION.DOWN); c.DrawTri(_shade_btn, BorderColor, DIRECTION.DOWN); break; } } if (Selected) { c.DrawRect(_caption_bar, Color.White); } else { c.DrawRect(_caption_bar, BorderColor); } } if (AllowResize) { _resize_btn.X = _client_area.Right - 15; _resize_btn.Y = _client_area.Bottom - 15; _resize_btn.Width = 10; _resize_btn.Height = 10; c.DrawFillRect(_resize_btn, _caption_color_material); c.DrawRect(_resize_btn, BorderColor); } } }
public override void OnRender(Canvas canvas) { canvas.DrawFillRect(_background, _background_color_material); canvas.DrawRect(_background, Color.White); if (DDD_Global.Instance.IsConnected) { if (_loading_textures) { //player_rect.Height = (font_small.MeasureString(null, DDD_Global.Instance.PlayerBrief, DrawTextFormat.WordBreak, Color.Yellow)).Height; canvas.DrawFillRect(player_rect, _background_window_material); font_small.DrawText(null, DDD_Global.Instance.PlayerBrief, player_rect, DrawTextFormat.WordBreak, Color.Yellow); _continue_btn.SetClientArea(player_rect.Left, player_rect.Bottom + 2, player_rect.Right, player_rect.Bottom + 27); _continue_btn.Text = "Start Game"; } _continue_btn.OnRender(canvas); } font_small.DrawText(null, Program.Build_ID, 12, 12, Color.Yellow); font_large.DrawText(null, Message, bounding_rect, DrawTextFormat.None, MsgColor); base.OnRender(canvas); }
public void OnRender(Canvas c) { if (State != WindowState.HIDE) { _shade_btn = _caption_bar; _shade_btn.Width = 12; _shade_btn.Height = 12; _shade_btn.X = _caption_bar.Right - 28; _shade_btn.Y += 7; _v_scroll_rect.X = _client_area.Right - ScrollWidth; _v_scroll_rect.Y = _caption_bar.Bottom; _v_scroll_rect.Height = _client_area.Height - (ScrollWidth + _caption_bar.Height); _v_scroll_rect.Width = ScrollWidth - 1; _h_scroll_rect.X = _client_area.X; _h_scroll_rect.Y = _client_area.Bottom - ScrollWidth; _h_scroll_rect.Width = _client_area.Width - ScrollWidth; _h_scroll_rect.Height = ScrollWidth - 1; _v_scroll_thumb = _v_scroll_rect; _h_scroll_thumb = _h_scroll_rect; c.DrawFillRect(_main_panel.ClientArea, _background_color_material); _main_panel.OnRender(c); if (HasScrollBars) { if (this._ShowHorizontalScroll) { DrawHorizontalScroll(c); } if (this._ShowVerticalScroll) { DrawVerticalScroll(c); } } c.DrawRect(_client_area, BorderColor); if (CaptionText != string.Empty) { c.DrawFillRect(_caption_bar, _caption_color_material); if (Font != null) { Font.DrawText(null, CaptionText, _caption_bar, DrawTextFormat.VerticalCenter | DrawTextFormat.Center, CaptionForeground); } if (AllowShade) { switch (State) { case WindowState.MINIMIZED: c.DrawFillTri(_shade_btn, _caption_foreground_material, DIRECTION.UP); c.DrawTri(_shade_btn, BorderColor, DIRECTION.UP); break; case WindowState.MAXIMIZED: c.DrawFillTri(_shade_btn, _caption_foreground_material, DIRECTION.DOWN); c.DrawTri(_shade_btn, BorderColor, DIRECTION.DOWN); break; } } if (Selected) { c.DrawRect(_caption_bar, Color.White); } else { c.DrawRect(_caption_bar, BorderColor); } } if (AllowResize) { _resize_btn.X = _client_area.Right - 15; _resize_btn.Y = _client_area.Bottom - 15; _resize_btn.Width = 10; _resize_btn.Height = 10; c.DrawFillRect(_resize_btn, _caption_color_material); c.DrawRect(_resize_btn, BorderColor); } } }
private void DrawHorizontalScroll(Canvas c) { float pct = (float)this._h_scroll_rect.Width / (float)_control.DocumentWidth; _h_scroll_thumb = _h_scroll_rect; _h_scroll_thumb.Height -= 3; _h_scroll_thumb.Y += 2; if (pct < 1) { _h_scroll_thumb.Width = pct * _h_scroll_rect.Width; _h_scroll_thumb.X += _control.DocumentPositionX * pct; } if (_h_scroll_thumb.Right < _h_scroll_rect.Right) { CanHScroll = true; } else { CanHScroll = false; _h_scroll_thumb.Width = _h_scroll_rect.Right - _h_scroll_thumb.Left; } // Scrollbar background c.DrawFillRect(_h_scroll_rect, _scroll_background_material); // Scrollbar thumb c.DrawFillRect(_h_scroll_thumb, _scroll_color_material); c.DrawRect(_h_scroll_rect, BorderColor); }
private void DrawVerticalScroll(Canvas c) { float pct = (float)this._v_scroll_rect.Height / (float) _control.DocumentHeight; _v_scroll_thumb = _v_scroll_rect; _v_scroll_thumb.Width -= 3; _v_scroll_thumb.X += 2; if (pct < 1) { _v_scroll_thumb.Height = pct * _v_scroll_rect.Height; _v_scroll_thumb.Y += Math.Abs(_control.DocumentPositionY) * pct; } if (_v_scroll_thumb.Bottom <= _v_scroll_rect.Bottom) { CanVScroll = true; } else { CanVScroll = false; _v_scroll_thumb.Height = _v_scroll_rect.Bottom - _v_scroll_thumb.Top; } // Scrollbar background c.DrawFillRect(_v_scroll_rect, _scroll_background_material); // Scrollbar thumb c.DrawFillRect(_v_scroll_thumb, _scroll_color_material); c.DrawRect(_v_scroll_rect, BorderColor); }
public override void OnRender(Canvas canvas) { Rectangle PlayfieldRect = PlayfieldPanel.ClientArea; Rectangle SpriteRect = Rectangle.Empty; if (Map != null) { SpriteRect = Map.ToRectangle(); } switch (SCROLL) { case ScrollState.LEFT: SpriteRect.X = (int)(SpriteRect.X + 10); if (SpriteRect.Contains(PlayfieldRect)) { MapScene.Pan(10, 0); } break; case ScrollState.RIGHT: SpriteRect.X = (int)(SpriteRect.X - 10); if (SpriteRect.Contains(PlayfieldRect)) { MapScene.Pan(-10, 0); } break; case ScrollState.UP: SpriteRect.Y = (int)(SpriteRect.Y + 10); if (SpriteRect.Contains(PlayfieldRect)) { MapScene.Pan(0, 10); } break; case ScrollState.DOWN: SpriteRect.Y = (int)(SpriteRect.Y - 10); if (SpriteRect.Contains(PlayfieldRect)) { MapScene.Pan(0, -10); } break; } canvas.DrawFillRect(background, background_material); canvas.DrawFillRect(frame, frame_color_material); canvas.DrawRect(frame, border_color); canvas.DrawRect(PlayfieldPanel.ClientArea, Color.Green); canvas.DrawFillRect(score, score_color_material); canvas.DrawFillRect(information_rect, score_color_material); canvas.DrawFillTri(left_arrow, background_material, DIRECTION.LEFT); canvas.DrawFillTri(right_arrow, background_material, DIRECTION.RIGHT); canvas.DrawFillTri(up_arrow, background_material, DIRECTION.UP); canvas.DrawFillTri(down_arrow, background_material, DIRECTION.DOWN); if (MapScene.SelectionCount() == 0) { Mode = MenuMode.DEFAULT; } switch (Mode) { case MenuMode.DEFAULT: DrawMoveMode(canvas); break; case MenuMode.ATTACK: DrawAttackMode(canvas); break; case MenuMode.SUBPLATFORM: DrawSubPMode(canvas); break; } Fonts["Large"].DrawText(null, ScoreHeader, score, DrawTextFormat.VerticalCenter, Color.Yellow); if (!IsPaused) { Fonts["Large"].DrawText(null, Time, time_rect, DrawTextFormat.VerticalCenter, Color.Yellow); } else { Fonts["Large"].DrawText(null, "Paused", time_rect, DrawTextFormat.VerticalCenter, Color.Yellow); } base.OnRender(canvas); }