Ejemplo n.º 1
0
        //-------------------------------------------------------------------
        //
        //  Public Methods
        //
        //-------------------------------------------------------------------

        #region Public Methods

        /// <summary>
        /// A method which creates a specified type content control.
        /// </summary>
        /// <param name="type"></param>
        /// <param name="content"></param>
        /// <returns></returns>
        public static StickyNoteContentControl CreateContentControl(StickyNoteType type, UIElement content)
        {
            StickyNoteContentControl contentControl = null;

            switch (type)
            {
            case StickyNoteType.Text:
            {
                RichTextBox rtb = content as RichTextBox;
                if (rtb == null)
                {
                    throw new InvalidOperationException(SR.Get(SRID.InvalidStickyNoteTemplate, type, typeof(RichTextBox), SNBConstants.c_ContentControlId));
                }

                contentControl = new StickyNoteRichTextBox(rtb);
                break;
            }

            case StickyNoteType.Ink:
            {
                InkCanvas canvas = content as InkCanvas;
                if (canvas == null)
                {
                    throw new InvalidOperationException(SR.Get(SRID.InvalidStickyNoteTemplate, type, typeof(InkCanvas), SNBConstants.c_ContentControlId));
                }

                contentControl = new StickyNoteInkCanvas(canvas);
                break;
            }
            }

            return(contentControl);
        }
Ejemplo n.º 2
0
        // Token: 0x06007871 RID: 30833 RVA: 0x00224F6C File Offset: 0x0022316C
        public static StickyNoteContentControl CreateContentControl(StickyNoteType type, UIElement content)
        {
            StickyNoteContentControl result = null;

            if (type != StickyNoteType.Text)
            {
                if (type == StickyNoteType.Ink)
                {
                    InkCanvas inkCanvas = content as InkCanvas;
                    if (inkCanvas == null)
                    {
                        throw new InvalidOperationException(SR.Get("InvalidStickyNoteTemplate", new object[]
                        {
                            type,
                            typeof(InkCanvas),
                            "PART_ContentControl"
                        }));
                    }
                    result = new StickyNoteContentControlFactory.StickyNoteInkCanvas(inkCanvas);
                }
            }
            else
            {
                RichTextBox richTextBox = content as RichTextBox;
                if (richTextBox == null)
                {
                    throw new InvalidOperationException(SR.Get("InvalidStickyNoteTemplate", new object[]
                    {
                        type,
                        typeof(RichTextBox),
                        "PART_ContentControl"
                    }));
                }
                result = new StickyNoteContentControlFactory.StickyNoteRichTextBox(richTextBox);
            }
            return(result);
        }
        // Token: 0x06007862 RID: 30818 RVA: 0x00224C48 File Offset: 0x00222E48
        private void UpdateContent(StickyNoteControl snc, bool updateAnnotation, XmlToken token)
        {
            Invariant.Assert(snc != null, "Sticky Note Control is null.");
            Invariant.Assert((token & (XmlToken.Text | XmlToken.Ink)) > (XmlToken)0, "No token specified.");
            StickyNoteContentControl content = snc.Content;

            if (content == null)
            {
                return;
            }
            if ((token == XmlToken.Ink && content.Type != StickyNoteType.Ink) || (token == XmlToken.Text && content.Type != StickyNoteType.Text))
            {
                return;
            }
            XmlElement xmlElement = null;

            if (updateAnnotation)
            {
                AnnotationResource annotationResource = null;
                bool flag  = false;
                bool flag2 = false;
                if (!content.IsEmpty)
                {
                    SNCAnnotation.GetCargoAndRoot(this, token, out annotationResource, out xmlElement, out flag2, out flag);
                    content.Save(xmlElement);
                }
                else
                {
                    string cargoName = SNCAnnotation.GetCargoName(token);
                    annotationResource = this.FindCargo(cargoName);
                    if (annotationResource != null)
                    {
                        this._annotation.Cargos.Remove(annotationResource);
                        this._cachedXmlElements.Remove(token);
                    }
                }
                if (flag)
                {
                    Invariant.Assert(xmlElement != null, "XmlElement should have been created.");
                    Invariant.Assert(annotationResource != null, "Cargo should have been retrieved.");
                    annotationResource.Contents.Add(xmlElement);
                }
                if (flag2)
                {
                    Invariant.Assert(annotationResource != null, "Cargo should have been created.");
                    this._annotation.Cargos.Add(annotationResource);
                    return;
                }
            }
            else
            {
                XmlElement xmlElement2 = (XmlElement)this.FindData(token);
                if (xmlElement2 != null)
                {
                    content.Load(xmlElement2);
                    return;
                }
                if (!content.IsEmpty)
                {
                    content.Clear();
                }
            }
        }