Exemplo n.º 1
0
        /// <summary>
        /// Builds the communication folder local.
        /// </summary>
        /// <returns>The communication folder local.</returns>
        /// <param name="icon">Icon.</param>
        public IconImage BuildCommunicationFolderLocal(Storage.CommunicationIcon icon)
        {
            IconImage image = null;

            SKSize loadedSize = Constants.DeviceLayout.GetSizeByGrid(canvasReference.CanvasSize, icon.Scale, icon.Scale);

            using (System.IO.Stream stream = App.MainAssembly.GetManifestResourceStream(icon.ResourceLocation))
            {
                SKBitmap tempBitmapPre = SKBitmap.Decode(stream);
                SKBitmap tempBitmap    = tempBitmapPre.Resize(new SKImageInfo((int)loadedSize.Width, (int)loadedSize.Width),
                                                              SKBitmapResizeMethod.Lanczos3);

                SKBitmap returnBitmap = new SKBitmap((int)System.Math.Round(tempBitmap.Width * 1.5),
                                                     (int)System.Math.Round(tempBitmap.Height * 1.5),
                                                     tempBitmap.ColorType,
                                                     tempBitmap.AlphaType);

                using (SKCanvas canvas2 = new SKCanvas(returnBitmap))
                {
                    canvas2.Clear(SKColors.Transparent);

                    canvas2.DrawBitmap(tempBitmap, SKRect.Create(System.Convert.ToInt16(tempBitmap.Width * 0.15),
                                                                 System.Convert.ToInt16(tempBitmap.Height * 0.1),
                                                                 tempBitmap.Width * 1.3f,
                                                                 tempBitmap.Height * 1.3f));

                    using (SKPaint paint = new SKPaint())
                    {
                        paint.TextSize    = Constants.DeviceLayout.TextSizeDefault * App.DisplayScaleFactor * icon.Scale;
                        paint.IsAntialias = true;
                        paint.Color       = SKColors.White;
                        paint.TextAlign   = SKTextAlign.Center;

                        canvas2.DrawText(icon.Text,
                                         (System.Convert.ToSingle(tempBitmap.Width) * 1.5f) / 2f,
                                         (System.Convert.ToSingle(tempBitmap.Height) * 1.5f) - (System.Convert.ToSingle(tempBitmap.Height) * 1.5f) / 4f,
                                         paint);
                    }

                    canvas2.Flush();
                }

                SKSize finalSize = Constants.DeviceLayout.GetSizeByGrid(canvasReference.CanvasSize,
                                                                        Constants.DeviceLayout.InterfaceDimensionDefault,
                                                                        Constants.DeviceLayout.InterfaceDimensionDefault);

                SKPoint settingsPoint;

                if ((int)icon.X == -1 || (int)icon.Y == -1)
                {
                    settingsPoint = Constants.DeviceLayout.GetCenterPoint(canvasReference.CanvasSize);
                }
                else
                {
                    settingsPoint = new SKPoint(icon.X, icon.Y);
                }

                image = new IconImage(returnBitmap)
                {
                    Tag                    = icon.Tag,
                    Text                   = icon.Text,
                    ImageInformation       = icon.ResourceLocation,
                    LocalImage             = true,
                    IsInsertableIntoFolder = false,
                    IsPinnedToSpot         = icon.IsPinned,
                    StoredFolderTag        = icon.FolderContainingIcon,
                    IsStoredInAFolder      = icon.IsStoredInFolder,
                    CurrentScale           = icon.Scale,
                    BorderColor            = SKColors.Black,
                    BorderWidth            = 2f,
                    Bounds                 = SKRect.Create(settingsPoint, loadedSize)
                };

                return(image);
            }
        }
Exemplo n.º 2
0
 public static System.Drawing.SizeF ToDrawingSize(this SKSize size)
 {
     return(new System.Drawing.SizeF(size.Width, size.Height));
 }
Exemplo n.º 3
0
        /// <inheritdoc/>
        protected override void DrawValueLabel(SKCanvas canvas, Dictionary <ChartEntry, SKRect> valueLabelSizes, float headerWithLegendHeight, SKSize itemSize, SKSize barSize, ChartEntry entry, float barX, float barY, float itemX, float origin)
        {
            if (string.IsNullOrEmpty(entry?.ValueLabel))
            {
                return;
            }

            (SKPoint location, SKSize size) = GetBarDrawingProperties(headerWithLegendHeight, itemSize, barSize, 0, barX, barY);
            if (ValueLabelOption == ValueLabelOption.TopOfChart)
            {
                base.DrawValueLabel(canvas, valueLabelSizes, headerWithLegendHeight, itemSize, entry.ValueLabelFitToBar ? barSize : SKSize.Empty, entry, barX, barY, itemX, origin);
            }
            else if (ValueLabelOption == ValueLabelOption.TopOfElement)
            {
                DrawHelper.DrawLabel(canvas, ValueLabelOrientation, ValueLabelOrientation == Orientation.Vertical ? YPositionBehavior.UpToElementHeight : YPositionBehavior.None, entry.ValueLabelFitToBar ? barSize : SKSize.Empty, new SKPoint(location.X + size.Width / 2, barY - Margin), entry.ValueLabelColor.WithAlpha((byte)(255 * AnimationProgress)), valueLabelSizes[entry], entry.ValueLabel, ValueLabelTextSize, Typeface, Margin);
            }
            else if (ValueLabelOption == ValueLabelOption.OverElement)
            {
                DrawHelper.DrawLabel(canvas, ValueLabelOrientation, ValueLabelOrientation == Orientation.Vertical ? YPositionBehavior.UpToElementMiddle : YPositionBehavior.DownToElementMiddle, entry.ValueLabelFitToBar ? barSize : SKSize.Empty, new SKPoint(location.X + size.Width / 2, barY + (origin - barY) / 2), entry.ValueLabelColor.WithAlpha((byte)(255 * AnimationProgress)), valueLabelSizes[entry], entry.ValueLabel, ValueLabelTextSize, Typeface, Margin);
            }
        }
Exemplo n.º 4
0
 /// <summary>
 /// Default constructor
 /// </summary>
 public FrameTitle7Border()
 {
     sizeRightBottom = new SKSize(0, sizeRightBottom.Height);
     float[] corners = { 15f, 1f, 1f, 1f, 1f, 15f, 15f, 15f };
     innerCorners = corners;
 }
Exemplo n.º 5
0
 /// <summary>
 /// Default constructor
 /// </summary>
 public FrameTitle2Border()
 {
     sizeLeftTop = new SKSize(sizeLeftTop.Width, defaultRadiusSize * 2f);
 }
Exemplo n.º 6
0
 /// <inheritdoc />
 protected override void DrawBarArea(SKCanvas canvas, float headerHeight, SKSize itemSize, SKSize barSize, SKColor color, float origin, float value, float barX, float barY)
 {
     if (PointAreaAlpha > 0)
     {
         var y = Math.Min(origin, barY);
         using (var shader = SKShader.CreateLinearGradient(new SKPoint(0, origin), new SKPoint(0, barY), new[] { color.WithAlpha(PointAreaAlpha), color.WithAlpha((byte)(PointAreaAlpha / 3)) }, null, SKShaderTileMode.Clamp))
             using (var paint = new SKPaint
             {
                 Style = SKPaintStyle.Fill,
                 Color = color.WithAlpha(PointAreaAlpha),
             })
             {
                 paint.Shader = shader;
                 var height = Math.Max(2, Math.Abs(origin - barY));
                 canvas.DrawRect(SKRect.Create(barX - (itemSize.Width / 2) + (barSize.Width / 2) - (PointSize / 2), y, PointSize, height), paint);
             }
     }
 }
 public TileInfo()
 {
     DefaultSize = new SKSize(60, 40);
 }
Exemplo n.º 8
0
 public SKSvg(float pixelsPerInch, SKSize canvasSize)
 {
     CanvasSize                = canvasSize;
     PixelsPerInch             = pixelsPerInch;
     ThrowOnUnsupportedElement = DefaultThrowOnUnsupportedElement;
 }
Exemplo n.º 9
0
        private (SKPoint point, SKPoint control, SKPoint nextPoint, SKPoint nextControl) CalculateCubicInfo(SKPoint[] points, int i, SKSize itemSize)
        {
            var point          = points[i];
            var nextPoint      = points[i + 1];
            var controlOffset  = new SKPoint(itemSize.Width * 0.8f, 0);
            var currentControl = point + controlOffset;
            var nextControl    = nextPoint - controlOffset;

            return(point, currentControl, nextPoint, nextControl);
        }
Exemplo n.º 10
0
        private SKPicture Load(XDocument xdoc)
        {
            var svg = xdoc.Root;
            var ns  = svg.Name.Namespace;

            // find the defs (gradients) - and follow all hrefs
            foreach (var d in svg.Descendants())
            {
                var id = d.Attribute("id")?.Value?.Trim();
                if (!string.IsNullOrEmpty(id))
                {
                    defs[id] = ReadDefinition(d);
                }
            }

            Version     = svg.Attribute("version")?.Value;
            Title       = svg.Element(ns + "title")?.Value;
            Description = svg.Element(ns + "desc")?.Value ?? svg.Element(ns + "description")?.Value;

            // TODO: parse the "preserveAspectRatio" values properly
            var preserveAspectRatio = svg.Attribute("preserveAspectRatio")?.Value;

            // get the SVG dimensions
            var viewBoxA = svg.Attribute("viewBox") ?? svg.Attribute("viewPort");

            if (viewBoxA != null)
            {
                ViewBox = ReadRectangle(viewBoxA.Value);
            }

            if (CanvasSize.IsEmpty)
            {
                // get the user dimensions
                var widthA  = svg.Attribute("width");
                var heightA = svg.Attribute("height");
                var width   = ReadNumber(widthA);
                var height  = ReadNumber(heightA);
                var size    = new SKSize(width, height);

                if (widthA == null)
                {
                    size.Width = ViewBox.Width;
                }
                else if (widthA.Value.Contains("%"))
                {
                    size.Width *= ViewBox.Width;
                }
                if (heightA == null)
                {
                    size.Height = ViewBox.Height;
                }
                else if (heightA != null && heightA.Value.Contains("%"))
                {
                    size.Height *= ViewBox.Height;
                }

                // set the property
                CanvasSize = size;
            }

            // create the picture from the elements
            using (var recorder = new SKPictureRecorder())
                using (var canvas = recorder.BeginRecording(SKRect.Create(CanvasSize)))
                {
                    // if there is no viewbox, then we don't do anything, otherwise
                    // scale the SVG dimensions to fit inside the user dimensions
                    if (!ViewBox.IsEmpty && (ViewBox.Width != CanvasSize.Width || ViewBox.Height != CanvasSize.Height))
                    {
                        if (preserveAspectRatio == "none")
                        {
                            canvas.Scale(CanvasSize.Width / ViewBox.Width, CanvasSize.Height / ViewBox.Height);
                        }
                        else
                        {
                            // TODO: just center scale for now
                            var scale    = Math.Min(CanvasSize.Width / ViewBox.Width, CanvasSize.Height / ViewBox.Height);
                            var centered = SKRect.Create(CanvasSize).AspectFit(ViewBox.Size);
                            canvas.Translate(centered.Left, centered.Top);
                            canvas.Scale(scale, scale);
                        }
                    }

                    // translate the canvas by the viewBox origin
                    canvas.Translate(-ViewBox.Left, -ViewBox.Top);

                    // if the viewbox was specified, then crop to that
                    if (!ViewBox.IsEmpty)
                    {
                        canvas.ClipRect(ViewBox);
                    }

                    LoadElements(svg.Elements(), canvas);

                    Picture = recorder.EndRecording();
                }

            return(Picture);
        }
Exemplo n.º 11
0
 public SKSvg(SKSize canvasSize)
     : this(DefaultPPI, canvasSize)
 {
 }
Exemplo n.º 12
0
        protected void DrawValueLabel(IEnumerable <Entry> serie, SKCanvas canvas, SKPoint[] points, SKSize itemSize, float height, SKRect[] valueLabelSizes)
        {
            if (points.Length > 0)
            {
                var entries = serie as Entry[] ?? serie.ToArray();
                for (int i = 0; i < points.Length; i++)
                {
                    var entry = entries.ElementAt(i);
                    var point = points[i];

                    if (!string.IsNullOrEmpty(entry.ValueLabel))
                    {
                        using (new SKAutoCanvasRestore(canvas))
                        {
                            using (var paint = new SKPaint())
                            {
                                paint.TextSize     = LabelTextSize;
                                paint.FakeBoldText = true;
                                paint.IsAntialias  = true;
                                paint.Color        = entry.Color;
                                paint.IsStroke     = false;

                                var bounds = new SKRect();
                                var text   = entry.ValueLabel;
                                paint.MeasureText(text, ref bounds);

                                if (ValueLabelRotation)
                                {
                                    canvas.RotateDegrees(90);
                                    canvas.Translate(Margin, -point.X + (bounds.Height / 2));
                                }
                                else
                                {
                                    canvas.Translate(point.X - (bounds.Width / 2),
                                                     point.Y - (SelectedPointSize / 2));
                                }


                                canvas.DrawText(text, 0, 0, paint);
                            }
                        }
                    }
                }
            }
        }
Exemplo n.º 13
0
        protected void DrawLabels(IEnumerable <Entry> serie, SKCanvas canvas, SKPoint[] points, SKSize itemSize, int height, float footerHeight)
        {
            var entries = serie as Entry[] ?? serie.ToArray();

            for (int i = 0; i < entries.Count(); i++)
            {
                var entry = entries.ElementAt(i);
                var point = points[i];

                if (!string.IsNullOrEmpty(entry.Label))
                {
                    using (var paint = new SKPaint())
                    {
                        paint.TextSize    = LabelTextSize;
                        paint.IsAntialias = true;
                        paint.Color       = entry.TextColor;
                        paint.IsStroke    = false;

                        var bounds = new SKRect();
                        var text   = entry.Label;
                        paint.MeasureText(text, ref bounds);

                        if (bounds.Width > itemSize.Width)
                        {
                            text = text.Substring(0, Math.Min(3, text.Length));
                            paint.MeasureText(text, ref bounds);
                        }

                        if (bounds.Width > itemSize.Width)
                        {
                            text = text.Substring(0, Math.Min(1, text.Length));
                            paint.MeasureText(text, ref bounds);
                        }

                        canvas.DrawText(text, point.X - (bounds.Width / 2), height - (Margin + (LabelTextSize / 2)), paint);
                    }
                }
            }
        }
Exemplo n.º 14
0
 protected void DrawFooter(IEnumerable <Entry> serie, SKCanvas canvas, SKPoint[] points, SKSize itemSize, int height, float footerHeight)
 {
     DrawLabels(serie, canvas, points, itemSize, height, footerHeight);
 }
Exemplo n.º 15
0
        /// <inheritdoc />
        protected override void DrawValueLabel(SKCanvas canvas, Dictionary <ChartEntry, SKRect> valueLabelSizes, float headerWithLegendHeight, SKSize itemSize, SKSize barSize, ChartEntry entry, float barX, float barY, float itemX, float origin)
        {
            if (string.IsNullOrEmpty(entry?.ValueLabel))
            {
                return;
            }

            var drawedPoint = new SKPoint(barX - (itemSize.Width / 2) + (barSize.Width / 2), barY);

            if (ValueLabelOption == ValueLabelOption.TopOfChart)
            {
                base.DrawValueLabel(canvas, valueLabelSizes, headerWithLegendHeight, itemSize, barSize, entry, barX, barY, itemX, origin);
            }
            else if (ValueLabelOption == ValueLabelOption.TopOfElement)
            {
                DrawHelper.DrawLabel(canvas, ValueLabelOrientation, ValueLabelOrientation == Orientation.Vertical ? YPositionBehavior.UpToElementHeight : YPositionBehavior.None, barSize, new SKPoint(drawedPoint.X, drawedPoint.Y - (PointSize / 2) - (Margin / 2)), entry.ValueLabelColor.WithAlpha((byte)(255 * AnimationProgress)), valueLabelSizes[entry], entry.ValueLabel, ValueLabelTextSize, Typeface, AllowValueLabelOverflow);
            }
            else if (ValueLabelOption == ValueLabelOption.OverElement)
            {
                DrawHelper.DrawLabel(canvas, ValueLabelOrientation, ValueLabelOrientation == Orientation.Vertical ? YPositionBehavior.UpToElementMiddle : YPositionBehavior.DownToElementMiddle, barSize, new SKPoint(drawedPoint.X, drawedPoint.Y), entry.ValueLabelColor.WithAlpha((byte)(255 * AnimationProgress)), valueLabelSizes[entry], entry.ValueLabel, ValueLabelTextSize, Typeface, AllowValueLabelOverflow);
            }
        }
Exemplo n.º 16
0
        public override void Run(
            )
        {
            ActionEnum action = PromptAction();

            // Opening the PDF file...
            string mainFilePath = PromptFileChoice("Please select a PDF file");

            using (var mainFile = new File(mainFilePath))
            {
                Document mainDocument   = mainFile.Document;
                Pages    mainPages      = mainDocument.Pages;
                int      mainPagesCount = mainPages.Count;

                switch (action)
                {
                case ActionEnum.PageDataSizeCalculation:
                {
                    Console.WriteLine("\nThis algorithm calculates the data size (expressed in bytes) of the selected document's pages.");
                    Console.WriteLine("Legend:");
                    Console.WriteLine(" * full: page data size encompassing all its dependencies (like shared resources) -- this is the size of the page when extracted as a single-page document;");
                    Console.WriteLine(" * differential: additional page data size -- this is the extra-content that's not shared with previous pages;");
                    Console.WriteLine(" * incremental: data size of the page sublist encompassing all the previous pages and the current one.\n");

                    // Calculating the page data sizes...
                    HashSet <PdfReference> visitedReferences = new HashSet <PdfReference>();
                    long incrementalDataSize = 0;
                    foreach (Page page in mainPages)
                    {
                        long pageFullDataSize         = PageManager.GetSize(page);
                        long pageDifferentialDataSize = PageManager.GetSize(page, visitedReferences);
                        incrementalDataSize += pageDifferentialDataSize;

                        Console.WriteLine(
                            "Page " + page.Number + ": "
                            + pageFullDataSize + " (full); "
                            + pageDifferentialDataSize + " (differential); "
                            + incrementalDataSize + " (incremental)"
                            );
                    }
                }
                break;

                case ActionEnum.BlankPageDetection:
                {
                    Console.WriteLine(
                        "\nThis algorithm makes a simple guess about whether a page should be considered empty:"
                        + "\nit evaluates the middle portion (70%) of a page assuming that possible contents"
                        + "\noutside this area would NOT qualify as actual (informative) content (such as"
                        + "\nredundant patterns like footers and headers). Obviously, this assumption may need"
                        + "\nsome fine-tuning as each document features its own layout ratios. Alternatively,"
                        + "\nan adaptive algorithm should automatically evaluate the content role based on its"
                        + "\ntypographic attributes in relation to the other contents existing in the same page"
                        + "\nor document.\n");
                    int blankPageCount = 0;
                    foreach (Page page in mainPages)
                    {
                        SKRect pageBox    = page.Box;
                        SKSize margin     = new SKSize(pageBox.Width * .15f, pageBox.Height * .15f);
                        SKRect contentBox = SKRect.Create(margin.Width, margin.Height, pageBox.Width - margin.Width * 2, pageBox.Height - margin.Height * 2);
                        if (PageManager.IsBlank(page, contentBox))
                        {
                            blankPageCount++;
                            Console.WriteLine("Page " + page.Number + " is blank");
                        }
                    }
                    Console.WriteLine(blankPageCount > 0 ? "Blank pages detected: " + blankPageCount + " of " + mainPages.Count : "No blank pages detected.");
                }
                break;

                case ActionEnum.PageAddition:
                {
                    // Opening the source file...
                    string sourceFilePath = PromptFileChoice("Select the source PDF file");
                    using (var sourceFile = new File(sourceFilePath))
                    {
                        // Source page collection.
                        Pages sourcePages = sourceFile.Document.Pages;
                        // Source page count.
                        int sourcePagesCount = sourcePages.Count;

                        // First page to add.
                        int fromSourcePageIndex = PromptPageChoice("Select the start source page to add", sourcePagesCount);
                        // Last page to add.
                        int toSourcePageIndex = PromptPageChoice("Select the end source page to add", fromSourcePageIndex, sourcePagesCount) + 1;
                        // Target position.
                        int targetPageIndex = PromptPageChoice("Select the position where to insert the source pages", mainPagesCount + 1);

                        // Add the chosen page range to the main document!
                        new PageManager(mainDocument).Add(
                            targetPageIndex,
                            sourcePages.GetSlice(
                                fromSourcePageIndex,
                                toSourcePageIndex
                                )
                            );
                    }
                    // Serialize the main file!
                    Serialize(mainFile, action);
                }
                break;

                case ActionEnum.PageMovement:
                {
                    // First page to move.
                    int fromSourcePageIndex = PromptPageChoice("Select the start page to move", mainPagesCount);
                    // Last page to move.
                    int toSourcePageIndex = PromptPageChoice("Select the end page to move", fromSourcePageIndex, mainPagesCount) + 1;
                    // Target position.
                    int targetPageIndex = PromptPageChoice("Select the position where to insert the pages", mainPagesCount + 1);

                    // Move the chosen page range!
                    new PageManager(mainDocument).Move(
                        fromSourcePageIndex,
                        toSourcePageIndex,
                        targetPageIndex
                        );

                    // Serialize the main file!
                    Serialize(mainFile, action);
                }
                break;

                case ActionEnum.PageRemoval:
                {
                    // First page to remove.
                    int fromPageIndex = PromptPageChoice("Select the start page to remove", mainPagesCount);
                    // Last page to remove.
                    int toPageIndex = PromptPageChoice("Select the end page to remove", fromPageIndex, mainPagesCount) + 1;

                    // Remove the chosen page range!
                    new PageManager(mainDocument).Remove(
                        fromPageIndex,
                        toPageIndex
                        );

                    // Serialize the main file!
                    Serialize(mainFile, action);
                }
                break;

                case ActionEnum.PageExtraction:
                {
                    // First page to extract.
                    int fromPageIndex = PromptPageChoice("Select the start page", mainPagesCount);
                    // Last page to extract.
                    int toPageIndex = PromptPageChoice("Select the end page", fromPageIndex, mainPagesCount) + 1;

                    // Extract the chosen page range!
                    Document targetDocument = new PageManager(mainDocument).Extract(
                        fromPageIndex,
                        toPageIndex
                        );

                    // Serialize the target file!
                    Serialize(targetDocument.File, action);
                }
                break;

                case ActionEnum.DocumentMerge:
                {
                    // Opening the source file...
                    string sourceFilePath = PromptFileChoice("Select the source PDF file");
                    using (var sourceFile = new File(sourceFilePath))
                    {
                        // Append the chosen source document to the main document!
                        new PageManager(mainDocument).Add(sourceFile.Document);
                    }
                    // Serialize the main file!
                    Serialize(mainFile, action);
                }
                break;

                case ActionEnum.DocumentBurst:
                {
                    // Split the document into single-page documents!
                    IList <Document> splitDocuments = new PageManager(mainDocument).Split();

                    // Serialize the split files!
                    int index = 0;
                    foreach (Document splitDocument in splitDocuments)
                    {
                        Serialize(splitDocument.File, action, ++index);
                    }
                }
                break;

                case ActionEnum.DocumentSplitByPageIndex:
                {
                    // Number of splits to apply to the source document.
                    int splitCount;
                    try
                    { splitCount = Int32.Parse(PromptChoice("Number of split positions: ")); }
                    catch
                    { splitCount = 0; }

                    // Split positions within the source document.
                    int[] splitIndexes = new int[splitCount];
                    {
                        int prevSplitIndex = 0;
                        for (int index = 0; index < splitCount; index++)
                        {
                            int splitIndex = PromptPageChoice("Position " + (index + 1) + " of " + splitCount, prevSplitIndex + 1, mainPagesCount);
                            splitIndexes[index] = splitIndex;
                            prevSplitIndex      = splitIndex;
                        }
                    }

                    // Split the document at the chosen positions!
                    IList <Document> splitDocuments = new PageManager(mainDocument).Split(splitIndexes);

                    // Serialize the split files!
                    {
                        int index = 0;
                        foreach (Document splitDocument in splitDocuments)
                        {
                            Serialize(splitDocument.File, action, ++index);
                        }
                    }
                }
                break;

                case ActionEnum.DocumentSplitOnMaximumFileSize:
                {
                    // Maximum file size.
                    long maxDataSize;
                    {
                        long mainFileSize = new io::FileInfo(mainFilePath).Length;
                        int  kbMaxDataSize;
                        do
                        {
                            try
                            { kbMaxDataSize = Int32.Parse(PromptChoice("Max file size (KB): ")); }
                            catch
                            { kbMaxDataSize = 0; }
                        } while (kbMaxDataSize == 0);
                        maxDataSize = kbMaxDataSize << 10;
                        if (maxDataSize > mainFileSize)
                        {
                            maxDataSize = mainFileSize;
                        }
                    }

                    // Split the document on maximum file size!
                    IList <Document> splitDocuments = new PageManager(mainDocument).Split(maxDataSize);

                    // Serialize the split files!
                    {
                        int index = 0;
                        foreach (Document splitDocument in splitDocuments)
                        {
                            Serialize(splitDocument.File, action, ++index);
                        }
                    }
                }
                break;
                }
            }
        }
Exemplo n.º 17
0
 /// <inheritdoc />
 protected override void DrawBar(ChartSerie serie, SKCanvas canvas, float headerHeight, float itemX, SKSize itemSize, SKSize barSize, float origin, float barX, float barY, SKColor color)
 {
     if (PointMode != PointMode.None)
     {
         var point = new SKPoint(barX - (itemSize.Width / 2) + (barSize.Width / 2), barY);
         canvas.DrawPoint(point, color, PointSize, PointMode);
     }
 }
Exemplo n.º 18
0
 protected void DrawFooter(SKCanvas canvas, SKPoint[] points, SKSize itemSize, int height, float footerHeight)
 {
     this.DrawLabels(canvas, points, itemSize, height, footerHeight);
 }
Exemplo n.º 19
0
        public void LoadList(HandObservable <CA> thisMod, string tagUsed)
        {
            CA firstCard;

            _tagUsed       = tagUsed;
            BindingContext = thisMod;
            SetBinding(TextProperty, new Binding(nameof(HandObservable <CA> .Text)));
            SetBinding(IsEnabledProperty, new Binding(nameof(HandObservable <CA> .IsEnabled)));
            _thisMod = thisMod;
            if (_alreadyLoaded == true)
            {
                throw new BasicBlankException("Needs some rethinking because i intended to load once");
            }
            if (_thisMod.HandList.Count == 0)
            {
                firstCard = new CA();
            }
            else
            {
                firstCard = _thisMod.HandList.First();
            }

            if (firstCard.DefaultSize.Height == 0 || firstCard.DefaultSize.Width == 0)
            {
                throw new BasicBlankException("The width and height must be greater than 0 when initializging hand wpf");
            }
            IGamePackageResolver thisR = (IGamePackageResolver)cons !;
            IProportionImage     thisI = thisR.Resolve <IProportionImage>(tagUsed);

            _sizeUsed  = firstCard.DefaultSize.GetSizeUsed(thisI.Proportion);
            ObjectList = _thisMod.HandList;
            ObjectList.CollectionChanged += ObjectList_CollectionChanged;
            ThisScroll = new ScrollView();
            if (HasAngles == false)
            {
                _thisStack         = new GameOverlapLayout <CA, GC>(_sizeUsed);
                _thisStack.Spacing = 0;
            }
            else
            {
                _otherStack         = new StackLayout();
                _otherStack.Spacing = 0;
            }
            SetBinding(MaximumCardsProperty, new Binding(nameof(HandObservable <CA> .Maximum)));
            PositionMainControls();
            PopulateList();
            SetVisibleConverter();
            _thisGrid.Children.Add(ThisDraw);
            ThisScroll.HorizontalScrollBarVisibility = ScrollBarVisibility.Default;
            ThisScroll.VerticalScrollBarVisibility   = ScrollBarVisibility.Default; //try this too.
            if (HasAngles == false)
            {
                ThisScroll.Content = _thisStack;
            }
            else
            {
                ThisScroll.Content = _otherStack;
            }
            var thisRect = ThisFrame.GetControlArea();

            if (HasAngles == false)
            {
                ThisScroll.Margin = new Thickness(thisRect.Left - 1, thisRect.Top - 1, 0, 3); // try this way.
            }
            else
            {
                ThisScroll.Margin = new Thickness(thisRect.Left - 1, thisRect.Top - 1, 3, 3);
            }
            _thisGrid.Children.Add(ThisScroll);
            RecalulateFrames();
            _drawControl = new SKCanvasView();
            _drawControl.EnableTouchEvents = true;
            _drawControl.Touch            += DrawControlTouch;
            _thisGrid.Children.Add(_drawControl);
            Content        = _thisGrid;
            _alreadyLoaded = true;
        }
Exemplo n.º 20
0
 public static Size ToSize(this SKSize size)
 {
     return(new Size((int)size.Width, (int)size.Height));
 }
Exemplo n.º 21
0
 /// <summary>
 /// Default constructor
 /// </summary>
 public FrameTitle5Border()
 {
     sizeLeftTop = new SKSize(sizeLeftTop.Width, defaultRadiusSize * 2f);
     drawScrews  = true;
 }
Exemplo n.º 22
0
 protected override SKSize MeasureOverride(SKSize availableSize)
 {
     return(SKSize.Empty);
 }
Exemplo n.º 23
0
 /// <summary>
 /// Default constructor
 /// </summary>
 public FrameThin1Border()
 {
     sizeLeftTop     = new SKSize(defaultRadiusSize * .8f, defaultRadiusSize * .8f);
     sizeRightBottom = new SKSize(defaultRadiusSize * .8f, defaultRadiusSize * .8f);
 }
Exemplo n.º 24
0
        private void BuildSteps(
            PrimitiveComposer composer,
            string[] steps,
            colorSpaces::Color[] colors,
            SKSize pageSize
            )
        {
            composer.SetFont(ResourceName_DefaultFont, 32);
            SKRect frame = SKRect.Create(
                0,
                0,
                pageSize.Width,
                pageSize.Height
                );

            // Step 0.
            {
                colors[0] = new colorSpaces::DeviceRGBColor(30 / 255d, 10 / 255d, 0);
                composer.SetFillColor(colors[0]);
                composer.SetStrokeColor(colors[0]);

                // Draw the page frame!
                composer.DrawRectangle(frame);
                composer.Stroke();

                // Draw the lower-left corner mark!
                composer.ShowText(
                    "Step 0",
                    new SKPoint(0, pageSize.Height),
                    XAlignmentEnum.Left,
                    YAlignmentEnum.Bottom,
                    0
                    );

                steps[0] = GetStepNote(composer, "default");
            }

            // Step 1.
            {
                colors[1] = new colorSpaces::DeviceRGBColor(80 / 255d, 25 / 255d, 0);
                composer.SetFillColor(colors[1]);
                composer.SetStrokeColor(colors[1]);

                // Transform the coordinate space, applying translation!
                composer.Translate(72, 72);

                // Draw the page frame!
                composer.DrawRectangle(frame);
                composer.Stroke();

                // Draw the lower-left corner mark!
                composer.ShowText(
                    "Step 1",
                    new SKPoint(0, pageSize.Height),
                    XAlignmentEnum.Left,
                    YAlignmentEnum.Bottom,
                    0
                    );

                steps[1] = GetStepNote(composer, "after translate(72,72)");
            }

            // Step 2.
            {
                colors[2] = new colorSpaces::DeviceRGBColor(130 / 255d, 45 / 255d, 0);
                composer.SetFillColor(colors[2]);
                composer.SetStrokeColor(colors[2]);

                // Transform the coordinate space, applying clockwise rotation!
                composer.Rotate(-20);

                // Draw the page frame!
                composer.DrawRectangle(frame);
                composer.Stroke();

                // Draw the coordinate space origin mark!
                composer.ShowText("Origin 2");

                // Draw the lower-left corner mark!
                composer.ShowText(
                    "Step 2",
                    new SKPoint(0, pageSize.Height),
                    XAlignmentEnum.Left,
                    YAlignmentEnum.Bottom,
                    0
                    );

                steps[2] = GetStepNote(composer, "after rotate(20)");
            }

            // Step 3.
            {
                colors[3] = new colorSpaces::DeviceRGBColor(180 / 255d, 60 / 255d, 0);
                composer.SetFillColor(colors[3]);
                composer.SetStrokeColor(colors[3]);

                // Transform the coordinate space, applying translation and scaling!
                composer.Translate(0, 72);
                composer.Scale(.5f, .5f);

                // Draw the page frame!
                composer.DrawRectangle(frame);
                composer.Stroke();

                // Draw the lower-left corner mark!
                composer.ShowText(
                    "Step 3",
                    new SKPoint(0, pageSize.Height),
                    XAlignmentEnum.Left,
                    YAlignmentEnum.Bottom,
                    0
                    );

                steps[3] = GetStepNote(composer, "after translate(0,72) and scale(.5,.5)");
            }

            // Step 4.
            {
                colors[4] = new colorSpaces::DeviceRGBColor(230 / 255d, 75 / 255d, 0);
                composer.SetFillColor(colors[4]);
                composer.SetStrokeColor(colors[4]);

                // Transform the coordinate space, restoring its initial CTM!
                composer.Add(
                    ModifyCTM.GetResetCTM(
                        composer.Scanner.State
                        )
                    );

                // Draw the page frame!
                composer.DrawRectangle(frame);
                composer.Stroke();

                // Draw the lower-left corner mark!
                composer.ShowText(
                    "Step 4",
                    new SKPoint(0, pageSize.Height),
                    XAlignmentEnum.Left,
                    YAlignmentEnum.Bottom,
                    0
                    );

                steps[4] = GetStepNote(composer, "after resetting CTM");
            }
        }
Exemplo n.º 25
0
 public void set_size(SKSize size)
 {
     size_ = size;
 }
Exemplo n.º 26
0
        private void BuildLegend(PrimitiveComposer composer, string[] steps, colorSpaces::Color[] colors, SKSize pageSize)
        {
            float maxCtmInversionApproximation;
            {
                float[] ctmInversionApproximations = new float[9];
                {
                    float[] initialCtmValues, finalCtmValues;
                    {
                        var state = composer.Scanner.State;
                        initialCtmValues = state.GetInitialCtm().Values;
                        finalCtmValues   = state.Ctm.Values;
                    }
                    for (
                        int index = 0,
                        length = finalCtmValues.Length;
                        index < length;
                        index++
                        )
                    {
                        ctmInversionApproximations[index] = Math.Abs(finalCtmValues[index]) - initialCtmValues[index];
                    }
                }
                maxCtmInversionApproximation = Max(ctmInversionApproximations);
            }

            BlockComposer blockComposer = new BlockComposer(composer);

            blockComposer.LineSpace = new Length(.25, Length.UnitModeEnum.Relative);

            composer.BeginLocalState();
            composer.SetFillColor(
                new colorSpaces::DeviceRGBColor(115 / 255d, 164 / 255d, 232 / 255d)
                );
            SKRect frame = SKRect.Create(
                18,
                18,
                pageSize.Width * .5f,
                pageSize.Height * .5f
                );

            blockComposer.Begin(frame, XAlignmentEnum.Left, YAlignmentEnum.Top);
            composer.SetFont(ResourceName_DefaultFont, 24);
            blockComposer.ShowText("Page coordinates sample");
            SKSize breakSize = new SKSize(0, 8);

            blockComposer.ShowBreak(breakSize);
            composer.SetFont(ResourceName_DefaultFont, 8);
            blockComposer.ShowText(
                "This sample shows the effects of the manipulation of the CTM (Current Transformation Matrix), "
                + "that is the mathematical device which affects the page coordinate system used to place "
                + "graphic contents onto the canvas."
                );
            blockComposer.ShowBreak(breakSize);
            blockComposer.ShowText(
                "The following steps represent the operations applied to this page's CTM in order to alter it. "
                + "Each step writes the word \"Step\" at the lower-left corner of the current page frame:"
                );
            blockComposer.ShowBreak(breakSize);
            for (int i = 0; i < steps.Length; i++)
            {
                composer.SetFillColor(colors[i]);
                blockComposer.ShowText("Step " + i + ")");
                composer.SetFillColor(
                    new colorSpaces::DeviceRGBColor(115 / 255d, 164 / 255d, 232 / 255d)
                    );
                blockComposer.ShowText(" " + steps[i]);
                blockComposer.ShowBreak(breakSize);
            }
            blockComposer.ShowText("Note that the approximation (" + maxCtmInversionApproximation + ") of the CTM components at step 4 is due to floating point precision limits; their exact values should be 1.0, 0.0, 0.0, 1.0, 0.0, 0.0.");
            blockComposer.End();
            composer.End();
        }
Exemplo n.º 27
0
 /// <inheritdoc />
 protected override void DrawBarArea(SKCanvas canvas, float headerHeight, SKSize itemSize, SKSize barSize, SKColor color, float origin, float value, float barX, float barY)
 {
     if (BarAreaAlpha > 0)
     {
         using (var paint = new SKPaint
         {
             Style = SKPaintStyle.Fill,
             Color = color.WithAlpha((byte)(this.BarAreaAlpha * this.AnimationProgress)),
         })
         {
             var max    = value > 0 ? headerHeight : headerHeight + itemSize.Height;
             var height = Math.Abs(max - barY);
             var y      = Math.Min(max, barY);
             canvas.DrawRect(SKRect.Create(barX - (itemSize.Width / 2), y, barSize.Width, height), paint);
         }
     }
 }
Exemplo n.º 28
0
 public FluxxCardInformation()
 {
     DefaultSize = new SKSize(73, 113);
 }
Exemplo n.º 29
0
 /// <inheritdoc />
 protected override void DrawBar(ChartSerie serie, SKCanvas canvas, float headerHeight, float itemX, SKSize itemSize, SKSize barSize, float origin, float barX, float barY, SKColor color)
 {
     using (var paint = new SKPaint
     {
         Style = SKPaintStyle.Fill,
         Color = color,
     })
     {
         (SKPoint location, SKSize size) = GetBarDrawingProperties(headerHeight, itemSize, barSize, origin, barX, barY);
         var rect = SKRect.Create(location, size);
         canvas.DrawRect(rect, paint);
     }
 }
Exemplo n.º 30
0
        /// <summary>
        /// Builds user interface icons
        /// </summary>
        /// <returns>The named icon.</returns>
        /// <param name="resource">Resource.</param>
        /// <param name="text">Text.</param>
        /// <param name="x">The x coordinate.</param>
        /// <param name="y">The y coordinate.</param>
        /// <param name="tagCode">Tag code.</param>
        /// <param name="alignRight">If set to <c>true</c> align right.</param>
        /// <param name="alignBottom">If set to <c>true</c> align bottom.</param>
        /// <param name="opaqueBackground">If set to <c>true</c> opaque background.</param>
        public IconImage BuildNamedIcon(string resource, string text, float x, float y, int tagCode,
                                        bool alignRight       = false,
                                        bool alignBottom      = false,
                                        bool opaqueBackground = false)
        {
            IconImage image = null;

            SKSize loadedSize = Constants.DeviceLayout.GetSizeByGrid(canvasReference.CanvasSize, 1f, 1f);

            using (System.IO.Stream stream = App.MainAssembly.GetManifestResourceStream(resource))
            {
                SKBitmap tempBitmapPre = SKBitmap.Decode(stream);
                SKBitmap tempBitmap    = tempBitmapPre.Resize(new SKImageInfo((int)loadedSize.Width, (int)loadedSize.Width),
                                                              SKBitmapResizeMethod.Lanczos3);
                //SkiaSharp.SKBitmap tempBitmap = SkiaSharp.SKBitmap.Decode(stream);

                SKBitmap returnBitmap = new SKBitmap((int)System.Math.Round(tempBitmap.Width * 1.5),
                                                     (int)System.Math.Round(tempBitmap.Height * 1.5),
                                                     tempBitmap.ColorType,
                                                     tempBitmap.AlphaType);

                using (SKCanvas canvas2 = new SKCanvas(returnBitmap))
                {
                    if (opaqueBackground)
                    {
                        canvas2.Clear(SKColors.White);
                    }
                    else
                    {
                        canvas2.Clear(SKColors.Transparent);
                    }


                    canvas2.DrawBitmap(tempBitmap, SKRect.Create(System.Convert.ToInt16(tempBitmap.Width * 0.25),
                                                                 System.Convert.ToInt16(tempBitmap.Height * 0.1),
                                                                 tempBitmap.Width,
                                                                 tempBitmap.Height));

                    using (SKPaint paint = new SKPaint())
                    {
                        paint.TextSize    = Constants.DeviceLayout.TextSizeDefault * App.DisplayScaleFactor;
                        paint.IsAntialias = true;
                        paint.Color       = SKColors.Black;
                        paint.TextAlign   = SKTextAlign.Center;

                        canvas2.DrawText(text,
                                         (System.Convert.ToSingle(tempBitmap.Width) * 1.5f) / 2f,
                                         (System.Convert.ToSingle(tempBitmap.Height) * 1.35f),
                                         paint);
                    }

                    canvas2.Flush();

                    SKSize finalSize = Constants.DeviceLayout.GetSizeByGrid(canvasReference.CanvasSize,
                                                                            Constants.DeviceLayout.InterfaceDimensionDefault,
                                                                            Constants.DeviceLayout.InterfaceDimensionDefault);


                    SKPoint settingsPoint;

                    if ((int)x == -1 || (int)y == -1)
                    {
                        settingsPoint = Constants.DeviceLayout.GetCenterPoint(canvasReference.CanvasSize);
                    }
                    else
                    {
                        settingsPoint = new SKPoint(x, y);
                    }

                    if (alignRight)
                    {
                        settingsPoint.X -= finalSize.Width;
                    }

                    if (alignBottom)
                    {
                        settingsPoint.Y -= finalSize.Height;
                    }


                    image = new IconImage(returnBitmap)
                    {
                        Tag                    = tagCode,
                        Text                   = text,
                        BorderColor            = SKColors.Black,
                        LocalImage             = true,
                        ImageInformation       = resource,
                        IsInsertableIntoFolder = false,
                        StoredFolderTag        = "",
                        BorderWidth            = 2f,
                        Bounds                 = SKRect.Create(settingsPoint, finalSize)
                    };

                    return(image);
                }
            }
        }