Inheritance: AbstractCareTool
Exemplo n.º 1
1
        public Button(string pText, float pX, float pY, float pWidth, float pHeight, bool pSmall)
        {
            width = pWidth;
            height = pHeight;
            x = pX;
            y = pY;

            // Text properties
            var brushProp = new LinearGradientBrushProperties();
            brushProp.StartPoint = new Vector2(x, y);
            brushProp.EndPoint = new Vector2(x, y + height);

            var stops = new GradientStop[2];
            stops[0] = new GradientStop() { Color = new Color4(1, 1, 1, 0.5f), Position = 0 };
            stops[1] = new GradientStop() { Color = new Color4(1, 1, 1, 1.0f), Position = 1 };

            textBrush = new LinearGradientBrush(GraphicsWindow.Instance.RenderTarget2D, brushProp, new GradientStopCollection(GraphicsWindow.Instance.RenderTarget2D, stops));
            textLayout = new TextLayout(Factories.FactoryWrite, pText, pSmall? Constants.SmallFont : Constants.RegularFont, width, height);

            // Frame properties
            borderBrush = new SolidColorBrush(GraphicsWindow.Instance.RenderTarget2D, new Color4(0, 0, 0, 0.3f));
            backBrush = new SolidColorBrush(GraphicsWindow.Instance.RenderTarget2D, new Color4(0.1f, 0.3f, 0.4f, 0.5f));
            highlightBrush = new SolidColorBrush(GraphicsWindow.Instance.RenderTarget2D, new Color4(0.2f, 0.6f, 0.8f, 0.5f));
            highlight = false;
        }
 private void DrawRectangle(Brush brush, float width, float height, float lineWidth) {
     surfaceGraphics.FillRectangle(brush,
         -width / 2f - lineWidth,
         -height / 2f - lineWidth,
         width + 2f * lineWidth,
         height + 2f * lineWidth);
 }
Exemplo n.º 3
0
 public Brush(Brush brush)
 {
     Color = brush.Color;
     Background = brush.Background;
     BitmapId = brush.BitmapId;
     FillStyle = brush.FillStyle;
 }
Exemplo n.º 4
0
 public PieChart(float fltCount, float fltTotal, Color c)
 {
     this.fltCount = fltCount;
     this.fltTotal = fltTotal;
     this.colorSlice = c;
     this.brushSlice = new SolidBrush(c);
 }
        private System.Drawing.Brush BrushToNativeBrush(Brush brush)
        {
            if (brush is SolidBrush)
            {
                return new System.Drawing.SolidBrush(ColorToNativeColor((brush as SolidBrush).Color));
            }
            else if (brush is LinearGradientBrush)
            {
                LinearGradientBrush b = (brush as LinearGradientBrush);
                System.Drawing.Drawing2D.LinearGradientBrush lgb = new System.Drawing.Drawing2D.LinearGradientBrush(RectangleToNativeRectangleF(b.Bounds), ColorToNativeColor(b.ColorStops[0].Color), ColorToNativeColor(b.ColorStops[b.ColorStops.Count - 1].Color), LinearGradientBrushOrientationToLinearGradientMode(b.Orientation));
                if (b.ColorStops.Count > 2)
                {
                    List<System.Drawing.Color> colorList = new List<System.Drawing.Color>();
                    List<float> positionList = new List<float>();

                    for (int i = 0; i < b.ColorStops.Count; i++)
                    {
                        colorList.Add(ColorToNativeColor(b.ColorStops[i].Color));
                        positionList.Add((float)(b.ColorStops[i].Position.ConvertTo(MeasurementUnit.Decimal).Value));
                    }

                    System.Drawing.Drawing2D.ColorBlend blend = new System.Drawing.Drawing2D.ColorBlend(b.ColorStops.Count);
                    blend.Colors = colorList.ToArray();
                    blend.Positions = positionList.ToArray();
                    lgb.InterpolationColors = blend;
                }
                return lgb;
            }
            return null;
        }
	override protected void Awake() {
		base.Awake();
		
		wizard = GameObject.Find("Wizard").GetComponent<Wizard>();
		candy = GameObject.Find("Candy").GetComponent<Candy>();
		eraserBrush = GameObject.Find("EraserBrush").GetComponent<Brush>(); 
	}
Exemplo n.º 7
0
 public Brush Set(Brush brush)
 {
     Sprite = brush.Sprite;
     Angle = brush.Angle;
     Scale = brush.Scale;
     return this;
 }
Exemplo n.º 8
0
 /// <summary>
 /// Initializes a new instance of the <see cref="RectangleRenderUnit" /> class.
 /// </summary>
 /// <param name="rectangle">The rectangle.</param>
 /// <param name="stroke">The stroke.</param>
 /// <param name="fill">The fill.</param>
 /// <param name="thickness">The thickness.</param>
 public RectangleRenderUnit(RectangleF rectangle, Brush stroke, Brush fill, float thickness)
 {
     this.rectangle = rectangle;
     this.stroke = stroke;
     this.fill = fill;
     this.thickness = thickness;
 }
Exemplo n.º 9
0
		protected Element (Pen pen, Brush brush)
		{
			Id = "";
			Pen = pen;
			Brush = brush;
			Transform = NGraphics.Transform.Identity;
		}
Exemplo n.º 10
0
 public PerspexTextRenderer(
     RenderTarget target,
     Brush foreground)
 {
     this.renderTarget = target;
     this.foreground = foreground;
 }
 private void GenerateImage(
     HttpResponse response,
     string textToInsert,
     int width,
     int height,
     Color backgroundColor,
     FontFamily fontFamily,
     float emSize,
     Brush brush,
     float x,
     float y,
     string contentType,
     ImageFormat imageFormat)
 {
     using (Bitmap bitmap = new Bitmap(width, height))
     {
         using (Graphics graphics = Graphics.FromImage(bitmap))
         {
             graphics.Clear(backgroundColor);
             graphics.DrawString(textToInsert, new Font(fontFamily, emSize), brush, x, y);
             response.ContentType = contentType;
             bitmap.Save(response.OutputStream, imageFormat);
         }
     }
 }
Exemplo n.º 12
0
 public virtual void Initialize(DeviceManager deviceManager)
 {
     sceneColorBrush = new SolidColorBrush(deviceManager.ContextDirect2D, Color.Blue);
     textFormat = new TextFormat(deviceManager.FactoryDirectWrite, "Calibri", 20) { TextAlignment = TextAlignment.Leading, ParagraphAlignment = ParagraphAlignment.Center };
     clock = Stopwatch.StartNew();
     deviceManager.ContextDirect2D.TextAntialiasMode = TextAntialiasMode.Grayscale;
 }
Exemplo n.º 13
0
    public static Rectangle CreateRectangle(Brush brush)
    {
        Rectangle rt = new Rectangle();
        rt.Fill = brush;

        return rt;
    }
Exemplo n.º 14
0
        public virtual void Initialize(DeviceManager deviceManager)
        {

            sceneColorBrush = new SolidColorBrush(deviceManager.ContextDirect2D, Colors.White);

            clock = Stopwatch.StartNew();
        }
Exemplo n.º 15
0
 public Element(Pen pen, Brush brush)
 {
     Id = Guid.NewGuid ().ToString ();
     Pen = pen;
     Brush = brush;
     Transform = NGraphics.Transform.Identity;
 }
Exemplo n.º 16
0
 public Text(string text, Rect frame, Font font, TextAlignment alignment = TextAlignment.Left, Pen pen = null, Brush brush = null)
     : base(pen, brush)
 {
     String = text;
     Frame = frame;
     Font = font;
     Alignment = alignment;
 }
Exemplo n.º 17
0
		public Text (string text, Rect frame, Font font, TextAlignment alignment = TextAlignment.Left, Pen pen = null, Brush brush = null)
			: base (pen, brush)
		{
			Frame = frame;
			Font = font;
			Alignment = alignment;
			Spans = new List<TextSpan> { new TextSpan (text) };
		}
Exemplo n.º 18
0
		public Text (Rect frame, Font font, TextAlignment alignment = TextAlignment.Left, Pen pen = null, Brush brush = null)
			: base (pen, brush)
		{
			Frame = frame;
			Font = font;
			Alignment = alignment;
			Spans = new List<TextSpan> ();
		}
Exemplo n.º 19
0
 public static void CreateColors(DeviceManager deviceManager)
 {
     PlayerColor = new SolidColorBrush(deviceManager.ContextDirect2D, new Color4(0.0f, 0.8f, 0.0f, 1.0f));
     EnemyColor = new SolidColorBrush(deviceManager.ContextDirect2D, new Color4(0.8f, 0.0f, 0.0f, 1.0f));
     AdditionalColor = new SolidColorBrush(deviceManager.ContextDirect2D, new Color4(0.8f, 0.8f, 0.0f, 1.0f));
     BackgroundColor = new SolidColorBrush(deviceManager.ContextDirect2D, new Color4(0.0f, 0.0f, 0.0f, 1.0f));
     ObstaclesColor = new SolidColorBrush(deviceManager.ContextDirect2D, new Color4(1.0f, 1.0f, 1.0f, 1.0f));
 }
Exemplo n.º 20
0
 public BrushEditor(IEditorApplication application, Tilemap Tilemap, Tileset Tileset, string brushFile)
 {
     selection = new Selection();
     selection.Changed += OnSelectionChanged;
     this.application = application;
     this.Tilemap = Tilemap;
     brush = Brush.loadFromFile(brushFile, Tileset);
 }
Exemplo n.º 21
0
        public override void initContent(SurfaceImageSourceTarget target, DrawingSize pixelSize)
        {
            this.size = pixelSize;

            context = target.DeviceManager.ContextDirect2D;
            pixelBrush = new SolidColorBrush(context, color);
            dimmingBrush = new SolidColorBrush(context, new Color(0, 0, 0, 10));
        }
Exemplo n.º 22
0
 /// <summary>
 /// Initializes a new instance of the <see cref="EllipseRenderUnit" /> class.
 /// </summary>
 /// <param name="ellipse">The ellipse.</param>
 /// <param name="stroke">The stroke.</param>
 /// <param name="fill">The fill.</param>
 /// <param name="thickness">The thickness.</param>
 public EllipseRenderUnit(Ellipse ellipse, Brush stroke, Brush fill, float thickness)
 {
     this.ellipse = ellipse;
     this.bounds = new RectangleF(ellipse.Point.X - ellipse.RadiusX, ellipse.Point.Y - ellipse.RadiusY, ellipse.RadiusX * 2, ellipse.RadiusY * 2);
     this.stroke = stroke;
     this.fill = fill;
     this.thickness = thickness;
 }
		private void Start() {
			// Use large system be default
			_currentSystem = largeSystem;
			_usingLarge = true;
			_brush = largeBrush;

			// Ignore last painted state
			_lastPainted = new TileIndex(-1, -1);
		}
Exemplo n.º 24
0
 public AvaloniaTextRenderer(
     DrawingContext context,
     SharpDX.Direct2D1.RenderTarget target,
     Brush foreground)
 {
     _context = context;
     _renderTarget = target;
     _foreground = foreground;
 }
Exemplo n.º 25
0
        // 繪圖主要方法
        public virtual void Render(TargetBase target)
        {
            var context2D = target.DeviceManager.ContextDirect2D;

            context2D.BeginDraw();
            context2D.Clear(Color.White);

            var sizeX = (float)target.RenderTargetBounds.Width;
            var sizeY = (float)target.RenderTargetBounds.Height;

            try
            {
                if (MainPage.pointers != null)
                {
                    for (int j = 0; j < MainPage.pointers.Count; j++)
                    {
                        // Different color for touch points
                        lineColorBrush = new SolidColorBrush(context2D, MainPage.pointers[j].color);

                        for (int i = 0; i < MainPage.pointers[j].Pointers.Count; i++)
                        {
                            if (i == MainPage.pointers[j].Pointers.Count - 1)
                            {
                                float x = (float)MainPage.pointers[j].Pointers[i].X;
                                float y = (float)MainPage.pointers[j].Pointers[i].Y;
                                // Pointers info
                                context2D.DrawText(string.Format("PointerID:{0}\nX:{1}\nY:{2}\n{3}", MainPage.pointers[j].PointerId, x, y, MainPage.pointers[j].DeviceType.ToString())
                                    , textFormat, new RectangleF(x - 150, y - 100, x - 20, y - 20), sceneColorBrush);

                                // Draw horizontal line
                                context2D.DrawLine(new DrawingPointF(0, y), new DrawingPointF(context2D.PixelSize.Width, y), lineColorBrush);
                                // Draw vertical line
                                context2D.DrawLine(new DrawingPointF(x, 0), new DrawingPointF(x, context2D.PixelSize.Height), lineColorBrush);
                                // Draw a circle (and like a Crosshair :D )
                                ellipse = new Ellipse(new DrawingPointF(x, y), 30, 30);
                                context2D.DrawEllipse(ellipse, lineColorBrush);
                                continue;
                            }

                            var beginPoint = new DrawingPointF((float)MainPage.pointers[j].Pointers[i].X, (float)MainPage.pointers[j].Pointers[i].Y);
                            var endPoint = new DrawingPointF((float)MainPage.pointers[j].Pointers[i + 1].X, (float)MainPage.pointers[j].Pointers[i + 1].Y);
                            context2D.DrawLine(beginPoint, endPoint, lineColorBrush, 10, strokeStyle);
                        }
                    }

                    // Update pointers contacts
                    context2D.DrawText(string.Format("Pointers Count:{0}/{1}", MainPage.pointers.Count, TouchCapabilities.Contacts), textFormat2, new RectangleF(8, 30, 8 + 200, 30 + 16), sceneColorBrush);
                }

            }
            catch (Exception ex)
            {
                Debug.WriteLine("Error:" + ex);
            }

            context2D.EndDraw();
        }
    private WarningToaster(string messageEmail1, string messageAutor1, string messageTheme1, string messageEmail2, string messageAutor2, string messageTheme2, int timeActive , ToasterPosition position, ToasterAnimation animation, double margin)
  {
    InitializeComponent();

    Brush[] brushes = new Brush[] {
            new SolidColorBrush(Color.FromArgb(0xFF, 0x2D, 0x1E, 0x4B)),
            new SolidColorBrush(Color.FromArgb(0xFF, 0x7B, 0x25, 0xFA)),
            new SolidColorBrush(Color.FromArgb(0xFF, 0x71, 0x9F, 0x3F))
        };
    Random rnd = new Random();
    avatar1.Fill = brushes[rnd.Next(brushes.Length)];
    avatar2.Fill = brushes[rnd.Next(brushes.Length)];

    var msgAutor1 = (System.Windows.Documents.Run)WarningToasterInstance.FindName("autorname1");
    if (msgAutor1 != null) msgAutor1.Text = messageAutor1 ?? string.Empty;
    var msgTheme1 = (System.Windows.Documents.Run)WarningToasterInstance.FindName("themetext1");
    if (messageTheme1.Length >= 28)
    {
        if (msgTheme1 != null) msgTheme1.Text = messageTheme1.Substring(0, 27) + "..." ?? string.Empty;
    }
    else
    {
        if (msgTheme1 != null) msgTheme1.Text = messageTheme1 ?? string.Empty;
    }
    var msgEmail1 = (System.Windows.Documents.Run)WarningToasterInstance.FindName("emailtext1");
    if (msgEmail1 != null) msgEmail1.Text = messageEmail1 ?? string.Empty;
    var msgName1 = (System.Windows.Documents.Run)WarningToasterInstance.FindName("autorletter1");
    if (msgName1 != null) msgName1.Text = messageEmail1.Substring(0, 1).ToUpper() ?? string.Empty;

    var msgAutor2 = (System.Windows.Documents.Run)WarningToasterInstance.FindName("autorname2");
    if (msgAutor2 != null) msgAutor2.Text = messageAutor2 ?? string.Empty;
    var msgTheme2 = (System.Windows.Documents.Run)WarningToasterInstance.FindName("themetext2");
    if (messageTheme2.Length >= 28)
    {
        if (msgTheme2 != null) msgTheme2.Text = messageTheme2.Substring(0, 27) + "..." ?? string.Empty;
    }
    else
    {
        if (msgTheme1 != null) msgTheme2.Text = messageTheme2 ?? string.Empty;
    }
    var msgEmail2 = (System.Windows.Documents.Run)WarningToasterInstance.FindName("emailtext2");
    if (msgEmail2 != null) msgEmail2.Text = messageEmail2 ?? string.Empty;
    var msgName2 = (System.Windows.Documents.Run)WarningToasterInstance.FindName("autorletter2");
    if (msgName2 != null) msgName2.Text = messageEmail2.Substring(0, 1).ToUpper() ?? string.Empty;

    Storyboard story = ToastSupport.GetAnimation(animation, ref WarningToasterInstance, timeActive);
    story.Completed += (sender, args) => { this.Close(); };
    story.Begin(WarningToasterInstance);

    Dispatcher.BeginInvoke(DispatcherPriority.DataBind, new Action(() =>
    {
        var topLeftDict = ToastSupport.GetTopandLeft(position, this, margin);
        Top = topLeftDict["Top"];
        Left = topLeftDict["Left"];
    }));
  }
Exemplo n.º 27
0
 /// <summary>
 /// Remove border effect
 /// </summary>
 public static void RemoveBorderEffect(Shape shape, BorderStyles borderStyle, Double borderThickness, Brush lineColor)
 {   
     shape.Stroke = lineColor;
     shape.StrokeThickness = borderThickness;
     shape.StrokeStartLineCap = PenLineCap.Flat;
     shape.StrokeEndLineCap = PenLineCap.Flat;
     shape.StrokeDashOffset = 0;
     shape.StrokeLineJoin = PenLineJoin.Bevel;
     shape.StrokeDashArray = Graphics.LineStyleToStrokeDashArray(borderStyle.ToString());
 }
Exemplo n.º 28
0
    /// <summary>
    /// Remove border effect
    /// </summary>
    public static void RemoveBorderEffect(Shape shape, BorderStyles borderStyle, Double borderThickness, Brush lineColor, Brush fillColor, Double width, Double height)
    {
        RemoveBorderEffect(shape, borderStyle, borderThickness, lineColor);
        shape.Fill = fillColor;
        shape.Height = height;
        shape.Width = width;

        shape.SetValue(Canvas.TopProperty, -shape.Height / 2);
        shape.SetValue(Canvas.LeftProperty, -shape.Width / 2);
    }
Exemplo n.º 29
0
 /// <summary>
 /// Initializes a new instance of the <see cref="GeometryRenderUnit" /> class.
 /// </summary>
 /// <param name="geometry">The geometry.</param>
 /// <param name="stroke">The stroke.</param>
 /// <param name="fill">The fill.</param>
 /// <param name="strokeWidth">The stroke width.</param>
 /// <param name="strokeStyle">The stroke style.</param>
 public GeometryRenderUnit(Geometry geometry, Brush stroke, Brush fill, float strokeWidth, StrokeStyle strokeStyle)
 {
     this.geometry = geometry;
     this.fill = fill;
     this.stroke = stroke;
     this.strokeWidth = strokeWidth;
     this.strokeStyle = strokeStyle;
     var raw = geometry.GetBounds();
     this.bounds = new RectangleF(raw.Left, raw.Top, raw.Right - raw.Left, raw.Bottom - raw.Top);
 }
Exemplo n.º 30
0
    /// <summary>
    /// Apply border effect
    /// </summary>
    public static void ApplyBorderEffect(Shape shape, BorderStyles borderStyles, Brush fillColor, Double scaleFactor, Double borderThickness, Brush borderColor)
    {
        ApplyBorderEffect(shape, borderStyles, borderThickness, borderColor);
        shape.Fill = fillColor;
        shape.Height *= scaleFactor;
        shape.Width *= scaleFactor;

        shape.SetValue(Canvas.TopProperty, -shape.Height / 2);
        shape.SetValue(Canvas.LeftProperty, -shape.Width / 2);
    }
Exemplo n.º 31
0
 internal ColorizedRectangle(Rectangle rectangle, Brush fillBrush, Pen borderPen)
 {
     Rectangle = rectangle;
     FillBrush = fillBrush;
     BorderPen = borderPen;
 }
Exemplo n.º 32
0
 public BrushEditor(IEditorApplication application, Tileset Tileset, string brushFile)
     : base(application, Tileset, new Selection())
 {
     brush      = Brush.loadFromFile(brushFile, Tileset);
     ActionName = "Tile Brush";
 }
Exemplo n.º 33
0
 private static void RenderLoopAll(StateButton sender, DrawingContext context, Brush backgroundBrush)
 {
     RenderLoopOffAndAllIcon(sender, context, Brushes.Black, backgroundBrush);
 }
Exemplo n.º 34
0
        private static void DrawCurvedText(Graphics graphics, string text, Point centre, float distanceFromCentreToBaseOfText, float radiansToTextCentre, Font font, Brush brush)
        {
            // Circumference for use later
            var circleCircumference = (float)(Math.PI * 2 * distanceFromCentreToBaseOfText);

            // Get the width of each character
            var characterWidths = GetCharacterWidths(graphics, text, font).ToArray();

            // The overall height of the string
            var characterHeight = graphics.MeasureString(text, font).Height;

            var textLength = characterWidths.Sum();

            // The string length above is the arc length we'll use for rendering the string. Work out the starting angle required to
            // centre the text across the radiansToTextCentre.
            float fractionOfCircumference = textLength / circleCircumference;

            float currentCharacterRadians = radiansToTextCentre + (float)(Math.PI * fractionOfCircumference);

            for (int characterIndex = 0; characterIndex < text.Length; characterIndex++)
            {
                char @char = text[characterIndex];

                // Polar to cartesian
                float x = (float)(distanceFromCentreToBaseOfText * Math.Sin(currentCharacterRadians));
                float y = -(float)(distanceFromCentreToBaseOfText * Math.Cos(currentCharacterRadians));

                using (GraphicsPath characterPath = new GraphicsPath())
                {
                    characterPath.AddString(@char.ToString(), font.FontFamily, (int)font.Style, font.Size, Point.Empty,
                                            StringFormat.GenericTypographic);

                    var pathBounds = characterPath.GetBounds();

                    // Transformation matrix to move the character to the correct location.
                    // Note that all actions on the Matrix class are prepended, so we apply them in reverse.
                    var transform = new Matrix();

                    // Translate to the final position
                    transform.Translate(centre.X + x, centre.Y + y);

                    // Rotate the character
                    var rotationAngleDegrees = currentCharacterRadians * 180F / (float)Math.PI - 180F;
                    transform.Rotate(rotationAngleDegrees);

                    // Translate the character so the centre of its base is over the origin
                    transform.Translate(-pathBounds.Width / 2F, -characterHeight);

                    characterPath.Transform(transform);

                    // Draw the character
                    graphics.FillPath(brush, characterPath);
                }

                if (characterIndex != text.Length - 1)
                {
                    // Move "currentCharacterRadians" on to the next character
                    float padding                     = 5;
                    var   distanceToNextChar          = padding + ((characterWidths[characterIndex] + characterWidths[characterIndex + 1]) / 2F);
                    float charFractionOfCircumference = distanceToNextChar / circleCircumference;
                    currentCharacterRadians -= charFractionOfCircumference * (float)(2F * Math.PI);
                }
            }
        }
Exemplo n.º 35
0
        /// <summary>
        /// 创建消息窗图像,同时输出内容区,用于外部定位
        /// </summary>
        private static Bitmap CreateTipImage(string text, TipStyle style, out Rectangle contentBounds)
        {
            var size       = Size.Empty;
            var iconBounds = Rectangle.Empty;
            var textBounds = Rectangle.Empty;

            if (style.Icon != null)
            {
                size            = style.Icon.Size;
                iconBounds.Size = size;
                textBounds.X    = size.Width;
            }

            if (text.Length != 0)
            {
                if (style.Icon != null)
                {
                    size.Width   += style.IconSpacing;
                    textBounds.X += style.IconSpacing;
                }

                textBounds.Size = Size.Truncate(GraphicsUtils.MeasureString(text, style.TextFont ?? DefaultFont, 0, DefStringFormat));
                size.Width     += textBounds.Width;

                if (size.Height < textBounds.Height)
                {
                    size.Height = textBounds.Height;
                }
                else if (size.Height > textBounds.Height)//若文字没有图标高,令文字与图标垂直居中,否则与图标平齐
                {
                    textBounds.Y += (size.Height - textBounds.Height) / 2;
                }
                textBounds.Offset(style.TextOffset);
            }
            size += style.Padding.Size;
            iconBounds.Offset(style.Padding.Left, style.Padding.Top);
            textBounds.Offset(style.Padding.Left, style.Padding.Top);

            contentBounds = new Rectangle(Point.Empty, size);
            var fullBounds = GraphicsUtils.GetBounds(contentBounds, style.Border, style.ShadowRadius, style.ShadowOffset.X, style.ShadowOffset.Y);

            contentBounds.Offset(-fullBounds.X, -fullBounds.Y);
            iconBounds.Offset(-fullBounds.X, -fullBounds.Y);
            textBounds.Offset(-fullBounds.X, -fullBounds.Y);

            var bmp = new Bitmap(fullBounds.Width, fullBounds.Height);

            Graphics g         = null;
            Brush    backBrush = null;
            Brush    textBrush = null;

            try
            {
                g = Graphics.FromImage(bmp);
                g.SmoothingMode   = SmoothingMode.HighQuality;
                g.PixelOffsetMode = PixelOffsetMode.HighQuality;

                backBrush = (style.BackBrush ?? (r => new SolidBrush(style.BackColor)))(contentBounds);
                GraphicsUtils.DrawRectangle(g, contentBounds,
                                            backBrush,
                                            style.Border,
                                            style.CornerRadius,
                                            style.ShadowColor,
                                            style.ShadowRadius,
                                            style.ShadowOffset.X,
                                            style.ShadowOffset.Y);

                if (style.Icon != null)
                {
                    //DEBUG: g.DrawRectangle(new Border(Color.Red) { Width = 1, Direction = Direction.Inner }.Pen, iconBounds);
                    g.DrawImageUnscaled(style.Icon, iconBounds.Location);
                }
                if (text.Length != 0)
                {
                    textBrush = new SolidBrush(style.TextColor);
                    //DEBUG: g.DrawRectangle(new Border(Color.Red){ Width=1, Direction= Direction.Inner}.Pen, textBounds);
                    g.DrawString(text, style.TextFont ?? DefaultFont, textBrush, textBounds.Location, DefStringFormat);
                }

                g.Flush(FlushIntention.Sync);
                return(bmp);
            }
            finally
            {
                if (g != null)
                {
                    g.Dispose();
                }
                if (backBrush != null)
                {
                    backBrush.Dispose();
                }
                if (textBrush != null)
                {
                    textBrush.Dispose();
                }
            }
        }
Exemplo n.º 36
0
 private static void DrawTrimmedString(IRenderContext context, VisualGroup group, string text, Font font, Brush brush, RectD box)
 {
     if (!box.IsEmpty)
     {
         group.Add(new TextVisual {
             Text   = text,
             Font   = font,
             Format = new StringFormat {
                 Trimming = StringTrimming.EllipsisCharacter
             },
             Brush    = brush,
             Location = box.GetTopLeft()
         });
     }
 }
Exemplo n.º 37
0
 private static void RenderLoopCurrent(StateButton sender, DrawingContext context, Brush backgroundBrush)
 {
     RenderLoopCurrentIcon(sender, context, Brushes.Black, backgroundBrush);
 }
        public void Create(string sPageNavTo, string sPageArgs, string sImage, string sStatus, string sIcoId = "")
        {
            RscStore store = new RscStore();

            Guid   gd       = Guid.NewGuid();
            string gdStr    = gd.ToString();
            string sPageUri = "/MainPage.xaml" + "?IcoGd=" + gdStr;

            if (sIcoId.Length > 0)
            {
                sPageUri += "&IcoId=" + sIcoId;
            }

            if (sIcoId.Length == 0)
            {
                string sStFldr = RscKnownFolders.GetTempPath("ShellTiles", "");
                store.WriteTextFile(sStFldr + "\\" + gdStr + ".txt", sPageNavTo + "\r\n" + sPageArgs, true);
            }
            else
            {
                //To make it enumerable...
                string sStFldr = RscKnownFolders.GetTempPath("ShellTiles", "");
                store.WriteTextFile(sStFldr + "\\" + gdStr + ".txt", sIcoId, true);
            }

            string sImageUri    = sImage;
            string sImgUriFinal = sImageUri;

            if (sImageUri.Length > 0)
            {
                string sTileImg = gdStr;
                if (sImageUri.IndexOf("isostore:\\") >= 0)
                {
                    sImageUri = sImageUri.Substring(10);
                    sTileImg += RscStore.ExtensionOfPath(sImageUri);
                }
                else
                {
                    sImageUri = sImageUri.Replace("Images/", "A:\\System\\Theme\\Current\\");
                    sImageUri = sImageUri.Replace(".jpg", ".png");
                    if (!store.FileExists(sImageUri))
                    {
                        sImageUri = sImageUri.Replace(".png", ".jpg");
                        sTileImg += ".jpg";
                    }
                    else
                    {
                        sTileImg += ".png";
                    }
                }

                string sTileImgPath = "A:\\Shared\\ShellContent";
                store.CreateFolderPath(sTileImgPath);
                sTileImgPath += "\\" + sTileImg;
                store.CopyFileForce(sImageUri, sTileImgPath);

                sImgUriFinal = "isostore:/" + sTileImgPath.Substring(3).Replace('\\', '/');
            }

            string sTitle = sStatus;

            if (sIcoId.Length > 0)
            {
                sTitle = "";

                Brush  brBk           = null;
                Brush  brFore         = null;
                double dFontSize      = 0;
                string sErr           = "";
                string sNotiTitle     = "";
                string sNotiContent   = "";
                string sNotiSound     = "";
                string sInfoToChngChk = "";

                string sInfo = GetInfo(true, sIcoId, out brBk, out brFore, out dFontSize,
                                       out sErr, out sNotiTitle, out sNotiContent, out sNotiSound,
                                       false, null, out sInfoToChngChk);

                if (sInfo == "")
                {
                    sInfo = "\n\n(N/A)";
                }
                if (brBk == null)
                {
                    brBk = new SolidColorBrush(Color.FromArgb(255, 32, 32, 32));                                    //Colors.Black );
                }
                if (brFore == null)
                {
                    brFore = new SolidColorBrush(Colors.White);
                }
                if (dFontSize > 0)
                {
                    dFontSize = cdFontSize - cdFontSize_SmDiff;
                }
                else
                {
                    dFontSize = cdFontSize;
                }
                if (sInfoToChngChk.Length == 0)
                {
                    sInfoToChngChk = sInfo;
                }

                //To update only if info has changed...
                string sStCntFldr = RscKnownFolders.GetTempPath("ShellTiles", "Content");
                store.WriteTextFile(sStCntFldr + "\\" + gdStr + ".txt", sInfo, true);

                string sTileImgPath = "A:\\Shared\\ShellContent";
                store.CreateFolderPath(sTileImgPath);
                sTileImgPath += "\\" + gdStr + ".jpg";
                store.DeleteFile(sTileImgPath);
                RenderText(sInfo, sTileImgPath, brBk, brFore, dFontSize);

                sImgUriFinal = "isostore:/" + sTileImgPath.Substring(3).Replace('\\', '/');
            }

            //MessageBox.Show( "Title: " + sTitle + "\r\n" + "NavTo: " + sPageUri + "\r\n" + "Image: " + sImageUri );

            StandardTileData initialData = new StandardTileData();

            {
                if (sImgUriFinal.Length > 0)
                {
                    initialData.BackgroundImage = new Uri(sImgUriFinal, UriKind.Absolute);
                }
                if (sTitle.Length > 0)
                {
                    initialData.Title = sTitle;
                }
            }
            ShellTile.Create(new Uri(sPageUri, UriKind.Relative), initialData);
        }
Exemplo n.º 39
0
 public override void setTextColor(Brush c)
 {
     label.Foreground = c;
 }
Exemplo n.º 40
0
 public Indicators.TextConstant8 TextConstant8(string line1, string line2, string line3, string line4, string line5, string line6, string line7, string line8, Brush backgroundColor, Brush fontColor, Brush outlineColor, SimpleFont noteFont, int backgroundOpacity, TextPosition noteLocation)
 {
     return(indicator.TextConstant8(Input, line1, line2, line3, line4, line5, line6, line7, line8, backgroundColor, fontColor, outlineColor, noteFont, backgroundOpacity, noteLocation));
 }
Exemplo n.º 41
0
 public TextConstant8 TextConstant8(ISeries <double> input, string line1, string line2, string line3, string line4, string line5, string line6, string line7, string line8, Brush backgroundColor, Brush fontColor, Brush outlineColor, SimpleFont noteFont, int backgroundOpacity, TextPosition noteLocation)
 {
     if (cacheTextConstant8 != null)
     {
         for (int idx = 0; idx < cacheTextConstant8.Length; idx++)
         {
             if (cacheTextConstant8[idx] != null && cacheTextConstant8[idx].Line1 == line1 && cacheTextConstant8[idx].Line2 == line2 && cacheTextConstant8[idx].Line3 == line3 && cacheTextConstant8[idx].Line4 == line4 && cacheTextConstant8[idx].Line5 == line5 && cacheTextConstant8[idx].Line6 == line6 && cacheTextConstant8[idx].Line7 == line7 && cacheTextConstant8[idx].Line8 == line8 && cacheTextConstant8[idx].BackgroundColor == backgroundColor && cacheTextConstant8[idx].FontColor == fontColor && cacheTextConstant8[idx].OutlineColor == outlineColor && cacheTextConstant8[idx].NoteFont == noteFont && cacheTextConstant8[idx].BackgroundOpacity == backgroundOpacity && cacheTextConstant8[idx].NoteLocation == noteLocation && cacheTextConstant8[idx].EqualsInput(input))
             {
                 return(cacheTextConstant8[idx]);
             }
         }
     }
     return(CacheIndicator <TextConstant8>(new TextConstant8()
     {
         Line1 = line1, Line2 = line2, Line3 = line3, Line4 = line4, Line5 = line5, Line6 = line6, Line7 = line7, Line8 = line8, BackgroundColor = backgroundColor, FontColor = fontColor, OutlineColor = outlineColor, NoteFont = noteFont, BackgroundOpacity = backgroundOpacity, NoteLocation = noteLocation
     }, input, ref cacheTextConstant8));
 }
Exemplo n.º 42
0
        private void UpdateVisualHorizontal(int width, int height, int leftThickness, int rightThickness)
        {
            Color color;
            float xStart = 0;
            float yStart = 0;
            float yEnd = 0;
            float yOpen = 0;
            float yOpenEnd = 0;
            float yClose = 0;
            float yCloseEnd = 0;
            int   leftOffset, rightOffset;
            Brush bullFillColor = (fastHiLoOpenCloseSeries as FastHiLoOpenCloseBitmapSeries).BullFillColor;
            Brush bearFillColor = (fastHiLoOpenCloseSeries as FastHiLoOpenCloseBitmapSeries).BearFillColor;

            for (int i = 0; i < xValues.Count; i++)
            {
                if (isSeriesSelected)
                {
                    color = seriesSelectionColor;
                }
                else if (fastHiLoOpenCloseSeries.SelectedSegmentsIndexes.Contains(startIndex) && (fastHiLoOpenCloseSeries as ISegmentSelectable).SegmentSelectionBrush != null)
                {
                    color = segmentSelectionColor;
                }
                else if (this.Series.Interior != null)
                {
                    color = (Series.Interior as SolidColorBrush).Color;
                }
                else if (isBull[i])
                {
                    color = bullFillColor != null ? color = ((SolidColorBrush)bullFillColor).Color : ((SolidColorBrush)this.Interior).Color;
                }
                else
                {
                    color = bearFillColor != null ? color = ((SolidColorBrush)bearFillColor).Color : ((SolidColorBrush)this.Interior).Color;
                }
                startIndex++;
                xStart    = xValues[i];
                yStart    = y_isInversed ? yLoValues[i] : yHiValues[i];
                yEnd      = y_isInversed ? yHiValues[i] : yLoValues[i];
                yOpen     = x_isInversed ? yCloseValues[i] : yOpenStartValues[i];
                yOpenEnd  = x_isInversed ? yCloseEndValues[i] : yOpenEndValues[i];
                yClose    = x_isInversed ? yOpenStartValues[i] : yCloseValues[i];
                yCloseEnd = x_isInversed ? yOpenEndValues[i] : yCloseEndValues[i];

                leftOffset  = (int)xStart - leftThickness;
                rightOffset = (int)xStart + rightThickness;
                if (!double.IsNaN(yStart) && !double.IsNaN(yEnd))
                {
                    bitmap.FillRectangle(fastBuffer, width, height, leftOffset, (int)yStart, rightOffset, (int)yEnd,
                                         color, fastHiLoOpenCloseSeries.bitmapPixels);
                }
                if (!double.IsNaN(yOpen))
                {
                    leftOffset  = (int)yOpen - leftThickness;
                    rightOffset = (int)yOpen + rightThickness;

                    bitmap.FillRectangle(fastBuffer, width, height, (int)yOpenEnd, leftOffset,
                                         (int)xStart - leftThickness, (int)rightOffset, color, fastHiLoOpenCloseSeries.bitmapPixels);
                }
                if (!double.IsNaN(yClose))
                {
                    leftOffset  = (int)yClose - leftThickness;
                    rightOffset = (int)yClose + rightThickness;

                    bitmap.FillRectangle(fastBuffer, width, height, (int)xStart + leftThickness, leftOffset,
                                         (int)yCloseEnd, (int)rightOffset, color, fastHiLoOpenCloseSeries.bitmapPixels);
                }
            }
        }
Exemplo n.º 43
0
        public bool Perform(DrawingContext context, GraphControl self, Point mousePos)
        {
            //DrawBG;
            Brush brush = ColorIdentifier.Background.get().toBrush();

            context.DrawRoundedRectangle(brush,
                                         new Pen(ColorIdentifier.InserterOutline.get().toBrush(),
                                                 DoubleIdentifier.InserterOutlineThickness.get()),
                                         new Rect(_pos, _size), DoubleIdentifier.InserterCornerRadius.get(), DoubleIdentifier.InserterCornerRadius.get());

            //Draw heading
            var f = new FormattedText(
                "Insert Node",
                CultureInfo.CurrentCulture,
                FlowDirection.LeftToRight,
                new Typeface("Verdana"), 12, ColorIdentifier.TilteText.get().toBrush(), VisualTreeHelper.GetDpi(self).PixelsPerDip);

            context.DrawText(
                f,
                new Point(_pos.X + (_size.Width - f.Width) / 2, _pos.Y + 2)
                );
            context.DrawLine(
                new Pen(
                    ColorIdentifier.InserterOutline.get().toBrush(), 1),
                new Point(_pos.X, _pos.Y + f.Height + 4),
                new Point(_pos.X + _size.Width, _pos.Y + f.Height + 4));

            //Draw SearchBox
            context.DrawImage(_searchIcon, new Rect(_pos.X + 4, _pos.Y + f.Height + 8, f.Height, f.Height));

            //TODO: DrawSearch String

            context.DrawLine(
                new Pen(
                    ColorIdentifier.InserterOutline.get().toBrush(),
                    DoubleIdentifier.InserterSeperatorThickness.get()),
                new Point(_pos.X, _pos.Y + f.Height + 12 + f.Height),
                new Point(_pos.X + _size.Width, _pos.Y + f.Height + 12 + f.Height)
                );
            //Draw Path
            double curY = _pos.Y + f.Height + 14 + f.Height;

            _rects = new List <Tuple <Rect, bool, string, Type> >();
            if (_path.Length > 0)
            {
                var sFormattedText = new FormattedText(
                    _path,
                    CultureInfo.CurrentCulture,
                    FlowDirection.LeftToRight,
                    new Typeface("Verdana"), 12, Brushes.White, VisualTreeHelper.GetDpi(self).PixelsPerDip)
                {
                    MaxTextWidth = _size.Width - 5
                };

                if (new Rect(new Point(_pos.X, curY), new Size(_size.Width, sFormattedText.Height)).Contains(mousePos))
                {
                    context.DrawRectangle(ColorIdentifier.Line2.get().toBrush(), null, new Rect(new Point(_pos.X, curY), new Size(_size.Width, sFormattedText.Height)));
                }

                context.DrawText(
                    sFormattedText,
                    new Point(_pos.X + 3, curY + 1)
                    );
                _rects.Add(new Tuple <Rect, bool, string, Type>(
                               new Rect(new Point(_pos.X, curY), new Size(_size.Width, sFormattedText.Height)), true, "\nReverse", null
                               ));
                curY += sFormattedText.Height + 4;
            }

            //Draw Items
            double toY = _pos.Y + _size.Height - 8;

            List <Tuple <string, Type> > items = new List <Tuple <string, Type> >(
                _nodeDict.Where(x => x.Item1.StartsWith(_path))
                );

            _drawnFolders = new List <string>();

            //apply scroll
            int tScroll = _scroll;

            tScroll = tScroll.InRange(0, items.Count - 1);

            for (int i = tScroll; i < items.Count; i++)
            {
                if (curY < toY)
                {
                    DrawElement(context, self, items[i].Item1, mousePos, items[i].Item2, ref curY);
                }
            }

            return(false);
        }
        void nui_SkeletonFrameReady(object sender, SkeletonFrameReadyEventArgs e)
        {
            SkeletonFrame skeletonFrame = e.SkeletonFrame;
            int           iSkeleton     = 0;

            Brush[] brushes = new Brush[6];
            brushes[0] = new SolidColorBrush(Color.FromRgb(255, 0, 0));
            brushes[1] = new SolidColorBrush(Color.FromRgb(0, 255, 0));
            brushes[2] = new SolidColorBrush(Color.FromRgb(64, 255, 255));
            brushes[3] = new SolidColorBrush(Color.FromRgb(255, 255, 64));
            brushes[4] = new SolidColorBrush(Color.FromRgb(255, 64, 255));
            brushes[5] = new SolidColorBrush(Color.FromRgb(128, 128, 255));

            skeleton.Children.Clear();
            foreach (SkeletonData data in skeletonFrame.Skeletons)
            {
                if (SkeletonTrackingState.Tracked == data.TrackingState)
                {
                    // Draw bones
                    Brush brush = brushes[iSkeleton % brushes.Length];
                    skeleton.Children.Add(getBodySegment(data.Joints, brush, JointID.HipCenter, JointID.Spine, JointID.ShoulderCenter, JointID.Head));
                    skeleton.Children.Add(getBodySegment(data.Joints, brush, JointID.ShoulderCenter, JointID.ShoulderLeft, JointID.ElbowLeft, JointID.WristLeft, JointID.HandLeft));
                    skeleton.Children.Add(getBodySegment(data.Joints, brush, JointID.ShoulderCenter, JointID.ShoulderRight, JointID.ElbowRight, JointID.WristRight, JointID.HandRight));
                    skeleton.Children.Add(getBodySegment(data.Joints, brush, JointID.HipCenter, JointID.HipLeft, JointID.KneeLeft, JointID.AnkleLeft, JointID.FootLeft));
                    skeleton.Children.Add(getBodySegment(data.Joints, brush, JointID.HipCenter, JointID.HipRight, JointID.KneeRight, JointID.AnkleRight, JointID.FootRight));

                    JointsCollection jc = data.Joints;

                    StringBuilder sb = new StringBuilder();
                    StringBuilder up = new StringBuilder();
                    StringBuilder lo = new StringBuilder();
                    int           k  = 0;
                    foreach (JointID jid in Enum.GetValues(typeof(JointID)))
                    {
                        if (jid != JointID.Count)
                        {
                            k++;
                            Microsoft.Research.Kinect.Nui.Vector v = jc[jid].Position;
                            if (k <= 4)
                            {
                                sb.Append(string.Format("{0} = {1}, {2}, {3}\n", jid, v.X, v.Y, v.Z));
                            }
                            else if (k <= 12)
                            {
                                up.Append(string.Format("{0} = {1}, {2}, {3}\n", jid, v.X, v.Y, v.Z));

                                if (k == 8)//HandLeft
                                {
                                    HandLY = v.Y;
                                    up.Append(string.Format("\n"));
                                }
                                if (k == 9)//ShoulderRight
                                {
                                    ShouRX = v.X;
                                    ShouRY = v.Y;
                                    ShouRZ = v.Z;
                                }
                                if (k == 10)//ElbowRight
                                {
                                    ElRX = v.X;
                                    ElRY = v.Y;
                                    ElRZ = v.Z;
                                }
                                if (k == 11)//WristRight
                                {
                                    WrRX = v.X;
                                    WrRY = v.Y;
                                    WrRZ = v.Z;
                                }
                                if (k == 12)//HandRight
                                {
                                    HandRX = v.X;
                                    HandRY = v.Y;
                                    HandRZ = v.Z;
                                }
                            }
                            else if (k <= 20)
                            {
                                lo.Append(string.Format("{0} = {1}, {2}, {3}\n", jid, v.X, v.Y, v.Z));
                                if (k == 13)//HipLeft
                                {
                                    HipLY = v.Y;
                                }
                                if (k == 16)
                                {
                                    lo.Append(string.Format("\n"));
                                }
                            }
                        }
                    }

                    middle.Text = sb.ToString();
                    upper.Text  = up.ToString();
                    lower.Text  = lo.ToString();

                    //Arduino Control 1st Rotation Angle
                    double angROT1 = Math.Atan((HandRX - ShouRX) / (HandRY - ShouRY));
                    if (angROT1 < 0)
                    {
                        angROT1 = 0.5 * Math.PI - angROT1;
                    }
                    arduino.analogWrite(3, Convert.ToInt32(Math.Floor(angROT1 * 180 / Math.PI)));

                    //Arduino Control 2nd Rotation Angle (Shoulder)
                    double angROT2 = Math.Atan((ShouRZ - ElRZ) / Math.Sqrt(Math.Pow((ElRY - ShouRY), 2) + Math.Pow((ElRX - ShouRX), 2)));
                    if (angROT2 < 0)
                    {
                        angROT2 += Math.PI;
                    }
                    if (ElRX < ShouRX)
                    {
                        angROT2 = Math.PI - angROT2;
                    }
                    int degRot2 = Convert.ToInt32(Math.Floor(angROT2 * 180 / Math.PI));
                    //Constrained by mechanism
                    if (degRot2 < 25)
                    {
                        degRot2 = 25;
                    }
                    else if (degRot2 > 155)
                    {
                        degRot2 = 155;
                    }
                    arduino.analogWrite(5, degRot2);

                    //Arduino Control 3rd Rotation Angle (Elbo)
                    double ax      = HandRX - ElRX;
                    double ay      = HandRY - ElRY;
                    double az      = HandRZ - ElRZ;
                    double bx      = ElRX - ShouRX;
                    double by      = ElRY - ShouRY;
                    double bz      = ElRZ - ShouRZ;
                    double angROT3 = Math.Acos((ax * bx + ay * by + az * bz) / Math.Sqrt(ax * ax + ay * ay + az * az) / Math.Sqrt(bx * bx + by * by + bz * bz));
                    arduino.analogWrite(10, Convert.ToInt32(Math.Floor(angROT3 * 180 / Math.PI)));

                    //Arduino Control 4th Rotation Angle (Grab)
                    if (HandLY > HipLY)
                    {
                        arduino.analogWrite(9, 30);
                    }
                    else
                    {
                        arduino.analogWrite(9, 110);
                    }

                    // Draw joints
                    foreach (Joint joint in data.Joints)
                    {
                        Point jointPos  = getDisplayPosition(joint);
                        Line  jointLine = new Line();
                        jointLine.X1              = jointPos.X - 3;
                        jointLine.X2              = jointLine.X1 + 6;
                        jointLine.Y1              = jointLine.Y2 = jointPos.Y;
                        jointLine.Stroke          = jointColors[joint.ID];
                        jointLine.StrokeThickness = 6;
                        skeleton.Children.Add(jointLine);
                    }
                }
                iSkeleton++;
            } // for each skeleton
        }
        Polyline getBodySegment(Microsoft.Research.Kinect.Nui.JointsCollection joints, Brush brush, params JointID[] ids)
        {
            PointCollection points = new PointCollection(ids.Length);

            for (int i = 0; i < ids.Length; ++i)
            {
                points.Add(getDisplayPosition(joints[ids[i]]));
            }

            Polyline polyline = new Polyline();

            polyline.Points          = points;
            polyline.Stroke          = brush;
            polyline.StrokeThickness = 5;
            return(polyline);
        }
Exemplo n.º 46
0
        private Bitmap renderSetItem(out int picHeight)
        {
            Bitmap setBitmap = null;
            int    setID;

            picHeight = 0;
            if (gear.Props.TryGetValue(GearPropType.setItemID, out setID))
            {
                SetItem setItem;
                if (!CharaSimLoader.LoadedSetItems.TryGetValue(setID, out setItem))
                {
                    return(null);
                }
                setBitmap = new Bitmap(252, DefaultPicHeight);
                Graphics     g      = Graphics.FromImage(setBitmap);
                StringFormat format = new StringFormat();
                format.Alignment = StringAlignment.Center;

                picHeight = 10;
                g.DrawString(setItem.SetItemName, GearGraphics.ItemDetailFont, GearGraphics.SetItemNameBrush, 126, 10, format);
                picHeight += 25;

                format.Alignment = StringAlignment.Far;

                foreach (var setItemPart in setItem.ItemIDs.Parts)
                {
                    string itemName = setItemPart.Value.RepresentName;
                    string typeName = setItemPart.Value.TypeName;

                    if (string.IsNullOrEmpty(itemName) || string.IsNullOrEmpty(typeName))
                    {
                        foreach (var itemID in setItemPart.Value.ItemIDs)
                        {
                            StringResult sr;
                            if (!StringLinker.StringEqp.TryGetValue(itemID.Key, out sr))
                            {
                                sr      = new StringResult();
                                sr.Name = "(null)";
                            }
                            itemName = sr.Name;
                            typeName = ItemStringHelper.GetSetItemGearTypeString(Gear.GetGearType(itemID.Key));
                            break;
                        }
                    }

                    itemName = itemName ?? string.Empty;
                    typeName = typeName ?? "Equipment";

                    Brush brush = setItemPart.Value.Enabled ? Brushes.White : GearGraphics.SetItemGrayBrush;
                    g.DrawString(itemName, GearGraphics.ItemDetailFont, brush, 8, picHeight);
                    g.DrawString("(" + typeName + ")", GearGraphics.ItemDetailFont, brush, 246, picHeight, format);
                    picHeight += 18;
                }

                picHeight += 5;
                g.DrawLine(Pens.White, 6, picHeight, 245, picHeight);//分割线
                picHeight += 9;
                foreach (KeyValuePair <int, SetItemEffect> effect in setItem.Effects)
                {
                    g.DrawString(effect.Key + " Set Items Equipped", GearGraphics.ItemDetailFont, GearGraphics.SetItemNameBrush, 8, picHeight);
                    picHeight += 16;
                    Brush brush = effect.Value.Enabled ? Brushes.White : GearGraphics.SetItemGrayBrush;
                    foreach (KeyValuePair <GearPropType, object> prop in effect.Value.Props)
                    {
                        if (prop.Key == GearPropType.Option)
                        {
                            List <Potential> ops = (List <Potential>)prop.Value;
                            foreach (Potential p in ops)
                            {
                                g.DrawString(p.ConvertSummary(), GearGraphics.SetItemPropFont, brush, 8, picHeight);
                                picHeight += 16;
                            }
                        }
                        else
                        {
                            g.DrawString(ItemStringHelper.GetGearPropString(prop.Key, Convert.ToInt32(prop.Value)),
                                         GearGraphics.SetItemPropFont, brush, 8, picHeight);
                            picHeight += 16;
                        }
                    }
                }
                picHeight += 11;
                format.Dispose();
                g.Dispose();
            }
            return(setBitmap);
        }
        public virtual string GetInfo(bool bForSysTile, string sIcoId, out Brush brBk, out Brush brFore,
                                      out double dFontSize, out string sErr,
                                      out string sNotiTitle, out string sNotiContent, out string sNotiSound,
                                      bool bCalledByAgent, object oAgentParam, out string sInfoToChngChk)
        {
            brBk      = null;
            brFore    = null;
            dFontSize = 0;
            sErr      = "";

            sNotiTitle   = "";
            sNotiContent = "";
            sNotiSound   = "";

            sInfoToChngChk = "";

            //Do not generate too many err files...
            //RscStore.AddSysEvent( ex, "Tile_Info_Title_Createion_Error" );
            RscStore.AddSysEvent("Not implemented: GetInfo", true, "Tile_Info_Title_Createion_Error");

            return("???");
        }
 public LineCreator(Brush linkBrush, double brushThickness, double opacity)
 {
     _linkBrush      = linkBrush;
     _brushThickness = brushThickness;
     _opacity        = opacity;
 }
Exemplo n.º 49
0
 public static void FillRoundRect(Graphics g, Brush b, Rectangle rect, int radius)
 {
     FillRoundRect(g, b, rect.X, rect.Y, rect.Width, rect.Height, radius);
 }
Exemplo n.º 50
0
        private static void RenderLoopCurrentIcon(StateButton sender, DrawingContext context, Brush iconBrush, Brush backgroundBrush)
        {
            Rect   iconRect     = sender.IconRect;
            double radiusMiddle = iconRect.Width * (1 - iconCurveThicknessFactor) / 2;
            Point  middlePoint  = new Point(sender.ActualWidth / 2, sender.ActualHeight / 2);

            Pen iconPen       = new Pen(iconBrush, iconRect.Width * iconCurveThicknessFactor);
            Pen backgroundPen = new Pen(backgroundBrush, 0);

            Geometry geoTopDelete   = GetTopDeleteGeometry(sender);
            Geometry geoRightDelete = GetRightDeleteGeometry(sender);
            Geometry geoArrow       = GetArrowGeometry(sender);
            Geometry geoOne         = GetOneGeomerty(sender);

            context.DrawEllipse(backgroundBrush, iconPen, middlePoint, radiusMiddle, radiusMiddle);
            context.DrawGeometry(backgroundBrush, backgroundPen, geoTopDelete);
            context.DrawGeometry(backgroundBrush, backgroundPen, geoRightDelete);
            context.DrawGeometry(iconBrush, backgroundPen, geoArrow);
            context.DrawGeometry(iconBrush, backgroundPen, geoOne);
        }
        private void RenderText(string text, int width, int height, double fontsize, string imagepath, Brush backColor, Brush brFore)
        {
            WriteableBitmap b = new WriteableBitmap(width, height);

            var canvas = new Grid();

            canvas.Width  = b.PixelWidth;
            canvas.Height = b.PixelHeight;

            var background = new Canvas();

            background.Height = b.PixelHeight;
            background.Width  = b.PixelWidth;

            //SolidColorBrush backColor = new SolidColorBrush((Color)Application.Current.Resources["PhoneAccentColor"]);
            //SolidColorBrush backColor = new SolidColorBrush( Colors.Black );
            background.Background = backColor;

            var textBlock = new TextBlock();

            textBlock.Text                = text;
            textBlock.FontWeight          = FontWeights.Bold;
            textBlock.TextAlignment       = TextAlignment.Left;
            textBlock.HorizontalAlignment = HorizontalAlignment.Center;
            textBlock.VerticalAlignment   = VerticalAlignment.Stretch;
            textBlock.Margin              = new Thickness(35);
            textBlock.Width               = b.PixelWidth - textBlock.Margin.Left * 2;
            textBlock.TextWrapping        = TextWrapping.Wrap;
            textBlock.Foreground          = brFore;    //new SolidColorBrush(Colors.White); //color of the text on the Tile
            textBlock.FontSize            = fontsize;

            canvas.Children.Add(textBlock);

            b.Render(background, null);
            b.Render(canvas, null);
            b.Invalidate();             //Draw bitmap

            RscStore store = new RscStore();

            System.IO.Stream stream = store.CreateFile(imagepath);
            b.SaveJpeg(stream, b.PixelWidth, b.PixelHeight, 0, 100);

            stream.Close();
        }
Exemplo n.º 52
0
        public static void renderTextInBlockCentre(Graphics g, String text, Font font, Brush brush, float left, float top, float width, float height)
        {
            SizeF font_size = g.MeasureString(text, font);
            float x         = (float)(left + (width / 2.0) - (font_size.Width / 2.0));
            float y         = (float)(top + (height / 2.0) - (font_size.Height / 2.0));

            g.DrawString(text, font, brush, x, y);
        }
        public void DoUpdate(bool bCalledByAgent, object oAgentParam)
        {
            RscStore.AddSysEvent(DateTime.Now.ToString(), false, "ShellTiles_DoUpdate");

            var tiles = ShellTile.ActiveTiles;

            string sDbg = "";

            string sStCntFldr = RscKnownFolders.GetTempPath("ShellTiles", "Content");

            foreach (ShellTile tile in tiles)
            {
                if (sDbg.Length > 0)
                {
                    sDbg += "\r\n";
                }
                sDbg += tile.NavigationUri.OriginalString;

                try
                {
                    StandardTileData updatedData = new StandardTileData();

                    int iPos = tile.NavigationUri.OriginalString.IndexOf("IcoId=");
                    if (iPos < 0)
                    {
                        continue;
                    }
                    iPos += 6;
                    string sIcoId = tile.NavigationUri.OriginalString.Substring(iPos);

                    iPos = tile.NavigationUri.OriginalString.IndexOf("IcoGd=");
                    if (iPos < 0)
                    {
                        continue;
                    }
                    iPos += 6;
                    int iPos2 = tile.NavigationUri.OriginalString.IndexOf('&', iPos);
                    if (iPos2 < 0)
                    {
                        continue;
                    }
                    iPos2--;
                    string sIcoGd = tile.NavigationUri.OriginalString.Substring(iPos, (iPos2 - iPos) + 1);

                    /*
                     * DateTime dNow = DateTime.Now;
                     * string sTm =     RscUtils.pad60(dNow.Hour) +
                     *                              ":" + RscUtils.pad60(dNow.Minute); // + ":" + RscUtils.pad60(dNow.Second);
                     *
                     * updatedData.Title = RscUtils.pad60(dNow.Day) + ". " + sTm;
                     */

                    Brush  brBk           = null;
                    Brush  brFore         = null;
                    double dFontSize      = 0;
                    string sErr           = "";
                    string sNotiTitle     = "";
                    string sNotiContent   = "";
                    string sNotiSound     = "";
                    string sInfoToChngChk = "";

                    string sInfo = GetInfo(true, sIcoId, out brBk, out brFore, out dFontSize,
                                           out sErr, out sNotiTitle, out sNotiContent, out sNotiSound,
                                           bCalledByAgent, oAgentParam, out sInfoToChngChk);

                    if (sInfo == "")
                    {
                        sInfo = "\n\n(N/A)";
                    }
                    if (brBk == null)
                    {
                        brBk = new SolidColorBrush(Color.FromArgb(255, 32, 32, 32));                                        //Colors.Black );
                    }
                    if (brFore == null)
                    {
                        brFore = new SolidColorBrush(Colors.White);
                    }
                    if (dFontSize > 0)
                    {
                        dFontSize = cdFontSize - cdFontSize_SmDiff;
                    }
                    else
                    {
                        dFontSize = cdFontSize;
                    }
                    if (sInfoToChngChk.Length == 0)
                    {
                        sInfoToChngChk = sInfo;
                    }
                    if (sErr.Length > 0)
                    {
                        sDbg += "\r\nERROR: " + sErr;
                    }

                    RscStore store = new RscStore();

                    // //
                    //

                    string sInfoToChngChk_Old = store.ReadTextFile(sStCntFldr + "\\" + sIcoGd + ".txt", "");
                    if (sInfoToChngChk_Old.CompareTo(sInfoToChngChk) != 0)
                    {
                        if (sNotiTitle.Length > 0 && sNotiContent.Length > 0)
                        {
                            string sUriSnd = sNotiSound;
                            if (sUriSnd.Length == 0)
                            {
                                sUriSnd = /*"/Lib_Rsc;component/" +*/ "Media/empty.mp3";
                            }

                            ShellToast_Wp80U3.ShowToast(sNotiTitle, sNotiContent,
                                                        new Uri(sUriSnd, UriKind.Relative));
                        }

                        store.WriteTextFile(sStCntFldr + "\\" + sIcoGd + ".txt", sInfoToChngChk, true);
                    }

                    //
                    // //
                    //

                    string sInfo_Old = store.ReadTextFile(sStCntFldr + "\\" + sIcoGd + "(full).txt", "");
                    if (sInfo_Old.CompareTo(sInfo) == 0)
                    {
                        sDbg += " " + sIcoId + "|" + sIcoGd + " (NO UPDATE, NO CHANGE)";
                        continue;                         //No change!!!
                    }

                    string sTileImgPath = "A:\\Shared\\ShellContent";
                    store.CreateFolderPath(sTileImgPath);
                    sTileImgPath += "\\" + sIcoGd + ".jpg";
                    store.DeleteFile(sTileImgPath);
                    RenderText(sInfo, sTileImgPath, brBk, brFore, dFontSize);

                    string sImgUriFinal = "isostore:/" + sTileImgPath.Substring(3).Replace('\\', '/');
                    updatedData.BackgroundImage = new Uri(sImgUriFinal, UriKind.Absolute);

                    tile.Update(updatedData);

                    sDbg += " " + sIcoId + "|" + sIcoGd + " (Updated)";

                    store.WriteTextFile(sStCntFldr + "\\" + sIcoGd + "(full).txt", sInfo, true);

                    //
                    // //
                }
                catch (Exception e)
                {
                    sDbg += "\r\nERROR: " + e.Message + "\r\n" + e.StackTrace;
                }
            }

            RscStore.AddSysEvent(sDbg, false, "ShellTiles_DoUpdate_List");
        }
Exemplo n.º 54
0
        internal static void DrawPlainText(IFlxGraphics Canvas, ExcelFile Workbook, TShapeProperties ShProp, RectangleF Coords, TShadowInfo ShadowInfo, TClippingStyle Clipping, float Zoom100)
        {
            string Text = GetGeoText(ShProp);

            if (Text == null)
            {
                return;
            }
            Text = Text.Replace("\n", String.Empty);
            string[] Lines = Text.Split('\r');
            if (Lines == null || Lines.Length <= 0)
            {
                return;
            }
            int LinesLength = Lines[Lines.Length - 1].Length == 0? Lines.Length - 1: Lines.Length;               //Last line is an empty enter.

            if (LinesLength <= 0)
            {
                return;
            }

            using (Font TextFont = GetGeoFont(ShProp))
            {
                using (Pen pe = GetPen(ShProp, Workbook, ShadowInfo))
                {
                    Canvas.SaveTransform();
                    try
                    {
                        float   LineGap = Canvas.FontLinespacing(TextFont);
                        SizeF[] Sizes   = new SizeF[LinesLength];
                        Sizes[0]         = Canvas.MeasureStringEmptyHasHeight(Lines[0], TextFont);
                        Sizes[0].Height -= LineGap; //Linespacing is not included here.

                        SizeF sz = Sizes[0];
                        for (int i = 1; i < LinesLength; i++)
                        {
                            Sizes[i] = Canvas.MeasureStringEmptyHasHeight(Lines[i], TextFont);
                            if (Sizes[i].Width > sz.Width)
                            {
                                sz.Width = Sizes[i].Width;
                            }
                            sz.Height += Sizes[i].Height;
                        }

                        if (sz.Width <= 0 || sz.Height <= 0 || Coords.Width <= 0 || Coords.Height <= 0)
                        {
                            return;
                        }
                        float rx = Coords.Width / sz.Width;
                        float ry = Coords.Height / sz.Height;
                        Canvas.Scale(rx, ry);

                        using (Brush br = GetBrush(new RectangleF(Coords.Left / rx, Coords.Top / ry, sz.Width, sz.Height), ShProp, Workbook, ShadowInfo, Zoom100)) //Mast be selected AFTER scaling, so gradients work.
                        {
                            float y = LineGap;
                            for (int i = 0; i < LinesLength; i++)
                            {
                                y += Sizes[i].Height;
                                float x = (sz.Width - Sizes[i].Width) / 2f;
                                Canvas.DrawString(Lines[i], TextFont, pe, br, Coords.Left / rx + x, Coords.Top / ry + y);
                            }
                        }
                    }
                    finally
                    {
                        Canvas.ResetTransform();
                    }
                }
            }
        }
Exemplo n.º 55
0
        /// <summary>
        /// Создать растровое изображение с QR Code массив более твердый или люк фон
        /// </summary>
        /// <param name="QRCode">QRCode</param>
        /// <param name="ModuleSize">Размер модуля в пикселях</param>
        /// <param name="QuietZone">Тихая зона в пикселях</param>
        /// <param name="Background">SolidBrush или HatchBrush фон</param>
        /// <param name="ImageWidth">Ширина выходного изображения</param>
        /// <param name="ImageHeight">Высота выходного изображения</param>
        /// <param name="QRCodeCenterPosX">QRCode позиция X </param>
        /// <param name="QRCodeCenterPosY">QRCode позиция Y</param>
        /// <param name="Rotation">Вращение QRCode в градусах</param>
        /// <returns>Растровое изображение QRCode</returns>
        public static Bitmap CreateBitmap(QRCode QRCode, Int32 ModuleSize, Int32 QuietZone, Brush Background, Int32 ImageWidth, Int32 ImageHeight, Double QRCodeCenterPosX, Double QRCodeCenterPosY, Double Rotation)
		{
            // Создать фоновое растровое изображение и раскрасить его кистью
            Bitmap BackgroundBitmap = new Bitmap(ImageWidth, ImageHeight);
		    Graphics Graphics = Graphics.FromImage(BackgroundBitmap);
		    Graphics.FillRectangle(Background, 0, 0, ImageWidth, ImageHeight);

            // Возвращение в QR растровый код закрасили фон
            return CreateBitmap(QRCode, ModuleSize, QuietZone, BackgroundBitmap, QRCodeCenterPosX, QRCodeCenterPosY, Rotation);
		}
Exemplo n.º 56
0
 public override void setBackgroundColor(Brush c)
 {
     label.Background = c;
 }
Exemplo n.º 57
0
        public void Clear(Brush brush, Graphics graph, int pointY)
        {
            var rect = new Rectangle(0, pointY, Config.WindowX, Config.LineHeight);

            graph.FillRectangle(brush, rect);
        }
Exemplo n.º 58
0
        private void Handle(IQuickInfoSession session, IList <object> quickInfoContent, out ITrackingSpan applicableToSpan)
        {
            applicableToSpan = null;
            DateTime time1 = DateTime.Now;

            ITextSnapshot snapshot     = this._sourceBuffer.CurrentSnapshot;
            var           triggerPoint = (SnapshotPoint)session.GetTriggerPoint(snapshot);

            if (triggerPoint == null)
            {
                AsmDudeToolsStatic.Output_WARNING("AsmQuickInfoSource:AugmentQuickInfoSession: trigger point is null");
                return;
            }

            Brush foreground = AsmDudeToolsStatic.Get_Font_Color();

            var enumerator = this._aggregator.GetTags(new SnapshotSpan(triggerPoint, triggerPoint)).GetEnumerator();

            if (enumerator.MoveNext())
            {
                var asmTokenTag = enumerator.Current;

                var enumerator2 = asmTokenTag.Span.GetSpans(this._sourceBuffer).GetEnumerator();
                if (enumerator2.MoveNext())
                {
                    SnapshotSpan tagSpan      = enumerator2.Current;
                    string       keyword      = tagSpan.GetText();
                    string       keywordUpper = keyword.ToUpper();

                    #region Tests
                    // TODO: multiple tags at the provided triggerPoint is most likely the result of a bug in AsmTokenTagger, but it seems harmless...
                    if (false)
                    {
                        if (enumerator.MoveNext())
                        {
                            var asmTokenTagX = enumerator.Current;
                            var enumeratorX  = asmTokenTagX.Span.GetSpans(this._sourceBuffer).GetEnumerator();
                            enumeratorX.MoveNext();
                            AsmDudeToolsStatic.Output_WARNING(string.Format("{0}:AugmentQuickInfoSession. current keyword " + keyword + ": but span has more than one tag! next tag=\"{1}\"", ToString(), enumeratorX.Current.GetText()));
                        }
                    }
                    #endregion

                    //AsmDudeToolsStatic.Output_INFO("AsmQuickInfoSource:AugmentQuickInfoSession: keyword=\""+ keyword + "\"; type=" + asmTokenTag.Tag.type +"; file="+AsmDudeToolsStatic.GetFileName(session.TextView.TextBuffer));
                    applicableToSpan = snapshot.CreateTrackingSpan(tagSpan, SpanTrackingMode.EdgeInclusive);

                    TextBlock    description = null;
                    AsmTokenType type        = asmTokenTag.Tag.Type;
                    switch (type)
                    {
                    case AsmTokenType.Misc:
                    {
                        description = new TextBlock();
                        description.Inlines.Add(Make_Run1("Keyword ", foreground));
                        description.Inlines.Add(Make_Run2(keyword, new SolidColorBrush(AsmDudeToolsStatic.ConvertColor(Settings.Default.SyntaxHighlighting_Misc))));

                        string descr = this._asmDudeTools.Get_Description(keywordUpper);
                        if (descr.Length > 0)
                        {
                            if (keyword.Length > (AsmDudePackage.maxNumberOfCharsInToolTips / 2))
                            {
                                descr = "\n" + descr;
                            }
                            description.Inlines.Add(new Run(AsmSourceTools.Linewrap(": " + descr, AsmDudePackage.maxNumberOfCharsInToolTips))
                                {
                                    Foreground = foreground
                                });
                        }
                        break;
                    }

                    case AsmTokenType.Directive:
                    {
                        description = new TextBlock();
                        description.Inlines.Add(Make_Run1("Directive ", foreground));
                        description.Inlines.Add(Make_Run2(keyword, new SolidColorBrush(AsmDudeToolsStatic.ConvertColor(Settings.Default.SyntaxHighlighting_Directive))));

                        string descr = this._asmDudeTools.Get_Description(keywordUpper);
                        if (descr.Length > 0)
                        {
                            if (keyword.Length > (AsmDudePackage.maxNumberOfCharsInToolTips / 2))
                            {
                                descr = "\n" + descr;
                            }
                            description.Inlines.Add(new Run(AsmSourceTools.Linewrap(": " + descr, AsmDudePackage.maxNumberOfCharsInToolTips))
                                {
                                    Foreground = foreground
                                });
                        }
                        break;
                    }

                    case AsmTokenType.Register:
                    {
                        int lineNumber = AsmDudeToolsStatic.Get_LineNumber(tagSpan);
                        if (keywordUpper.StartsWith("%"))
                        {
                            keywordUpper = keywordUpper.Substring(1);                                       // remove the preceding % in AT&T syntax
                        }
                        Rn reg = RegisterTools.ParseRn(keywordUpper, true);
                        if (this._asmDudeTools.RegisterSwitchedOn(reg))
                        {
                            var registerTooltipWindow = new RegisterTooltipWindow(foreground);
                            registerTooltipWindow.SetDescription(reg, this._asmDudeTools);
                            registerTooltipWindow.SetAsmSim(this._asmSimulator, reg, lineNumber, true);
                            quickInfoContent.Add(registerTooltipWindow);
                        }
                        break;
                    }

                    case AsmTokenType.Mnemonic:
                    case AsmTokenType.Jump:
                    {
                        int      lineNumber = AsmDudeToolsStatic.Get_LineNumber(tagSpan);
                        Mnemonic mnemonic   = AsmSourceTools.ParseMnemonic_Att(keywordUpper, true);
                        if (this._asmDudeTools.MnemonicSwitchedOn(mnemonic))
                        {
                            var instructionTooltipWindow = new InstructionTooltipWindow(foreground)
                            {
                                Session = session         // set the owner of this windows such that we can manually close this window
                            };
                            instructionTooltipWindow.SetDescription(mnemonic, this._asmDudeTools);
                            instructionTooltipWindow.SetPerformanceInfo(mnemonic, this._asmDudeTools);
                            instructionTooltipWindow.SetAsmSim(this._asmSimulator, lineNumber, true);
                            quickInfoContent.Add(instructionTooltipWindow);
                        }
                        break;
                    }

                    case AsmTokenType.Label:
                    {
                        string label                = keyword;
                        string labelPrefix          = asmTokenTag.Tag.Misc;
                        string full_Qualified_Label = AsmDudeToolsStatic.Make_Full_Qualified_Label(labelPrefix, label, AsmDudeToolsStatic.Used_Assembler);

                        description = new TextBlock();
                        description.Inlines.Add(Make_Run1("Label ", foreground));
                        description.Inlines.Add(Make_Run2(full_Qualified_Label, new SolidColorBrush(AsmDudeToolsStatic.ConvertColor(Settings.Default.SyntaxHighlighting_Label))));

                        string descr = Get_Label_Description(full_Qualified_Label);
                        if (descr.Length == 0)
                        {
                            descr = Get_Label_Description(label);
                        }
                        if (descr.Length > 0)
                        {
                            if (keyword.Length > (AsmDudePackage.maxNumberOfCharsInToolTips / 2))
                            {
                                descr = "\n" + descr;
                            }
                            description.Inlines.Add(new Run(AsmSourceTools.Linewrap(": " + descr, AsmDudePackage.maxNumberOfCharsInToolTips))
                                {
                                    Foreground = foreground
                                });
                        }
                        break;
                    }

                    case AsmTokenType.LabelDef:
                    {
                        string label          = keyword;
                        string extra_Tag_Info = asmTokenTag.Tag.Misc;
                        string full_Qualified_Label;
                        if ((extra_Tag_Info != null) && extra_Tag_Info.Equals(AsmTokenTag.MISC_KEYWORD_PROTO))
                        {
                            full_Qualified_Label = label;
                        }
                        else
                        {
                            full_Qualified_Label = AsmDudeToolsStatic.Make_Full_Qualified_Label(extra_Tag_Info, label, AsmDudeToolsStatic.Used_Assembler);
                        }

                        AsmDudeToolsStatic.Output_INFO("AsmQuickInfoSource:AugmentQuickInfoSession: found label def " + full_Qualified_Label);

                        description = new TextBlock();
                        description.Inlines.Add(Make_Run1("Label ", foreground));
                        description.Inlines.Add(Make_Run2(full_Qualified_Label, new SolidColorBrush(AsmDudeToolsStatic.ConvertColor(Settings.Default.SyntaxHighlighting_Label))));

                        string descr = Get_Label_Def_Description(full_Qualified_Label, label);
                        if (descr.Length > 0)
                        {
                            if (keyword.Length > (AsmDudePackage.maxNumberOfCharsInToolTips / 2))
                            {
                                descr = "\n" + descr;
                            }
                            description.Inlines.Add(new Run(AsmSourceTools.Linewrap(": " + descr, AsmDudePackage.maxNumberOfCharsInToolTips))
                                {
                                    Foreground = foreground
                                });
                        }
                        break;
                    }

                    case AsmTokenType.Constant:
                    {
                        description = new TextBlock();
                        description.Inlines.Add(Make_Run1("Constant ", foreground));

                        var(Valid, Value, NBits) = AsmSourceTools.Evaluate_Constant(keyword);
                        string constantStr = (Valid)
                                    ? Value + "d = " + Value.ToString("X") + "h = " + AsmSourceTools.ToStringBin(Value, NBits) + "b"
                                    : keyword;

                        description.Inlines.Add(Make_Run2(constantStr, new SolidColorBrush(AsmDudeToolsStatic.ConvertColor(Settings.Default.SyntaxHighlighting_Constant))));
                        break;
                    }

                    case AsmTokenType.UserDefined1:
                    {
                        description = new TextBlock();
                        description.Inlines.Add(Make_Run1("User defined 1: ", foreground));
                        description.Inlines.Add(Make_Run2(keyword, new SolidColorBrush(AsmDudeToolsStatic.ConvertColor(Settings.Default.SyntaxHighlighting_Userdefined1))));

                        string descr = this._asmDudeTools.Get_Description(keywordUpper);
                        if (descr.Length > 0)
                        {
                            if (keyword.Length > (AsmDudePackage.maxNumberOfCharsInToolTips / 2))
                            {
                                descr = "\n" + descr;
                            }
                            description.Inlines.Add(new Run(AsmSourceTools.Linewrap(": " + descr, AsmDudePackage.maxNumberOfCharsInToolTips))
                                {
                                    Foreground = foreground
                                });
                        }
                        break;
                    }

                    case AsmTokenType.UserDefined2:
                    {
                        description = new TextBlock();
                        description.Inlines.Add(Make_Run1("User defined 2: ", foreground));
                        description.Inlines.Add(Make_Run2(keyword, new SolidColorBrush(AsmDudeToolsStatic.ConvertColor(Settings.Default.SyntaxHighlighting_Userdefined2))));

                        string descr = this._asmDudeTools.Get_Description(keywordUpper);
                        if (descr.Length > 0)
                        {
                            if (keyword.Length > (AsmDudePackage.maxNumberOfCharsInToolTips / 2))
                            {
                                descr = "\n" + descr;
                            }
                            description.Inlines.Add(new Run(AsmSourceTools.Linewrap(": " + descr, AsmDudePackage.maxNumberOfCharsInToolTips))
                                {
                                    Foreground = foreground
                                });
                        }
                        break;
                    }

                    case AsmTokenType.UserDefined3:
                    {
                        description = new TextBlock();
                        description.Inlines.Add(Make_Run1("User defined 3: ", foreground));
                        description.Inlines.Add(Make_Run2(keyword, new SolidColorBrush(AsmDudeToolsStatic.ConvertColor(Settings.Default.SyntaxHighlighting_Userdefined3))));

                        string descr = this._asmDudeTools.Get_Description(keywordUpper);
                        if (descr.Length > 0)
                        {
                            if (keyword.Length > (AsmDudePackage.maxNumberOfCharsInToolTips / 2))
                            {
                                descr = "\n" + descr;
                            }
                            description.Inlines.Add(new Run(AsmSourceTools.Linewrap(": " + descr, AsmDudePackage.maxNumberOfCharsInToolTips))
                                {
                                    Foreground = foreground
                                });
                        }
                        break;
                    }

                    default:
                        //description = new TextBlock();
                        //description.Inlines.Add(makeRun1("Unused tagType " + asmTokenTag.Tag.type));
                        break;
                    }
                    if (description != null)
                    {
                        description.FontSize   = AsmDudeToolsStatic.Get_Font_Size() + 2;
                        description.FontFamily = AsmDudeToolsStatic.Get_Font_Type();
                        //AsmDudeToolsStatic.Output_INFO(string.Format("{0}:AugmentQuickInfoSession; setting description fontSize={1}; fontFamily={2}", this.ToString(), description.FontSize, description.FontFamily));
                        quickInfoContent.Add(description);
                    }
                }
            }
            //AsmDudeToolsStatic.Output_INFO("AsmQuickInfoSource:AugmentQuickInfoSession: applicableToSpan=\"" + applicableToSpan + "\"; quickInfoContent,Count=" + quickInfoContent.Count);
            AsmDudeToolsStatic.Print_Speed_Warning(time1, "QuickInfo");
        }
Exemplo n.º 59
0
 public static void SetForeground(DependencyObject element, Brush value)
 {
     element.SetValue(ForegroundProperty, value);
 }
Exemplo n.º 60
0
 protected override void populateGraphic(Graphics gd, Brush b, System.Drawing.Rectangle r)
 {
     using (Pen p = new Pen(Color.Black, 1)){
         gd.DrawEllipse(p, r);
     }
 }