Ejemplo n.º 1
0
        /// <summary>
        /// Add a definition file direcotory.
        /// </summary>
        public void AddDefinitionFileDirectory()
        {
            DvtkApplicationLayer.Session theSession = GetSessionTreeViewManager().GetSession();
            Dvtk.Sessions.DefinitionFileDirectoryList theDefinitionFileDirectoryList = theSession.Implementation.DefinitionManagement.DefinitionFileDirectoryList;

            FolderBrowserDialog theFolderBrowserDialog = new FolderBrowserDialog();

            theFolderBrowserDialog.Description = "Select the directory where definition files are located.";

            if (theFolderBrowserDialog.ShowDialog() == DialogResult.OK)
            {
                bool   isExistingDirectory = false;
                string theNewDirectory     = GetDirectoryWithTrailingSlashesRemoved(theFolderBrowserDialog.SelectedPath);

                // Find out if this new directory already exists.
                foreach (string theExistingDirectory in theDefinitionFileDirectoryList)
                {
                    if (theNewDirectory == GetDirectoryWithTrailingSlashesRemoved(theExistingDirectory))
                    {
                        isExistingDirectory = true;
                        break;
                    }
                }

                theNewDirectory = theNewDirectory + "\\";

                // Only add this new directory if it does not already exist.
                if (!isExistingDirectory)
                {
                    DirectoryInfo theDirectoryInfo = new DirectoryInfo(theNewDirectory);

                    // If the new directory is not valid, show an error message.
                    if (!theDirectoryInfo.Exists)
                    {
                        MessageBox.Show("The directory \"" + theNewDirectory + "\" is not a valid directory.",
                                        "Directory not added",
                                        MessageBoxButtons.OK,
                                        MessageBoxIcon.Information);
                    }
                    else
                    {
                        theDefinitionFileDirectoryList.Add(theNewDirectory);

                        // Notify the rest of the world.
                        // This will implicitly also update this specify SOP classes tab.

                        SessionChange theSessionChange = new SessionChange(theSession, SessionChange.SessionChangeSubTypEnum.SOP_CLASSES_OTHER);
                        Notify(theSessionChange);
                    }
                }
                else
                {
                    MessageBox.Show("The directory \"" + theNewDirectory + "\" is already present in\nthe list of definition file directories.",
                                    "Directory not added",
                                    MessageBoxButtons.OK,
                                    MessageBoxIcon.Information);
                }
            }
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Add a definition file direcotory.
        /// </summary>
        private void AddDefinitionFileDirectory()
        {
            Dvtk.Sessions.DefinitionFileDirectoryList theDefinitionFileDirectoryList = theSession.DefinitionManagement.DefinitionFileDirectoryList;

            FolderBrowserDialog theFolderBrowserDialog = new FolderBrowserDialog();

            theFolderBrowserDialog.Description = "Select the directory where definition files are located.";

            if (theFolderBrowserDialog.ShowDialog() == DialogResult.OK)
            {
                bool   isExistingDirectory = false;
                string theNewDirectory     = GetDirectoryWithTrailingSlashesRemoved(theFolderBrowserDialog.SelectedPath);

                // Find out if this new directory already exists.
                foreach (string theExistingDirectory in theDefinitionFileDirectoryList)
                {
                    if (theNewDirectory == GetDirectoryWithTrailingSlashesRemoved(theExistingDirectory))
                    {
                        isExistingDirectory = true;
                        break;
                    }
                }

                theNewDirectory = theNewDirectory + "\\";

                // Only add this new directory if it does not already exist.
                if (!isExistingDirectory)
                {
                    DirectoryInfo theDirectoryInfo = new DirectoryInfo(theNewDirectory);

                    // If the new directory is not valid, show an error message.
                    if (!theDirectoryInfo.Exists)
                    {
                        MessageBox.Show("The directory \"" + theNewDirectory + "\" is not a valid directory.",
                                        "Directory not added",
                                        MessageBoxButtons.OK,
                                        MessageBoxIcon.Information);
                    }
                    else
                    {
                        theDefinitionFileDirectoryList.Add(theNewDirectory);
                        UpdateDataGrid((Dvtk.Sessions.ScriptSession)theSession);
                    }
                }
                else
                {
                    MessageBox.Show("The directory \"" + theNewDirectory + "\" is already present in\nthe list of definition file directories.",
                                    "Directory not added",
                                    MessageBoxButtons.OK,
                                    MessageBoxIcon.Information);
                }
            }
        }