Пример #1
0
 def _dispatch_updater(self):
     # ask WPF dispatcher for gui update
     self.pbar.Dispatcher.Invoke(System.Action(self._update_pbar),
                                 Threading.DispatcherPriority.Background)
Пример #2
0
    def _setup_event_telemetry_checkboxes(self):
        supportedEvents = EventUtils.GetSupportedEventTypes()
        for event_type in coreutils.get_enum_values(EventType):
            # verify event type is supported in telemetry system
            # grab the two parts of the event type name
            api_name, api_event = str(event_type).split('_')

            # figure out the namespace
            api_namespace = 'Autodesk.Revit.ApplicationServices.'
            if api_name in ['UIApplication', 'AddInCommandBinding']:
                api_namespace = 'Autodesk.Revit.UI.'

            # figure out the ui title
            api_title = api_event
            api_obj = api_name + '.' + api_event

            cbox = Controls.CheckBox()
            cbox.Margin = Windows.Thickness(0, 10, 0, 0)
            cbox.FontFamily = Windows.Media.FontFamily("Consolas")
            cbox.IsChecked = False
            tblock = Controls.TextBlock()
            tblock.Margin = Windows.Thickness(0, 2, 0, 0)
            # if event does not have interesting telemetry data, hide from user
            if event_type in [
                    EventType.AddInCommandBinding_BeforeExecuted,
                    EventType.AddInCommandBinding_CanExecute,
                    EventType.AddInCommandBinding_Executed,
                    EventType.Application_JournalUpdated
            ]:
                cbox.IsEnabled = False
                cbox.Visibility = Windows.Visibility.Collapsed

            # if the event type is not supported in running revit, inform user
            elif event_type not in supportedEvents:
                cbox.IsEnabled = False
                tblock.Inlines.Add(
                    Documents.Run("{}\n".format(' '.join(
                        coreutils.split_words(str(api_title))))))
                tblock.Inlines.Add(
                    Documents.Run("Not Supported in this Revit Version\n"))

            # if event is JournalCommandExecuted, create better user interface
            elif event_type == EventType.Application_JournalCommandExecuted:
                tblock.Inlines.Add(Documents.Run("Command Executed\n"))
                tblock.Inlines.Add(
                    Documents.Run(
                        "Event Type:               journal-command-exec\n"))
                tblock.Inlines.Add(
                    Documents.Run(
                        "Tracks execution of commands from active journal file. Includes:\n"
                    ))
                tblock.Inlines.Add(
                    Documents.Run(
                        "  Builtin Commands (e.g. ID_OBJECTS_WALL)\n"))
                tblock.Inlines.Add(
                    Documents.Run(
                        "  Thirdparty Commands (e.g. CustomCtrl_%CustomCtrl_%Site Designer%Modify%Sidewalk)\n"
                    ))
                tblock.Inlines.Add(
                    Documents.Run(
                        "  pyRevit Commands (e.g. CustomCtrl_%CustomCtrl_%pyRevit%pyRevit%Settings)\n"
                    ))

            # otherwise prepare the option for the event type
            elif event_type in supportedEvents:
                tblock.Inlines.Add(
                    Documents.Run("{}\n".format(' '.join(
                        coreutils.split_words(str(api_title))))))
                tblock.Inlines.Add(Documents.Run("API Event Type:           "))
                hyperlink = Documents.Hyperlink(Documents.Run(api_obj + "\n"))
                hyperlink.NavigateUri = \
                    System.Uri(apidocs.make_event_uri(api_namespace + api_obj))
                hyperlink.Click += self.handle_url_click
                tblock.Inlines.Add(hyperlink)
                tblock.Inlines.Add(
                    Documents.Run("pyRevit Event/Hook Name:  {}".format(
                        EventUtils.GetEventName(event_type))))
            cbox.Content = tblock
            self.event_telemetry_sp.Children.Add(cbox)