コード例 #1
0
ファイル: Labs6.cs プロジェクト: ezhangle/AdnRevitApiLabsXtra
        void DismissDialog(
            object sender,
            DialogBoxShowingEventArgs e)
        {
            TaskDialogShowingEventArgs te = e as TaskDialogShowingEventArgs;

            if (te != null)
            {
                if (te.DialogId == "TaskDialog_Family_Already_Exists")
                {
                    // In this task dialog, 1001 maps to the first button,
                    // which is the "override the existing version"
                    int iReturn = 1001;

                    // Set OverrideResult argument to 1001 mimic clicking the first button.
                    e.OverrideResult(iReturn);

                    // 1002 maps the second button in this dialog.
                    // DialogResult.Cancel maps to the cancel button.
                }
            }
            else
            {
                MessageBoxShowingEventArgs msgArgs = e as MessageBoxShowingEventArgs;
                if (null != msgArgs) // this is a message box
                {
                    //e.OverrideResult( (int) WinForms.DialogResult.Yes );
                    //Debug.Print( "Dialog id is {0}\r\nMessage is {1}",
                    //  msgArgs.HelpId, msgArgs.Message ); // Revit 2016

                    e.OverrideResult((int)WinForms.DialogResult.Yes);
                    Debug.Print("Dialog id is {0}\r\nMessage is {1}",
                                msgArgs.DialogId, msgArgs.Message); // Revit 2017
                }
                else // this is some other dialog, for example, element property dialog.
                {
                    // Use the HelpId to identify the dialog.
                    //if( e.HelpId == 1002 ) // Element property dialog's HelpId is 1002 in Revit 2016 and earlier

                    if (e.DialogId.Equals("1002")) // What is the corresponding Element property dialog DialogId?
                    {
                        e.OverrideResult((int)WinForms.DialogResult.No);
                        Debug.Print(
                            "We just dismissed the element property dialog "
                            + "and set the return value to No.");
                    }
                }
            }
        }
コード例 #2
0
        void AppDialogShowing(object sender, DialogBoxShowingEventArgs args)
        {
            // DialogBoxShowingEventArgs has two subclasses - TaskDialogShowingEventArgs & MessageBoxShowingEventArgs
            // In this case we are interested in this event if it is TaskDialog being shown.
            if (args is TaskDialogShowingEventArgs e)
            {
                //worry about this later - 1002 = cancel
                if (e.DialogId == "TaskDialog_Unresolved_References")
                {
                    e.OverrideResult(1002);
                }
                //Don't sync newly created files. 1003 = close
                if (e.DialogId == "TaskDialog_Local_Changes_Not_Synchronized_With_Central")
                {
                    e.OverrideResult(1003);
                }
                if (e.DialogId == "TaskDialog_Save_Changes_To_Local_File")
                {
                    //Relinquish unmodified elements and worksets
                    e.OverrideResult(1001);
                }
                if (e.DialogId == "TaskDialog_Copied_Central_Model")
                {
                    args.OverrideResult((int)TaskDialogResult.Close);
                }
                if (e.Message == "The floor/roof overlaps the highlighted wall(s). Would you like to join geometry and cut the overlapping volume out of the wall(s)?")
                {
                    // Call OverrideResult to cause the dialog to be dismissed with the specified return value
                    // (int) is used to convert the enum TaskDialogResult.No to its integer value which is the data type required by OverrideResult
                    e.OverrideResult((int)TaskDialogResult.No);
                }
            }

//      // Get the help id of the showing dialog
//      int dialogId = args.HelpId;
//
//      // Format the prompt information string
//      String promptInfo = "A Revit dialog will be opened.\n";
//      promptInfo += "The help id of this dialog is " + dialogId.ToString() + "\n";
//      promptInfo += "If you don't want the dialog to open, please press cancel button";
//
//      // Show the prompt message, and allow the user to close the dialog directly.
//      TaskDialog taskDialog = new TaskDialog("Revit");
//      taskDialog.MainContent = promptInfo;
//      TaskDialogCommonButtons buttons = TaskDialogCommonButtons.Ok |
//                                        TaskDialogCommonButtons.Cancel;
//      taskDialog.CommonButtons = buttons;
//      TaskDialogResult result = taskDialog.Show();
//      if (TaskDialogResult.Cancel == result)
//      {
//        // Do not show the Revit dialog
//        args.OverrideResult(1);
//      }
//      else
//      {
//        // Continue to show the Revit dialog
//        args.OverrideResult(0);
//      }
        }
コード例 #3
0
 public void app_DialogBoxShowing(Object sender, DialogBoxShowingEventArgs args)
 {
     if (args is TaskDialogShowingEventArgs)
     {
         TaskDialogShowingEventArgs argsTask = args as TaskDialogShowingEventArgs;
         args.OverrideResult((int)TaskDialogResult.Close);
     }
 }
コード例 #4
0
 static private void OnDialogBoxShowingEvent(object sender, DialogBoxShowingEventArgs e)
 {
     if (e.OverrideResult((int)System.Windows.Forms.DialogResult.OK))
     {
         return;
     }
     else if (e.OverrideResult((int)System.Windows.Forms.DialogResult.Cancel))
     {
         return;
     }
     else if (e.OverrideResult((int)System.Windows.Forms.DialogResult.Abort))
     {
         return;
     }
     else if (e.OverrideResult((int)System.Windows.Forms.DialogResult.Ignore))
     {
         return;
     }
     else if (e.OverrideResult((int)System.Windows.Forms.DialogResult.Yes))
     {
         return;
     }
     else if (e.OverrideResult((int)System.Windows.Forms.DialogResult.No))
     {
         return;
     }
     else if (e.OverrideResult((int)System.Windows.Forms.DialogResult.Retry))
     {
         return;
     }
 }
コード例 #5
0
        public static void DismissDuplicateQuestion(object value, DialogBoxShowingEventArgs e)
        {
            var t = e as MessageBoxShowingEventArgs;

            if (t != null && t.Message == @"Elements have duplicate 'Number' values.")
            {
                e.OverrideResult((int)TaskDialogResult.Ok);
            }
        }
コード例 #6
0
        /// <summary>
        /// The DialogBoxShowing callback to cancel display of the "Document not saved" message when saving is cancelled.
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="args"></param>
        private void HideDocumentNotSaved(object sender, DialogBoxShowingEventArgs args)
        {
            TaskDialogShowingEventArgs tdArgs = args as TaskDialogShowingEventArgs;

            // The "Document not saved" dialog does not have a usable id, so we are forced to look at the text instead.
            if (tdArgs != null && tdArgs.Message.Contains("not saved"))
            {
                args.OverrideResult(0x0008);
            }
        }
コード例 #7
0
        private void HideDocumentNotSaved(object sender, DialogBoxShowingEventArgs args)
        {
            TaskDialogShowingEventArgs tdArgs = args as TaskDialogShowingEventArgs;

            // 由于阻止了保存文件,会弹出“为保存文件”对话框,这里将它频闭掉
            if (tdArgs != null && tdArgs.Message.Contains("未保存"))
            {
                args.OverrideResult(0x0008);
            }
        }
コード例 #8
0
        private void OnDialogBoxShowing(object sender, DialogBoxShowingEventArgs e)
        {
            TaskDialogShowingEventArgs e2 = e as TaskDialogShowingEventArgs;

            if (null != e2 && e2.DialogId.Equals(
                    "TaskDialog_Really_Print_Or_Export_Temp_View_Modes"))
            {
                e.OverrideResult(
                    (int)TaskDialogResult.CommandLink2);
            }
        }
コード例 #9
0
 private void CancelAllDialogs(object sender, DialogBoxShowingEventArgs e)
 {
     if (e.Cancellable)
     {
         e.Cancel = true;
     }
     else
     {
         e.OverrideResult(1);
     }
 }
コード例 #10
0
 private void Application_DialogBoxShowing(object sender, DialogBoxShowingEventArgs e)
 {
     try
     {
         // https://www.revitapidocs.com/2020/cb46ea4c-2b80-0ec2-063f-dda6f662948a.htm
         e.OverrideResult(1);
     }
     catch (Exception ex)
     {
         myHub.Invoke("SendError", Process.GetCurrentProcess().Id, ex.Message);
     }
 }
コード例 #11
0
ファイル: Command.cs プロジェクト: acnicholas/FileUpgrader
 private static void OnDialogShowing(object o, DialogBoxShowingEventArgs e)
 {
     if (e.Cancellable)
     {
         e.Cancel();
     }
     //worry about this later - 1002 = cancel
     if (e.DialogId == "TaskDialog_Unresolved_References")
     {
         e.OverrideResult(1002);
     }
     //Don't sync newly created files. 1003 = close
     if (e.DialogId == "TaskDialog_Local_Changes_Not_Synchronized_With_Central")
     {
         e.OverrideResult(1003);
     }
     if (e.DialogId == "TaskDialog_Save_Changes_To_Local_File")
     {
         //Relinquish unmodified elements and worksets
         e.OverrideResult(1001);
     }
 }
コード例 #12
0
        // // General Warning Swallower



        /* */
        public void Project_DialogBoxShowing(Object sender, DialogBoxShowingEventArgs args)
        {
            TaskDialogShowingEventArgs args2 = args as TaskDialogShowingEventArgs;

            if (null != args2)
            {
                string s = args2.DialogId;

                TaskDialog.Show("dl", "Dialog ID is:  " + s + "---");
                if (args2.DialogId == "TaskDialog_Audit_Warning")
                {
                    args.OverrideResult((int)TaskDialogResult.Yes);
                }
                if (args2.DialogId == "TaskDialog_Unresolved_References")
                {
                    // Buttons with custom text have custom IDs with incremental values
                    // starting at 1001 for the left-most or top-most button in a task dialog.
                    // "Open Manage Links to correct the problem", "1001"
                    //args2.OverrideResult(1001);
                    // "Ignore and continue opening the project", "1002"
                    args2.OverrideResult(1002);
                }
            }
        }
コード例 #13
0
ファイル: Commands.cs プロジェクト: jeremytammik/ExportCncFab
        static void OnDialogBoxShowing(
            object sender,
            DialogBoxShowingEventArgs e)
        {
            TaskDialogShowingEventArgs e2
            = e as TaskDialogShowingEventArgs;

              if( null != e2 && e2.DialogId.Equals(
            "TaskDialog_Really_Print_Or_Export_Temp_View_Modes" ) )
              {
            int cmdLink
              = (int) TaskDialogResult.CommandLink2;

            e.OverrideResult( cmdLink );
              }
        }
コード例 #14
0
 /// <summary>
 /// Will dismiss all dialogs
 /// </summary>
 private void DismissAllDialogs(object o, DialogBoxShowingEventArgs e)
 {
     e.OverrideResult(1);
     popupsNum += 1;
 }
コード例 #15
0
        public void OnDialogBoxShowing(object sender, DialogBoxShowingEventArgs args)
        {
            if (!ModuleData.AutoConfirmEnabled || !ModuleData.up_close_dialogs)
            {
                return;
            }
            HashSet <string> dialogIds = new HashSet <string>();
            SQLiteConnection sql       = new SQLiteConnection();

            try
            {
                sql.ConnectionString = string.Format(@"Data Source=Z:\Отдел BIM\03_Скрипты\08_Базы данных\KPLN_Loader.db;Version=3;");
                sql.Open();
                using (SQLiteCommand cmd = new SQLiteCommand("SELECT Name FROM TaskDialogs", sql))
                {
                    using (SQLiteDataReader rdr = cmd.ExecuteReader())
                    {
                        while (rdr.Read())
                        {
                            dialogIds.Add(rdr.GetString(0));
                        }
                    }
                }
                sql.Close();
            }
            catch (Exception)
            {
                try
                {
                    sql.Close();
                }
                catch (Exception) { }
            }
            if (dialogIds.Contains(args.DialogId))
            {
                Print(string.Format("Всплывающий диалог: [{0}]...", args.DialogId), KPLN_Loader.Preferences.MessageType.System_Regular);
                sql = new SQLiteConnection();
                string value = "NONE";
                try
                {
                    sql.ConnectionString = string.Format(@"Data Source=Z:\Отдел BIM\03_Скрипты\08_Базы данных\KPLN_Loader.db;Version=3;");
                    sql.Open();
                    using (SQLiteCommand cmd = new SQLiteCommand(string.Format("SELECT OverrideResult FROM TaskDialogs WHERE Name = '{0}'", args.DialogId), sql))
                    {
                        using (SQLiteDataReader rdr = cmd.ExecuteReader())
                        {
                            while (rdr.Read())
                            {
                                value = rdr.GetString(0);
                            }
                        }
                    }
                    sql.Close();
                }
                catch (Exception)
                {
                    try
                    {
                        sql.Close();
                    }
                    catch (Exception) { }
                }
                if (value != "NONE")
                {
                    TaskDialogResult rslt;
                    if (Enum.TryParse(value, out rslt))
                    {
                        args.OverrideResult((int)rslt);
                        Print(string.Format("...действие «по умолчанию» - [{0}]", rslt.ToString("G")), KPLN_Loader.Preferences.MessageType.System_Regular);
                    }
                }
                else
                {
                    Print("...действие «по умолчанию» - [NONE]", KPLN_Loader.Preferences.MessageType.System_Regular);
                }
            }
            else
            {
                Print(string.Format("Не удалось идентифицировать всплывающий диалог: [{0}]", args.DialogId), KPLN_Loader.Preferences.MessageType.Critical);
                try
                {
                    sql.ConnectionString = string.Format(@"Data Source=Z:\Отдел BIM\03_Скрипты\08_Базы данных\KPLN_Loader.db;Version=3;");
                    sql.Open();
                    using (SQLiteCommand cmd = sql.CreateCommand())
                    {
                        cmd.CommandText = "INSERT INTO TaskDialogs ([Name], [OverrideResult]) VALUES (@Name, @OverrideResult)";
                        cmd.Parameters.Add(new SQLiteParameter()
                        {
                            ParameterName = "@Name", Value = args.DialogId
                        });
                        cmd.Parameters.Add(new SQLiteParameter()
                        {
                            ParameterName = "@OverrideResult", Value = "NONE"
                        });
                        cmd.ExecuteNonQuery();
                    }
                    sql.Close();
                }
                catch (Exception)
                {
                    try
                    {
                        sql.Close();
                    }
                    catch (Exception) { }
                }
                try
                {
                    Thread t = new Thread(() =>
                    {
                        SaveImage(args.DialogId.ToString());
                    });
                    t.Start();
                }
                catch (Exception)
                { }
                try
                {
                    if (args.Cancellable)
                    {
                        args.Cancel();
                        Print("...действие «по умолчанию» - [Закрыть]", KPLN_Loader.Preferences.MessageType.System_Regular);
                    }
                }
                catch (Exception)
                { }
            }
        }