예제 #1
0
        //Button to set the path to the template file
        private void btnSetTemplatePath_Click(object sender, EventArgs e)
        {
            //Create the dialog
            OpenFileDialog openFileDialog1 = new OpenFileDialog();

            //Set the initial directory
            openFileDialog1.InitialDirectory = @"C:\";

            //Set the dialog title
            openFileDialog1.Title = "Browse for pCast File";

            //Perform checks
            openFileDialog1.CheckFileExists = true;
            openFileDialog1.CheckPathExists = true;

            //Set default extension
            openFileDialog1.DefaultExt = "txt";

            //Set the file type filter
            openFileDialog1.Filter = "pCast Files (*.txt)|*.txt";  //"Text files (*.txt)|*.txt|All files (*.*)|*.*"

            openFileDialog1.FilterIndex = 2;

            //Open to last directory
            openFileDialog1.RestoreDirectory = true;

            //Include readOnly files
            openFileDialog1.ReadOnlyChecked = true;
            openFileDialog1.ShowReadOnly    = true;

            //If the user clicks ok show the path in the textbox
            if (openFileDialog1.ShowDialog() == DialogResult.OK)
            {
                //Set the text box to the returned path
                tbxTemplateFileLocation.Text = openFileDialog1.FileName;

                //Write the new path to the settings file
                cmdSettingsReadWrite cls = new cmdSettingsReadWrite();
                cls.UpdateSetting("<PCAST_TEMPLATE_FILE_LOCATION>", openFileDialog1.FileName);

                //Call the method to reload the file path from settings and put it into the box
                tbxTemplateFileLocation.Text = pCastFilePathFromSettings();

                //reload the template list
                fillTemplateGrid(pathToTemplate);
            } //if
        }     //btnOpenFile_Click
예제 #2
0
        private void btnOpenFile_Click(object sender, EventArgs e)
        {
            //Create the dialog
            OpenFileDialog openFileDialog1 = new OpenFileDialog();

            //Set the initial directory
            openFileDialog1.InitialDirectory = @"C:\";

            //Set the dialog title
            openFileDialog1.Title = "Browse for DNote CSV File";

            //Perform checks
            openFileDialog1.CheckFileExists = true;
            openFileDialog1.CheckPathExists = true;

            //Set default extension
            openFileDialog1.DefaultExt = "rvt";

            //Set the file type filter
            openFileDialog1.Filter = "Revit Files (*.rvt)|*.rvt";  //"Text files (*.txt)|*.txt|All files (*.*)|*.*"

            openFileDialog1.FilterIndex = 2;

            //Open to last directory
            openFileDialog1.RestoreDirectory = true;

            //Include readOnly files
            openFileDialog1.ReadOnlyChecked = true;
            openFileDialog1.ShowReadOnly    = true;

            //If the user clicks ok show the path in the textbox
            if (openFileDialog1.ShowDialog() == DialogResult.OK)
            {
                Autodesk.Revit.UI.TaskDialog.Show("Test", "OK");

                //Set the text box to the returned path
                tbxFilePath.Text = openFileDialog1.FileName;

                //Write the new path to the settings file
                cmdSettingsReadWrite cls = new cmdSettingsReadWrite();
                cls.UpdateSetting("<IMPORT_VIEW_FILE_PATH>", openFileDialog1.FileName);

                //Call the method to reload the file path from settings and put it into the grid
                GetFilePathFromSettings();
            } //if
        }     //btnOpenFile_Click
예제 #3
0
        }     //btnOpenFile_Click

        private void btnNewCSV_Click(object sender, EventArgs e)
        {
            SaveFileDialog saveFileDialog1 = new SaveFileDialog();

            saveFileDialog1.InitialDirectory = @"C:\";
            saveFileDialog1.Title            = "Save DNote File";
            saveFileDialog1.CheckFileExists  = false;
            saveFileDialog1.CheckPathExists  = true;
            saveFileDialog1.DefaultExt       = "csv";
            saveFileDialog1.Filter           = "DNote files (*.csv)|*.csv";
            saveFileDialog1.FileName         = "DNotes";
            saveFileDialog1.FilterIndex      = 2;
            saveFileDialog1.RestoreDirectory = true;
            saveFileDialog1.OverwritePrompt  = true;
            saveFileDialog1.CreatePrompt     = false;

            if (saveFileDialog1.ShowDialog() == DialogResult.OK)

            {
                //Create the DNotes datatable
                DataTable dt = CreateCSVFile.CreateDNoteDataTable();

                //Get the filepath from the save dialog
                String filePath = saveFileDialog1.FileName;

                //Send the datatable to the CSV writer, this is to the writer not the reader
                dt.ToCSV(filePath);

                //Write the new path to the settings file
                cmdSettingsReadWrite cls = new cmdSettingsReadWrite();
                cls.UpdateSetting("<DNOTE_FILE_PATH>", filePath);

                //Call the method to reload the updated file path from settings
                GetDNoteFilePathFromSettings();
            }
        }
예제 #4
0
        //get and save the source project location


        public static string SourceProject(bool resetPath, string pathOrName)
        {
            cmdSettingsReadWrite cls = new cmdSettingsReadWrite();
            string path;
            string name;

            if (resetPath == true)
            {
                //Clear the setting
                cls.UpdateSetting("<GETTER_SOURCE_PROJECT>", "");
            }

            //read the settings file
            string _sourceProjectPath = cls.GetSetting("<GETTER_SOURCE_PROJECT>");

            if (_sourceProjectPath != "")
            {
                name = Path.GetFileName(_sourceProjectPath);

                if (pathOrName == "Name")
                {
                    return(name);
                }
                if (pathOrName == "Path")
                {
                    return(_sourceProjectPath);
                }
                else
                {
                    return(null);
                }
            }
            else
            {
                try
                {
                    //get the file path and name
                    path = OAT_Utilities.oat_OpenFileDialog("rvt");
                    name = Path.GetFileName(path);

                    //Write the new path to the settings file
                    cls.UpdateSetting("<GETTER_SOURCE_PROJECT>", path);

                    if (pathOrName == "Name")
                    {
                        return(name);
                    }
                    if (pathOrName == "Path")
                    {
                        return(path);
                    }
                    else
                    {
                        return(null);
                    }
                }
                catch (Exception)
                {
                    throw;
                }
            }
        }