示例#1
0
        public SettingsWindowViewModel()
        {
            var connectionString = App.GetConnectionString();

            _dataAdapter = new SettingsDataAdapter(connectionString);
            _watchedApplicationDataAdapter = new WatchedApplicationDataAdapter(connectionString);
            _languageDataAdapter           = new ApplicationLanguageDataAdapter(connectionString);
            Settings  = SettingsViewModelFactory.GetSettings(_dataAdapter, _watchedApplicationDataAdapter, _languageDataAdapter);
            _controls = new Dictionary <string, UserControl>();

            var viewKey = ChamiUIStrings.ViewCategory;

            _controls[viewKey] = new ConsoleAppearanceEditor(Settings.ConsoleAppearanceSettings);
            var loggingKey = ChamiUIStrings.LoggingCategory;

            _controls[loggingKey] = new LoggingSettingsEditor(Settings.LoggingSettings);
            var safetyKey = ChamiUIStrings.SafetyCategory;

            _controls[safetyKey] = new SafeVariableEditor(Settings.SafeVariableSettings);
            var detectorKey = ChamiUIStrings.DetectorCategory;

            _controls[detectorKey] = new ApplicationDetectorControl(Settings.WatchedApplicationSettings);
            var languageKey = ChamiUIStrings.LanguageCategory;

            _controls[languageKey] = new LanguageSelectorControl(Settings.LanguageSettings);
            DisplayedControl       = _controls.Values.FirstOrDefault();
            var minimizationKey = ChamiUIStrings.MinimizationCategory;

            _controls[minimizationKey] = new MinimizationBehaviourControl(Settings.MinimizationBehaviour);
        }
    protected void Page_Init(object sender, EventArgs e)
    {
        string strLanguageSelectorControlPath = ConfigurationManager.AppSettings["LanguageSelectorControl.ascx"];
        ucLanguageSelectorControl = (LanguageSelectorControl)LoadControl(strLanguageSelectorControlPath);

        phLanguageSelectorControl.Controls.Clear();
        phLanguageSelectorControl.Controls.Add(ucLanguageSelectorControl);

        ucLanguageSelectorControl.LanguageSelected += new LanguageSelectorControl.LanguageSelectedEvent(this.LanguageSelected);
    }
    private void LoadLanguageSelectorControl()
    {
        string strLanguageSelectorControlPath = ConfigurationManager.AppSettings["LanguageSelectorControl.ascx"];
        ucLanguageSelectorControl = (LanguageSelectorControl)LoadControl(strLanguageSelectorControlPath);

        phLanguageSelectorControl.Controls.Clear();
        phLanguageSelectorControl.Controls.Add(ucLanguageSelectorControl);

        ucLanguageSelectorControl.LanguageSelected += new LanguageSelectorControl.LanguageSelectedEvent(this.LanguageSelected);

        return;
    }
        private void CreateEducationThemeAndTemplate()
        {
            SampleUtilities.RegisterTheme(SampleConstants.EducationThemeName, SampleConstants.EducationThemePath);
            SampleUtilities.RegisterTheme(SampleConstants.EducationInGermanThemeName, SampleConstants.EducationInGermanThemePath);

            SampleUtilities.RegisterTemplate(new Guid(SampleConstants.EducationTemplateId), SampleConstants.EducationTemplateName, SampleConstants.EducationTemplateName, SampleConstants.EducationTemplateMasterPage, SampleConstants.EducationThemeName, CultureInfo.GetCultureInfo("en"));
            var result = SampleUtilities.RegisterTemplate(new Guid(SampleConstants.EducationTemplateId), SampleConstants.EducationInGermanTemplateName, SampleConstants.EducationInGermanTemplateName, SampleConstants.EducationTemplateMasterPage, SampleConstants.EducationInGermanThemeName, CultureInfo.GetCultureInfo("de"));

            if (result)
            {
                // Main layout
                var mainLayoutControl = new LayoutControl();
                List<ColumnDetails> mainLayoutColumns = new List<ColumnDetails>();
                ColumnDetails mainLayoutColumn1 = new ColumnDetails()
                {
                    ColumnSpaces = new ColumnSpaces(0, 0, 0, 50),
                    ColumnWidthPercentage = 70,
                    PlaceholderId = "Left"
                };
                mainLayoutColumns.Add(mainLayoutColumn1);
                ColumnDetails mainLayoutColumn2 = new ColumnDetails()
                {
                    ColumnWidthPercentage = 30,
                    PlaceholderId = "Right"
                };
                mainLayoutColumns.Add(mainLayoutColumn2);
                mainLayoutControl.Layout = SampleUtilities.GenerateLayoutTemplate(mainLayoutColumns, string.Empty);
                mainLayoutControl.ID = "Header";
                SampleUtilities.AddControlToTemplate(new Guid(SampleConstants.EducationTemplateId), mainLayoutControl, "headerInfo", "Header");

                // Logo
                var logoBlock = new ContentBlock();
                logoBlock.Html = string.Format(@"<h1><a href=""[pages]{0}"">Telerik International University</a></h1> <h3>established 2005, Sofia</h3>", SampleConstants.HomePageId);
                logoBlock.CssClass = "sfContentBlock";
                string logoId = SampleUtilities.AddLocalizedControlToTemplate(new Guid(SampleConstants.EducationTemplateId), logoBlock, "Header_Left", "Content block", "en");

                Dictionary<string, object> logoProperties = new Dictionary<string, object>();

                logoProperties.Add("Html", string.Format(@"<h1><a href=""[pages]{0}"">Internationale Universit&auml;t Telerik</a></h1> <h3>gegr&uuml;ndet im 2005, in Sofia</h3>", SampleConstants.HomePageId));
                SampleUtilities.UpdateLocalizedControlInTemplate(logoId, new Guid(SampleConstants.EducationTemplateId), logoProperties, "de");

                // Language/search layout
                var languagesSearchLayoutControl = new LayoutControl();
                List<ColumnDetails> languagesSearchLayoutColumns = new List<ColumnDetails>();
                ColumnDetails languagesSearchLayoutColumn1 = new ColumnDetails()
                {
                    ColumnSpaces = new ColumnSpaces(0, 0, 0, 0),
                    ColumnWidthPercentage = 46,
                    PlaceholderId = "Left"
                };
                languagesSearchLayoutColumns.Add(languagesSearchLayoutColumn1);
                ColumnDetails languagesSearchLayoutColumn2 = new ColumnDetails()
                {
                    ColumnWidthPercentage = 54,
                    PlaceholderId = "Right"
                };
                languagesSearchLayoutColumns.Add(languagesSearchLayoutColumn2);
                languagesSearchLayoutControl.Layout = SampleUtilities.GenerateLayoutTemplate(languagesSearchLayoutColumns, string.Empty);
                languagesSearchLayoutControl.ID = "LanguageSearch";
                SampleUtilities.AddControlToTemplate(new Guid(SampleConstants.EducationTemplateId), languagesSearchLayoutControl, "Header_Right", "Language and Search");

                // Language
                var languages = new LanguageSelectorControl();
                languages.SelectorType = LanguageSelectorType.Vertical;
                SampleUtilities.AddControlToTemplate(new Guid(SampleConstants.EducationTemplateId), languages, "LanguageSearch_Right", "Language selector");

                // Login layout
                //var loginLayoutControl = new LayoutControl();
                //List<ColumnDetails> loginLayoutColumns = new List<ColumnDetails>();
                //ColumnDetails loginLayoutColumn1 = new ColumnDetails()
                //{
                //    ColumnSpaces = new ColumnSpaces(0, 0, 0, 0),
                //    PlaceholderId = "Center"
                //};
                //loginLayoutColumns.Add(loginLayoutColumn1);
                //loginLayoutControl.Layout = SampleUtilities.GenerateLayoutTemplate(loginLayoutColumns, "login-status");
                //loginLayoutControl.ID = "Login";
                //SampleUtilities.AddControlToTemplate(new Guid(SampleConstants.EducationTemplateId), loginLayoutControl, "Header_Right", "Login");

                //// Login name
                //LoginNameControl loginNameControl = new LoginNameControl();
                //SampleUtilities.AddControlToTemplate(new Guid(SampleConstants.EducationTemplateId), loginNameControl, "Login_Center", "Login name");

                //// Login status
                //LoginStatusControl loginStatusControl = new LoginStatusControl();
                //SampleUtilities.AddControlToTemplate(new Guid(SampleConstants.EducationTemplateId), loginStatusControl, "Login_Center", "Login status");

                // Image
                ImageControl headerImage = new ImageControl();
                headerImage.ImageId = SampleUtilities.GetLocalizedImageId("the_building", "en");
                headerImage.CssClass = "headerImage";
                string controlId = SampleUtilities.AddLocalizedControlToTemplate(new Guid(SampleConstants.EducationTemplateId), headerImage, "image", "Image", "en");

                Dictionary<string, object> properties = new Dictionary<string, object>();
                properties.Add("ImageId", SampleUtilities.GetLocalizedImageId("headerspring1", "de"));
                SampleUtilities.UpdateLocalizedControlInTemplate(controlId, new Guid(SampleConstants.EducationTemplateId), properties, "de");

                // Explore your potentials
                ContentBlockBase exploreContentBlock = new ContentBlockBase();
                exploreContentBlock.Html = @"<h4>Explore your potentials</h4> <p>Share your voice and unlock your potentials while we will equip you with the skills you need for the future!</p>";
                SampleUtilities.AddControlToTemplate(new Guid(SampleConstants.EducationTemplateId), exploreContentBlock, "tagline", "Content block");

                // Header navigation
                var headerNavigationControl = new NavigationControl();
                headerNavigationControl.NavigationMode = NavigationModes.HorizontalSimple;
                headerNavigationControl.SelectionMode = PageSelectionModes.TopLevelPages;
                headerNavigationControl.Skin = "education";
                SampleUtilities.AddControlToTemplate(new Guid(SampleConstants.EducationTemplateId), headerNavigationControl, "header", "Navigation");

                // Footer navigation
                var footerNavigationControl = new NavigationControl();
                footerNavigationControl.NavigationMode = NavigationModes.SiteMapInColumns;
                footerNavigationControl.SelectionMode = PageSelectionModes.TopLevelPages;
                footerNavigationControl.Skin = "footer";
                SampleUtilities.AddControlToTemplate(new Guid(SampleConstants.EducationTemplateId), footerNavigationControl, "footernavigation", "Navigation");
            }
        }