//////////////////////////////////////////////////////////////////////////////////// // //////////////////////////////////////////////////////////////////////////////////// private void LayoutCombo_SelectionChanged(object sender, SelectionChangedEventArgs e) { selectedLayout_ = (DisplayLayout)LayoutCombo.SelectedItem; // Show this one if (selectedLocation_ != DisplayLocation.UninitializedEnum) { display_.ExperimentWorkspaceLayout = selectedLayout_; } }
//////////////////////////////////////////////////////////////////////////////////// // Constructor //////////////////////////////////////////////////////////////////////////////////// public DisplayControlsSample(ILightFieldApplication app) { // Cache Some Members application_ = app; display_ = application_.DisplayManager; // Initialize the WPF component InitializeComponent(); // Setup Layout Mode Combo Box LayoutCombo.Items.Add(DisplayLayout.One); LayoutCombo.Items.Add(DisplayLayout.TwoHorizontal); LayoutCombo.Items.Add(DisplayLayout.TwoVertical); LayoutCombo.Items.Add(DisplayLayout.ThreeTopFavored); LayoutCombo.Items.Add(DisplayLayout.ThreeVertical); LayoutCombo.Items.Add(DisplayLayout.FourEven); LayoutCombo.Items.Add(DisplayLayout.FourTopFavored); LayoutCombo.Items.Add(DisplayLayout.FourVertical); LayoutCombo.Items.Add(DisplayLayout.FourLeftFavored); LayoutCombo.Items.Add(DisplayLayout.FiveTopFavored); LayoutCombo.Items.Add(DisplayLayout.FiveLeftFavored); // Defaults from application selectedLocation_ = display_.Location; selectedLayout_ = display_.ExperimentWorkspaceLayout; // Default Combo Boxes LayoutCombo.SelectedItem = selectedLayout_; // Experiment if (selectedLocation_ == DisplayLocation.ExperimentWorkspace) { LocationCombo.SelectedIndex = 0; } // Data Workspace else { LocationCombo.SelectedIndex = 1; } IndexCombo.SelectedIndex = 0; }
/// <summary> /// Initializes the control properties. /// </summary> protected void SetupControl() { if (StopProcessing) { // Do nothing } else { mLayoutSeparator = DisplayLayout.ToLower() == "vertical" ? "<br />" : " "; DataSet ds = null; // Try to get data from cache using (CachedSection <DataSet> cs = new CachedSection <DataSet>(ref ds, this.CacheMinutes, true, this.CacheItemName, "languageselection", CMSContext.CurrentSiteName)) { if (cs.LoadData) { // Get the data ds = CultureInfoProvider.GetSiteCultures(CMSContext.CurrentSiteName); // Save to the cache if (cs.Cached) { cs.CacheDependency = CacheHelper.GetCacheDependency(new string[] { "cms.culturesite|all", "cms.culture|all" }); cs.Data = ds; } } } if (!DataHelper.DataSourceIsEmpty(ds) && (ds.Tables[0].Rows.Count > 1)) { // Collection of available documents in culture Dictionary <string, string> documentCultures = null; // Check whether hiding is required or URLs should be generated with lang prefix if (this.HideUnavailableCultures || this.UseURLsWithLangPrefix) { string cacheItemName = this.CacheItemName; if (!String.IsNullOrEmpty(cacheItemName)) { cacheItemName += "prefix"; } // Current page info PageInfo currentPageInfo = CMSContext.CurrentPageInfo; // Try to get data from cache using (CachedSection <Dictionary <string, string> > cs = new CachedSection <Dictionary <string, string> >(ref documentCultures, this.CacheMinutes, true, cacheItemName, "languageselectionprefix", CMSContext.CurrentSiteName, currentPageInfo.NodeAliasPath.ToLower())) { if (cs.LoadData) { // Initialize tree provider object TreeProvider tp = new TreeProvider(CMSContext.CurrentUser); tp.FilterOutDuplicates = false; tp.CombineWithDefaultCulture = false; // Get all language versions DataSet culturesDs = tp.SelectNodes(CMSContext.CurrentSiteName, "/%", TreeProvider.ALL_CULTURES, false, null, "NodeID = " + currentPageInfo.NodeId, null, -1, true, 0, "DocumentCulture, DocumentUrlPath"); // Create culture/UrlPath collection if (!DataHelper.DataSourceIsEmpty(culturesDs)) { documentCultures = new Dictionary <string, string>(); foreach (DataRow dr in culturesDs.Tables[0].Rows) { string docCulture = ValidationHelper.GetString(dr["DocumentCulture"], String.Empty).ToLower(); string urlPath = ValidationHelper.GetString(dr["DocumentUrlPath"], String.Empty); documentCultures.Add(docCulture, urlPath); } } // Add to the cache if (cs.Cached) { cs.CacheDependency = this.GetCacheDependency(); cs.Data = documentCultures; } } } } // Render the cultures ltlHyperlinks.Text = ""; int count = 0; int rows = ds.Tables[0].Rows.Count; foreach (DataRow dr in ds.Tables[0].Rows) { string cultureCode = dr["CultureCode"].ToString(); string cultureShortName = dr["CultureShortName"].ToString(); string cultureAlias = Convert.ToString(dr["CultureAlias"]); bool documentCultureExists = true; // Check whether exists document in specified culture if ((documentCultures != null) && (this.HideUnavailableCultures)) { documentCultureExists = documentCultures.ContainsKey(cultureCode.ToLower()); } if (documentCultureExists) { if (!((HideCurrentCulture) && (String.Compare(CMSContext.CurrentDocument.DocumentCulture, cultureCode, true) == 0))) { // Get flag icon URL imgFlagIcon = UIHelper.GetFlagIconUrl(this.Page, cultureCode, "16x16"); string url = null; string lang = cultureCode; // Check whether culture alias is defined and if so use it if (!String.IsNullOrEmpty(cultureAlias)) { lang = cultureAlias; } // Get specific url with language prefix if (this.UseURLsWithLangPrefix && documentCultures != null) { string urlPath = String.Empty; if (documentCultures.ContainsKey(cultureCode.ToLower())) { urlPath = documentCultures[cultureCode.ToLower()]; } url = TreePathUtils.GetUrl(CMSContext.CurrentAliasPath, urlPath, CMSContext.CurrentSiteName, lang); url += URLHelper.GetQuery(URLHelper.CurrentURL); url = URLHelper.RemoveParameterFromUrl(url, URLHelper.LanguageParameterName); url = URLHelper.RemoveParameterFromUrl(url, URLHelper.AliasPathParameterName); } // Get URL with lang parameter else { // Build current URL url = URLHelper.CurrentURL; url = URLHelper.RemoveParameterFromUrl(url, URLHelper.LanguageParameterName); url = URLHelper.RemoveParameterFromUrl(url, URLHelper.AliasPathParameterName); url = URLHelper.AddParameterToUrl(url, URLHelper.LanguageParameterName, lang); } if (ShowCultureNames) { // Add flag icon before the link text ltlHyperlinks.Text += "<img src=\"" + imgFlagIcon + "\" alt=\"" + HTMLHelper.HTMLEncode(cultureShortName) + "\" />"; ltlHyperlinks.Text += "<a href=\"" + url + "\">"; ltlHyperlinks.Text += HTMLHelper.HTMLEncode(cultureShortName); // Set surrounding div css class selectionClass = "languageSelectionWithCultures"; } else { ltlHyperlinks.Text += "<a href=\"" + url + "\">" + "<img src=\"" + imgFlagIcon + "\" alt=\"" + HTMLHelper.HTMLEncode(cultureShortName) + "\" />"; // Set surrounding div css class selectionClass = "languageSelection"; } count++; // Check last item if (count == rows) { ltlHyperlinks.Text += "</a>"; } else { ltlHyperlinks.Text += "</a>" + Separator + mLayoutSeparator; } } } } } else { // Hide if less than two cultures Visible = false; } if (string.IsNullOrEmpty(selectionClass)) { ltrDivOpen.Text = "<div>"; } else { ltrDivOpen.Text = "<div class=\"" + selectionClass + "\">"; } ltrDivClose.Text = "</div>"; // Check if RTL hack must be applied if (CultureHelper.IsPreferredCultureRTL()) { ltrDivOpen.Text += "<span style=\"visibility:hidden;\">a</span>"; } } }
/// <summary> /// Initializes the control properties. /// </summary> protected void SetupControl() { if (StopProcessing) { // Do nothing } else { List <string[]> cultures = GetCultures(); if ((cultures != null) && (cultures.Count > 1)) { // Render the cultures ltlHyperlinks.Text = String.Empty; mLayoutSeparator = DisplayLayout.ToLowerCSafe() == "vertical" ? "<br />" : " "; bool addSeparator = false; // Loop thru all cultures foreach (string[] data in cultures) { string url = data[0]; string code = data[1]; string name = data[2]; // Get flag icon URL imgFlagIcon = UIHelper.GetFlagIconUrl(Page, code, "16x16"); if (addSeparator) { ltlHyperlinks.Text += Separator + mLayoutSeparator; } if (ShowCultureNames) { // Add flag icon before the link text ltlHyperlinks.Text += "<img src=\"" + imgFlagIcon + "\" alt=\"" + HTMLHelper.HTMLEncode(name) + "\" />"; // ltlHyperlinks.Text += HTMLHelper.HTMLEncode(name); // Set surrounding div css class selectionClass = "languageSelectionWithCultures"; } else { ltlHyperlinks.Text += "<a href=\"" + url + "\">" + "<img src=\"" + imgFlagIcon + "\" alt=\"" + HTMLHelper.HTMLEncode(name) + "\" />"; // Set surrounding div css class selectionClass = "languageSelection"; } ltlHyperlinks.Text += "</a>"; addSeparator = true; } } // Hide webpart if there isn't more than one culture else { Visible = false; } if (string.IsNullOrEmpty(selectionClass)) { ltrDivOpen.Text = "<div>"; } else { ltrDivOpen.Text = "<div class=\"" + selectionClass + "\">"; } ltrDivClose.Text = "</div>"; // Check if RTL hack must be applied if (CultureHelper.IsPreferredCultureRTL()) { ltrDivOpen.Text += "<span style=\"visibility:hidden;\">a</span>"; } } }