コード例 #1
0
        /// <summary>
        /// Get the HTML declaration for the content control type being inserted.
        /// </summary>
        /// <param name="cctType">A MappingType specifying the type of control to insert.</param>
        /// <returns>A string specifying the corresponding type HTML.</returns>
        private static string GetTypeInfo(Utilities.MappingType cctType)
        {
            switch (cctType)
            {
            case Utilities.MappingType.Text:
                return(@"Text=""t""");

            case Utilities.MappingType.DropDown:
                return(@"DropDown=""t""");

            case Utilities.MappingType.Picture:
                return(@"DisplayAsPicture=""t""");

            case Utilities.MappingType.Date:
                return(@"Calendar=""t"" MapToDateTime=""t""");

            default:
                return(string.Empty);
            }
        }
コード例 #2
0
        /// <summary>
        /// Get the placeholder text for the drag/drop HTML.
        /// </summary>
        /// <param name="cctType">A MappingType specifying the type of control to insert.</param>
        /// <returns>A string specifying the corresponding placeholder text.</returns>
        private static string GetPlaceholderText(Utilities.MappingType cctType)
        {
            switch (cctType)
            {
            case Utilities.MappingType.Text:
                return(Properties.Resources.PlainTextPlaceholder);

            case Utilities.MappingType.DropDown:
                return(Properties.Resources.DropDownPlaceholder);

            case Utilities.MappingType.Picture:
                return(string.Empty);

            case Utilities.MappingType.Date:
                return(Properties.Resources.DatePlaceholder);

            default:
                return(string.Empty);
            }
        }
コード例 #3
0
        /// <summary>
        /// Generate the HTML to put on the clipboard for drag and drop.
        /// </summary>
        /// <param name="strXPath">A string specifying the XPath to the node.</param>
        /// <param name="strPrefixMap">A string specifying any necessary prefix mappings.</param>
        /// <param name="strStoreId">A string specifying the ID to the corresponding XML part in the file.</param>
        /// <param name="cctType">A MappingType specifying the type of control to insert.</param>
        /// <returns>The HTML needed for drag/drop to succeed.</returns>
        internal static string GenerateClipboardHTML(string strXPath, string strPrefixMap, string strStoreId, Utilities.MappingType cctType)
        {
            //create HTML
            StringBuilder sb       = new StringBuilder();
            Encoding      encoding = Encoding.UTF8;

            //build it up
            string strPrefix   = string.Format(CultureInfo.InvariantCulture, cHtmlPrefix, encoding.WebName);
            string strStyles   = cHtmlStyles;
            string strHtmlBody = @"<w:Sdt PrefixMappings=""" + strPrefixMap + @""" Xpath=""" + strXPath + @""" ShowingPlcHdr=""t"" "
                                 + GetTypeInfo(cctType) + @"StoreItemID=""" + ConvertStoreID(strStoreId)
                                 + @"""><p class='MsoNormal'><span lang=X-NONE><w:sdtPr></w:sdtPr></span><span class='MsoPlaceholderText'>"
                                 + GetPlaceholderText(cctType) + "</span></w:Sdt>";
            string strSuffix = cHtmlSuffix;

            // Get lengths of chunks
            int HeaderLength = encoding.GetByteCount(cHeader);

            HeaderLength -= 16; // extra formatting characters {0:000000}

            //determine html points
            int StartHtml     = HeaderLength;
            int StartFragment = StartHtml + encoding.GetByteCount(strPrefix) + encoding.GetByteCount(strStyles);
            int EndFragment   = StartFragment + encoding.GetByteCount(strHtmlBody);
            int EndHtml       = EndFragment + encoding.GetByteCount(strSuffix);

            // Build the data
            sb.AppendFormat(CultureInfo.InvariantCulture, cHeader, StartHtml, EndHtml, StartFragment, EndFragment);
            sb.Append(strPrefix);
            sb.Append(strStyles);
            sb.Append(strHtmlBody);
            sb.Append(strSuffix);

            return(sb.ToString());
        }
コード例 #4
0
 internal static string GenerateClipboardHTML(bool needBind, string strXPath, string strPrefixMap, string strStoreId, Utilities.MappingType cctType,
                                              string strTitle, string strTag)
 {
     return(GenerateClipboardHTML(needBind, strXPath, strPrefixMap, strStoreId, cctType, strTitle, strTag, null));
 }