protected void _eventsCalendar_DayRender(object sender, DayRenderEventArgs e) { TbComparer tbComparer; int compare; HyperLink hyperLink; LiteralControl literalControl; try { if (_articlesDatesList == null) throw new Exception("Cannot read articles dates"); tbComparer = new TbComparer(); compare = _articlesDatesList.BinarySearch(e.Day.Date, tbComparer); if (e.Cell.Controls.Count > 0) { literalControl = e.Cell.Controls[0] as LiteralControl; if (literalControl != null) { hyperLink = new HyperLink(); hyperLink.Text = literalControl.Text; hyperLink.NavigateUrl = ResolveUrl("~/Default.aspx?year=" + e.Day.Date.Year + "&month=" + e.Day.Date.Month + "&day=" + e.Day.Date.Day); hyperLink.CssClass = "TopArticlesLinks"; if (compare >= 0) { //We found that an Article was published on this exact day. // Grab the Article Date belonging to this exact day. DateTime[] ThisArticleDate = new DateTime[_articlesDatesList.Count]; for (int i = 0; i < _articlesDatesList.Count; i++) { if (_articlesDatesList[i].Date == e.Day.Date.Date) { ThisArticleDate[i] = _articlesDatesList[i]; } } //Grab the Article Titles belonging to this exact day. string[] ArticleTitle = new string[ThisArticleDate.Length]; for (int i = 0; i < ThisArticleDate.Length; i++) { DateTime dt = new DateTime(); if (ThisArticleDate[i] == dt) { } else { ArticleTitle[i] = Articles.GetArticleTitleByDate(ThisArticleDate[i]); } } //Populate the ToolTip Div to show the user on mouseover the Article Title. string ToolTipDiv = ""; for (int i = 0; i < ArticleTitle.Length; i++) { if (ArticleTitle[i] == null) { } else { ToolTipDiv += ArticleTitle[i] + "."; } } //Assign the Article Title to the Tool Tip for this Day. hyperLink.Attributes["onmouseout"] = "PopulateDiv(event,'ToolTipDiv', '" + ToolTipDiv + "')"; hyperLink.Attributes["onmouseover"] = "PopulateDiv(event,'ToolTipDiv', '" + ToolTipDiv + "')"; hyperLink.Style.Add("color", System.Drawing.ColorTranslator.ToHtml(_eventsCalendar.SelectorStyle.ForeColor)); hyperLink.ToolTip = ""; } else { hyperLink.Style.Add("color", System.Drawing.ColorTranslator.ToHtml(_eventsCalendar.ForeColor)); //If there are no Aticles for this day, then... hyperLink.ToolTip = "No Articles on this day."; } e.Cell.Controls.Clear(); e.Cell.Controls.Add(hyperLink); } } } catch (Exception) { } }
protected override void OnPreRender(EventArgs e) { string val; TbComparer tbComparer; int compare; try { base.OnPreRender(e); if (!IsPostBack || _automaticInitForArticle) { _allRdoBtn.Checked = _selectAll; _selectRdoBtn.Checked = !_selectAll; // _customCategoriesPanel.Enabled = !_selectAll; if (_selectedIds != null) { tbComparer = new TbComparer(); for (int i = 0; i < _categoriesChBList.Items.Count; ++i) { val = _categoriesChBList.Items[i].Value; compare = _selectedIds.BinarySearch(val, tbComparer); // if current item is in _selectedId if (compare >= 0) _categoriesChBList.Items[i].Selected = true; } } } _allRdoBtn.Attributes.Add("OnClick", "SetControlEnable('" + _customCategoriesPanel.ClientID + "', true)"); _selectRdoBtn.Attributes.Add("OnClick", "SetControlEnable('" + _customCategoriesPanel.ClientID + "', false)"); } catch (Exception) { } }
public List<string> GetSelectedCategories() { ListItem listItem; List<string> result = new List<string>(_categoriesChBList.Items.Count); TbComparer tbComparer = new TbComparer(); try { for (int i = 0; i < _categoriesChBList.Items.Count; ++i) { listItem = _categoriesChBList.Items[i]; if (listItem.Selected) result.Add(listItem.Value); } result.Sort(tbComparer); } catch (Exception) { } return result; }
public static void UpdateArticles(bool aNewAllGroups, List<string> aNewIds, string aArticleId) { Int64 articleId, id; List<string> oldIds, allCategories; string category; bool inOld, inNew; if (!Int64.TryParse(aArticleId, out articleId)) throw new Exception("Cannot parse aArticleId!"); if (aNewIds == null && !aNewAllGroups) throw new Exception("Invalid parameter: aNewIds!"); try { oldIds = TableArticleCategories.ReadCategoriesShort(articleId); if (oldIds == null) throw new Exception("oldIds == null"); // if old categories are for all if (oldIds.Count == 1 && oldIds[0].Equals("1")) { // new categories are for all if (aNewAllGroups) { // don't do nothing } else // new categories are custom { if (aNewIds.Count > 0) { // delete all row in ArticleCategories TableArticleCategories.Delete(articleId, 1); // insert new categories for (int i = 0; i < aNewIds.Count; ++i) { if (Int64.TryParse(aNewIds[i], out id)) TableArticleCategories.Insert(articleId, id); } } } } else // old categories are custom { // new categories are for all if (aNewAllGroups) { // delete all old custom categories TableArticleCategories.Delete(articleId); // insert row for all categories TableArticleCategories.Insert(articleId, 1); } else { allCategories = TableCategory.ReadCategoriesShort(); TbComparer tbComparer = new TbComparer(); // iterate through all categories for (int i = 0; i < allCategories.Count; ++i) { category = allCategories[i]; inOld = oldIds.BinarySearch(category, tbComparer) >= 0; inNew = aNewIds.BinarySearch(category, tbComparer) >= 0; if (inOld && !inNew) { // delete the category TableArticleCategories.Delete(articleId, Int64.Parse(category)); } else if (!inOld && inNew) { // add the category TableArticleCategories.Insert(articleId, Int64.Parse(category)); } } } } } catch (Exception) { } }