public SvgDrawingCanvas() { _drawForInteractivity = true; _drawObjects = new List <Drawing>(); _linkObjects = new List <Drawing>(); _displayTransform = Transform.Identity; // Create a tooltip and set its position. _tooltip = new ToolTip(); _tooltip.Placement = PlacementMode.MousePoint; _tooltip.PlacementRectangle = new Rect(50, 0, 0, 0); _tooltip.HorizontalOffset = 20; _tooltip.VerticalOffset = 20; _tooltipText = new TextBlock(); _tooltipText.Text = string.Empty; _tooltipText.Margin = new Thickness(6, 0, 0, 0); //Create BulletDecorator and set it as the tooltip content. Ellipse bullet = new Ellipse(); bullet.Height = 10; bullet.Width = 10; bullet.Fill = Brushes.LightCyan; BulletDecorator decorator = new BulletDecorator(); decorator.Bullet = bullet; decorator.Margin = new Thickness(0, 0, 10, 0); decorator.Child = _tooltipText; _tooltip.Content = decorator; _tooltip.IsOpen = false; _tooltip.Visibility = Visibility.Hidden; //Finally, set tooltip on this canvas this.ToolTip = _tooltip; this.Background = Brushes.Transparent; _animationCanvas = new SvgAnimationLayer(this); }
private void OnApplyTestState(TreeViewItem treeItem) { SvgTestInfo testInfo = treeItem.Tag as SvgTestInfo; if (testInfo == null) { return; } BulletDecorator header = treeItem.Header as BulletDecorator; if (header == null) { return; } int selIndex = stateComboBox.SelectedIndex; if (selIndex < 0) { return; } testInfo.State = (SvgTestState)selIndex; testInfo.Comment = testComment.Text; Ellipse bullet = header.Bullet as Ellipse; if (bullet != null) { bullet.Fill = testInfo.StateBrush; } if (!_isTreeModified) { this.Title = this.Title + " *"; _isTreeModified = true; } _isTreeChangedPending = false; testApply.IsEnabled = false; }
private Paragraph BuildBullet( string paragraphText) { var textBlock = new TextBlock(); textBlock.Inlines.AddRange(BuildInlines(paragraphText)); textBlock.TextWrapping = TextWrapping.Wrap; textBlock.Margin = new Thickness(8, 0, 0, 0); var bulletDecorator = new BulletDecorator(); #pragma warning disable CA1303 // Do not pass literals as localized parameters bulletDecorator.Bullet = new TextBlock(new Run("○")); #pragma warning restore CA1303 // Do not pass literals as localized parameters bulletDecorator.Child = textBlock; var paragraph = new Paragraph(); paragraph.Inlines.Add(bulletDecorator); paragraph.Margin = new Thickness(0, 0, 0, 6); paragraph.LineHeight = 18; return(paragraph); }
public static IObservable <EventPattern <KeyEventArgs> > KeyUpObserver(this BulletDecorator This) { return(Observable.FromEventPattern <KeyEventHandler, KeyEventArgs>(h => This.KeyUp += h, h => This.KeyUp -= h)); }
public static IObservable <EventPattern <DependencyPropertyChangedEventArgs> > FocusableChangedObserver(this BulletDecorator This) { return(Observable.FromEventPattern <DependencyPropertyChangedEventHandler, DependencyPropertyChangedEventArgs>(h => This.FocusableChanged += h, h => This.FocusableChanged -= h)); }
private void LoadTreeViewCategory(XmlReader reader, TreeViewItem categoryItem, SvgTestCategory testCategory) { int total = 0, unknowns = 0, failures = 0, successes = 0, partials = 0; int itemCount = 0; while (reader.Read()) { if (reader.NodeType == XmlNodeType.Element) { if (string.Equals(reader.Name, "test", StringComparison.OrdinalIgnoreCase)) { SvgTestInfo testInfo = new SvgTestInfo(reader); if (!testInfo.IsEmpty) { TextBlock headerText = new TextBlock(); headerText.Text = string.Format("({0:D3}) - {1}", itemCount, testInfo.Title); headerText.Margin = new Thickness(3, 0, 0, 0); Ellipse bullet = new Ellipse(); bullet.Height = 16; bullet.Width = 16; bullet.Fill = testInfo.StateBrush; bullet.Stroke = Brushes.DarkGray; bullet.StrokeThickness = 1; BulletDecorator decorator = new BulletDecorator(); decorator.Bullet = bullet; decorator.Margin = new Thickness(0, 0, 10, 0); decorator.Child = headerText; TreeViewItem treeItem = new TreeViewItem(); treeItem.Header = decorator; treeItem.Padding = new Thickness(3); treeItem.FontSize = 12; treeItem.FontWeight = FontWeights.Normal; treeItem.Tag = testInfo; categoryItem.Items.Add(treeItem); itemCount++; total++; SvgTestState testState = testInfo.State; switch (testState) { case SvgTestState.Unknown: unknowns++; break; case SvgTestState.Failure: failures++; break; case SvgTestState.Success: successes++; break; case SvgTestState.Partial: partials++; break; } } } } else if (reader.NodeType == XmlNodeType.EndElement) { if (string.Equals(reader.Name, "category", StringComparison.OrdinalIgnoreCase)) { break; } } } testCategory.SetValues(total, unknowns, failures, successes, partials); }
public static IObservable <EventPattern <RequestBringIntoViewEventArgs> > RequestBringIntoViewObserver(this BulletDecorator This) { return(Observable.FromEventPattern <RequestBringIntoViewEventHandler, RequestBringIntoViewEventArgs>(h => This.RequestBringIntoView += h, h => This.RequestBringIntoView -= h)); }
public static IObservable <EventPattern <ContextMenuEventArgs> > ContextMenuClosingObserver(this BulletDecorator This) { return(Observable.FromEventPattern <ContextMenuEventHandler, ContextMenuEventArgs>(h => This.ContextMenuClosing += h, h => This.ContextMenuClosing -= h)); }
public static IObservable <EventPattern <MouseButtonEventArgs> > MouseLeftButtonDownObserver(this BulletDecorator This) { return(Observable.FromEventPattern <MouseButtonEventHandler, MouseButtonEventArgs>(h => This.MouseLeftButtonDown += h, h => This.MouseLeftButtonDown -= h)); }
public static IObservable <EventPattern <DragEventArgs> > PreviewDragLeaveObserver(this BulletDecorator This) { return(Observable.FromEventPattern <DragEventHandler, DragEventArgs>(h => This.PreviewDragLeave += h, h => This.PreviewDragLeave -= h)); }
public static IObservable <EventPattern <ManipulationCompletedEventArgs> > ManipulationCompletedObserver(this BulletDecorator This) { return(Observable.FromEventPattern <EventHandler <ManipulationCompletedEventArgs>, ManipulationCompletedEventArgs>(h => This.ManipulationCompleted += h, h => This.ManipulationCompleted -= h)); }
public static IObservable <EventPattern <QueryContinueDragEventArgs> > QueryContinueDragObserver(this BulletDecorator This) { return(Observable.FromEventPattern <QueryContinueDragEventHandler, QueryContinueDragEventArgs>(h => This.QueryContinueDrag += h, h => This.QueryContinueDrag -= h)); }
public static IObservable <EventPattern <GiveFeedbackEventArgs> > GiveFeedbackObserver(this BulletDecorator This) { return(Observable.FromEventPattern <GiveFeedbackEventHandler, GiveFeedbackEventArgs>(h => This.GiveFeedback += h, h => This.GiveFeedback -= h)); }
public static IObservable <EventPattern <TextCompositionEventArgs> > TextInputObserver(this BulletDecorator This) { return(Observable.FromEventPattern <TextCompositionEventHandler, TextCompositionEventArgs>(h => This.TextInput += h, h => This.TextInput -= h)); }
public static IObservable <EventPattern <SizeChangedEventArgs> > SizeChangedObserver(this BulletDecorator This) { return(Observable.FromEventPattern <SizeChangedEventHandler, SizeChangedEventArgs>(h => This.SizeChanged += h, h => This.SizeChanged -= h)); }
public static IObservable <EventPattern <KeyboardFocusChangedEventArgs> > PreviewLostKeyboardFocusObserver(this BulletDecorator This) { return(Observable.FromEventPattern <KeyboardFocusChangedEventHandler, KeyboardFocusChangedEventArgs>(h => This.PreviewLostKeyboardFocus += h, h => This.PreviewLostKeyboardFocus -= h)); }
public static IObservable <EventPattern <ManipulationInertiaStartingEventArgs> > ManipulationInertiaStartingObserver(this BulletDecorator This) { return(Observable.FromEventPattern <EventHandler <ManipulationInertiaStartingEventArgs>, ManipulationInertiaStartingEventArgs>(h => This.ManipulationInertiaStarting += h, h => This.ManipulationInertiaStarting -= h)); }
public static IObservable <EventPattern <DragEventArgs> > DropObserver(this BulletDecorator This) { return(Observable.FromEventPattern <DragEventHandler, DragEventArgs>(h => This.Drop += h, h => This.Drop -= h)); }
public static IObservable <EventPattern <ManipulationBoundaryFeedbackEventArgs> > ManipulationBoundaryFeedbackObserver(this BulletDecorator This) { return(Observable.FromEventPattern <EventHandler <ManipulationBoundaryFeedbackEventArgs>, ManipulationBoundaryFeedbackEventArgs>(h => This.ManipulationBoundaryFeedback += h, h => This.ManipulationBoundaryFeedback -= h)); }
public static IObservable <EventPattern <TouchEventArgs> > PreviewTouchUpObserver(this BulletDecorator This) { return(Observable.FromEventPattern <EventHandler <TouchEventArgs>, TouchEventArgs>(h => This.PreviewTouchUp += h, h => This.PreviewTouchUp -= h)); }
public static IObservable <EventPattern <ToolTipEventArgs> > ToolTipClosingObserver(this BulletDecorator This) { return(Observable.FromEventPattern <ToolTipEventHandler, ToolTipEventArgs>(h => This.ToolTipClosing += h, h => This.ToolTipClosing -= h)); }
public static IObservable <EventPattern <TouchEventArgs> > TouchLeaveObserver(this BulletDecorator This) { return(Observable.FromEventPattern <EventHandler <TouchEventArgs>, TouchEventArgs>(h => This.TouchLeave += h, h => This.TouchLeave -= h)); }
public static IObservable <EventPattern <MouseButtonEventArgs> > PreviewMouseUpObserver(this BulletDecorator This) { return(Observable.FromEventPattern <MouseButtonEventHandler, MouseButtonEventArgs>(h => This.PreviewMouseUp += h, h => This.PreviewMouseUp -= h)); }
public static IObservable <EventPattern <RoutedEventArgs> > UnloadedObserver(this BulletDecorator This) { return(Observable.FromEventPattern <RoutedEventHandler, RoutedEventArgs>(h => This.Unloaded += h, h => This.Unloaded -= h)); }
private void LoadTreeView(XmlReader reader) { SvgTestResult testResult = new SvgTestResult(); treeView.BeginInit(); treeView.Items.Clear(); while (reader.Read()) { if (reader.NodeType == XmlNodeType.Element && string.Equals(reader.Name, "category", StringComparison.OrdinalIgnoreCase)) { // <category label="Animations"> string category = reader.GetAttribute("label"); if (!string.IsNullOrWhiteSpace(category)) { SvgTestCategory testCategory = new SvgTestCategory(category); TextBlock headerText = new TextBlock(); headerText.Text = category; headerText.Margin = new Thickness(3, 0, 0, 0); BulletDecorator decorator = new BulletDecorator(); if (_folderClose != null) { Image image = new Image(); image.Source = _folderClose; decorator.Bullet = image; } else { Ellipse bullet = new Ellipse(); bullet.Height = 16; bullet.Width = 16; bullet.Fill = Brushes.Goldenrod; bullet.Stroke = Brushes.DarkGray; bullet.StrokeThickness = 1; decorator.Bullet = bullet; } decorator.Margin = new Thickness(0, 0, 10, 0); decorator.Child = headerText; TreeViewItem categoryItem = new TreeViewItem(); categoryItem.Header = decorator; categoryItem.Margin = new Thickness(0, 3, 0, 3); categoryItem.FontSize = 14; categoryItem.FontWeight = FontWeights.Bold; treeView.Items.Add(categoryItem); LoadTreeViewCategory(reader, categoryItem, testCategory); if (testCategory.IsValid) { testResult.Categories.Add(testCategory); } } } } if (_testResults == null) { _testResults = new List <SvgTestResult>(); } bool saveResults = false; if (testResult.IsValid) { if (_testResults.Count == 0) { _testResults.Add(testResult); saveResults = true; } else { int foundAt = -1; for (int i = 0; i < _testResults.Count; i++) { SvgTestResult nextResult = _testResults[i]; if (nextResult != null && nextResult.IsValid) { if (string.Equals(nextResult.Version, testResult.Version)) { foundAt = i; break; } } } if (foundAt >= 0) { SvgTestResult nextResult = _testResults[foundAt]; if (!SvgTestResult.AreEqual(nextResult, testResult)) { _testResults[foundAt] = testResult; saveResults = true; } } else { _testResults.Add(testResult); saveResults = true; } } } if (saveResults) { if (!string.IsNullOrWhiteSpace(_testResultsPath)) { string backupFile = null; if (File.Exists(_testResultsPath)) { backupFile = IoPath.ChangeExtension(_testResultsPath, ".bak"); try { if (File.Exists(backupFile)) { File.Delete(backupFile); } File.Move(_testResultsPath, backupFile); } catch (Exception ex) { MessageBox.Show(ex.ToString(), AppErrorTitle, MessageBoxButton.OK, MessageBoxImage.Error); return; } } try { XmlWriterSettings settings = new XmlWriterSettings(); settings.Indent = true; settings.IndentChars = " "; settings.Encoding = Encoding.UTF8; using (XmlWriter writer = XmlWriter.Create(_testResultsPath, settings)) { this.SaveTestResults(writer); } } catch (Exception ex) { if (!string.IsNullOrWhiteSpace(backupFile) && File.Exists(backupFile)) { File.Move(backupFile, _testResultsPath); } MessageBox.Show(ex.ToString(), AppErrorTitle, MessageBoxButton.OK, MessageBoxImage.Error); } } } treeView.EndInit(); }
public static IObservable <EventPattern <StylusButtonEventArgs> > StylusButtonUpObserver(this BulletDecorator This) { return(Observable.FromEventPattern <StylusButtonEventHandler, StylusButtonEventArgs>(h => This.StylusButtonUp += h, h => This.StylusButtonUp -= h)); }
private void SaveTreeView(XmlWriter writer) { if (writer == null) { return; } ItemCollection treeNodes = treeView.Items; if (treeNodes == null || treeNodes.Count == 0) { return; } SvgTestResult testResult = new SvgTestResult(); writer.WriteStartDocument(); writer.WriteStartElement("tests"); for (int i = 0; i < treeNodes.Count; i++) { TreeViewItem categoryItem = treeNodes[i] as TreeViewItem; if (categoryItem != null) { BulletDecorator header = categoryItem.Header as BulletDecorator; if (header == null) { continue; } TextBlock headerText = header.Child as TextBlock; if (headerText == null) { continue; } SvgTestCategory testCategory = new SvgTestCategory(headerText.Text); this.SaveTreeViewCategory(writer, categoryItem, testCategory); if (testCategory.IsValid) { testResult.Categories.Add(testCategory); } } } writer.WriteEndElement(); writer.WriteEndDocument(); if (_testResults == null) { _testResults = new List <SvgTestResult>(); } if (testResult.IsValid) { if (_testResults.Count == 0) { _testResults.Add(testResult); } } else { int foundAt = -1; for (int i = 0; i < _testResults.Count; i++) { SvgTestResult nextResult = _testResults[i]; if (nextResult != null && nextResult.IsValid) { if (string.Equals(nextResult.Version, testResult.Version)) { foundAt = i; break; } } } if (foundAt >= 0) { SvgTestResult nextResult = _testResults[foundAt]; if (!SvgTestResult.AreEqual(nextResult, testResult)) { _testResults[foundAt] = testResult; } } else { _testResults.Add(testResult); } } }
public static IObservable <EventPattern <RoutedEventArgs> > LostFocusObserver(this BulletDecorator This) { return(Observable.FromEventPattern <RoutedEventHandler, RoutedEventArgs>(h => This.LostFocus += h, h => This.LostFocus -= h)); }
public static IObservable <EventPattern <EventArgs> > LayoutUpdatedObserver(this BulletDecorator This) { return(Observable.FromEventPattern <EventHandler, EventArgs>(h => This.LayoutUpdated += h, h => This.LayoutUpdated -= h)); }
public static IObservable <EventPattern <KeyEventArgs> > PreviewKeyDownObserver(this BulletDecorator This) { return(Observable.FromEventPattern <KeyEventHandler, KeyEventArgs>(h => This.PreviewKeyDown += h, h => This.PreviewKeyDown -= h)); }