/// <summary> /// Metoda volaná pro vykreslování obsahu "Přes Child prvky". /// </summary> /// <param name="e"></param> /// <param name="boundsAbsolute"></param> /// <param name="drawMode"></param> public void DrawOverChilds(GInteractiveDrawArgs e, Rectangle boundsAbsolute, DrawItemMode drawMode) { Rectangle boundsVisibleAbsolute = boundsAbsolute; if (e.DrawLayer == GInteractiveDrawLayer.Standard) { boundsVisibleAbsolute = e.GetClip(boundsAbsolute); } this.ControlBuffered.DrawImages(e, ref boundsAbsolute, boundsVisibleAbsolute, drawMode); if (!this.DrawTextInCurrentState) { return; } if (e.DrawLayer == GInteractiveDrawLayer.Standard) { boundsVisibleAbsolute = e.GetClip(boundsAbsolute); } FontInfo fontInfo = FontInfo.CaptionBold; ExtendedContentAlignment textPosition = this.TextPosition; string text = this.GetCaption(e, boundsAbsolute, boundsVisibleAbsolute, fontInfo, textPosition); if (String.IsNullOrEmpty(text)) { return; } this.ControlBuffered.DrawText(e, boundsVisibleAbsolute, text, fontInfo, textPosition); }
/// <summary> /// Metoda vrátí text, který má být zobrazen v grafickém prvku /// </summary> /// <param name="e"></param> /// <param name="boundsAbsolute"></param> /// <param name="boundsVisibleAbsolute"></param> /// <param name="fontInfo"></param> /// <param name="textPosition"></param> /// <returns></returns> protected string GetCaption(GInteractiveDrawArgs e, Rectangle boundsAbsolute, Rectangle boundsVisibleAbsolute, FontInfo fontInfo, ExtendedContentAlignment textPosition) { // 1. Pokud je text v prvku uveden explicitně, pak jej použijeme: string text = this._FirstItem.Text; if (text != null) { return(text); } // 2. Text pro aktuální velikost je pravděpodobně uložený v paměti (od posledně): Size size = boundsAbsolute.Size; text = this.GetCaptionForSize(size); if (text != null) { return(text); } // 3. Pro danou velikost ještě text není zapamatován => Získáme text Caption z datového zdroje grafu a zapamatujeme si ho: CreateTextArgs args = new CreateTextArgs(this._ParentGraph, e, fontInfo, this, this._FirstItem, GraphControlPosition.Group, boundsAbsolute, boundsVisibleAbsolute); text = this._ParentGraph.GraphItemGetCaptionText(args); this.SetCaptionForSize(size, text); return(text); }
/// <summary> /// Draw a background of EditableArea in standard mode /// </summary> /// <param name="e"></param> /// <param name="bounds">Absolute bounds</param> protected virtual void DrawStandardBackground(GInteractiveDrawArgs e, Rectangle bounds) { Point?point = ((this.InteractiveState == GInteractiveState.MouseOver) ? this.CurrentMouseRelativePoint : (Point?)null); Painter.DrawAreaBase(e.Graphics, bounds, this.BackColor.Value, Orientation.Horizontal, this.InteractiveState, point, null); Painter.DrawString(e.Graphics, "GEditableArea", FontInfo.Default, bounds, ContentAlignment.MiddleCenter, Color.Black); }
/// <summary> /// Vykreslí tuto jednu linku /// </summary> /// <param name="e"></param> internal void Draw(GInteractiveDrawArgs e) { if (this.Link.NeedDraw) { this.Link.Draw(e, this.Mode, this.VisibleRatio); } }
/// <summary> /// Physically draw this ChildItem on given Graphics. /// </summary> /// <param name="e"></param> protected virtual void DrawItem(GInteractiveDrawArgs e) { if (!this.Is.Visible) { return; } Rectangle bounds; switch (this.ItemType) { case ChildItemType.Area: break; case ChildItemType.Border: bounds = this.BoundsAbsolute.Enlarge(0, 0, -1, -1); e.Graphics.DrawRectangle(Pens.Black, bounds); break; case ChildItemType.Left: case ChildItemType.TopLeft: case ChildItemType.Top: case ChildItemType.TopRight: case ChildItemType.Right: case ChildItemType.BottomRight: case ChildItemType.Bottom: case ChildItemType.BottomLeft: bounds = this.BoundsAbsolute; e.Graphics.FillRectangle(Painter.InteractiveClipBrushForState(this.ItemState), bounds); break; } }
/// <summary> /// Kreslení prvku VERTICAL /// </summary> /// <param name="e"></param> /// <param name="absoluteBounds"></param> /// <param name="absoluteVisibleBounds"></param> /// <param name="drawMode"></param> protected void DrawVertical(GInteractiveDrawArgs e, Rectangle absoluteBounds, Rectangle absoluteVisibleBounds, DrawItemMode drawMode) { Rectangle beginBounds = new Rectangle(absoluteBounds.X, absoluteBounds.Y, 1, absoluteBounds.Height); Rectangle centerBounds = new Rectangle(absoluteBounds.X + 1, absoluteBounds.Y, absoluteBounds.Width - 2, absoluteBounds.Height); Rectangle endBounds = new Rectangle(absoluteBounds.Right - 1, absoluteBounds.Y, 1, absoluteBounds.Height); this.DrawResizer(e, beginBounds, centerBounds, endBounds); }
/// <summary> /// Kreslení prvku HORIZONAL /// </summary> /// <param name="e"></param> /// <param name="absoluteBounds"></param> /// <param name="absoluteVisibleBounds"></param> /// <param name="drawMode"></param> protected void DrawHorizontal(GInteractiveDrawArgs e, Rectangle absoluteBounds, Rectangle absoluteVisibleBounds, DrawItemMode drawMode) { Rectangle beginBounds = new Rectangle(absoluteBounds.X, absoluteBounds.Y, absoluteBounds.Width, 1); Rectangle centerBounds = new Rectangle(absoluteBounds.X, absoluteBounds.Y + 1, absoluteBounds.Width, absoluteBounds.Height - 2); Rectangle endBounds = new Rectangle(absoluteBounds.X, absoluteBounds.Bottom - 1, absoluteBounds.Width, 1); this.DrawResizer(e, beginBounds, centerBounds, endBounds); }
/// <summary> /// Vykreslí tuto grupu. /// Grupa se kreslí pouze tehdy, pokud obsahuje více než 1 prvek, a pokud vrstva <see cref="ITimeGraphItem.Layer"/> je nula nebo kladná (pro záp**né vrstvy se nekreslí). /// </summary> /// <param name="e">Standardní data pro kreslení</param> /// <param name="boundsAbsolute">Absolutní souřadnice tohoto prvku</param> /// <param name="drawMode">Režim kreslení (má význam pro akce Drag and Drop)</param> public void Draw(GInteractiveDrawArgs e, Rectangle boundsAbsolute, DrawItemMode drawMode) { if (!this.IsValidRealTime || this.Layer < 0 || this.ItemCount <= 1) { return; } this.ControlBuffered.DrawItem(e, boundsAbsolute, drawMode); }
/// <summary> /// Vykreslí text /// </summary> /// <param name="e"></param> /// <param name="absoluteBounds"></param> /// <param name="absoluteVisibleBounds"></param> /// <param name="drawMode"></param> protected override void DrawText(GInteractiveDrawArgs e, Rectangle absoluteBounds, Rectangle absoluteVisibleBounds, DrawItemMode drawMode) { string text = this.Text; if (!String.IsNullOrEmpty(text)) { Painter.DrawString(e.Graphics, text, this.FontCurrent, absoluteBounds, this.Alignment, color: this.TextColorCurrent); } }
protected override void Draw(GInteractiveDrawArgs e, Rectangle absoluteBounds, Rectangle absoluteVisibleBounds, DrawItemMode drawMode) { var style = this.StyleCurrent; var borderType = style.BorderType; int borderWidth = Painter.GetBorderWidth(borderType); var interactiveState = VisualInteractiveState; var backColor = style.GetBackColor(interactiveState); var borderColor = style.GetBorderColor(interactiveState); Rectangle backBounds = absoluteBounds.Enlarge(-borderWidth); Painter.DrawAreaBase(e.Graphics, backBounds, backColor, System.Windows.Forms.Orientation.Horizontal, interactiveState); Painter.DrawBorder(e.Graphics, absoluteBounds, borderColor, borderType, interactiveState); }
/// <summary> /// Vykreslí tuto jednu linku /// </summary> /// <param name="e">Data pro kreslení</param> /// <param name="mode">Důvody zobrazení</param> /// <param name="ratio">Poměr průhlednosti: hodnota v rozsahu 0.0 (neviditelná) - 1.0 (plná barva)</param> internal void Draw(GInteractiveDrawArgs e, TimeGraphLinkMode mode, float ratio) { if (this.IsLinkTypeVisible) { if (this.LinkCenter) { this.DrawCenter(e, mode, ratio); } else { this.DrawPrevNext(e, mode, ratio); } } }
/// <summary> /// Kreslení prvku /// </summary> /// <param name="e"></param> /// <param name="absoluteBounds"></param> /// <param name="absoluteVisibleBounds"></param> /// <param name="drawMode"></param> protected override void Draw(GInteractiveDrawArgs e, Rectangle absoluteBounds, Rectangle absoluteVisibleBounds, DrawItemMode drawMode) { if (!this._ResizeControl.ShowResizeAllways && !this.ParentHasMouse) { return; } if (this.Orientation == Orientation.Vertical) { this.DrawVertical(e, absoluteBounds, absoluteVisibleBounds, drawMode); } else { this.DrawHorizontal(e, absoluteBounds, absoluteVisibleBounds, drawMode); } }
/// <summary> /// Vykreslí přímou linku nebo křivku Prev.Center to Next.Center /// </summary> /// <param name="e">Data pro kreslení</param> /// <param name="mode">Důvody zobrazení</param> /// <param name="ratio">Poměr průhlednosti: hodnota v rozsahu 0.0 (neviditelná) - 1.0 (plná barva)</param> protected void DrawCenter(GInteractiveDrawArgs e, TimeGraphLinkMode mode, float ratio) { TimeGraph graph = (this.ItemNext != null ? this.ItemNext.Graph : (this.ItemPrev != null ? this.ItemPrev.Graph : null)); RelationState relationState = GetRelationState(this.ItemPrev, this.ItemNext); Color color1 = this.GetColorForState(relationState, graph); Point?prevPoint = GetPoint(this.ItemPrev, RectangleSide.CenterX | RectangleSide.CenterY, true, false); Point?nextPoint = GetPoint(this.ItemNext, RectangleSide.CenterX | RectangleSide.CenterY, true, false); if (!(prevPoint.HasValue && nextPoint.HasValue)) { return; } Painter.DrawLinkLine(e.Graphics, prevPoint.Value, nextPoint.Value, color1, this.LinkWidth, System.Drawing.Drawing2D.LineCap.Round, System.Drawing.Drawing2D.LineCap.ArrowAnchor, ratio); }
/// <summary> /// Draw current size axis to specified graphic. /// Coordinates are this.Area. /// </summary> /// <param name="e">Data pro kreslení</param> /// <param name="absoluteBounds">Absolutní souřadnice tohoto prvku, sem by se mělo fyzicky kreslit</param> /// <param name="absoluteVisibleBounds">Absolutní souřadnice tohoto prvku, oříznuté do viditelné oblasti.</param> protected override void Draw(GInteractiveDrawArgs e, Rectangle absoluteBounds, Rectangle absoluteVisibleBounds) { if (e.DrawLayer == GInteractiveDrawLayer.Standard) { try { e.Graphics.SetClip(absoluteBounds); this._PaintBackground(e.Graphics, absoluteBounds); this.PaintSheet(e.Graphics, absoluteBounds); base.Draw(e, absoluteBounds, absoluteVisibleBounds); } finally { e.Graphics.ResetClip(); } } }
/// <summary> /// Draw this item in standard mode /// </summary> /// <param name="e">Data pro kreslení</param> /// <param name="absoluteBounds">Absolutní souřadnice tohoto prvku, sem by se mělo fyzicky kreslit</param> /// <param name="absoluteVisibleBounds">Absolutní souřadnice tohoto prvku, oříznuté do viditelné oblasti.</param> /// <param name="drawMode">Režim kreslení (pomáhá řešit Drag and Drop procesy)</param> protected override void Draw(GInteractiveDrawArgs e, Rectangle absoluteBounds, Rectangle absoluteVisibleBounds, DrawItemMode drawMode) { bool isGhost = (drawMode.HasFlag(DrawItemMode.Ghost)); if (!isGhost) { this.DrawStandardBackground(e, absoluteBounds); } else { this.DrawGhostBackground(e, absoluteBounds); } bool isTarget = (drawMode.HasFlag(DrawItemMode.DraggedBounds)); if (isTarget) { this.DrawChildItems(e); } }
/// <summary> /// Vykreslí přímou linku nebo S křivku { Prev.End to Next.Begin } /// </summary> /// <param name="e">Data pro kreslení</param> /// <param name="mode">Důvody zobrazení</param> /// <param name="ratio">Poměr průhlednosti: hodnota v rozsahu 0.0 (neviditelná) - 1.0 (plná barva)</param> protected void DrawPrevNext(GInteractiveDrawArgs e, TimeGraphLinkMode mode, float ratio) { TimeGraph graph = (this.ItemNext != null ? this.ItemNext.Graph : (this.ItemPrev != null ? this.ItemPrev.Graph : null)); RelationState relationState = GetRelationState(this.ItemPrev, this.ItemNext); Color color1 = this.GetColorForState(relationState, graph); Point?prevPoint = GetPoint(this.ItemPrev, RectangleSide.MiddleRight, true, true); Point?nextPoint = GetPoint(this.ItemNext, RectangleSide.MiddleLeft, true, true); LinkLineType lineType = this.CurrentLineShape; float? treshold = 4f * (float)(this.LinkWidth.HasValue ? this.LinkWidth.Value : 3); using (System.Drawing.Drawing2D.GraphicsPath graphicsPath = Painter.CreatePathLink(lineType, prevPoint, nextPoint, treshold)) { bool useRoundAnchor = (lineType == LinkLineType.ZigZagHorizontal || lineType == LinkLineType.ZigZagVertical || lineType == LinkLineType.ZigZagOptimal); System.Drawing.Drawing2D.LineCap startCap = (useRoundAnchor ? System.Drawing.Drawing2D.LineCap.RoundAnchor : System.Drawing.Drawing2D.LineCap.Round); System.Drawing.Drawing2D.LineCap endCap = System.Drawing.Drawing2D.LineCap.ArrowAnchor; Painter.DrawLinkPath(e.Graphics, graphicsPath, color1, null, this.LinkWidth, startCap, endCap, ratio); } }
/// <summary> /// Kreslení prvku v rámci daných souřadnic /// </summary> /// <param name="e"></param> /// <param name="beginBounds"></param> /// <param name="centerBounds"></param> /// <param name="endBounds"></param> protected void DrawResizer(GInteractiveDrawArgs e, Rectangle beginBounds, Rectangle centerBounds, Rectangle endBounds) { Color baseColor = this.GetCurrentValue(this._ResizeControl.InactiveColor, this._ResizeControl.MouseOnParentColor, this._ResizeControl.MouseOverColor, this._ResizeControl.MouseDownColor); Color lightColor = Skin.Modifiers.GetColor3DBorderLight(baseColor); Color darkColor = Skin.Modifiers.GetColor3DBorderDark(baseColor); if (centerBounds.Height > 0) { e.Graphics.FillRectangle(Skin.Brush(baseColor), centerBounds); } if (this.IsMouseDown) { // MouseDown => Begin prostor bude tmavší, End prostor bude světlejší: e.Graphics.FillRectangle(Skin.Brush(darkColor), beginBounds); e.Graphics.FillRectangle(Skin.Brush(lightColor), endBounds); } else { // Bez MouseDown: e.Graphics.FillRectangle(Skin.Brush(lightColor), beginBounds); e.Graphics.FillRectangle(Skin.Brush(darkColor), endBounds); } }
/// <summary> /// Výchozí metoda pro kreslení prvku, volaná z jádra systému. /// </summary> /// <param name="e">Kreslící argument</param> /// <param name="absoluteBounds">Absolutní souřadnice tohoto prvku, sem by se mělo fyzicky kreslit</param> /// <param name="absoluteVisibleBounds">Absolutní souřadnice tohoto prvku, oříznuté do viditelné oblasti.</param> protected override void Draw(GInteractiveDrawArgs e, Rectangle absoluteBounds, Rectangle absoluteVisibleBounds) { if (e.DrawLayer != GInteractiveDrawLayer.Dynamic) { return; } // Najdeme oblast pro kreslení (Clip na oblast grafu, nebo na oblast grafu + dat v tabulce): Rectangle clip = this.GetClip(e.GraphicsBounds); // Na grafiku nasadíme clip a hladkou kresbu: using (Painter.GraphicsUse(e.Graphics, clip, GraphicSetting.Smooth)) { // Vykreslíme prvky: LinkInfo[] linkInfos = this._LinkDict.Values.ToArray(); // Zhmotníme kolekci kvůli enumeraci foreach (LinkInfo linkInfo in linkInfos) { linkInfo.Draw(e); } } }
/// <summary> /// Draw a editable clips of EditableArea /// </summary> /// <param name="e"></param> protected virtual void DrawChildItems(GInteractiveDrawArgs e) { // GPainter.DrawButtonBase(e.Graphics, this.Bounds, Color.GreenYellow, this.CurrentState, Orientation.Horizontal, point, null); if (this.IsSelected) { this.DrawSelection(e); } if (this.InteractiveState == GInteractiveState.MouseOver || this.InteractiveState == GInteractiveState.LeftDown || this.InteractiveState == GInteractiveState.LeftDrag) { this.ItemBorder.DrawChild(e); this.ItemLeft.DrawChild(e); this.ItemRight.DrawChild(e); this.ItemTop.DrawChild(e); this.ItemBottom.DrawChild(e); this.ItemTopLeft.DrawChild(e); this.ItemTopRight.DrawChild(e); this.ItemBottomRight.DrawChild(e); this.ItemBottomLeft.DrawChild(e); } }
/// <summary> /// Draw a editable clips of EditableArea /// </summary> /// <param name="e"></param> public void DrawChild(GInteractiveDrawArgs e) { this.DrawItem(e); }
/// <summary> /// Vykreslení pozadí /// </summary> /// <param name="e"></param> protected virtual void PaintBackground(GInteractiveDrawArgs e) { }
void ITimeGraphItem.Draw(GInteractiveDrawArgs e, Rectangle boundsAbsolute, DrawItemMode drawMode) { this.Draw(e, boundsAbsolute, drawMode); }
/// <summary> /// Called to draw content of this item. /// This instance (GScrollbar.ChildItem) is not drawed by system, but as part of Scrollbar. /// </summary> /// <param name="e">Data pro kreslení</param> /// <param name="absoluteBounds">Absolutní souřadnice tohoto prvku, sem by se mělo fyzicky kreslit</param> /// <param name="absoluteVisibleBounds">Absolutní souřadnice tohoto prvku, oříznuté do viditelné oblasti.</param> protected override void Draw(GInteractiveDrawArgs e, Rectangle absoluteBounds, Rectangle absoluteVisibleBounds) { // This instance (GMovableItem.ChildItem) is not drawed by system, but as part of GMovableItem: // base.Draw(e); }
/// <summary> /// Vykreslí pozadí /// </summary> /// <param name="e"></param> protected override void PaintBackground(GInteractiveDrawArgs e) { base.PaintBackground(e); }
/// <summary> /// Draw a background of EditableArea in Ghost mode /// </summary> /// <param name="e"></param> /// <param name="bounds">Absolute bounds</param> protected virtual void DrawGhostBackground(GInteractiveDrawArgs e, Rectangle bounds) { Painter.DrawAreaBase(e.Graphics, bounds, Color.FromArgb(128, this.BackColor.Value), Orientation.Horizontal, GInteractiveState.None, null, null); }
/// <summary> /// Vykreslí TrackBar /// </summary> /// <param name="e"></param> /// <param name="absoluteBounds"></param> /// <param name="absoluteVisibleBounds"></param> /// <param name="drawMode"></param> protected override void Draw(GInteractiveDrawArgs e, Rectangle absoluteBounds, Rectangle absoluteVisibleBounds, DrawItemMode drawMode) { Painter.DrawTrackBar(e.Graphics, absoluteBounds, this.Layout); }
/// <summary> /// Draw a selection frame /// </summary> /// <param name="e"></param> protected virtual void DrawSelection(GInteractiveDrawArgs e) { Rectangle bounds = this.BoundsAbsolute; e.Graphics.DrawRectangle(Pens.Magenta, bounds); }
/// <summary> /// Vykreslí text /// </summary> /// <param name="e"></param> /// <param name="absoluteBounds"></param> /// <param name="absoluteVisibleBounds"></param> /// <param name="drawMode"></param> protected override void Draw(GInteractiveDrawArgs e, Rectangle absoluteBounds, Rectangle absoluteVisibleBounds, DrawItemMode drawMode) { this.DrawBackground(e, absoluteBounds, absoluteVisibleBounds, drawMode); // Background this.DrawText(e, absoluteBounds, absoluteVisibleBounds, drawMode); // Text this.DrawBorder(e, absoluteBounds, absoluteVisibleBounds, drawMode); // Rámeček }
/// <summary> /// Vykreslí pozadí. /// Bázová metoda <see cref="TextObject.DrawBackground(GInteractiveDrawArgs, Rectangle, Rectangle, DrawItemMode)"/> /// vyvolá prosté kreslení pozadí <see cref="InteractiveObject.Draw(GInteractiveDrawArgs, Rectangle, Rectangle, DrawItemMode)"/>. /// </summary> /// <param name="e"></param> /// <param name="absoluteBounds"></param> /// <param name="absoluteVisibleBounds"></param> /// <param name="drawMode"></param> protected virtual void DrawBackground(GInteractiveDrawArgs e, Rectangle absoluteBounds, Rectangle absoluteVisibleBounds, DrawItemMode drawMode) { base.Draw(e, absoluteBounds, absoluteVisibleBounds, drawMode); // Background }
/// <summary> /// Vykreslí rámeček. /// Bázová metoda <see cref="TextObject.DrawBorder(GInteractiveDrawArgs, Rectangle, Rectangle, DrawItemMode)"/> nekeslí nic. /// </summary> /// <param name="e"></param> /// <param name="absoluteBounds"></param> /// <param name="absoluteVisibleBounds"></param> /// <param name="drawMode"></param> protected virtual void DrawBorder(GInteractiveDrawArgs e, Rectangle absoluteBounds, Rectangle absoluteVisibleBounds, DrawItemMode drawMode) { }