Beispiel #1
0
        protected override void OnRender(DrawingContext drawingContext)
        {
            if (double.IsNaN(ActualWidth) || double.IsNaN(ActualHeight))
            {
                return;
            }

            if (!isRenderingNeeded && oldActualWidth == ActualWidth && oldActualHeight == ActualHeight)
            {
                return;
            }

            //Size has changed. Recreate all Visuals
            oldActualWidth    = ActualWidth;
            oldActualHeight   = ActualHeight;
            isRenderingNeeded = false;

            Visuals.Clear();
            Visuals.Add(crerateBackGroundVisual());
            foreach (Renderer renderer in renderers)
            {
                //////var xGridLineRenderer = renderer as XGridLineRenderer;
                //////if (xGridLineRenderer!=null) {
                //////  if (double.IsNaN(xGridLineRenderer.MinDisplayValueY) || double.IsNaN(xGridLineRenderer.MaxDisplayValueY)){
                //////    xGridLineRenderer.SetDisplayValueRangeY(xGridLineRenderer.YLegendScroller.MinDisplayValue, xGridLineRenderer.YLegendScroller.MaxDisplayValue);
                //////  }
                //////}
                Visuals.Add(renderer.CreateVisual(ActualWidth, ActualHeight));
            }
            TraceWpf.Line("PlotArea.OnRender: " + renderers.Count + " Renderer Visuals recreated");
        }
Beispiel #2
0
        // test wird sogar ausgeführt
        protected override void init()
        {
            DrawingVisual vis = new DrawingVisual();

            Visuals.Add(vis);
            System.Windows.Forms.MessageBox.Show("Bäääääää");
        }
Beispiel #3
0
 public void Add(Visual visual)
 {
     if (Children == null)
     {
         Visuals.Add(visual);
     }
     else if (RectContainsRect(Children[0].Rect, visual.WorldBoundingRect))
     {
         Children[0].Add(visual);
     }
     else if (RectContainsRect(Children[1].Rect, visual.WorldBoundingRect))
     {
         Children[1].Add(visual);
     }
     else if (RectContainsRect(Children[2].Rect, visual.WorldBoundingRect))
     {
         Children[2].Add(visual);
     }
     else if (RectContainsRect(Children[3].Rect, visual.WorldBoundingRect))
     {
         Children[3].Add(visual);
     }
     else
     {
         Visuals.Add(visual);
     }
 }
Beispiel #4
0
 /// <summary>
 /// tree
 /// </summary>
 /// <param name="subRectVisual"></param>
 protected void AddSubVisual(RectDrawingVisual subRectVisual)
 {
     if (subRectVisual == null)
     {
         return;
     }
     Visuals.Add(subRectVisual);
     subRectVisual.ParentCanvas = ParentCanvas;
 }
Beispiel #5
0
        private IShape AddShape(IShape shape)
        {
            var randomColor = Color.FromRgb((byte)rnd.Next(256), (byte)rnd.Next(256), (byte)rnd.Next(256));

            shape.Color = randomColor;
            shape.Left  = GetRandomDouble(1) * (drawAreaWidth > 0 ? (drawAreaWidth - shape.Width) : 200.0);
            shape.Top   = GetRandomDouble(1) * (drawAreaHeight > 0 ? (drawAreaHeight - shape.Height) : 200.0);
            Visuals.Add(shape);
            return(shape);
        }
Beispiel #6
0
        /// <inheritdoc/>
        protected override Size MeasureCore(Size constraint)
        {
            // Remove all visual children
            Visuals.Clear();

            // Measure the visible lines, starting at the first visible line from the scroll position
            double ypos = 0.0, xwidth = 0.0;
            var    partial_offset = (double?)null;
            var    ofs            = TextView.ScrollOffset;

            for (var doc_line = TextView.FirstVisibleLine(ofs.Y); doc_line != null; doc_line = doc_line.NextLine)
            {
                // Get/Create the visual line
                var vis_line = TextView.VisualLine(doc_line);
                vis_line.EnsureTextLines(constraint);
                vis_line.YPos = ofs.Y + ypos;

                // Record the partial offset of the first line
                partial_offset ??= vis_line.YPos - ofs.Y;                // todo

                // Record the width of the line
                xwidth = Math.Max(xwidth, vis_line.LineWidth);

                // Increment the y position by the line height
                ypos += vis_line.LineHeight;

                // Add the line as a visual child of the view
                Visuals.Add(vis_line.Graphics);
            }
            InvalidateArrange();

            // Record the partial line offset
            PartialLineOffset = partial_offset ?? 0.0;

            // Grow the document area a bit
            const bool AllowScrollBelowDocument = false;             //todo: option

            xwidth += AdditionalHorizontalScrollAmount;
            ypos   += AllowScrollBelowDocument && !double.IsInfinity(constraint.Height) ? Math.Min(0, constraint.Height - TextView.DefaultLineHeight) : 0.0;

            // Return the desired size
            return(new Size(
                       Math.Min(constraint.Width, xwidth),
                       Math.Min(constraint.Height, ypos)));
        }
Beispiel #7
0
        private void DuplicateSelected()
        {
            var newItems       = new List <IShape>();
            var selectedShapes = SelectedShapes.ToList();

            for (int i = selectedShapes.Count - 1; i >= 0; i--)
            {
                var oldItem = selectedShapes[i];
                var newItem = oldItem.Clone() as IShape;
                oldItem.IsSelected = false;
                newItem.Left      += 10;
                newItem.Top       += 10;
                newItems.Add(newItem);
            }
            foreach (var item in newItems)
            {
                Visuals.Add(item);
            }
        }
Beispiel #8
0
        public void CreateBuffer()
        {
            Body = new DigitalComponent(Shader)
            {
                PinsCount = 1,
                Delta     = Delta,
                Position  = new Vector2(X, Y)
            };
            Body.CreateBuffer();

            for (int i = 0; i < Word.Length; i++)
            {
                var letter = Word[i];
                var glyph  = new Glyph7x5(letter, new Vector2(X + Delta * (2 + i), Y + Delta * 0.4f), Shader);
                GlyphWord.Add(glyph);
            }
            MemoryGlyph = new Glyph7x5('0', new Vector2(X + Delta * 2.5f, Y + Delta * 2.0f), Shader);

            Visuals.Add(MemoryGlyph);
            Visuals.Add(Body);
            Visuals.AddRange(GlyphWord);
        }
Beispiel #9
0
 public void AddVisual(Visual visual)
 {
     Visuals.Add(visual);
 }