// Token: 0x06007854 RID: 30804 RVA: 0x002243FC File Offset: 0x002225FC public static void UpdateAnnotation(XmlToken token, StickyNoteControl snc, SNCAnnotation sncAnnotation) { AnnotationService annotationService = null; bool autoFlush = false; try { annotationService = AnnotationService.GetService(((IAnnotationComponent)snc).AnnotatedElement); if (annotationService != null && annotationService.Store != null) { autoFlush = annotationService.Store.AutoFlush; annotationService.Store.AutoFlush = false; } if ((token & XmlToken.Ink) != (XmlToken)0 && snc.Content.Type == StickyNoteType.Ink) { sncAnnotation.UpdateContent(snc, true, XmlToken.Ink); } if ((token & XmlToken.Text) != (XmlToken)0 && snc.Content.Type == StickyNoteType.Text) { sncAnnotation.UpdateContent(snc, true, XmlToken.Text); } if ((token & (XmlToken.Left | XmlToken.Top | XmlToken.XOffset | XmlToken.YOffset | XmlToken.Width | XmlToken.Height | XmlToken.IsExpanded | XmlToken.Author | XmlToken.ZOrder)) != (XmlToken)0) { SNCAnnotation.UpdateMetaData(token, snc, sncAnnotation); } } finally { if (annotationService != null && annotationService.Store != null) { annotationService.Store.AutoFlush = autoFlush; } } }
// Token: 0x06007855 RID: 30805 RVA: 0x002244C0 File Offset: 0x002226C0 public static void UpdateStickyNoteControl(XmlToken token, StickyNoteControl snc, SNCAnnotation sncAnnotation) { Invariant.Assert((token & (XmlToken.Left | XmlToken.Top | XmlToken.XOffset | XmlToken.YOffset | XmlToken.Width | XmlToken.Height | XmlToken.IsExpanded | XmlToken.Author | XmlToken.Text | XmlToken.Ink | XmlToken.ZOrder)) > (XmlToken)0, "No token specified."); Invariant.Assert(snc != null, "Sticky Note Control is null."); Invariant.Assert(sncAnnotation != null, "Annotation is null."); if ((token & XmlToken.Ink) != (XmlToken)0 && sncAnnotation.HasInkData) { sncAnnotation.UpdateContent(snc, false, XmlToken.Ink); } if ((token & XmlToken.Text) != (XmlToken)0 && sncAnnotation.HasTextData) { sncAnnotation.UpdateContent(snc, false, XmlToken.Text); } if ((token & XmlToken.Author) != (XmlToken)0) { int count = sncAnnotation._annotation.Authors.Count; string listSeparator = snc.Language.GetSpecificCulture().TextInfo.ListSeparator; string text = string.Empty; for (int i = 0; i < count; i++) { if (i != 0) { text = text + listSeparator + sncAnnotation._annotation.Authors[i]; } else { text += sncAnnotation._annotation.Authors[i]; } } snc.SetValue(StickyNoteControl.AuthorPropertyKey, text); } if ((token & XmlToken.Height) != (XmlToken)0) { XmlAttribute xmlAttribute = (XmlAttribute)sncAnnotation.FindData(XmlToken.Height); if (xmlAttribute != null) { double num = Convert.ToDouble(xmlAttribute.Value, CultureInfo.InvariantCulture); snc.SetValue(FrameworkElement.HeightProperty, num); } else { snc.ClearValue(FrameworkElement.HeightProperty); } } if ((token & XmlToken.Width) != (XmlToken)0) { XmlAttribute xmlAttribute = (XmlAttribute)sncAnnotation.FindData(XmlToken.Width); if (xmlAttribute != null) { double num2 = Convert.ToDouble(xmlAttribute.Value, CultureInfo.InvariantCulture); snc.SetValue(FrameworkElement.WidthProperty, num2); } else { snc.ClearValue(FrameworkElement.WidthProperty); } } if ((token & XmlToken.IsExpanded) != (XmlToken)0) { XmlAttribute xmlAttribute = (XmlAttribute)sncAnnotation.FindData(XmlToken.IsExpanded); if (xmlAttribute != null) { bool isExpanded = Convert.ToBoolean(xmlAttribute.Value, CultureInfo.InvariantCulture); snc.IsExpanded = isExpanded; } else { snc.ClearValue(StickyNoteControl.IsExpandedProperty); } } if ((token & XmlToken.ZOrder) != (XmlToken)0) { XmlAttribute xmlAttribute = (XmlAttribute)sncAnnotation.FindData(XmlToken.ZOrder); if (xmlAttribute != null) { ((IAnnotationComponent)snc).ZOrder = Convert.ToInt32(xmlAttribute.Value, CultureInfo.InvariantCulture); } } if ((token & (XmlToken.Left | XmlToken.Top | XmlToken.XOffset | XmlToken.YOffset)) != (XmlToken)0) { TranslateTransform translateTransform = new TranslateTransform(); if ((token & XmlToken.Left) != (XmlToken)0) { XmlAttribute xmlAttribute = (XmlAttribute)sncAnnotation.FindData(XmlToken.Left); if (xmlAttribute != null) { double num3 = Convert.ToDouble(xmlAttribute.Value, CultureInfo.InvariantCulture); if (snc.FlipBothOrigins) { num3 = -(num3 + snc.Width); } translateTransform.X = num3; } } if ((token & XmlToken.Top) != (XmlToken)0) { XmlAttribute xmlAttribute = (XmlAttribute)sncAnnotation.FindData(XmlToken.Top); if (xmlAttribute != null) { double y = Convert.ToDouble(xmlAttribute.Value, CultureInfo.InvariantCulture); translateTransform.Y = y; } } if ((token & XmlToken.XOffset) != (XmlToken)0) { XmlAttribute xmlAttribute = (XmlAttribute)sncAnnotation.FindData(XmlToken.XOffset); if (xmlAttribute != null) { snc.XOffset = Convert.ToDouble(xmlAttribute.Value, CultureInfo.InvariantCulture); } } if ((token & XmlToken.YOffset) != (XmlToken)0) { XmlAttribute xmlAttribute = (XmlAttribute)sncAnnotation.FindData(XmlToken.YOffset); if (xmlAttribute != null) { snc.YOffset = Convert.ToDouble(xmlAttribute.Value, CultureInfo.InvariantCulture); } } snc.PositionTransform = translateTransform; } }
/// <summary> /// This static method will update a StickyNoteControl object with the specified data in an Annotation /// </summary> /// <param name="token">A flag which indicates the data needs to be updated. The flag can be combinated with the any valid bits.</param> /// <param name="snc">A StickyNoteControl instance</param> /// <param name="sncAnnotation">An SNCAnnotation object which contains a CAF annotation object</param> public static void UpdateStickyNoteControl(XmlToken token, StickyNoteControl snc, SNCAnnotation sncAnnotation) { Invariant.Assert((token & AllValues) != 0, "No token specified."); Invariant.Assert(snc != null, "Sticky Note Control is null."); Invariant.Assert(sncAnnotation != null, "Annotation is null."); // XmlAttribute node; // Update Ink if ((token & XmlToken.Ink) != 0 && sncAnnotation.HasInkData) { sncAnnotation.UpdateContent(snc, false, XmlToken.Ink); } // Update Text if ((token & XmlToken.Text) != 0 && sncAnnotation.HasTextData) { sncAnnotation.UpdateContent(snc, false, XmlToken.Text); } // Update Author if ((token & XmlToken.Author) != 0) { int nCount = sncAnnotation._annotation.Authors.Count; // Get the culture specific text separator. string listSeparator = snc.Language.GetSpecificCulture().TextInfo.ListSeparator; string authors = string.Empty; for (int i = 0; i < nCount; i++) { if (i != 0) { authors += listSeparator + sncAnnotation._annotation.Authors[i]; } else { authors += sncAnnotation._annotation.Authors[i]; } } // Setting the author property will cause the UI to update snc.SetValue(StickyNoteControl.AuthorPropertyKey, authors); } // Update Height if ((token & XmlToken.Height) != 0) { node = (XmlAttribute)sncAnnotation.FindData(XmlToken.Height); if (node != null) { double height = Convert.ToDouble(node.Value, CultureInfo.InvariantCulture); snc.SetValue(FrameworkElement.HeightProperty, height); } else { snc.ClearValue(FrameworkElement.HeightProperty); } } // Update Width if ((token & XmlToken.Width) != 0) { node = (XmlAttribute)sncAnnotation.FindData(XmlToken.Width); if (node != null) { double width = Convert.ToDouble(node.Value, CultureInfo.InvariantCulture); snc.SetValue(FrameworkElement.WidthProperty, width); } else { snc.ClearValue(FrameworkElement.WidthProperty); } } // Update IsExpanded if ((token & XmlToken.IsExpanded) != 0) { node = (XmlAttribute)sncAnnotation.FindData(XmlToken.IsExpanded); if (node != null) { bool expanded = Convert.ToBoolean(node.Value, CultureInfo.InvariantCulture); snc.IsExpanded = expanded; } else { snc.ClearValue(StickyNoteControl.IsExpandedProperty); } } // Update ZOrder if ((token & XmlToken.ZOrder) != 0) { node = (XmlAttribute)sncAnnotation.FindData(XmlToken.ZOrder); if (node != null) { ((IAnnotationComponent)snc).ZOrder = Convert.ToInt32(node.Value, CultureInfo.InvariantCulture); } } // Update Position if ((token & PositionValues) != 0) { TranslateTransform transform = new TranslateTransform(); if ((token & XmlToken.Left) != 0) { node = (XmlAttribute)sncAnnotation.FindData(XmlToken.Left); if (node != null) { double left = Convert.ToDouble(node.Value, CultureInfo.InvariantCulture); // All 'left' values are persisted assuming two things: // 1) the top-left corner (visually) of the StickyNote is the origin of its coordinate space // 2) the positive x-axis of its parent is to the right // This flag signals that we have a positive x-axis to the left and our // top-right corner (visually) is our origin. So we need to flip the // value before using it. if (snc.FlipBothOrigins) { left = -(left + snc.Width); } transform.X = left; } } if ((token & XmlToken.Top) != 0) { node = (XmlAttribute)sncAnnotation.FindData(XmlToken.Top); if (node != null) { double top = Convert.ToDouble(node.Value, CultureInfo.InvariantCulture); transform.Y = top; } } // Now, we update the StickyNote offset if ((token & XmlToken.XOffset) != 0) { node = (XmlAttribute)sncAnnotation.FindData(XmlToken.XOffset); if (node != null) { snc.XOffset = Convert.ToDouble(node.Value, CultureInfo.InvariantCulture); } } if ((token & XmlToken.YOffset) != 0) { node = (XmlAttribute)sncAnnotation.FindData(XmlToken.YOffset); if (node != null) { snc.YOffset = Convert.ToDouble(node.Value, CultureInfo.InvariantCulture); } } // Set the adorner layer transform. snc.PositionTransform = transform; } }
//------------------------------------------------------------------------------- // // Public Methods // //------------------------------------------------------------------------------- #region Public Methods /// <summary> /// This static method will update an Annotation object with the specified data in a StickyNoteControl /// </summary> /// <param name="token">A flag which indicates the data needs to be updated. The flag can be combinated with the any valid bits.</param> /// <param name="snc">A StickyNoteControl instance</param> /// <param name="sncAnnotation">An SNCAnnotation object which contains a CAF annotation object</param> public static void UpdateAnnotation(XmlToken token, StickyNoteControl snc, SNCAnnotation sncAnnotation) { AnnotationService service = null; bool autoFlush = false; try { service = AnnotationService.GetService(((IAnnotationComponent)snc).AnnotatedElement); if (service != null && service.Store != null) { autoFlush = service.Store.AutoFlush; // Temporarily turn off autoflush until we are done // updating all the necessary values service.Store.AutoFlush = false; } Debug.Assert((token & AllValues) != 0); // Update Ink if ((token & XmlToken.Ink) != 0 && snc.Content.Type == StickyNoteType.Ink) { sncAnnotation.UpdateContent(snc, true, XmlToken.Ink); } // Update Text if ((token & XmlToken.Text) != 0 && snc.Content.Type == StickyNoteType.Text) { sncAnnotation.UpdateContent(snc, true, XmlToken.Text); } // Update MetaData if ((token & NegativeAllContents) != 0) { UpdateMetaData(token, snc, sncAnnotation); } } finally { if (service != null && service.Store != null) { // If auto flush was true before, setting it to true again should cause a flush. service.Store.AutoFlush = autoFlush; } } }