示例#1
0
        public void ExportPages(string dir, GraphCursor <IVisual, IVisualEdge> source)
        {
            var graph         = source.Graph;
            var digidocVisual = source.Cursor;
            var man           = new StreamContentIoManager();

            if (HasPages(graph, digidocVisual))
            {
                int i = 0;
                var s = source.Cursor.Data == null ? CommonSchema.NullString : source.Cursor.Data.ToString();

                foreach (var pageContent in PageStreams(graph, digidocVisual))
                {
                    var info     = man.GetContentInfo(pageContent);
                    var ext      = info != null ? "." + info.Extension : "";
                    var pageName = i.ToString().PadLeft(5, '0');
                    if (pageContent.Description != null)
                    {
                        pageName = pageContent.Description.ToString().PadLeft(5, '0');
                    }

                    var name = dir + Path.DirectorySeparatorChar + s + " " + pageName + ext;

                    man.WriteSink(pageContent, new Uri(name));
                    pageContent.Data.Dispose();
                    pageContent.Data = null;
                }
            }
        }
示例#2
0
        /// <summary>
        /// gets a content from ContentOut-Func
        /// and writes it into a file
        /// </summary>
        public void Save()
        {
            if (ContentOut == null)
            {
                return;
            }

            try {
                DefaultDialogValues(SaveFileDialog, WriteFilter);
                var content = ContentOut();
                if (content != null)
                {
                    var info = StreamContentIoManager.GetContentInfo(content);
                    if (info != null)
                    {
                        string ext = null;
                        SaveFileDialog.Filter     = StreamContentIoManager.GetFilter(info, out ext) + "All Files|*.*";
                        SaveFileDialog.DefaultExt = ext;
                    }
                    else
                    {
                        SaveFileDialog.Filter = "All Files|*.*";
                    }
                    var fileName = "";
                    if (content.Source != null)
                    {
                        fileName = content.Source.ToString();
                    }
                    else if (content.Description != null)
                    {
                        fileName = content.Description.ToString();
                    }

                    SaveFileDialog.SetFileName(fileName);
                    if (FileDialogShow(SaveFileDialog, false) == DialogResult.Ok)
                    {
                        StreamContentIoManager.ConfigureSinkIo = s => ConfigureSink(s);
                        StreamContentIoManager.WriteSink(content, IoUtils.UriFromFileName(SaveFileDialog.FileName));
                        SaveFileDialog.ResetFileName();
                    }
                }
            } catch (Exception ex) {
                Registry.Pooled <IExceptionHandler>().Catch(ex, MessageType.OK);
            }
        }