Exemplo n.º 1
0
 public override void ThemeChanged()
 {
     ThemeConfiguration.SetColorScheme(this);
     ThemeConfiguration.SetColorScheme(log);
     ThemeConfiguration.SetColorScheme(od);
     ThemeConfiguration.SetColorScheme(help);
     ThemeConfiguration.SetColorScheme(ac);
 }
        protected string GetLayout(string theme = "")
        {
            if (string.IsNullOrWhiteSpace(theme))
            {
                theme = this.GetTheme();
            }

            return(ThemeConfiguration.GetLayout(this.Tenant, theme));
        }
Exemplo n.º 3
0
        protected string GetHomepageLayout(string theme = "")
        {
            if (string.IsNullOrWhiteSpace(theme))
            {
                theme = GetTheme();
            }

            return(ThemeConfiguration.GetHomepageLayout(theme));
        }
Exemplo n.º 4
0
        public override void InitHelpers()
        {
            base.InitHelpers();
            //_localizationService = EngineContext.Current.Resolve<ILocalizationService>();
            _workContext          = EngineContext.Current.Resolve <IWorkContext>();
            _systemSettingService = EngineContext.Current.Resolve <ISystemSettingService>();

            _themeContext       = EngineContext.Current.Resolve <IThemeContext>();
            _themeConfiguration = _themeContext.CurrentThemeConfiguration;
        }
Exemplo n.º 5
0
 public void Run()
 {
     this.currentConfiguration = this.GetOrCreateThemeConfiguration();
     // MahApps.Metro.ThemeManager.InvalidateSystemResourcesOnBackgroundThread = true;
     ApplyConfiguration(this.currentConfiguration);
     using (var reg = new ThemeRegistrySettings())
     {
         FlyoutTheme = reg.FlyoutTheme;
     }
 }
Exemplo n.º 6
0
        public async Task <ActionResult> HomeAsync(int pageNumber = 1)
        {
            try
            {
                if (pageNumber <= 0)
                {
                    pageNumber = 1;
                }

                var awaiter = await ContentModel.GetBlogContentsAsync(this.Tenant, pageNumber).ConfigureAwait(true);

                var contents = awaiter?.ToList() ?? new List <Content>();

                if (!contents.Any())
                {
                    return(this.View(GetLayoutPath(this.Tenant) + "404.cshtml"));
                }

                foreach (var content in contents)
                {
                    content.Contents =
                        await ContentExtensions.ParseHtmlAsync(this.Tenant, content.Contents).ConfigureAwait(false);
                }

                string theme  = this.GetTheme();
                string layout = ThemeConfiguration.GetBlogLayout(this.Tenant, theme).Or(ThemeConfiguration.GetLayout(this.Tenant, theme));

                var configuration = await Configurations.GetDefaultConfigurationAsync(this.Tenant).ConfigureAwait(false);

                var model = new Blog
                {
                    Contents   = contents,
                    LayoutPath = GetLayoutPath(this.Tenant),
                    Layout     = layout
                };

                if (configuration != null)
                {
                    model.Title       = configuration.BlogTitle;
                    model.Description = configuration.BlogDescription;
                }

                return(this.View(this.GetRazorView <AreaRegistration>("Frontend/Blog/Home.cshtml", this.Tenant), model));
            }
            catch (NpgsqlException ex)
            {
                Log.Error($"An exception was encountered while trying to get blog contents. Exception: {ex}");
            }

            return(null);
        }
Exemplo n.º 7
0
        public static ThemeConfiguration GetDefaultThemeConfiguration()
        {
            var DefaultBackground = Color.FromArgb(100, 75, 75, 75);
            var DefaultFont       = new Font("segoe ui", 11);
            var random            = new Random(3);
            var themeConfig       = new ThemeConfiguration();

            foreach (var item in GetRegisteredNodes())
            {
                var code = Color.FromArgb(255, Color.FromArgb(random.Next()));

                var ItemHeaderColor = code;

                themeConfig.Directory.Add(item.Type(), new Theme()
                {
                    BackColor       = DefaultBackground,
                    Border          = true,
                    HeaderColor     = ItemHeaderColor,
                    BorderThickness = 2,
                    BorderColor     = Color.FromArgb(100, Color.White),
                    CornerRadius    = 10,
                    Forecolor       = Color.White,
                    Font            = DefaultFont,
                    FocusedTheme    = new Theme()
                    {
                        BackColor       = DefaultBackground,
                        Border          = true,
                        HeaderColor     = ItemHeaderColor,
                        BorderThickness = 2,
                        BorderColor     = Color.FromArgb(100, Color.Black),
                        CornerRadius    = 10,
                        Forecolor       = Color.White,
                        Font            = DefaultFont
                    },
                    HoverTheme = new Theme()
                    {
                        BackColor       = Color.FromArgb(100, DefaultBackground),
                        Border          = true,
                        HeaderColor     = ItemHeaderColor,
                        BorderThickness = 2,
                        BorderColor     = Color.FromArgb(100, Color.White),
                        CornerRadius    = 10,
                        Forecolor       = Color.White,
                        Font            = DefaultFont
                    }
                });
            }

            return(themeConfig);
        }
Exemplo n.º 8
0
        public ActionResult Home(int pageNumber = 1)
        {
            try
            {
                if (pageNumber <= 0)
                {
                    pageNumber = 1;
                }

                var contents = ContentModel.GetBlogContents(pageNumber);

                if (contents == null || !contents.Any())
                {
                    return(this.View(GetLayoutPath() + "404.cshtml"));
                }

                foreach (var content in contents)
                {
                    content.Contents = ContentExtensions.ParseHtml(this.Tenant, content.Contents);
                }

                string theme         = this.GetTheme();
                string layout        = ThemeConfiguration.GetBlogLayout(theme);
                var    configuration = Configurations.GetDefaultConfiguration();

                var model = new Blog
                {
                    Contents   = contents,
                    LayoutPath = GetLayoutPath(),
                    Layout     = layout
                };

                if (configuration != null)
                {
                    model.Title       = configuration.BlogTitle;
                    model.Description = configuration.BlogDescription;
                }

                return(this.View(this.GetRazorView <AreaRegistration>("Blog/Home.cshtml"), model));
            }
            catch (NpgsqlException ex)
            {
                Log.Error($"An exception was encountered while trying to get blog contents. Exception: {ex}");
            }

            return(null);
        }
Exemplo n.º 9
0
        private ThemeConfiguration GetOrCreateThemeConfiguration()
        {
            using (var context = dbContext())
            {
                var themeconfig = context.ThemeConfigurations.FirstOrDefault(x => x.Name == "default");
                if (themeconfig == null)
                {
                    var theme = MahApps.Metro.ThemeManager.DetectAppStyle(Application.Current);
                    themeconfig = new ThemeConfiguration {
                        Name = "default", Accent = theme.Item2.Name, Theme = theme.Item1.Name
                    };
                    context.ThemeConfigurations.Add(themeconfig);
                    context.SaveChanges();
                }

                return(themeconfig);
            }
        }
Exemplo n.º 10
0
        public ActionResult Post(string categoryAlias, string alias)
        {
            var model = ContentModel.GetContent(this.Tenant, categoryAlias, alias, true);

            if (model == null)
            {
                return(this.View(GetLayoutPath() + "404.cshtml"));
            }

            string path   = GetLayoutPath();
            string theme  = this.GetTheme();
            string layout = ThemeConfiguration.GetBlogLayout(theme);

            model.LayoutPath = path;
            model.Layout     = layout;
            model.Contents   = ContentExtensions.ParseHtml(this.Tenant, model.Contents);

            return(this.View(this.GetRazorView <AreaRegistration>("Blog/Post.cshtml"), model));
        }
Exemplo n.º 11
0
        public async Task <ActionResult> PostAsync(string categoryAlias, string alias)
        {
            var model = await ContentModel.GetContentAsync(this.Tenant, categoryAlias, alias, true).ConfigureAwait(true);

            if (model == null)
            {
                return(this.View(GetLayoutPath(this.Tenant) + "404.cshtml"));
            }

            string path   = GetLayoutPath(this.Tenant);
            string theme  = this.GetTheme();
            string layout = ThemeConfiguration.GetBlogLayout(this.Tenant, theme).Or(ThemeConfiguration.GetLayout(this.Tenant, theme));

            model.LayoutPath = path;
            model.Layout     = layout;
            model.Contents   = await ContentExtensions.ParseHtmlAsync(this.Tenant, model.Contents).ConfigureAwait(true);

            return(this.View(this.GetRazorView <AreaRegistration>("Frontend/Blog/Post.cshtml", this.Tenant), model));
        }
Exemplo n.º 12
0
        public void ApplyConfiguration(ThemeConfiguration themeConfiguration = null)
        {
            if (themeConfiguration == null)
            {
                themeConfiguration = CurrentConfiguration;
            }

            var currenttheme = MahApps.Metro.ThemeManager.DetectAppStyle(Application.Current);
            var theme        = MahApps.Metro.ThemeManager.AppThemes.FirstOrDefault(x => x.Name == themeConfiguration.Theme);

            if (theme == null)
            {
                theme = currenttheme.Item1;
            }
            var accent = MahApps.Metro.ThemeManager.Accents.FirstOrDefault(x => x.Name == themeConfiguration.Accent);

            if (accent == null)
            {
                accent = currenttheme.Item2;
            }

            MahApps.Metro.ThemeManager.ChangeAppStyle(Application.Current, accent, theme);
        }
Exemplo n.º 13
0
        public ThemeConfiguration GetTenantThemeConfiguration(Tenant tenant)
        {
            ThemeConfiguration config = _themeConfigs.SingleOrDefault(x => x.ThemeName.Equals(defaultTheme, StringComparison.InvariantCultureIgnoreCase));

            var _tenantSetting = _settingService.LoadSetting <TenantSettings>();

            if (!string.IsNullOrEmpty(_tenantSetting.DefaultTheme))
            {
                var tenantID    = tenant.ID.ToString();
                var themeName   = _tenantSetting.DefaultTheme;
                var themeConfig = _themeConfigs
                                  .SingleOrDefault(x =>
                                                   (x.AvailableToTenants.Any(a => a == "*") || x.AvailableToTenants.Any(a => a == tenantID)) &&
                                                   x.ThemeName.Equals(themeName, StringComparison.InvariantCultureIgnoreCase));

                if (themeConfig != null && !string.IsNullOrEmpty(themeConfig.ThemeName))
                {
                    config = themeConfig;
                }
            }

            return(config);
        }
Exemplo n.º 14
0
        private void MainWindow_Load(object sender, EventArgs e)
        {
            Program.trayIcon    = new TrayIcon();
            Program.OnShutdown += Program.trayIcon.Dispose;
            Program.OnShutdown += LogCenter.Instance.Kill;
            Program.updater     = new Updates.UpdateChecker();
            Program.updater.Updater();
            Program.OnShutdown += Program.updater.Close;
            // call the log purger
            LogCenter.Instance.CleanLogs();

            log      = new LogDisplay();
            log.Dock = DockStyle.Fill;

            splitContainer1.Panel2.Controls.Add(log);

            // load up the adapter control handler
            ac      = new AdapterControl();
            ac.Dock = DockStyle.Fill;

            // load up the options tab handler
            od      = new OptionsDisplay();
            od.Dock = DockStyle.Fill;

            // load up the options tab handler
            help      = new Help();
            help.Dock = DockStyle.Fill;

            MainWindow_Resize(null, null);
            if (GeneralConfiguration.Instance.StartMinimized)
            {
                this.WindowState = FormWindowState.Minimized;
            }
            splitContainer1.Panel1.BackgroundImage = ThemeConfiguration.GetCurrentBanner();
            ThemeChanged();
        }
Exemplo n.º 15
0
        private ThemeConfiguration GetOrCreateThemeConfiguration()
        {
            using (var context = dbContext())
            {
                var themeconfig = context.ThemeConfigurations.FirstOrDefault(x => x.Name == "default");
                if (themeconfig == null)
                {
                    var theme = MahApps.Metro.ThemeManager.DetectAppStyle(Application.Current);
                    themeconfig = new ThemeConfiguration { Name = "default", Accent = theme.Item2.Name, Theme = theme.Item1.Name };
                    context.ThemeConfigurations.Add(themeconfig);
                    context.SaveChanges();
                }

                return themeconfig;
            }
        }
Exemplo n.º 16
0
        private string GetLayoutFile()
        {
            string theme = Configuration.GetDefaultTheme(this.Tenant);

            return(ThemeConfiguration.GetLayout(this.Tenant, theme));
        }
Exemplo n.º 17
0
        public void ApplyConfiguration(ThemeConfiguration themeConfiguration = null)
        {
            if (themeConfiguration == null)
            {
                themeConfiguration = CurrentConfiguration;
            }

            var currenttheme = MahApps.Metro.ThemeManager.DetectAppStyle(Application.Current);
            var theme = MahApps.Metro.ThemeManager.AppThemes.FirstOrDefault(x => x.Name == themeConfiguration.Theme);
            if (theme == null)
            {
                theme = currenttheme.Item1;
            }
            var accent = MahApps.Metro.ThemeManager.Accents.FirstOrDefault(x => x.Name == themeConfiguration.Accent);
            if (accent == null)
            {
                accent = currenttheme.Item2;
            }

            MahApps.Metro.ThemeManager.ChangeAppStyle(Application.Current, accent, theme);
        }
Exemplo n.º 18
0
 public void Run()
 {
     currentConfiguration = GetOrCreateThemeConfiguration();
     // MahApps.Metro.ThemeManager.InvalidateSystemResourcesOnBackgroundThread = true;
     ApplyConfiguration(currentConfiguration);
     using (var reg = new ThemeRegistrySettings())
     {
         FlyoutTheme = reg.FlyoutTheme;
     }
 }
Exemplo n.º 19
0
 public virtual void ThemeChanged()
 {
     ThemeConfiguration.SetColorScheme(this);
 }
Exemplo n.º 20
0
 public ThemeProvider(IJSRuntime jSRuntime, ThemeConfiguration themeConfiguration)
 {
     _jSRuntime    = jSRuntime;
     _themes       = themeConfiguration.Themes;
     _defaultTheme = themeConfiguration.DefaultTheme;
 }
Exemplo n.º 21
0
 public override void ThemeChanged()
 {
     ThemeConfiguration.SetColorScheme(this);
 }