public virtual ActionResult UpdateWidgetLookAndFeel(WidgetLookAndFeelModel model)
        {
            bool isSuccessed = false;

            if (ModelState.IsValid)
            {
                var widgetSettingService         = ServiceLocator.Current.GetInstance <IPageWidgetSettingService>();
                PageWidgetSettings widgetSetting = widgetSettingService.Find(model.SettingId) ??
                                                   new PageWidgetSettings
                {
                    Id     = model.SettingId,
                    Widget = new PageWidget {
                        Id = model.WidgetId
                    }
                };
                widgetSetting   = model.MapTo(widgetSetting);
                isSuccessed     = widgetSettingService.Save(widgetSetting);
                model.SettingId = widgetSetting.Id;
            }
            if (isSuccessed)
            {
                Success(Translate("Messages.Success"));
            }
            else
            {
                Error(Translate("Messages.UnknownError"));
            }

            return(PartialView(MVC.Shared.Views.Widgets.WidgetLookAndFeelForm, model));
        }
        public virtual ActionResult ShowWidgetCSS(long pageWidgetId)
        {
            var                widgetService = ServiceLocator.Current.GetInstance <IPageWidgetService>();
            PageWidget         widget        = widgetService.Find(pageWidgetId);
            PageWidgetSettings widgetSetting = widget.Settings ?? new PageWidgetSettings {
                Widget = widget
            };

            return(PartialView(MVC.Shared.Views.Widgets.WidgetCSSSettings, new WidgetCSSModel().MapFrom(widgetSetting)));
        }
示例#3
0
        public static String GetWidgetStyles(PageWidgetSettings settings)
        {
            var builder = new StringBuilder();

            if (settings != null)
            {
                if (settings.LookAndFeelSettings.WidthValue.HasValue && !String.IsNullOrEmpty(settings.LookAndFeelSettings.WidthUnit))
                {
                    builder.AppendFormat("width:{0}{1};", settings.LookAndFeelSettings.WidthValue, settings.LookAndFeelSettings.WidthUnit);
                }
            }
            return(builder.ToString());
        }
示例#4
0
        public static String GetWidgetHolderStyles(PageWidgetSettings settings)
        {
            var builder = new StringBuilder();

            if (settings != null)
            {
                AppendStyleString(builder, "background-color", settings.LookAndFeelSettings.BackgroundColor);
                AppendStyleString(builder, "font-family", settings.LookAndFeelSettings.FontFamily);
                AppendStyleString(builder, "color", settings.LookAndFeelSettings.Color);
                if (settings.LookAndFeelSettings.FontSizeValue.HasValue && !String.IsNullOrEmpty(settings.LookAndFeelSettings.FontSizeUnit))
                {
                    builder.AppendFormat("font-size:{0}{1};", settings.LookAndFeelSettings.FontSizeValue, settings.LookAndFeelSettings.FontSizeUnit);
                }
                if (settings.LookAndFeelSettings.HeightValue.HasValue && !String.IsNullOrEmpty(settings.LookAndFeelSettings.HeightUnit))
                {
                    builder.AppendFormat("height:{0}{1};", settings.LookAndFeelSettings.HeightValue, settings.LookAndFeelSettings.HeightUnit);
                }
            }
            return(builder.ToString());
        }