Example #1
0
        private static void BuildEntriesSection <T>(
            bytes::IBuffer buffer,
            EntryTypeEnum entryType,
            IList <T> items,
            BuildEntryDelegate <T> buildEntryFunction,
            string operatorSuffix,
            GetOutCodeDelegate outCodeFunction,
            string outCodeFormat
            )
        {
            if (items.Count == 0)
            {
                return;
            }

            for (int index = 0, count = items.Count; index < count; index++)
            {
                if (index % SubSectionMaxCount == 0)
                {
                    if (index > 0)
                    {
                        buffer.Append("end").Append(entryType.Tag()).Append(operatorSuffix).Append("\n");
                    }
                    buffer.Append(Math.Min(count - index, SubSectionMaxCount).ToString()).Append(" ").Append("begin").Append(entryType.Tag()).Append(operatorSuffix).Append("\n");
                }
                buildEntryFunction(items[index], buffer, outCodeFunction, outCodeFormat);
            }
            buffer.Append("end").Append(entryType.Tag()).Append(operatorSuffix).Append("\n");
        }
 /// <summary>
 /// Initializes a new instance of the <see cref="ResourceDataItem"/> class.
 /// </summary>
 /// <param name="resourceName">Name of the resource.</param>
 /// <param name="contentType">Type of the content.</param>
 /// <param name="filename">The filename.</param>
 /// <param name="dataType">Type of the data.</param>
 public ResourceDataItem(string resourceName, string contentType, string filename, string dataType)
 {
     m_resourceName = resourceName;
     m_contentType  = contentType;
     m_filename     = filename;
     m_dataType     = dataType;
     m_entryType    = EntryTypeEnum.Regular;
 }
 /// <summary>
 /// Initializes a new instance of the <see cref="ResourceDataItem"/> class.
 /// </summary>
 /// <param name="rdi">The rdi.</param>
 public ResourceDataItem(ResourceDataItem rdi)
 {
     m_resourceName = rdi.m_resourceName;
     m_contentType  = rdi.m_contentType;
     m_filename     = rdi.m_filename;
     m_dataType     = rdi.m_dataType;
     m_entryType    = rdi.m_entryType;
 }
Example #4
0
 /// <summary>
 /// Initializes a new instance of the <see cref="ResourceDataItem"/> class.
 /// </summary>
 /// <param name="resourceName">Name of the resource.</param>
 /// <param name="contentType">Type of the content.</param>
 /// <param name="filename">The filename.</param>
 /// <param name="dataType">Type of the data.</param>
 public ResourceDataItem(string resourceName, string contentType, string filename, string dataType)
 {
     m_resourceName = resourceName;
     m_contentType = contentType;
     m_filename = filename;
     m_dataType = dataType;
     m_entryType = EntryTypeEnum.Regular;
 }
Example #5
0
 /// <summary>
 /// Initializes a new instance of the <see cref="ResourceDataItem"/> class.
 /// </summary>
 /// <param name="rdi">The rdi.</param>
 public ResourceDataItem(ResourceDataItem rdi)
 {
     m_resourceName = rdi.m_resourceName;
     m_contentType = rdi.m_contentType;
     m_filename = rdi.m_filename;
     m_dataType = rdi.m_dataType;
     m_entryType = rdi.m_entryType;
 }
Example #6
0
 /// <summary>
 /// Initializes a new instance of the <see cref="ResourceItem"/> class.
 /// </summary>
 /// <param name="resourcePath">The resource path.</param>
 /// <param name="headerPath">The header path.</param>
 /// <param name="contentPath">The content path.</param>
 public ResourceItem(string resourcePath, string headerPath, string contentPath)
 {
     m_originalResourcePath = m_resourcePath = resourcePath;
     m_headerpath = headerPath;
     m_contentpath = contentPath;
     m_entryType = EntryTypeEnum.Regular;
     m_items = new List<ResourceDataItem>();
     m_isFolder = m_originalResourcePath.EndsWith("/"); //NOXLATE
 }
Example #7
0
 /// <summary>
 /// Initializes a new instance of the <see cref="ResourceItem"/> class.
 /// </summary>
 /// <param name="ri">The ri.</param>
 public ResourceItem(ResourceItem ri)
 {
     m_originalResourcePath = ri.m_originalResourcePath;
     m_headerpath = ri.m_headerpath;
     m_contentpath = ri.m_contentpath;
     m_resourcePath = ri.m_resourcePath;
     m_entryType = ri.m_entryType;
     m_isFolder = ri.m_isFolder;
     m_items = new List<ResourceDataItem>();
     foreach (ResourceDataItem rdi in ri.m_items)
         m_items.Add(new ResourceDataItem(rdi));
 }
Example #8
0
        /**
         * <summary>Builds a CMap according to the specified arguments.</summary>
         * <param name="entryType"></param>
         * <param name="cmapName">CMap name (<code>null</code> in case no custom name is needed).</param>
         * <param name="codes"></param>
         * <param name="outCodeFunction"></param>
         * <returns>Buffer containing the serialized CMap.</returns>
         */
        public static bytes::IBuffer Build(
            EntryTypeEnum entryType,
            string cmapName,
            SortedDictionary <ByteArray, int> codes,
            GetOutCodeDelegate outCodeFunction
            )
        {
            bytes::IBuffer buffer = new bytes::Buffer();

            // Header.
            string outCodeFormat;

            switch (entryType)
            {
            case EntryTypeEnum.BaseFont:
            {
                if (cmapName == null)
                {
                    cmapName = "Adobe-Identity-UCS";
                }
                buffer.Append(
                    "/CIDInit /ProcSet findresource begin\n"
                    + "12 dict begin\n"
                    + "begincmap\n"
                    + "/CIDSystemInfo\n"
                    + "<< /Registry (Adobe)\n"
                    + "/Ordering (UCS)\n"
                    + "/Supplement 0\n"
                    + ">> def\n"
                    + "/CMapName /").Append(cmapName).Append(" def\n"
                                                             + "/CMapVersion 10.001 def\n"
                                                             + "/CMapType 2 def\n"
                                                             + "1 begincodespacerange\n"
                                                             + "<0000> <FFFF>\n"
                                                             + "endcodespacerange\n"
                                                             );
                outCodeFormat = "<{0:X4}>";
                break;
            }

            case EntryTypeEnum.CID:
            {
                if (cmapName == null)
                {
                    cmapName = "Custom";
                }
                buffer.Append(
                    "%!PS-Adobe-3.0 Resource-CMap\n"
                    + "%%DocumentNeededResources: ProcSet (CIDInit)\n"
                    + "%%IncludeResource: ProcSet (CIDInit)\n"
                    + "%%BeginResource: CMap (").Append(cmapName).Append(")\n"
                                                                         + "%%Title: (").Append(cmapName).Append(" Adobe Identity 0)\n"
                                                                                                                 + "%%Version: 1\n"
                                                                                                                 + "%%EndComments\n"
                                                                                                                 + "/CIDInit /ProcSet findresource begin\n"
                                                                                                                 + "12 dict begin\n"
                                                                                                                 + "begincmap\n"
                                                                                                                 + "/CIDSystemInfo 3 dict dup begin\n"
                                                                                                                 + "/Registry (Adobe) def\n"
                                                                                                                 + "/Ordering (Identity) def\n"
                                                                                                                 + "/Supplement 0 def\n"
                                                                                                                 + "end def\n"
                                                                                                                 + "/CMapVersion 1 def\n"
                                                                                                                 + "/CMapType 1 def\n"
                                                                                                                 + "/CMapName /").Append(cmapName).Append(" def\n"
                                                                                                                                                          + "/WMode 0 def\n"
                                                                                                                                                          + "1 begincodespacerange\n"
                                                                                                                                                          + "<0000> <FFFF>\n"
                                                                                                                                                          + "endcodespacerange\n"
                                                                                                                                                          );
                outCodeFormat = "{0}";
                break;
            }

            default:
                throw new NotImplementedException();
            }

            // Entries.
            {
                IList <KeyValuePair <ByteArray, int> >  cidChars  = new List <KeyValuePair <ByteArray, int> >();
                IList <KeyValuePair <ByteArray, int>[]> cidRanges = new List <KeyValuePair <ByteArray, int>[]>();
                {
                    KeyValuePair <ByteArray, int>?  lastCodeEntry = null;
                    KeyValuePair <ByteArray, int>[] lastCodeRange = null;
                    foreach (KeyValuePair <ByteArray, int> codeEntry in codes)
                    {
                        if (lastCodeEntry.HasValue)
                        {
                            int codeLength = codeEntry.Key.Data.Length;
                            if (codeLength == lastCodeEntry.Value.Key.Data.Length &&
                                codeEntry.Key.Data[codeLength - 1] - lastCodeEntry.Value.Key.Data[codeLength - 1] == 1 &&
                                outCodeFunction(codeEntry) - outCodeFunction(lastCodeEntry.Value) == 1) // Contiguous codes.
                            {
                                if (lastCodeRange == null)
                                {
                                    lastCodeRange = new KeyValuePair <ByteArray, int>[] { lastCodeEntry.Value, default(KeyValuePair <ByteArray, int>) };
                                }
                            }
                            else // Separated codes.
                            {
                                AddEntry(cidRanges, cidChars, lastCodeEntry.Value, lastCodeRange);
                                lastCodeRange = null;
                            }
                        }
                        lastCodeEntry = codeEntry;
                    }
                    AddEntry(cidRanges, cidChars, lastCodeEntry.Value, lastCodeRange);
                }
                // Ranges section.
                BuildEntriesSection(buffer, entryType, cidRanges, BuildRangeEntry, "range", outCodeFunction, outCodeFormat);
                // Chars section.
                BuildEntriesSection(buffer, entryType, cidChars, BuildCharEntry, "char", outCodeFunction, outCodeFormat);
            }

            // Trailer.
            switch (entryType)
            {
            case EntryTypeEnum.BaseFont:
                buffer.Append(
                    "endcmap\n"
                    + "CMapName currentdict /CMap defineresource pop\n"
                    + "end\n"
                    + "end\n"
                    );
                break;

            case EntryTypeEnum.CID:
                buffer.Append(
                    "endcmap\n"
                    + "CMapName currentdict /CMap defineresource pop\n"
                    + "end\n"
                    + "end\n"
                    + "%%EndResource\n"
                    + "%%EOF"
                    );
                break;

            default:
                throw new NotImplementedException();
            }

            return(buffer);
        }
 public static void SetEntryType(BindableObject bindable, EntryTypeEnum entryType)
 {
     bindable.SetValue(EntryTypeProperty, entryType);
 }
Example #10
0
		public bool DriveDistanceSM_StopState(StateBehaviorEnum behavior, StateData submachineState, Signal signal, EntryTypeEnum enumEntryType, EntryEnum[] entryArray, int nArrayCount) 
		{
			if (m_StateMachineImpl == null)
				return false;
	
			StateData state = m_StateMachineImpl.GetStateObject(submachineState, (int)StateEnum.DriveDistance_ENUM_DRIVEDISTANCESM_STOPSTATE);
			switch (behavior) 
			{
				case StateBehaviorEnum.ENTRY:
					if(state.active_count > 0)
						return false;
					m_drivedistancesm = StateEnum.DriveDistance_ENUM_DRIVEDISTANCESM_STOPSTATE;
					state.IncrementActiveCount();
					DriveDistanceSM_StopState_behavior(StateBehaviorEnum.ENTRY);
			
					if(enumEntryType == EntryTypeEnum.HistoryEntry)
					{
						return true;
					}
			
					DriveDistanceSM_StopState_behavior(StateBehaviorEnum.DO);
					if((enumEntryType == EntryTypeEnum.EntryPointEntry || enumEntryType == EntryTypeEnum.DefaultEntry) && state.IsActiveState())
						m_StateMachineImpl.deferInternalEvent(EventEnum.COMPLETION, null, state);
					break;
				case StateBehaviorEnum.EXIT:
					if(state.active_count == 0)
						return false;
					m_drivedistancesm = StateEnum.NOSTATE;
					state.DecrementActiveCount();
					DriveDistanceSM_StopState_behavior(StateBehaviorEnum.EXIT);
					m_StateMachineImpl.removeInternalEvent(state);
					break;
			}
	
			return true;
		}
Example #11
0
		public bool StateProc(StateEnum state, StateData submachineState, StateBehaviorEnum behavior, Signal signal, EntryTypeEnum enumEntryType, EntryEnum[] entryArray, int nArrayCount)
		{
			switch (state) 
			{
				case StateEnum.DriveDistance_ENUM_DRIVEDISTANCESM_FORWARDSTATE:
					DriveDistanceSM_ForwardState(behavior, submachineState, signal, enumEntryType, entryArray, nArrayCount);
					break;

				case StateEnum.DriveDistance_ENUM_DRIVEDISTANCESM_STOPSTATE:
					DriveDistanceSM_StopState(behavior, submachineState, signal, enumEntryType, entryArray, nArrayCount);
					break;
			}
			return false;
		}
Example #12
0
		public bool StateProc(int state, StateData submachineState, StateBehaviorEnum behavior, Signal signal, EntryTypeEnum enumEntryType, int[] entryArray, int nArrayCount)
		{
			EntryEnum[] entryEnumArray = new EntryEnum[nArrayCount];
			for (int i = 0; i < nArrayCount; i++)
			{
				if (entryArray != null && i < entryArray.Length)
					entryEnumArray[i] = (EntryEnum)entryArray[i];
			}      
			return StateProc((StateEnum)state, submachineState, behavior, signal, enumEntryType, entryEnumArray, nArrayCount);
		}
Example #13
0
		public virtual bool StateProc(StateEnum state, StateData submachineState, StateBehaviorEnum behavior, Signal signal, EntryTypeEnum enumEntryType)
		{
			return StateProc(state, submachineState, behavior, signal, enumEntryType, null, 0);
		}