Ejemplo n.º 1
0
        /// <summary>Displays the specified notification</summary>
        /// <param name="text">Main text</param>
        /// <param name="text2">Secondary text</param>
        /// <param name="number">Numeric information (such as an item count) passed as a string</param>
        /// <param name="imageResource">Generic image resource to load a brush from (if this parameter is passed an the resource is found the image parameter is ignored)</param>
        /// <param name="image">A logo image (passed as a brush).</param>
        /// <param name="model">Notification view model (if passed, text, number, image and overrideTimeout parameters are ignored)</param>
        /// <param name="viewName">Name of a custom view to be used by the status.</param>
        /// <param name="controllerType">Type of the controller (used as a context to find views)</param>
        /// <param name="overrideTimeout">Overrides the theme's default notification timeout. If model is passed, set this property in model.</param>
        public static void Notification(string text = "", string text2 = "", string number = "", string imageResource = "", Brush image = null, NotificationViewModel model = null, string viewName = "", Type controllerType = null, TimeSpan? overrideTimeout = null)
        {
            var context = new RequestContext(new RouteData("NotificationMessage", new {viewName = string.Empty}));

            // If a controller type was specified, we try to use it, which provides a context to find views
            Controller controller;
            if (controllerType == null) controller = new Controller();
            else controller = Activator.CreateInstance(controllerType) as Controller;
            if (controller == null) controller = new Controller();
            context.ProcessingController = controller;

            context.Result = controller.NotificationMessage(viewName, text, text2, number, imageResource, image, model, overrideTimeout);

            ExecuteViewHandlers(context);
        }
Ejemplo n.º 2
0
        /// <summary>Displays the specified notification</summary>
        /// <param name="viewName">Name of a custom view to be used by the status.</param>
        /// <param name="text">Main text</param>
        /// <param name="text2">Secondary text</param>
        /// <param name="number">Numeric information (such as an item count) passed as a string</param>
        /// <param name="imageResource">Generic image resource to load a brush from (if this parameter is passed an the resource is found the image parameter is ignored)</param>
        /// <param name="image">A logo image (passed as a brush).</param>
        /// <param name="model">Notification view model (if passed, text, number, image and overrideTimeout parameters are ignored)</param>
        /// <param name="overrideTimeout">Overrides the theme's default notification timeout. If model is passed, set this property in model.</param>
        protected NotificationMessageResult NotificationMessage(string viewName = "", string text = "", string text2 = "", string number = "", string imageResource = "", Brush image = null, NotificationViewModel model = null, TimeSpan? overrideTimeout = null)
        {
            if (model == null)
            {
                model = new NotificationViewModel {Text1 = text, Text2 = text2, Number1 = number, OverrideTimeout = overrideTimeout};
                if (!string.IsNullOrEmpty(imageResource))
                {
                    var resource = Application.Current.FindResource(imageResource);
                    if (resource != null) model.Logo1 = resource as Brush;
                }
                if (model.Logo1 == null && image != null) model.Logo1 = image;
            }

            var result = new NotificationMessageResult {Model = model};

            FindView(viewName, ViewLevel.Normal, result);

            return result;
        }
Ejemplo n.º 3
0
 /// <summary>Displays the specified notification</summary>
 /// <param name="text">Main text</param>
 /// <param name="text2">Secondary text</param>
 /// <param name="number">Numeric information (such as an item count) passed as a string</param>
 /// <param name="imageResource">Generic image resource to load a brush from (if this parameter is passed an the resource is found the image parameter is ignored)</param>
 /// <param name="image">A logo image (passed as a brush).</param>
 /// <param name="model">Notification view model (if passed, text, number, image and overrideTimeout parameters are ignored)</param>
 /// <param name="standardView">Standard view to display</param>
 /// <param name="controllerType">Type of the controller (used as a context to find views)</param>
 /// <param name="overrideTimeout">Overrides the theme's default notification timeout. If model is passed, set this property in model.</param>
 public static void Notification(StandardViews standardView, string text = "", string text2 = "", string number = "", string imageResource = "", Brush image = null, NotificationViewModel model = null, Type controllerType = null, TimeSpan? overrideTimeout = null)
 {
     var viewName = "CODEFrameworkStandardView" + standardView;
     Notification(text, text2, number, imageResource, image, model, viewName, controllerType, overrideTimeout);
 }