Beispiel #1
0
        /// <summary>
        /// print the ship's cargo history
        /// </summary>
        public void printHistory()
        {
            StringBuilder sb = new StringBuilder();

            int col1 = 25;
            int col2 = 25;
            int col3 = 9;
            int col4 = 8;
            int col5 = 8;

            // create two column headers, can have max of 4
            string ch1 = "Cargo Code".PadRight(col1) +
              "Description".PadRight(col2) +
              "Purchase".PadRight(col3) +
              "Sold".PadLeft(col4) +
              "Profit".PadLeft(col5);
            string ch2 = "   " +
                "sold at";
            int total = 5;

            // generate the detail lines (Dummy Data)
            int totalCreds = 0;
            int profit = 0;
            Traveller.World w = new World();
            foreach (Traveller.Starship.cargoDesc lot in this.sold)
            {
                Match worldMatch = w.worldRegex.Match(lot.origSEC);
                string origName = worldMatch.Groups["name"].Value;
                worldMatch = w.worldRegex.Match(lot.destSEC);
                string destName = worldMatch.Groups["name"].Value;
                profit = lot.sellingPrice - lot.purchasePrice;

                string desc = lot.desc;
                if (desc.Length > 24)
                    desc = desc.Substring(0, 24);
                string origCode = lot.origCode;
                if (origCode.Length > 24)
                    origCode = origCode.Substring(0, 24);

                sb.Append(String.Format("{0,-24} {1,-25} {2,8} {3,8} {4,8}",
                    lot.origCode, desc, lot.purchasePrice, lot.sellingPrice, profit) +
                    Environment.NewLine);
                sb.Append(String.Format("  purch date: {0} at {1} sold date: {2} at {3}", lot.purchaseDate, origName, lot.sellingDate, destName) +
                    Environment.NewLine + Environment.NewLine);
                total += 15;
                totalCreds += profit;
            }

            // now we will pretend to have had a total break and change the
            // subtitle, after forcing a page change
            sb.Append(Environment.NewLine + " ".PadLeft(45) +
              "Profit Cr" + totalCreds.ToString().PadLeft(12) + Environment.NewLine);

            // finally, set up & print the report
            // instantiate the object
            CPrintReportStringDemo.CPrintReportString cprs = new CPrintReportStringDemo.CPrintReportString();

            // set the title font points size and style
            cprs.TitleFontSize = 14;
            cprs.TitleFontStyle = TitleStyle.BoldItalic;
            cprs.Footer = String.Format("Confidential: Cargo History for {0}", this.name);

            // get margin extenders if any
            cprs.LeftMarginExtender = MarginExtender.OneHalfInch;
            cprs.RightMarginExtender = MarginExtender.OneHalfInch;
            cprs.TopMarginExtender = MarginExtender.OneHalfInch;
            cprs.BottomMarginExtender = MarginExtender.OneHalfInch;

            // call the print or preview method
            string title = String.Format("Cargo History for {0}", this.name);
            string subTitle = " ";
            cprs.SubTitle2 = " ";
            cprs.SubTitle3 = "";
            cprs.SubTitle4 = "";
            cprs.PrintOrPreview(CharsPerLine.CPL80,
              sb.ToString(), title, subTitle, PrintPreview.Preview,
              PrintOrientation.Portrait, ch1, ch2);
        }
Beispiel #2
0
        /// <summary>
        /// make a jump
        /// </summary>
        /// <param name="sec">string - world jumping to (SEC format)</param>
        /// <remarks>add a week, add the travelogue, subtract jump cost</remarks>
        public void makeJump(string sec)
        {
            Traveller.World w = new World();
            Match worldMatch = w.worldRegex.Match(this.sec);
            string currentWorld = worldMatch.Groups["name"].Value;
            worldMatch = w.worldRegex.Match(sec);
            string nextWorld = worldMatch.Groups["name"].Value;

            this.travelogue(String.Format("Jumping from {0} to {1}", currentWorld, nextWorld));
            this.credits -= this.jumpCost;  // cost per jump
            this.sec = sec;                 // new system
            addDays(7);                     // jump
            save();
            this.travelogue(String.Format("arrived at {0}", nextWorld));
        }