コード例 #1
0
 public InterpretedPatternExporter(IExportBuilder ieb)
 {
     builder       = ieb;
     positionStack = new Stack <long>();
 }
コード例 #2
0
        void OnDialogResponse(object o, Gtk.ResponseArgs args)
        {
            lock (LockObj) {
                if (args.ResponseId == ResponseType.Ok && dataBook != null && dataBook.NPages > 0)
                {
                    DataView dv = ((DataViewDisplay)dataBook.CurrentPageWidget).View;

                    IExportBuilder builder = null;
                    TreeIter       iter;
                    ExportAsCombo.GetActiveIter(out iter);
                    ExportPlugin plugin = (ExportPlugin)ExportAsCombo.Model.GetValue(iter, 1);


                    Util.Range range;

                    try {
                        range = GetCurrentRange(dv);
                    }
                    catch (FormatException ex) {
                        ErrorAlert ea = new ErrorAlert(Catalog.GetString("Error in custom range"), ex.Message, mainWindow);
                        ea.Run();
                        ea.Destroy();
                        return;
                    }

                    Util.Range bufferRange;
                    if (dv.Buffer.Size == 0)
                    {
                        bufferRange = new Util.Range();
                    }
                    else
                    {
                        bufferRange = new Util.Range(0, dv.Buffer.Size - 1);
                    }

                    if (!bufferRange.Contains(range.Start) || !bufferRange.Contains(range.End))
                    {
                        ErrorAlert ea = new ErrorAlert(Catalog.GetString("Error in range"), Catalog.GetString("Range is out of file's limits"), mainWindow);
                        ea.Run();
                        ea.Destroy();
                        return;
                    }

                    Stream stream = null;
                    try {
                        stream  = new FileStream(ExportFileEntry.Text, FileMode.Create, FileAccess.Write);
                        builder = plugin.CreateBuilder(stream);

                        InterpretedPatternExporter exporter = new InterpretedPatternExporter(builder);
                        exporter.Pattern = ExportPatternComboEntry.Entry.Text;

                        cancelClicked = false;
                        BeginExport(exporter, dv.Buffer, range.Start, range.End);
                    }
                    catch (Exception ex) {
                        if (stream != null)
                        {
                            stream.Close();
                        }

                        ErrorAlert ea = new ErrorAlert(Catalog.GetString("Error saving to file"), ex.Message, mainWindow);
                        ea.Run();
                        ea.Destroy();
                        return;
                    }
                }
                else if (args.ResponseId == ResponseType.Close)
                {
                    this.Hide();
                }
            }
        }
コード例 #3
0
ファイル: ExportDataProvider.cs プロジェクト: Jos1k/Roads
 /// <summary>
 /// Initializes a new instance of the <see cref="ExportDataProvider"/> class.
 /// </summary>
 /// <param name="exportStringBuilder">The export string builder.</param>
 public ExportDataProvider(IExportBuilder exportStringBuilder)
 {
     _exportStringBuilder = exportStringBuilder;
 }