コード例 #1
0
ファイル: ScoreStaffs.xaml.cs プロジェクト: teomuresan/GAtune
        private void DrawTie(double width, double left, double notePos, char orientation, byte partIndex)
        {
            Image image = new Image();

            image.Width = width;
            double height = LayoutController.ElementHeight["T"];

            image.Height = height;
            image.HorizontalAlignment = HorizontalAlignment.Left;
            double top = LayoutController.GetTieTopMargin(notePos, height, orientation, partIndex);

            image.Margin = new Thickness(left, top, 0, 0);

            DrawingVisual drawingVisual = new DrawingVisual();
            // Retrieve the DrawingContext in order to create new drawing content.
            DrawingContext drawingContext = drawingVisual.RenderOpen();

            // Concave arc.
            if (orientation == '-')
            {
                LayoutController.DrawArc(drawingContext, null, new Pen(Brushes.Black, 2),
                                         new Point(0, height / 6), new Point(width, height / 6), new Size(width, height));
            }
            // Convex arc.
            else
            {
                LayoutController.DrawArc(drawingContext, null, new Pen(Brushes.Black, 2),
                                         new Point(width, 0), new Point(0, 0), new Size(width, height));
            }
            // Persist the drawing content.
            drawingContext.Close();

            RenderTargetBitmap bmp = new RenderTargetBitmap((int)width + 50, (int)height, 120, 96, PixelFormats.Pbgra32);

            bmp.Render(drawingVisual);
            image.Source = bmp;

            staffGrid.Children.Add(image);
            Grid.SetRow(image, partIndex);
        }