public static void LoadItems(this ISectionHeader sectionHeader, IEnumerable <IScreenItem> items) { foreach (var item in items) { sectionHeader.AddItem(item); } }
/// <summary> /// match the section of the screen definition against content of an actual /// screen. /// </summary> /// <param name="section"></param> /// <param name="Content"></param> /// <returns></returns> public static bool Match( this ISectionHeader section, IScreenLoc Start, ScreenContent Content, string DebugInfo) { bool isMatch = true; // match from screenDefn to the screenContent. foreach (var item in section.Items) { if (isMatch == false) { break; } isMatch = item.Match(Start, Content, DebugInfo); // BgnTemp if ((isMatch == false) && (DebugInfo == "DisplayMessages")) { isMatch = item.Match(Start, Content, DebugInfo); } // EndTemp } return(isMatch); }
private void butTest_Click(object sender, RoutedEventArgs e) { ISectionHeader sh = this.Model; // find the first ScreenSection. set to the items of that section. var sect = sh.Items.OfType <ScreenSectionModel>().First(); if (sect != null) { sh = sect; } var found = sh.Items.FirstOrDefault(c => c.ItemName == "abc3"); if (found != null) { sh.RemoveItem(found); } var item = new ScreenLiteralModel(); item.ItemName = "abc3"; item.ScreenLoc = new OneScreenLoc(1, 5); sh.AddItem(item); }
/// <summary> /// capture the data of the screen to a DataItemReport class. /// </summary> /// <param name="Defn"></param> /// <param name="Content"></param> /// <returns></returns> public static DataItemReport CaptureToReport(this IScreenDefn Defn, ScreenContent Content) { ISectionHeader sectionHeader = Defn as ISectionHeader; var start = new OneScreenLoc(1, 1); var itemReport = sectionHeader.CaptureToReport(start, Content); return(itemReport); }
public static void RemoveItemAt( this ISectionHeader sectionHeader, int Index) { var item = sectionHeader.Items[Index]; sectionHeader.Items.RemoveAt(Index); item.SectionHeader = null; }
public static bool IsLastItem(this ISectionHeader sectionHeader, int Index) { if (Index + 1 == sectionHeader.Items.Count) { return(true); } else { return(false); } }
/// <summary> /// Determines whether the specified <see cref="ISectionHeader"/> is equal to this instance. /// </summary> /// <param name="other">The <see cref="ISectionHeader"/> to compare with this instance.</param> /// <returns><c>true</c> if the specified <see cref="ISectionHeader"/> is equal to this instance; /// otherwise, <c>false</c>.</returns> public bool Equals(ISectionHeader other) { SectionHeader header = other as SectionHeader; if (header != null) { return(Pair == header.Pair); } return(Pair == other); }
public static void ClearItems(this ISectionHeader sectionHeader) { // first clear the link to section header in all the items. foreach (var item in sectionHeader.Items) { item.SectionHeader = null; } // clear the list of items of the sectionHeader. sectionHeader.Items.Clear(); }
/// <summary> /// insert item at the start of the list. ( before item 0. ) /// </summary> /// <param name="sectionHeader"></param> /// <param name="item"></param> public static void InsertItemBegin( this ISectionHeader sectionHeader, IScreenItem item) { if (sectionHeader.Items.Count == 0) { AddItem(sectionHeader, item); } else { InsertItemBefore(sectionHeader, 0, item); } }
public static void ReplaceModel( this ISectionHeader sectionHeader, ScreenItemModel itemModel, ScreenItemModel screenItemModel) { var ix = sectionHeader.ItemIndexOf(itemModel); if (ix >= 0) { sectionHeader.InsertItemBefore(ix, screenItemModel); sectionHeader.RemoveItem(itemModel); } }
public static ScreenItemInstance FindItem( this IScreenDefn Defn, IScreenLoc FindLoc, ScreenContent Content) { ScreenItemInstance found = null; ISectionHeader sectionHeader = Defn as ISectionHeader; var start = new OneScreenLoc(1, 1); found = sectionHeader.FindItem(start, FindLoc, Content); return(found); }
public static XElement ToXElement(this ISectionHeader Header, XName Name) { if (Header == null) { return(new XElement(Name, null)); } else { XElement xe = new XElement(Name, Header.Items.ToXElement("Items") ); return(xe); } }
public static CopyPasteItem ToCopyPasteItem( this XElement Elem, XNamespace Namespace) { CopyPasteItem copyPasteItem = null; if (Elem != null) { var copyPasteCode = Elem.Element(Namespace + "CopyPasteCode").StringOrDefault("none").TryParseCopyPasteCode().Value; ISectionHeader header = null; var item = Elem.Element(Namespace + "ScreenItem").ToScreenItem(Namespace); copyPasteItem = new CopyPasteItem(copyPasteCode, item, header); } return(copyPasteItem); }
public static ColumnReport Report(this ISectionHeader Defn, string Title = null) { var report = new ColumnReport(); // write the title line. if (Title.IsNullOrEmpty( ) == false) { report.WriteTextLine(Title); report.WriteGapLine(); } report.AddColDefn("ItemName", 15, WhichSide.Left); report.AddColDefn("Type", 7); report.AddColDefn("Row/Col", 7); report.AddColDefn("Lgth", 5); report.AddColDefn("Usage", 6); report.AddColDefn("Dspatr", 6); report.AddColDefn("Text", 50); report.WriteColumnHeading(true); foreach (var item in Defn.Items) { var valueList = new string[] { item.ItemName, item.ItemType.ToString( ), item.ScreenLoc.ToText( ), item.GetLength( ), item.GetUsage( ).ToString( ), item.GetDsplyAttr( ).ToDsplyAttrText( ), item.GetValue( ) }; report.WriteDetail(valueList); if (item is IScreenSection) { var sectReport = (item as ISectionHeader) .Report("Items of section " + item.ItemName); report.WriteGapLine(); report.WriteTextLines(sectReport, 5); report.WriteGapLine(); } } return(report); }
public static ScreenItemInstance FindItem( this ISectionHeader section, IScreenLoc Start, IScreenLoc FindLoc, ScreenContent Content) { ScreenItemInstance findItem = null; // find the screenitem located at the find location. foreach (var item in section.Items) { findItem = item.FindItem(Start, FindLoc, Content); if (findItem != null) { break; } } return(findItem); }
private bool StartDrag(MouseEventArgs e) { this.DragItemIndex = null; this.DragSectionHeader = null; bool handled = false; // locate the visual object within the scope of the ListBox where the // cursor is located. HitTestResult ht = VisualTreeHelper.HitTest(lbScreenItems, e.GetPosition(lbScreenItems)); if (ht != null) { // search up the visual tree to the ListBoxItem var lbItem = FindParent <ListBoxItem>(ht.VisualHit); if (lbItem != null) { // item to drag. var dragScreenItem = lbItem.Content as IScreenItem; if (dragScreenItem != null) { // the sectionHeader of the item to drag. var dragSectionHeader = dragScreenItem.SectionHeader; // find the SectionItemsControl that contains the ListBox which // contains this ListBoxItem. // var sic = FindParent<SectionItemsControl>(lbItem); // index of item to drag. // var ix = sic.SectionHeader.ItemIndexOf(dragScreenItem); var ix = dragSectionHeader.ItemIndexOf(dragScreenItem); this.DragItemIndex = ix; this.DragSectionHeader = dragSectionHeader; this.IsDragging = true; this.PopupWindow.IsOpen = true; this.PopupText.Text = "Dragging. " + dragScreenItem.ToString(); handled = true; Debug.WriteLine("start dragging"); } } } return(handled); }
/// <summary> /// determine if the ScreenDefn matches the screen content. /// </summary> /// <param name="Content"></param> /// <returns></returns> public static bool Match(this IScreenDefn Defn, ScreenContent Content) { bool isMatch = true; // BgnTemp // SpecialLogFile.AppendTextLines(this.ToColumnReport()); // EndTemp // extract all ContentText on the screen. Add to FieldDict. Content.AddAllContentText(); ISectionHeader sectionHeader = Defn as ISectionHeader; var start = new OneScreenLoc(1, 1); isMatch = sectionHeader.Match(start, Content, Defn.ScreenName); return(isMatch); }
/// <summary> /// Determines whether the specified <see cref="System.Object"/> is equal to this instance. /// </summary> /// <param name="obj">The <see cref="System.Object"/> to compare with this instance.</param> /// <returns><c>true</c> if the specified <see cref="System.Object"/> is equal to this instance; /// otherwise, <c>false</c>.</returns> public override bool Equals(object obj) { SectionHeader header = obj as SectionHeader; if (header != null) { return(Pair == header.Pair); } ISectionHeader iheader = obj as ISectionHeader; if (iheader != null) { return(Pair == iheader); } return(false); }
public static void WorkScreenItem( ActionCode action, ISectionHeader sectionHeader, ScreenItemModel itemModel) { bool cancelAction = false; while (true) { var window = new WorkScreenItemWindow(action); window.ScreenItemModel = itemModel; var rv = window.ShowDialog(); if ((rv == null) || (rv.Value == false)) { cancelAction = true; break; } if (window.ModelTypeChanged == true) { if (action != ActionCode.Add) { sectionHeader.ReplaceModel(itemModel, window.ScreenItemModel); sectionHeader.OnSectionHeaderChanged(); } itemModel = window.ScreenItemModel; continue; } else { // the selectedItem was passed by reference. On return that same reference // has been updated by the WorkScreenItemWindow. No need to apply to the // itemsSource. It is already updated. cancelAction = false; itemModel = window.ScreenItemModel; break; } } // entry accepted. Add to list of items. if ((cancelAction == false) && (action == ActionCode.Add)) { sectionHeader.AddItem(itemModel); } }
/// <summary> /// capture the data of the screen to a DataTable class. /// </summary> /// <param name="Defn"></param> /// <param name="Content"></param> /// <returns></returns> public static EnhancedDataTable Capture( this IScreenDefn Defn, ScreenContent Content, ScreenItemInstance ItemInstance = null) { ISectionHeader sectionHeader = Defn as ISectionHeader; var start = new OneScreenLoc(1, 1); var report = sectionHeader.CaptureToReport(start, Content); var table = report.ToDataTable(); // mark the selected datarow in the dataTable. int rownum = 0; if ((ItemInstance != null) && (ItemInstance.RepeatNum > 0)) { rownum = ItemInstance.RepeatNum - 1; } table.MarkSelectedRow(rownum); return(table); }
private void Add_Common(CopyPasteCode code, ISectionHeader header, IScreenItem screenItem) { if (screenItem != null) { var wasCode = screenItem.CopyPasteCode; EnsureRemoved(screenItem); // apply the code to the screenItem as a toggle. If the item CopyPasteCode // is the same as code being added, then remove the code. Do not add. if (wasCode.CompareEqual(code) != true) { // mark the screen item with the action. if (this.IsGlobalList == true) { screenItem.CopyPasteCode = code; } // add to this pending action list. var cpItem = new CopyPasteItem(code, screenItem, header); this.Add(cpItem); } } }
public static DataItemReport CaptureToReport( this ISectionHeader section, IScreenLoc Start, ScreenContent Content) { var report = new DataItemReport(); var row = new DataItemList(); // capture item data from each item of the section that is marked for capture. // ( by default, all ScreenField items are captured. ) foreach (var item in section.Items) { var rv = item.CaptureReport(Start, Content); var dataItem = rv.Item1; var itemReport = rv.Item2; if (dataItem != null) { report.Columns.Add(dataItem.ToColumnDefn()); row.Add(dataItem); } // this item is a section. The capture function returned a DataItemReport // contains the data of the report. Join that report with what has been // captured up to this point. if (itemReport != null) { var comboReport = DataItemReport.CombineHorizontally(report, itemReport); report = comboReport; } } if (row.Count > 0) { report.Rows.Add(row); } return(report); }
/// <summary> /// Constructor /// </summary> /// <param name="toFile">Name of the file to export to</param> /// <param name="headerText">Main Header text</param> /// <param name="subheadingText">Sub-heading text</param> /// <param name="footerText">footer text</param> /// <param name="grid">Grid View to export</param> /// <param name="outputFormat">Output format</param> public static void Export(String toFile , String headerText , String subheadingText , String footerText , UltraGrid grid , FileFormat outputFormat) { // Create the report itself Report report = new Report(); // ...then the sections for header, footer and body ISection mainSection = report.AddSection(); mainSection.PageMargins = new Infragistics.Documents.Reports.Report.Margins(50); ISectionHeader headerSection = mainSection.AddHeader(); headerSection.Height = 50; headerSection.Repeat = true; // Add a footer for page numbering ISectionFooter footerSection = mainSection.AddFooter(); // Create place-holder for header text Infragistics.Documents.Reports.Report.Text.IText headerTextSection = headerSection.AddText(0, 0); // ...and add the header in to this section, centralized headerTextSection.AddContent(headerText); headerTextSection.Alignment.Horizontal = Alignment.Center; headerTextSection.Alignment.Vertical = Alignment.Middle; // Set style for the header Infragistics.Documents.Reports.Report.Text.Style HeaderStyle = new Infragistics.Documents.Reports.Report.Text.Style(new Infragistics.Documents.Reports.Graphics.Font("Verdana", 10, Infragistics.Documents.Reports.Graphics.FontStyle.Underline), Infragistics.Documents.Reports.Graphics.Brushes.DarkBlue); headerTextSection.Style = HeaderStyle; // Add in a sub-heading if required if (subheadingText != null && subheadingText != "") { headerTextSection = headerSection.AddText(0, 20); Infragistics.Documents.Reports.Report.Text.Style subHeaderStyle = new Infragistics.Documents.Reports.Report.Text.Style(new Infragistics.Documents.Reports.Graphics.Font("Verdana", 8, Infragistics.Documents.Reports.Graphics.FontStyle.Underline), Infragistics.Documents.Reports.Graphics.Brushes.DarkBlue); headerTextSection.Style = subHeaderStyle; headerTextSection.AddContent(subheadingText); } // Add the body of the report which is the contents of the grid UltraGridDocumentExporter exporter = new UltraGridDocumentExporter(); exporter.Export(grid, mainSection); //------------------------- // Setup Footer content //------------------------- footerSection.Height = 50; // Do we have a footer to display? if (footerText != null && footerText != "") { // Create place-holder for footer text Infragistics.Documents.Reports.Report.Text.IText footerTextSection = footerSection.AddText(0, 0); // ...and add the footer text in to this section, left aligned footerTextSection.Alignment.Horizontal = Alignment.Left; footerTextSection.Alignment.Vertical = Alignment.Top; // Set style for the text Infragistics.Documents.Reports.Report.Text.Style footerStyle = new Infragistics.Documents.Reports.Report.Text.Style(new Infragistics.Documents.Reports.Graphics.Font("Verdana", 6, Infragistics.Documents.Reports.Graphics.FontStyle.Underline), Infragistics.Documents.Reports.Graphics.Brushes.DarkBlue); footerTextSection.Style = footerStyle; // ...and set the text itself footerTextSection.AddContent(footerText); } PageNumbering pn = mainSection.PageNumbering; // The Template property is the actual string that shows the page numbering. Use the [Page #] place- // holder for the current page and the [TotalPages] place-holder for the total amount of pages in // the entire document. pn.Template = "Page [Page #] of [TotalPages]"; // Setting SkipFirst to true does not place page numbering on the first page of the section. This // is useful if the first page is a Title page. pn.SkipFirst = false; // The page numbering will be aligned with the right side of the page. Valid values off the // Alignment enum include Left, Center, and Right. pn.Alignment.Horizontal = Alignment.Right; // The page numbering will be located at the bottom of the page. Valid values off the // Alignment enum include Top and Bottom. pn.Alignment.Vertical = Alignment.Bottom; // The page numbering is at the extreme bottom of the page, so we need to change the Y Offset // in order to bring it in line with the rest of the page footer text. pn.OffsetY = -18; // Delete the old report if it exists try { if (File.Exists(toFile)) { File.Delete(toFile); } } catch (Exception) { //Ignore any errors } // Generate the report try { report.Generate(); report.Publish(toFile, outputFormat); } catch (Exception ex) { MessageBox.Show("Failed to write the export file " + toFile + ", the error was " + ex.Message); } }
public CopyPasteItem(CopyPasteCode code, IScreenItem item, ISectionHeader header) { this.CopyPasteCode = code; this.ScreenItem = item; this.SectionHeader = header; }
/// <summary> /// Export the /// </summary> /// <param name="ToFile"></param> /// <param name="listSections"></param> /// <param name="outputFormat"></param> public static void Export(string toFile, UltraGrid grid, ExportSectionList listSections, FileFormat outputFormat) { // Create the report itself Report report = new Report(); // ...then the sections for header, footer and body ISection mainSection = report.AddSection(); mainSection.PageMargins = new Infragistics.Documents.Reports.Report.Margins(50); ISectionHeader headerSection = mainSection.AddHeader(); headerSection.Height = 50; headerSection.Repeat = true; ISectionFooter footerSection = mainSection.AddFooter(); footerSection.Height = 50; // Add the body of the report which is the contents of the grid UltraGridDocumentExporter exporter = new UltraGridDocumentExporter(); exporter.Export(grid, mainSection); // Setup the page numbering PageNumbering pn = mainSection.PageNumbering; // The Template property is the actual string that shows the page numbering. Use the [Page #] place- // holder for the current page and the [TotalPages] place-holder for the total amount of pages in // the entire document. pn.Template = "Page [Page #] of [TotalPages]"; // Setting SkipFirst to true does not place page numbering on the first page of the section. This // is useful if the first page is a Title page. pn.SkipFirst = false; // The page numbering will be aligned with the right side of the page. Valid values off the // Alignment enum include Left, Center, and Right. pn.Alignment.Horizontal = Alignment.Right; // The page numbering will be located at the bottom of the page. Valid values off the // Alignment enum include Top and Bottom. pn.Alignment.Vertical = Alignment.Bottom; // The page numbering is at the extreme bottom of the page, so we need to change the Y Offset // in order to bring it in line with the rest of the page footer text. pn.OffsetY = -18; // Delete the old report if it exists try { if (File.Exists(toFile)) { File.Delete(toFile); } } catch (Exception) { //Ignore any errors } // Generate the report try { report.Generate(); report.Publish(toFile, outputFormat); } catch (Exception ex) { MessageBox.Show("Failed to write the export file " + toFile + ", the error was " + ex.Message); } }
/// <summary> /// paste the items from this CopyPasteList onto the top of the ToList. /// </summary> /// <param name="ToList"></param> /// <returns></returns> public IScreenItem PasteTop(ISectionHeader ToSectionHeader) { var item = Paste_Actual(RelativePosition.Begin, ToSectionHeader); return(item); }
public void AddCopy(ISectionHeader header, IScreenItem screenItem) { Add_Common(CopyPasteCode.Copy, header, screenItem); }
private IScreenItem Paste_Actual( RelativePosition Rltv, ISectionHeader ToSectionHeader, int ToIndex = -1) { int toIndex = ToIndex; IScreenItem lastPasteItem = null; if (ToIndex >= 0) { lastPasteItem = ToSectionHeader.GetItemAt(ToIndex); } var rltv = Rltv; foreach (var item in this) { IScreenItem pasteItem = null; // remove from the from list. if (item.CopyPasteCode == CopyPasteCode.Cut) { pasteItem = item.Cut(); } // dup the item to copy. if (item.CopyPasteCode == CopyPasteCode.Copy) { pasteItem = ScreenItemModel.Factory(item.ScreenItem); pasteItem.AssignItemGuid(); } // index of the insert relative to item. toIndex = -1; if (lastPasteItem != null) { toIndex = ToSectionHeader.Items.IndexOf(lastPasteItem); } // insert into ToList. if (rltv == RelativePosition.After) { ToSectionHeader.InsertItemAfter(toIndex, pasteItem); } else if (rltv == RelativePosition.Begin) { ToSectionHeader.InsertItemBegin(pasteItem); } else if (rltv == RelativePosition.End) { ToSectionHeader.AddItem(pasteItem); } else if (rltv == RelativePosition.Before) { ToSectionHeader.InsertItemBefore(toIndex, pasteItem); } else { throw new Exception("invalid relative postion"); } // clear the copy/paste marking on the screenItem. if (this.IsGlobalList == true) { item.ScreenItem.CopyPasteCode = null; } // the last pasted item. lastPasteItem = pasteItem; // subsequent items are placed after the prior pasted item rltv = RelativePosition.After; } // clear the list of pending actions. this.Clear(); return(lastPasteItem); }
/// <summary> /// paste the items from this CopyPasteList onto the end of the ToList. /// </summary> /// <param name="ToList"></param> /// <returns></returns> public IScreenItem PasteBottom(ISectionHeader ToSectionHeader) { var item = Paste_Actual(RelativePosition.End, ToSectionHeader); return(item); }
public IScreenItem PasteBefore(ISectionHeader ToSectionHeader, int ToIndex) { var item = Paste_Actual(RelativePosition.Before, ToSectionHeader, ToIndex); return(item); }