Пример #1
0
        public override void Trigger(EditableView.ClickPosition.Sources source, EditableView pnlView, Transaction transaction)
        {
            if (!Globals.Root.CurrentConfig.ReadBoolean(Config.Multiple_Documents) && !Editor.CheckDiscardCurrent(false))
            {
                return;
            }
            string file = FileDialog.ShowOpen(FileDialog.Context.OtherUserDoc, Filter);

            if (string.IsNullOrEmpty(file))
            {
                return;
            }
            using (var operation = new Globals.Operation(this.DescriptionWithoutAccelerator()))
                try
                {
                    ParseFile(file);
                    Document document = GenerateDocument();
                    if (operation.ConfirmSuccess())
                    {
                        Globals.Root.SelectDocument(document);
                    }
                }
                catch (Exception ex) when(!Globals.Root.IsDebug)
                {
                    MessageBox.Show(ex.Message);
                }
            finally
            { m_Elements = null; }
        }
Пример #2
0
        public static void SaveAs(bool worksheet, EditableView pnlView)
        {
            var strFilename = FileDialog.ShowSave(FileDialog.Context.Document, "SAW 7|*" + Document.StandardExtension + "|SAW 6|*.sss", Path.GetFileName(CurrentDocument.FilenameWithExtension(Document.StandardExtension)));

            if (string.IsNullOrEmpty(strFilename))
            {
                return;
            }
            CurrentDocument.SAWHeader.SetWindowBounds(pnlView.GetDocumentScreenCoords());
            if (strFilename.ToLower().EndsWith(".sss"))
            {
                using (var op = new Globals.Operation("[Save_SAW6]"))
                {
                    var oldDoc = new SAW6Doc(CurrentDocument);

                    using (var writer = new ArchiveWriter(strFilename, oldDoc.m_Header.Version))
                    {
                        oldDoc.Write(writer);
                    }
                    op.ConfirmSuccess(true);
                }
            }
            else
            {
                if (!CurrentDocument.IsPaletteWithin)
                {
                    CurrentDocument.Filename = strFilename;
                }
                CurrentDocument.DisplayName = "";                 // otherwise the original worksheet name remains in the title bar, rather than the filename
                SaveFile(pnlView);
            }
        }
Пример #3
0
        public override void Trigger(EditableView.ClickPosition.Sources source, EditableView pnlView, Transaction transaction)
        {
            if (!g_WarningDone)
            {
                MessageBox.Show(Strings.Item("SAW_IRM_SaveNote"));
            }
            g_WarningDone = true;

            string file = FileDialog.ShowSave(FileDialog.Context.OtherUserDoc, ImportIRM.Filter);

            if (string.IsNullOrEmpty(file))
            {
                return;
            }

            using (var operation = new Globals.Operation(this.DescriptionWithoutAccelerator()))
            {
                Document          doc         = Globals.Root.CurrentDocument;
                StringBuilder     output      = new StringBuilder();
                int               mainHeight  = 0;
                List <Scriptable> pageButtons =
                    (from shape in doc.Page(0).Shapes
                     where shape is Scriptable s && s.SelectScript.CommandList.Any(c => c is CmdGotoPage)
                     orderby PageButtonDestination(shape as Scriptable)
                     select shape as Scriptable).ToList();
                for (int pageIndex = 0; pageIndex < doc.Pages.Count(); pageIndex++)
                {
                    Page page = doc.Page(pageIndex);
                    // buttons used to change pages:
                    if (pageIndex == 0)
                    {
                        m_YOffset  = (int)page.Size.Height;
                        mainHeight = WritePageButtons(output, pageButtons, page);
                    }
                    m_YOffset = (int)page.Size.Height - mainHeight;

                    string name = pageButtons.Count() > pageIndex ? pageButtons[pageIndex].Element.LabelText : "page" + (pageIndex + 1);
                    output.Append('[').Append(name).AppendLine("]");
                    foreach (Shape s in page.Shapes)
                    {
                        if (s.ShapeCode == Shape.Shapes.Scriptable)
                        {
                            Scriptable scriptable = (Scriptable)s;
                            if (scriptable.SelectScript.CommandList.Any(c => c is CmdGotoPage))
                            {
                                continue;                                 // these are the copies of the page buttons
                            }
                            WriteElement(output, "POS", s.Bounds.Location);
                            WriteElement(output, "SIZE", s.Bounds.Size.ToPointF());
                            WriteElement(output, "TEXT", scriptable.Element.LabelText);
                            string remote  = ExtractCommentValue(scriptable.SelectScript, "REMOTE");
                            string command = ExtractCommentValue(scriptable.SelectScript, "COMMAND");
                            WriteElement(output, "REMOTE", remote ?? "?");
                            WriteElement(output, "COMMAND", command ?? "?", true);
                        }
                        else if (s.ShapeCode == Shape.Shapes.TextLine)
                        {
                            WriteElement(output, "LBL", s.Bounds.Location);
                            WriteElement(output, "SIZE", s.Bounds.Size.ToPointF());
                            WriteElement(output, "TEXT", s.LabelText, true);
                        }
                        // all other types ignored.  In particular separator line which was sort of generated automatically from button bounds
                    }
                    output.AppendLine("[END]");
                    output.AppendLine();
                }
                if (operation.ConfirmSuccess())
                {
                    File.WriteAllText(file, output.ToString());
                }
            }
        }