Beispiel #1
0
        /// <summary>
        /// Creates a layout for a document.
        /// </summary>
        /// <param name="document">The document.</param>
        /// <param name="parentControl">The parent control to which embedded objects can
        /// attach themselves.</param>
        /// <exception cref="ArgumentNullException">Thrown if <paramref name="document"/>
        /// or <paramref name="parentControl"/> is null.</exception>
        public SplashLayout(SplashDocument document, Control parentControl)
        {
            if (document == null)
                throw new ArgumentNullException("document");
            if (parentControl == null)
                throw new ArgumentNullException("parentControl");

            this.document = document;
            this.parentControl = parentControl;

            recursionGuard = new RecursionGuard();

            scriptMetricsCache = new ScriptMetricsCache();
            scriptLineBuffer = new UnmanagedBuffer(InitialCapacityForLinesPerDocument, sizeof(ScriptLine));

            tempScriptItemBuffer = new UnmanagedBuffer(InitialCapacityForScriptRunsPerParagraph, sizeof(SCRIPT_ITEM));
            tempEmbeddingLevelBuffer = new UnmanagedBuffer(InitialCapacityForScriptRunsPerParagraph, sizeof(byte));
            tempVisualToLogicalMapBuffer = new UnmanagedBuffer(InitialCapacityForScriptRunsPerParagraph, sizeof(int));
            tempLogicalClustersBuffer = new UnmanagedBuffer(InitialCapacityForCharsPerScriptRun, sizeof(short));

            scriptParagraphCache = new ScriptParagraphCache(ScriptParagraphCacheSize);

            embeddedObjectHosts = new Dictionary<int, EmbeddedObjectHost>();
            pendingEmbeddedObjectHostsToCreate = new Queue<EmbeddedObjectHost>();
            pendingEmbeddedObjectHostsToShow = new Queue<EmbeddedObjectHost>();

            desiredLayoutWidth = 400; // arbitrary
            desiredLayoutRightToLeft = false; // arbitrary

            AttachDocumentEvents();
            Reset();
        }
 public ScriptParagraphCache(int size)
 {
     buffer = new UnmanagedBuffer(size, sizeof(LruEntry));
 }
Beispiel #3
0
        private static void ScriptItemize(char* chars, int charCount, bool rightToLeft,
            UnmanagedBuffer tempScriptItemBuffer, out SCRIPT_ITEM* scriptItems, out int scriptItemCount)
        {
            var scriptControl = new SCRIPT_CONTROL();
            var scriptState = new SCRIPT_STATE();
            if (rightToLeft)
            {
                // Start in a RTL context.
                scriptState.uBidiLevel = 1;
            }

            for (; ; )
            {
                scriptItems = (SCRIPT_ITEM*)tempScriptItemBuffer.GetPointer();
                int result = NativeMethods.ScriptItemize(chars, charCount,
                    tempScriptItemBuffer.Capacity - 1 /*itemize needs 1 extra item beyond capacity as a sentinel*/,
                    &scriptControl, &scriptState, scriptItems, out scriptItemCount);
                if (result == NativeConstants.S_OK)
                    return;
                if (result != NativeConstants.E_OUTOFMEMORY)
                    Marshal.ThrowExceptionForHR(result);

                tempScriptItemBuffer.SetCapacity(tempScriptItemBuffer.Capacity * 2);
            }
        }
 public ScriptParagraphCache(int size)
 {
     buffer = new UnmanagedBuffer(size, sizeof(LruEntry));
 }