private void ApplyStyle(AnnotationBase anno, bool isText = false) { anno.Style = new ChartStyle() { Fill = new SolidColorBrush(ViewModel.ViewModel.Instance.AnnotationStyle.Fill), Stroke = new SolidColorBrush(ViewModel.ViewModel.Instance.AnnotationStyle.Stroke), }; if (isText) { anno.Style.FontFamily = new FontFamily(ViewModel.ViewModel.Instance.EditingAnnotationStyle.FontFamily); anno.Style.FontWeight = ViewModel.ViewModel.Instance.EditingAnnotationStyle.FontWeight; anno.Style.Stroke = new SolidColorBrush(ViewModel.ViewModel.Instance.EditingAnnotationStyle.Foreground); anno.Style.FontSize = ViewModel.ViewModel.Instance.EditingAnnotationStyle.FontSize; } else { var shape = anno as Shape; shape.ContentStyle = new ChartStyle() { FontFamily = new FontFamily(ViewModel.ViewModel.Instance.AnnotationStyle.FontFamily), FontWeight = ViewModel.ViewModel.Instance.AnnotationStyle.FontWeight, Stroke = new SolidColorBrush(ViewModel.ViewModel.Instance.AnnotationStyle.Foreground), FontSize = ViewModel.ViewModel.Instance.AnnotationStyle.FontSize, }; } }
private void UpdateAnnotation(AnnotationBase annotation) { annotation.Y1Value = 0d; annotation.Y2Value = 1d; annotation.ParentSurface.InvalidateElement(); }
private void ShowContentEditor(AnnotationBase anno, Point location) { Dispatcher.BeginInvoke(new Action(() => { EditorPopup.IsOpen = false; })); GetAnnotationEditorData(anno); ContentEditor.Annotation = anno; ContentEditor.UpdateEditorContent(); EditorPopup.Child = ContentEditor; EditorPopup.Width = double.NaN; EditorPopup.Height = double.NaN; Point pt = Application.Current.MainWindow.PointToScreen(location); Dispatcher.BeginInvoke(new Action(() => { EditorPopup.HorizontalOffset = pt.X; EditorPopup.VerticalOffset = pt.Y; EditorPopup.IsOpen = true; EditorPopup.Focus(); })); }
private void AddAnnotation(Point p, PointerRoutedEventArgs e) { _start = p; try { if (FlexChart.HitTest(_start).ChartElement == ChartElement.PlotArea) { _annotationToAdd = (AnnotationBase)Activator.CreateInstance(NewAnnotationType); _annotationToAdd.Attachment = Attachment; if (_annotationToAdd is Shape) { _annotationToAdd.SetValue(Shape.ContentProperty, NewAnnotationType.Name); } _annotationToAdd.Location = Helpers.CoordsToAnnoPoint(FlexChart, _annotationToAdd, _start); if (_annotationToAdd is Text) { var pt = e.GetCurrentPoint((Window.Current.Content as Frame).Content as MainPage).Position; var anno = this.HitTest(pt); if (anno == null) { ((Text)_annotationToAdd).Content = "New Text Annotation"; ShowContentEditor(_annotationToAdd, e.GetCurrentPoint((Window.Current.Content as Frame).Content as MainPage).Position); ContentEditor.Accept = () => { ApplyStyle(_annotationToAdd, true); this.Annotations.Add(_annotationToAdd); SelectedAnnotation = _annotationToAdd; }; ContentEditor.Reject = () => { _annotationToAdd = null; }; } return; } if (_annotationToAdd is Polygon) { var polygon = PolygonAddFunc(_start); polygon.Attachment = Attachment; for (int i = 0; i < polygon.Points.Count; i++) { polygon.Points[i] = Helpers.CoordsToAnnoPoint(FlexChart, polygon, polygon.Points[i]); } _annotationToAdd = polygon; } _drawing = true; //Start drawing on MouseMove _isDragging = false; ApplyStyle(_annotationToAdd); this.Annotations.Add(_annotationToAdd); SelectedAnnotation = _annotationToAdd; _flexChart.Invalidate(); } } catch (Exception ex) { throw new Exception(ex.Message); } }
private void ShowContentEditor(AnnotationBase anno, Point location) { ContentEditor.Annotation = anno; ContentEditor.UpdateEditorContent(); EditorPopup.Child = ContentEditor; EditorPopup.Width = double.NaN; EditorPopup.Height = double.NaN; Point pt = location; double x, y; if (FlexChart.ActualWidth - pt.X < 180) { x = FlexChart.ActualWidth - 180; y = pt.Y + 10; } else { x = pt.X + 10; y = pt.Y + 10; } EditorPopup.HorizontalOffset = x; EditorPopup.VerticalOffset = y; EditorPopup.IsOpen = true; }
internal override void UpdateAnnotations() { Annotations = new AnnotationBase[3]; var lengthDim = new LinearDimension(); lengthDim.Plane = Plane; lengthDim.Prefix = "Length "; lengthDim.DimensionLinePoint = new Point2d(0, -Settings.AnnotationOffset); lengthDim.ExtensionLine1End = new Point2d(0, 0); lengthDim.ExtensionLine2End = new Point2d(Length, 0); Annotations[0] = lengthDim; var widthDim = new LinearDimension(); widthDim.Plane = new Plane(Plane.Origin, Plane.YAxis, -Plane.XAxis); widthDim.Prefix = "Width "; widthDim.DimensionLinePoint = new Point2d(0, Settings.AnnotationOffset); widthDim.ExtensionLine1End = new Point2d(0, 0); widthDim.ExtensionLine2End = new Point2d(Width, 0); Annotations[1] = widthDim; var heightDim = new LinearDimension(); heightDim.Plane = new Plane(Plane.Origin, Vector3d.CrossProduct(Plane.XAxis, Plane.YAxis), Plane.XAxis); heightDim.Prefix = "Height "; heightDim.DimensionLinePoint = new Point2d(0, Settings.AnnotationOffset); heightDim.ExtensionLine1End = new Point2d(0, 0); heightDim.ExtensionLine2End = new Point2d(Height, 0); Annotations[2] = heightDim; }
public void AddAnnotation(AnnotationBase annotation) { annotation.SetBinding(AnnotationBase.IsInEditModeProperty, new Binding(IsInEditModeProperty.Name) { Source = this }); Annotations.Add(annotation); }
public AnnoLink(AnnotationBase annotation) { Annotation = annotation; Text = Annotation.ToString(); AutoSize = false; AutoEllipsis = true; TextAlign = System.Drawing.ContentAlignment.MiddleLeft; }
protected AnnotationAction(string name, AnnotationBase owner, string uri = null) { Name = name; Owner = owner; if (!string.IsNullOrEmpty(uri)) { Image = new BitmapImage(new Uri(uri)); } }
private static void StartRemove() { AnnotaionConfigDataList suffixs = GetCofnig(); if (suffixs == null) { Debug.LogError("未找到配置文件"); return; } var path = EditorUtility.OpenFolderPanel("选择目标文件夹", "", ""); Debug.Log(path); if (path == null || path == string.Empty) { return; } foreach (var p in suffixs.list) { if (p.extension == "") { continue; } string tmp = p.extension; AnnotationBase annotation = new AnnotationBase(p.multiLineStartStr, p.multiLineEndStr, p.singleLineStartStr, p.sensitiveWords); string[] files = System.IO.Directory.GetFiles(path, tmp, System.IO.SearchOption.AllDirectories); int total = files.Length; int index = 0; for (int i = 0; i < files.Length; i++) { string filePath = files[i]; index++; EditorUtility.DisplayCancelableProgressBar( "处理文件", string.Format("正在处理{0}", filePath.Replace("\\", "/")), (float)(index / total)); string text = FileUtility.ReadAllText(filePath); List <AnnotationBase.AnnotationData> tmpList = annotation.GetAllAnnotationData(text); for (int j = 0; j < tmpList.Count; j++) { AnnotationBase.AnnotationData annotationData = tmpList[j]; if (annotationData.isBeforeContent || annotationData.containsSensitiveWords) { string needRemoveStr = annotationData.originalText; Debug.Log(needRemoveStr); int startIndex = text.IndexOf(needRemoveStr); text = text.Remove(startIndex, needRemoveStr.Length); } } FileUtility.SaveFile(filePath, text); } } EditorUtility.ClearProgressBar(); EditorUtility.DisplayDialog("清理完成", string.Format("清理{0}下文件注释成功", path), "OK"); AssetDatabase.Refresh(ImportAssetOptions.ForceSynchronousImport); }
private void AddAnnotation(Point p) { _start = p; try { _annotationToAdd = (AnnotationBase)Activator.CreateInstance(NewAnnotationType); _annotationToAdd.Attachment = Attachment; _annotationToAdd.Location = Helpers.CoordsToAnnoPoint(FlexChart, _annotationToAdd, _start); if (_annotationToAdd is Text) { var pt = Mouse.GetPosition(FlexChart); var anno = this.HitTest(pt); if (anno == null) { ((Text)_annotationToAdd).Content = "New Text Annotation"; ShowContentEditor(_annotationToAdd, Mouse.GetPosition(Application.Current.MainWindow)); ContentEditor.Accept = () => { this.Annotations.Add(_annotationToAdd); SelectedAnnotation = _annotationToAdd; HideContentEditor(); }; ContentEditor.Reject = () => { _annotationToAdd = null; HideContentEditor(); }; } return; } if (_annotationToAdd is Polygon) { var polygon = PolygonAddFunc(_start); polygon.Attachment = Attachment; for (int i = 0; i < polygon.Points.Count; i++) { polygon.Points[i] = Helpers.CoordsToAnnoPoint(FlexChart, polygon, polygon.Points[i]); } _annotationToAdd = polygon; } _annotationToAdd.Style = new ChartStyle { Fill = Brushes.Red }; this.Annotations.Add(_annotationToAdd); SelectedAnnotation = _annotationToAdd; _drawing = true; //Start drawing on MouseMove _flexChart.Invalidate(); } catch (Exception ex) { Console.WriteLine(ex.Message); } }
public static void SetStyle(this AnnotationBase annotation, ChartStyle style) { if (annotation == null || annotation.Style == null) { return; } annotation.Style.Fill = style.Fill; annotation.Style.FontStyle = style.FontStyle; annotation.Style.Stroke = style.Stroke; annotation.Style.StrokeThickness = style.StrokeThickness; }
/// <summary> /// Fill creator name field in annotation info /// </summary> /// <param name="polylineAnnotation">AnnotationBase</param> protected static void FillCreatorName(AnnotationBase polylineAnnotation, AnnotationDataEntity annotationData) { CommentsEntity[] comments = annotationData.comments; if (comments != null && comments.Length > 0 && comments[0] != null) { polylineAnnotation.User = new User { Name = comments[0].userName }; } }
private void UpdateRectCache(AnnotationBase annoToUpdate) { if (annoToUpdate != null) { try { var anno = _rectCache.First(a => a.annotation == annoToUpdate); anno.BoundingRectangle = Helpers.GetRect(FlexChart, anno.annotation); } catch (Exception ex) { } } }
public static void SetStyle(this AnnotationBase annotation, ChartStyle style) { if (annotation == null || annotation.Style == null) { return; } annotation.Style.Fill = style.Fill; annotation.Style.FillColor = style.FillColor; annotation.Style.Font = style.Font; annotation.Style.Stroke = style.Stroke; annotation.Style.StrokeColor = style.StrokeColor; annotation.Style.StrokeDashPattern = style.StrokeDashPattern; annotation.Style.StrokeWidth = style.StrokeWidth; }
public static ChartStyle CloneStyle(this AnnotationBase annotation) { if (annotation == null || annotation.Style == null) { return(null); } return(new ChartStyle { Fill = annotation.Style.Fill, FontStyle = annotation.Style.FontStyle, Stroke = annotation.Style.Stroke, StrokeThickness = annotation.Style.StrokeThickness }); }
private void ShowContentEditor(AnnotationBase anno, PointF location) { if (!Chart.Controls.Contains(ContentEditor)) { Chart.Controls.Add(ContentEditor); } ContentEditor.Annotation = anno; ContentEditor.UpdateEditorContent(); if (location.X + ContentEditor.Width > Chart.PlotRect.Right) { location.X -= ContentEditor.Width; } ContentEditor.Location = Point.Round(location); ContentEditor.Visible = true; }
/// <summary> /// Gets the Annotation at the specified point /// </summary> /// <param name="pt">Point in control coordiantes</param> /// <returns>The Annotation at the specified point, null otherwise</returns> public AnnotationBase HitTest(PointF pt) { AnnotationBase selectedAnnotation = null; //Need to start hit-testing from the TopMost annotation foreach (var anno in this.Annotations.Reverse()) { var annoEx = _rectCache.First(a => a.annotation == anno); if (annoEx.HitTest(pt, 0)) { selectedAnnotation = annoEx.annotation; break; } } return(selectedAnnotation); }
internal override void UpdateAnnotations() { if (Annotations is null) { Annotations = new AnnotationBase[1]; } var dim = new LinearDimension(); dim.Plane = Plane; dim.Prefix = "Radius "; dim.DimensionLinePoint = new Point2d(0, 0); dim.ExtensionLine1End = new Point2d(0, 0); dim.ExtensionLine2End = new Point2d(Radius, 0); Annotations[0] = dim; }
internal override Annotation Clone(IDocumentEssential owner, Page page) { PDFDictionary res = AnnotationBase.Copy(Dictionary); IPDFObject open = Dictionary["Open"]; if (open != null) { res.AddItem("Open", open.Clone()); } PopupAnnotation annot = new PopupAnnotation(res, owner); annot.SetPage(Page, false); annot.SetPage(page, true); return(annot); }
public static ChartStyle CloneStyle(this AnnotationBase annotation) { if (annotation == null || annotation.Style == null) { return(null); } return(new ChartStyle { Fill = annotation.Style.Fill, FillColor = annotation.Style.FillColor, Font = annotation.Style.Font, Stroke = annotation.Style.Stroke, StrokeColor = annotation.Style.StrokeColor, StrokeDashPattern = annotation.Style.StrokeDashPattern, StrokeWidth = annotation.Style.StrokeWidth }); }
private void GetAnnotationEditorData(AnnotationBase anno) { var editStyle = (ContentEditor as AnnotationEditor).EditingAnnotationStyle; ChartStyle contentStyle = null; if (anno is Shape) { contentStyle = (anno as Shape).ContentStyle; } if (anno is Text) { contentStyle = anno.Style; Data.AnnotationStyle style = ViewModel.ViewModel.Instance.GetAnnotationStyle(Data.NewAnnotationType.Text); if (style != null && contentStyle != null) { contentStyle.FontFamily = new FontFamily(style.FontFamily); contentStyle.FontSize = contentStyle.FontSize == 0 ? style.FontSize : contentStyle.FontSize; } } if (editStyle != null && anno != null) { editStyle.Stroke = anno.Style == null || anno.Style.Stroke == null ? Colors.Black : (anno.Style.Stroke as SolidColorBrush).Color; editStyle.Fill = anno.Style == null || anno.Style.Fill == null ? Colors.Black : (anno.Style.Fill as SolidColorBrush).Color; } if (contentStyle != null) { if (anno is Text) { editStyle.Foreground = contentStyle == null || contentStyle.Stroke == null? ViewModel.ViewModel.Instance.GetAnnotationStyle(Data.NewAnnotationType.Text).Foreground : (contentStyle.Stroke as SolidColorBrush).Color; } else { editStyle.Foreground = contentStyle == null || contentStyle.Stroke == null ? Colors.Black : (contentStyle.Stroke as SolidColorBrush).Color; } editStyle.FontFamily = contentStyle.FontFamily.Source.ToString(); editStyle.FontSize = contentStyle.FontSize; editStyle.FontWeight = contentStyle.FontWeight; } }
private void AddAnnotation(PointF p) { _start = p; try { _annotationToAdd = (AnnotationBase)Activator.CreateInstance(NewAnnotationType); _annotationToAdd.Attachment = Attachment; _annotationToAdd.Location = Helpers.CoordsToAnnoPoint(Chart, _annotationToAdd, _start); if (_annotationToAdd is Text) { ((Text)_annotationToAdd).Content = "New Text Annotation"; ShowContentEditor(_annotationToAdd, p); ContentEditor.Accept = () => { this.Annotations.Add(_annotationToAdd); SelectedAnnotation = _annotationToAdd; HideContentEditor(); }; ContentEditor.Reject = () => { _annotationToAdd = null; HideContentEditor(); }; return; } if (_annotationToAdd is Polygon) { var polygon = PolygonAddFunc(_start); polygon.Attachment = Attachment; for (int i = 0; i < polygon.Points.Count; i++) { polygon.Points[i] = Helpers.CoordsToAnnoPoint(Chart, polygon, polygon.Points[i]); } _annotationToAdd = polygon; } this.Annotations.Add(_annotationToAdd); SelectedAnnotation = _annotationToAdd; _drawing = true; //Start drawing on MouseMove } catch (Exception ex) { Console.WriteLine(ex.Message); } }
/// <summary> /// Map AnnotationInfo instances into AnnotationDataEntity /// </summary> /// <param name="annotations">AnnotationInfo[]</param> /// <param name="pageNumber">int</param> /// <returns></returns> public static AnnotationDataEntity[] MapForPage(AnnotationBase[] annotations, int pageNumber, PageInfo pageInfo, string documentType) { // initiate annotations data array IList <AnnotationDataEntity> pageAnnotations = new List <AnnotationDataEntity>(); // each annotation data - this functionality used since annotations data returned by the // GroupDocs.Annotation library are obfuscated for (int n = 0; n < annotations.Length; n++) { AnnotationBase annotationInfo = annotations[n]; if (pageNumber == annotationInfo.PageNumber + 1) { AnnotationDataEntity annotation = MapAnnotationDataEntity(annotationInfo, pageInfo, documentType); pageAnnotations.Add(annotation); } } return(pageAnnotations.ToArray()); }
private void ShowContentEditor(AnnotationBase anno, Point location) { GetAnnotationEditorData(anno); ContentEditor.Annotation = anno; ContentEditor.UpdateEditorContent(); EditorPopup.Child = ContentEditor; EditorPopup.Width = double.NaN; EditorPopup.Height = double.NaN; Point pt = location; double x, y; bool outsideWidth = FlexChart.ActualWidth - pt.X < 180; bool outsideHeight = FlexChart.ActualHeight - pt.Y < 180; if (outsideWidth || outsideHeight) { if (outsideWidth && outsideHeight) { x = FlexChart.ActualWidth - 180; y = FlexChart.ActualHeight - 180; } else if (outsideWidth) { x = FlexChart.ActualWidth - 180; y = pt.Y - 10; } else { x = pt.X - 10; y = FlexChart.ActualHeight - 180; } } else { x = pt.X - 10; y = pt.Y - 10; } EditorPopup.HorizontalOffset = x; EditorPopup.VerticalOffset = y; EditorPopup.IsOpen = true; }
protected new AnnotationBase InitAnnotationBase(AnnotationBase annotationBase) { distanceAnnotation = base.InitAnnotationBase(annotationBase) as DistanceAnnotation; // add replies string text = annotationData.text ?? ""; CommentsEntity[] comments = annotationData.comments; if (comments != null && comments.Length != 0) { Reply reply = distanceAnnotation.Replies[0]; if (reply != null) { reply.Comment = string.Format("{0} {1}", text, reply.Comment); } } return(distanceAnnotation); }
private async void annotationsContainer_MouseLeftButtonDown(object sender, MouseButtonEventArgs e) { var _lastPosition = e.GetPosition(sender as IInputElement); await Task.Delay(100); if (!_cancelAddAnnotation) { var _lastCreateAnnotation = AnnotationBase.Create(SelectedAnnotationType, _lastPosition.X, _lastPosition.Y, SelectedBrush); AddAnnotation(_lastCreateAnnotation); var focusedElement = await _lastCreateAnnotation.GetElementToFocusOnCreating(); if (focusedElement != null) { focusedElement.CaptureMouse(); focusedElement.RaiseEvent(e); } } _cancelAddAnnotation = false; e.Handled = true; }
internal override void UpdateAnnotations() { Annotations = new AnnotationBase[2]; var widthDim = new LinearDimension(); widthDim.Plane = Plane; widthDim.Prefix = "Width "; widthDim.DimensionLinePoint = new Point2d(0, -Settings.AnnotationOffset); widthDim.ExtensionLine1End = new Point2d(0, 0); widthDim.ExtensionLine2End = new Point2d(Width, 0); Annotations[0] = widthDim; var heightDim = new LinearDimension(); heightDim.Plane = new Plane(Plane.Origin, Plane.YAxis, -Plane.XAxis); heightDim.Prefix = "Height "; heightDim.DimensionLinePoint = new Point2d(0, -Width - Settings.AnnotationOffset); heightDim.ExtensionLine1End = new Point2d(0, -Width); heightDim.ExtensionLine2End = new Point2d(Height, -Width); Annotations[1] = heightDim; }
/// <summary> /// Initial for annotation info /// </summary> /// <returns>AnnotationBase</returns> protected AnnotationBase InitAnnotationBase(AnnotationBase annotationBase) { // set page number to add annotation annotationBase.PageNumber = annotationData.pageNumber - 1; // set annotation type annotationBase.Type = GetType(); annotationBase.CreatedOn = DateTime.UtcNow; annotationBase.Id = annotationData.id; // add replies CommentsEntity[] comments = annotationData.comments; if (comments != null && comments.Length != 0) { Reply[] replies = new Reply[comments.Length]; for (int i = 0; i < comments.Length; i++) { Reply reply = GetAnnotationReplyInfo(comments[i]); replies[i] = reply; } annotationBase.Replies = replies.ToList(); } return(annotationBase); }
private void SetAnnotationEditorData(AnnotationBase anno, Data.AnnotationStyle style) { if (anno is Text) { if (anno.Style == null) { anno.Style = new ChartStyle(); } anno.Style.Fill = new SolidColorBrush(style.Fill); anno.Style.Stroke = new SolidColorBrush(style.Stroke); anno.Style.FontFamily = new FontFamily(style.FontFamily); anno.Style.FontWeight = style.FontWeight; anno.Style.Stroke = new SolidColorBrush(style.Foreground); anno.Style.FontSize = style.FontSize; } else if (anno is Shape) { var shape = anno as Shape; if (shape.Style == null) { shape.Style = new ChartStyle(); } shape.Style.Fill = new SolidColorBrush(style.Fill); shape.Style.Stroke = new SolidColorBrush(style.Stroke); if (shape.ContentStyle == null) { shape.ContentStyle = new ChartStyle(); } shape.ContentStyle.FontFamily = new FontFamily(style.FontFamily); shape.ContentStyle.FontWeight = style.FontWeight; shape.ContentStyle.Stroke = new SolidColorBrush(style.Foreground); shape.ContentStyle.FontSize = style.FontSize; } }
public static IAnnotation FromBytes(byte[] bytes) { AnnotationBase aBase = new AnnotationBase(bytes); switch (aBase.Type) { case AnnotationType.Base: return aBase; break; case AnnotationType.Image: return new ImageAnnotation(bytes); break; case AnnotationType.QuestionAndAnswer: return new QuestionAndAnswerAnnotation(bytes); break; case AnnotationType.Text: return new TextAnnotation(bytes); break; default: return aBase; break; } }