public static void Print(RadGanttView ganttView)
        {
            var isFirstPass  = true;
            var exportImages = Enumerable.Empty <BitmapSource>();
            var enumerator   = exportImages.GetEnumerator();
            var pd           = new System.Windows.Printing.PrintDocument();

            pd.BeginPrint += pd_BeginPrint;
            pd.PrintPage  += (s, e) =>
            {
                if (isFirstPass)
                {
                    var printingSettings = new ImageExportSettings(e.PrintableArea, true, GanttArea.AllAreas);
                    using (var export = ganttView.ExportingService.BeginExporting(printingSettings))
                    {
                        exportImages = export.ImageInfos.ToList().Select(info => info.Export());
                        enumerator   = exportImages.GetEnumerator();
                        enumerator.MoveNext();
                    }
                    isFirstPass = false;
                }

                e.PageVisual = PrintPage(enumerator.Current);
                enumerator.MoveNext();
                e.HasMorePages = enumerator.Current != null;
            };
            pd.Print("Gantt");
        }
 private void btPrint_Click(object sender, RoutedEventArgs e)
 {
     PrintDocument printDocument = new PrintDocument();
     printDocument.PrintPage += new EventHandler<PrintPageEventArgs>(printDocument_PrintPage);
     printDocument.EndPrint += new EventHandler<EndPrintEventArgs>(printDocument_EndPrint);
     printDocument.Print("print job");
 }
Beispiel #3
0
        public static void PrintGrid(this DataGrid source,PagedCollectionView pcv)
        {
            var dg = source.ToPrintFriendlyGrid(pcv);
            var doc = new PrintDocument();

            var offsetY = 0d;
            var totalHeight = 0d;
            var canvas = new Canvas();
            canvas.Children.Add(dg);
            doc.PrintPage += (s, e) =>
            {
                e.PageVisual = canvas;
                canvas.Margin = new Thickness(50);
                if (totalHeight == 0)
                {
                    totalHeight = dg.DesiredSize.Height;
                }

                Canvas.SetTop(dg, -offsetY);

                offsetY += e.PrintableArea.Height;

                e.HasMorePages = offsetY <= totalHeight;
            };


            doc.Print(null);
        }
Beispiel #4
0
		public void NonUserInitiated ()
		{
			bool begin = false;
			bool end = false;
			bool print = false;

			PrintDocument pd = new PrintDocument ();
			pd.BeginPrint += delegate {
				begin = true;
			};
			pd.EndPrint += delegate {
				end = true;
			};
			pd.PrintPage += delegate {
				print = true;
			};

			Enqueue (() => {
				Assert.Throws<SecurityException> (delegate {
					pd.Print (null);
				}, "Print");
			});
			// no event is firedPrintDocument if call to Print was not user initiated
			EnqueueConditional (() => begin == end == print == false);
			EnqueueTestComplete ();
		}
 private void btPrint_Click(object sender, RoutedEventArgs e)
 {
     PrintDocument doc = new PrintDocument();
     doc.BeginPrint += new EventHandler<BeginPrintEventArgs>(doc_BeginPrint);
     doc.PrintPage += new EventHandler<PrintPageEventArgs>(doc_PrintPage);
     doc.EndPrint += new EventHandler<EndPrintEventArgs>(doc_EndPrint);
     doc.Print("resizeprint");
 }
Beispiel #6
0
        public static void PrintForm(this UIElement source)
        {
            var doc = new PrintDocument();
            doc.PrintPage += (s, e) =>
            {
                e.PageVisual = source;
            };

            doc.Print(null);
        }
        private void btnPrint_Click(object sender, RoutedEventArgs e)
        {
            var pd = new PrintDocument();
            pd.PrintPage += (s, args) =>
            {
                args.PageVisual = logEntryEventArgsDataGrid;
            };

            pd.Print("Logs TZero");
        }
        public static void PrintPage(string title, UIElement objectToPrint)
        {
            var pd = new PrintDocument();

            pd.PrintPage += (s, args) =>
            {
                args.PageVisual = objectToPrint;
            };

            pd.Print(title);
        }
 private void OKButton_Click(object sender, RoutedEventArgs e)
 {
     PrintDocument printDocument = new PrintDocument();
              
     printDocument.PrintPage += (s, pe) =>
     {
         //this.ReportRoot.Height = pe.PrintableArea.Height;
         //this.ReportRoot.Width = pe.PrintableArea.Width;
         pe.PageVisual = this.ReportRoot;
         pe.HasMorePages = false;
         
     };
     printDocument.Print("Voucher");
 }
 public MainPage()
 {
     InitializeComponent();
     VersionBlock.DataContext = this;
     graphView = new View.Graph(canvas1);
     pd = new PrintDocument();
     pd.PrintPage += new EventHandler<PrintPageEventArgs>(pd_PrintPage);
     graphView.ChangeDataGrid += new EventHandler<MyLib.Event.Args<List<View.Graph.RelationData>>>(graphView_ChangeDataGrid);
     MyLib.Task.Utility.UISyncContext = System.Threading.Tasks.TaskScheduler.FromCurrentSynchronizationContext();
     ClusteringSettingPanel.DataContext = ClusteringViewModel;
     fileInputControl.Update = (n) => { clusterTable = n; ChangeClusterTable(); };
     fileInputControl.UpdateClustering = (n) => { clusterTable = n; ChangeClusterTable();ClusteringViewModel.Run(); };
     fileInputControl.GetClutsterTable = () => { return clusterTable; };
 }
Beispiel #11
0
        public static void Print(this Panel panel)
        {
            // Create new a new PrintDocument object
            PrintDocument pd = new PrintDocument();

            // Set the printable area
            pd.PrintPage += (s, args) =>
            {
                args.PageVisual = panel;
            };

            // Print the document
            pd.Print("Rawr");
        }
        private void Print(ChildWindow window)
        {
            var doc = new PrintDocument();

            doc.PrintPage += (s, ea) =>
            {
                ea.PageVisual = new Image { Source = new BitmapImage(Uri) };
                ea.HasMorePages = false;
            };

            doc.EndPrint += (sender, args) => window.Close();

            var settings = new PrinterFallbackSettings { ForceVector = false };

            doc.Print(Title, settings);
        }
        private void PrintCommandExecute()
        {
            var printer = new PrintDocument();
            printer.PrintPage += (printerObj, printerArgs) =>
                                     {
                                         printerArgs.PageVisual = PageVisual;
                                     };

            printer.EndPrint += (printerObj, printerArgs) =>
                                    {
                                        SetWait(false);
                                        InvokeClose();
                                    };

            SetWait(true);
            printer.Print("договор");
        }
 private void OKButton_Click(object sender, RoutedEventArgs e)
 {
     PrintDocument lPoint = new PrintDocument();
     lPoint.PrintPage += new EventHandler<PrintPageEventArgs>(report_PrintPage);
     lPoint.Print("Report");
 }
Beispiel #15
0
        protected void printDocument()
        {
            multidoc = new PrintDocument();
            int index = 0;
            List<StackPanel> pages=null;

            StackPanel host=null;
            Grid layout=null;
            Grid grid=null;
            TextBlock page=null;
            bool isFirstPage=true;
            double width=0;
            double height=0;
            bool rotate=false;

            multidoc.PrintPage += (s, arg) => {
                if (isFirstPage) {
                    width = arg.PrintableArea.Width;
                    height = arg.PrintableArea.Height;
                    rotate = false;

                    if (width < height) {
                        double temp=width;
                        width = height;
                        height = temp;
                        rotate = true;
                    }

                    pages = getPrintPages(width, height - 65);

                    layout = createGridLayout(width, height, out grid, out page);
                    isFirstPage = false;
                }

                if (index < pages.Count) {
                    int pageIndex=index + 1;
                    //GlobalStatus.Current.Status = String.Format("Печать страницы №{0} из {1}", pageIndex, pages.Count);

                    grid.Children.Remove(host);
                    host = pages[index];
                    page.Text = String.Format("Cтраница {0} из {1}", pageIndex, pages.Count);

                    grid.Children.Add(host);
                    host.SetValue(Grid.RowProperty, 1);
                    if (rotate) {
                        CompositeTransform transform=new CompositeTransform() {
                            Rotation = 90,
                            TranslateX = height

                        };
                        grid.RenderTransform = transform;
                    }
                    arg.PageVisual = layout;
                }
                index++;
                arg.HasMorePages = index < pages.Count;
            };

            multidoc.BeginPrint += (s, arg) => {
                GlobalStatus.Current.Status = "Печать списка заявок";
                GlobalStatus.Current.IsBusy = true;
            };

            multidoc.EndPrint += (s, arg) => {
                GlobalStatus.Current.Status = "Готово";
                GlobalStatus.Current.IsBusy = false;
            };

            multidoc.Print("Список заявок");
        }
Beispiel #16
0
        private void PrintButtonClicked( object sender, RoutedEventArgs e )
        {
            _curentPage = 1;

            var printDocument = new PrintDocument ();
            printDocument.BeginPrint += PrintingStartedHandler;
            printDocument.PrintPage += PrintPageHandler;
            printDocument.EndPrint += PrintingEndedHandler;

            printDocument.Print ( string.IsNullOrWhiteSpace ( Title ) ? "Document" : Title );
        }
 private void PrintButton_Click(object sender, RoutedEventArgs e)
 {
     PrintDocument doc = new PrintDocument() { DocumentName = "打印头像" };
     //doc.StartPrint += new EventHandler<StartPrintEventArgs>(doc_StartPrint);
     doc.EndPrint += OnEndPrint;
     doc.PrintPage += new EventHandler<PrintPageEventArgs>(doc_PrintPage);
     doc.Print();
 }
Beispiel #18
0
        //打印
        public void Print()
        {
            PageIndex = -1;
            Count = (List.Count % PageRow == 0) ? (List.Count / PageRow) : (List.Count / PageRow) + 1;
            if (Count == 0)
            {
                return;
            }
            if (IsPrintPage)
            {
                PagedObjectList pdl = new PagedObjectList();
                pdl.WebClientInfo = List.WebClientInfo;
                pdl.Path = List.Path;
                pdl.Count = List.Count;
                pdl.PageSize = PageRow;
                List = pdl;
            }
            int c = list.Count;
            PrintDocument pd = new PrintDocument();
            pd.PrintPage += (o, e) =>
            {
                PrintDocument pd1 = (PrintDocument)o;
                if (pd1.PrintedPageCount - 1 != PageIndex)
                {
                    return;
                }
                if (List is BasePagedList)
                {
                    PageIndex++;
                    BasePagedList pol = (BasePagedList)List;
                    pol.DataLoaded += (o1, e1) =>
                    {
                        //加载展示数据
                        items.CopyFrom(List, 0, this.pageRow);
                        UIElement Footer = null;
                        if (this.cusFooterElem != null)
                        {
                            Footer = (Area as FrameworkElement).FindName(cusFooterElem) as UIElement;
                        }
                        else
                        {
                            Footer = (Area as FrameworkElement).FindName("Footer") as UIElement;
                        }
                        if (Footer != null)
                        {
                            Footer.Visibility = Visibility.Collapsed;
                        }

                        //打印完成,重置索引
                        if (PageIndex == Count - 1)
                        {
                            if (Footer != null)
                            {
                                Footer.Visibility = Visibility.Visible;
                            }
                            e.HasMorePages = false;
                        }
                        else
                        {
                            e.HasMorePages = true;
                        }
                        e.PageVisual = Area;
                        area.UpdateLayout();
                    };
                    pol.PageIndex = PageIndex;
                }
                else
                {
                    //计算获取的数据开始,截止行
                    pageIndex = 0;
                    PageIndex++;
                    int startRow = (PageIndex - 1) * pageRow;
                    int endRow = (PageIndex * pageRow) - 1;
                    endRow = endRow > (List.Count - 1) ? (List.Count - 1) : (PageIndex * pageRow) - 1;
                    items.CopyFrom(List, startRow, endRow);
                    e.PageVisual = Area;
                    area.UpdateLayout();
                    //打印完成,重置索引
                    if (PageIndex == Count)
                    {
                        e.HasMorePages = false;
                        PageIndex = 0;
                    }
                    else
                    {
                        e.HasMorePages = true;
                    }
                }
            };
            pd.Print("");
        }
        void printLabels_Click(object sender, System.Windows.RoutedEventArgs e)
        {
            List<string> labels = new List<string>();
            foreach (var item in this.GroupMakingItems)
            {
                if (item.IsMask)
                {
                    for (int x = item.StartNumber.Value; x <= item.StopNumber.Value; x += item.StepNumber.Value)

                        labels.Add(string.Format("{0}{1}{2}", item.Before, x.ToString(), item.After));
                }
                else
                {
                    labels.Add(item.Texto);
                }
            }

            if (labels.Count > 0)
            {
                //Dispatchers.Main.BeginInvoke(() => {
                PrintDocument doc = new PrintDocument();

                doc.PrintPage += (s, ea) =>
                {
                    StackPanel printPanel = new StackPanel() { HorizontalAlignment = HorizontalAlignment.Left, Orientation = Orientation.Vertical };

                    foreach (var item in labels)
                    {
                        TextBlock row = new TextBlock() { Height = 20, Width = 80, Margin = new Thickness(2), FontFamily = new FontFamily("Tahoma"), FontSize = 12 };
                        row.Text = item;
                        printPanel.Children.Add(row);
                    }

                    ea.PageVisual = printPanel;
                    ea.HasMorePages = false;
                };

                PrinterFallbackSettings settings = new PrinterFallbackSettings();
                settings.ForceVector = true;
                settings.OpacityThreshold = 0.5;

                //doc.Print("Silverlight Forced Vector Print", settings);
                doc.PrintBitmap("Silverlight Bitmap Print");
                //});
            }
        }
Beispiel #20
0
        /// <summary>
        /// Prints a <see cref="UIElement" />.
        /// </summary>
        /// <param name="visual">The visual.</param>
        private static void Print(UIElement visual)
        {
#if SILVERLIGHT
            var printDocument = new PrintDocument();
            printDocument.PrintPage += (s, e) => { e.PageVisual = visual; };
            printDocument.Print("Silverlight printed document");
#else
            var printDialog = new PrintDialog();
            if ((bool)printDialog.ShowDialog())
            {
                printDialog.PrintVisual(visual, string.Empty);
            }
#endif
        }
        public PrintWindow(OrderFlow order)
        {
            InitializeComponent();
            this.DataContext = this;

            _order = order;

            if(order.CommitTime.HasValue)
            {
                DateTime dt = order.CommitTime.Value;
                string str;
                if (dt.Hour >= 1 && dt.Hour < 7)
                {
                    str = "凌晨";
                }
                else if (dt.Hour >= 7 && dt.Hour < 13)
                {
                    str = "上午";
                }
                else if (dt.Hour >= 13 && dt.Hour < 19)
                {
                    str = "下午";
                }
                else
                {
                    str = "晚上";
                }
                ExpiredTime = string.Format("{0:yyyy年MM月dd日} {1}{0:hh}时{0:mm}分", dt,str);
            }
            pd = new PrintDocument();
            pd.PrintPage += new EventHandler<PrintPageEventArgs>(pd_PrintPage);
            pd.EndPrint += new EventHandler<EndPrintEventArgs>(pd_EndPrint);
        }
Beispiel #22
0
 //打印
  public void PrintOneNoLoad()
 {
     PageIndex = -1;
     Count = (List.Count % PageRow == 0) ? (List.Count / PageRow) : (List.Count / PageRow) + 1;
     if (Count == 0)
     {
         return;
     }
     int c = list.Count;
     int printIndex = 0;
     PrintDocument pd = new PrintDocument();
     pd.PrintPage += (o, e) =>
     {
         PrintDocument pd1 = (PrintDocument)o;  
         if (pd1.PrintedPageCount - 1 != PageIndex)
         {
             return;
         }
         if (List is PagedObjectList)
         {
             PageIndex++;
             PagedObjectList pol = (PagedObjectList)List;
  
                 //加载展示数据
                 go.CopyDataFrom(List[printIndex]);
                 e.PageVisual = DataArea;
                 DataArea.UpdateLayout();
                 //打印完成,重置索引
                 if (printIndex == Count - 1)
                 {
                     e.HasMorePages = false;
                 }
                 else
                 {
                     e.HasMorePages = true;
                 }
                 printIndex++;
          }
     };
     pd.Print("");
 }
        //Print the document
        private void btnPrint_Click(object sender, RoutedEventArgs e)
        {
            PrintPreview cw = new PrintPreview();
            cw.ShowPreview(rtb);
            cw.HasCloseButton = false;

            //Hook up a handler to the Closed event before we display the PrintPreview window by calling the Show() method.
            cw.Closed += (t, a) =>
            {
                if (cw.DialogResult.Value)
                {
                    PrintDocument theDoc = new PrintDocument();
                    theDoc.PrintPage += (s, args) =>
                    {
                        args.PageVisual = rtb;
                        args.HasMorePages = false;
                    };

                    theDoc.EndPrint += (s, args) =>
                    {
                        MessageBox.Show("The document printed successfully", "Text Editor", MessageBoxButton.OK);
                    };

                    theDoc.Print("Silverlight 4 Text Editor");
                    ReturnFocus();
                }
            };
            cw.Show();
        }
Beispiel #24
0
        /// <summary>
        /// Prints a <see cref="UIElement" />.
        /// </summary>
        /// <param name="bitmap">The bitmap.</param>
        private static void Print(BitmapSource bitmap)
        {
            var image = new Image();
            image.Source = bitmap;

#if SILVERLIGHT
            var printDocument = new PrintDocument();
            printDocument.PrintPage += (s, e) => { e.PageVisual = image; };
            printDocument.Print("Silverlight printed document");
#else
            var printDialog = new PrintDialog();
            if ((bool)printDialog.ShowDialog())
            {
                printDialog.PrintVisual(image, string.Empty);
            }
#endif
        }
Beispiel #25
0
 //打印方法
 public void Print()
 {
     //触发开始打印事件
     OnPrinting();
     PrintDocument pd = new PrintDocument();
     //pd.BeginPrint += (o, e) =>
     //{
     //    State = State.Start;
     //};
     pd.PrintPage += (o, e) =>
     {
         e.PageVisual = Area;
     };
     pd.EndPrint += (o, e) =>
     {
         State = State.End;
         AsyncCompletedEventArgs args1 = new AsyncCompletedEventArgs(null, true, State.End);
         OnCompleted(args1);
     };
     //默认打印机
     if (userDefaultPrinter || isDirect)
     {
         pd.Print("", null, userDefaultPrinter);
     }
     else
     {
         pd.Print("");
     }
 }
Beispiel #26
0
        /// <summary>
        /// The print to printer.
        /// </summary>
        /// <param name="canvas1">
        /// The canvas 1.
        /// </param>
        /// <param name="canvas2">
        /// The canvas 2.
        /// </param>
        /// <param name="canvas3">
        /// The canvas 3.
        /// </param>
        /// <param name="canvas4">
        /// The canvas 4.
        /// </param>
        /// <returns>
        /// The <see cref="BitmapSource"/>.
        /// </returns>
        public static BitmapSource PrintToPrinter(Canvas canvas1, Canvas canvas2, Canvas canvas3, Canvas canvas4)
        {
            var wb =
                new WriteableBitmap(
                    (int)Math.Round(canvas1.ActualWidth, 0) + (int)Math.Round(canvas2.ActualWidth, 0), 
                    (int)Math.Round(canvas1.ActualHeight, 0) + (int)Math.Round(canvas3.ActualHeight, 0));

            wb.Render(canvas1, null);
            wb.Render(canvas2, new TranslateTransform { X = canvas1.ActualWidth, Y = 0 });
            wb.Render(canvas3, new TranslateTransform { X = 0, Y = canvas1.ActualHeight });
            wb.Render(canvas4, new TranslateTransform { X = canvas1.ActualWidth, Y = canvas2.ActualHeight });
            wb.Invalidate();

            var doc = new PrintDocument();
            doc.PrintPage += (s, e) =>
                {
                    e.HasMorePages = false;
                    var b = new Border { BorderThickness = new Thickness(0) };
                    b.Padding = new Thickness(96.0 / 2.54);

                    var img = new Image { Source = wb, Stretch = Stretch.Uniform };
                    b.Child = img;
                    b.Width = e.PrintableArea.Width;
                    b.Height = e.PrintableArea.Height;
                    e.PageVisual = b;
                };
            doc.PrintBitmap("Print Canvases");

            return wb;
        }
		public void Print()
		{
			PrintDocument document = new PrintDocument();
			document.PrintPage += Document_PrintPage;
			document.Print("Invoice");
		}
 private void SchedulerInit()
 {
     this.ResourceTypes = new ObservableCollection<ResourceType>();
     this.SchedulerCategories = new CategoryCollection();
     this.selectedCalendars = new List<ScheduleCalendar>();
     this.SchedulerCurrentDate = Etech.Library.DateEx.GetStartOfDay(DateTime.Today);
     this.defaultResource = new Resource("Personal", "Calendar");
     this.GroupFilter = new Func<object, bool>(this.GroupFilterFunc);
     this.schedulerDoc = new PrintDocument();
     this.schedulerDoc.PrintPage += new EventHandler<PrintPageEventArgs>(OnSchedulerPrintPage);
     this.schedulerDoc.EndPrint += new EventHandler<EndPrintEventArgs>(OnSchedulerEndPrint);
     this.SchedulerEditingId = Guid.Empty;
 }
Beispiel #29
0
 // Executes when the user navigates to this page.
 protected override void OnNavigatedTo(NavigationEventArgs e)
 {
     _printDocument = _printDocument ?? new PrintDocument();
     PrintStatus.DataContext = _printDocument;
 }
Beispiel #30
0
 public void Print(string documentName)
 {
     var printDoc = new PrintDocument();
     printDoc.PrintPage += PrintDocPrintPage;
     printDoc.Print(documentName);
 }
Beispiel #31
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");
        }