void Save(PageItem Page) { try { SaveFileDialog dlg = new SaveFileDialog() { FileName = "Page", Filter = "All Files (*.*)|*.*|Xml Files (*.xml)|*.xml", FilterIndex = 2 }; if (dlg.ShowDialog() == true) { using (TextWriter writer = new StreamWriter(dlg.FileName)) { XmlSerializer serializer = new XmlSerializer(Page.GetType(), Page.GetTypes()); serializer.Serialize(writer, Page); } } } catch (Exception ex) { Debug.Print(ex.Message); } }
void Open(PageItem Page) { try { OpenFileDialog dlg = new OpenFileDialog() { FileName = "", Filter = "All Files (*.*)|*.*|Xml Files (*.xml)|*.xml", FilterIndex = 2 }; if (dlg.ShowDialog() == true) { bool IsPrinting = Page.IsPrinting; bool IsGridVisible = Page.IsGridVisible; bool IsDeletedVisible = Page.IsDeletedVisible; using (TextReader reader = new StreamReader(dlg.FileName)) { XmlSerializer serializer = new XmlSerializer(Page.GetType(), Page.GetTypes()); PageItem newPage = new PageItem(); newPage = (PageItem)serializer.Deserialize(reader); // restore not serialized valules newPage.IsPrinting = IsPrinting; newPage.IsGridVisible = IsGridVisible; newPage.IsDeletedVisible = IsDeletedVisible; // newPage.Signals = ?? // get all DataBlockLogicItem items //var list = from item in newPage.Items // where item is DataBlockLogicItem // select item; this.DataContext = newPage; Page = null; } } } catch (Exception ex) { Debug.Print(ex.Message); } }
private void DrawBorder(PageItem pi, Graphics g, RectangleF r) { if (pi.GetType().Name.Equals("PagePie")) { return; } if (r.Height <= 0 || r.Width <= 0) // no bounding box to use { return; } StyleInfo si = pi.SI; DrawLine(si.BColorTop, si.BStyleTop, si.BWidthTop, g, r.X, r.Y, r.Right, r.Y); DrawLine(si.BColorRight, si.BStyleRight, si.BWidthRight, g, r.Right, r.Y, r.Right, r.Bottom); DrawLine(si.BColorLeft, si.BStyleLeft, si.BWidthLeft, g, r.X, r.Y, r.X, r.Bottom); DrawLine(si.BColorBottom, si.BStyleBottom, si.BWidthBottom, g, r.X, r.Bottom, r.Right, r.Bottom); return; }