Exemple #1
0
        public ActionResult GetResources(string themeName)
        {
            if (string.IsNullOrWhiteSpace(themeName))
            {
                return(this.Failed("Invalid theme name", HttpStatusCode.BadRequest));
            }

            string tenant = DbConvention.GetTenant();
            string path   = $"~/Tenants/{tenant}/Areas/Frapid.WebsiteBuilder/Themes/{themeName}/";

            path = HostingEnvironment.MapPath(path);

            if (path == null || !Directory.Exists(path))
            {
                return(this.Failed("Path not found", HttpStatusCode.NotFound));
            }

            var resource = ThemeResource.Get(path);

            resource = ThemeResource.NormalizePath(path, resource);

            string json = JsonConvert.SerializeObject(resource, Formatting.None,
                                                      new JsonSerializerSettings {
                ContractResolver = new CamelCasePropertyNamesContractResolver()
            });

            return(this.Content(json, "application/json"));
        }
        public AppearanceManagerViewModel(IAppearanceSettings settings)
        {
            _settings = settings;

            _themes        = new ObservableCollection <ThemeResource>(AppearanceManager.GetThemes());
            _selectedTheme = (from t in _themes where t.Name == _settings.Theme select t).FirstOrDefault();

            if (_selectedTheme == null)
            {
                SelectedTheme = CurrentTheme;
            }
            SelectedTheme.Apply();

            _accents         = new ObservableCollection <AccentResource>(AppearanceManager.GetAccents());
            _accentGroups    = new ObservableCollection <string>((from a in _accents orderby a.SortOrder ascending select a.AccentGroup).Distinct().ToList());
            _accentGroupings = new CollectionViewSource {
                Source = _accents
            };
            _accentGroupings.Filter += AccentGroupingsOnFilter;
            _accentGroupings.SortDescriptions.Add(new SortDescription("SortOrder", ListSortDirection.Ascending));

            _selectedAccent = (from a in _accents where a.Name == _settings.Accent select a).FirstOrDefault();

            if (_selectedAccent == null)
            {
                SelectedAccent = CurrentAccent;
            }
            SelectedAccent.Apply();

            ApplyCommand  = new DelegateCommand(Apply, CanExecuteApply);
            CancelCommand = new DelegateCommand(Cancel, CanExecuteCancel);
        }
Exemple #3
0
        public static ThemeResource CreateThemeResource(this ResourceDictionary resourceDictionary, string resourceKey)
        {
            var resource      = resourceDictionary[resourceKey];
            var themeResource = new ThemeResource
            {
                Key   = resourceKey,
                Value = resource
            };

            return(themeResource);
        }
Exemple #4
0
        internal void ChangeTheme(ThemeResource theme)
        {
            var currentTheme = this.Resources.MergedDictionaries
                               .OfType <ThemeResourceDictionary>().FirstOrDefault();
            var newTheme = ThemeResourceDictionary.GetInstance(theme);

            if (newTheme == currentTheme)
            {
                return;
            }

            // テーマリソースの差し替え
            if (currentTheme != null)
            {
                this.Resources.MergedDictionaries.Remove(currentTheme);
            }

            if (newTheme != null)
            {
                this.Resources.MergedDictionaries.Add(newTheme);
            }


            // 外部リソースの差し替え
            // ※スタイルリソースのBasedOnはインスタンス化時に読み込まれるため、
            //   毎回インスタンス化する必要がある。
            foreach (var resType in ExternalResourceTypes)
            {
                var currentRes = this.Resources.MergedDictionaries.FirstOrDefault(dic => resType.IsInstanceOfType(dic));
                if (currentRes != null)
                {
                    this.Resources.MergedDictionaries.Remove(currentRes);
                }

                var newRes = resType.GetConstructor(Type.EmptyTypes).Invoke(null) as ResourceDictionary;
                this.Resources.MergedDictionaries.Add(newRes);
            }
        }
        public Theme DeserializeGet(string value)
        {
            var repository = new ThemeResource(new TictailClientTest(), "abc");

            return(repository.DeserializeGet(value));
        }
Exemple #6
0
 protected override void OnPreRender(EventArgs e)
 {
     base.OnPreRender(e);
     this.modalPopupExtender.BehaviorID = this.modalPopupExtender.ClientID + "_behavior";
     this.imgProgressIndicator.ImageUrl = ThemeResource.GetThemeResource(this, "progress.gif");
 }
 public ThemeResourceExtension(ThemeResource resourceKey)
 {
     ValidationHelper.NotNull(resourceKey, "resourceKey");
     _resourceKey = resourceKey;
 }
 internal static void ExtensionGetPostAction(bool isOrgScope, DataRow inputRow, DataTable dataTable, DataObjectStore store)
 {
     foreach (object obj in dataTable.Rows)
     {
         DataRow       dataRow       = (DataRow)obj;
         ExtensionType extensionType = (ExtensionType)dataRow["Type"];
         if (ExtensionType.MarketPlace == extensionType)
         {
             dataRow["IsMarketplaceExtension"] = true;
             string text = string.Format("{0}?app={1}&ver={2}&clid={3}&p1={4}&p2={5}&p3={6}&p4={7}&p5={8}&Scope={9}&CallBackURL={10}&DeployId={11}", new object[]
             {
                 ExtensionUtility.MarketplaceLandingPageUrl,
                 ExtensionUtility.Application,
                 ExtensionUtility.Version,
                 Util.GetLCIDInDecimal(),
                 ExtensionUtility.ClientFullVersion,
                 ExtensionUtility.ClickContext,
                 ExtensionUtility.DefaultInputForQueryString,
                 ExtensionUtility.EndNodeTargetCode,
                 dataRow["MarketplaceContentmarket"] + "\\" + dataRow["MarketplaceAssetID"],
                 isOrgScope ? ExtensionUtility.OrganizationInstallScope : ExtensionUtility.UserInstallScope,
                 isOrgScope ? ExtensionUtility.UrlEncodedOfficeCallBackUrlForOrg : ExtensionUtility.UrlEncodedOfficeCallBackUrl,
                 ExtensionUtility.DeploymentId
             });
             string myAppsPageLink = string.Format("{0}?app={1}&ver={2}&clid={3}&p1={4}&p2={5}&p3={6}&p4={7}&p5={8}&Scope={9}&CallBackURL={10}&DeployId={11}", new object[]
             {
                 ExtensionUtility.MyAppsPageUrl,
                 ExtensionUtility.Application,
                 ExtensionUtility.Version,
                 Util.GetLCIDInDecimal(),
                 ExtensionUtility.ClientFullVersion,
                 ExtensionUtility.ClickContext,
                 ExtensionUtility.DefaultInputForQueryString,
                 ExtensionUtility.EndNodeTargetCode,
                 dataRow["MarketplaceContentmarket"] + "\\" + dataRow["MarketplaceAssetID"],
                 isOrgScope ? ExtensionUtility.OrganizationInstallScope : ExtensionUtility.UserInstallScope,
                 isOrgScope ? ExtensionUtility.UrlEncodedOfficeCallBackUrlForOrg : ExtensionUtility.UrlEncodedOfficeCallBackUrl,
                 ExtensionUtility.DeploymentId
             });
             string directCallbackLink = string.Format("{0}&Scope={1}&lc={2}&clientToken={3}&AssetId={4}", new object[]
             {
                 isOrgScope?ExtensionUtility.OfficeCallBackUrlForOrg: ExtensionUtility.OfficeCallBackUrl,
                 isOrgScope ? ExtensionUtility.OrganizationInstallScope : ExtensionUtility.UserInstallScope,
                 dataRow["MarketplaceContentmarket"],
                 dataRow["Etoken"],
                 dataRow["MarketplaceAssetID"]
             });
             dataRow["DetailsUrl"] = text;
             dataRow["ReviewUrl"]  = string.Format("{0}?app={1}&ver={2}&clid={3}&p1={4}&p2={5}&p3={6}&p4={7}&p5={8}&Scope={9}&CallBackURL={10}&DeployId={11}", new object[]
             {
                 ExtensionUtility.MarketplaceLandingPageUrl,
                 ExtensionUtility.Application,
                 ExtensionUtility.Version,
                 Util.GetLCIDInDecimal(),
                 ExtensionUtility.ClientFullVersion,
                 ExtensionUtility.ClickContext,
                 ExtensionUtility.DefaultInputForQueryString,
                 ExtensionUtility.ReviewsTargetCode,
                 dataRow["MarketplaceContentMarket"] + "\\" + dataRow["MarketplaceAssetID"],
                 isOrgScope ? ExtensionUtility.OrganizationInstallScope : ExtensionUtility.UserInstallScope,
                 isOrgScope ? ExtensionUtility.UrlEncodedOfficeCallBackUrlForOrg : ExtensionUtility.UrlEncodedOfficeCallBackUrl,
                 ExtensionUtility.DeploymentId
             });
             string text2 = (dataRow["AppStatus"] != null && !DBNull.Value.Equals(dataRow["AppStatus"])) ? ((string)dataRow["AppStatus"]) : string.Empty;
             if (!string.IsNullOrWhiteSpace(text2))
             {
                 dataRow["ShowNotification"] = true;
                 ExtensionUtility.SetErrorDescriptionAndNotificationLink(text2, dataRow, text, directCallbackLink, myAppsPageLink);
             }
             string value = (dataRow["LicenseType"] != null && !DBNull.Value.Equals(dataRow["LicenseType"])) ? ((string)dataRow["LicenseType"]) : string.Empty;
             if (Microsoft.Exchange.Management.Extension.LicenseType.Trial.ToString().Equals(value, StringComparison.OrdinalIgnoreCase))
             {
                 dataRow["ShowTrialReminder"]           = true;
                 dataRow["TrialReminderActionLinkUrl"]  = text;
                 dataRow["ShowTrialReminderActionLink"] = true;
             }
         }
         ExtensionInstallScope extensionInstallScope = (ExtensionInstallScope)dataRow["Scope"];
         if (isOrgScope)
         {
             dataRow["ExtensionCanBeUninstalled"] = (extensionInstallScope == ExtensionInstallScope.Organization);
             dataRow["ShowEnableDisable"]         = true;
         }
         else
         {
             dataRow["ExtensionCanBeUninstalled"] = (extensionInstallScope == ExtensionInstallScope.User);
             DefaultStateForUser?defaultStateForUser = dataRow["DefaultStateForUser"] as DefaultStateForUser?;
             if (defaultStateForUser != null && defaultStateForUser.Value == DefaultStateForUser.AlwaysEnabled)
             {
                 dataRow["ExtensionCanNotBeUninstalledMessage"] = OwaOptionStrings.ExtensionCanNotBeDisabledNorUninstalled;
                 dataRow["ShowEnableDisable"] = false;
             }
             else
             {
                 dataRow["ExtensionCanNotBeUninstalledMessage"] = OwaOptionStrings.ExtensionCanNotBeUninstalled;
                 dataRow["ShowEnableDisable"] = true;
             }
             if (extensionInstallScope == ExtensionInstallScope.Organization)
             {
                 dataRow["ShowNotificationLink"]        = false;
                 dataRow["ShowTrialReminderActionLink"] = false;
             }
         }
         if (dataRow["IconURL"].IsNullValue())
         {
             string themeResource = ThemeResource.GetThemeResource(ExtensionUtility.pagesSection.Theme, "extensiondefaulticon.png");
             dataRow["IconURL"] = new Uri(themeResource);
         }
     }
 }
Exemple #9
0
 public static string ToUrl(this CssFiles.CssFile cssFile, Control control)
 {
     return(ThemeResource.GetThemeResource(control, (RtlUtil.IsRtl && cssFile.RtlFileName != null) ? cssFile.RtlFileName : cssFile.FileName));
 }
Exemple #10
0
 private static void OutputCssLink(Control control, CssFiles.CssFile cssFile, bool isRtl)
 {
     CssFiles.OutputCssLink(control.Page.Response.Output, ThemeResource.GetThemeResource(control.Page, (isRtl && cssFile.RtlFileName != null) ? cssFile.RtlFileName : cssFile.FileName));
 }
Exemple #11
0
 public ListItem(ThemeResource res, string desc)
 {
     Theme       = res;
     Description = desc;
 }