internal YieldAwaiter(string name) { Name = name; action = default; external = default; result = default; }
/// <summary> /// Questo metodo crea e mostra una finestra di dialogo non modale, a meno che non esista già. /// </summary> /// <remarks> /// Il comando esterno lo richiama su richiesta dell'utente finale /// </remarks> /// public void ShowForm(UIApplication uiapp) { // If we do not have a dialog yet, create and show it if (m_MyForm == null || m_MyForm.IsDisposed) { // Un nuovo gestore per gestire l'invio delle richieste tramite la finestra di dialogo RequestHandler handler = new RequestHandler(); // Evento esterno per la finestra di dialogo da utilizzare (per inviare richieste) ExternalEvent exEvent = ExternalEvent.Create(handler); // Diamo gli oggetti alla nuova finestra di dialogo. // La finestra di dialogo diventa il proprietario responsabile della loro disposizione, alla fine. m_MyForm = new ModelessForm(exEvent, handler); m_MyForm.Show(); if (ModelessForm.thisModForm.NotSaveFolder) { m_MyForm.TopMost = false; } else { m_MyForm.TopMost = true; } } }
// constructor public Configuration(UIApplication uiapp) { InitializeComponent(); extPickLayer = new ExtPickLayer(uiapp); ExEvent = ExternalEvent.Create(extPickLayer); }
public static void Initialize(UIApplication uiapp, SynchronizationContext uiContext, ExternalEvent eventHandler, List <Action> queue) { Uiapp = uiapp; UiContext = uiContext; EventHandler = eventHandler; Queue = queue; }
public MainWindow() { InitializeComponent(); //初始化 createExeWallCommand = new CreatExternalWall(); createWallEvent = ExternalEvent.Create(createExeWallCommand); }
//Dialog instantiation public FindLabelForm(ExternalEvent exEvent, RequestHandler handler, UIApplication uiapp) // define o metodo Form1 com um argumento commandData do tipo ExternalCommandData { Document doc = uiapp.ActiveUIDocument.Document; // doc define o documento ativo na aplicacao FamilyManager mgr = doc.FamilyManager; Dictionary <string, FamilyParameter> fps = GetFamilyParameters(mgr); List <string> labelNames = new List <string>(fps.Keys); InitializeComponent(); // inicia o Formulario m_Handler = handler; m_ExEvent = exEvent; #region comboBoxLabels comboBoxLabels.Enabled = true; comboBoxLabels.Items.Insert(0, "Select Label"); comboBoxLabels.SelectedItem = 0; comboBoxLabels.Text = "Select Label"; foreach (string i in labelNames) { comboBoxLabels.Items.AddRange(new object[] { i }); } #endregion //comboBoxlabels }
public ViewModel() { Creator handler = new Creator(); ExternalEvent exEvent = ExternalEvent.Create(handler); this._event = exEvent; }
public WarningChartPresenter(UIApplication uiapp, ExternalEvent exEvent, RequestHandler handler) { this._Application = uiapp; this.exEvent = exEvent; this.handler = handler; this.LoadData(); }
/// <summary> /// Main Dockable window /// </summary> public form_MainDock() { InitializeCef(); InitializeComponent(); InitializeChromium(); _extEvent = ExternalEvent.Create(_handler); }
public static void OpenOrFocusSpeckle(UIApplication app) { if (Bootstrapper != null) { Bootstrapper.Application.MainWindow.Show(); return; } UIApplication uiapp = app; var bindings = new ConnectorBindingsRevit(uiapp); var eventHandler = ExternalEvent.Create(new SpeckleExternalEventHandler(bindings)); bindings.SetExecutorAndInit(eventHandler); Bootstrapper = new Bootstrapper() { Bindings = bindings }; Bootstrapper.Setup(Application.Current != null ? Application.Current : new Application()); Bootstrapper.Application.Startup += (o, e) => { var helper = new System.Windows.Interop.WindowInteropHelper(Bootstrapper.Application.MainWindow); helper.Owner = app.MainWindowHandle; }; }
public Result Execute( ExternalCommandData commandData, ref string message, ElementSet elements) { UIApplication uiapp = commandData.Application; UIDocument uidoc = uiapp.ActiveUIDocument; Application app = uiapp.Application; Sel = uidoc.Selection; Doc = uidoc.Document; Data = new AddViewToSheetData(); GetAllViews(); viewObjects = GetData(Doc); var ac = ActiveView as ViewSheet; if (ac == null) { TaskDialog.Show("Add View", "Please go to the ViewSheet to Add the Views"); return(Result.Cancelled); } var form = new AddViewsToSheetForm(this, Doc); this._exEvent = ExternalEvent.Create((IExternalEventHandler) new EventAddview(this, Doc)); form.Show(); form.ExEvent = this._exEvent; return(Result.Succeeded); }
/// <summary> /// Constructor /// </summary> /// <param name="_uiapp"></param> /// <param name="exEvent"></param> /// <param name="handler"></param> public RevitWindow(UIApplication _uiapp, ExternalEvent exEvent, ExtOpenView handler) { InitializeComponent(); try { m_ExEvent = exEvent; m_Handler = handler; uiapp = _uiapp; mainPan.jiraPan.AddIssueBtn.Click += new RoutedEventHandler(AddIssueJira); mainPan.bcfPan.AddIssueBtn.Click += new RoutedEventHandler(AddIssueBCF); mainPan.bcfPan.Open3dViewBtn.Click += new RoutedEventHandler(Open3dViewBCF); mainPan.jiraPan.Open3dViewBtn.Click += new RoutedEventHandler(Open3dViewJira); } catch (Exception ex1) { MessageBox.Show("exception: " + ex1); } // mainPan.bcfPan.AddIssueBtn.Click += new RoutedEventHandler(AddIssueBCF); }
public static bool ToggleSubscription2(IExternalEventHandler handler) { if (Subscribed) { Util.Log("Unsubscribing..."); _event.Dispose(); _event = null; button1.ItemText = _subscribe; //_timer.Stop(); //_timer.Report( "Subscription timing" ); //_timer = null; Util.Log("Unsubscribed."); } else { Util.Log("Subscribing..."); _event = ExternalEvent.Create(handler); button1.ItemText = _unsubscribe; //_timer = new JtTimer( "Subscription" ); Util.Log("Subscribed."); } return(null != _event); }
public void ShowForm(UIApplication uiapp) { if (_AutomaticArrangementUserControl == null) { if (Instance == null) { Instance = this; } // A new handler to handle request posting by the dialog RevitHandler handler = new RevitHandler(); // External Event for the dialog to use (to post requests) ExternalEvent exEvent = ExternalEvent.Create(handler); // We give the objects to the new dialog; // The dialog becomes the owner responsible for disposing them, eventually. _AutomaticArrangementUserControl = new AutomaticArrangementUserControl(exEvent); BitmapImage pb1Image = new BitmapImage(new Uri("pack://application:,,,/AutomaticArrangement;component/Resources/icon.ico")); Window.Content = _AutomaticArrangementUserControl; Window.Icon = pb1Image; Window.Title = Util.ApplicationWindowTitle; Window.Height = Util.ApplicationWindowHeight; Window.Topmost = Util.IsApplicationWindowTopMost; Window.Width = Util.ApplicationWindowWidth; Window.WindowStartupLocation = WindowStartupLocation.CenterScreen; Window.Show(); Window.Closed += OnClosing; App.AutomaticArrangementButton.Enabled = false; } }
public Result OnStartup(UIControlledApplication application) { try { application.CreateRibbonTab(tabName); } catch { Log.AppendLog(LogMessageType.INFO, "Ribbon tab was not created because it already exists: " + tabName); } var assembly = Assembly.GetAssembly(GetType()); var panel = application.GetRibbonPanels(tabName).FirstOrDefault(x => x.Name == "Mission Control") ?? application.CreateRibbonPanel(tabName, "Mission Control"); var unused = (PushButton)panel.AddItem(new PushButtonData("GroupManager_Command", " Groups " + Environment.NewLine + "Manager", assembly.Location, "HOK.MissionControl.GroupsManager.GroupsManagerCommand") { LargeImage = ButtonUtil.LoadBitmapImage(assembly, "HOK.MissionControl.GroupsManager", Properties.Resources.GroupsManager_ImageName), ToolTip = Properties.Resources.GroupsManager_Description }); application.ControlledApplication.DocumentChanged += OnDocumentChanged; GroupManagerHandler = new GroupManagerRequestHandler(); GroupManagerEvent = ExternalEvent.Create(GroupManagerHandler); return(Result.Succeeded); }
/// <summary> /// Symbol Selection Form Class Instance and Initializer /// </summary> /// <param name="exEvent">External event which implemented when raise calling</param> /// <param name="handler">Revit API Externl Event Handler</param> /// <param name="m_doc">Active Revit Document</param> public SymbolSelectionForm(ExternalEvent exEvent, CreateBeamExternalEventHandler handler, Document m_doc) { InitializeComponent(); m_Handler = handler; m_ExEvent = exEvent; doc = m_doc; }
private void SelectAutoCADFile_Click(object sender, EventArgs e) { resetActiveView(); DialogResult result = this.openAutoCADFileDialog.ShowDialog(); if (result == DialogResult.OK) { string selectedFileName = this.openAutoCADFileDialog.FileName; if (File.Exists(selectedFileName)) { try { Autodesk.Revit.DB.View curView = GetViewByName(this.comboBoxImportView.SelectedItem.ToString()); if (curView != null) { uiapp.ActiveUIDocument.ActiveView = curView; CadDetailConverterHandler handler = new CadDetailConverterHandler(curView, selectedFileName); ExternalEvent exEvent = ExternalEvent.Create(handler); exEvent.Raise(); this.Close(); this.Dispose(); } } catch (Exception ex) { TaskDialog.Show("Exception", ex.Message); } } } }
public Result OnStartup(UIControlledApplication a) { RibbonPanel ribbonPanel = a.CreateRibbonPanel("AutoSync"); string assembly = Assembly.GetExecutingAssembly().Location; PushButtonData b1Data = new PushButtonData("AutoSync", "AutoSync", assembly, "AutoSync.ShowActive"); b1Data.AvailabilityClassName = "AutoSync.Availability"; PushButton pb1 = ribbonPanel.AddItem(b1Data) as PushButton; pb1.ToolTip = "AutoSync Inactive Revit Documents."; Uri addinImage = new Uri("pack://application:,,,/AutoSync;component/Resources/AutoSync.png"); BitmapImage pb1Image = new BitmapImage(addinImage); pb1.LargeImage = pb1Image; externalevent = ExternalEvent.Create(timerevent); a.ControlledApplication.DocumentOpening += new EventHandler <DocumentOpeningEventArgs>(OnOpening); a.ControlledApplication.DocumentOpened += new EventHandler <DocumentOpenedEventArgs>(OnOpened); a.ControlledApplication.DocumentCreated += new EventHandler <DocumentCreatedEventArgs>(OnCreated); a.ControlledApplication.DocumentClosing += new EventHandler <DocumentClosingEventArgs>(OnClosing); a.ControlledApplication.DocumentChanged += new EventHandler <DocumentChangedEventArgs>(OnChanged); a.ViewActivated += new EventHandler <ViewActivatedEventArgs>(OnViewActivated); return(Result.Succeeded); }
/// <summary> /// Toggle on and off subscription to /// automatic cloud updates. /// </summary> public static ExternalEvent ToggleSubscription( // EventHandler<IdlingEventArgs> handler IExternalEventHandler handler) { if (Subscribed) { Debug.Print("Unsubscribing..."); //_uiapp.Idling -= _handler; //_handler = null; _event.Dispose(); _event = null; _buttons[_subscribeButtonIndex].ItemText = _subscribe; _timer.Stop(); _timer.Report("Subscription timing"); _timer = null; Debug.Print("Unsubscribed."); } else { Debug.Print("Subscribing..."); //_uiapp.Idling += handler; //_handler = handler; _event = ExternalEvent.Create(handler); _buttons[_subscribeButtonIndex].ItemText = _unsubscribe; _timer = new JtTimer("Subscription"); Debug.Print("Subscribed."); } return(_event); }
public Result Execute(ExternalCommandData commandData, ref string message, ElementSet elements) { if (!Launched) { // Create a new speckle binding instance var bindings = new SpeckleUiBindingsRevit(commandData.Application); // Create an external event handler to raise actions var eventHandler = ExternalEvent.Create(new SpeckleRevitExternalEventHandler(bindings)); // Give it to our bindings so we can actually do stuff with revit bindings.SetExecutorAndInit(eventHandler); // Initialise the window SpeckleWindow = new SpeckleUiWindow(bindings); var helper = new System.Windows.Interop.WindowInteropHelper(SpeckleWindow); helper.Owner = System.Diagnostics.Process.GetCurrentProcess().MainWindowHandle; // TODO: find a way to set the parent/owner of the speckle window so it minimises/maximises etc. together with the revit window. SpeckleWindow.Show(); Launched = true; } SpeckleWindow.Show(); SpeckleWindow.Focus(); return(Result.Succeeded); }
public Result Execute(ExternalCommandData commandData, ref string message, ElementSet elements) { UIApplication uiapp = commandData.Application; UIDocument uidoc = uiapp.ActiveUIDocument; Application app = uiapp.Application; Document doc = uidoc.Document; try { //Token token = AuthorizeApp(); // A new handler to handle request posting by the dialog ExternalEventAuthorizationHandler handler = new ExternalEventAuthorizationHandler(); // External Event for the dialog to use (to post requests) ExternalEvent exEvent = ExternalEvent.Create(handler); // We give the objects to the new dialog; // The dialog becomes the owner responsible for disposing them, eventually. ExternalEventAuthorization externalEventAuthorizationAnswer = new ExternalEventAuthorization(exEvent, handler); return(Result.Succeeded); } catch (Exception ex) { // unchecked exception cause command failed message = ex.Message; return(Autodesk.Revit.UI.Result.Failed); } }
public Result OnStartup(UIControlledApplication application) { try { appCommand = this; m_app = application; AddInId appId = m_app.ActiveAddInId; addInGuid = appId.GetGUID(); addInName = appId.GetAddInName(); doorUpdater = new DoorUpdater(appId); dtmUpdater = new DTMUpdater(appId); revisionUpdater = new RevisionUpdater(appId); socketHandler = new SocketHandler(doorUpdater, dtmUpdater, revisionUpdater); extEvent = ExternalEvent.Create(socketHandler); LogUtil.InitializeLog(); LogUtil.AppendLog("Mission Control AddIn Started"); m_app.ControlledApplication.DocumentOpening += CollectConfigurationOnOpening; m_app.ControlledApplication.DocumentOpened += RegisterUpdatersOnOpen; m_app.ControlledApplication.FailuresProcessing += FailureProcessor.CheckFailure; m_app.ControlledApplication.DocumentClosing += UnregisterUpdaterOnClosing; } catch (Exception ex) { string message = ex.Message; LogUtil.AppendLog("OnStartup:" + ex.Message); } return(Result.Succeeded); }
public static async Task <IDisposableEntity <ExternalEvent> > CreateExternalEventAsync( this TestServiceScope scope, EventInfo eventInfo, string externalServiceName = TestingConstants.Placeholder, string externalEventId = TestingConstants.Placeholder) { if (externalServiceName == TestingConstants.Placeholder) { externalServiceName = "Test"; } if (externalEventId == TestingConstants.Placeholder) { externalEventId = Guid.NewGuid().ToString(); } var externalEvent = new ExternalEvent { EventInfo = eventInfo, ExternalServiceName = externalServiceName, ExternalEventId = externalEventId }; await scope.Db.ExternalEvents.AddAsync(externalEvent); await scope.Db.SaveChangesAsync(); return(new DisposableEntity <ExternalEvent>(externalEvent, scope.Db)); }
/// <summary> /// Toggle subscription to automatic database /// updates. Forward the call to the external /// application that creates the external event, /// store it and launch a separate thread checking /// for database updates. When changes are pending, /// invoke the external event Raise method. /// </summary> public static void ToggleSubscription( UIApplication uiapp) { // Todo: stop thread first! _event = App.ToggleSubscription( new DbUpdater(uiapp)); if (null == _event) { _thread.Abort(); _thread = null; } else { // Start a new thread to regularly check the // database status and raise the external event // when updates are pending. _thread = new Thread( CheckForPendingDatabaseChanges); _thread.Start(); } }
//De-facto the command is here. Will either be started on start (duh) or activated when switched back to a Family Document public bool ShowForm() { GetRevitHandle(); _presenter = null; if (_presenter == null || _presenter._isClosed) { try { if (!Application.App.ActiveUIDocument.Document.IsFamilyDocument) { DialogUtils.Alert("Error", "Usable only in Family Documents"); return(false); } handler = new RequestHandler(); //new handler exEvent = ExternalEvent.Create(handler); //new event _document = Application.App.ActiveUIDocument.Document; //set current document _presenter = new FamilyParameterViewModel(_document); _presenter.Show(_hWndRevit); //pass parent (Revit) thread here _presenter.PresenterClosed += Stop; } catch (Exception ex) { TaskDialog.Show("Error", ex.Message); _presenter.Dispose(); _presenter = null; return(false); } } return(true); }
public async Task PublishAsync(ExternalEvent externalEvent) { var eventGridEvent = MapToEventGridEvent(externalEvent); try { //TODO Try to read the endpoint from configuration //var topicHostName = new Uri(_eventGridSettings.Value.InvoiceManagementTopicEndpoint).Host; var topicHostName = new Uri("http://someendpoint").Host; await _retryPolicy.ExecuteAsync(async ctx => { _logger.Log(LogLevel.Debug, $"Publishing event:{eventGridEvent.EventType} to EventGrid. RetryCount:{ctx["retryCount"]} {DateTime.Now}"); _eventGridGateway.PublishEventsWithHttpMessagesAsync(topicHostName, new List <EventGridEvent> { eventGridEvent }); }, new Context { { "retryCount", 1 } }); } catch (Exception ex) { _logger.LogError("Exception while publishing to event grid", ex); throw; } }
public UserControl1() { InitializeComponent(); mainPage = this; _hander = new ExternalHander(); _event = ExternalEvent.Create(_hander); }
// Constructor public ParameterEditorViewModel() { PropertyExteralEventSetParameterValue = new ExternalEventSetParameterValue(); SetParameterExternalEvent = ExternalEvent.Create(PropertyExteralEventSetParameterValue); _selectionRegex = new Regex(@"\d{4,5}"); _parameterName = "Comments"; _revitElementParameterNames = new ObservableCollection <string> { "Comments" }; ParameterValue = string.Empty; _lengthModel = new LengthModel { //VisibleLength = "-222' 11 22/32\"", LengthRepresentation = string.Empty //SelectedText = string.Empty }; _autoUpdateModifiedParameterValue = true; }
public Result OnStartup(UIControlledApplication app) { // (Konrad) Initiate Nlog logger. NLogUtils.CreateConfiguration(); _logger = LogManager.GetCurrentClassLogger(); // (Konrad) Setup Document events. app.ControlledApplication.DocumentOpened += OnDocumentOpened; app.ControlledApplication.DocumentCreated += OnDocumentCreated; app.ControlledApplication.DocumentSaving += OnDocumentSaving; app.ControlledApplication.DocumentSynchronizingWithCentral += OnDocumentSynchronizingWithCentral; app.ControlledApplication.DocumentSynchronizedWithCentral += OnDocumentSynchronizedWithCentral; app.ControlledApplication.FailuresProcessing += FailureProcessor.CheckFailure; app.ViewActivated += OnViewActivated; app.CreateRibbonTab("Honeybee"); var panel = app.CreateRibbonPanel("Honeybee", "Honeybee"); SettingsCommand.CreateButton(panel); var hbButton = CreateHbModelCommand.CreateButton(); var dfButton = CreateDfModelCommand.CreateButton(); var splitButton = new SplitButtonData("CreateModelCommand", "Split"); var sb = (SplitButton)panel.AddItem(splitButton); sb.AddPushButton(hbButton); sb.AddPushButton(dfButton); CreateModelHandler = new CreateModelRequestHandler(); CreateModelEvent = ExternalEvent.Create(CreateModelHandler); // (Konrad) Register an updater that will watch annotations for changes. AnnotationUpdater = new AnnotationUpdater(app.ActiveAddInId); return(Result.Succeeded); }
public Scroller(UIApplication appRevit, ExternalEvent exEvent) { InitializeComponent(); Title = ModPlusAPI.Language.GetItem("h1"); _externalEvent = exEvent; this.appRevit = appRevit; }
public RoslynEditorViewModel(RevitRoslynHost host, ExternalEvent externalEvent, ScriptRunnerHandler scriptRunnerHandler) { Host = host; scriptRunnerHandler.RoslynEditorViewModel = this; _externalEvent = externalEvent; _scriptRunnerHandler = scriptRunnerHandler; }
public static ExternalEvent CreateExternalEvent(string eventValue) { ExternalEvent externalEvent = new ExternalEvent(); externalEvent.Event = eventValue; return externalEvent; }
protected override void OnFormClosed(FormClosedEventArgs e) { // we own both the event and the handler // we should dispose it before we are closed m_ExEvent.Dispose(); m_ExEvent = null; m_Handler = null; // do not forget to call the base class base.OnFormClosed(e); }
/// <summary> /// Constructor /// </summary> /// <param name="_uiapp"></param> /// <param name="exEvent"></param> /// <param name="handler"></param> public RevitWindow(UIApplication _uiapp, ExternalEvent exEvent, ExtEvntOpenView handler) { InitializeComponent(); try { ExtEvent = exEvent; Handler = handler; uiapp = _uiapp; } catch (Exception ex1) { TaskDialog.Show("Error!", "exception: " + ex1); } }
public ExternalEventExampleDialog(ExternalEvent exEvent, ExternalEventExample handler) { InitializeComponent(); m_ExEvent = exEvent; m_Handler = handler; }
public Result OnShutdown( UIControlledApplication a) { if ( Subscribed ) { _event.Dispose(); _event = null; } return Result.Succeeded; }
/// <summary> /// Toggle subscription to automatic database /// updates. Forward the call to the external /// application that creates the external event, /// store it and launch a separate thread checking /// for database updates. When changes are pending, /// invoke the external event Raise method. /// </summary> public static void ToggleSubscription( UIApplication uiapp) { // Todo: stop thread first! _event = App.ToggleSubscription( new DbUpdater( uiapp ) ); if( null == _event ) { _thread.Abort(); _thread = null; } else { // Start a new thread to regularly check the // database status and raise the external event // when updates are pending. _thread = new Thread( CheckForPendingDatabaseChanges ); _thread.Start(); } }
/// <summary> /// Toggle on and off subscription to automatic /// cloud updates. Return true when subscribed. /// </summary> public static bool ToggleSubscription2( IExternalEventHandler handler) { if ( Subscribed ) { Util.Log( "Unsubscribing..." ); _event.Dispose(); _event = null; _buttons[_subscribeButtonIndex].ItemText = _subscribe; //_timer.Stop(); //_timer.Report( "Subscription timing" ); //_timer = null; Util.Log( "Unsubscribed." ); } else { Util.Log( "Subscribing..." ); _event = ExternalEvent.Create( handler ); _buttons[_subscribeButtonIndex].ItemText = _unsubscribe; //_timer = new JtTimer( "Subscription" ); Util.Log( "Subscribed." ); } return null != _event; }
public IEntity Map(MemberInfo mi) { IEntity tag = (IEntity)_entityCache[GetCacheKey(mi)]; if (null == tag) { switch (mi.MemberType) { case MemberTypes.Method: { return Map((MethodInfo)mi); } case MemberTypes.Constructor: { return Map((ConstructorInfo)mi); } case MemberTypes.Field: { tag = new ExternalField(this, (FieldInfo)mi); break; } case MemberTypes.Property: { tag = new ExternalProperty(this, (PropertyInfo)mi); break; } case MemberTypes.Event: { tag = new ExternalEvent(this, (EventInfo)mi); break; } case MemberTypes.NestedType: { return Map((Type)mi); } default: { throw new NotImplementedException(mi.ToString()); } } _entityCache.Add(GetCacheKey(mi), tag); } return tag; }
public bool Initialise(object revitApplicationObject, IOpohoRuntimeData rtmd) { // ensures always runs on the revit thread var cmdFactory = OpohoCompositionManager.Current().ConsoleCommandProvider; _sessionManager.Reset(); var application = revitApplicationObject as UIControlledApplication; if (application != null) { application.ApplicationClosing += ApplicationClosingEventHandler; application.ControlledApplication.DocumentCreated += DocumentCreated; application.ControlledApplication.DocumentOpened += DocumentOpened; application.ControlledApplication.DocumentClosing += DocumentClosing; _replEvent = ExternalEvent.Create(this); cmdFactory.RegisterStartRepl(RaiseStartRepl); return true; } return false; }
public void Initialise(object uiControlledApplicationObject) { var application = uiControlledApplicationObject as UIControlledApplication; if (application == null) { Log.Error("OpohoScriptProvider Initialise:- Not an UIControlledApplication passed as uiControlledApplicationObject"); return; } var config = OpohoCompositionManager.Current().ConfigurationProvider as IConsoleConfigurationProvider; if (config == null) { Log.Error("Invalid ConfigurationProvider. Unable to register extensions"); return; } _watcher = new FileSystemWatcher { Path = config.ScriptDirectory, Filter = "*.csx", IncludeSubdirectories = false, NotifyFilter = NotifyFilters.Attributes | NotifyFilters.CreationTime | NotifyFilters.FileName | NotifyFilters.LastWrite }; _metaReferences = BuildMetaReferences(config.DefaultReferences); foreach (var path in Directory.GetFiles(config.ScriptDirectory, "*.csx",SearchOption.TopDirectoryOnly)) { var item = CreateScriptItem(path); if (string.IsNullOrEmpty(item.Name)) { Log.Error("script item name null or empty"); continue; } ScriptList.Add(item); } BuildScriptAssembly(_metaReferences, ScriptList); _replEvent = ExternalEvent.Create(this); _watcher.EnableRaisingEvents = true; _watcher.Changed += OnChanged; _watcher.Deleted += OnDeleted; _watcher.Renamed += OnRenamed; }
protected override void OnFormClosed(FormClosedEventArgs e) { // 保存的实例需要释放 m_ExEvent.Dispose(); m_ExEvent = null; m_Handler = null; base.OnFormClosed(e); }
/// <summary> /// Toggle on and off subscription to /// automatic cloud updates. /// </summary> public static ExternalEvent ToggleSubscription( // EventHandler<IdlingEventArgs> handler IExternalEventHandler handler) { if( Subscribed ) { Debug.Print( "Unsubscribing..." ); //_uiapp.Idling -= _handler; //_handler = null; _event.Dispose(); _event = null; _buttons[_subscribeButtonIndex].ItemText = _subscribe; _timer.Stop(); _timer.Report( "Subscription timing" ); _timer = null; Debug.Print( "Unsubscribed." ); } else { Debug.Print( "Subscribing..." ); //_uiapp.Idling += handler; //_handler = handler; _event = ExternalEvent.Create( handler ); _buttons[_subscribeButtonIndex].ItemText = _unsubscribe; _timer = new JtTimer( "Subscription" ); Debug.Print( "Subscribed." ); } return _event; }