private void InsertSidebarArticle(ArticlePreviewInfo article) { if (string.IsNullOrEmpty(uxSidebarArticleNumber.Text)) { MessageBox.Show(@"Please enter an article number", @"Informa"); return; } string sidebarArticleNumber = article.ArticleNumber; string address = article.PreviewUrl; if (string.IsNullOrEmpty(address)) { MessageBox.Show(@"Article number does not exist!", @"Informa"); return; } var app = Globals.SitecoreAddin.Application; app.Selection.TypeParagraph(); app.Selection.TypeParagraph(); app.Selection.TypeParagraph(); Range selection = app.Selection.Previous(WdUnits.wdParagraph).Previous(WdUnits.wdParagraph); selection.Text = "[Sidebar#" + sidebarArticleNumber.Trim() + "]"; selection = app.ActiveDocument.Range(selection.Start, selection.End); app.ActiveDocument.Hyperlinks.Add(selection, address, null, InternalLinkTooltip); selection.set_Style("9.0 Sidebar"); selection.Select(); app.Selection.Next(WdUnits.wdParagraph).Select(); }
/// <summary> /// /// </summary> /// <param name="articleStruct"></param> /// <returns>True if article is found</returns> public bool UpdatePreview(ArticlePreviewInfo articleStruct) { Controls.Clear(); if (string.IsNullOrEmpty(articleStruct.ArticleNumber)) { Title.Text = @"No article with that article number exists"; SetColumnSpan(Title, 2); Controls.Add(Title); Title.Width = Title.Parent.Width; return(false); } Title.Text = WebUtility.HtmlDecode(articleStruct.Title); Authors.Text = articleStruct.Authors.Count() > 0 ? articleStruct.Authors.Aggregate((complete, cur) => complete + ", " + cur) : @"N/A"; ArticleNumber.Text = articleStruct.ArticleNumber; Publication.Text = articleStruct.Publication; SetColumnSpan(Title, 2); Controls.Add(Title); Controls.Add(By); Controls.Add(Authors); Controls.Add(ArticlePound); Controls.Add(ArticleNumber); Controls.Add(PubLabel); Controls.Add(Publication); Authors.Width = Authors.Parent.Width; Authors.Height = Authors.Parent.Height; Title.Width = Authors.Parent.Width; Title.Height = Authors.Parent.Height; return(true); }
private void ConfigureViewLabel(Label label, ArticlePreviewInfo article) { label.MouseMove += delegate { Cursor.Current = Cursors.Hand; }; ConfigureLabel(label, article); }
public static void ConvertArticleDatesToLocalTimezone(ArticlePreviewInfo article) { if (article == null) { return; } if (article.Date != DateTime.MinValue && article.Date != DateTime.MaxValue) { article.Date = TimeZoneInfo.ConvertTime(article.Date, ServerTimezone, TimeZoneInfo.Local); } }
public Label CreateRemoveImageLabel(ArticlePreviewInfo article) { var label = new Label { Width = 20, Height = 20, Image = Properties.Resources.remove, ImageAlign = ContentAlignment.MiddleCenter }; return(label); }
private void PreviewArticle(string articleNumber) { if (string.IsNullOrEmpty(articleNumber)) { MessageBox.Show(@"Please enter an article number!", @"Informa"); return; } ArticlePreviewInfo info = SitecoreClient.DoesArticleExist(articleNumber) ? SitecoreClient.GetArticlePreviewInfo(articleNumber) : new ArticlePreviewInfo(); uxArticlePreviewTable.UpdatePreview(info); uxArticlePreviewTable.Tag = info; }
public bool UpdatePreviewBox() { if (string.IsNullOrEmpty(uxArticleNumber.Text)) { MessageBox.Show(@"Please enter an article number!", @"Informa"); return(false); } ArticlePreviewInfo info = SitecoreClient.DoesArticleExist(uxArticleNumber.Text) ? SitecoreClient.GetArticlePreviewInfo(uxArticleNumber.Text) : new ArticlePreviewInfo(); bool retrieved = _uxArticlePreviewTable.UpdatePreview(info); _uxArticlePreviewTable.Tag = info; return(retrieved); }
public Label CreateViewLabel(ArticlePreviewInfo article) { var view = new Label { Text = @"View", Font = new Font(Font, FontStyle.Underline), ForeColor = Color.Blue }; view.MouseClick += delegate { //Process.Start(PreviewLinkUpdater.GetPreviewURL(article.PreviewUrl).ToString()); Process.Start(article.PreviewUrl); }; return(view); }
public void AddRow(ArticlePreviewInfo article, bool italic = false, bool bold = false, bool removable = true) { //RowStyles.Add(new RowStyle(SizeType.Absolute, 20F)); Label image; Label articleNumber = CreateFieldLabel(article.ArticleNumber); Label title = CreateFieldLabel(article.Title); Label publication = CreateFieldLabel(article.Publication); Label date = CreateDateLabel(article.Date); Label view = CreateViewLabel(article); if (removable) { image = CreateRemoveImageLabel(article); Controls.Add(image); ConfigureRemoveLabel(image, article); } else { image = new Label(); Controls.Add(image); } if (italic) { title.Font = new Font(image.Font, FontStyle.Strikeout | FontStyle.Italic); } if (bold) { title.Font = new Font(image.Font, FontStyle.Bold); } Controls.Add(articleNumber); Controls.Add(title); Controls.Add(publication); Controls.Add(date); Controls.Add(view); title.Tag = article.ArticleNumber; ConfigureLabel(articleNumber, article); ConfigureLabel(title, article); ConfigureLabel(publication, article); ConfigureLabel(date, article); ConfigureViewLabel(view, article); }
private void InsertRelatedArticle(ArticlePreviewInfo article) { if (string.IsNullOrEmpty(uxRelatedArticleNumber.Text)) { MessageBox.Show(@"Please enter an article number"); return; } string relatedArticleNumber = uxRelatedArticleNumber.Text; Object address = article.PreviewUrl; var app = Globals.SitecoreAddin.Application; app.Selection.Text = "([A#" + relatedArticleNumber.Trim() + "])"; Range hyperlinkRange = app.ActiveDocument.Range(app.Selection.Start + 1, app.Selection.End - 1); //Word.Hyperlink hyperlink = app.ActiveDocument.Hyperlinks.Add(hyperlinkRange, ref address, null, InternalLinkTooltip); app.Selection.MoveRight(WdUnits.wdCharacter, 2); }
private void ConfigureRemoveLabel(Label label, ArticlePreviewInfo article) { label.MouseMove += delegate { Cursor.Current = Cursors.Hand; }; label.Click += delegate { if (!SitecoreRelatedArticles.Remove(article)) { LocalRelatedArticles.Remove(article); } HasChanged = true; MenuItem.HasChanged = true; UpdateMenuItem(); PopulateTable(); }; ConfigureLabel(label, article); }
public void AddToRelated(ArticlePreviewInfo preview) { if (LocalRelatedArticles.Select(t => t.ArticleNumber).Contains(preview.ArticleNumber) || LocalReferencedArticles.Select(t => t.ArticleNumber).Contains(preview.ArticleNumber) || HasArticle(GetActiveSitecoreRelatedArticles(), preview)) { MessageBox.Show(@"The selected article is already a Related Article or Referenced Article.", @"Informa"); //foreach(Control control in Controls) //{ // if (control.Tag == null || control.Font.Strikeout) continue; // control.BackColor = // control.Tag.ToString() == preview.ArticleNumber // ? Color.Yellow // : Color.Transparent; //} return; } LocalRelatedArticles.Add(preview); //UpdateMenuItem(); PopulateTable(); }
/// <summary> /// Initializes a new instance of the <see cref="ArticleNavItemViewModel"/> class. /// </summary> /// <param name="articlePreviewInfo">The article preview information.</param> /// <param name="deleteArticleAction"></param> public ArticleNavItemViewModel(ArticlePreviewInfo articlePreviewInfo, Action <object> deleteArticleAction) { this.articlePreviewInfo = articlePreviewInfo; DeleteArticleCommand = new Command(CanDeleteArticle, deleteArticleAction); }
public ArticleNavItemViewModel() { articlePreviewInfo = new ArticlePreviewInfo(); }
private static bool HasArticle(IEnumerable <ArticlePreviewInfo> articles, ArticlePreviewInfo article) { return(articles.Select(a => a.ArticleNumber).Contains(article.ArticleNumber)); }
public void ConfigureLabel(Label label, ArticlePreviewInfo article = null) { //label.Tag = article.ArticleNumber; label.Width = label.Parent.Width; label.Height = 15; }