Esempio 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);
        }
Esempio 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);
        }
        //-------------------------------------------------------------------
        //
        //  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;
        }