예제 #1
0
        public void OpenDocument(String fullName, Workplace owner)
        {
            // First: verify if the document isn't already open
            IDockContent[] openDocuments = dockPanel.DocumentsToArray();

            foreach (SinapseDocumentView openDocument in openDocuments)
            {
                if (openDocument.Document != null &&
                    openDocument.Document.File.FullName == fullName)
                {
                    // The document was already open
                    openDocument.DockHandler.Show(); // Activate it
                    return;
                }
            }

            // The document wasn't open, lets open it:
            ISinapseDocument document = DocumentManager.Open(fullName);

            document.Owner = owner; // If we have an owner Workplace, set it

            // Now lets determine the adequate viewer for this document type
            Type viewerType = SinapseDocumentView.GetViewer(Utils.GetExtension(fullName, true));

            // Activate the viewer,
            SinapseDocumentView viewer = Activator.CreateInstance(viewerType, this, document) as SinapseDocumentView;

            // And then lets show the new viewer on the main window.
            viewer.DockHandler.Show(dockPanel, DockState.Document);

            mruDocuments.Insert(fullName);
        }
예제 #2
0
        public static ISinapseDocument Create(string name, string fullName, Type type)
        {
            // Creates a new instance, then save it to the disk.
            ISinapseDocument doc = Activator.CreateInstance(type, new object[] { name, new FileInfo(fullName) }) as ISinapseDocument;

            doc.Save(fullName);
            return(doc);
        }
예제 #3
0
        public void OpenDocument(ISinapseDocument document)
        {
            // Now lets determine the adequate viewer for this document type
            Type viewerType = SinapseDocumentView.GetViewer(document);

            // Activate the viewer
            SinapseDocumentView viewer = Activator.CreateInstance(viewerType, this, document) as SinapseDocumentView;

            // And then show the viewer on the main window.
            viewer.DockHandler.Show(dockPanel, DockState.Document);
        }
예제 #4
0
 /// <summary>
 ///   Saves the SinapseDocument referenced by this SinapseDocumentInfo to the disk.
 ///   If type is null, only creates an empty file.
 /// </summary>
 public void Create()
 {
     if (type == null)
     {
         File.Create(FullName);
     }
     else
     {
         // Creates a new instance, then save it to the disk.
         ISinapseDocument doc = Activator.CreateInstance(type, new object[] { Name, new FileInfo(FullName) }) as ISinapseDocument;
         doc.Save(FullName);
     }
 }
예제 #5
0
        public SinapseDocumentView(Workbench workbench, ISinapseDocument document)
        {
            this.workbench = workbench;
            this.document  = document;

            if (document != null)
            {
                this.document.ContentChanged += new EventHandler(document_DocumentChanged);
                this.document.FileSaved      += new EventHandler(document_FileSaved);

                saveFileDialog            = new SaveFileDialog();
                saveFileDialog.DefaultExt = DocumentManager.GetExtension(document.GetType());
            }
        }
예제 #6
0
        public static ISinapseDocument Open(string fullName)
        {
            ISinapseDocument document = null;

            // First we check if file exists,
            if (System.IO.File.Exists(fullName))
            {
                // Determine the type of the document being open
                Type type = DocumentManager.GetType(Utils.GetExtension(fullName, true));

                // Create the method info for the static method SerializableObject<T>.Open
                MethodInfo methodOpen = type.GetMethod("Open",
                                                       BindingFlags.Static | BindingFlags.Public);

                // Call the Open method passing the FullPath as its first parameter
                document = (ISinapseDocument)methodOpen.Invoke(null, new object[] { fullName });
            }
            else
            {
                throw new FileNotFoundException("The file could not be found", fullName);
            }

            return(document);
        }
예제 #7
0
 public NetworkSystemView(Workbench workbench, ISinapseDocument document)
     : base(workbench, document)
 {
     InitializeComponent();
 }
예제 #8
0
 public TableSourceView(Workbench workbench, ISinapseDocument document)
     : base(workbench, document)
 {
     InitializeComponent();
 }
예제 #9
0
        public void OpenDocument(ISinapseDocument document)
        {
            // Now lets determine the adequate viewer for this document type
            Type viewerType = SinapseDocumentView.GetViewer(document);

            // Activate the viewer
            SinapseDocumentView viewer = Activator.CreateInstance(viewerType, this, document) as SinapseDocumentView;

            // And then show the viewer on the main window.
            viewer.DockHandler.Show(dockPanel, DockState.Document);
        }
예제 #10
0
 public static Type GetViewer(ISinapseDocument document)
 {
     return(GetViewer(DocumentManager.GetExtension(document.GetType())));
 }
예제 #11
0
 public TableSourceView(Workbench workbench, ISinapseDocument document)
     : base(workbench, document)
 {
     InitializeComponent();
 }
예제 #12
0
 public NetworkSystemView(Workbench workbench, ISinapseDocument document)
     : base(workbench, document)
 {
     InitializeComponent();
 }