public ExportDialog(LogFile.ExportConfigurationInfo config)
 {
     Owner = Application.Current.MainWindow;
     InitializeComponent();
     this.checkIndex.IsChecked           = config.Index;
     this.checkContent.IsChecked         = config.Content;
     this.checkGroup1.IsChecked          = config.Group1;
     this.checkGroup2.IsChecked          = config.Group2;
     this.checkGroup3.IsChecked          = config.Group3;
     this.checkGroup4.IsChecked          = config.Group4;
     this.checkRemoveEmptyRows.IsChecked = config.RemoveEmpty;
     this.textSeparator.Text             = config.Separator;
 }
Exemple #2
0
        public override bool SaveFile(string fileName, IFile <LogFileItem> file)
        {
            try
            {
                SetStatus("SaveFile:enter: " + fileName);
                file.IsNew = false;
                LogFile logFile = (LogFile)file;

                if (File.Exists(fileName))
                {
                    File.Delete(fileName);
                }

                using (StreamWriter writer = File.CreateText(fileName))
                {
                    LogFile.ExportConfigurationInfo config = logFile.ExportConfiguration;

                    foreach (LogFileItem item in logFile.ContentItems)
                    {
                        StringBuilder sb = new StringBuilder();

                        sb = FormatExportItem(config.Index, config.Separator, config.RemoveEmpty, item.Index.ToString(), sb);
                        sb = FormatExportItem(config.Content, config.Separator, config.RemoveEmpty, item.Content, sb);
                        sb = FormatExportItem(config.Group1, config.Separator, config.RemoveEmpty, item.Group1, sb);
                        sb = FormatExportItem(config.Group2, config.Separator, config.RemoveEmpty, item.Group2, sb);
                        sb = FormatExportItem(config.Group3, config.Separator, config.RemoveEmpty, item.Group3, sb);
                        sb = FormatExportItem(config.Group4, config.Separator, config.RemoveEmpty, item.Group4, sb);

                        writer.WriteLine(sb.ToString());
                    }

                    writer.Close();
                }

                SetStatus("SaveFile:exit: " + fileName);
                return(true);
            }
            catch (Exception e)
            {
                SetStatus("Fatal:SaveFile:exception: " + e.ToString());
                return(false);
            }
        }
Exemple #3
0
        public void CopyExecuted(object sender)
        {
            try
            {
                // for configuration of fields to export from file view
                LogFile.ExportConfigurationInfo config = new LogFile.ExportConfigurationInfo();
                if (sender is LogFile.ExportConfigurationInfo)
                {
                    config = (sender as LogFile.ExportConfigurationInfo);
                }

                HtmlFragment htmlFragment = new HtmlFragment();
                foreach (IFileItem lbi in SelectedContent)
                {
                    // get all cells
                    if (typeof(T) == typeof(LogFileItem))
                    {
                        LogFileItem   item = (LogFileItem)lbi;
                        StringBuilder sb   = new StringBuilder();

                        sb = FormatExportItem(config.Index, config.Separator, config.RemoveEmpty, item.Index.ToString(), sb);
                        sb = FormatExportItem(config.Content, config.Separator, config.RemoveEmpty, item.Content, sb);
                        sb = FormatExportItem(config.Group1, config.Separator, config.RemoveEmpty, item.Group1, sb);
                        sb = FormatExportItem(config.Group2, config.Separator, config.RemoveEmpty, item.Group2, sb);
                        sb = FormatExportItem(config.Group3, config.Separator, config.RemoveEmpty, item.Group3, sb);
                        sb = FormatExportItem(config.Group4, config.Separator, config.RemoveEmpty, item.Group4, sb);

                        htmlFragment.AddClipToList(sb.ToString(), lbi.Background, lbi.Foreground);
                    }
                    else
                    {
                        htmlFragment.AddClipToList(lbi.Content, lbi.Background, lbi.Foreground);
                    }
                }

                htmlFragment.CopyListToClipboard();
            }
            catch (Exception ex)
            {
                SetStatus("Exception:CopyCmdExecute:" + ex.ToString());
            }
        }