Exemple #1
0
 protected override bool RunDialog(IntPtr hwndOwner)
 {
     using (CommandForm frm = new CommandForm())
     {
         frm.Command   = this.Command;
         frm.Arguments = this.Arguments;
         bool flag = frm.ShowDialog() == DialogResult.OK;
         if (flag)
         {
             this.Command   = frm.Command;
             this.Arguments = frm.Arguments;
         }
         return(flag);
     }
 }
Exemple #2
0
 private void DisplayForm()
 {
     if (CommandForm != null)
     {
         if (CommandForm.Visible)
         {
             CommandForm.Focus();
         }
         else
         {
             if (DisplayFormModal)
             {
                 CommandForm.ShowDialog(new WindowWrapper((IntPtr)Application.MainFrameHWND));
             }
             else
             {
                 CommandForm.Show(new WindowWrapper((IntPtr)Application.MainFrameHWND));
             }
         }
     }
 }
Exemple #3
0
        public Result Execute(ExternalCommandData commandData, ref string message, Autodesk.Revit.DB.ElementSet elements)
        {
            application = commandData.Application.Application;
            doc         = commandData.Application.ActiveUIDocument.Document;
            StoreOriginalVisibility(doc.ActiveView);

            CommandForm commandForm = new CommandForm();

            if (DialogResult.OK == commandForm.ShowDialog())
            {
                analysisCat = commandForm.SelectedAnalysisCategory;
                commandForm.Close();

                mainForm = new MainForm(doc, analysisCat);
                if (mainForm.FoundStyles)
                {
                    if (DialogResult.OK == mainForm.ShowDialog())
                    {
                        DisplayManinForm();
                    }
                }
            }
            return(Result.Succeeded);
        }
Exemple #4
0
        Result IExternalCommand.Execute(ExternalCommandData commandData, ref string message, Autodesk.Revit.DB.ElementSet elements)
        {
            try
            {
                m_app          = commandData.Application;
                m_doc          = m_app.ActiveUIDocument.Document;
                iniDataManager = new INIDataManager(m_app);

                if (iniDataManager.FindINI())
                {
                    TaskDialog taskdialog = new TaskDialog("BCF Reader");
                    taskdialog.MainInstruction   = "Open a BCF file.";
                    taskdialog.MainContent       = "Some bcf files have ever saved in this Revit project.\n You can open a new BCF file or choose a linked file on the file lists.";
                    taskdialog.AllowCancellation = true;
                    taskdialog.AddCommandLink(TaskDialogCommandLinkId.CommandLink1, "Open a new BCF file.");
                    taskdialog.AddCommandLink(TaskDialogCommandLinkId.CommandLink2, "Select a linked BCF file.");
                    iniDataManager.ReadINI();//collect reference data into referencedictionary

                    TaskDialogResult tResult = taskdialog.Show();
                    if (TaskDialogResult.CommandLink1 == tResult)
                    {
                        bcfFile = OpenBCF(iniDataManager.MasterFilePath);
                    }
                    else if (TaskDialogResult.CommandLink2 == tResult)
                    {
                        BcfListForm bcfForm = new BcfListForm();
                        bcfForm.RefDictionary = iniDataManager.RefDictionary;
                        bcfForm.DisplayBcfFiles();
                        if (DialogResult.OK == bcfForm.ShowDialog())
                        {
                            bcfFile = bcfForm.BCFPath;
                        }
                    }
                    iniDataManager.SelectedFilePath = bcfFile;
                    if (File.Exists(bcfFile))
                    {
                        commandForm = new CommandForm(m_app, bcfFile, iniDataManager);
                        commandForm.ShowDialog();
                    }
                    else if (bcfFile == null)
                    {
                    }
                    else
                    {
                        MessageBox.Show("BCF file dose not exist.\n" + bcfFile, "File Not Found", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                    }
                }
                else if (null != iniDataManager.MasterFilePath)
                {
                    bcfFile = OpenBCF(iniDataManager.MasterFilePath);
                    iniDataManager.SelectedFilePath = bcfFile;
                    if (null != bcfFile)
                    {
                        commandForm = new CommandForm(m_app, bcfFile, iniDataManager);
                        commandForm.ShowDialog();
                    }
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show("This tool Cannot open the BCF file. Please select an appropriate file. \n" + ex.Message, "Failure: Opening BCF file", MessageBoxButtons.OK, MessageBoxIcon.Warning);
            }
            return(Result.Succeeded);
        }