Esempio n. 1
0
        /// <summary>
        /// event handler that auto-rejects renaming of views
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        void a_DialogBoxShowing(
            object sender,
            DialogBoxShowingEventArgs e)
        {
            TaskDialogShowingEventArgs e2
                = e as TaskDialogShowingEventArgs;

            string s = string.Empty;

            if (null != e2)
            {
                s = string.Format(", dialog id {0}, message '{1}'",
                                  e2.DialogId, e2.Message);

                bool isConfirm = e2.Message.Contains("Would you like to rename corresponding level and views?");

                if (isConfirm)
                {
                    e2.OverrideResult(
                        (int)System.Windows.Forms.DialogResult.No);

                    s += ", auto-confirmed.";
                }
            }
        }
Esempio n. 2
0
 private void OnDialogBoxShowing(object sender, DialogBoxShowingEventArgs e)
 {
     if (e is TaskDialogShowingEventArgs e1)
     {
         e1.OverrideResult((int)TaskDialogResult.CommandLink1);
     }
 }
 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;
     }
 }
Esempio n. 4
0
 public void dialogBoxShowing(object sender, DialogBoxShowingEventArgs e)
 {
     try
     {
         TaskDialogShowingEventArgs taskDialog = e as TaskDialogShowingEventArgs;
         if (null != taskDialog)
         {
             string dialogId = taskDialog.DialogId;
             if (dialogId == "TaskDialog_Copied_Central_Model")
             {
                 DialogResult dr = MessageBox.Show("Would you like to suppress the message about the copied central model?", "Copied Centeral Model", MessageBoxButtons.YesNo, MessageBoxIcon.Warning);
                 if (dr == DialogResult.Yes)
                 {
                     if (taskDialog.Cancellable)
                     {
                         taskDialog.Cancel = true;
                     }
                     taskDialog.OverrideResult((int)DialogResult.OK);
                 }
             }
         }
     }
     catch (Exception ex)
     {
         string message = ex.Message;
     }
 }
Esempio n. 5
0
        private void Uiapp_DialogBoxShowing(object sender, DialogBoxShowingEventArgs e)
        {
            TaskDialogShowingEventArgs e2 = e as TaskDialogShowingEventArgs;

            string s = string.Empty;

            bool isConfirm    = false;
            int  dialogResult = 0;

            if (e2.DialogId.Equals("TaskDialog_Missing_Third_Party_Updaters"))
            {
                isConfirm    = true;
                dialogResult = (int)TaskDialogResult.CommandLink1;
            }

            if (isConfirm)
            {
                e2.OverrideResult(dialogResult);
                s += ", auto-confirmed.";
            }
            else
            {
                s = string.Format(
                    ", dialog id {0}, message '{1}'",
                    e2.DialogId, e2.Message);
                winForms.MessageBox.Show(s);
            }
        }
Esempio n. 6
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);
//      }
        }
Esempio n. 7
0
 public void app_DialogBoxShowing(Object sender, DialogBoxShowingEventArgs args)
 {
     if (args is TaskDialogShowingEventArgs)
     {
         TaskDialogShowingEventArgs argsTask = args as TaskDialogShowingEventArgs;
         args.OverrideResult((int)TaskDialogResult.Close);
     }
 }
Esempio n. 8
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);
            }
        }
        /// <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);
            }
        }
        // from https://forums.autodesk.com/t5/revit-api-forum/twinmotion-dynamic-link-export-fbx-automatically/m-p/10028748
        void OnDialogBoxShowing(
            object sender,
            DialogBoxShowingEventArgs args)
        {
            //DialogBoxShowingEventArgs args
            TaskDialogShowingEventArgs e2 = args
                                            as TaskDialogShowingEventArgs;

            e2.OverrideResult((int)TaskDialogResult.Ok);
        }
Esempio n. 11
0
        private void HideDocumentNotSaved(object sender, DialogBoxShowingEventArgs args)
        {
            TaskDialogShowingEventArgs tdArgs = args as TaskDialogShowingEventArgs;

            // 由于阻止了保存文件,会弹出“为保存文件”对话框,这里将它频闭掉
            if (tdArgs != null && tdArgs.Message.Contains("未保存"))
            {
                args.OverrideResult(0x0008);
            }
        }
Esempio n. 12
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);
            }
        }
Esempio n. 13
0
 private void CancelAllDialogs(object sender, DialogBoxShowingEventArgs e)
 {
     if (e.Cancellable)
     {
         e.Cancel = true;
     }
     else
     {
         e.OverrideResult(1);
     }
 }
 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);
     }
 }
Esempio n. 15
0
        private void dismissFloorQuestion(object o, DialogBoxShowingEventArgs e)
        {
            // DialogBoxShowingEventArgs has two subclasses - TaskDialogShowingEventArgs & MessageBoxShowingEventArgs
            // In this case we are interested in this event if it is TaskDialog being shown.
            //TaskDialog.Show("did", e.DialogId.ToString());

            TaskDialogShowingEventArgs t = e as TaskDialogShowingEventArgs;
            //if (t != null && t.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);
            //}
        }
Esempio n. 16
0
        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.");
                    }
                }
            }
        }
Esempio n. 17
0
 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);
     }
 }
Esempio n. 18
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);
                }
            }
        }
Esempio n. 19
0
        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 );
              }
        }
Esempio n. 20
0
 private void m_app_DialogBoxShowing(object sender, DialogBoxShowingEventArgs e)
 {
     DisplayEvent("Dialog Box");
 }
Esempio n. 21
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)
                { }
            }
        }
 /// <summary>
 /// Will dismiss all dialogs
 /// </summary>
 private void DismissAllDialogs(object o, DialogBoxShowingEventArgs e)
 {
     e.OverrideResult(1);
     popupsNum += 1;
 }
Esempio n. 23
0
        /// <summary>
        /// event handler that auto-rejects renaming of views
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        void a_DialogBoxShowing(
            object sender,
            DialogBoxShowingEventArgs e)
        {
            TaskDialogShowingEventArgs e2
                = e as TaskDialogShowingEventArgs;

            string s = string.Empty;

            if (null != e2)
            {
                s = string.Format(", dialog id {0}, message '{1}'",
                    e2.DialogId, e2.Message);

                bool isConfirm = e2.Message.Contains("Would you like to rename corresponding level and views?");

                if (isConfirm)
                {
                    e2.OverrideResult(
                        (int)System.Windows.Forms.DialogResult.No);

                    s += ", auto-confirmed.";
                }
            }
        }
Esempio n. 24
0
        public void a_DialogBoxShowing(object sender, DialogBoxShowingEventArgs e)
        {
            TaskDialogShowingEventArgs e2 = e as TaskDialogShowingEventArgs;

            string s = string.Empty;

            if (null != e2)
            {
                /*
                 * TaskDialogResult
                 * None = 0,
                 * Ok = 1,
                 * Cancel = 2,
                 * Retry = 4,
                 * Yes = 6,
                 * No = 7,
                 * Close = 8,
                 * CommandLink1 = 1001,
                 * CommandLink2 = 1002,
                 * CommandLink3 = 1003,
                 * CommandLink4 = 1004
                 */

                bool isConfirm    = false;
                int  dialogResult = 0;

                if (e2.DialogId.Equals("TaskDialog_Update_Resources"))
                {
                    isConfirm    = true;
                    dialogResult = (int)TaskDialogResult.CommandLink1;
                }

                if (e2.DialogId.Equals("TaskDialog_Unresolved_References"))
                {
                    isConfirm    = true;
                    dialogResult = (int)TaskDialogResult.CommandLink2;
                }


                if (e2.DialogId.Equals("TaskDialog_Missing_Third_Party_Updaters"))
                {
                    isConfirm    = true;
                    dialogResult = (int)TaskDialogResult.CommandLink2;
                }

                if (e2.DialogId.Equals("TaskDialog_Missing_Third_Party_Updater"))
                {
                    isConfirm    = true;
                    dialogResult = (int)TaskDialogResult.CommandLink2;
                }

                if (e2.DialogId.Equals("TaskDialog_Local_Changes_Not_Synchronized_With_Central"))
                {
                    isConfirm    = true;
                    dialogResult = (int)TaskDialogResult.CommandLink2;
                }

                if (e2.DialogId.Equals("TaskDialog_Default_Family_Template_File_Invalid"))
                {
                    isConfirm    = true;
                    dialogResult = (int)TaskDialogResult.Close;
                }

                if (isConfirm)
                {
                    e2.OverrideResult(dialogResult);
                    s += ", auto-confirmed.";
                }
                else
                {
                    //s = string.Format(", dialog id {0}, message '{1}'", e2.DialogId, e2.Message);
                    //MessageBox.Show(s);
                }
            }
        }