/// <summary> /// Draw the entity. /// </summary> /// <param name="spriteBatch">Sprite batch to draw on.</param> /// <param name="phase">The phase we are currently drawing.</param> override protected void DrawEntity(SpriteBatch spriteBatch, DrawPhase phase) { // get outline width int outlineWidth = OutlineWidth; // draw outline if (outlineWidth > 0) { Rectangle outlineDest = _destRect; outlineDest.X -= outlineWidth; outlineDest.Y -= outlineWidth; outlineDest.Width += outlineWidth * 2; outlineDest.Height += outlineWidth * 2; spriteBatch.Draw(Resources.WhiteTexture, outlineDest, OutlineColor); } // get fill color Color fill = FillColor; // draw the rectangle spriteBatch.Draw(Resources.WhiteTexture, _destRect, fill); // call base draw function base.DrawEntity(spriteBatch, phase); }
/// <summary> /// Draw the entity. /// </summary> /// <param name="spriteBatch">Sprite batch to draw on.</param> /// <param name="phase">The phase we are currently drawing.</param> override protected void DrawEntity(SpriteBatch spriteBatch, DrawPhase phase) { // get progressbar frame width float progressbarFrameWidth = Resources.ProgressBarData.FrameWidth; // draw progress bar frame Texture2D barTexture = Resources.ProgressBarTexture; UserInterface.Active.DrawUtils.DrawSurface(spriteBatch, barTexture, _destRect, new Vector2(progressbarFrameWidth, 0f), 1, FillColor); // calc frame actual height and scaling factor (this is needed to calc frame width in pixels) Vector2 frameSizeTexture = new Vector2(barTexture.Width * progressbarFrameWidth, barTexture.Height); Vector2 frameSizeRender = frameSizeTexture; float ScaleXfac = _destRect.Height / frameSizeRender.Y; // calc frame width in pixels _frameActualWidth = progressbarFrameWidth * barTexture.Width * ScaleXfac; // update the progress bar color and size int markWidth = (int)((_destRect.Width - _frameActualWidth * 2) * GetValueAsPercent()); ProgressFill.Offset = (new Vector2(_frameActualWidth / GlobalScale, 0)); ProgressFill.Size = new Vector2(markWidth, _destRectInternal.Height) / GlobalScale; ProgressFill.Visible = markWidth > 0; }
/// <summary> /// Draw the entity. /// </summary> /// <param name="spriteBatch">Sprite batch to draw on.</param> /// <param name="phase">The phase we are currently drawing.</param> override protected void DrawEntity(SpriteBatch spriteBatch, DrawPhase phase) { // get texture based on checkbox / mouse state Texture2D texture = GetTexture(); // calculate actual size Vector2 actualSize = CHECKBOX_SIZE * GlobalScale; // dest rect Rectangle dest = new Rectangle(_destRect.X, (int)(_destRect.Y + _destRect.Height / 2 - actualSize.Y / 2), (int)(actualSize.X), (int)(actualSize.Y)); dest = _userinterface.Active.DrawUtils.ScaleRect(dest, Scale); // source rect Rectangle src = new Rectangle(0, 0, texture.Width, texture.Height); // draw checkbox spriteBatch.Draw(texture, dest, src, FillColor); // call base draw function base.DrawEntity(spriteBatch, phase); }
bool IUIElementDrawFilter.DrawElement(DrawPhase drawPhase, ref UIElementDrawParams drawParams) { switch (drawPhase) { case DrawPhase.BeforeDrawImage: ImageUIElement imageElement = (ImageUIElement)drawParams.Element; Image image = imageElement.Image; int availableHeight = drawParams.Element.RectInsideBorders.Height; float ratio = (float)availableHeight / (float)image.Height; float newHeight = image.Height * ratio; float newWidth = image.Width * ratio; Rectangle rect = new Rectangle( imageElement.Rect.X, imageElement.Rect.Y, (int)(newWidth), (int)(newHeight) ); // Draw the scaled image. drawParams.Graphics.DrawImage(image, rect); // This tells the grid not to draw the image (since we've already drawn it). return(true); } return(false); }
/// <summary> /// Draw the entity. /// </summary> /// <param name="spriteBatch">Sprite batch to draw on.</param> /// <param name="phase">The phase we are currently drawing.</param> override protected void DrawEntity(SpriteBatch spriteBatch, DrawPhase phase) { // get mouse state for graphics EntityState state = _entityState; if (Checked) { state = EntityState.MouseDown; } // get texture based on skin and state Texture2D texture = _customSkin == null ? Resources.ButtonTextures[_skin, state] : _customSkin[(int)state]; // get frame width TextureData data = Resources.ButtonData[(int)_skin]; Vector2 frameSize = _customSkin == null ? new Vector2(data.FrameWidth, data.FrameHeight) : _customFrame; // draw the button background with frame if (frameSize.Length() > 0) { float scale = frameSize.Y > 0 ? Scale : 1f; UserInterface.Active.DrawUtils.DrawSurface(spriteBatch, texture, _destRect, frameSize, 1, FillColor, scale); } // draw the button background without frame (just stretch texture) else { UserInterface.Active.DrawUtils.DrawImage(spriteBatch, texture, _destRect, FillColor, 1); } // call base draw function base.DrawEntity(spriteBatch, phase); }
public void RefreshActiveMap(DrawPhase drawPhase) { if (_activeDataView == null) { return; } if (_activeDataView.MapView == null || _refreshing) { return; } _refreshing = true; //_activeDataView.MapView.RefreshMap(drawPhase); TimeSpan ts = DateTime.Now - _lastRefresh; if (ts.TotalMilliseconds < 300) { _appWindow.Cursor = System.Windows.Input.Cursors.Wait; //MessageBox.Show("Slower... !!!"); Thread.Sleep((int)(300 - ts.TotalMilliseconds)); _appWindow.Cursor = System.Windows.Input.Cursors.Arrow; } _activeDataView.MapView.RefreshCopyrightVisibility(); _lastRefresh = DateTime.Now; Thread thread = new Thread(new ParameterizedThreadStart(this.RefreshActiveMapThread)); thread.Start(drawPhase); _refreshing = false; }
/// <summary> /// Draws the element. /// </summary> /// <param name="drawPhase">The draw phase.</param> /// <param name="drawParams">The draw parameters.</param> /// <returns></returns> public bool DrawElement(DrawPhase drawPhase, ref UIElementDrawParams drawParams) { UIElement element = drawParams.Element; if (drawPhase == DrawPhase.BeforeDrawBorders) { Border3DSide sides = (Border3DSide)0; if (element is DayHeaderAreaUIElement) { sides = Border3DSide.Top | Border3DSide.Bottom; } else if (element is DayHeaderUIElement) { sides = Border3DSide.Bottom; } if (sides != 0) { if ((sides & Border3DSide.Top) != 0) { drawParams.DrawBorders(UIElementBorderStyle.Solid, Border3DSide.Top); } if ((sides & Border3DSide.Bottom) != 0) { drawParams.DrawBorders(UIElementBorderStyle.TwoColor, Border3DSide.Bottom); } return(true); } } return(false); }
/// <summary> /// Draw the entity. /// </summary> /// <param name="spriteBatch">Sprite batch to draw on.</param> /// <param name="phase">The phase we are currently drawing.</param> override protected void DrawEntity(SpriteBatch spriteBatch, DrawPhase phase) { // if needed, recalc max (but not if currently interacting with this object). if (UserInterface.Active.ActiveEntity != this) { CalcAutoMaxValue(); } // get textures based on type Texture2D texture = Resources.VerticalScrollbarTexture; Texture2D markTexture = Resources.VerticalScrollbarMarkTexture; float FrameHeight = Resources.VerticalScrollbarData.FrameHeight; // draw scrollbar body UserInterface.Active.DrawUtils.DrawSurface(spriteBatch, texture, _destRect, new Vector2(0f, FrameHeight), 1, FillColor); // calc frame actual height and scaling factor (this is needed to calc frame width in pixels) Vector2 frameSizeTexture = new Vector2(texture.Width, texture.Height * FrameHeight); Vector2 frameSizeRender = frameSizeTexture; float ScaleYfac = _destRect.Width / frameSizeRender.X; // calc the size of the mark piece int markWidth = _destRect.Width; _markHeight = (int)(((float)markTexture.Height / (float)markTexture.Width) * (float)markWidth); // calc frame width in pixels _frameActualHeight = FrameHeight * texture.Height * ScaleYfac; // now draw mark float markY = _destRect.Y + _frameActualHeight + _markHeight * 0.5f + (_destRect.Height - _frameActualHeight * 2 - _markHeight) * (GetValueAsPercent()); Rectangle markDest = new Rectangle(_destRect.X, (int)System.Math.Round(markY) - _markHeight / 2, markWidth, _markHeight); UserInterface.Active.DrawUtils.DrawImage(spriteBatch, markTexture, markDest, FillColor); }
public bool DrawElement(DrawPhase drawPhase, ref UIElementDrawParams drawParams) { // draw after the element theme as been drawn if (DrawPhase.AfterDrawTheme == drawPhase) { // get the button element var buttonElement = drawParams.Element as ButtonUIElementBase; if (buttonElement != null) { // get the button control and current button state var dropDown = drawParams.ControlElement.Control as UltraDropDownButton; //var buttonState = buttonElement.ButtonState; var buttonState = UIElementButtonState.MouseOver; if (!dropDown.IsDroppedDown && !buttonElement.IsMouseOver) { XPThemes.ToolBar.DrawToolbarButton( false, drawParams.Element is SplitButtonDropDownUIElement, buttonState, ref drawParams, drawParams.Element.Rect, drawParams.InvalidRect); } } } return false; }
/// <summary> /// Draw the entity. /// </summary> /// <param name="spriteBatch">Sprite batch to draw on.</param> /// <param name="phase">The phase we are currently drawing.</param> override protected void DrawEntity(SpriteBatch spriteBatch, DrawPhase phase) { if (SelectedIndex == -1 && _selectedTextParagraph.Text != _placeholderText) { _selectedTextParagraph.Text = _placeholderText; } }
/// <summary> /// Draw the entity. /// </summary> /// <param name="spriteBatch">Sprite batch to draw on.</param> /// <param name="phase">The phase we are currently drawing.</param> override protected void DrawEntity(SpriteBatch spriteBatch, DrawPhase phase) { // draw background if (DrawBackground) { // get background color based on phase Color backColor = Color.White; switch (phase) { case DrawPhase.Base: backColor = GetActiveStyle("BackgroundColor").asColor; break; case DrawPhase.Outline: backColor = OutlineColor; break; case DrawPhase.Shadow: backColor = ShadowColor; break; } // get background dest rect Rectangle dest = _destRect; dest.X -= BackgroundSize / 2; dest.Y -= BackgroundSize / 2; dest.Width += BackgroundSize; dest.Height += BackgroundSize; // draw background UserInterface.Active.DrawUtils.DrawImage(spriteBatch, Resources.IconBackgroundTexture, dest, backColor); } // now draw the image itself base.DrawEntity(spriteBatch, phase); }
/// <summary> /// Draw the entity. /// </summary> /// <param name="spriteBatch">Sprite batch to draw on.</param> /// <param name="phase">The phase we are currently drawing.</param> override protected void DrawEntity(SpriteBatch spriteBatch, DrawPhase phase) { // get textures based on skin Texture2D texture = Resources.SliderTextures[_skin]; Texture2D markTexture = Resources.SliderMarkTextures[_skin]; // get slider metadata DataTypes.TextureData data = Resources.SliderData[(int)_skin]; float frameWidth = data.FrameWidth; // draw slider body UserInterface.Active.DrawUtils.DrawSurface(spriteBatch, texture, _destRect, new Vector2(frameWidth, 0f), 1, FillColor); // calc frame actual height and scaling factor (this is needed to calc frame width in pixels) Vector2 frameSizeTexture = new Vector2(texture.Width * frameWidth, texture.Height); Vector2 frameSizeRender = frameSizeTexture; float ScaleXfac = _destRect.Height / frameSizeRender.Y; // calc the size of the mark piece int markHeight = _destRect.Height; _markWidth = (int)(((float)markTexture.Width / (float)markTexture.Height) * (float)markHeight); // calc frame width in pixels _frameActualWidth = frameWidth * texture.Width * ScaleXfac; // now draw mark float markX = _destRect.X + _frameActualWidth + _markWidth * 0.5f + (_destRect.Width - _frameActualWidth * 2 - _markWidth) * GetValueAsPercent(); Rectangle markDest = new Rectangle((int)System.Math.Round(markX) - _markWidth / 2, _destRect.Y, _markWidth, markHeight); UserInterface.Active.DrawUtils.DrawImage(spriteBatch, markTexture, markDest, FillColor); // call base draw function base.DrawEntity(spriteBatch, phase); }
public Task RefreshActiveMap(DrawPhase drawPhase) { if (_activeDataView == null) { return(Task.CompletedTask); } if (_activeDataView.MapView == null) { return(Task.CompletedTask); } lock (refreshLock) { TimeSpan ts = DateTime.Now - _lastRefresh; if (ts.TotalMilliseconds < 300) { _appWindow.Cursor = System.Windows.Input.Cursors.Wait; //MessageBox.Show("Slower... !!!"); Thread.Sleep((int)(300 - ts.TotalMilliseconds)); _appWindow.Cursor = System.Windows.Input.Cursors.Arrow; } _activeDataView.MapView.RefreshCopyrightVisibility(); _lastRefresh = DateTime.Now; Task.Run(async() => { await this.RefreshActiveMapThread(drawPhase); }); } return(Task.CompletedTask); }
bool IUIElementDrawFilter.DrawElement(DrawPhase drawPhase, ref UIElementDrawParams drawParams) { this.DrawBorder(ref drawParams, Border3DSide.Left, this.borderColorLeft); this.DrawBorder(ref drawParams, Border3DSide.Right, this.borderColorRight); this.DrawBorder(ref drawParams, Border3DSide.Top, this.borderColorTop); this.DrawBorder(ref drawParams, Border3DSide.Bottom, this.borderColorBottom); return(false); }
public bool DrawElement(DrawPhase drawPhase, ref UIElementDrawParams drawParams) { // 포커스 사각형을 그리지 않음. if (drawPhase == DrawPhase.BeforeDrawFocus) { return(true); } // RowSelector if (drawParams.Element is RowSelectorUIElement) { this.DrawElement_RowSelectorUIElement(ref drawParams); return(true); } // RowSelector Header if (drawParams.Element is RowSelectorHeaderUIElement) { this.DrawElement_RowSelectorHeaderUIElement(ref drawParams); return(true); } // ComboBox ArrowButton (Code Type) if (drawParams.Element is EditorWithComboDropDownButtonUIElement) { this.DrawElement_EditorWithComboDropDownButtonUIElement(ref drawParams); return(true); } // Sort Indicator(Arrow) if (drawParams.Element is SortIndicatorUIElement) { this.DrawElement_SortIndicatorUIElement(ref drawParams); return(true); } // filter button if (drawParams.Element is FilterDropDownButtonUIElement) { this.DrawElement_FilterDropDownButtonUIElement(ref drawParams); return(true); } // Tab (동작안됨) if (drawParams.Element is TabItemUIElement) { if (drawPhase == DrawPhase.BeforeDrawBorders) { this.orginialSmoothingMode = drawParams.Graphics.SmoothingMode; drawParams.Graphics.SmoothingMode = SmoothingMode.AntiAlias; } else if (drawPhase == DrawPhase.AfterDrawBorders) { drawParams.Graphics.SmoothingMode = this.orginialSmoothingMode; } } return(false); }
/// <summary> /// Draw the entity. /// </summary> /// <param name="spriteBatch">Sprite batch to draw on.</param> /// <param name="phase">The phase we are currently drawing.</param> override protected void DrawEntity(SpriteBatch spriteBatch, DrawPhase phase) { // call base draw function to draw the panel part base.DrawEntity(spriteBatch, phase); // get which paragraph we currently show - real or placeholder bool showPlaceholder = !(IsFocused || _value.Length > 0); Paragraph currParagraph = showPlaceholder ? PlaceholderParagraph : TextParagraph; // get actual processed string _actualDisplayText = PrepareInputTextForDisplay(showPlaceholder, IsFocused); // for multiline only - handle scrollbar visibility and max if (_multiLine && (_actualDisplayText != null) && (_destRectInternal.Height > 0)) { // get how many lines can fit in the textbox and how many lines display text actually have int linesFit = _destRectInternal.Height / (int)(System.Math.Max(currParagraph.LineHeightY(), 1)); int linesInText = _actualDisplayText.Split('\n').Length; // if there are more lines than can fit, show scrollbar and manage scrolling: if (linesInText > linesFit) { // fix paragraph width to leave room for the scrollbar float prevWidth = currParagraph.Size.X; currParagraph.Size = new Vector2(_destRectInternal.Width / GlobalScale - 20, 0); if (currParagraph.Size.X != prevWidth) { // update size and re-calculate lines in text _actualDisplayText = PrepareInputTextForDisplay(showPlaceholder, IsFocused); linesInText = _actualDisplayText.Split('\n').Length; } // set scrollbar max and steps _scrollbar.Max = (uint)System.Math.Max(linesInText - linesFit, 2); _scrollbar.StepsCount = _scrollbar.Max; _scrollbar.Visible = true; // update text to fit scrollbar. first, rebuild the text with just the visible segment List <string> lines = new List <string>(_actualDisplayText.Split('\n')); int from = System.Math.Min(_scrollbar.Value, lines.Count - 1); int size = System.Math.Min(linesFit, lines.Count - from); lines = lines.GetRange(from, size); _actualDisplayText = string.Join("\n", lines); currParagraph.Text = _actualDisplayText; } // if no need for scrollbar make it invisible else { currParagraph.Size = Vector2.Zero; _scrollbar.Visible = false; } } // set placeholder and main text visibility based on current value TextParagraph.Visible = !showPlaceholder; PlaceholderParagraph.Visible = showPlaceholder; }
async public Task RefreshActiveMap(DrawPhase drawPhase) { if (_application is IMapApplication) { await((IMapApplication)_application).RefreshActiveMap(drawPhase); } else if (_control != null) { await _control.RefreshMap(); } }
protected override void Draw(GameTime gameTime) { dPhase = DrawPhase.Trans; //draw translated stuff on the target Matrix translator = Matrix.CreateTranslation(translation.X, translation.Y, 0); GraphicsDevice.SetRenderTarget(rt); spriteBatch.Begin(transformMatrix: translator, samplerState: SamplerState.PointWrap); switch (gm) { case (GameMode.TilesetEditor): DrawEditor(); break; case (GameMode.Game): DrawGame(); break; case (GameMode.Menus): DrawMenus(); break; } spriteBatch.End(); dPhase = DrawPhase.NonTrans; GraphicsDevice.SetRenderTarget(nonTransRt); GraphicsDevice.Clear(Color.TransparentBlack); spriteBatch.Begin(samplerState: SamplerState.PointWrap); switch (gm) { case (GameMode.TilesetEditor): DrawEditor(); break; case (GameMode.Game): DrawGame(); break; case (GameMode.Menus): DrawMenus(); break; } cursor.Draw(spriteBatch, mousePos, 1f, false); spriteBatch.End(); //draw overlay GraphicsDevice.SetRenderTarget(null); //draw the non translated target Matrix scaler = Matrix.CreateScale(scale.X, scale.Y, 0); spriteBatch.Begin(transformMatrix: scaler); spriteBatch.Draw(rt, rtPos, null); spriteBatch.Draw(nonTransRt, rtPos, null); spriteBatch.End(); base.Draw(gameTime); }
/// <summary> /// Draw the entity. /// </summary> /// <param name="spriteBatch">Sprite batch to draw on.</param> /// <param name="phase">The phase we are currently drawing.</param> override protected void DrawEntity(SpriteBatch spriteBatch, DrawPhase phase) { // update processed text if needed if (_processedText == null) { UpdateDestinationRects(); } // draw background color if (BackgroundColor.A > 0) { // get background color Color backColor = UserInterface.Active.DrawUtils.FixColorOpacity(BackgroundColor); // get destination rect to draw it var rect = BackgroundColorUseBoxSize ? _destRect : _actualDestRect; // fix height for box background and scaling if (BackgroundColorUseBoxSize) { rect.Height = (int)(rect.Height / GlobalScale); } // add padding var padding = new Point( (int)(BackgroundColorPadding.X * GlobalScale), (int)(BackgroundColorPadding.Y * GlobalScale)); rect.Location -= padding; rect.Size += padding + padding; // draw background color spriteBatch.Draw(Resources.WhiteTexture, rect, backColor); } // draw outilnes //int outlineWidth = OutlineWidth; //if (outlineWidth > 0) //{ // DrawTextOutline(spriteBatch, outlineWidth); //} // get fill color Color fillCol = UserInterface.Active.DrawUtils.FixColorOpacity(FillColor); // draw text itself //spriteBatch.DrawString(_currFont, _processedText, _position, fillCol, // 0, _fontOrigin, _actualScale, SpriteEffects.None, 0.5f); CustomUitls.DrawParagraph(spriteBatch, UserInterface.unifont, _processedText, _position - _fontOrigin, fillCol, _destRect.Width, (int)UserInterface.fontSize.Y); // call base draw function base.DrawEntity(spriteBatch, phase); }
/// <summary> /// Draw the entity. /// </summary> /// <param name="spriteBatch">Sprite batch to draw on.</param> /// <param name="phase">The phase we are currently drawing.</param> override protected void DrawEntity(SpriteBatch spriteBatch, DrawPhase phase) { // get line texture Texture2D texture = Resources.HorizontalLineTexture; // draw panel UserInterface.Active.DrawUtils.DrawSurface(spriteBatch, texture, _destRect, FRAME_WIDTH, 1, FillColor); // call base draw function base.DrawEntity(spriteBatch, phase); }
public bool DrawElement(DrawPhase drawPhase, ref UIElementDrawParams drawParams) { // Draw a custom border around ButtonToolUIElements ButtonToolUIElement buttonToolUiElement = drawParams.Element as ButtonToolUIElement; if (buttonToolUiElement != null && drawPhase == DrawPhase.BeforeDrawBorders) { drawParams.DrawBorders(UIElementBorderStyle.Solid, Border3DSide.All); return(true); } return(false); }
public void RefreshActiveMap(DrawPhase drawPhase) { if (_application is IMapApplication) { ((IMapApplication)_application).RefreshActiveMap(drawPhase); } else if (_control != null) { _control.RefreshMap(); } }
/// <summary> /// Called during the drawing operation of a UIElement for a specific phase /// of the operation. This will only be called for the phases returned /// from the GetPhasesToFilter method. /// </summary> /// <param name="drawPhase">Contains a single bit which identifies the current draw phase.</param> /// <param name="drawParams">Exposes properties required for drawing an element (e.g. Element, Graphics, InvalidRect etc.)</param> /// <returns> /// Returning true from this method indicates that this phase has been handled and the default processing should be skipped. /// </returns> bool IUIElementDrawFilter.DrawElement(DrawPhase drawPhase, ref UIElementDrawParams drawParams) { UltraTreeNode treeNode = drawParams.Element.GetContext(typeof(UltraTreeNode), true) as UltraTreeNode; if (treeNode != null) { var scale = (float)drawParams.ControlElement.Control.DeviceDpi / 96; var sz300 = (int)(300 * scale); TreeFeedsNodeBase feedsNode = treeNode as TreeFeedsNodeBase; if (drawPhase == DrawPhase.AfterDrawElement && feedsNode != null && feedsNode.Control != null) { int unread = feedsNode.UnreadCount; if (unread > 0) { // this image width is a workaround to extend the nods's clickable // area to include the unread count visual representation... int clickableAreaExtenderImageWidth = feedsNode.Control.RightImagesSize.Width; string st = String.Format("({0})", unread); Rectangle ur = drawParams.Element.RectInsideBorders; using (Brush unreadColorBrush = new SolidBrush(FontColorHelper.UnreadCounterColor)) { drawParams.Graphics.DrawString(st, FontColorHelper.UnreadCounterFont, unreadColorBrush, ur.X + ur.Width - clickableAreaExtenderImageWidth, ur.Y, StringFormat.GenericDefault); } return(true); } return(false); } if (treeNode.Level == 0) { RectangleF initialRect = drawParams.Element.RectInsideBorders; RectangleF r = new RectangleF(initialRect.Left, initialRect.Top, 0, 0); // this SHOULD be the horizontal scrolling area, but how do we get this (?): r.Width = treeNode.Control.DisplayRectangle.Width + sz300; r.Height = treeNode.ItemHeightResolved; TreeFeedsNodeGroupHeaderPainter.PaintOutlook2003Header(drawParams.Graphics, r); return(true); } } // To return FALSE from this method indicates that the element should draw itself as normal. // To return TRUE from this method indicates that the element should not draw itself. // Return true to prevent further drawing by the element return(false); }
bool IUIElementDrawFilter.DrawElement(DrawPhase drawPhase, ref UIElementDrawParams drawParams) { if (drawParams.Element is EditorWithTextDisplayTextUIElement && this.image != null) { int offset = drawParams.Element.Rect.Y + (drawParams.Element.Rect.Height - this.image.Height) / 2; Point p = new Point(drawParams.Element.Rect.X + drawParams.Element.Rect.Width - offset - this.image.Width, offset); Rectangle r = new Rectangle(p, new Size(this.image.Width, this.image.Height)); drawParams.Graphics.CompositingMode = CompositingMode.SourceOver; drawParams.Graphics.CompositingQuality = CompositingQuality.HighQuality; drawParams.Graphics.DrawImage(this.image, r, new Rectangle(new Point(0, 0), this.image.Size), GraphicsUnit.Pixel); } return(false); }
public bool DrawElement(DrawPhase drawPhase, ref UIElementDrawParams drawParams) { GroupByRowDescriptionUIElement element = (GroupByRowDescriptionUIElement)drawParams.Element; if (element.GroupByRow.Value is int) { int value = (int)element.GroupByRow.Value; if (value % 2 == 0) { drawParams.AppearanceData.ForeColor = Color.Orange; } } return(false); }
/// <summary> /// Called during the drawing operation of a UIElement for a specific phase /// of the operation. This will only be called for the phases returned /// from the GetPhasesToFilter method. /// </summary> /// <param name="drawPhase">Contains a single bit which identifies the current draw phase.</param> /// <param name="drawParams">The <see cref="T:Infragistics.Win.UIElementDrawParams" /> used to provide rendering information.</param> /// <returns> /// Returning true from this method indicates that this phase has been handled and the default processing should be skipped. /// </returns> /// <exception cref="System.NotImplementedException"></exception> public bool DrawElement(DrawPhase drawPhase, ref UIElementDrawParams drawParams) { switch (drawPhase) { case DrawPhase.BeforeDrawBorders: if (drawParams.Element is HeaderUIElement) { drawParams.DrawBorders(UIElementBorderStyle.TwoColor, System.Windows.Forms.Border3DSide.Bottom); return(true); } break; } return(false); }
private void SetUpPhases() { drawPhase = new DrawPhase(players); actionPhase = new ActionPhase(players); encounterPhase = new EncounterPhase(players); actionPhase2 = new ActionPhase(players); cleanUpPhase = new CleanUpPhase(players); drawPhase.NextPhase = actionPhase; actionPhase.NextPhase = encounterPhase; encounterPhase.NextPhase = actionPhase2; actionPhase2.NextPhase = cleanUpPhase; cleanUpPhase.NextPhase = drawPhase; actionPhase.PhaseNumber = 1; actionPhase2.PhaseNumber = 2; }
/// <summary> /// Draw the entity. /// </summary> /// <param name="spriteBatch">Sprite batch to draw on.</param> /// <param name="phase">The phase we are currently drawing.</param> override protected void DrawEntity(SpriteBatch spriteBatch, DrawPhase phase) { // draw panel itself, but only if got style if (_skin != PanelSkin.None) { // get texture based on skin Texture2D texture = _customTexture ?? Resources.PanelTextures[_skin]; TextureData data = Resources.PanelData[(int)_skin]; Vector2 frameSize = _customFrame ?? new Vector2(data.FrameWidth, data.FrameHeight); // draw panel UserInterface.Active.DrawUtils.DrawSurface(spriteBatch, texture, _destRect, frameSize, 1f, FillColor, Scale); } // call base draw function base.DrawEntity(spriteBatch, phase); }
/// <summary> /// This method is passed the same UIElementDrawParams structure as GetPhasesToFilter() and a bit flag indicating /// which single draw phase is being performed. The method returns a boolean. If false is returned then the default /// drawing for that phase will be performed. If true is returned for a 'Before' phase then the default drawing /// for that phase will be skipped. Note: returning true for the BeforeDrawElement phase will cause all the other /// phases to be skipped (even if bits for those phases were returned by the call to GetPhasesToFilter). /// Also, if themes are active, returning true for the BeforeDrawTheme phase will skip all phases up to but not /// including the BeforeDrawChildElements phase. The BeforeDrawFocus phase is only called if the control has focus /// (or the forceDrawAsFocused parameter was set to true on the call to the Draw method) and the element's virtual /// DrawsFocusRect property returns true. /// </summary> public bool DrawElement(DrawPhase drawPhase, ref UIElementDrawParams drawParams) { // The TextHAlign set on the label must be honored, so we setup a StringFormat // to use when drawing the text. HAlign align = drawParams.AppearanceData.TextHAlign; StringFormat frmt = new StringFormat(); if (align == HAlign.Left) { frmt.Alignment = StringAlignment.Near; } else if (align == HAlign.Center) { frmt.Alignment = StringAlignment.Center; } else if (align == HAlign.Right) { frmt.Alignment = StringAlignment.Far; } // Draw the text. drawParams.Graphics.DrawString( _text.ToString(), drawParams.Font, drawParams.TextBrush, drawParams.Element.RectInsideBorders, frmt ); if (!_hasScrolled) { // Rearrange the characters in our private copy of the label's Text so that the next // time we draw the string it will be "scrolled" by one character. UpdateText(); // Since we only want to scroll the text once per tick of the timer, // set this flag now to prevent this block of code from executing until the next tick. _hasScrolled = true; } // Returning true prevents the text we just drew from being drawn over. return(true); }
/// <summary> /// Draw the entity. /// </summary> /// <param name="spriteBatch">Sprite batch to draw on.</param> /// <param name="phase">The phase we are currently drawing.</param> override protected void DrawEntity(SpriteBatch spriteBatch, DrawPhase phase) { // negate parent's padding _internalRoot.Padding = -Parent.Padding; // recalculate the size of the panel containing the internal panels float buttonsHeight = GetButtonsHeight(false); _panelsPanel.SetOffset(new Vector2(0, buttonsHeight)); // adjust size var parentSize = GetActualDestRect().Size; _internalRoot.Size = new Vector2(parentSize.X, parentSize.Y - GetButtonsHeight(true)) / GlobalScale; // call base draw function base.DrawEntity(spriteBatch, phase); }
/// <summary> /// Called during the drawing operation of a UIElement for a specific phase /// of the operation. This will only be called for the phases returned /// from the GetPhasesToFilter method. /// </summary> /// <param name="drawPhase">Contains a single bit which identifies the current draw phase.</param> /// <param name="drawParams">The <see cref="T:Infragistics.Win.UIElementDrawParams" /> used to provide rendering information.</param> /// <returns> /// Returning true from this method indicates that this phase has been handled and the default processing should be skipped. /// </returns> /// <exception cref="System.NotImplementedException"></exception> public bool DrawElement(DrawPhase drawPhase, ref UIElementDrawParams drawParams) { switch (drawPhase) { case DrawPhase.BeforeDrawBackColor: EditorButtonUIElement editorButtonUIElement = drawParams.Element as EditorButtonUIElement; if (editorButtonUIElement != null && editorButtonUIElement.IsMouseOver && !editorButtonUIElement.IsMouseDown) { drawParams.AppearanceData.BackColor = System.Drawing.Color.FromArgb(211, 211, 211); } break; } return(false); }
public bool DrawElement(DrawPhase drawPhase, ref UIElementDrawParams drawParams) { return drawPhase == DrawPhase.BeforeDrawBorders || drawPhase == DrawPhase.BeforeDrawFocus; }
public bool DrawElement(DrawPhase drawPhase, ref UIElementDrawParams drawParams) { return true; }