Exemple #1
0
        void AddNewDocument_Click(object sender, EventArgs e)
        {
            if (projectView.SelectedNode == null)
            {
                return;
            }

            Folder folder = FindFolder(projectView.SelectedNode);

            if (folder == null)
            {
                return;
            }

            if (folder.ProjectDocument.ReadOnly && !folder.ProjectDocument.Checkout())
            {
                return;
            }

            Type docType = (sender as ToolStripMenuItem).Tag as Type;
            DocumentClassAttribute attr = DocumentClassAttribute.ForType(docType);

            string       fileName = Path.Combine(folder.AbsolutePath, "New " + attr.Name + attr.FileExtensions[0]);
            DocumentItem docItem  = m_manager.Project.AddDocument(folder, fileName, docType);
            Document     doc      = m_manager.CreateDocument(fileName, docType);

            m_mainWindow.ShowDocument(doc);
        }
Exemple #2
0
        public ProjectPanel(IManager manager)
        {
            InitializeComponent();

            m_manager                 = manager;
            m_mainWindow              = (MainWindow)manager.MainWindow;
            m_manager.PropertyChange += new PropertyChangeEventHandler(Manager_PropertyChange);

            manager.ProjectOpened += new ProjectOpenedEventHandler(Manager_ProjectOpened);

            m_systemImageList = new SystemImageList();
            m_systemImageList.SetImageList(projectView);

            m_italicFont = new Font(projectView.Font, FontStyle.Italic);
            m_boldFont   = new Font(projectView.Font, FontStyle.Bold);

            UpdateTree();

            foreach (Type docType in m_manager.GetPluginImplementations(typeof(Document)))
            {
                DocumentClassAttribute docAttr = DocumentClassAttribute.ForType(docType);
                if (docAttr != null)
                {
                    ToolStripMenuItem item = new ToolStripMenuItem();
                    item.Text   = "New " + docAttr.Name;
                    item.Click += new EventHandler(AddNewDocument_Click);
                    item.Tag    = docType;
                    addToolStripMenuItem.DropDownItems.Insert(0, item);
                }
            }
        }
Exemple #3
0
        public bool SaveDocument(Document doc, bool saveAs)
        {
            if (!doc.OnDisk || saveAs)
            {
                saveDocumentDialog.FileName = doc.FileName;

                DocumentClassAttribute attr = DocumentClassAttribute.ForType(doc.GetType());
                string extensions           = String.Join(";", Array.ConvertAll <string, string>(attr.FileExtensions, delegate(string ext) { return("*" + ext); }));
                saveDocumentDialog.Filter     = attr.Name + "(" + extensions + ")|" + extensions + "|All files (*.*)|*.*";
                saveDocumentDialog.DefaultExt = "*" + attr.FileExtensions[0];

                if (saveDocumentDialog.ShowDialog() == DialogResult.OK)
                {
                    // If first time it's been saved then rename it in the project
                    if (!saveAs)
                    {
                        DocumentItem documentItem = Manager.Project.FindDocument(doc.FileName);
                        if (documentItem != null)
                        {
                            Manager.Project.RenameDocument(documentItem, saveDocumentDialog.FileName);
                        }
                    }

                    doc.FileName = saveDocumentDialog.FileName;
                }
                else
                {
                    return(false);
                }
            }

            return(doc.SaveDocument());
        }
        private void listViewPlugins_SelectedIndexChanged(object sender, EventArgs e)
        {
            richTextBoxDetails.Clear();

            if (listViewPlugins.SelectedItems.Count == 1)
            {
                PluginDetails details = (PluginDetails)listViewPlugins.SelectedItems[0].Tag;
                IPlugin       plugin  = details.Plugin;
                if (plugin != null)
                {
                    richTextBoxDetails.AppendText(details.Assembly.GetName().Name + "\n");
                    richTextBoxDetails.AppendText("Documents:\n");
                    foreach (Type docType in details.GetImplementations(typeof(Document)))
                    {
                        DocumentClassAttribute attr = DocumentClassAttribute.ForType(docType);
                        richTextBoxDetails.AppendText("\t" + attr.Name + " (" + attr.ViewType.ToString() + ")\n");
                        richTextBoxDetails.AppendText("\tFile Extensions:\n");
                        foreach (string ext in attr.FileExtensions)
                        {
                            richTextBoxDetails.AppendText("\t\t" + ext + "\n");
                        }
                    }
                }
            }
        }
Exemple #5
0
        private Type ChooseViewType(Document doc)
        {
            DocumentClassAttribute attr = DocumentClassAttribute.ForType(doc.GetType());

            if (attr == null)
            {
                return(null);
            }
            else
            {
                return(attr.ViewType);
            }
        }
Exemple #6
0
        private void InitialisePlugins()
        {
            foreach (PluginDetails details in mPlugins)
            {
                if (details.Plugin != null)
                {
                    details.Plugin.Initialise(this);
                }
            }

            foreach (Type docType in GetPluginImplementations(typeof(Document)))
            {
                DocumentClassAttribute attr = DocumentClassAttribute.ForType(docType);
                if (attr != null)
                {
                    foreach (string docExt in attr.FileExtensions)
                    {
                        mFileTypes[docExt] = docType;
                    }
                }
            }
        }
Exemple #7
0
        public MainWindow(Manager manager)
        {
            mManager = manager;

            InitializeComponent();

            mDocumentViews = new List <DocumentView>();
            mToolWindows   = new List <ToolWindow>();

            mManager.MainWindow      = this;
            mManager.PropertyChange += new PropertyChangeEventHandler(Manager_PropertyChange);
            mManager.ProjectOpened  += new ProjectOpenedEventHandler(Manager_ProjectOpened);
            mManager.ProjectClosed  += new ProjectClosedEventHandler(Manager_ProjectClosed);

            mDockContentHistory      = new List <IDockContent>();
            mPluginsWindow           = new PluginsWindow(this);
            mOptionsWindow           = new OptionsWindow(this);
            mFindFileInProjectWindow = new FindFileInProjectWindow(this);
            mDocumentSwitchWindow    = new DocumentSwitchWindow(this);

            // Get recent projects list
            mRecentProjects = new List <string>();
            string data;

            data = (string)mManager.RegistryRoot.GetValue("RecentProjects");
            if (data != null)
            {
                foreach (string proj in data.Split(new char[] { ';' }))
                {
                    if (String.Compare(System.IO.Path.GetExtension(proj), ".xml", true) == 0 ||
                        String.Compare(System.IO.Path.GetExtension(proj), ".vcproj", true) == 0)
                    {
                        mRecentProjects.Add(proj);
                    }
                }
            }

            UpdateRecentProjects();

            // Set up open document dialog
            StringBuilder filter = new StringBuilder();

            foreach (Type docType in mManager.GetPluginImplementations(typeof(Document)))
            {
                DocumentClassAttribute attr = DocumentClassAttribute.ForType(docType);
                if (attr != null)
                {
                    string extensions = String.Join(";", Array.ConvertAll <string, string>(attr.FileExtensions, delegate(string ext) { return("*" + ext); }));
                    filter.Append(attr.Name + "(" + extensions + ")|" + extensions + "|");
                }
            }
            filter.Append("All files (*.*)|*.*");
            openDocumentDialog.Filter = filter.ToString();

            // Set up new project menu
            foreach (Type projType in mManager.GetPluginImplementations(typeof(Project)))
            {
                ProjectClassAttribute attr        = ProjectClassAttribute.ForType(projType);
                ConstructorInfo       constructor = projType.GetConstructor(new Type [] { typeof(IManager) });
                if (constructor != null)
                {
                    ToolStripMenuItem item = new ToolStripMenuItem(attr.Name, null, new EventHandler(NewProject_Click));
                    item.Tag = projType;
                    tsiFileNewProject.DropDownItems.Add(item);
                }
            }

            tsiFileNewProject.Enabled = tsiFileNewProject.DropDownItems.Count != 0;

            sourceControlToolStripMenuItem.Enabled = false;
        }