//外部方法:根据文件名获取文件数据 //[Benchmark] public Byte[] GetFile(string name) { //先从缓存区查找文件 if (MyCache.GetInstance().GetCacheFile(name) != null) { return(MyCache.instance.GetCacheFile(name)); } //根据文件头信息读出文件 if (!filesDic.ContainsKey(name)) { throw new Exception("文件" + name + "不存在!"); } HeadInfo targetHead = filesDic[name]; byte[] result = new byte[targetHead.length]; using (FileStream fs = new FileStream(packPath, FileMode.Open)) { fs.Seek(targetHead.start, SeekOrigin.Begin); fs.Read(result, 0, targetHead.length); } //当前文件进行一次规律判断 MyCache.GetInstance().RuleDetection(name, result); return(result); }
public static ParseHeaderResult ParseHeader(HeadInfo headInfo, int clubId) { string homeTeamName; string awayTeamName; if (headInfo.MatchHomeClubId == clubId) { homeTeamName = headInfo.MatchHomeTeamAlias !; awayTeamName = headInfo.MatchAwayTeamAlias !; } else if (headInfo.MatchAwayClubId == clubId) { homeTeamName = headInfo.MatchAwayTeamAlias !; awayTeamName = headInfo.MatchHomeTeamAlias !; } else { throw new Exception($"Unmatched clubId: {clubId}"); } ParseHeaderResult result = new( homeTeamName, awayTeamName, headInfo.MatchRoundId, headInfo.MatchDate !.ToDateTime(headInfo.MatchTime), headInfo.MatchHallName !, OilPatternInformation.Create( headInfo.MatchOilPatternName !, headInfo.MatchOilPatternId)); return(result); }
public void SetText(Transform trans, string text) { HeadInfo headInfo = GetHeadInfo(trans); headInfo.nameInfo.text = text; headInfo.nameInfo.coloredText = "[ffa7ff]" + text + "[-]"; }
/// <summary> /// 构造函数 /// </summary> /// <param name="filePath"></param> /// <param name="unpackPath"></param> public ResExtract(byte[] bytes) { mTotalBytes = bytes; int headSize = BitConverter.ToInt32(bytes, 0); bool isBinary = BitConverter.ToBoolean(bytes, 4); mHeadInfo = new HeadInfo(); mHeadInfo.headSize = headSize; mHeadInfo.isBinary = isBinary; // 获取文件名和文件位置 int fileCount = 0; int index = 5; while (index < headSize + 4) { var fileNameLength = (byte)BitConverter.ToChar(bytes, index); index += 1; var fileName = Encoding.UTF8.GetString(bytes, index, fileNameLength); index += fileNameLength; var fileOffset = BitConverter.ToInt32(bytes, index); index += 4; mHeadInfo.fileOffsets[fileName] = fileOffset; fileCount++; } mFileCount = fileCount; }
public void SetupParticles(ref HeadInfo head) { //m_Particles.Clear(); if (m_Root == null) { return; } m_rootParentTransform = m_Root.parent; m_LocalGravity = m_Root.InverseTransformDirection(m_Gravity); m_ObjectScale = Mathf.Abs(transform.lossyScale.x); m_ObjectPrevPosition = transform.position; m_ObjectMove = Vector3.zero; m_BoneTotalLength = 0; AppendParticles(m_Root, -1, 0, ref head); UpdateParameters(); for (int i = 0; i < m_ParticleCount; i++) { m_particleTransformArr[i].parent = null; } m_headInfo.m_particleCount = m_ParticleCount; }
static Hash ChessGetHash(string className) { string fileName = className + ".tsv"; SettingParser parser = new SettingParser(fileName); parser.Parse(true); Hash hash = new Hash(); hash["ClassName"] = className; List <Hash> headsHash = new List <Hash>(); foreach (var h in parser.heads) { HeadInfo headInfo = h.Value; Hash head = new Hash(); head["name"] = headInfo.name; head["type"] = headInfo.type; head["meta"] = headInfo.meta; Debug.Log("head name " + headInfo.name); headsHash.Add(head); } hash["heads"] = headsHash; return(hash); }
//构造函数:资源包解析。初始化主要目的是把资源包中所有文件头信息保存到字典中。 public MyPackReader(string packPath) { int readPosition = 0; packByte = File.ReadAllBytes(packPath); //读取整个资源包,将所有头文件记录到字典中。 while (readPosition < packByte.Length) { //获取文件头的长度 int hh = 4; byte[] hhByte = new byte[4]; Array.Copy(packByte, readPosition, hhByte, 0, 4); int headLength = hhByte[0] + hhByte[1] * 256 + hhByte[2] * 256 * 256 + hhByte[3] * 256 * 256 * 256; //获取文件头信息,存入字典 byte[] headByte = new byte[headLength]; Array.Copy(packByte, readPosition + hh, headByte, 0, headLength); HeadInfo currentHead = (HeadInfo)BytesToStruct(headByte, typeof(HeadInfo)); currentHead.start += hh + headLength; filesDic.Add(currentHead.name, currentHead); //移动到下一个文件空间 readPosition = readPosition + headLength + currentHead.length + hh; } }
public static async Task <HeadInfo> GetHeadInfo(int matchId) { HeadInfo headInfo = await Try( $"HeadInfo-{matchId}.json", () => Client.GetHeadInfo(matchId)); return(headInfo); }
/// <summary> /// Called when a new user is leaving. /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void Instance_SessionLeft(object sender, SharingSessionTracker.SessionLeftEventArgs e) { HeadInfo headInfo = remoteHeadInfos[e.exitingUserId]; DestroyImmediate(headInfo.headInfo.HeadObject); DestroyImmediate(headInfo.headProxyInfo.HeadObject); remoteHeadInfos.Remove(e.exitingUserId); }
public void InitDevice() { HeadInfo.InitDeviceInfo(); UDPServer.InitRouterDevices(); ResultModel model = new ResultModel(); string jsonData = JsonConvert.SerializeObject(model); Clients.All.InitDeviceCall(model); }
//外部方法:添加一个文件到包 public void AddFile(string name, byte[] file, string path) { //记录头文件信息并转为byte[] HeadInfo currentInfo = new HeadInfo(positionCount, file.Length); byte[] structByte = StructToBytes(currentInfo); //将文件信息和文件数据写入包中 CopyToPackByte(name, structByte, file, path); }
public BitsMatchResult( MatchResults matchResults, MatchScores matchScores, HeadResultInfo headResultInfo, HeadInfo headInfo) { MatchResults = matchResults; MatchScores = matchScores; HeadResultInfo = headResultInfo; HeadInfo = headInfo; }
/// <summary> /// Change header text with new data /// </summary> /// <returns>New header</returns> internal void ChangeHeader() { // find string with needed value Regex regex = new Regex(@"К(\s*)о(\s*)л(\s*)и(\s*)ч(\s*)е(\s*)с(\s*)т(\s*)в(\s*)о(\s+)н(\s*)а(\s*)р(\s*)у(\s*)ш(\s*)е(\s*)н(\s*)и(\s*)й(\s*):(\s+\d+)", RegexOptions.IgnoreCase | RegexOptions.Compiled); Match match = regex.Match(HeadInfo.ToString()); // calculate count of voluation int count = TableData.Where(i => i.OOR == true).Count(); // change header HeadInfo.Replace(match.Value, $"Количество нарушений: {count}"); }
HeadInfo GetHeadInfo(Transform trans) { HeadInfo headInfo = FindHeadInfo(trans); if (null == headInfo) { headInfo = new HeadInfo(); headInfo.targetTran = trans; headInfo.nameInfo = new NameInfo(); } return(headInfo); }
/// <summary> /// 更新头像信息 /// </summary> /// <param name="unit"></param> public void updateHeadInfo(GameObject unit) { BattleUnit data = unit.GetComponent <BattleUnit> (); chooseIcon.transform.position = new Vector3( unit.transform.position.x, unit.transform.position.y + data.getHeight(), 0); chooseIcon.SetActive(true); HeadInfo info = buttonHead.GetComponent <HeadInfo> (); info.updateHead(data.getUnitId(), data.GetAttributeData()); }
void UpdateDynamicBones(float t, ref HeadInfo head) { if (m_Root == null) { return; } m_ObjectScale = Mathf.Abs(transform.lossyScale.x); m_ObjectMove = m_transform.position - m_ObjectPrevPosition; m_ObjectPrevPosition = transform.position; Vector3 force = m_Gravity; Vector3 fdir = m_Gravity.normalized; Vector3 rf = m_Root.TransformDirection(m_LocalGravity); Vector3 pf = fdir * Mathf.Max(Vector3.Dot(rf, fdir), 0); // project current gravity to rest gravity force -= pf; // remove projected gravity force = (force + m_Force) * m_ObjectScale; int loop = 1; if (m_UpdateRate > 0) { float dt = 1.0f / m_UpdateRate; m_Time += t; loop = 0; while (m_Time >= dt) { m_Time -= dt; if (++loop >= 3) { m_Time = 0; break; } } } loop = math.max(1, loop); if (loop > 0) { for (int i = 0; i < loop; ++i) { UpdateParticles1(force, ref head); UpdateParticles2(ref head); m_ObjectMove = Vector3.zero; } } ApplyParticlesToTransforms(); }
public void SetWeight(float w, ref HeadInfo head) { if (head.m_Weight != w) { if (w == 0) { InitTransforms(); } else if (head.m_Weight == 0) { ResetParticlesPosition(ref head); } head.m_Weight = w; } }
protected override void onUnitInit() { mAttr.reset(); mSkill.reset(); mBuff.reset(); mMove.reset(); mAI.reset(); mSkill.addSkills(GHelper.toIntArray(table.skills)); if (!isServer) { mHeadInfo = HeadInfo.Bind(this.transform, this); } }
public static async Task <BitsMatchResult> GetBitsMatchResult(this IBitsClient client, int matchId) { Task <MatchResults> matchResultsTask = client.GetMatchResults(matchId); Task <MatchScores> matchScoresTask = client.GetMatchScores(matchId); Task <HeadResultInfo> headResultInfoTask = client.GetHeadResultInfo(matchId); Task <HeadInfo> headInfoTask = client.GetHeadInfo(matchId); await Task.WhenAll(matchResultsTask, matchScoresTask, headResultInfoTask, headInfoTask); MatchResults matchResults = await matchResultsTask; MatchScores matchScores = await matchScoresTask; HeadResultInfo headResultInfo = await headResultInfoTask; HeadInfo headInfo = await headInfoTask; return(new BitsMatchResult(matchResults, matchScores, headResultInfo, headInfo)); }
void UpdateParticles2(ref HeadInfo head) { for (int i = 1; i < m_ParticleCount; ++i) { Particle p = m_Particles[i]; Particle p0 = m_Particles[p.m_ParentIndex]; float3 ePos = p.worldPosition; float3 ep0Pos = p0.worldPosition; float erestLen = math.distance(ep0Pos, ePos); // keep shape float stiffness = Mathf.Lerp(1.0f, p.m_Stiffness, head.m_Weight); if (stiffness > 0 || p.m_Elasticity > 0) { //extend, 本地坐标变换到父级空间下计算距离 float4x4 em0 = float4x4.TRS(p0.tmpWorldPosition, p0.worldRotation, p.parentScale); float3 erestPos = math.mul(em0, new float4(p.localPosition.xyz, 1)).xyz; float3 ed = erestPos - p.tmpWorldPosition; float3 eStepElasticity = ed * p.m_Elasticity; p.tmpWorldPosition += eStepElasticity; if (stiffness > 0) { float len = math.distance(erestPos, p.tmpWorldPosition); float maxlen = erestLen * (1 - stiffness) * 2; if (len > maxlen) { float3 max = ed * ((len - maxlen) / len); p.tmpWorldPosition += max; } } } float3 edd = p0.tmpWorldPosition - p.tmpWorldPosition; float eleng = math.distance(p0.tmpWorldPosition, p.tmpWorldPosition); if (eleng > 0) { float3 tmp = edd * ((eleng - erestLen) / eleng); p.tmpWorldPosition += tmp; } m_Particles[p.index] = p; } }
//TODO: Step 4 create Handler to receive network message and update current application state. /// <summary> /// Called when a remote user sends a head transform. /// </summary> /// <param name="msg"></param> void UpdateHeadTransform(NetworkInMessage msg) { // Parse the message long userID = msg.ReadInt64(); Vector3 headPos = CustomMessages.Instance.ReadVector3(msg); Quaternion headRot = CustomMessages.Instance.ReadQuaternion(msg); HeadInfo headInfo = GetRemoteHeadInfo(userID); headInfo.headInfo.HeadObject.transform.localPosition = headPos; headInfo.headInfo.HeadObject.transform.localRotation = headRot; headInfo.headProxyInfo.HeadObject.transform.localPosition = ProxyUpdater.MiniaturizePosition(headPos); headInfo.headProxyInfo.HeadObject.transform.localRotation = headRot; }
private void ShowAsInstanceType5() { HeadInfo headInfo = DataReader <HeadInfo> .Get(this.actorType); if (headInfo != null && headInfo.InstanceType4.get_Count() >= 5) { HeadInfoManager.Instance.ShowName(this.uuid, headInfo.InstanceType5.get_Item(0) == 1); HeadInfoManager.Instance.ShowTitle(this.uuid, headInfo.InstanceType5.get_Item(1) == 1); HeadInfoManager.Instance.ShowBloodBarByScene(this.uuid, headInfo.InstanceType5.get_Item(2) == 1); HeadInfoManager.Instance.ShowGuildTitle(this.uuid, headInfo.InstanceType5.get_Item(3) == 1); HeadInfoManager.Instance.ShowCommonIcon(this.uuid, headInfo.InstanceType5.get_Item(4) == 1); } else { this.HideAll(this.uuid); } }
/// <summary> /// 销毁 /// </summary> public void Destroy() { if (mFileBytes != null) { mFileBytes.Clear(); mFileBytes = null; } mFileCount = 0; if (mHeadInfo != null) { mHeadInfo.fileOffsets.Clear(); mHeadInfo = null; } mTotalBytes = null; }
/// <inheritdoc/> public override Task Connect(HeadInfo request, IServerStreamWriter <Empty> responseStream, ServerCallContext context) { var headId = request.HeadId.To <HeadId>(); Timer timer = null; try { _logger.Information($"Head connected '{headId}'"); if (request.ServicesByName.Count == 0) { _logger.Information("Not providing any head services"); } else { request.ServicesByName.ForEach(_ => _logger.Information($"Providing service {_}")); } var connectionTime = _systemClock.GetCurrentTime(); var client = new Head( headId, request.Host, request.Port, request.Runtime, request.ServicesByName, connectionTime); _connectedHeads.Connect(client); timer = new Timer(1000) { Enabled = true }; timer.Elapsed += (s, e) => responseStream.WriteAsync(new Empty()); context.CancellationToken.ThrowIfCancellationRequested(); context.CancellationToken.WaitHandle.WaitOne(); } finally { _connectedHeads.Disconnect(headId); timer?.Dispose(); } return(Task.CompletedTask); }
private void Awake() { m_transform = this.transform; m_headInfo = new HeadInfo(); m_headInfo.m_UpdateRate = this.m_UpdateRate; m_headInfo.m_ObjectMove = this.m_ObjectMove; m_headInfo.m_Weight = this.m_Weight; m_headInfo.m_particleCount = 0; m_Particles = new NativeArray <Particle>(MAX_TRANSFORM_LIMIT, Allocator.Persistent); m_particleTransformArr = new Transform[MAX_TRANSFORM_LIMIT]; m_ParticleCount = 0; m_GravityNormalize = m_Gravity.normalized; SetupParticles(ref m_headInfo); }
//外部方法:根据文件名获取文件数据 public Byte[] GetFile(string name) { //先从缓存区查找文件 if (MyCache.GetInstance().GetCacheFile(name) != null) { return(MyCache.instance.GetCacheFile(name)); } //根据文件头信息读出文件 HeadInfo targetHead = filesDic[name]; byte[] result = new byte[targetHead.length]; Array.Copy(packByte, targetHead.start, result, 0, targetHead.length); //当前文件进行一次规律判断 MyCache.GetInstance().RuleDetection(name, result); return(result); }
void ResetParticlesPosition(ref HeadInfo head) { //for (int i = 0; i < m_ParticleCount; ++i) //{ // Particle p = m_Particles[i]; // Transform trans = m_particleTransformArr[p.index]; // if (trans != null) // { // p.m_Position = p.m_PrevPosition = trans.position; // } // else // end bone // { // Transform pb = m_particleTransformArr[p.m_ParentIndex]; // p.m_Position = p.m_PrevPosition = pb.TransformPoint(p.m_EndOffset); // } // p.m_isCollide = 0; // m_Particles[i] = p; //} m_ObjectPrevPosition = m_transform.position; }
static void server_OnChangeState(Recv机头网络状态报告 cmd) { string routeToken = cmd.RecvData.routeAddress; string headAddress = cmd.机头地址; int? deviceId = null; //获取控制器实体 Base_DeviceInfo router = DeviceBusiness.GetDeviceModel(routeToken); Data_MerchDevice merchDevice = MerchDeviceBusiness.GetMerchModel(router.ID, headAddress); if (merchDevice != null) { deviceId = merchDevice.DeviceID; } if (deviceId == null) { Data_MerchSegment merchSegment = MerchSegmentBusiness.GetMerchSegmentModel(router.ID, headAddress); if (merchSegment == null) { deviceId = merchDevice.DeviceID; } } if (deviceId != null) { Base_DeviceInfo device = DeviceBusiness.GetDeviceModelById((int)deviceId); if (device != null) { List <HeadInfo.机头信息> headList = HeadInfo.GetAllHead(); HeadInfo.机头信息 head = headList.FirstOrDefault(t => t.令牌 == device.Token); string strDeviceState = GetDeviceState(head); string state = DeviceStatusBusiness.GetDeviceState(device.Token); if (state != strDeviceState) { DeviceStatusBusiness.SetDeviceState(device.Token, strDeviceState); } } } }
private void ParseConfig(byte[] bytes) { int offset = 0; HeadInfo headInfo = new HeadInfo(); offset += headInfo.ParseHeadInfo(bytes); m_StringCache = new Dictionary <short, string>(headInfo.StringCacheCount); ParseStringCache(bytes, headInfo.StringCacheStartIndex, offset += headInfo.StringCacheSize, m_StringCache); for (int i = 1; i <= (int)Trunk.DontLoad; i = i << 1) { if ((headInfo.TrunkFlags & i) == i) { TrunkInfo trunk = new TrunkInfo(); offset += trunk.ParseHeadInfo(bytes, offset); var list = GetList(i, trunk.DataCount); ParseLoadList(bytes, offset, offset += (trunk.DataCount * 2), list); } } }
private List <DeviceModel> GetDeviceList(List <DeviceModel> currList) { List <DeviceModel> list = new List <DeviceModel>(); List <HeadInfo.机头信息> headList = HeadInfo.GetAllHead(); foreach (var item in currList) { HeadInfo.机头信息 head = headList.FirstOrDefault(t => t.令牌 == item.DeviceToken); DeviceModel info = new DeviceModel(); info.RouterToken = item.RouterToken; info.DeviceId = item.DeviceId; info.DeviceToken = item.DeviceToken; info.DeviceName = item.DeviceName; info.DeviceType = item.DeviceType; info.State = UDPServer.GetDeviceState(head); info.SN = item.SN; info.HeadAddress = item.HeadAddress; list.Add(info); } return(list); }
private void LoadWAV(string fileName) { if (File.Exists(fileName)) { FileStream fs = new FileStream(fileName, FileMode.Open); BinaryReader br = new BinaryReader(fs); int FChNum; int FChLength; double xValue; double yValue; TopFilehead fileHead = new TopFilehead(); fileHead.Fstr = br.ReadChars(8); fileHead.BLKNum = br.ReadInt16(); fileHead.BLKoft = new Int32[256]; for (int i = 0; i < 256; i++) { fileHead.BLKoft[i] = br.ReadInt32(); } string headStr = new string(fileHead.Fstr); if (headStr != "$DPACKS$") { MessageBox.Show("文件格式不匹配!", "错误", MessageBoxButtons.OK, MessageBoxIcon.Error); return; } TmpChNum = FChNum = fileHead.BLKNum; HeadInfo chHeadInfo = new HeadInfo(); for (int i = 0; i < FChNum; i++) { br.BaseStream.Seek(fileHead.BLKoft[i], 0); chHeadInfo.Name = br.ReadChars(10); //通道名称 chHeadInfo.DataStart = br.ReadInt32(); //通道起点 chHeadInfo.DataEnd = br.ReadInt32(); //通道终点 chHeadInfo.DeltaX = br.ReadDouble(); //采样间隔 chHeadInfo.OffsetX = br.ReadDouble(); //X轴偏移 chHeadInfo.UnitX = br.ReadChars(5); //X轴单位 chHeadInfo.DeltaY = br.ReadDouble(); //量化点的分辨率 chHeadInfo.OffsetY = br.ReadDouble(); //Y轴偏移 chHeadInfo.UnitY = br.ReadChars(5); //Y轴单位 chHeadInfo.DataStartEx = br.ReadInt64(); //长文件通道起点 chHeadInfo.DataEndEx = br.ReadInt64(); //长文件通道终点 chHeadInfo.LenFlag = br.ReadInt16(); //长文件标示 chHeadInfo.resvd = br.ReadChars(2); //保留字段 if (chHeadInfo.LenFlag == (Int16)0x55AA) { FChLength = Convert.ToInt32(chHeadInfo.DataEndEx - chHeadInfo.DataStartEx); } else { FChLength = chHeadInfo.DataEnd - chHeadInfo.DataStart; } Int16[] data = new Int16[FChLength]; br.BaseStream.Seek(fileHead.BLKoft[i] + 80, 0); for (int j = 0; j < FChLength; j++) { data[j] = br.ReadInt16(); } for (int k = 0; k < FChLength; k++) { xValue = (chHeadInfo.DataStart + k) * chHeadInfo.DeltaX; //第k点的x值 yValue = data[k] * chHeadInfo.DeltaY + chHeadInfo.OffsetY; //第k点的y值 } //载入.WAV数据 if (i == 0) { float tx; float ty; for (int l = 0; l < FChLength; l++) { tx = Convert.ToSingle((chHeadInfo.DataStart + l) * chHeadInfo.DeltaX); ty = Convert.ToSingle(data[l] * chHeadInfo.DeltaY + chHeadInfo.OffsetY); tx *= (float)Math.Pow(10, 6); this.m_DataChan1.Add(new PointF(tx, ty)); x1.Add(tx); y1.Add(ty); } } if (i == 1) { float tx; float ty; for (int l = 0; l < FChLength; l++) { tx = Convert.ToSingle((chHeadInfo.DataStart + l) * chHeadInfo.DeltaX); ty = Convert.ToSingle(data[l] * chHeadInfo.DeltaY + chHeadInfo.OffsetY); tx *= (float)Math.Pow(10, 6); this.m_DataChan2.Add(new PointF(tx, ty)); x2.Add(tx); y2.Add(ty); } } if (i == 2) { float tx; float ty; for (int l = 0; l < FChLength; l++) { tx = Convert.ToSingle((chHeadInfo.DataStart + l) * chHeadInfo.DeltaX); ty = Convert.ToSingle(data[l] * chHeadInfo.DeltaY + chHeadInfo.OffsetY); tx *= (float)Math.Pow(10, 6); this.m_DataChan3.Add(new PointF(tx, ty)); x3.Add(tx); y3.Add(ty); } } if (i == 3) { float tx; float ty; for (int l = 0; l < FChLength; l++) { tx = Convert.ToSingle((chHeadInfo.DataStart + l) * chHeadInfo.DeltaX); ty = Convert.ToSingle(data[l] * chHeadInfo.DeltaY + chHeadInfo.OffsetY); tx *= (float)Math.Pow(10, 6); this.m_DataChan4.Add(new PointF(tx, ty)); x4.Add(tx); y4.Add(ty); } } } //存储测试数据,记录通道名称 chHeadInfo.Name.CopyTo(this.TmpName, 0); //采样率 = 1 / 采样间隔(μHZ / MHz) this.TmpsamRate = 1 / chHeadInfo.DeltaX / Math.Pow(10, 6); //量程 = 2^15 * 量化点的分辨率(V) this.TmpRange = Math.Pow(2, 15) * chHeadInfo.DeltaY; br.Close(); fs.Close(); } }
/// <summary> /// Analyzes layout of headword. /// </summary> /// <param name="g">A Graphics object used for measurements.</param> private void doAnalyzeHeadword(Graphics g) { // If already analyzed, nothing to do if (headInfo != null) return; // This is how we measure StringFormat sf = StringFormat.GenericTypographic; g.TextRenderingHint = System.Drawing.Text.TextRenderingHint.AntiAlias; // On-demand: measure a single ideograph's dimensions // We only measure simplified. Assume simplified and traditional fonts come in matching pairs -> same size. if (ideoSize.Width == 0) { ideoSize = HanziRenderer.GetCharSize(Magic.ZhoContentFontFamily, Magic.ZhoResultFontSize); float hanziLinePad = 6.0F; hanziLinePad *= scale; ideoLineHeight = ideoSize.Height + hanziLinePad; } headInfo = new HeadInfo(); if (analyzedScript == SearchScript.Simplified) headInfo.HeadMode = HeadMode.OnlySimp; else if (analyzedScript == SearchScript.Traditional) headInfo.HeadMode = HeadMode.OnlyTrad; else headInfo.HeadMode = HeadMode.BothSingleLine; //// For width of headword, use padLeft from border, plus 4 to 6 ideographs' worth of space //// Depending on longest headword in entire list //int hwChars = maxHeadLength; //if (hwChars < 4) hwChars = 4; //if (hwChars > 6) hwChars = 6; //float hwidth = ((float)hwChars) * ideoSize.Width; // Revised // For width of headword, always take 5 characters' width of space float hwidth = 5.0F * ideoSize.Width; headInfo.HeadwordRight = padLeft + hwidth; // Measure simplified chars from start; break when needed PointF loc = new PointF(((float)padLeft) + ideoSize.Width, padTop); bool lbrk = false; if (analyzedScript == SearchScript.Simplified || analyzedScript == SearchScript.Both) { lbrk |= doAnalyzeHanzi(g, entry.ChSimpl, true, sf, headInfo.SimpBlocks, ref loc, headInfo.HeadwordRight); } if (analyzedScript == SearchScript.Traditional || analyzedScript == SearchScript.Both) { //loc.X = padLeft; loc.X = ((float)padLeft) + ideoSize.Width; if (analyzedScript == SearchScript.Both) loc.Y += ideoLineHeight; lbrk |= doAnalyzeHanzi(g, entry.ChTrad, false, sf, headInfo.TradBlocks, ref loc, headInfo.HeadwordRight); } // If we're displaying both simplified and traditional, fade out // traditional chars that are same as simplified, right above them if (analyzedScript == SearchScript.Both) { for (int i = 0; i != headInfo.SimpBlocks.Count; ++i) { if (headInfo.SimpBlocks[i].Char == headInfo.TradBlocks[i].Char) headInfo.TradBlocks[i].Faded = true; } } // Bottom of headword area headInfo.HeadwordBottom = loc.Y + ideoLineHeight; // If we had a line break and we're showing both scripts, update info if (analyzedScript == SearchScript.Both && lbrk) headInfo.HeadMode = HeadMode.BothMultiLine; }