//單日多元選項項目使用比例 private void Get_chart_SeleteOtherItem(string date) { string Date = date; //查詢資料 DataUtility du = new DataUtility(); DataTable dt = new DataTable();//查詢當日多元選項使用人次 Dictionary <string, object> d = new Dictionary <string, object>(); d.Add("date", Date); dt = du.getDataTableBysp("Ex107_Get_UseOtherItemsCount", d); if (dt.Rows.Count > 0) { int original_count = 0; int swin_count = 0; int walk_count = 0; int jump_count = 0; int total_count = 0; double[] rate = new double[4]; original_count = Convert.ToInt16(dt.Rows[0]["original"].ToString()); swin_count = Convert.ToInt16(dt.Rows[0]["swin"].ToString()); walk_count = Convert.ToInt16(dt.Rows[0]["walk"].ToString()); jump_count = Convert.ToInt16(dt.Rows[0]["jump"].ToString()); total_count = original_count + swin_count + walk_count + jump_count; if (total_count == 0) { //當日無多元選項人次 chart_SeleteOtherItem.Series["Pie"].Name = "本日無受測人員"; rate[0] = 0; rate[1] = 0; rate[2] = 0; rate[3] = 0; } else { //計算百分比 rate[0] = Math.Round(Convert.ToDouble(original_count) / Convert.ToDouble(total_count) * 100, 1); rate[1] = Math.Round(Convert.ToDouble(swin_count) / Convert.ToDouble(total_count) * 100, 1); rate[2] = Math.Round(Convert.ToDouble(walk_count) / Convert.ToDouble(total_count) * 100, 1); rate[3] = Math.Round(Convert.ToDouble(jump_count) / Convert.ToDouble(total_count) * 100, 1); string[] xValues = { "基本項目(3km跑步)", "800公尺游走", "五公里健走", "5分鐘跳繩" }; string[] titleArr = { "項目", "人數" }; int[] yValues = { original_count, swin_count, walk_count, jump_count }; //繪製樣式 chart_SeleteOtherItem.Series["Pie"]["DrawingStyle"] = "Cylinder"; //顯示圖形的樣式類別 chart_SeleteOtherItem.Series["Pie"].ChartType = SeriesChartType.Pie; chart_SeleteOtherItem.Series["Pie"].Points.DataBindXY(xValues, rate); chart_SeleteOtherItem.Series["Pie"].Legend = "Pie"; //設定圖形X軸的顯示文字 chart_SeleteOtherItem.ChartAreas["PieChartArea"].AxisX.Title = "項目"; chart_SeleteOtherItem.ChartAreas["PieChartArea"].AxisY.Title = "人數比例\n(%)"; //塞入表格 if (total_count > 0) { //人數 lab_OtherItem_count1.Text = original_count.ToString(); lab_OtherItem_count2.Text = swin_count.ToString(); lab_OtherItem_count3.Text = walk_count.ToString(); lab_OtherItem_count4.Text = jump_count.ToString(); //百分比 lab_OtherItem_rate1.Text = rate[0].ToString(); lab_OtherItem_rate2.Text = rate[1].ToString(); lab_OtherItem_rate3.Text = rate[2].ToString(); lab_OtherItem_rate4.Text = rate[3].ToString(); //設定圖形X軸的顯示文字 foreach (DataPoint dp in chart_SeleteOtherItem.Series["Pie"].Points) { dp.Label = dp.YValues[0].ToString() + "%"; dp.LegendText = dp.AxisLabel;//圖例名稱 } } } } }
public static string DisplayPhoneText(this HtmlHelper helper, string phoneNumb) { return(DataUtility.normalizePhoneNumber(phoneNumb)); }
protected override void OnPopulateMesh(VertexHelper vh) { vh.Clear(); _vertexList = new List <Vector3>(); float width = rectTransform.rect.width; float height = rectTransform.rect.height; int realSegments = (int)(segements * showPercent); Vector4 uv = overrideSprite != null?DataUtility.GetOuterUV(overrideSprite) : Vector4.zero; float uvWidth = uv.z - uv.x; float uvHeight = uv.w - uv.y; Vector2 uvCenter = new Vector2(uvWidth * 0.5f, uvHeight * 0.5f); Vector2 convertRatio = new Vector2(uvWidth / width, uvHeight / height); float radian = (2 * Mathf.PI) / segements; float radius = width * 0.5f; Vector2 originPos = new Vector2((0.5f - rectTransform.pivot.x) * width, (0.5f - rectTransform.pivot.y) * height); Vector2 vertPos = Vector2.zero; UIVertex origin = new UIVertex(); byte temp = (byte)(255 * showPercent); origin.color = new Color32(temp, temp, temp, 255); origin.position = originPos; origin.uv0 = new Vector2(vertPos.x * convertRatio.x + uvCenter.x, vertPos.y * convertRatio.y + uvCenter.y); vh.AddVert(origin); int vertexCount = realSegments + 1; float curRadian = 0; Vector2 posTemp; for (int i = 0; i < segements + 1; i++) { float x = Mathf.Cos(curRadian) * radius; float y = Mathf.Sin(curRadian) * radius; curRadian += radian; UIVertex vertexTemp = new UIVertex(); if (i < vertexCount) { vertexTemp.color = color; } else { vertexTemp.color = new Color32(60, 60, 60, 255); } posTemp = new Vector2(x, y); vertexTemp.position = posTemp + originPos; vertexTemp.uv0 = new Vector2(posTemp.x * convertRatio.x + uvCenter.x, posTemp.y * convertRatio.y + uvCenter.y); vh.AddVert(vertexTemp); _vertexList.Add(posTemp + originPos); } int id = 1; for (int i = 0; i < segements; i++) { vh.AddTriangle(id, 0, id + 1); id++; } }
private void GenerateSlicedSprite(VertexHelper toFill) { if (!hasBorder) { GenerateSimpleSprite(toFill, false); return; } Vector4 vector; Vector4 vector2; Vector4 vector3; Vector4 vector4; if (overrideSprite != null) { vector = DataUtility.GetOuterUV(overrideSprite); vector2 = DataUtility.GetInnerUV(overrideSprite); vector3 = DataUtility.GetPadding(overrideSprite); vector4 = overrideSprite.border; } else { vector = Vector4.zero; vector2 = Vector4.zero; vector3 = Vector4.zero; vector4 = Vector4.zero; } Rect pixelAdjustedRect = GetPixelAdjustedRect(); vector4 = GetAdjustedBorders(vector4 / pixelsPerUnit, pixelAdjustedRect); vector3 /= pixelsPerUnit; s_VertScratch[0] = new Vector2(vector3.x, vector3.y); s_VertScratch[3] = new Vector2(pixelAdjustedRect.width - vector3.z, pixelAdjustedRect.height - vector3.w); s_VertScratch[1].x = vector4.x; s_VertScratch[1].y = vector4.y; s_VertScratch[2].x = pixelAdjustedRect.width - vector4.z; s_VertScratch[2].y = pixelAdjustedRect.height - vector4.w; Vector2 scale = new Vector2(1f / pixelAdjustedRect.width, 1f / pixelAdjustedRect.height); for (int i = 0; i < 4; i++) { s_UV1Scratch[i] = s_VertScratch[i]; s_UV1Scratch[i].Scale(scale); } for (int j = 0; j < 4; j++) { Vector2[] array = s_VertScratch; int num = j; array[num].x = array[num].x + pixelAdjustedRect.x; Vector2[] array2 = s_VertScratch; int num2 = j; array2[num2].y = array2[num2].y + pixelAdjustedRect.y; } s_UVScratch[0] = new Vector2(vector.x, vector.y); s_UVScratch[1] = new Vector2(vector2.x, vector2.y); s_UVScratch[2] = new Vector2(vector2.z, vector2.w); s_UVScratch[3] = new Vector2(vector.z, vector.w); toFill.Clear(); float x2 = transform.localScale.x; for (int k = 0; k < 3; k++) { int num5 = k + 1; for (int l = 0; l < 3; l++) { if (fillCenter || k != 1 || l != 1) { int num6 = l + 1; AddQuad(toFill, new Vector2(s_VertScratch[k].x, s_VertScratch[l].y), new Vector2(s_VertScratch[num5].x, s_VertScratch[num6].y), color, new Vector2(s_UVScratch[k].x, s_UVScratch[l].y), new Vector2(s_UVScratch[num5].x, s_UVScratch[num6].y), new Vector2(s_UV1Scratch[k].x, s_UV1Scratch[l].y), new Vector2(s_UV1Scratch[num5].x, s_UV1Scratch[num6].y), x2); } } } }
protected override void OnPopulateMesh(VertexHelper toFill) { if (font == null) { return; } // We don't care if we the font Texture changes while we are doing our Update. // The end result of cachedTextGenerator will be valid for this instance. // Otherwise we can get issues like Case 619238. m_DisableFontTextureRebuiltCallback = true; Material mat = materialForRendering; int emojIndex = 0; Emoji emoj = mEmojies.Count > 0 ? mEmojies[emojIndex] : default(Emoji); Vector2 extents = rectTransform.rect.size; var settings = GetGenerationSettings(extents); cachedTextGenerator.PopulateWithErrors(text, settings, gameObject); // Apply the offset to the vertices IList <UIVertex> verts = cachedTextGenerator.verts; float unitsPerPixel = 1 / pixelsPerUnit; //Last 4 verts are always a new line... (\n) int vertCount = verts.Count - 4; Vector2 roundingOffset = new Vector2(verts[0].position.x, verts[0].position.y) * unitsPerPixel; roundingOffset = PixelAdjustPoint(roundingOffset) - roundingOffset; toFill.Clear(); if (roundingOffset != Vector2.zero) { for (int i = 0; i < vertCount; ++i) { int tempVertsIndex = i & 3; m_TempVerts[tempVertsIndex] = verts[i]; m_TempVerts[tempVertsIndex].position *= unitsPerPixel; m_TempVerts[tempVertsIndex].position.x += roundingOffset.x; m_TempVerts[tempVertsIndex].position.y += roundingOffset.y; if (tempVertsIndex == 3) { toFill.AddUIVertexQuad(m_TempVerts); } } } else { for (int i = 0; i < vertCount; ++i) { int tempVertsIndex = i & 3; m_TempVerts[tempVertsIndex] = verts[i]; m_TempVerts[tempVertsIndex].position *= unitsPerPixel; if (tempVertsIndex == 3) { if (emojIndex < mEmojies.Count && emoj.charIndex == (i >> 2) && emoj.sprite != null && mat != null) { Vector4 uv = DataUtility.GetOuterUV(emoj.sprite); m_TempVerts[0].uv1 = new Vector2(uv.x, uv.w); m_TempVerts[1].uv1 = new Vector2(uv.z, uv.w); m_TempVerts[2].uv1 = new Vector2(uv.z, uv.y); m_TempVerts[3].uv1 = new Vector2(uv.x, uv.y); mat.SetTexture(mTexId, emoj.sprite.texture); if (++emojIndex < mEmojies.Count) { emoj = mEmojies[emojIndex]; } } toFill.AddUIVertexQuad(m_TempVerts); } } } m_DisableFontTextureRebuiltCallback = false; }
private void GenerateFilledSprite(VertexHelper toFill, bool preserveAspect) { toFill.Clear(); if ((double)this.m_FillAmount < 1.0 / 1000.0) { return; } Vector4 drawingDimensions = this.GetDrawingDimensions(preserveAspect); Vector4 vector4 = !((UnityEngine.Object) this.overrideSprite != (UnityEngine.Object)null) ? Vector4.zero : DataUtility.GetOuterUV(this.overrideSprite); UIVertex.simpleVert.color = (Color32)this.color; float num1 = vector4.x; float num2 = vector4.y; float num3 = vector4.z; float num4 = vector4.w; if (this.m_FillMethod == Image.FillMethod.Horizontal || this.m_FillMethod == Image.FillMethod.Vertical) { if (this.fillMethod == Image.FillMethod.Horizontal) { float num5 = (num3 - num1) * this.m_FillAmount; if (this.m_FillOrigin == 1) { drawingDimensions.x = drawingDimensions.z - (drawingDimensions.z - drawingDimensions.x) * this.m_FillAmount; num1 = num3 - num5; } else { drawingDimensions.z = drawingDimensions.x + (drawingDimensions.z - drawingDimensions.x) * this.m_FillAmount; num3 = num1 + num5; } } else if (this.fillMethod == Image.FillMethod.Vertical) { float num5 = (num4 - num2) * this.m_FillAmount; if (this.m_FillOrigin == 1) { drawingDimensions.y = drawingDimensions.w - (drawingDimensions.w - drawingDimensions.y) * this.m_FillAmount; num2 = num4 - num5; } else { drawingDimensions.w = drawingDimensions.y + (drawingDimensions.w - drawingDimensions.y) * this.m_FillAmount; num4 = num2 + num5; } } } Image.s_Xy[0] = (Vector3) new Vector2(drawingDimensions.x, drawingDimensions.y); Image.s_Xy[1] = (Vector3) new Vector2(drawingDimensions.x, drawingDimensions.w); Image.s_Xy[2] = (Vector3) new Vector2(drawingDimensions.z, drawingDimensions.w); Image.s_Xy[3] = (Vector3) new Vector2(drawingDimensions.z, drawingDimensions.y); Image.s_Uv[0] = (Vector3) new Vector2(num1, num2); Image.s_Uv[1] = (Vector3) new Vector2(num1, num4); Image.s_Uv[2] = (Vector3) new Vector2(num3, num4); Image.s_Uv[3] = (Vector3) new Vector2(num3, num2); if ((double)this.m_FillAmount < 1.0 && this.m_FillMethod != Image.FillMethod.Horizontal && this.m_FillMethod != Image.FillMethod.Vertical) { if (this.fillMethod == Image.FillMethod.Radial90) { if (!Image.RadialCut(Image.s_Xy, Image.s_Uv, this.m_FillAmount, this.m_FillClockwise, this.m_FillOrigin)) { return; } Image.AddQuad(toFill, Image.s_Xy, (Color32)this.color, Image.s_Uv); } else if (this.fillMethod == Image.FillMethod.Radial180) { for (int index = 0; index < 2; ++index) { int num5 = this.m_FillOrigin <= 1 ? 0 : 1; float t1; float t2; float t3; float t4; if (this.m_FillOrigin == 0 || this.m_FillOrigin == 2) { t1 = 0.0f; t2 = 1f; if (index == num5) { t3 = 0.0f; t4 = 0.5f; } else { t3 = 0.5f; t4 = 1f; } } else { t3 = 0.0f; t4 = 1f; if (index == num5) { t1 = 0.5f; t2 = 1f; } else { t1 = 0.0f; t2 = 0.5f; } } Image.s_Xy[0].x = Mathf.Lerp(drawingDimensions.x, drawingDimensions.z, t3); Image.s_Xy[1].x = Image.s_Xy[0].x; Image.s_Xy[2].x = Mathf.Lerp(drawingDimensions.x, drawingDimensions.z, t4); Image.s_Xy[3].x = Image.s_Xy[2].x; Image.s_Xy[0].y = Mathf.Lerp(drawingDimensions.y, drawingDimensions.w, t1); Image.s_Xy[1].y = Mathf.Lerp(drawingDimensions.y, drawingDimensions.w, t2); Image.s_Xy[2].y = Image.s_Xy[1].y; Image.s_Xy[3].y = Image.s_Xy[0].y; Image.s_Uv[0].x = Mathf.Lerp(num1, num3, t3); Image.s_Uv[1].x = Image.s_Uv[0].x; Image.s_Uv[2].x = Mathf.Lerp(num1, num3, t4); Image.s_Uv[3].x = Image.s_Uv[2].x; Image.s_Uv[0].y = Mathf.Lerp(num2, num4, t1); Image.s_Uv[1].y = Mathf.Lerp(num2, num4, t2); Image.s_Uv[2].y = Image.s_Uv[1].y; Image.s_Uv[3].y = Image.s_Uv[0].y; float num6 = !this.m_FillClockwise ? this.m_FillAmount * 2f - (float)(1 - index) : this.fillAmount * 2f - (float)index; if (Image.RadialCut(Image.s_Xy, Image.s_Uv, Mathf.Clamp01(num6), this.m_FillClockwise, (index + this.m_FillOrigin + 3) % 4)) { Image.AddQuad(toFill, Image.s_Xy, (Color32)this.color, Image.s_Uv); } } } else { if (this.fillMethod != Image.FillMethod.Radial360) { return; } for (int index = 0; index < 4; ++index) { float t1; float t2; if (index < 2) { t1 = 0.0f; t2 = 0.5f; } else { t1 = 0.5f; t2 = 1f; } float t3; float t4; if (index == 0 || index == 3) { t3 = 0.0f; t4 = 0.5f; } else { t3 = 0.5f; t4 = 1f; } Image.s_Xy[0].x = Mathf.Lerp(drawingDimensions.x, drawingDimensions.z, t1); Image.s_Xy[1].x = Image.s_Xy[0].x; Image.s_Xy[2].x = Mathf.Lerp(drawingDimensions.x, drawingDimensions.z, t2); Image.s_Xy[3].x = Image.s_Xy[2].x; Image.s_Xy[0].y = Mathf.Lerp(drawingDimensions.y, drawingDimensions.w, t3); Image.s_Xy[1].y = Mathf.Lerp(drawingDimensions.y, drawingDimensions.w, t4); Image.s_Xy[2].y = Image.s_Xy[1].y; Image.s_Xy[3].y = Image.s_Xy[0].y; Image.s_Uv[0].x = Mathf.Lerp(num1, num3, t1); Image.s_Uv[1].x = Image.s_Uv[0].x; Image.s_Uv[2].x = Mathf.Lerp(num1, num3, t2); Image.s_Uv[3].x = Image.s_Uv[2].x; Image.s_Uv[0].y = Mathf.Lerp(num2, num4, t3); Image.s_Uv[1].y = Mathf.Lerp(num2, num4, t4); Image.s_Uv[2].y = Image.s_Uv[1].y; Image.s_Uv[3].y = Image.s_Uv[0].y; float num5 = !this.m_FillClockwise ? this.m_FillAmount * 4f - (float)(3 - (index + this.m_FillOrigin) % 4) : this.m_FillAmount * 4f - (float)((index + this.m_FillOrigin) % 4); if (Image.RadialCut(Image.s_Xy, Image.s_Uv, Mathf.Clamp01(num5), this.m_FillClockwise, (index + 2) % 4)) { Image.AddQuad(toFill, Image.s_Xy, (Color32)this.color, Image.s_Uv); } } } } else { Image.AddQuad(toFill, Image.s_Xy, (Color32)this.color, Image.s_Uv); } }
public object GetTaskActivity([FromBody] UserAuthParams userAuthParams) { string conn = ConfigurationManager.ConnectionStrings["constr"].ConnectionString; SqlCommand cmdObj; DataUtility du = new DataUtility(); cmdObj = new SqlCommand(); cmdObj.CommandText = "[GetAllTaskTransaction]"; cmdObj.Parameters .Add(new SqlParameter("@UserId", SqlDbType.NVarChar)) .Value = userAuthParams.authToken; DataTable dtList = new DataTable(); List <TransactionDetails> TransactionDetailsList = new List <TransactionDetails>(); dtList = du.GetDataTableWithProc(cmdObj); if (dtList.Rows.Count > 0) { foreach (DataRow dtrow in dtList.Rows) { TransactionDetails obj = new TransactionDetails(); obj.TransactionNo = dtrow["TransactionNo"].ToString(); obj.AssetsId = dtrow["AssestId"].ToString(); obj.ActivityId = dtrow["Activity"].ToString(); obj.ActivityName = dtrow["TaskName"].ToString(); obj.CustId = dtrow["CustName"].ToString(); obj.CustName = dtrow["CustName"].ToString(); obj.AssignToId = dtrow["AssignToNew"].ToString(); obj.AssignToName = dtrow["Name"].ToString(); obj.AssignmentDate = dtrow["AssignDateNew"].ToString(); obj.HostName = dtrow["HostName"].ToString(); obj.BImage = dtrow["BImage"].ToString(); obj.Aimage = dtrow["AImage"].ToString(); obj.completedby = dtrow["CompleteBy"].ToString(); obj.actiondate = dtrow["ActDate"].ToString(); obj.Description = dtrow["Description"].ToString(); obj.DND = dtrow["DND"].ToString(); obj.FaultyDesc = dtrow["FaultyDesc"].ToString(); TransactionDetailsList.Add(obj); } return(TransactionDetailsList); } else { var msg = new HttpResponseMessage(HttpStatusCode.NoContent) { ReasonPhrase = "No List Found" }; return(msg); } }
protected override void Execute(UIEventData eData, Rect rect) { if (eData.EventType == UIEventType.Layout) { var sprite = m_SpriteInput[this]; if (sprite != null) { m_SpriteData = new SpriteData() { padding = DataUtility.GetPadding(sprite), rect = sprite.rect, outerUv = DataUtility.GetOuterUV(sprite), pivot = sprite.pivot, vertices = sprite.vertices, uvs = sprite.uv, triangles = sprite.triangles, bounds = sprite.bounds } } ; else { m_SpriteData = new SpriteData() { rect = new Rect(0, 0, 100, 100), outerUv = new Vector4(0, 0, 1, 1) } }; } else if (eData.EventType == UIEventType.PreRepaint) { var color = m_Color[this]; var pivot = m_Pivot[this]; var vertexHelper = eData.MeshRepository.GetVertexHelper(guid); var localRect = new Rect(-pivot.x * rect.width, -pivot.y * rect.height, rect.width, rect.height); if (m_SpriteData.vertices != null) { GenerateSprite(vertexHelper, m_SpriteData, localRect, pivot, color); } else { GenerateSimpleSprite(vertexHelper, m_SpriteData, localRect, pivot, color); } } else if (eData.EventType == UIEventType.Repaint) { var pivot = m_Pivot[this]; var sprite = m_SpriteInput[this]; var matrix = m_Matrix[this]; var mat = m_Material[this]; var vertexHelper = eData.MeshRepository.GetVertexHelper(guid); var mesh = eData.MeshRepository.GetMesh(guid); MaterialPropertyBlock propertyBlock = null; vertexHelper.FillMesh(mesh); if (sprite != null) { propertyBlock = eData.MeshRepository.GetPropertyBLock(guid); propertyBlock.SetTexture(m_MainTexProp, sprite.texture); } eData.RenderBuffer.Render(mesh, Matrix4x4.Translate(new Vector3(rect.x + pivot.x * rect.width, rect.y + pivot.y * rect.width, m_ZOffset[this])) * matrix, mat, propertyBlock); } base.Execute(eData, rect); }
protected void btn_Inq_Click(object sender, EventArgs e) { string gender = string.Empty; //性別 string age = string.Empty; //年齡 string item = string.Empty; //項目代碼 string itemName = string.Empty; //項目名稱 string grade = string.Empty; //成績 string score = string.Empty; //分數 lab_gender.Text = null; lab_age.Text = null; lab_item.Text = null; lab_grade.Text = null; if (!string.IsNullOrEmpty(hf_gender.Value) && !string.IsNullOrEmpty(hf_age.Value) && !string.IsNullOrEmpty(hf_item.Value)) { gender = hf_gender.Value; age = hf_age.Value; item = hf_item.Value; itemName = hf_itemName.Value; grade = hf_grade.Value; lab_gender.Text = (gender == "M") ? "男性" : "女性"; lab_gender.ForeColor = (gender == "M") ? Color.Blue : Color.Red; lab_age.Text = age; lab_item.Text = itemName; if (item == "run" || item == "F" || item == "G" || item == "J") { if (Convert.ToInt16(grade) >= 60) { lab_grade.Text = (Convert.ToInt16(grade) / 60).ToString() + "分" + (Convert.ToInt16(grade) % 60).ToString() + "秒"; } else { lab_grade.Text = grade + "秒"; } } else { lab_grade.Text = grade + "次"; } bool checkOK = false; try { Dictionary <string, object> di = new Dictionary <string, object>(); DataUtility du = new DataUtility(); DataTable dt = new DataTable(); di.Add("gender", gender); di.Add("age", age); di.Add("grade", grade); di.Add("item", item); dt = du.getDataTableBysp("Ex108_GetScoreTrial", di); if (dt.Rows.Count > 0) { if (!string.IsNullOrEmpty(dt.Rows[0]["score"].ToString())) { score = dt.Rows[0]["score"].ToString(); checkOK = true; } else { score = "查無分數"; } } else { score = "查無分數"; } } catch (Exception ex) { score = "查詢失敗"; } finally { lab_score.Text = score; if (checkOK == true) { lab_score.ForeColor = (Convert.ToInt16(score) >= 60) ? Color.Green : Color.Red; } } } else { ScriptManager.RegisterClientScriptBlock(this, this.GetType(), "", "alert('輸入資料不完整!!');", true); } }
/// <summary> /// Creates the wizard form data. /// </summary> /// <param name="formKey">The form key.</param> /// <param name="fieldData">The field data.</param> /// <param name="editButton">The edit button.</param> /// <returns>WizardFormData.</returns> /// TODO Edit XML Comment Template for CreateWizardFormData public virtual WizardFormData CreateWizardFormData(string formKey, IEnumerable <WizardContentField> fieldData, WizardButtonData editButton = null) { var data = fieldData?.ToList(); var form = data?.FirstOrDefault(o => o.FieldType.Equals("Form", StringComparison.InvariantCultureIgnoreCase) && o.FieldKey.Equals(formKey, StringComparison.InvariantCultureIgnoreCase)); if (form == null) { return(new WizardFormData(null, null, null)); } var returnObject = new WizardFormData(formKey, fieldData, editButton); string strInput; strInput = form.FieldData?.Trim(); if (string.IsNullOrWhiteSpace(strInput)) { return(returnObject); } var fields = data.Where(o => o.ParentKey.Equals(form.FieldKey, StringComparison.CurrentCultureIgnoreCase)).OrderBy(o => o.Order).ToList(); foreach (var o in fields) { JToken field = JToken.FromObject(o); strInput = o.FieldData?.Trim(); if (!string.IsNullOrWhiteSpace(strInput)) { if (strInput.StartsWith("{") && strInput.EndsWith("}")) { try { var dta = JToken.Parse(strInput); if ((field["FieldType"]?.ToString() ?? "").Equals("Select", StringComparison.InvariantCultureIgnoreCase)) { /* * // Example of overriding lookup data: * switch (dta["lookup"]?.ToString().ToLower()) * { * case "country": * dta["data"] = JToken.FromObject(DataRepository.GetCountryList()); * break; * } */ } field["FieldData"] = dta; } catch { // ignored } } } field["FieldData"] = field["FieldData"] ?? new JObject(); ((List <JToken>)(returnObject.Fields)).Add(field); } strInput = form.FieldData?.Trim(); if (string.IsNullOrWhiteSpace(strInput)) { return(returnObject); } if (strInput.StartsWith("{") && strInput.EndsWith("}")) { try { var jObj = JToken.Parse(strInput); returnObject.UseCardLayout = DataUtility.ParseBool(jObj["useCardLayout"]); } catch { // ignored } } return(returnObject); }
/// <inheritdoc /> /// TODO Edit XML Comment Template for CreateWizardContent public virtual IWizardContent CreateWizardScreenContent(string groupKey, string screenKey, object formData = null) { var fieldData = DataRepository.GetFieldData(groupKey)?.ToList() ?? new List <WizardContentField>(); var wizard = fieldData?.FirstOrDefault(o => o.FieldType.Equals("Screen", StringComparison.InvariantCultureIgnoreCase) && o.FieldKey.Equals(screenKey, StringComparison.InvariantCultureIgnoreCase)); var model = formData ?? new object(); var content = new WizardScreenContent(screenKey, fieldData, formData); var fields = fieldData.Where(o => o.ParentKey.Equals(wizard?.FieldKey, StringComparison.CurrentCultureIgnoreCase)).OrderBy(o => o.Order).ToList(); var formList = fields.Where(o => o.FieldType.Equals("Form", StringComparison.InvariantCultureIgnoreCase)).OrderBy(o => o.Order).ToList(); string embedData = fields.FirstOrDefault(o => o.FieldType.Equals("Embed", StringComparison.InvariantCultureIgnoreCase))?.FieldData ?? "{}"; foreach (var form in formList) { ((List <WizardFormData>)content.Forms).Add(CreateWizardFormData(form.FieldKey, fieldData)); } if (!string.IsNullOrWhiteSpace(embedData)) { try { JToken dta = JToken.Parse(embedData); JToken embedWiz = dta["embedWizard"]; if (embedWiz is JArray) { foreach (var key in dta["embedWizard"]) { AddEmbeddedForm(key.Value <string>(), content, null, DataUtility.ParseBool(dta["disabled"]?.ToString()), DataUtility.ParseBool(dta["editButton"])); } } } catch { } } ((List <WizardFormData>)content.Forms).Sort((o1, o2) => o1.Order - o2.Order); foreach (var wizardFormData in content.Forms) { foreach (var formField in wizardFormData.Fields) { formField["Label"] = wizardFormData.ResolvePlaceholders(formField["Label"].ToString(), formData); } } return(content); }
/// <summary> /// Adds the embedded form. /// </summary> /// <param name="key">The key.</param> /// <param name="content">The content.</param> /// <param name="extraFields">The extra fields.</param> /// <param name="isDisabled">if set to <c>true</c> [is disabled].</param> /// <param name="hasEditButton">if set to <c>true</c> [has edit button].</param> /// TODO Edit XML Comment Template for AddEmbeddedForm public virtual void AddEmbeddedForm(string key, IWizardContent content, IEnumerable <WizardContentField> extraFields = null, bool isDisabled = false, bool hasEditButton = false) { List <WizardContentField> embed = (List <WizardContentField>)DataRepository.GetFieldData(key); var wizard = embed?.FirstOrDefault(o => o.FieldType.Equals("Wizard", StringComparison.InvariantCultureIgnoreCase)); if (extraFields != null) { foreach (var field in extraFields) { embed?.Add(field); } } if (isDisabled) { foreach (var field in embed) { field.SetDisabledFlag(); } } var fields = embed?.Where(o => o.ParentKey.Equals(wizard?.FieldKey, StringComparison.CurrentCultureIgnoreCase)).OrderBy(o => o.Order).ToList(); var formList = fields?.Where(o => o.FieldType.Equals("Form", StringComparison.InvariantCultureIgnoreCase)).OrderBy(o => o.Order).ToList(); foreach (var form in formList) { WizardButtonData editButton = null; if (hasEditButton) { JToken data = form.GetFieldData(); editButton = new WizardButtonData(); editButton.Class = "btn btn-sm btn-outline-primary"; editButton.Label = "Edit"; editButton.Icon = "fa fa-edit"; editButton.Action = new { type = "nav", section = DataUtility.ParseInt(data["section"]), step = DataUtility.ParseInt(data["step"]) }; } ((List <WizardFormData>)(content.Forms)).Add(CreateWizardFormData(form.FieldKey, embed, editButton)); } }
public void BindPage(Int64 paymentProfileId) { DisableButtonOnClick(ButtonSave); ErrorMessage.Text = string.Empty; TextCardSecurity.Text = string.Empty; TextCreditCard.Text = string.Empty; AspDotNetStorefrontCore.Customer adnsfCustomer = AspDotNetStorefrontCore.Customer.Current; int customerId = adnsfCustomer.CustomerID; PanelError.Visible = false; PopulateExpirationDates(); PopulateAddresses(customerId); this.PaymentProfileId = 0; // initially zero if (paymentProfileId <= 0) { return; } Int64 profileId = DataUtility.GetProfileId(customerId); if (profileId <= 0) { return; } var profileMgr = new ProfileManager(customerId, adnsfCustomer.EMail, profileId); var paymentProfile = profileMgr.GetPaymentProfile(paymentProfileId); if (paymentProfile == null) { return; } this.PaymentProfileId = paymentProfileId; var ccPayment = (GatewayAuthorizeNet.AuthorizeNetApi.CreditCardMaskedType)paymentProfile.payment.Item; var dataPaymentProfile = DataUtility.GetPaymentProfile(adnsfCustomer.CustomerID, this.PaymentProfileId); TextCreditCard.Text = ccPayment.cardNumber; TextCardSecurity.Text = string.Empty; ExpirationMonth.ClearSelection(); var foundItem = ExpirationMonth.Items.FindByValue(dataPaymentProfile.ExpirationMonth); if (foundItem != null) { foundItem.Selected = true; } ExpirationYear.ClearSelection(); foundItem = ExpirationYear.Items.FindByValue(dataPaymentProfile.ExpirationYear); if (foundItem != null) { foundItem.Selected = true; } var address = DataUtility.GetPaymentProfile(customerId, this.PaymentProfileId); if (address != null) { BillingAddresses.ClearSelection(); BillingAddresses.Items.FindByValue(address.AddressId.ToString()).Selected = true; } }
protected override void OnPopulateMesh(VertexHelper vh) { Vector4 v = GetDrawingDimensions(false); Vector4 uv = overrideSprite != null?DataUtility.GetOuterUV(overrideSprite) : Vector4.zero; var color32 = color; vh.Clear(); if (!isRunning) { SetNormalMesh(vh, v, uv, color32); } else { Vector2 subRect = new Vector2(SubRectX, SubRectY); int ColNum = Mathf.CeilToInt((v.z - v.x) / subRect.x); int LineNum = Mathf.CeilToInt((v.w - v.y) / subRect.y); subRect = new Vector2((v.z - v.x) / ColNum, (v.w - v.y) / LineNum); Vector2 uvDelta = new Vector2(subRect.x / (v.z - v.x), subRect.y / (v.w - v.y)); int startNum = 0; Vector2 target = new Vector2(TargetX, TargetY); for (int i = 0; i < LineNum; i++) { for (int j = 0; j < ColNum; j++) { color32 = color; //计算对应的v块 Vector2 leftBottom = new Vector2(v.x + j * subRect.x, v.y + i * subRect.y); Vector2 leftTop = new Vector2(leftBottom.x, leftBottom.y + subRect.y); Vector2 rightBottom = new Vector2(leftBottom.x + subRect.x, leftBottom.y); Vector2 rightTop = new Vector2(leftBottom.x + subRect.x, leftBottom.y + subRect.y); //计算对应的uv块 Vector2 leftBottomUV = new Vector2(uv.x + j * uvDelta.x, uv.y + i * uvDelta.y); Vector2 leftTopUV = new Vector2(leftBottomUV.x, leftBottomUV.y + uvDelta.y); Vector2 rightBottomUV = new Vector2(leftBottomUV.x + uvDelta.x, leftBottomUV.y); Vector2 rightTopUV = new Vector2(leftBottomUV.x + uvDelta.x, leftBottomUV.y + uvDelta.y); Vector2 position = new Vector2(); float distance = (target - leftBottom).magnitude; float percent = (mDelta - distance * Interval) / Mathf.Pow(distance, Acceleration); position.x = Mathf.Lerp(leftBottom.x, target.x, percent); position.y = Mathf.Lerp(leftBottom.y, target.y, percent); color32.a = Mathf.Clamp01(Mathf.Lerp(10, 0, percent)); if (color32.a < 0.01f) { continue; } Vector2 delta = position - leftBottom; vh.AddVert(new Vector3(leftBottom.x + delta.x, leftBottom.y + delta.y), color32, new Vector2(leftBottomUV.x, leftBottomUV.y)); vh.AddVert(new Vector3(leftTop.x + delta.x, leftTop.y + delta.y), color32, new Vector2(leftTopUV.x, leftTopUV.y)); vh.AddVert(new Vector3(rightBottom.x + delta.x, rightBottom.y + delta.y), color32, new Vector2(rightBottomUV.x, rightBottomUV.y)); vh.AddVert(new Vector3(rightTop.x + delta.x, rightTop.y + delta.y), color32, new Vector2(rightTopUV.x, rightTopUV.y)); vh.AddTriangle(startNum + 0, startNum + 1, startNum + 3); vh.AddTriangle(startNum + 0, startNum + 3, startNum + 2); startNum += 4; } } if (startNum == 0) { ResetImage(0); } } }
private void GenerateSimpleSprite(VertexHelper vh, bool lPreserveAspect) { Vector4 drawingDimensions = this.GetDrawingDimensions(lPreserveAspect); Vector4 vector4 = !((UnityEngine.Object) this.overrideSprite != (UnityEngine.Object)null) ? Vector4.zero : DataUtility.GetOuterUV(this.overrideSprite); Color color = this.color; vh.Clear(); vh.AddVert(new Vector3(drawingDimensions.x, drawingDimensions.y), (Color32)color, new Vector2(vector4.x, vector4.y)); vh.AddVert(new Vector3(drawingDimensions.x, drawingDimensions.w), (Color32)color, new Vector2(vector4.x, vector4.w)); vh.AddVert(new Vector3(drawingDimensions.z, drawingDimensions.w), (Color32)color, new Vector2(vector4.z, vector4.w)); vh.AddVert(new Vector3(drawingDimensions.z, drawingDimensions.y), (Color32)color, new Vector2(vector4.z, vector4.y)); vh.AddTriangle(0, 1, 2); vh.AddTriangle(2, 3, 0); }
/// <summary> /// 检查类型是否匹配,长度是否超长,必填项是否已填,取值范围是否正确等等..... /// </summary> /// <returns>检查成功返回true,不成功返回false</returns> public string ItemCheck() { string nameCN = this.ItemNameCN.IsEmpty() ? "控件ID:" + this.ID : this.ItemNameCN; string data = this.Text.TrimString(); // 必填项检查 if (this.ItemIsRequired && data.IsEmpty()) { this.Focus(); this._ErrorMessage = DataUtility.GetErrorMessage_DataRequired(nameCN); return(this._ErrorMessage); } if (data.IsEmpty()) { return(""); } // 数据类型检查 if (!DataUtility.CheckDataType(data, ((IDataItem)this).ItemType)) { this.Focus(); this._ErrorMessage = DataUtility.GetErrorMessage_DataType(nameCN, ((IDataItem)this).ItemType); return(this._ErrorMessage); } // 数据格式检查 data = DataUtility.FormatData(data, ((IDataItem)this).ItemType, ((IDataItem)this).ItemFormat); if (data.IsEmpty()) { this.Focus(); this._ErrorMessage = DataUtility.GetErrorMessage_DataFormat(nameCN, ((IDataItem)this).ItemType, ((IDataItem)this).ItemFormat); return(this._ErrorMessage); } this.Text = data; // 最小值数据类型检查 if (!DataUtility.CheckDataType(this.MinData, ((IDataItem)this).ItemType)) { this.Focus(); this._ErrorMessage = DataUtility.GetErrorMessage_DataType(nameCN + "(最小值)", ((IDataItem)this).ItemType); return(this._ErrorMessage); } // 最大值数据类型检查 if (!DataUtility.CheckDataType(this.MaxData, ((IDataItem)this).ItemType)) { this.Focus(); this._ErrorMessage = DataUtility.GetErrorMessage_DataType(nameCN + "(最大值)", ((IDataItem)this).ItemType); return(this._ErrorMessage); } // 数据取值范围检查 if (!DataUtility.CheckDataRange(data, ((IDataItem)this).ItemType, this.MinData, this.MaxData)) { this.Focus(); this._ErrorMessage = DataUtility.GetErrorMessage_DataRange(nameCN, ((IDataItem)this).ItemType, this.MinData, this.MaxData); return(this._ErrorMessage); } //等等..... return(string.Empty); }
private void GenerateTiledSprite(VertexHelper toFill) { Vector4 vector4_1; Vector4 vector4_2; Vector4 vector4_3; Vector2 vector2_1; if ((UnityEngine.Object) this.overrideSprite != (UnityEngine.Object)null) { vector4_1 = DataUtility.GetOuterUV(this.overrideSprite); vector4_2 = DataUtility.GetInnerUV(this.overrideSprite); vector4_3 = this.overrideSprite.border; vector2_1 = this.overrideSprite.rect.size; } else { vector4_1 = Vector4.zero; vector4_2 = Vector4.zero; vector4_3 = Vector4.zero; vector2_1 = Vector2.one * 100f; } Rect pixelAdjustedRect = this.GetPixelAdjustedRect(); float num1 = (vector2_1.x - vector4_3.x - vector4_3.z) / this.pixelsPerUnit; float num2 = (vector2_1.y - vector4_3.y - vector4_3.w) / this.pixelsPerUnit; vector4_3 = this.GetAdjustedBorders(vector4_3 / this.pixelsPerUnit, pixelAdjustedRect); Vector2 uvMin = new Vector2(vector4_2.x, vector4_2.y); Vector2 vector2_2 = new Vector2(vector4_2.z, vector4_2.w); UIVertex.simpleVert.color = (Color32)this.color; float x1 = vector4_3.x; float x2 = pixelAdjustedRect.width - vector4_3.z; float y1 = vector4_3.y; float y2 = pixelAdjustedRect.height - vector4_3.w; toFill.Clear(); Vector2 uvMax = vector2_2; if ((double)num1 == 0.0) { num1 = x2 - x1; } if ((double)num2 == 0.0) { num2 = y2 - y1; } if (this.m_FillCenter) { float y3 = y1; while ((double)y3 < (double)y2) { float y4 = y3 + num2; if ((double)y4 > (double)y2) { uvMax.y = uvMin.y + (float)(((double)vector2_2.y - (double)uvMin.y) * ((double)y2 - (double)y3) / ((double)y4 - (double)y3)); y4 = y2; } uvMax.x = vector2_2.x; float x3 = x1; while ((double)x3 < (double)x2) { float x4 = x3 + num1; if ((double)x4 > (double)x2) { uvMax.x = uvMin.x + (float)(((double)vector2_2.x - (double)uvMin.x) * ((double)x2 - (double)x3) / ((double)x4 - (double)x3)); x4 = x2; } Image.AddQuad(toFill, new Vector2(x3, y3) + pixelAdjustedRect.position, new Vector2(x4, y4) + pixelAdjustedRect.position, (Color32)this.color, uvMin, uvMax); x3 += num1; } y3 += num2; } } if (!this.hasBorder) { return; } Vector2 vector2_3 = vector2_2; float y5 = y1; while ((double)y5 < (double)y2) { float y3 = y5 + num2; if ((double)y3 > (double)y2) { vector2_3.y = uvMin.y + (float)(((double)vector2_2.y - (double)uvMin.y) * ((double)y2 - (double)y5) / ((double)y3 - (double)y5)); y3 = y2; } Image.AddQuad(toFill, new Vector2(0.0f, y5) + pixelAdjustedRect.position, new Vector2(x1, y3) + pixelAdjustedRect.position, (Color32)this.color, new Vector2(vector4_1.x, uvMin.y), new Vector2(uvMin.x, vector2_3.y)); Image.AddQuad(toFill, new Vector2(x2, y5) + pixelAdjustedRect.position, new Vector2(pixelAdjustedRect.width, y3) + pixelAdjustedRect.position, (Color32)this.color, new Vector2(vector2_2.x, uvMin.y), new Vector2(vector4_1.z, vector2_3.y)); y5 += num2; } vector2_3 = vector2_2; float x5 = x1; while ((double)x5 < (double)x2) { float x3 = x5 + num1; if ((double)x3 > (double)x2) { vector2_3.x = uvMin.x + (float)(((double)vector2_2.x - (double)uvMin.x) * ((double)x2 - (double)x5) / ((double)x3 - (double)x5)); x3 = x2; } Image.AddQuad(toFill, new Vector2(x5, 0.0f) + pixelAdjustedRect.position, new Vector2(x3, y1) + pixelAdjustedRect.position, (Color32)this.color, new Vector2(uvMin.x, vector4_1.y), new Vector2(vector2_3.x, uvMin.y)); Image.AddQuad(toFill, new Vector2(x5, y2) + pixelAdjustedRect.position, new Vector2(x3, pixelAdjustedRect.height) + pixelAdjustedRect.position, (Color32)this.color, new Vector2(uvMin.x, vector2_2.y), new Vector2(vector2_3.x, vector4_1.w)); x5 += num1; } Image.AddQuad(toFill, new Vector2(0.0f, 0.0f) + pixelAdjustedRect.position, new Vector2(x1, y1) + pixelAdjustedRect.position, (Color32)this.color, new Vector2(vector4_1.x, vector4_1.y), new Vector2(uvMin.x, uvMin.y)); Image.AddQuad(toFill, new Vector2(x2, 0.0f) + pixelAdjustedRect.position, new Vector2(pixelAdjustedRect.width, y1) + pixelAdjustedRect.position, (Color32)this.color, new Vector2(vector2_2.x, vector4_1.y), new Vector2(vector4_1.z, uvMin.y)); Image.AddQuad(toFill, new Vector2(0.0f, y2) + pixelAdjustedRect.position, new Vector2(x1, pixelAdjustedRect.height) + pixelAdjustedRect.position, (Color32)this.color, new Vector2(vector4_1.x, vector2_2.y), new Vector2(uvMin.x, vector4_1.w)); Image.AddQuad(toFill, new Vector2(x2, y2) + pixelAdjustedRect.position, new Vector2(pixelAdjustedRect.width, pixelAdjustedRect.height) + pixelAdjustedRect.position, (Color32)this.color, new Vector2(vector2_2.x, vector2_2.y), new Vector2(vector4_1.z, vector4_1.w)); }
private void RemoveEquipmentsBySkillExclusion(IList <IAbility> excludedAbilities, List <SolverDataEquipmentModel> equipments) { equipments.RemoveAll(e => e.Equipment.Abilities.Any(a => excludedAbilities.Any(x => DataUtility.AreAbilitiesOnSameSkill(a, x)))); }
private MachineConfig OnActionMachineConfigLoader(string configName) { TextAsset asset = configs.Find(t => string.Compare(t.name, configName) == 0); return(DataUtility.FromJson <MachineConfig>(asset.text)); }
protected override void doDeploy(NetworkTopology networkTopology) { if (checkHaveRunned(networkTopology)) { isNeedWriteing2SQLite = false; isNeedReset = false; } else { NetworkTopology process_topo = networkTopology; int centerID; isNeedRecompute = false; lastDeployCount = 0; allLevelScopeCount = 0; allLevelDeploy = new List <List <int> >(); // Finding the center node to run all level's process. //while (tmp_src_net_topo.FindCenterNodeID(out centerID, isNeedRecompute)) while (selectStartNode(process_topo, out centerID, isNeedRecompute)) { NetworkTopology scope_net_topo = new NetworkTopology(networkTopology.Nodes); scope_net_topo.AdjacentMatrix = networkTopology.AdjacentMatrix; List <int> now_level_depoly_id = new List <int>(); // Adding the center node to scope network topology. scope_net_topo.Nodes.Add(process_topo.Nodes.Find(n => n.ID == centerID)); // Starting run algorithm with this level. process_topo = startAlgorithm(process_topo, scope_net_topo, now_level_depoly_id); // Adding this round generated scope network topology to list. allRoundScopeList.Add(scope_net_topo); deployNodes.AddRange(now_level_depoly_id); allLevelDeploy.Add(now_level_depoly_id); isNeedRecompute = deployNodes.Count != lastDeployCount; lastDeployCount = deployNodes.Count; allLevelScopeCount += scope_net_topo.Nodes.Count; DataUtility.Log(string.Format("================= Level {0} ==================\n", allRoundScopeList.Count)); DataUtility.Log(string.Format("Center Node:\t{0}\n", centerID)); DataUtility.Log(string.Format("Scope Node Count:\t{0}\n", scope_net_topo.Nodes.Count)); DataUtility.Log(string.Format("All Scope Node Count/Run Level:\t{0}/{1} = {2:0.0000}\n", allLevelScopeCount, allRoundScopeList.Count, (float)allLevelScopeCount / (float)allRoundScopeList.Count)); DataUtility.Log(string.Format("Deploy Count/Node Count:\t{0}/{1} = {2:0.0000}\n", deployNodes.Count, networkTopology.Nodes.Count, (float)deployNodes.Count / (float)networkTopology.Nodes.Count)); } if (process_topo.Nodes.Count != 0) { allRoundScopeList.Add(process_topo); } } // Modifying actual tracer type on network topology depend on computed deployment node. foreach (int id in deployNodes) { networkTopology.Nodes.Find(n => n.ID == id).Tracer = NetworkTopology.TracerType.Tunneling; } }
private void GenerateTiledSprite(VertexHelper toFill) { Vector4 vector; Vector4 vector2; Vector4 vector3; Vector2 vector4; if (overrideSprite != null) { vector = DataUtility.GetOuterUV(overrideSprite); vector2 = DataUtility.GetInnerUV(overrideSprite); vector3 = overrideSprite.border; vector4 = overrideSprite.rect.size; } else { vector = Vector4.zero; vector2 = Vector4.zero; vector3 = Vector4.zero; vector4 = Vector2.one * 100f; } Rect pixelAdjustedRect = GetPixelAdjustedRect(); float num = (vector4.x - vector3.x - vector3.z) / multipliedPixelsPerUnit; float num2 = (vector4.y - vector3.y - vector3.w) / multipliedPixelsPerUnit; vector3 = GetAdjustedBorders(vector3 / multipliedPixelsPerUnit, pixelAdjustedRect); Vector2 vector5 = new Vector2(vector2.x, vector2.y); Vector2 vector6 = new Vector2(vector2.z, vector2.w); float x = vector3.x; float num3 = pixelAdjustedRect.width - vector3.z; float y = vector3.y; float num4 = pixelAdjustedRect.height - vector3.w; toFill.Clear(); Vector2 vector7 = vector6; if (num <= 0f) { num = num3 - x; } if (num2 <= 0f) { num2 = num4 - y; } if (overrideSprite != null && (hasBorder || overrideSprite.packed || overrideSprite.texture.wrapMode != TextureWrapMode.Repeat)) { long num5; long num6; if (fillCenter) { num5 = (long)Math.Ceiling((num3 - x) / num); num6 = (long)Math.Ceiling((num4 - y) / num2); double num7; if (hasBorder) { num7 = (num5 + 2.0) * (num6 + 2.0) * 4.0; } else { num7 = num5 * num6 * 4.0; } if (num7 > 65000.0) { Debug.LogError("Too many sprite tiles on Image \"" + name + "\". The tile size will be increased. To remove the limit on the number of tiles, set the Wrap mode to Repeat in the Image Import Settings", this); double num8 = 16250.0; double num9; if (hasBorder) { num9 = (num5 + 2.0) / (num6 + 2.0); } else { num9 = num5 / (double)num6; } double num10 = Math.Sqrt(num8 / num9); double num11 = num10 * num9; if (hasBorder) { num10 -= 2.0; num11 -= 2.0; } num5 = (long)Math.Floor(num10); num6 = (long)Math.Floor(num11); num = (num3 - x) / num5; num2 = (num4 - y) / num6; } } else if (hasBorder) { num5 = (long)Math.Ceiling((num3 - x) / num); num6 = (long)Math.Ceiling((num4 - y) / num2); if ((num6 + num5 + 2.0) * 2.0 * 4.0 > 65000.0) { Debug.LogError("Too many sprite tiles on Image \"" + name + "\". The tile size will be increased. To remove the limit on the number of tiles, set the Wrap mode to Repeat in the Image Import Settings", this); double num12 = 16250.0; double num13 = num5 / (double)num6; double num14 = (num12 - 4.0) / (2.0 * (1.0 + num13)); double d = num14 * num13; num5 = (long)Math.Floor(num14); num6 = (long)Math.Floor(d); num = (num3 - x) / num5; num2 = (num4 - y) / num6; } } else { num5 = (num6 = 0L); } if (fillCenter) { for (long num15 = 0L; num15 < num6; num15 += 1L) { float num16 = y + num15 * num2; float num17 = y + (num15 + 1L) * num2; if (num17 > num4) { vector7.y = vector5.y + (vector6.y - vector5.y) * (num4 - num16) / (num17 - num16); num17 = num4; } vector7.x = vector6.x; for (long num18 = 0L; num18 < num5; num18 += 1L) { float num19 = x + num18 * num; float num20 = x + (num18 + 1L) * num; if (num20 > num3) { vector7.x = vector5.x + (vector6.x - vector5.x) * (num3 - num19) / (num20 - num19); num20 = num3; } AddQuad(toFill, new Vector2(num19, num16) + pixelAdjustedRect.position, new Vector2(num20, num17) + pixelAdjustedRect.position, color, vector5, vector7); } } } if (hasBorder) { vector7 = vector6; for (long num21 = 0L; num21 < num6; num21 += 1L) { float num22 = y + num21 * num2; float num23 = y + (num21 + 1L) * num2; if (num23 > num4) { vector7.y = vector5.y + (vector6.y - vector5.y) * (num4 - num22) / (num23 - num22); num23 = num4; } AddQuad(toFill, new Vector2(0f, num22) + pixelAdjustedRect.position, new Vector2(x, num23) + pixelAdjustedRect.position, color, new Vector2(vector.x, vector5.y), new Vector2(vector5.x, vector7.y)); AddQuad(toFill, new Vector2(num3, num22) + pixelAdjustedRect.position, new Vector2(pixelAdjustedRect.width, num23) + pixelAdjustedRect.position, color, new Vector2(vector6.x, vector5.y), new Vector2(vector.z, vector7.y)); } vector7 = vector6; for (long num24 = 0L; num24 < num5; num24 += 1L) { float num25 = x + num24 * num; float num26 = x + (num24 + 1L) * num; if (num26 > num3) { vector7.x = vector5.x + (vector6.x - vector5.x) * (num3 - num25) / (num26 - num25); num26 = num3; } AddQuad(toFill, new Vector2(num25, 0f) + pixelAdjustedRect.position, new Vector2(num26, y) + pixelAdjustedRect.position, color, new Vector2(vector5.x, vector.y), new Vector2(vector7.x, vector5.y)); AddQuad(toFill, new Vector2(num25, num4) + pixelAdjustedRect.position, new Vector2(num26, pixelAdjustedRect.height) + pixelAdjustedRect.position, color, new Vector2(vector5.x, vector6.y), new Vector2(vector7.x, vector.w)); } AddQuad(toFill, new Vector2(0f, 0f) + pixelAdjustedRect.position, new Vector2(x, y) + pixelAdjustedRect.position, color, new Vector2(vector.x, vector.y), new Vector2(vector5.x, vector5.y)); AddQuad(toFill, new Vector2(num3, 0f) + pixelAdjustedRect.position, new Vector2(pixelAdjustedRect.width, y) + pixelAdjustedRect.position, color, new Vector2(vector6.x, vector.y), new Vector2(vector.z, vector5.y)); AddQuad(toFill, new Vector2(0f, num4) + pixelAdjustedRect.position, new Vector2(x, pixelAdjustedRect.height) + pixelAdjustedRect.position, color, new Vector2(vector.x, vector6.y), new Vector2(vector5.x, vector.w)); AddQuad(toFill, new Vector2(num3, num4) + pixelAdjustedRect.position, new Vector2(pixelAdjustedRect.width, pixelAdjustedRect.height) + pixelAdjustedRect.position, color, new Vector2(vector6.x, vector6.y), new Vector2(vector.z, vector.w)); return; } } else { Vector2 b = new Vector2((num3 - x) / num, (num4 - y) / num2); if (fillCenter) { AddQuad(toFill, new Vector2(x, y) + pixelAdjustedRect.position, new Vector2(num3, num4) + pixelAdjustedRect.position, color, Vector2.Scale(vector5, b), Vector2.Scale(vector6, b)); } } }
private void LoadEditMode() { PopulateControlsFromLink(LinkRepository.FindById(DataUtility.ParseInt(QsLinkId))); Submit.CommandName = CMD_UPDATE; Submit.Text = "Save"; }
protected override void OnPopulateMesh(VertexHelper vh) { vh.Clear(); innerVertices.Clear(); outterVertices.Clear(); float degreeDelta = (float)(2 * Mathf.PI / segements); int curSegements = (int)(segements * fillPercent); float tw = rectTransform.rect.width; float th = rectTransform.rect.height; float outerRadius = rectTransform.pivot.x * tw; float innerRadius = rectTransform.pivot.x * tw - thickness; Vector4 uv = overrideSprite != null?DataUtility.GetOuterUV(overrideSprite) : Vector4.zero; float uvCenterX = (uv.x + uv.z) * 0.5f; float uvCenterY = (uv.y + uv.w) * 0.5f; float uvScaleX = (uv.z - uv.x) / tw; float uvScaleY = (uv.w - uv.y) / th; float curDegree = 0; UIVertex uiVertex; int verticeCount; int triangleCount; Vector2 curVertice; if (fill) //圆形 { curVertice = Vector2.zero; verticeCount = curSegements + 1; uiVertex = new UIVertex(); uiVertex.color = color; uiVertex.position = curVertice; uiVertex.uv0 = new Vector2(curVertice.x * uvScaleX + uvCenterX, curVertice.y * uvScaleY + uvCenterY); vh.AddVert(uiVertex); for (int i = 1; i < verticeCount; i++) { float cosA = Mathf.Cos(curDegree); float sinA = Mathf.Sin(curDegree); curVertice = new Vector2(cosA * outerRadius, sinA * outerRadius); curDegree += degreeDelta; uiVertex = new UIVertex(); uiVertex.color = color; uiVertex.position = curVertice; uiVertex.uv0 = new Vector2(curVertice.x * uvScaleX + uvCenterX, curVertice.y * uvScaleY + uvCenterY); vh.AddVert(uiVertex); outterVertices.Add(curVertice); } triangleCount = curSegements * 3; for (int i = 0, vIdx = 1; i < triangleCount - 3; i += 3, vIdx++) { vh.AddTriangle(vIdx, 0, vIdx + 1); } if (fillPercent == 1) { //首尾顶点相连 vh.AddTriangle(verticeCount - 1, 0, 1); } } else//圆环 { verticeCount = curSegements * 2; for (int i = 0; i < verticeCount; i += 2) { float cosA = Mathf.Cos(curDegree); float sinA = Mathf.Sin(curDegree); curDegree += degreeDelta; curVertice = new Vector3(cosA * innerRadius, sinA * innerRadius); uiVertex = new UIVertex(); uiVertex.color = color; uiVertex.position = curVertice; uiVertex.uv0 = new Vector2(curVertice.x * uvScaleX + uvCenterX, curVertice.y * uvScaleY + uvCenterY); vh.AddVert(uiVertex); innerVertices.Add(curVertice); curVertice = new Vector3(cosA * outerRadius, sinA * outerRadius); uiVertex = new UIVertex(); uiVertex.color = color; uiVertex.position = curVertice; uiVertex.uv0 = new Vector2(curVertice.x * uvScaleX + uvCenterX, curVertice.y * uvScaleY + uvCenterY); vh.AddVert(uiVertex); outterVertices.Add(curVertice); } triangleCount = curSegements * 3 * 2; for (int i = 0, vIdx = 0; i < triangleCount - 6; i += 6, vIdx += 2) { vh.AddTriangle(vIdx + 1, vIdx, vIdx + 3); vh.AddTriangle(vIdx, vIdx + 2, vIdx + 3); } if (fillPercent == 1) { //首尾顶点相连 vh.AddTriangle(verticeCount - 1, verticeCount - 2, 1); vh.AddTriangle(verticeCount - 2, 0, 1); } } }
protected void Page_Load(object sender, EventArgs e) { Query q = QueryRepository.FindById(DataUtility.ParseInt(QueryString["queryid"])); PopulateControlsFromQuery(q); }
private void btn_Update_Click(object sender, EventArgs e) { New_Name = txb_Name.Text.Trim(); New_Birth = dtp_Birth.Value; New_Age = lab_Age.Text.Trim(); bool isChangeAge = false; string AlertMsg = string.Empty; if (New_Name != Old_Name || New_Birth.ToShortDateString() != Old_Birth.ToShortDateString() || New_Age != Old_Age) { AlertMsg += "請確認異動資料如下:" + Environment.NewLine; if (New_Name != Old_Name) { AlertMsg += "姓名:[" + Old_Name + "] --> [" + New_Name + "]" + Environment.NewLine; } if (New_Birth.ToShortDateString() != Old_Birth.ToShortDateString()) { AlertMsg += "生日:[" + Old_Birth.ToShortDateString() + "] --> [" + New_Birth.ToShortDateString() + "]" + Environment.NewLine; } if (New_Age != Old_Age) { isChangeAge = true; AlertMsg += "年齡:[" + Old_Age + "] --> [" + New_Age + "]" + Environment.NewLine + Environment.NewLine + "(若已結算成績且年齡有異動者,系統將自動重新計算成績)" + Environment.NewLine; } DialogResult dialogResult = MessageBox.Show(AlertMsg, "確認更新資料", MessageBoxButtons.YesNo); if (dialogResult == DialogResult.Yes) { try { Dictionary <string, object> d = new Dictionary <string, object>(); DataUtility du = new DataUtility(); d.Add("id", Id); d.Add("date", Test_date.ToShortDateString()); d.Add("name", New_Name); d.Add("birth", New_Birth.ToShortDateString()); d.Add("age", New_Age); du.executeNonQueryBysp("Ex108_UpdatePlayerData", d); if (isChangeAge == true && Status.Substring(0, 1) == "1") { if (Status == "102" || Status == "103" || Status == "105") { Dictionary <string, object> di = new Dictionary <string, object>(); DataTable dt = new DataTable(); di.Add("id", Id); di.Add("date", Test_date); DateTime Change_time = new DateTime(2018, 12, 31, 23, 59, 59); //檢查時間 2018年12月31日 if (Test_date > Change_time) //如果時間大於設定時間 { //新版-2019年1月1日開始啟用之成績結算sp dt = du.getDataTableBysp(@"Ex108_CalResultByID", di); } else { //舊版2018年之前用 dt = du.getDataTableBysp(@"Ex106_CalResultByID", di); } } } btn_InqData_Click(btn_InqData, e);//再執行一次查詢 MessageBox.Show("資料更新成功!!"); } catch (Exception ex) { MessageBox.Show("資料更新失敗,錯誤訊息如下:" + Environment.NewLine + ex.Message); } } } else { MessageBox.Show("資料未異動"); } }
private void OnEnable() { this.m_spriteRenderer = base.GetComponent <SpriteRenderer>(); this.m_uvs = DataUtility.GetInnerUV(this.m_spriteRenderer.sprite); this.m_spriteRenderer.sharedMaterial.SetVector("_CustomUVS", this.m_uvs); }
public static List <Tag> getTagList(this HtmlHelper helper, Profile profile) { return(DataUtility.getTagList(profile)); }
private Vector4 GetDrawingDimensions(bool shouldPreserveAspect) { Vector4 vector4_1 = !((UnityEngine.Object) this.overrideSprite == (UnityEngine.Object)null) ? DataUtility.GetPadding(this.overrideSprite) : Vector4.zero; Vector2 vector2 = !((UnityEngine.Object) this.overrideSprite == (UnityEngine.Object)null) ? new Vector2(this.overrideSprite.rect.width, this.overrideSprite.rect.height) : Vector2.zero; Rect pixelAdjustedRect = this.GetPixelAdjustedRect(); int num1 = Mathf.RoundToInt(vector2.x); int num2 = Mathf.RoundToInt(vector2.y); Vector4 vector4_2 = new Vector4(vector4_1.x / (float)num1, vector4_1.y / (float)num2, ((float)num1 - vector4_1.z) / (float)num1, ((float)num2 - vector4_1.w) / (float)num2); if (shouldPreserveAspect && (double)vector2.sqrMagnitude > 0.0) { float num3 = vector2.x / vector2.y; float num4 = pixelAdjustedRect.width / pixelAdjustedRect.height; if ((double)num3 > (double)num4) { float height = pixelAdjustedRect.height; pixelAdjustedRect.height = pixelAdjustedRect.width * (1f / num3); pixelAdjustedRect.y += (height - pixelAdjustedRect.height) * this.rectTransform.pivot.y; } else { float width = pixelAdjustedRect.width; pixelAdjustedRect.width = pixelAdjustedRect.height * num3; pixelAdjustedRect.x += (width - pixelAdjustedRect.width) * this.rectTransform.pivot.x; } } vector4_2 = new Vector4(pixelAdjustedRect.x + pixelAdjustedRect.width * vector4_2.x, pixelAdjustedRect.y + pixelAdjustedRect.height * vector4_2.y, pixelAdjustedRect.x + pixelAdjustedRect.width * vector4_2.z, pixelAdjustedRect.y + pixelAdjustedRect.height * vector4_2.w); return(vector4_2); }
private void GenerateSimpleSprite(VertexHelper vh, bool lPreserveAspect) { Vector4 drawingDimensions = this.GetDrawingDimensions(lPreserveAspect); Vector4 vector = (!(this.activeSprite != null)) ? Vector4.zero : DataUtility.GetOuterUV(this.activeSprite); Color color = this.color; vh.Clear(); vh.AddVert(new Vector3(drawingDimensions.x, drawingDimensions.y), color, new Vector2(vector.x, vector.y)); vh.AddVert(new Vector3(drawingDimensions.x, drawingDimensions.w), color, new Vector2(vector.x, vector.w)); vh.AddVert(new Vector3(drawingDimensions.z, drawingDimensions.w), color, new Vector2(vector.z, vector.w)); vh.AddVert(new Vector3(drawingDimensions.z, drawingDimensions.y), color, new Vector2(vector.z, vector.y)); vh.AddTriangle(0, 1, 2); vh.AddTriangle(2, 3, 0); }
//取得近七日多元選項比例 private void Get_chart_7DaySeleteOther() { DataUtility du = new DataUtility(); DataTable AllItem_dt = new DataTable(); //查詢日期及第三項基本+多元人數 DataTable OtherItem_dt = new DataTable(); //多元人數 Dictionary <string, object> d = new Dictionary <string, object>(); AllItem_dt = du.getDataTableBysp("Ex107_Get_7day_AllItemTest"); if (AllItem_dt.Rows.Count > 0) { string[] xValues_date = new string[AllItem_dt.Rows.Count]; string[] titleArr = { "多元比例(%)" }; int[] yValues_AllItem = new int[AllItem_dt.Rows.Count]; int[] yValues_OtherItem = new int[AllItem_dt.Rows.Count]; double[] yValues_OtherRate = new double[AllItem_dt.Rows.Count]; for (int i = AllItem_dt.Rows.Count - 1; i >= 0; i--) { xValues_date[AllItem_dt.Rows.Count - (i + 1)] = Convert.ToDateTime(AllItem_dt.Rows[i]["date"]).ToString("MM/dd"); //日期 yValues_AllItem[AllItem_dt.Rows.Count - (i + 1)] = Convert.ToInt16(AllItem_dt.Rows[i]["allitem"].ToString()); //總人數 d.Add("date", Convert.ToDateTime(AllItem_dt.Rows[i]["date"]).ToString("yyyy/MM/dd")); OtherItem_dt = du.getDataTableBysp("Ex107_Get_7day_OtherItemTest", d); if (OtherItem_dt.Rows.Count > 0) { yValues_OtherItem[AllItem_dt.Rows.Count - (i + 1)] = Convert.ToInt16(OtherItem_dt.Rows[0]["otheritem"].ToString());//多元人數 yValues_OtherRate[AllItem_dt.Rows.Count - (i + 1)] = Math.Round((Convert.ToDouble(yValues_OtherItem[AllItem_dt.Rows.Count - (i + 1)] / Convert.ToDouble(yValues_AllItem[AllItem_dt.Rows.Count - (i + 1)]))) * 100, 1); } else { yValues_OtherItem[AllItem_dt.Rows.Count - (i + 1)] = 0; yValues_OtherRate[AllItem_dt.Rows.Count - (i + 1)] = 0; } OtherItem_dt.Clear(); d.Clear(); } //柱狀圖 //設定 Legends------------------------------------------------------------------------ chart_7DaySeleteOther.Legends["Column"].DockedToChartArea = "ColumnChartArea"; //顯示在圖表內 //繪製的樣式 chart_7DaySeleteOther.Series["Column"]["DrawingStyle"] = "Cylinder"; chart_7DaySeleteOther.Series["Column"].BorderWidth = 0;//設定線粗 chart_7DaySeleteOther.Series["Column"].Points.DataBindXY(xValues_date, yValues_OtherRate); chart_7DaySeleteOther.Series["Column"].Legend = "Column"; chart_7DaySeleteOther.Series["Column"].LegendText = titleArr[0]; chart_7DaySeleteOther.ChartAreas["ColumnChartArea"].AxisX.Title = "日期"; chart_7DaySeleteOther.ChartAreas["ColumnChartArea"].AxisY.Title = "多元比例%"; chart_7DaySeleteOther.ChartAreas["ColumnChartArea"].AxisY.TextOrientation = TextOrientation.Stacked; //將文字變橫向顯示 chart_7DaySeleteOther.ChartAreas["ColumnChartArea"].AxisY.Maximum = 100; //設定Y軸最大值 //打開圖例 chart_7DaySeleteOther.Series["Column"].IsValueShownAsLabel = true; chart_7DaySeleteOther.Series["Column"].IsVisibleInLegend = false; //設定圖形X軸的顯示文字 foreach (DataPoint dp in chart_7DaySeleteOther.Series["Column"].Points) { dp.Label = dp.YValues[0].ToString() + "%"; } //放入資料表 if (xValues_date.Length > 0) { lab_Item_date1.Text = Convert.ToDateTime(AllItem_dt.Rows[6]["date"]).ToString("yyyy/MM/dd"); //日期 lab_Item_All1.Text = yValues_AllItem[0].ToString(); //總人數 lab_Item_Other1.Text = yValues_OtherItem[0].ToString(); //多元人數 lab_Item_Rate1.Text = yValues_OtherRate[0].ToString(); //多元比例 } if (xValues_date.Length > 1) { lab_Item_date2.Text = Convert.ToDateTime(AllItem_dt.Rows[5]["date"]).ToString("yyyy/MM/dd"); //日期 lab_Item_All2.Text = yValues_AllItem[1].ToString(); //總人數 lab_Item_Other2.Text = yValues_OtherItem[1].ToString(); //多元人數 lab_Item_Rate2.Text = yValues_OtherRate[1].ToString(); //多元比例 } if (xValues_date.Length > 2) { lab_Item_date3.Text = Convert.ToDateTime(AllItem_dt.Rows[4]["date"]).ToString("yyyy/MM/dd"); //日期 lab_Item_All3.Text = yValues_AllItem[2].ToString(); //總人數 lab_Item_Other3.Text = yValues_OtherItem[2].ToString(); //多元人數 lab_Item_Rate3.Text = yValues_OtherRate[2].ToString(); //多元比例 } if (xValues_date.Length > 3) { lab_Item_date4.Text = Convert.ToDateTime(AllItem_dt.Rows[3]["date"]).ToString("yyyy/MM/dd"); //日期 lab_Item_All4.Text = yValues_AllItem[3].ToString(); //總人數 lab_Item_Other4.Text = yValues_OtherItem[3].ToString(); //多元人數 lab_Item_Rate4.Text = yValues_OtherRate[3].ToString(); //多元比例 } if (xValues_date.Length > 4) { lab_Item_date5.Text = Convert.ToDateTime(AllItem_dt.Rows[2]["date"]).ToString("yyyy/MM/dd"); //日期 lab_Item_All5.Text = yValues_AllItem[4].ToString(); //總人數 lab_Item_Other5.Text = yValues_OtherItem[4].ToString(); //多元人數 lab_Item_Rate5.Text = yValues_OtherRate[4].ToString(); //多元比例 } if (xValues_date.Length > 5) { lab_Item_date6.Text = Convert.ToDateTime(AllItem_dt.Rows[1]["date"]).ToString("yyyy/MM/dd"); //日期 lab_Item_All6.Text = yValues_AllItem[5].ToString(); //總人數 lab_Item_Other6.Text = yValues_OtherItem[5].ToString(); //多元人數 lab_Item_Rate6.Text = yValues_OtherRate[5].ToString(); //多元比例 } if (xValues_date.Length > 6) { lab_Item_date7.Text = Convert.ToDateTime(AllItem_dt.Rows[0]["date"]).ToString("yyyy/MM/dd"); //日期 lab_Item_All7.Text = yValues_AllItem[6].ToString(); //總人數 lab_Item_Other7.Text = yValues_OtherItem[6].ToString(); //多元人數 lab_Item_Rate7.Text = yValues_OtherRate[6].ToString(); //多元比例 } } }