void PrintToPrinter(string EntryDocNo, ReportParameter[] parameters)
        {
            DataTable dt = Db.GetDataAsDataTableFromSP("sp_AdmissionReport", "AdmissionDT", "@EntryDocNo", EntryDocNo);

            appcode.Printable p = new Printable();
            //p.PrinterName = "PDFCreator";
            p.Run(Config.ReportsPath + "SelfAdmission.rdlc", "AdmissionDataset", dt, parameters);
        }
Exemple #2
0
 internal TestCaseWriter(string testName, Printable given, TargetFactory <T> targetFactory, IList <Action <T, F> > actions, Action <T, F> failingAction)
 {
     this._testName      = testName;
     this._given         = given;
     this._targetFactory = targetFactory;
     this._actions       = actions;
     this._failingAction = failingAction;
 }
Exemple #3
0
        public static void ResetPrintDocument(this Printable @this)
        {
            if ([email protected])
            {
                @this.PrintDocument = new PrintDocumentBuilder(@this.Strategy.Session).Build();
            }

            @this.PrintDocument.Media?.Delete();
        }
        public byte[] CreatePdfContent(Printable printable)
        {
            _issueReport = new Dictionary <string, string>();
            // the prince converter optimized for boom templates
            var converter = new BoomConverter();

            converter.IssueReport += converter_IssueReport;
            // TODO: Add dynamic modifications to final document here
            var html = converter.GenerateHtml(printable, Printable.TemplatePartial.DocumentXml);

            return(MakePdf(html));
        }
Exemple #5
0
            /// <summary>
            /// A new instance where 'format' describes the page's
            /// size and orientation and 'painter' is the instance
            /// that will draw the page's graphics. </summary>
            /// <exception cref="NullPointerException">
            ///          If the <code>painter</code> or <code>format</code>
            ///          argument is <code>null</code> </exception>
            internal BookPage(Book outerInstance, Printable painter, PageFormat format)
            {
                this.OuterInstance = outerInstance;

                if (painter == null || format == null)
                {
                    throw new NullPointerException();
                }

                MFormat  = format;
                MPainter = painter;
            }
Exemple #6
0
        /// <summary>
        /// Appends <code>numPages</code> pages to the end of this
        /// <code>Book</code>.  Each of the pages is associated with
        /// <code>page</code>. </summary>
        /// <param name="painter">   the <code>Printable</code> instance that renders
        ///                  the page </param>
        /// <param name="page">      the size and orientation of the page </param>
        /// <param name="numPages">  the number of pages to be added to the
        ///                  this <code>Book</code>. </param>
        /// <exception cref="NullPointerException">
        ///          If the <code>painter</code> or <code>page</code>
        ///          argument is <code>null</code> </exception>
        public virtual void Append(Printable painter, PageFormat page, int numPages)
        {
            BookPage bookPage  = new BookPage(this, painter, page);
            int      pageIndex = MPages.Count;
            int      newSize   = pageIndex + numPages;

            MPages.Capacity = newSize;
            for (int i = pageIndex; i < newSize; i++)
            {
                MPages[i] = bookPage;
            }
        }
Exemple #7
0
        public string CreateHtml(Printable printable)
        {
            _printable   = printable;
            _issueReport = new Dictionary <string, string>();
            // first we get the container template
            var converter = new BoomConverter();

            converter.IssueReport += converter_IssueReport;
            // TODO: Add dynamic modifications to final document here
            var html = converter.GenerateHtml(printable, Printable.TemplatePartial.DocumentXml);

            return(html);
        }
Exemple #8
0
        /// <summary>
        /// Sets the <code>PageFormat</code> and the <code>Painter</code> for a
        /// specified page number. </summary>
        /// <param name="pageIndex"> the zero based index of the page whose
        ///                  painter and format is altered </param>
        /// <param name="painter">   the <code>Printable</code> instance that
        ///                  renders the page </param>
        /// <param name="page">      the size and orientation of the page </param>
        /// <exception cref="IndexOutOfBoundsException"> if the specified
        ///          page is not already in this <code>Book</code> </exception>
        /// <exception cref="NullPointerException"> if the <code>painter</code> or
        ///          <code>page</code> argument is <code>null</code> </exception>
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in .NET:
//ORIGINAL LINE: public void setPage(int pageIndex, Printable painter, PageFormat page) throws IndexOutOfBoundsException
        public virtual void SetPage(int pageIndex, Printable painter, PageFormat page)
        {
            if (painter == null)
            {
                throw new NullPointerException("painter is null");
            }

            if (page == null)
            {
                throw new NullPointerException("page is null");
            }

            MPages[pageIndex] = new BookPage(this, painter, page);
        }
Exemple #9
0
 private void realize()
 {
     try
     {
         Type type = Type.GetType(className);
         real = (Printable)Activator.CreateInstance(type);
         real.SetPrinterName(name);
     }
     catch (Exception e)
     {
         Debug.Log("クラス " + className + " が見つかりません。");
         Debug.Log(e.StackTrace.ToString());
     }
 }
        void PrintToPrinter(string EntryDocNo, string candclass, string shares, string classname)
        {
            DataTable dt = Db.GetDataAsDataTableFromSP("sp_GetVotePaper", "VoteDT", "@class", candclass, "@status", "candidate");

            appcode.Printable p = new Printable();
            //p.PrinterName = "PDFCreator";
            ReportParameter[] ReportParams = new ReportParameter[]
            {
                new ReportParameter("title", "لإنتخاب أعضاء مجلس الادارة فئة " + classname),
                new ReportParameter("SharesQty", shares),
                new ReportParameter("docno", EntryDocNo)
            };
            p.OnlyOnePage = true;
            p.Run(@Config.ReportsPath + "VotePaper.rdlc", "DataSet1", dt, ReportParams);
        }
Exemple #11
0
 public static void TryPrinting(params object[] arr)
 {
     foreach (object o in arr)
     {
         //https://docs.microsoft.com/en-us/dotnet/csharp/language-reference/keywords/as
         Printable printableObject = o as Printable;
         if (printableObject != null)
         {
             Console.WriteLine("{0}", printableObject.Print());
         }
         else
         {
             Console.WriteLine("{0}", o);
         }
     }
 }
        public byte[] CreatePdfCover(Printable printable)
        {
            var coverTpl  = Encoding.UTF8.GetString(printable.Templates.Single(t => t.InternalName == Printable.TemplatePartial.BookCover).Content);
            var tempFiles = new List <string>();
            // create and write cover background
            var coverImg = Path.Combine(printable.TempStorePath, "bg" + Guid.NewGuid() + ".png");

            using (var coverFile = File.Create(coverImg)) {
                coverFile.Write(printable.CoverImage, 0, printable.CoverImage.Length);
            }
            tempFiles.Add(coverImg);
            // create and write QR code
            // TODO: Make this dynamic with additional data
            // create and write barcode, if needed
            byte[] barcodeImg = null;
            if (printable.HasIsbn)
            {
                barcodeImg = GetBarCode(printable.Isbn, 158, 77, printable.Title);
            }
            string bio = null;

            if (printable.AdditionalAuthorInfo.Any())
            {
                bio = String.Join(" ", printable.AdditionalAuthorBiographies.ToArray());
            }
            var publishedAuthors = "";

            if (printable.AdditionalAuthorInfo.Any())
            {
                publishedAuthors = String.Join(", ", printable.AdditionalAuthorInfo.ToArray());
            }
            if (printable.PermaLink != null)
            {
                printable.Updatelink = String.Format(WebConfigurationManager.AppSettings["production:CoverPermaLink"], printable.PermaLink);
                printable.QRImg      = CreateQRCode(printable.Updatelink);
            }
            printable.BarCodeImg = barcodeImg;
            printable.CoverImg   = coverImg;
            printable.HasToc     = false;
            printable.HasIndex   = false;
            printable.HasImprint = false;
            var bc   = new BoomConverter();
            var html = bc.GenerateHtml(printable, Printable.TemplatePartial.BookCover);

            return(MakePdf(html));
        }
Exemple #13
0
        private static void UpdatePrintDocument(this Printable @this, byte[] document)
        {
            if (document != null)
            {
                if ([email protected])
                {
                    @this.PrintDocument = new PrintDocumentBuilder(@this.Strategy.Session).Build();
                }

                if ([email protected])
                {
                    @this.PrintDocument.Media = new MediaBuilder(@this.Strategy.Session).Build();
                }

                @this.PrintDocument.Media.InData = document;
            }
            else
            {
                @this.ResetPrintDocument();
            }
        }
Exemple #14
0
 void PrintToPrinter(string EntryDocNo, string candclass, string shares, string classname)
 {
     if (_DocType == "vote")
     {
         DataTable         dt = Db.GetDataAsDataTableFromSP("sp_GetVotePaper", "VoteDT", "@class", candclass, "@status", "candidate");
         appcode.Printable p  = new Printable();
         //p.PrinterName = "PDFCreator";
         ReportParameter[] ReportParams = new ReportParameter[]
         {
             new ReportParameter("title", "لإنتخاب أعضاء مجلس الادارة فئة " + classname),
             new ReportParameter("SharesQty", shares),
             new ReportParameter("docno", EntryDocNo)
         };
         p.OnlyOnePage = true;
         p.Run(@Config.ReportsPath + "VotePaper.rdlc", "DataSet1", dt, ReportParams);
     }
     else if (_DocType == "entry")
     {
         DataTable         dt2 = Db.GetDataAsDataTableFromSP("sp_AdmissionReport", "AdmissionDT", "@EntryDocNo", EntryDocNo);
         appcode.Printable p   = new Printable();
         //p.PrinterName = "PDFCreator";
         ReportParameter[] ReportParams = new ReportParameter[]
         {
             new ReportParameter("EventDate", Config.EventDate),
             new ReportParameter("EventYear", Config.EventYear),
             new ReportParameter("EventName", Config.EventName)
         };
         p.OnlyOnePage = true;
         //if (int.Parse(dt2.Rows[0]["TotalHolderDelagateSharesQty"].ToString()) > 0)
         //{
         p.Run(@Config.ReportsPath + "AgentAdmission2.rdlc", "AddmissionDataset", dt2, ReportParams);
         //}
         //else
         //{
         //    p.Run(@Config.ReportsPath + "SelfAdmission.rdlc", "AdmissionDataset", dt2, ReportParams);
         //}
     }
 }
Exemple #15
0
        static void Main(string[] args)
        {
            var myDoc = new Document();

            myDoc.Print();
            myDoc.CountCharacters();

            //Printable mySecondDoc = new Printable();
            Printable printableItem = myDoc;

            printableItem.Print();
            //printableItem.CountCharacters();

            Document theDoc = printableItem as Document;

            if (theDoc != null)
            {
                theDoc.CountCharacters();
            }

            string contents = theDoc.Read();

            Console.WriteLine("contents: " + contents);
        }
Exemple #16
0
 public virtual TestCaseWriter <T, F> TestCaseWriter(string name, Printable given)
 {
     return(new TestCaseWriter <T, F>(name, given, _targetFactory, _givenActions, _failingAction));
 }
Exemple #17
0
 /// <summary>
 /// Appends a single page to the end of this <code>Book</code>. </summary>
 /// <param name="painter">   the <code>Printable</code> instance that
 ///                  renders the page </param>
 /// <param name="page">      the size and orientation of the page </param>
 /// <exception cref="NullPointerException">
 ///          If the <code>painter</code> or <code>page</code>
 ///          argument is <code>null</code> </exception>
 public virtual void Append(Printable painter, PageFormat page)
 {
     MPages.Add(new BookPage(this, painter, page));
 }
Exemple #18
0
        public static void RenderPrintDocument(this Printable @this, Template template, IDictionary <string, object> model, IDictionary <string, byte[]> images)
        {
            var document = template?.Render(model, images);

            @this.UpdatePrintDocument(document);
        }
Exemple #19
0
 public PrintQueue Locate(Printable printable)
 {
     return this.DefaultPrintQueue;
 }
Exemple #20
0
 public bool Write(Printable print)
 {
     return(Write(print.GetPrint()));
 }
Exemple #21
0
 public static void PrintableArea(Printable p)
 {
     Console.WriteLine("Minimum Area to print: " + p.area());
 }
Exemple #22
0
 /// <summary>
 /// Calls <code>painter</code> to render the pages in the specified
 /// <code>format</code>.  The pages in the document to be printed by
 /// this <code>PrinterJob</code> are rendered by the
 /// <code>Printable</code> object, <code>painter</code>. The
 /// <code>PageFormat</code> of each page is <code>format</code>. </summary>
 /// <param name="painter"> the <code>Printable</code> called to render
 ///          each page of the document </param>
 /// <param name="format"> the size and orientation of each page to
 ///                   be printed </param>
 public abstract void SetPrintable(Printable painter, PageFormat format);
        private void btn_Commit_Click(object sender, EventArgs e)
        {
            if (CheckRequiredFields())
            {
                if (Config.PrintAdmissionDocument && Db.GetPrinterName(Utility.GetMACAddress()) == "N/A")
                {
                    MessageBox.Show("لم يتم تحديد الطابعة التي سيتم عبرها طباعة بطاقة الدخول", "خطأ"
                                    , MessageBoxButtons.OK, MessageBoxIcon.Error, MessageBoxDefaultButton.Button1,
                                    MessageBoxOptions.RightAlign);
                }
                else
                {
                    string Msg = "هل تريد بالتأكيد الحفظ؟" + Environment.NewLine + Environment.NewLine + "تنبيه : لايمكن  التراجع بعد الحفظ.";
                    if (new Dialogs.Dg_ComfirmMessage("الحفظ", Msg).MessageResult() == DialogResult.Yes)
                    {
                        string EntryDocNo = Db.CreateReception(string.Empty, 0, CurrentHolderClass
                                                               , txt_H_DlgName.Text, txt_H_IdTypeId.Text, txt_H_IdNo.Text, DateTime.Parse(txt_H_IdDate.Text)
                                                               , txt_H_IdPlace.Text, int.Parse(string.IsNullOrEmpty(txt_H_CardNo.Text) ? "0" : txt_H_CardNo.Text)
                                                               , string.Empty, SharedParam.CurrentUser.UserID, "OrgDelegate", "post", SharedParam.CurrentUser.UserID);
                        if (int.Parse(EntryDocNo) > 0)
                        {
                            int lineno = 0;
                            foreach (PresentHolderCertsWithDelegate tmp in HolderCertsList)
                            {
                                int result = Db.CreateReceptionDetails(int.Parse(EntryDocNo), ++lineno, tmp.CertNo, tmp.ShareQty, tmp.ClassId
                                                                       , true, tmp.DlgNo, tmp.DlgDate, tmp.DlgName, tmp.ApprovedNo, tmp.ApprovedDate, tmp.ApprovedOrg
                                                                       , int.Parse(tmp.RowId), tmp.Note, tmp.Delegate_Type, tmp.Reception_Type, tmp.Userid);
                            }
                            if (!Db.HasData("reception_details", " Where entry_doc_no=" + EntryDocNo))
                            {
                                Db.ExecuteSQLCommand("delete from reception where entry_doc_no=" + EntryDocNo);
                            }
                            else
                            {
                                DataTable dt = Db.GetDataAsDataTable("select isnull(count(*),0) cnt,sum(share_qty) shares from reception_details where entry_doc_no=@entrydocno"
                                                                     , "actual", "entrydocno", EntryDocNo);
                                if (dt != null)
                                {
                                    Dialogs.Dg_InfoMessage frm = new Dialogs.Dg_InfoMessage("تم الحفظ بنجاح"
                                                                                            , EntryDocNo
                                                                                            , (dt.Rows[0]["cnt"] == DBNull.Value ? 0 : (int)dt.Rows[0]["cnt"])
                                                                                            , (dt.Rows[0]["shares"] == DBNull.Value ? 0 : (int)dt.Rows[0]["shares"]));
                                    frm.ShowDialog();

                                    if (Config.PrintAdmissionDocument)
                                    {
                                        string result = Db.CreatePrint(int.Parse(EntryDocNo)
                                                                       , "entry", "first_print", SharedParam.CurrentUser.UserID, "other"
                                                                       , string.Empty);
                                        if (result == "success")
                                        {
                                            DataTable         dt2 = Db.GetDataAsDataTableFromSP("sp_AdmissionReport", "AdmissionDT", "@EntryDocNo", EntryDocNo);
                                            appcode.Printable p   = new Printable();
                                            //p.PrinterName = "PDFCreator";
                                            ReportParameter[] ReportParams = new ReportParameter[]
                                            {
                                                new ReportParameter("EventDate", Config.EventDate),
                                                new ReportParameter("EventYear", Config.EventYear)
                                            };
                                            p.OnlyOnePage = true;
                                            p.Run(@Config.ReportsPath + "SelfAdmission.rdlc", "AdmissionDataset", dt2, ReportParams);
                                            //PrintToPrinter(EntryDocNo, ReportParams);
                                            //PrintToPrinter(EntryDocNo);
                                        }
                                        else
                                        {
                                            MessageBox.Show("فشلت عملية الطباعة");
                                        }
                                    }
                                    NewTransaction();
                                }
                            }
                        }
                        else
                        {
                        }
                    }
                    else
                    {
                        //MessageBox.Show("NO");
                    }
                }// Check Printer ...
            }
        }
Exemple #24
0
 public void printOnScreens(string screenTag, Printable myObject)
 {
     printOnScreens(screenTag, myObject.ToString());
 }
        private void Render(object sender, TicEventArgs e)
        {
            var toRender = new List <Printable>();

            // background
            var background = e.Universe.PrintableBackground;

            toRender.Add(background);

            // pipes
            var pipes = e.PrintablePipes;

            if (MyBird.IsDead || MyBird.CurrentGraceInterval > 0)
            {
                pipes = pipes.Select(p => new Printable(p.X, p.Y, p.Image, Convert.ToInt32(p.R), 0.4, p.GuidKey)).ToList();
            }
            toRender.AddRange(pipes);


            // the base
            var theBase = e.Universe.TheBase;

            toRender.Add(theBase);

            // score
            toRender.AddRange(GetPrintableScore(MyBird.score));

            // other players
            foreach (var bird in e.Players)
            {
                if (bird != MyBird)
                {
                    var otherBirdIndex = bird.IsDead?0:bird.playerIndex;
                    var otherBird      = new Printable(bird.playerx, bird.playery, bird.player_images[otherBirdIndex], -bird.visibleRot, opacity: 0.5, guidKey: bird.GuidKey);
                    toRender.Add(otherBird);
                }
            }

            // myBird
            var myBirdIndex = MyBird.IsDead?0:MyBird.playerIndex;
            var ocell       = new Printable(MyBird.playerx, MyBird.playery, MyBird.player_images[myBirdIndex], -MyBird.visibleRot, null, MyBird.GuidKey);

            toRender.Add(ocell);

            // play again
            if (MyBird.IsDead && MyBird.CurrentPenaltyTime == 0)
            {
                var playAgain = e.Universe.PlayAgain;
                toRender.Add(playAgain);
                if (!PleaseStopSent)
                {
                    PleaseStopSent = true;
                    Universe.PleaseStop();
                }
            }
            else if (MyBird.IsDead && MyBird.CurrentPenaltyTime > 0)
            {
                var gameOver = e.Universe.GameOver;
                toRender.Add(gameOver);
            }

            Statistics.totalPlayers  = e.Players.Count();
            Statistics.fps           = Universe.CurrentFps;
            Statistics.totalSessions = Universe.TotalSessions.ToString();
            Statistics.startedAt     = Universe.StartedAt;
            Statistics.maxScore      = Universe.MaxScore;
            lock (ToRender)
            {
                ToRender.Clear();
                ToRender.AddRange(toRender);
            }

            InvokeAsync(StateHasChanged);
        }