Ejemplo n.º 1
0
        private void PrintGraph()
        {
            Encoders.AddEncoder <JpegEncoder>();
            Encoders.AddEncoder <PngEncoder>();

            GraphViewModel graphVM = ViewModelLocator.GraphDataStatic;

            ExtendedImage extendedImage = graphVM.GraphToImage();

            Grid          printGrid          = new Grid();
            RowDefinition printRowDefinition = new RowDefinition();

            printGrid.RowDefinitions.Add(printRowDefinition);

            Image image = new Image()
            {
                Source = extendedImage.ToBitmap()
            };

            printGrid.Children.Add(image);

            PrintDocument printDocument = new PrintDocument();

            printDocument.PrintPage += (s, args) =>
            {
                args.PageVisual   = printGrid;
                args.HasMorePages = false;
            };
            printDocument.Print("SnagL Graph");
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Used to render the contents to a tile
        /// </summary>
        /// <returns>a <see cref="StandardTileData"/> with the contents of this control</returns>
        public StandardTileData ToTile()
        {
            // Need to call these, otherwise the contents aren't rendered correctly.
            this.Measure(new Size(173, 173));
            this.Arrange(new Rect(0, 0, 173, 173));

            // The png encoder is the work of the ImageTools API. http://imagetools.codeplex.com/
            ExtendedImage tileImaged = this.ToImage();

            Encoders.AddEncoder <PngEncoder>();

            var p = new PngEncoder();

            const string tempFileName = "/Shared/ShellContent/tileImage.png";

            using (IsolatedStorageFile myIsolatedStorage = IsolatedStorageFile.GetUserStoreForApplication())
            {
                if (myIsolatedStorage.FileExists(tempFileName))
                {
                    myIsolatedStorage.DeleteFile(tempFileName);
                }

                IsolatedStorageFileStream fileStream = myIsolatedStorage.CreateFile(tempFileName);
                p.Encode(tileImaged, fileStream);
                fileStream.Close();
            }

            var newTile = new StandardTileData
            {
                Title           = Title,
                BackgroundImage =
                    new Uri("isostore:" + tempFileName, UriKind.RelativeOrAbsolute)
            };

            return(newTile);
        }
Ejemplo n.º 3
0
 /// <summary>
 /// Initializes the <see cref="ImageExtensions"/> class.
 /// </summary>
 static ImageExtensions()
 {
     Encoders.AddEncoder <PngEncoder>();
 }