public void ShowRandomApplicationTip() { var randomTip = HelpFeature.GetRandomFeature(); int rowCount = 0; StringBuilder sb = new StringBuilder(); sb.AppendLine("Did you know?"); sb.AppendLine(); foreach (var line in randomTip.HelpLines) { if (rowCount > 3) { break; } sb.AppendLine(line.Content); rowCount++; } if (rowCount < randomTip.HelpLines.Count) { sb.AppendLine(); sb.AppendLine("... (click to read more)"); } _notificationManager.ShowAsync( content: new NotificationContent() { Title = randomTip.Title, Message = sb.ToString(), Type = NotificationType.Information }, expirationTime: TimeSpan.FromSeconds(10), onClick: () => { var quickTip = new QuickTipDialog(appSettingService, randomTip); quickTip.TrySetViewablePositionFromOwner(OwnerControl); quickTip.Show(); }); }
public QuickTipDialog(IAppSettingService settingService, HelpFeature randomFeature) { DataContext = this; InitializeComponent(); this.Title = "Did you know?"; if (DesignerProperties.GetIsInDesignMode(this)) { SettingService = new DesignerAppSettingService(); } else { // ToDo: Evil Hack to have the cake (see actual design in design mode) and eat it too (have different styles at runtime) this.Resources = null; SettingService = settingService; this.KeyDown += Window_KeyDown; } SetContents(randomFeature); }
public HelpWindow() { DataContext = this; InitializeComponent(); if (DesignerProperties.GetIsInDesignMode(this)) { } else { // ToDo: Evil Hack to have the cake (see actual design in design mode) and eat it too (have different styles at runtime) this.Resources = null; } this.KeyDown += Window_KeyDown; quickStart = new Help.General.QuickStart(); this.allFeatures = HelpFeature.All.Where(f => f.FeatureClass == HelpFeatureClass.NewFeature).ToList(); int topicRowCount = 0; var quickStartrowDefinition = new RowDefinition(); quickStartrowDefinition.Height = GridLength.Auto; TopicListGrid.RowDefinitions.Add(quickStartrowDefinition); var quickStartButton = new Button(); quickStartButton.Name = quickStart.Id; quickStartButton.Content = quickStart.Title; quickStartButton.HorizontalAlignment = HorizontalAlignment.Stretch; quickStartButton.Click += HelpButton_Click; Style quickStartButtonStyle = (Style)FindResource("HelpTopicButtonLayout"); if (quickStartButtonStyle != null) { quickStartButton.Style = quickStartButtonStyle; } quickStartButton.HorizontalAlignment = HorizontalAlignment.Stretch; quickStartButton.IsEnabled = true; TopicListGrid.InsertAt(quickStartButton, 0, topicRowCount); topicRowCount++; foreach (var feature in allFeatures) { var rowDefinition = new RowDefinition(); rowDefinition.Height = GridLength.Auto; TopicListGrid.RowDefinitions.Add(rowDefinition); var button = new Button(); button.Name = feature.Id; button.Content = feature.Title; button.HorizontalAlignment = HorizontalAlignment.Stretch; button.Click += HelpButton_Click; Style buttonStyle = (Style)FindResource("HelpTopicButtonLayout"); if (buttonStyle != null) { button.Style = buttonStyle; } button.HorizontalAlignment = HorizontalAlignment.Stretch; button.IsEnabled = true; TopicListGrid.InsertAt(button, 0, topicRowCount); topicRowCount++; } quickStartButton.PerformClick(); quickStartButton.Focus(); }
private void AddFeatureToDisplayList(HelpFeature feature, Grid targetGrid) { var featureRowDefinition = new RowDefinition(); featureRowDefinition.Height = GridLength.Auto; targetGrid.RowDefinitions.Add(featureRowDefinition); Style textBlockStyle = (Style)FindResource("DefaultTextBlockStyle"); Style addedFeatureImageStyle = (Style)FindResource("AddedFeature_Image_Style"); Style bugfixImageStyle = (Style)FindResource("BugFix_Image_Style"); Style verboseInfoImageStyle = (Style)FindResource("VerboseInformationFeature_Image_Style"); var featureText = new TextBlock(); featureText.Style = textBlockStyle; featureText.HorizontalAlignment = System.Windows.HorizontalAlignment.Stretch; featureText.VerticalAlignment = System.Windows.VerticalAlignment.Center; featureText.Text = feature.Title; var detailsHelpText = feature.HelpLinesAsString(); switch (feature.FeatureClass) { case HelpFeatureClass.Information: { if (verboseInfoImageStyle != null) { var featureType = new SVGImage.SVG.SVGImage(); featureType.Style = verboseInfoImageStyle; featureType.SetCustomToolTip("important information"); targetGrid.InsertAt(featureType, 0, targetGrid.RowDefinitions.Count - 1); } break; } case HelpFeatureClass.NewFeature: { if (addedFeatureImageStyle != null) { var featureType = new SVGImage.SVG.SVGImage(); featureType.Style = addedFeatureImageStyle; featureType.SetCustomToolTip("added feature"); targetGrid.InsertAt(featureType, 0, targetGrid.RowDefinitions.Count - 1); } break; } case HelpFeatureClass.BugFix: { if (bugfixImageStyle != null) { var featureType = new SVGImage.SVG.SVGImage(); featureType.Style = bugfixImageStyle; featureType.SetCustomToolTip("bug fix"); targetGrid.InsertAt(featureType, 0, targetGrid.RowDefinitions.Count - 1); } break; } } featureText.SetCustomToolTip(detailsHelpText); targetGrid.InsertAt(featureText, 1, targetGrid.RowDefinitions.Count - 1); }
private void SetContents(HelpFeature randomFeature) { FeatureCaption = randomFeature.Title; FeatureContents = randomFeature.HelpLinesAsString(); }
private void GenerateRandomTip() { HelpFeature randomFeature = HelpFeature.GetRandomFeature(); SetContents(randomFeature); }