コード例 #1
0
        private static void ExportToCsv(IEnumerable <PrintTask> printTasks)
        {
            // right click success or fail
            // user settings that are different
            var records = new List <RowData>();

            // do the export
            foreach (var printTask in printTasks)
            {
                string groupNames = PrintHistoryListItem.GetItemNamesFromMcx(printTask.PrintName);

                records.Add(new RowData()
                {
                    Printer              = printTask.PrinterName,
                    Name                 = printTask.PrintName,
                    Start                = printTask.PrintStart,
                    End                  = printTask.PrintEnd,
                    Compleated           = printTask.PrintComplete,
                    Canceled             = printTask.PrintCanceled,
                    PrintQuality         = printTask.PrintQuality,
                    ItemsPrinted         = groupNames,
                    Minutes              = printTask.PrintTimeMinutes,
                    RecoveryCount        = printTask.RecoveryCount,
                    QualitySettingsName  = printTask.QualitySettingsName,
                    MaterialSettingsName = printTask.MaterialSettingsName,
                    Notes                = printTask.Note,
                });
            }

            AggContext.FileDialogs.SaveFileDialog(
                new SaveFileDialogParams("MatterControl Printer Export|*.printer", title: "Export Printer Settings")
            {
                FileName = "Pinter Histor.csv",
                Filter   = "CSV Files|*.csv"
            },
                (saveParams) =>
            {
                try
                {
                    if (!string.IsNullOrWhiteSpace(saveParams.FileName))
                    {
                        using (var writer = new StreamWriter(saveParams.FileName))
                        {
                            using (var csv = new CsvWriter(writer, CultureInfo.InvariantCulture))
                            {
                                csv.WriteRecords(records);
                            }
                        }
                    }
                }
                catch (Exception e2)
                {
                    UiThread.RunOnIdle(() =>
                    {
                        StyledMessageBox.ShowMessageBox(e2.Message, "Couldn't save file".Localize());
                    });
                }
            });
        }
コード例 #2
0
        public ListViewItemBase AddItem(ListViewItem item)
        {
            var historyRowItem = item.Model as PrintHistoryItem;
            var detailsView    = new PrintHistoryListItem(item, this.ThumbWidth, this.ThumbHeight, historyRowItem?.PrintTask, theme);

            this.AddChild(detailsView);

            return(detailsView);
        }