protected virtual void OnOpen(CancellableEventArgs args) { if (this.Open != null) { this.Open(this, args); } }
protected virtual void OnClose(CancellableEventArgs args) { if (this.Close != null) { this.Close(this, args); } }
public bool DispatchCancelable(EventHandler?eventHandler, object sender, CancellableEventArgs args, string?eventName = null) { if (eventHandler == null) { return(args.Cancel); } eventHandler(sender, args); return(args.Cancel); }
public virtual void Show() { if (this.isVisible) { return; } CancellableEventArgs args = new CancellableEventArgs(); this.OnOpen(args); if (args.Cancel) { return; } this.windowPanel.Show(); this.isVisible = true; this.OnOpened(); }
public virtual void Hide() { if (!isVisible) { return; } CancellableEventArgs args = new CancellableEventArgs(); this.OnClose(args); if (args.Cancel) { return; } this.StopResizing(); this.windowPanel.Hide(); this.isVisible = false; this.OnClosed(); }
private static void PublishErrorPage(CancellableEventArgs e, IContent content) { var helper = new UmbracoHelper(UmbracoContext.Current); var published = helper.TypedContent(content.Id); if (published != null) { var publisher = NinjectWebCommon.Kernel.GetService <IPublishingService>(); if (publisher.PublishWebFormsPage(published.UrlWithDomain(), content.ContentType.Alias)) { e.Messages.Add(new EventMessage("Success", "Static error page updated", EventMessageType.Info)); content.SetValue(PropertyAliases.StaticPage, string.Format("/{0}.aspx", content.ContentType.Alias)); } else { e.Messages.Add(new EventMessage("Error", "Failure updating static error page", EventMessageType.Error)); } } else { e.Messages.Add(new EventMessage("Warning", "Publish again to update static error page", EventMessageType.Warning)); } }
/// <summary> /// Call methods for tinifing when upload image /// </summary> /// <param name="mediaItemId">Media Item Id</param> /// <param name="e">CancellableEventArgs</param> private async System.Threading.Tasks.Task OptimizeOnUploadAsync(int mediaItemId, CancellableEventArgs e) { TImage image; try { image = _imageService.GetImage(mediaItemId); } catch (NotSupportedExtensionException ex) { e.Messages.Add(new EventMessage(PackageConstants.ErrorCategory, ex.Message, EventMessageType.Error)); throw; } var imageHistory = _historyService.GetImageHistory(image.Id); if (imageHistory == null) { await _imageService.OptimizeImageAsync(image).ConfigureAwait(false); } }
private void optionsWindow_Close(object sender, CancellableEventArgs e) { SaveModOptions(); }
private void HandleEvent(Dictionary <string, ContentTypeRegistration> eventList, Tentity entity, CancellableEventArgs e, Func <object, IContentBase, HttpContextBase, UmbracoContext, ApplicationContext, CancellableEventArgs, bool> eventDispatcher) { if (eventList.ContainsKey(_getAliasFromContentInstance.Invoke(entity)) && CodeFirstManager.Current.Features.EnableContentEvents) { var instance = _createInstance.Invoke(entity, eventList[_getAliasFromContentInstance.Invoke(entity)]); (instance as CodeFirstContentBase).NodeDetails = (ContentNodeDetails)typeof(Tnodedetails).GetConstructor(new Type[] { entity.GetType() }).Invoke(new object[] { entity }); if (e.CanCancel) { e.Cancel |= !eventDispatcher.Invoke(instance, entity, new HttpContextWrapper(HttpContext.Current), UmbracoContext.Current, ApplicationContext.Current, e); } else { eventDispatcher.Invoke(instance, entity, new HttpContextWrapper(HttpContext.Current), UmbracoContext.Current, ApplicationContext.Current, e); } _mapModelToContent.Invoke(entity, (instance as CodeFirstContentBase <Tnodedetails>), eventList[_getAliasFromContentInstance.Invoke(entity)]); } }
public virtual bool OnCopy(Tdocument model, IContentBase contentInstance, HttpContextBase httpContext, UmbracoContext umbContext, ApplicationContext appContext, CancellableEventArgs e) { return(true); }
private void KamikazeRobot_Died(object sender, CancellableEventArgs e) { ((SelfService)Arme).STOP = true; }
internal static bool OnUnpublishObject(object model, IContentBase contentInstance, HttpContextBase httpContext, UmbracoContext umbContext, ApplicationContext appContext, CancellableEventArgs e) { return(OnEvent("OnUnpublish", model, contentInstance, httpContext, umbContext, appContext, e)); }
private static bool OnEvent(string eventName, object model, IContentBase contentInstance, HttpContextBase httpContext, UmbracoContext umbContext, ApplicationContext appContext, CancellableEventArgs e) { if (model.GetType().Inherits <CodeFirstContentBase>()) { return((bool)typeof(ModelEventDispatcher <>) .MakeGenericType(model.GetType()) .GetTypeInfo() .InvokeMember(eventName, BindingFlags.Static | BindingFlags.NonPublic | BindingFlags.InvokeMethod, null, null, new object[] { model, contentInstance, httpContext, umbContext, appContext, e })); } else { throw new CodeFirstException("Not a valid model type"); } }
/// <summary> /// An event raised whenever an instance of the QuestionSet document type is created. The method /// sets some default values on the document instance. /// </summary> public bool OnCreate(QuestionSet model, IContentBase contentInstance, HttpContextBase httpContext, UmbracoContext umbContext, ApplicationContext appContext, CancellableEventArgs e) { model.Content.WelcomeParagraph = new RichtextEditor() { Value = "Welcome to the new question set" }; model.NodeDetails.Name = "New question set"; return(true); }