Example #1
0
 public static void ExportComponent(IPrintable printableControl, ExportType exportType,
                                    ExportOptions exportOptions)
 {
     ExportComponent(new List <IPrintable> {
         printableControl
     }, exportType, exportOptions);
 }
Example #2
0
        public static void Print(IPrintable I)
        {
            //double area = 0;

            //if (shape is Circle)
            //{
            //    var circle = (Circle) shape;
            //    area = circle.Radius * circle.Radius * Math.PI;
            //    Console.WriteLine($"Circle: radius = {circle.Radius}, area = {area}");
            //}
            //else if (shape is RightAngledTriangle)
            //{
            //    var rightTriangle = (RightAngledTriangle) shape;
            //    area = 0.5 * rightTriangle.Side1 * rightTriangle.Side2;
            //    var info = "Right-angled Triangle: ";
            //    info += $"sides {rightTriangle.Side1} {rightTriangle.Side2} {rightTriangle.Side3}, ";
            //    info += $"area = {area}";
            //    Console.WriteLine(info);
            //}
            //else if (shape is Triangle)
            //{
            //    var triangle = (Triangle) shape;

            //    var side1 = triangle.Side1;
            //    var side2 = triangle.Side2;
            //    var side3 = triangle.Side3;
            //    var p = (side1 + side2 + side3) / 2;
            //    area = Math.Sqrt(p * (p - side1) * (p - side2) * (p - side3));
            //    Console.WriteLine($"Triangle: sides: {side1} {side2} {side3}, area = {area}");
            //}

            Console.WriteLine(I.Print());
        }
Example #3
0
        public static void ExportXls(IPrintable Printer, string printCaption, Control.ControlCollection Controls)
        {
            if (Printer == null)
            {
                return;
            }
            OnBestFitColumns(Controls);
            PrintCaption = printCaption;
            DevExpress.XtraPrinting.PrintingSystem         ps   = new DevExpress.XtraPrinting.PrintingSystem();
            DevExpress.XtraPrinting.PrintableComponentLink link = new DevExpress.XtraPrinting.PrintableComponentLink(ps);
            link.Component = Printer;
            link.CreateReportHeaderArea += new DevExpress.XtraPrinting.CreateAreaEventHandler(printableComponentLink_CreateReportHeaderArea);

            link.PaperKind = System.Drawing.Printing.PaperKind.A4;

            link.Margins.Bottom = link.Margins.Left = link.Margins.Right = link.Margins.Top = 50;

            link.CreateDocument();
            string         fileName = string.Empty;
            SaveFileDialog save     = new SaveFileDialog();

            save.Filter = "Exel 2013 (*.xls)|*.xls";
            if (save.ShowDialog() == System.Windows.Forms.DialogResult.OK)
            {
                fileName = save.FileName;
            }

            if (string.IsNullOrEmpty(fileName))
            {
                return;
            }
            link.ExportToXls(fileName);
        }
Example #4
0
        public void Write(IPrintable printable)
        {
            StreamWriter sw = new StreamWriter(path);

            //sw.Write(DXF.Content(printable));
            sw.Close();
        }
Example #5
0
        private void ShowDefaultReport(IPrintable e, bool isPrint)
        {
            PrintingSystem p = new PrintingSystem();

            p.ShowMarginsWarning   = false;
            p.PreviewFormEx.KeyUp += new KeyEventHandler(PreviewFormEx_KeyUp);
            PrintableComponentLink i = new PrintableComponentLink(p);

            i.CreateDocument(p);

            i.Component       = e;
            i.Landscape       = _data.DrTable["isLand"] == DBNull.Value || bool.Parse(_data.DrTable["isLand"].ToString());
            i.PaperKind       = PaperKind.A4;
            i.RtfReportFooter = "Tổng Cộng";

            i.Margins = new System.Drawing.Printing.Margins(25, 25, 25, 25);
            i.CreateReportHeaderArea += new CreateAreaEventHandler(i_CreateReportHeaderArea);

            i.CreateReportFooterArea                  += new CreateAreaEventHandler(i_CreateReportFooterArea);
            gridViewReport.ColumnPanelRowHeight        = 30;
            gridViewReport.OptionsPrint.UsePrintStyles = true;
            i.CreateDocument();

            i.ShowPreview(this.gridControlReport.LookAndFeel);
        }
Example #6
0
        public String ToString(IEntityEquals left, IPrintable printable)
        {
            StringBuilder sb = new StringBuilder();

            printable.ToString(sb);
            return(sb.ToString());
        }
Example #7
0
        static void Main(string[] args)
        {
            IPrintable printer = PrinterCreator.create(PrinterType.CONSOLE);

            printer.print("Input count of elements in vector:");
            int n = UserInput.inputInt();

            int[] intArray = new int[n];

            for (int i = 0; i < n; i++)
            {
                printer.print("Input element №" + i);
                intArray[i] = UserInput.inputInt();
            }

            Vector vector     = new Vector(intArray);
            int    sumOfElem  = Calculator.sumOfElemBetweenFirstAndLastZero(vector);
            int    prodOfElem = Calculator.prodOfEvenElem(vector);
            int    firstZero  = Calculator.indexOfFirstZero(vector);
            int    lastZero   = Calculator.indexOfLastZero(vector);

            printer.print("product of even elements = " + prodOfElem);
            printer.print("sum of elements between first and last zero = " + sumOfElem);
            printer.print("index of first zero = " + firstZero);
            printer.print("index of last zero = " + lastZero);

            Console.ReadKey();
        }
Example #8
0
        static void Main(string[] args)
        {
            Lesson lesson1 = new Lesson(1, "math");
            Lesson lesson2 = new Lesson(2, "geography");
            Lesson lesson3 = new Lesson(3, "english");


            Person person1 = new Person(1, "moshe");
            Person person2 = new Person(2, "danny");
            Person person3 = new Person(3, "rueven");
            Person person4 = new Person(4, "dana");



            Student     student1    = new Student(5, "moshe student", 222, "ironi hey");
            StudentUniv studentUniv = new StudentUniv(6, "student ununv 1", 333, "Bar Ilan", "Bilding 1", "First");
            Person      person5     = new StudentUniv(7, "student ununv 2", 555, "Bar Ilan", "Bilding 1", "First");

            IPrintable printable1 = lesson1;
            IClearable clearable1 = lesson1;


            IPrintable printable2 = person2;
            IClearable clearable2 = lesson2;


            IPrintable printable3 = student1;
            IClearable clearable3 = student1;


            clearable1.Clear();


            List <IPrintable> allPrintables = new List <IPrintable>();

            allPrintables.Add(printable1);
            allPrintables.Add(printable2);
            allPrintables.Add(lesson2);
            allPrintables.Add(lesson2);
            allPrintables.Add(person2);
            allPrintables.Add(person3);
            allPrintables.Add(person4);
            allPrintables.Add(student1);


            MyPrinter myPrinter = new MyPrinter("http://ddd.com", 1, 1);

            PrinterWork.PrintAll(myPrinter, allPrintables);


            List <IMail> mailsList = new List <IMail>();

            mailsList.Add((IMail)studentUniv);
            mailsList.Add((IMail)person5);


            if (person1.CompareTo(person2) > 0)
            {
            }
        }
Example #9
0
        private void ShowCustomizePreview(IPrintable ctrl, bool isLanscape)
        {
            // Create a PrintingSystem component.
            PrintingSystem ps = new PrintingSystem();
            // Create a link that will print a control.
            PrintableComponentLink Print = new PrintableComponentLink(ps);

            // Specify the control to be printed.
            Print.Component = ctrl;
            // Set the paper format.
            Print.PaperKind = System.Drawing.Printing.PaperKind.A4;
            Print.Landscape = isLanscape;
            Print.Margins   = new System.Drawing.Printing.Margins(40, 40, 40, 40);
            string dbName = Config.GetValue("DbName").ToString();

            if (dbName.Contains("DEMO"))
            {
                ps.Watermark.Text             = "Hoa Tiêu Demo";
                ps.Watermark.TextTransparency = 150;
            }
            // Subscribe to the CreateReportHeaderArea event used to generate the report header.
            Print.CreateReportHeaderArea +=
                new CreateAreaEventHandler(Print_CreateReportHeaderArea);
            Print.CreateReportFooterArea += new CreateAreaEventHandler(Print_CreateReportFooterArea);
            // Generate the report.
            Print.CreateDocument();
            // Show the report.
            Print.ShowPreview();
        }
Example #10
0
    public static string Print(this IPrintable printable, string?name = null)
    {
        StructuredStringBuilder sb = new();

        printable.Print(sb, name);
        return(sb.ToString());
    }
Example #11
0
        public void ShowRibbonPreview(IPrintable component, string title)
        {
            //HEADER
            PageHeaderArea header = new PageHeaderArea();

            header.Content.Add(string.Empty);
            header.Content.Add(title);
            header.LineAlignment = BrickAlignment.Center;
            header.Font          = new Font("Tahoma", 16, FontStyle.Bold);

            //FOOTER
            PageFooterArea footer = new PageFooterArea();

            footer.Content.AddRange(new string[] { "", "", "Página: [Page #]" });

            //UNION HEADER/FOOTER
            PageHeaderFooter headerfooter = new PageHeaderFooter(header, footer);

            PrintableComponentLink print = new PrintableComponentLink(new PrintingSystem());

            print.Component        = component;
            print.PageHeaderFooter = headerfooter;
            print.PaperKind        = PaperKind.A4;
            print.Margins          = new Margins(60, 30, 60, 60);
            print.CreateDocument();
            print.ShowRibbonPreview(this.LookAndFeel);
        }
Example #12
0
        /// <summary>
        /// Print the message
        /// </summary>
        /// <param name="message">the message to print</param>
        public virtual void Print(T message)
        {
            string     msg     = Create(message);
            IPrintable printer = GetPrinter();

            printer.WriteLine(msg);
        }
Example #13
0
        public static string ToHtml(IPrintable printable)
        {
            Dictionary <string, IPrintable> map = printable.GetItems();
            string name = SecurityElement.Escape(printable.ToString());

            if (map == null || map.Count == 0)
            {
                return(name);
            }
            StringBuilder sb = new StringBuilder();

            sb.AppendLine("<div>");
            //if (printable is ReflectionPrintable) sb.AppendFormat("<b>{0}</b><br />\n", name);
            foreach (var item in map)
            {
                string key      = SecurityElement.Escape(item.Key);
                string itemHtml = ToHtml(item.Value);
                if (!(item.Value is LeafPrintable))
                {
                    itemHtml = "\n" + string.Join("\n", itemHtml.Split('\n').Select(x => "  " + x));
                    sb.AppendFormat("<i>{0}</i>: <a href='#' onclick='toggle(this); return false;'>{1}</a>\n", key, SecurityElement.Escape(item.Value.ToString()));
                    sb.AppendFormat("<div class='hidden'>{0}</div>\n", itemHtml);
                }
                else
                {
                    sb.AppendFormat("<i>{0}</i>: {1}<br/>\n", key, itemHtml);
                }
            }
            sb.AppendLine("</div>");

            return(sb.ToString());
        }
Example #14
0
        static void Main(string[] args)
        {
            IPrintable printer = PrinterCreator.create(PrinterType.CONSOLE);

            printer.print("Input count of elements in vector:");
            int n = UserInput.inputInt();

            double[] doubleArray = new double[n];

            for (int i = 0; i < n; i++)
            {
                printer.print("Input element №" + i);
                doubleArray[i] = UserInput.inputDouble();
            }

            Vector vector        = new Vector(doubleArray);
            double sumOfNegative = Calculator.sumOfNegativeElem(vector);
            double prodOfElem    = Calculator.prodOfElemBetweenMinAndMax(vector);
            int    indexMax      = Calculator.indexOfMaxElem(vector);
            int    indexMin      = Calculator.indexOfMinElem(vector);

            printer.print("sum of negative elements = " + sumOfNegative);
            printer.print("product of elements between min and max = " + prodOfElem);
            printer.print("max index = " + indexMax);
            printer.print("min index = " + indexMin);

            Console.ReadKey();
        }
Example #15
0
        private void CreateNewObject(Point?mouseButtonRelesedLocation = null)
        {
            mouseUpLocation = mouseButtonRelesedLocation;
            if (tabControl.SelectedTab == tpShapes && mouseDownLocation.HasValue && mouseUpLocation.HasValue && mouseDownLocation.Value.X != mouseUpLocation.Value.X && mouseDownLocation.Value.Y != mouseUpLocation.Value.Y)
            {
                if (rbRectangle.Checked)
                {
                    temporarlyPrintable = new PdfRectangle(foregroundColor, (int)nudLineWidth.Value, mouseDownLocation.Value, mouseUpLocation.Value);
                }
                else if (rbEllipse.Checked)
                {
                    temporarlyPrintable = new PdfEllipse(foregroundColor, (int)nudLineWidth.Value, mouseDownLocation.Value, mouseUpLocation.Value);
                }
            }
            if (mouseDownLocation.HasValue)
            {
                if (tabControl.SelectedTab == tpText && !String.IsNullOrWhiteSpace(tbText.Text))
                {
                    temporarlyPrintable = new PdfText(tbText.Text, mouseDownLocation.Value, fontColor, fontName, fontSize);
                }
                else if (tabControl.SelectedTab == tpImage && !String.IsNullOrWhiteSpace(imageFilePath))
                {
                    temporarlyPrintable = new PdfImage(imageFilePath, mouseDownLocation.Value.X, mouseDownLocation.Value.Y, (int)nudImageWidth.Value, (int)nudImageHeight.Value);
                }
            }

            RefreshScreen();
        }
Example #16
0
        public override void Run()
        {
            IPrintable printable = WorkbenchSingleton.Workbench.ActiveViewContent as IPrintable;

            if (printable != null)
            {
                using (PrintDocument pdoc = printable.PrintDocument) {
                    if (pdoc != null)
                    {
                        using (PrintDialog ppd = new PrintDialog()) {
                            ppd.Document       = pdoc;
                            ppd.AllowSomePages = true;
                            if (ppd.ShowDialog(ICSharpCode.SharpDevelop.Gui.WorkbenchSingleton.MainForm) == DialogResult.OK)                               // fixed by Roger Rubin
                            {
                                pdoc.Print();
                            }
                        }
                    }
                    else
                    {
                        MessageService.ShowError("${res:ICSharpCode.SharpDevelop.Commands.Print.CreatePrintDocumentError}");
                    }
                }
            }
            else
            {
                MessageService.ShowError("${res:ICSharpCode.SharpDevelop.Commands.Print.CantPrintWindowContentError}");
            }
        }
Example #17
0
        public static void Print(IPrintable printable, string filename, int width, int height)
        {
            filename = ShowDialog(filename);
            if (filename == null)
            {
                return;
            }
            string extension = Path.GetExtension(filename).ToLower();

            if (File.Exists(filename))
            {
                File.Delete(filename);
            }
            BasicImageFormat format = BasicImageFormat.GetFromExtension(extension);

            if (format == null)
            {
                MessageBox.Show("Could not find the specified file format: " + extension);
            }
            IGraphics graphics = format.CreateGraphics(filename, width, height);

            printable.Print(graphics, width, height);
            graphics.Close();
            graphics.Dispose();
        }
Example #18
0
        /* The internal access modifier will make a member of a type accessible within the assembly
         *  in which it is declared. This can be an exe or dll*/

        /* The readonly access modifier will make a member of a type read only. The value of the
         * member can only be set at declaration or within the constructor of the class.  */

        public static void TestInterface()
        {
            Report     myReport  = new Report();
            IPrintable printItem = myReport;

            printItem.GetPrintableText(1, 1);
        }
Example #19
0
 public StateFactory(FormMain FormMain, KeyEvents keyEvents, SkillManager skills, IPrintable printable)
 {
     this.FormMain  = FormMain;
     this.keyEvents = keyEvents;
     this.printable = printable;
     this.skills    = skills;
 }
        private void resetProfiler()
        {
            // Close printRuleViewer if it is still open
            printRuleViewer?.Close();

            // reset everything
            model = null;
            Model.MarkerLiteral.Cause = null; //The cause may be a term in the old model, preventing the GC from freeing some resources untill a new cause is set in the new model
            z3AxiomTree.Nodes.Clear();
            toolTipBox.Clear();
            printRuleDict = new PrintRuleDictionary();
            expanded.Clear();
            searchTree = null;
            currentInfoPanelPrintable = null;

            // clear history
            historyNode.Nodes.Clear();

            dagView.Clear(); //The dagView keeps references to the instances represented by visible nodes. Clearing it allows these resources to be freed.

            /* The entire model can be garbage collected now. Most of it will have aged into generation 2 of the garbage collection algorithm by now
             * which might take a while (~10s) until it is executed regularly. Giving the hint is, therefore, a good idea.
             */
            GC.Collect(2, GCCollectionMode.Optimized);
        }
        public static void Print(IPrintable iprintable)
        {
            Console.WriteLine(iprintable.Print());
            //shape.Print();

            /*double area = 0;
             *
             * if (shape is Circle)
             * {
             *  var circle = (Circle) shape;
             *  area = circle.Radius * circle.Radius * Math.PI;
             *  Console.WriteLine($"Circle: radius = {circle.Radius}, area = {area}");
             * }
             * else if (shape is RightAngledTriangle)
             * {
             *  var rightTriangle = (RightAngledTriangle) shape;
             *  area = 0.5 * rightTriangle.Side1 * rightTriangle.Side2;
             *  var info = "Right-angled Triangle: ";
             *  info += $"sides {rightTriangle.Side1} {rightTriangle.Side2} {rightTriangle.Side3}, ";
             *  info += $"area = {area}";
             *  Console.WriteLine(info);
             * }
             * else if (shape is Triangle)
             * {
             *  var triangle = (Triangle) shape;
             *
             *  var side1 = triangle.Side1;
             *  var side2 = triangle.Side2;
             *  var side3 = triangle.Side3;
             *  var p = (side1 + side2 + side3) / 2;
             *  area = Math.Sqrt(p * (p - side1) * (p - side2) * (p - side3));
             *  Console.WriteLine($"Triangle: sides: {side1} {side2} {side3}, area = {area}");*/
        }
Example #22
0
    void GenerateThumbnailCore(Item item)
    {
        IPrintable component = DocumentService.CreatePrintableComponent(item);

        if (component == null)
        {
            return;
        }

        PrintableComponentLinkBase pcl = new PrintableComponentLinkBase(new PrintingSystemBase());

        pcl.Component = component;
        pcl.CreateDocument();
        ImageExportOptions imgOptions = new ImageExportOptions();

        imgOptions.ExportMode      = ImageExportMode.SingleFilePageByPage;
        imgOptions.Format          = System.Drawing.Imaging.ImageFormat.Png;
        imgOptions.PageRange       = "1";
        imgOptions.PageBorderWidth = 0;
        MemoryStream stream = new MemoryStream();

        pcl.ExportToImage(stream, imgOptions);

        stream.Position = 0;
        string thumbPath = GetThumbnailPath(item);

        GenerateThumbnailInternal(stream, thumbPath, ThumbnailWidth, ThumbnailHeight);

        IDisposable disposableComponent = component as IDisposable;

        if (disposableComponent != null)
        {
            disposableComponent.Dispose();
        }
    }
Example #23
0
        static void Main(string[] args)
        {
            IPrintable[] printable = new IPrintable[] {
                new Book("ABSALOM, ABSALOM! BY WILLIAM FAULKNER"),
                new Book("A TIME TO KILL BY JOHN GRISHAM"),
                new Magazine("Reader's Digest"),
                new Magazine("School Magazine"),
                new Journal("Acta Astronomica"),
                new Journal("Advances in Space Research"),
                new Magazine("Popular Science"),
                new Magazine("Southern Living"),
                new Journal("AIP Conference Proceedings"),
                new Journal("Astrobiology"),
                new Book("THE HOUSE OF MIRTH BY EDITH WHARTON"),
                new Book("EAST OF EDEN BY JOHN STEINBECK"),
            };

            for (int i = 0; i < printable.Length; i++)
            {
                printable[i].Print();
            }

            Magazine.PrintMagazines(printable);
            Book.PrintBook(printable);

            Console.ReadKey();
        }
Example #24
0
        public static string ShowPopupReportType(IPrintable printable, HttpServerUtility serverUtility, bool reportWide)
        {
            if (SessionWrapper.Instance.Get != null)
            {
                SessionWrapper.Instance.Get.PrintBag = printable;
            }
            else if (!string.IsNullOrEmpty(QueryString.ViewIDValue))
            {
                SessionWrapper.Instance.GetSession(QueryString.ViewIDValue).PrintBag = printable;
            }

            if (reportWide)
            {
                return
                    (string.Format(
                         "window.open('{0}Popups/{1}', 'Popup', 'status=yes, scrollbars=yes, menubar=no, toolbar=no, location=no, width=1050, height=640, resizable=no');",
                         RelativePathComputer.ComputeRelativePathToRoot(serverUtility), printable.PopupPageName));
            }
            else
            {
                return
                    (string.Format(
                         "window.open('{0}Popups/{1}', 'Popup', 'status=yes, scrollbars=yes, menubar=no, toolbar=no, location=no, width=958, height=640, resizable=no');",
                         RelativePathComputer.ComputeRelativePathToRoot(serverUtility), printable.PopupPageName));
            }
        }
Example #25
0
        /// <summary>
        /// 显示打印预览窗体
        /// </summary>
        /// <param name="component">可以是GridContronl或者TreeList或者其他</param>
        /// <param name="headerTitle">标题</param>
        /// <param name="landscape">true表示横向,false表示纵向</param>
        /// <param name="headerFont">标题字体</param>
        public static void ShowPreview(IPrintable component, string headerTitle, bool landscape, Font headerFont)
        {
            PrintingSystem ps = new DevExpress.XtraPrinting.PrintingSystem();

            DevExpress.XtraPrinting.PrintableComponentLink link = new DevExpress.XtraPrinting.PrintableComponentLink(ps);
            ps.Links.Add(link);
            link.Component = component;            //这里可以是可打印的部件

            PageHeaderFooter phf = link.PageHeaderFooter as PageHeaderFooter;

            phf.Header.Content.AddRange(new string[] { "", headerTitle, "" });
            phf.Header.Font          = headerFont;
            phf.Header.LineAlignment = BrickAlignment.Center;
            phf.Footer.Content.AddRange(new string[] { DateTime.Now.ToString("yyyy-MM-dd"), "", "[Page # of Pages #]" });
            phf.Footer.LineAlignment = BrickAlignment.Center;
            link.Landscape           = landscape;
            link.CreateDocument();             //建立文档


            //ps.PreviewFormEx.Menu.MenuItems[0].MenuItems.RemoveAt(6) ;
            //ps.PreviewFormEx.Menu.MenuItems[0].MenuItems.RemoveAt(5);
            //ps.PreviewFormEx.Menu.MenuItems[0].MenuItems.RemoveAt(4);
            //ps.PreviewFormEx.PrintPreviewBar.Buttons.RemoveAt(4);
            //ps.PreviewFormEx.PrintPreviewBar.Buttons.RemoveAt(23);
            //ps.PreviewFormEx.PrintPreviewBar.Buttons.RemoveAt(23);lgm


            ps.PreviewFormEx.Text = headerTitle;

            ps.PreviewFormEx.Show();            //进行预览
        }
Example #26
0
        private void Button3_Click(object sender, EventArgs e)
        {
            Word   data = new Word();
            string text = "";

            text = textBox1.Text;
            bool hasLetters = false;

            hasLetters = FindLetters(text, hasLetters);
            if (hasLetters == true)
            {
                Analyzer textAn = new Analyzer(text);
                textAn.FindInDict();
                textAn.SelectPartOfSpeech();
                string tempInf = "";


                for (int i = 0; i < textAn.WordsInf.Count; i++)
                {
                    textBox2.Text = "";
                    IPrintable word = Analyzer.GetElemFromWordsInfList(i);
                    if (word is Noun || word is Adjective || word is Pronoun || word is Numeral)
                    {
                        tempInf += word.Print(i).Split(',').First() + ", " + word.Print(i).Split(',').Last() + "\r\n";
                    }
                    else
                    {
                        tempInf += word.Print(i).Split(',').First() + ", не склоняется или нет данных\r\n";
                    }
                }

                textBox2.Text += tempInf;
            }
        }
Example #27
0
        public static void ExportToExcel(string title, params IPrintable[] panels)
        {
            SaveFileDialog saveFileDialog = new SaveFileDialog();

            saveFileDialog.FileName = title;
            saveFileDialog.Title    = string.Format("{0} Excel", UnitField.Export);
            saveFileDialog.Filter   = "Excel (*.xlsx)|*.xlsx|Excel(*.xls)|*.xls";
            if (saveFileDialog.ShowDialog() == DialogResult.Cancel)
            {
                return;
            }
            string         text          = saveFileDialog.FileName;
            PrintingSystem expr_43       = new PrintingSystem();
            CompositeLink  compositeLink = new CompositeLink(expr_43);

            expr_43.Links.Add(compositeLink);
            for (int i = 0; i < panels.Length; i++)
            {
                IPrintable printable = panels[i];
                compositeLink.Links.Add(ExportToExcelHelper.CreatePrintableLink(printable));
            }
            compositeLink.Landscape = true;
            try
            {
                int num = 1;
                while (File.Exists(text))
                {
                    if (text.Contains(")."))
                    {
                        int startIndex = text.LastIndexOf("(", StringComparison.Ordinal);
                        int length     = text.LastIndexOf(").", StringComparison.Ordinal) - text.LastIndexOf("(", StringComparison.Ordinal) + 2;
                        text = text.Replace(text.Substring(startIndex, length), string.Format("({0}).", num));
                    }
                    else
                    {
                        text = text.Replace(".", string.Format("({0}).", num));
                    }
                    num++;
                }
                if (text.LastIndexOf(".xlsx", StringComparison.Ordinal) >= text.Length - 5)
                {
                    XlsxExportOptions options = new XlsxExportOptions();
                    compositeLink.ExportToXlsx(text, options);
                }
                else
                {
                    XlsExportOptions options2 = new XlsExportOptions();
                    compositeLink.ExportToXls(text, options2);
                }
                if (XtraMessageBox.Show(UnitField.ExportOK, UnitField.SystemMessage, MessageBoxButtons.YesNo, MessageBoxIcon.Asterisk) == DialogResult.Yes)
                {
                    Process.Start(text);
                }
            }
            catch (Exception arg_16F_0)
            {
                XtraMessageBox.Show(arg_16F_0.Message);
            }
        }
Example #28
0
 private void DrawPrintable(IPrintable printable, PaintEventArgs e)
 {
     if (printable != null)
     {
         printable.DrawOnGraphics(e.Graphics);
         RefreshScreen();
     }
 }
Example #29
0
 public static void PrintControl(IWin32Window owner, IPrintable control)
 {
     using PrintableComponentLink link = new PrintableComponentLink()
           {
               Component = control
           };
     PrintControl(owner, link, link is ISupportLookAndFeel feel ? feel.LookAndFeel : null);
 }
Example #30
0
 private void mnuPrint_Click(object sender, EventArgs e)
 {
     if (_docManager.HasDocument)
     {
         IPrintable document = _docManager.ActiveDocument;
         document.ShowPrintDialog();
     }
 }
		public static void PrintPreview(IPrintable printable)
		{
			using (PrintDocument pdoc = printable.PrintDocument) {
				if (pdoc != null) {
					PrintPreviewDialog ppd = new PrintPreviewDialog();
					ppd.TopMost   = true;
					ppd.Document  = pdoc;
					ppd.Show(WorkbenchSingleton.MainWin32Window);
				} else {
					MessageService.ShowError("${res:ICSharpCode.SharpDevelop.Commands.Print.CreatePrintDocumentError}");
				}
			}
		}
		public static void Print(IPrintable printable)
		{
			using (PrintDocument pdoc = printable.PrintDocument) {
				if (pdoc != null) {
					using (PrintDialog ppd = new PrintDialog()) {
						ppd.Document  = pdoc;
						ppd.AllowSomePages = true;
						if (ppd.ShowDialog(ICSharpCode.SharpDevelop.Gui.WorkbenchSingleton.MainWin32Window) == DialogResult.OK) { // fixed by Roger Rubin
							pdoc.Print();
						}
					}
				} else {
					MessageService.ShowError("${res:ICSharpCode.SharpDevelop.Commands.Print.CreatePrintDocumentError}");
				}
			}
		}
Example #33
0
        private void BuildDocument()
        {
            if (_document != null) return;

            try
            {
                throw new NotImplementedException("ラテン対応してません");
                ILatinWordMetric latinWordMetric; //TODO: 実装
                var engine = new LayoutEngine(_layout, latinWordMetric);
                var aozoraText = ReadFromFile();
                _document = engine.Compose(aozoraText);
            }
            catch (Exception ex)
            {
                System.Diagnostics.Debugger.Break();
                throw ex;
            }
        }
Example #34
0
 public static void Print(IPrintable printable, string filename, int width, int height)
 {
     filename = ShowDialog(filename);
     if (filename == null){
         return;
     }
     string extension = System.IO.Path.GetExtension(filename).ToLower();
     if (File.Exists(filename)){
         File.Delete(filename);
     }
     BasicImageFormat format = BasicImageFormat.GetFromExtension(extension);
     if (format == null){
         MessageBox.Show("Could not find the specified file format: " + extension);
     }
     IGraphics graphics = format.CreateGraphics(filename, width, height);
     printable.Print(graphics, width, height);
     graphics.Close();
     graphics.Dispose();
 }
        /// <summary>
        /// Initializes a new instance of the <see cref="XtraPrintService"/> class.
        /// </summary>
        /// <param name="printable">The printable.</param>
        public XtraPrintService(IPrintable printable)
        {
            printSystem = new PrintingSystem();
            printSystem.ShowMarginsWarning = false;

            PrintableComponentLink pcl = new PrintableComponentLink(printSystem);
            pcl.CreateMarginalHeaderArea += new CreateAreaEventHandler(pcl_CreateMarginalHeaderArea);
            pcl.CreateMarginalFooterArea += new CreateAreaEventHandler(pcl_CreateMarginalFooterArea);
            pcl.Component = printable;
            printSystem.Links.Add(pcl);

            PrinterSettingsUsing pst = new PrinterSettingsUsing();
            pst.UseMargins = false;
            pst.UsePaperKind = false;
            printSystem.PageSettings.PaperKind = PaperKind.A4;
            printSystem.PageSettings.PaperName = "A4";
            printSystem.PageSettings.LeftMargin = 5;
            printSystem.PageSettings.RightMargin = 5;
            printSystem.PageSettings.AssignDefaultPrinterSettings(pst);
        }
Example #36
0
        public ReportCenter(IPrintable Printable, PaperKind paperKind)
        {
            printSystem = new PrintingSystem();
            mReportName = "";
            mCondition = "";
            PrintableComponentLink pcl = new PrintableComponentLink();
            pcl.CreateMarginalHeaderArea += new DevExpress.XtraPrinting.CreateAreaEventHandler(link_CreateMarginalHeaderArea);
            pcl.CreateMarginalFooterArea += new DevExpress.XtraPrinting.CreateAreaEventHandler(link_CreateMarginalFooterArea);
            pcl.Component = Printable;
            printSystem.Links.Add(pcl);
            pcl.CreateDocument();

            PrinterSettingsUsing pst = new PrinterSettingsUsing();
            pst.UseMargins = false;
            pst.UsePaperKind = false;
            printSystem.PageSettings.PaperKind = paperKind;
            printSystem.PageSettings.PaperName = "A4";
            printSystem.PageSettings.LeftMargin = 2;
            printSystem.PageSettings.RightMargin = 2;
            printSystem.PageSettings.AssignDefaultPrinterSettings(pst);
        }
Example #37
0
		/// <exception cref="ArgumentNullException">
		/// <paramref name="document"/> is null.
		/// </exception>
		public static void CopyAsImage(IPrintable document, bool selectedOnly)
		{
			if (document == null)
				throw new ArgumentNullException("document");

			RectangleF areaF = document.GetPrintingArea(true);
			areaF.Offset(0.5F, 0.5F);
			Rectangle area = Rectangle.FromLTRB((int) areaF.Left, (int) areaF.Top,
				(int) Math.Ceiling(areaF.Right), (int) Math.Ceiling(areaF.Bottom));

			using (Bitmap image = new Bitmap(area.Width, area.Height, PixelFormat.Format24bppRgb))
			using (Graphics g = Graphics.FromImage(image))
			{
				// Set drawing parameters
				g.SmoothingMode = SmoothingMode.HighQuality;
				if (DiagramEditor.Settings.Default.UseClearTypeForImages)
					g.TextRenderingHint = TextRenderingHint.ClearTypeGridFit;
				else
					g.TextRenderingHint = TextRenderingHint.SingleBitPerPixelGridFit;
				g.TranslateTransform(-area.Left, -area.Top);

				// Draw image
				g.Clear(Style.CurrentStyle.BackgroundColor);
				IGraphics graphics = new GdiGraphics(g);
				document.Print(graphics, selectedOnly, Style.CurrentStyle);

				try
				{
					System.Windows.Forms.Clipboard.SetImage(image);
				}
				catch
				{
					//UNDONE: exception handling of CopyAsImage()
				}
			}
		}
Example #38
0
 public static void ToConsole(IPrintable printableObjects)
 {
     printableObjects.Print();
 }
 public Command(IConvertable converter, IPhonebookRepository repository, IPrintable printer)
 {
     this.Converter = converter;
     this.PhonebookRepository = repository;
     this.Printer = printer;
 }
Example #40
0
 //Decoupled, Coherent
 public static void Print(IPrintable thing)
 {
     Console.WriteLine(thing.Print());
 }
Example #41
0
		private static void SaveAsImage(IPrintable document, string path,
			ImageFormat format, bool selectedOnly, bool transparent)
		{
			const int Margin = 20;

			RectangleF areaF = document.GetPrintingArea(selectedOnly);
			areaF.Offset(0.5F, 0.5F);
			Rectangle area = Rectangle.FromLTRB((int) areaF.Left, (int) areaF.Top,
				(int) Math.Ceiling(areaF.Right), (int) Math.Ceiling(areaF.Bottom));

			if (format == ImageFormat.Emf) // Save to metafile
			{
				Graphics metaG = control.CreateGraphics();
				IntPtr hc = metaG.GetHdc();
				Graphics g = null;

				try
				{
					// Set drawing parameters
					Metafile meta = new Metafile(path, hc);
					g = Graphics.FromImage(meta);
					g.SmoothingMode = SmoothingMode.HighQuality;
					if (DiagramEditor.Settings.Default.UseClearTypeForImages)
						g.TextRenderingHint = TextRenderingHint.ClearTypeGridFit;
					else
						g.TextRenderingHint = TextRenderingHint.AntiAliasGridFit;
					g.TranslateTransform(-area.Left, -area.Top);

					// Draw image
					IGraphics graphics = new GdiGraphics(g);
					document.Print(graphics, selectedOnly, Style.CurrentStyle);

					meta.Dispose();
				}
				catch (Exception ex)
				{
					MessageBox.Show(
						string.Format("{0}\n{1}: {2}", Strings.ErrorInSavingImage,
							Strings.ErrorsReason, ex.Message),
						Strings.Error, MessageBoxButtons.OK, MessageBoxIcon.Error);
				}
				finally
				{
					metaG.ReleaseHdc();
					metaG.Dispose();
					if (g != null)
						g.Dispose();
				}
			}
			else // Save to rastered image
			{
				int width = area.Width + Margin * 2;
				int height = area.Height + Margin * 2;
				PixelFormat pixelFormat;

				if (transparent)
					pixelFormat = PixelFormat.Format32bppArgb;
				else
					pixelFormat = PixelFormat.Format24bppRgb;

				using (Bitmap image = new Bitmap(width, height, pixelFormat))
				using (Graphics g = Graphics.FromImage(image))
				{
					// Set drawing parameters
					g.SmoothingMode = SmoothingMode.HighQuality;
					if (DiagramEditor.Settings.Default.UseClearTypeForImages && !transparent)
						g.TextRenderingHint = TextRenderingHint.ClearTypeGridFit;
					else
						g.TextRenderingHint = TextRenderingHint.SingleBitPerPixelGridFit;
					g.TranslateTransform(Margin - area.Left, Margin - area.Top);

					// Draw image
					if (!transparent)
						g.Clear(Style.CurrentStyle.BackgroundColor);

					IGraphics graphics = new GdiGraphics(g);
					document.Print(graphics, selectedOnly, Style.CurrentStyle);

					try
					{
						image.Save(path, format);
					}
					catch (Exception ex)
					{
						MessageBox.Show(
							string.Format("{0}\n{1}: {2}", Strings.ErrorInSavingImage,
								Strings.ErrorsReason, ex.Message),
							Strings.Error, MessageBoxButtons.OK, MessageBoxIcon.Error);
					}
				}
			}
		}
Example #42
0
 /// <summary>
 /// ��ʾ��ӡԤ������
 /// </summary>
 /// <param name="component">������GridContronl����TreeList��������</param>
 /// <param name="headerTitle">����</param>
 public static void ShowPreview(IPrintable component, string headerTitle)
 {
     ShowPreview(component, headerTitle, false);
 }
Example #43
0
 public HomeController(IStoryTeller teller, IPrintable printer)
 {
     _teller = teller;
     _printer = printer;
 }
Example #44
0
 public PrintElement(IPrintable printObject)  //  constructor
 {
     _printObject = printObject;
 }
 public CommandChange(IConvertable converter, IPhonebookRepository repository, IPrintable printer)
     : base(converter, repository, printer)
 {
 }
 /// <summary>
 /// Initializes a new instance of the <see cref="XtraPrintService"/> class.
 /// </summary>
 /// <param name="printable">The printable.</param>
 /// <param name="reportTitle">The report title.</param>
 /// <param name="condition">The condition.</param>
 public XtraPrintService(IPrintable printable, string reportTitle, string condition)
     : this(printable, reportTitle)
 {
     this.condition = condition;
 }
 /// <summary>
 /// Initializes a new instance of the <see cref="XtraPrintService"/> class.
 /// </summary>
 /// <param name="printable">The printable.</param>
 /// <param name="reportTitle">The report title.</param>
 /// <param name="paperKind">Kind of the paper.</param>
 public XtraPrintService(IPrintable printable, string reportTitle, PaperKind paperKind)
     : this(printable, reportTitle)
 {
     printSystem.PageSettings.PaperKind = paperKind;
 }
Example #48
0
 /// <summary>
 /// ��ʾ��ӡԤ������
 /// </summary>
 /// <param name="component">������GridContronl����TreeList��������</param>
 /// <param name="headerTitle">����</param>
 /// <param name="landscape">true��ʾ����false��ʾ����</param>
 public static void ShowPreview(IPrintable component, string headerTitle, bool landscape)
 {
     ShowPreview(component, headerTitle, landscape, new Font("����", 22, System.Drawing.FontStyle.Bold));
 }
 /// <summary>
 /// Initializes a new instance of the <see cref="XtraPrintService"/> class.
 /// </summary>
 /// <param name="printable">The printable.</param>
 /// <param name="reportTitle">The report title.</param>
 public XtraPrintService(IPrintable printable, string reportTitle)
     : this(printable)
 {
     this.reportTitle = reportTitle;
 }
Example #50
0
        /*
        * "[Page #]" (represented via the PreviewStringId.PageInfo_PageNumber property)
        * "[Page # of Pages #]" (represented via the PreviewStringId.PageInfo_PageNumberOfTotal property)
        * "[Date Printed]" (represented via the PreviewStringId.PageInfo_PageDate property)
        * "[Time Printed]" (represented via the PreviewStringId.PageInfo_PageTime property)
        * "[User Name]" (represented via the PreviewStringId.PageInfo_PageUserName property)
        */
        public static PrintableComponentLink GetPrintableComponentLink(
            IPrintable gridControl,
            String reportHeader,
            Image ReportHeaderImage,
            String rtfGridHeader,
            float rtfGridHeaderHeight,
            String mainTitle,
            String subTitle,
            String reportFooter,
            String rtfGridFooter)
        {
            float height = 0;

            DevExpress.XtraPrinting.PrintingSystem printingSystem1;
            printingSystem1 = new DevExpress.XtraPrinting.PrintingSystem();
            ((System.ComponentModel.ISupportInitialize)(printingSystem1)).BeginInit();
            DevExpress.XtraPrinting.PrintableComponentLink printableComponentLink1;
            printableComponentLink1 = new DevExpress.XtraPrinting.PrintableComponentLink();
            printableComponentLink1.PaperKind = System.Drawing.Printing.PaperKind.A4;
            printableComponentLink1.Margins.Left = 50;
            printableComponentLink1.Margins.Right = 50;
            printableComponentLink1.Margins.Top = 50;
            printableComponentLink1.Margins.Bottom = 50;
            printingSystem1.Links.AddRange(new object[] { printableComponentLink1 });
            printableComponentLink1.Component = gridControl;
            printableComponentLink1.PrintingSystem = printingSystem1;

            DevExpress.XtraPrinting.PageHeaderArea headerArea;
            headerArea = new DevExpress.XtraPrinting.PageHeaderArea();
            headerArea.Content.Add(reportHeader);
            headerArea.LineAlignment = DevExpress.XtraPrinting.BrickAlignment.Near;

            #region Đầu trang
            if (rtfGridHeader != null)
            {
                printableComponentLink1.RtfReportHeader = rtfGridHeader;
                height = rtfGridHeaderHeight;
            }
            printableComponentLink1.CreateReportHeaderArea += delegate(object sender, DevExpress.XtraPrinting.CreateAreaEventArgs e)
            {
                float currentHeight = height;

                #region Giải pháp 1
                Image headerImage = (ReportHeaderImage == null ?
                    FWImageDic.LOGO_IMAGE48 : ReportHeaderImage);

                DevExpress.XtraPrinting.ImageBrick logo;
                logo = e.Graph.DrawImage(headerImage,
                    new RectangleF(10, 5, headerImage.Width, headerImage.Height),
                    DevExpress.XtraPrinting.BorderSide.None, Color.Transparent);
                //currentHeight += headerImage.Height;
                #endregion

                if (mainTitle != null)
                {
                    DevExpress.XtraPrinting.TextBrick brick;
                    brick = e.Graph.DrawString(mainTitle, Color.Navy, new RectangleF(0, currentHeight, 620, 40), DevExpress.XtraPrinting.BorderSide.None);
                    currentHeight += 40;
                    brick.Font = new Font("Tahoma", 20);
                    brick.StringFormat = new DevExpress.XtraPrinting.BrickStringFormat(StringAlignment.Center);
                    brick.BackColor = Color.White;
                    brick.ForeColor = Color.Black;

                }

                if (subTitle != null)
                {
                    DevExpress.XtraPrinting.TextBrick brickDate;
                    brickDate = e.Graph.DrawString(subTitle, Color.Navy, new RectangleF(0, currentHeight, 620, 40), DevExpress.XtraPrinting.BorderSide.None);
                    currentHeight += 40;
                    brickDate.Font = new Font("Tahoma", 10);
                    brickDate.StringFormat = new DevExpress.XtraPrinting.BrickStringFormat(StringAlignment.Center);
                    brickDate.BackColor = Color.White;
                    brickDate.ForeColor = Color.Black;
                }
            };
            #endregion

            if(rtfGridFooter!= null)
                printableComponentLink1.RtfReportFooter = rtfGridFooter;

            #region Header Footer
            DevExpress.XtraPrinting.PageFooterArea footerArea;
            footerArea = new DevExpress.XtraPrinting.PageFooterArea();
            footerArea.Content.Add(reportFooter);
            footerArea.LineAlignment = DevExpress.XtraPrinting.BrickAlignment.Near;

            DevExpress.XtraPrinting.PageHeaderFooter pageHeaderFooter;
            pageHeaderFooter = new DevExpress.XtraPrinting.PageHeaderFooter(headerArea, footerArea);
            printableComponentLink1.PageHeaderFooter = pageHeaderFooter;
            #endregion

            ((System.ComponentModel.ISupportInitialize)(printingSystem1)).EndInit();

            printableComponentLink1.CreateDocument();

            return printableComponentLink1;
        }
Example #51
0
 /// <summary>
 /// Prints an IPrintable
 /// </summary>
 /// <param name="printable">The IPrintable</param>
 public void Print(IPrintable printable)
 {
     Console.Clear();
     this.PrintStartScreen();
     this.Print(printable.ToPrintable());
 }
 public AbstractCommandsFactory(IConvertable converter, IPhonebookRepository repository, IPrintable printer)
 {
     this.Converter = converter;
     this.Repository = repository;
     this.Printer = printer;
 }
Example #53
0
 public void AddPrintObject(IPrintable printObject)
 {
     _printObjects.Add(printObject);
 }
Example #54
0
 public void Add(IPrintable element)
 {
     this.pagePopulators.Add(element);
 }
Example #55
0
		/// <exception cref="ArgumentNullException">
		/// <paramref name="document"/> is null.
		/// </exception>
		public static void CopyAsImage(IPrintable document)
		{
			CopyAsImage(document, true);
		}
 public RegularCommandsFactory(IConvertable converter, IPhonebookRepository repository, IPrintable printer)
     : base(converter, repository, printer)
 {
 }
 /// <summary>
 /// Позволяет сменить метод вывода информации.
 /// </summary>
 /// <param name="printer"></param>
 public void SetPrinter(IPrintable printer)
 {
     Printer = printer;
 }
 static void Output(IPrintable toOutput)
 {
     Console.WriteLine(toOutput.Print());
 }
Example #59
0
 public PrintElement(IPrintable printObject)
 {
     _printObject = printObject;
 }
Example #60
-1
        /// <summary>
        /// ��ʾ��ӡԤ������
        /// </summary>
        /// <param name="component">������GridContronl����TreeList��������</param>
        /// <param name="headerTitle">����</param>
        /// <param name="landscape">true��ʾ����false��ʾ����</param>
        /// <param name="headerFont">��������</param>
        public static void ShowPreview(IPrintable component, string headerTitle, bool landscape, Font headerFont)
        {
            PrintingSystem ps = new DevExpress.XtraPrinting.PrintingSystem();
            DevExpress.XtraPrinting.PrintableComponentLink link = new DevExpress.XtraPrinting.PrintableComponentLink(ps);
            ps.Links.Add(link);
            link.Component = component;//��������ǿɴ�ӡ�IJ���

            PageHeaderFooter phf = link.PageHeaderFooter as PageHeaderFooter;
            phf.Header.Content.AddRange(new string[]{"", headerTitle, ""});
            phf.Header.Font = headerFont;
            phf.Header.LineAlignment = BrickAlignment.Center;
            phf.Footer.Content.AddRange(new string[] { DateTime.Now.ToString("yyyy-MM-dd"), "", "[Page # of Pages #]" });
            phf.Footer.LineAlignment = BrickAlignment.Center;
            link.Landscape = landscape;
            link.CreateDocument(); //�����ĵ�

            //ps.PreviewFormEx.Menu.MenuItems[0].MenuItems.RemoveAt(6) ;
            //ps.PreviewFormEx.Menu.MenuItems[0].MenuItems.RemoveAt(5);
            //ps.PreviewFormEx.Menu.MenuItems[0].MenuItems.RemoveAt(4);
            //ps.PreviewFormEx.PrintPreviewBar.Buttons.RemoveAt(4);
            //ps.PreviewFormEx.PrintPreviewBar.Buttons.RemoveAt(23);
            //ps.PreviewFormEx.PrintPreviewBar.Buttons.RemoveAt(23);lgm

            ps.PreviewFormEx.Text=headerTitle;

            ps.PreviewFormEx.Show();//����Ԥ��
        }