Ejemplo n.º 1
0
		static FlowDocument CreateDocument(Project project, Lessee lessee, bool overview) {
			var doc = new FlowDocument();

			if ( lessee != null && !overview ) {// Print 1 page for a single lessee
				WritePage(doc, new Lessee[] { lessee }, project, false, true);
			} else if ( lessee == null && overview ) {// Partition lessees 8 at a time
				int i = 0;
				var list = new List<Lessee>();
				foreach ( Lessee l in project.Result.Lessees.Keys.OrderBy(l => l.Name) ) {
					list.Add(l);
					if ( ++i == 8 ) {
						WritePage(doc, list, project, true, false);
						i = 0;
						list = new List<Lessee>();
					}
				}
				if ( i > 6 ) {
					WritePage(doc, list.Take(6).ToList(), project, true, false);
					WritePage(doc, new Lessee[] { list[list.Count - 1] }, project, true, true);
				} else WritePage(doc, list, project, true, true);
			} else if ( lessee == null && !overview ) {// Print 1 page per lessee for all lessees
				foreach ( Lessee l in project.Result.Lessees.Keys ) {
					WritePage(doc, new Lessee[] { l }, project, false, false);
				}
			} else {
				throw new ArgumentException("Arguments invalid");
			}

			return doc;
		}
Ejemplo n.º 2
0
        public void RemoveLessee(Lessee l)
        {
            var opt = options.FirstOrDefault(o => o.Lessee == l);

            if (opt != null)
            {
                options.Remove(opt);
            }
        }
Ejemplo n.º 3
0
		public void AddLessee(Lessee l) {
			if ( options.Count(o => o.Lessee == l) < 1 ) {
				var o = new CostOptions(this, l);
				o.PropertyChanged += (s, e) => {
					if (e.PropertyName == "Amount") {
						CalculateTotalAmountFromExternal();
					}
				};
				options.Add(o);
			}
		}
Ejemplo n.º 4
0
 public void AddLessee(Lessee l)
 {
     if (options.Count(o => o.Lessee == l) < 1)
     {
         var o = new CostOptions(this, l);
         o.PropertyChanged += (s, e) => {
             if (e.PropertyName == "Amount")
             {
                 CalculateTotalAmountFromExternal();
             }
         };
         options.Add(o);
     }
 }
Ejemplo n.º 5
0
        // Print - brings up the print dialogue and starts printing
        public static bool Print(Project project, Lessee lessee = null, bool overview = false) {
			PrintDocumentImageableArea area = null;
			var writer = PrintQueue.CreateXpsDocumentWriter(ref area);
			var document = CreateDocument(project, lessee, overview);
			document.PageWidth = area.MediaSizeWidth;
			document.PageHeight = area.MediaSizeHeight;
			document.ColumnWidth = document.PageWidth;
			document.PagePadding = new Thickness(40);
			IDocumentPaginatorSource source = document;
			try {
				writer.WriteAsync(source.DocumentPaginator);
			} catch ( Exception ) {
				return false;
			}
            return true;
        }
Ejemplo n.º 6
0
		public static void Write(LesseeManager lessees, string filepath, IdTable ids) {
			var f = new XmlWriter(filepath);
			f.Begin("Lessees");
			var list = new Lessee[lessees.Count];
			lock ( lessees ) lessees.CopyTo(list, 0);
			foreach ( var l in list ) {
				f.Begin(l, ids);
				f.Begin("Payments");
				var paymentlist = new AdvancePayment[l.Payments.Count];
				lock ( l.Payments ) l.Payments.CopyTo(paymentlist, 0);
				foreach ( var p in paymentlist ) f.Write(p, ids);
				f.End("Payments");
				f.End(l);
			}
			f.End("Lessees");
			f.Close();
		}
Ejemplo n.º 7
0
		public static void Read(string filepath, LesseeManager lessees, ReferenceTable references, IdTable ids) {
			var xml = new XPathDocument(filepath).CreateNavigator();
			var li = xml.Select("/Lessees/Lessee");
            var list = new List<Lessee>();
			while ( li.MoveNext() ) {
				var lnode = li.Current;
				var l = new Lessee();
				ids[l] = new Guid(lnode.GetAttribute("id", ""));
				AssignProperties(lnode, l, references);
				var pi = lnode.Select("Payments/AdvancePayment");
				while ( pi.MoveNext() ) {
					var pnode = pi.Current;
					var p = new AdvancePayment();
					ids[p] = new Guid(pnode.GetAttribute("id", ""));
					AssignProperties(pnode, p, references);
					l.Payments.Add(p);
				}
                list.Add(l);
			}
            foreach (var i in list.OrderBy(item => item.Name))
                lessees.Add(i);
		}
Ejemplo n.º 8
0
 internal AdvancePaymentCollection(Lessee host)
 {
     lessee = host;
 }
Ejemplo n.º 9
0
		public void RemoveLessee(Lessee l) {
			var opt = options.FirstOrDefault(o => o.Lessee == l);
			if ( opt != null ) options.Remove(opt);
		}
Ejemplo n.º 10
0
 internal CostOptions(Cost host, Lessee appliesTo)
 {
     cost   = host;
     lessee = appliesTo;
 }
Ejemplo n.º 11
0
		internal CostOptions(Cost host, Lessee appliesTo) {
			cost = host;
			lessee = appliesTo;
		}