コード例 #1
0
        public static void SaveStepPictureAsPNG(Step st, string file, ViewMaker vo)
        {
            // TODO clone tran and autozoom

            BitmapSource bit = MakeBitmap(st, vo);

            PngBitmapEncoder png = new PngBitmapEncoder();

            png.Frames.Add(BitmapFrame.Create(bit));
            File.Delete(file);
            using (Stream stm = File.Create(file))
            {
                png.Save(stm);
            }
        }
コード例 #2
0
        public ViewMaker CloneSettings()
        {
            ViewMaker vo = new ViewMaker();

            vo.width  = this.width;
            vo.height = this.height;

            vo.bShowAnnotations = this.bShowAnnotations;
            vo.bShowFaceLabels  = this.bShowFaceLabels;
            vo.bShowEndGrain    = this.bShowEndGrain;
            vo.bShowHighlights  = this.bShowHighlights;
            vo.bShowLines       = this.bShowLines;
            vo.bStaticLines     = this.bStaticLines;
            vo.bAnimate         = this.bAnimate;
            vo.bShowAxes        = this.bShowAxes;
            vo.bCloneTran       = this.bCloneTran;
            vo.bAutoZoom        = this.bAutoZoom;

            vo.transparencies = this.transparencies;
            vo.LineThickness  = this.LineThickness;

            return(vo);
        }
コード例 #3
0
        private static FixedPage CreateFixedPageForStep(Step st, PrintStuff ps)
        {
            FixedPage page = new FixedPage();

            page.Background = Brushes.White;
            page.Width      = ps.dpi * ps.page_width;
            page.Height     = ps.dpi * ps.page_height;

            double picWidth  = 4;
            double picHeight = 4;

            ViewMaker vo = new ViewMaker();

            vo.bAnimate         = false;
            vo.bShowAnnotations = true;
            vo.bShowAxes        = false;
            vo.bShowEndGrain    = true;
            vo.bShowFaceLabels  = true;
            vo.bShowHighlights  = true;
            vo.bShowLines       = true;
            vo.bStaticLines     = true;
            vo.height           = (int)(ps.dpi * picHeight);
            vo.width            = (int)(ps.dpi * picWidth);
            vo.bCloneTran       = true;
            vo.bAutoZoom        = true;
            vo.transparencies   = null;

            vo.MakeView(st);

            // Move the picture to the center of the area
            Rect r = wpfmisc.Get2DBoundingBox(vo.vp);

            vo.vp.RenderTransform = new TranslateTransform((vo.vp.Width - r.Width) / 2 - r.Left, (vo.vp.Height - r.Height) / 2 - r.Top);

            Border b = new Border();

            //b.Background = Brushes.Yellow;
            b.BorderThickness = new Thickness(1);
            b.BorderBrush     = Brushes.Black;
            b.Child           = vo.vp;

            FixedPage.SetLeft(b, ps.dpi * ps.margin_left);
            FixedPage.SetTop(b, ps.dpi * (ps.margin_left * 2));

            page.Children.Add((UIElement)b);

            TextBlock tbTitle = new TextBlock();

            tbTitle.Text       = st.Description;
            tbTitle.FontSize   = 24;
            tbTitle.FontFamily = new FontFamily("Arial");
            FixedPage.SetLeft(tbTitle, ps.dpi * ps.margin_left);
            FixedPage.SetTop(tbTitle, ps.dpi * ps.margin_top);
            page.Children.Add((UIElement)tbTitle);

            TextBlock tbProse = new TextBlock();

            tbProse.TextWrapping = TextWrapping.Wrap;
            tbProse.MaxWidth     = vo.width;
            tbProse.Text         = st.prose;
            tbProse.FontSize     = 12;
            tbProse.FontFamily   = new FontFamily("serif");
            FixedPage.SetLeft(tbProse, ps.dpi * ps.margin_left);
            FixedPage.SetTop(tbProse, ps.dpi * (ps.margin_top + 1));
            page.Children.Add((UIElement)tbProse);

            FlowDocumentScrollViewer fdsv_notes = new FlowDocumentScrollViewer();

            fdsv_notes.HorizontalScrollBarVisibility = ScrollBarVisibility.Disabled;
            fdsv_notes.VerticalScrollBarVisibility   = ScrollBarVisibility.Disabled;
            fdsv_notes.Width  = ps.dpi * 3;
            fdsv_notes.Height = ps.dpi * 3;
            if (st.Notes != null)
            {
                // TODO fdsv_notes.Document = XamlReader.Load(new XmlTextReader(new StringReader(st.Notes))) as FlowDocument;
            }
            FixedPage.SetLeft(fdsv_notes, ps.dpi * ps.margin_left);
            FixedPage.SetTop(fdsv_notes, ps.dpi * 6);
            page.Children.Add((UIElement)fdsv_notes);

            TextBlock tbCredit = new TextBlock(new Run("www.sawdust.com"));

            tbCredit.FontSize   = 10;
            tbCredit.FontFamily = new FontFamily("Arial");

            FixedPage.SetRight(tbCredit, ps.dpi * ps.margin_right);
            FixedPage.SetBottom(tbCredit, ps.dpi * ps.margin_bottom);
            page.Children.Add(tbCredit);

            Size sz = new Size(ps.dpi * ps.page_width, ps.dpi * ps.page_height);

            page.Measure(sz);
            page.Arrange(new Rect(new Point(), sz));
            page.UpdateLayout();

            return(page);
        }