/// <summary> /// Extends BeginInvoke so that when a state object is not needed, null does not need to be passed. /// <example> /// printeventhandler.BeginInvoke(sender, e, callback); /// </example> /// </summary> public static IAsyncResult BeginInvoke(this PrintEventHandler printeventhandler, Object sender, PrintEventArgs e, AsyncCallback callback) { if (printeventhandler == null) { throw new ArgumentNullException("printeventhandler"); } return(printeventhandler.BeginInvoke(sender, e, callback, null)); }
private void InitInstance() { PrintPageEventHandler pdoc_page_handler = new PrintPageEventHandler(this.pdoc_PrintPage); PrintEventHandler pdoc_event_handler = new PrintEventHandler(this.pdoc_BeginPrint); if (this.pdoc != null) { this.pdoc.PrintPage += pdoc_page_handler; this.pdoc.BeginPrint += pdoc_event_handler; } }
public Layout() { /// /// Required for Windows.Forms Class Composition Designer support /// InitializeComponent(); printPage = new PrintPageEventHandler(PrintPage); beginPrint = new PrintEventHandler(BeginPrint); queryPageSettings = new QueryPageSettingsEventHandler(QueryPageSettings); }
public Layout(System.ComponentModel.IContainer container) { /// /// Required for Windows.Forms Class Composition Designer support /// container.Add(this); InitializeComponent(); printPage = new PrintPageEventHandler(PrintPage); beginPrint = new PrintEventHandler(BeginPrint); queryPageSettings = new QueryPageSettingsEventHandler(QueryPageSettings); }
/// <summary> /// Called when [end print]. /// </summary> /// <param name="sender">The sender.</param> /// <param name="e">The /// <see cref="T:System.Drawing.Printing.PrintEventArgs"/> /// instance containing the event data.</param> protected virtual void OnEndPrint ( object sender, PrintEventArgs e ) { PrintEventHandler handler = EndPrint; if (handler != null) { handler(this, e); } }
/// <summary> /// Fixes RTL alignment direction for the given cells in the given report /// </summary> /// <param name="report">The report to fix its RTL direction alignment</param> /// <param name="cells">Cells to intercept their Text proeprty for a possible RTL fix</param> private static void MakeCellsRightToLeft(XtraReport report, IEnumerable <XRLabel> cells) { foreach (var cell in cells) { // Searching for cells that have a binding on their Text property var binding = cell.DataBindings.FirstOrDefault(x => x.PropertyName == "Text"); if (binding != null) { // In order to be able to unregister from the event we have to have // a reference to the handler PrintEventHandler beforePrintDelegate = null; beforePrintDelegate = (_s, _e) => { var value = report.GetCurrentColumnValue(binding.DataMember); if (report.Parameters.Cast <Parameter>().Any(x => x.Name == binding.DataMember)) { // a parameter is bound to this control cell.Text = FixRTL(cell.Text); } else { // Examine the data type of the obtained value if it's not string // we unregister from the BeforePrint event not to get future notifications if (value is string) { // Adds a Right-To-Left MARK (U+200F) to the end of the string (_s as XRLabel).Text = FixRTL(value.ToString()); } else { // Unregisters from the BeforePrint cell.BeforePrint -= beforePrintDelegate; } } }; // Registering to the BeforePrint event to intercept the string values cell.BeforePrint += beforePrintDelegate; } else { // If the cell has no binding to any source so just add RLM character // to the end of its Text property cell.Text = FixRTL(cell.Text); } } }
public void EndPrint_SetValue_ReturnsExpected() { bool flag = false; var endPrintHandler = new PrintEventHandler((sender, e) => flag = true); using (var document = new PrintDocument()) { document.PrintController = new TestPrintController(); document.EndPrint += endPrintHandler; document.Print(); Assert.True(flag); flag = false; document.EndPrint -= endPrintHandler; document.Print(); Assert.False(flag); } }
public string Execute(PrinterSettings printerSetting, PrintEventHandler end_print, Stream stream, Dictionary<string, object> reportDataSources) { string msg = string.Empty; PrintDocument printDoc = this.CreatePrintDocument(printerSetting, ref msg); if (!string.IsNullOrEmpty(msg)) { return msg; } LoggingService.Debug("检查打印模板文件是否存在..."); if ((stream == null) || (stream.Length == 0L)) { LoggingService.Warn("模板是空值或无内容"); return "报表模板不存在!"; } LoggingService.Debug("准备生成打印流..."); LocalReport report = new LocalReport(); report.LoadReportDefinition(stream); return this.InternalExecute(printDoc, report, end_print, reportDataSources); }
public string Execute(PrinterSettings printerSetting, PrintEventHandler end_print, string templetFile, Dictionary<string, object> reportDataSources) { string msg = string.Empty; PrintDocument printDoc = this.CreatePrintDocument(printerSetting, ref msg); if (!string.IsNullOrEmpty(msg)) { return msg; } LoggingService.Debug("检查打印模板文件是否存在..."); if (!File.Exists(templetFile)) { LoggingService.WarnFormatted("没有报表模板{0}", new object[] { templetFile }); return "报表模板文件不存在!"; } LoggingService.Debug("准备生成打印流..."); LocalReport report = new LocalReport(); report.ReportPath = templetFile; return this.InternalExecute(printDoc, report, end_print, reportDataSources); }
public static void PrintOrShowRDLC(string name, bool preview, byte[] reportData, DataSet ds, PrintEventHandler end_print, PrinterSettings printerSetting, Action<ReportViewDialog> action) { Dictionary<string, object> reportDataSource = new Dictionary<string, object>(); foreach (DataTable table in ds.Tables) { reportDataSource.Add(table.TableName, table); } using (MemoryStream stream = new MemoryStream(reportData)) { if (preview) { ShowRDLC(name, stream, reportDataSource, action, end_print); } else { PrintRDLC(printerSetting, end_print, stream, reportDataSource); } } }
public string Execute(PrintEventHandler end_print, string templetFile, Dictionary<string, object> reportDataSources) { return this.Execute(null, end_print, templetFile, reportDataSources); }
private string InternalExecute(PrintDocument printDoc, LocalReport report, PrintEventHandler end_print, Dictionary<string, object> reportDataSources) { foreach (KeyValuePair<string, object> pair in reportDataSources) { report.DataSources.Add(new ReportDataSource(pair.Key, pair.Value)); if (LoggingService.IsDebugEnabled) { LoggingService.DebugFormatted("添加报表数据源:{0}", new object[] { pair.Key }); } } this.Export(report); this.m_currentPageIndex = 0; if ((this.m_streams == null) || (this.m_streams.Count == 0)) { return "无法生成要打印的报表!"; } LoggingService.Debug("生成了打印流..."); printDoc.PrintPage += new PrintPageEventHandler(this.PrintPage); if (end_print != null) { printDoc.EndPrint += end_print; } try { LoggingService.Debug("开始打印了..."); printDoc.Print(); LoggingService.Debug("打印完成了..."); } catch (Win32Exception exception) { LoggingService.Error(exception); return "连接不到打印机或打印机不能正常工作,请检查打印机!"; } return string.Empty; }
private void InitializeSimpleLayout() { line = new Line(); // Preparing events handlers beginPrint = new PrintEventHandler(BeginPrint); printPage = new PrintPageEventHandler(PrintPage); }
/// <summary> /// Initializes a new instance of the FlowChart class. /// </summary> public FlowChart() { license = LicenseManager.Validate(typeof(FlowChart), this); measureUnit = GraphicsUnit.Millimeter; // set control styles for flicker-free redraw SetStyle(ControlStyles.UserPaint, true); SetStyle(ControlStyles.AllPaintingInWmPaint, true); SetStyle(ControlStyles.Opaque, true); SetStyle(ControlStyles.ResizeRedraw, true); // we want to process keyboard input SetStyle(ControlStyles.Selectable, true); // init static objects lock (syncRoot) { Arrow.initHeadTemplates(); CustomCursors.Init(new ResourceManager( "MindFusion.FlowChartX.Cursors", typeof(ChartObject).Assembly)); } mouseMoved = false; boxFillColor = Color.FromArgb(220, 220, 255); boxFrameColor = Color.Black; arrowColor = Color.Black; arrowTextStyle = ArrowTextStyle.Center; arrowFillColor = Color.FromArgb(120, 220, 255); tableFrameColor = Color.Black; tableFillColor = Color.FromArgb(180, 160, 160); penDashStyle = DashStyle.Solid; penWidth = 0; BackColor = Color.FromArgb(170, 170, 200); // grid properties alignToGrid = true; showGrid = false; gridColor = Color.FromArgb(140, 140, 150); gridSizeX = 4; gridSizeY = 4; gridStyle = GridStyle.Points; // shadows properties shadowOffsetX = 1; shadowOffsetY = 1; shadowColor = Color.FromArgb(110, 110, 140); shadowsStyle = ShadowsStyle.OneLevel; activeMnpColor = Color.White; selMnpColor = Color.FromArgb(170, 170, 170); disabledMnpColor = Color.FromArgb(200, 0, 0); textFormat = new StringFormat(); textFormat.Alignment = StringAlignment.Center; textFormat.LineAlignment = StringAlignment.Center; // Set some flags, because otherwise the serializer // generates noncompilable code textFormat.FormatFlags = StringFormatFlags.NoFontFallback; imagePos = ImageAlign.Document; boxStyle = BoxStyle.RoundedRectangle; tableStyle = TableStyle.Rectangle; boxPen = new Pen(boxFrameColor, penWidth); boxBrush = new SolidBrush(boxFillColor); boxBrush.AddRef(); arrowPen = new Pen(arrowColor, penWidth); arrowBrush = new SolidBrush(arrowFillColor); arrowBrush.AddRef(); tablePen = new Pen(tableFrameColor, penWidth); tableBrush = new SolidBrush(tableFillColor); tableBrush.AddRef(); exteriorBrush = null; brush = new SolidBrush(BackColor); brush.AddRef(); boxes = new BoxCollection(); controlHosts = new ControlHostCollection(); tables = new TableCollection(); arrows = new ArrowCollection(); selection = new Selection(this); selectionOnTop = true; groups = new GroupCollection(); zOrder = new ChartObjectCollection(); textColor = Color.Black; arrowStyle = MindFusion.FlowChartX.ArrowStyle.Polyline; arrowSegments = 1; activeObject = null; modificationStart = ModificationStyle.SelectedOnly; autoHandlesObj = null; autoAnchorsObj = null; interaction = null; scrollX = scrollY = 0; zoomFactor = 100.0f; allowRefLinks = true; Behavior = BehaviorType.FlowChart; arrowEndsMovable = true; selectAfterCreate = true; // init default custom draw properties boxCustomDraw = CustomDraw.None; tableCustomDraw = CustomDraw.None; cellCustomDraw = CustomDraw.None; arrowCustomDraw = CustomDraw.None; restrObjsToDoc = RestrictToDoc.Intersection; dynamicArrows = false; arrowsSnapToBorders = false; arrowsRetainForm = false; arrowCascadeOrientation = Orientation.Auto; curPointer = Cursors.Arrow; curCannotCreate = Cursors.No; curModify = Cursors.SizeAll; curArrowStart = Cursors.Hand; curArrowEnd = Cursors.Hand; curArrowCannotCreate = Cursors.No; curHorzResize = Cursors.SizeWE; curVertResize = Cursors.SizeNS; curMainDgnlResize = Cursors.SizeNWSE; curSecDgnlResize = Cursors.SizeNESW; curRotateShape = CustomCursors.Rotate; panCursor = Cursors.NoMove2D; tableRowsCount = 4; tableColumnsCount = 2; tableRowHeight = 6; tableColWidth = 18; tableCaptionHeight = 5; tableCaption = "Table"; tableCellBorders = CellFrameStyle.System3D; selHandleSize = 2; showDisabledHandles = true; arrowSelStyle = HandlesStyle.SquareHandles; boxSelStyle = HandlesStyle.SquareHandles; chostSelStyle = HandlesStyle.HatchHandles; tableSelStyle = HandlesStyle.DashFrame; recursiveExpand = false; expandOnIncoming = false; boxesExpandable = false; tablesScrollable = false; tablesExpandable = false; controlHostsExpandable = false; arrowHead = ArrowHead.Arrow; arrowBase = ArrowHead.None; arrowInterm = ArrowHead.None; arrowHeadSize = 5; arrowBaseSize = 5; arrowIntermSize = 5; ShowScrollbars = true; DocExtents = new RectangleF(0, 0, 210, 297); autoScroll = true; autoScrDX = autoScrDY = 0; dirty = false; antiAlias = SmoothingMode.None; textRendering = TextRenderingHint.SystemDefault; sortGroupsByZ = false; // tooltips showToolTips = true; toolTip = ""; toolTipCtrl = new ToolTip(); toolTipCtrl.Active = showToolTips; shapeRotation = 0; DefaultShape = ShapeTemplate.FromId("Cylinder"); inplaceEditAllowed = false; inplaceObject = null; nowEditing = false; inplaceEditFont = (Font)Font.Clone(); inplaceAcceptOnEnter = false; inplaceCancelOnEsc = true; allowSplitArrows = false; printOptions = new PrintOptions(this); printOptions.EnableBackground = false; printOptions.EnableBackgroundImage = false; printOptions.PaintControls = true; displayOptions = new PrintOptions(this); renderOptions = displayOptions; previewOptions = new PreviewOptions(); allowLinksRepeat = true; showAnchors = ShowAnchors.Auto; snapToAnchor = SnapToAnchor.OnCreate; beginPrintHandler = new PrintEventHandler(this.BeginPrint); printPageHandler = new PrintPageEventHandler(this.PrintPage); printRect = new RectangleF(0, 0, 1, 1); usePolyTextLt = false; userAction = false; tableLinkStyle = TableLinkStyle.Rows; undoManager = new UndoManager(this); defaultControlType = typeof(System.Windows.Forms.Button); hostedCtrlMouseAction = HostMouseAction.SelectHost; dummy = new DummyNode(this); allowUnconnectedArrows = false; allowUnanchoredArrows = true; autoSizeDoc = MindFusion.FlowChartX.AutoSize.None; panMode = false; enableStyledText = false; expandBtnPos = ExpandButtonPosition.OuterRight; focusLost = false; hitTestPriority = HitTestPriority.NodesBeforeArrows; boxText = arrowText = ""; // arrow crossings arrowCrossings = ArrowCrossings.Straight; crossRadius = 1.5f; redrawNonModified = false; roundRectFactor = 1; scriptHelper = new ScriptHelper(this); // link routing options routingOptions = new RoutingOptions(this); routingGrid = new RoutingGrid(this); routeArrows = false; dontRouteForAwhile = false; validityChecks = true; _modifierKeyActions = new ModifierKeyActions(); middleButtonAction = MouseButtonAction.None; forceCacheRedraw = false; showHandlesOnDrag = true; mergeThreshold = 0; expandButtonAction = ExpandButtonAction.ExpandTreeBranch; }
public static string PrintRDLC(PrinterSettings printerSetting, PrintEventHandler end_print, Stream stream, Dictionary<string, object> reportDataSources) { return RDLCPrintInstance.Execute(printerSetting, end_print, stream, reportDataSources); }
public void SetCustomButton(string Text, string ImgUrl, PrintEventHandler Handler, string toolTip) { SetCustomButton(Text, ImgUrl, Handler); m_CustomToolTip = toolTip; }
public static string PrintRDLC(PrinterSettings printerSetting, PrintEventHandler end_print, byte[] bytes, Dictionary<string, object> reportDataSources) { using (MemoryStream stream = new MemoryStream(bytes)) { return PrintRDLC(printerSetting, end_print, stream, reportDataSources); } }
public static void ShowRDLC(string name, byte[] bytes, Dictionary<string, object> reportDataSource, Action<ReportViewDialog> action, PrintEventHandler printHandler) { using (MemoryStream stream = new MemoryStream(bytes)) { ShowRDLC(name, stream, reportDataSource, action, printHandler); } }
public static void ShowRDLC(string name, Stream stream, Dictionary<string, object> reportDataSource, Action<ReportViewDialog> action, PrintEventHandler printHandler) { using (ReportViewDialog dialog = new ReportViewDialog()) { dialog.LoadReportDefinition(stream); dialog.Text = name; foreach (KeyValuePair<string, object> pair in reportDataSource) { dialog.AddDataSource(pair.Key, pair.Value); if (LoggingService.IsDebugEnabled) { LoggingService.DebugFormatted("添加报表数据源:{0}", new object[] { pair.Key }); } } if (LoggingService.IsDebugEnabled) { LoggingService.Debug("执行自定义报表处理过程"); } if (action != null) { action(dialog); } dialog.WindowState = FormWindowState.Maximized; if (printHandler != null) { dialog.Print += printHandler; } dialog.ShowDialog(); try { dialog.Close(); } catch { } } }
/// <summary> /// 画像プリントメソッド. /// </summary> /// <param name="photoPath">画像ファイルパス.</param> /// <param name="copies">プリント枚数.</param> /// <param name="paperWidth">プリント紙幅.</param> /// <param name="paperHeight">プリント紙高.</param> /// <param name="OnEndPrint">プリント終了イベント.</param> public static void PrintPhoto(string photoPath, int copies = 1, int paperWidth = 0, int paperHeight = 0, PrintEventHandler OnEndPrint = null) { int printedNum = 1; PrintDocument pd = new PrintDocument(); pd.DefaultPageSettings.Margins = new Margins(0, 0, 0, 0); pd.PrinterSettings.DefaultPageSettings.Margins = new Margins(0, 0, 0, 0); // 紙サイズ設定() if (paperWidth != 0 && paperHeight != 0) { pd.DefaultPageSettings.PaperSize = pd.PrinterSettings.DefaultPageSettings.PaperSize = new PaperSize("Sticker", paperWidth, paperHeight); } pd.PrinterSettings.Copies = (short)copies; pd.PrintPage += (sndr, args) => { System.Drawing.Image i = System.Drawing.Image.FromFile(photoPath); Rectangle m = args.MarginBounds; args.Graphics.DrawImage(i, m); if (printedNum < copies) { args.HasMorePages = true; printedNum++; } else { args.HasMorePages = false; } i.Dispose(); }; pd.EndPrint += OnEndPrint; pd.Print(); }
public TileableImagePrinter(PrintDocument document, Image image) { _image = image; /* calculate imageable area = page area - margins */ Rectangle bounds = document.DefaultPageSettings.Bounds; Margins margins = document.DefaultPageSettings.Margins; Rectangle pageBounds = new Rectangle( bounds.Location + new Size(margins.Left, margins.Right), bounds.Size - new Size(margins.Left + margins.Right, margins.Top + margins.Bottom)); _pageSize = pageBounds.Size; _pageRegion = new Region(pageBounds); /* calculate image size in 1/100 of an inch */ _imageSize = new SizeF(image.Size.Width * HUNDREDTH_INCH_PER_PIXEL, image.Size.Height * HUNDREDTH_INCH_PER_PIXEL); /* calculate how many page columns + rows required to tile out the image */ _pageColumnCount = ((int)(_imageSize.Width / _pageSize.Width)) + 1; _pageRowCount = ((int)(_imageSize.Height / _pageSize.Height)) + 1; /* calculate the offset of the image on the first page, from page margins + 1/2 of difference between image size and total page size */ _imageOffset = new PointF( pageBounds.Left + (_pageColumnCount * _pageSize.Width - _imageSize.Width) / 2.0f, pageBounds.Top + (_pageRowCount * _pageSize.Height - _imageSize.Height) / 2.0f); /* start at page 0 */ _page = 0; _printPage = delegate(object sender, PrintPageEventArgs eventArgs) { /* which page column + row we are printing */ int pageColumn = _page % _pageColumnCount; int pageRow = _page / _pageColumnCount; /* clip to the imageable area and draw the offset image into it */ eventArgs.Graphics.Clip = _pageRegion; eventArgs.Graphics.DrawImage(_image, new RectangleF( _imageOffset - new SizeF(pageColumn * _pageSize.Width, pageRow * _pageSize.Height), _imageSize)); /* only print column * row pages */ eventArgs.HasMorePages = ++_page < _pageColumnCount * _pageRowCount; }; _endPrint = delegate(object sender, PrintEventArgs eventArgs) { /* detach handlers from the print document */ PrintDocument printDocument = (PrintDocument)sender; printDocument.PrintPage -= _printPage; printDocument.EndPrint -= _endPrint; }; /* attach handlers to the print document */ document.PrintPage += _printPage; document.EndPrint += _endPrint; }
public static string PrintRDLC(PrintEventHandler end_print, string templetFile, Dictionary<string, object> reportDataSources) { return RDLCPrintInstance.Execute(null, end_print, templetFile, reportDataSources); }
public void SetCustomButton(string Text, string ImgUrl, PrintEventHandler Handler) { m_gridModes |= GridModes.CustomButton; m_CustomButtonText = Text; //m_CustomText=Text; m_CustomImg = ImgUrl; this.CustomButton = Handler; }