private static void ModDivCore(ref BigIntegerBuilder regNum, ref BigIntegerBuilder regDen, bool fQuo, ref BigIntegerBuilder regQuo) { regQuo.Set(0); if (regNum._iuLast < regDen._iuLast) { return; } var num1 = regDen._iuLast + 1; var num2 = regNum._iuLast - regDen._iuLast; var num3 = num2; var num4 = regNum._iuLast; while (true) { if (num4 < num2) { num3++; break; } if (regDen._bits[num4 - num2] == regNum._bits[num4]) { num4--; } else { if (regDen._bits[num4 - num2] < regNum._bits[num4]) { num3++; } break; } } if (num3 == 0) { return; } if (fQuo) { regQuo.SetSizeLazy(num3); } var num5 = regDen._bits[num1 - 1]; var num6 = regDen._bits[num1 - 2]; var num7 = NumericHelper.CbitHighZero(num5); var num8 = 32 - num7; if (num7 > 0) { num5 = num5 << (num7 & 31) | num6 >> (num8 & 31); num6 = num6 << (num7 & 31); if (num1 > 2) { num6 = num6 | regDen._bits[num1 - 3] >> (num8 & 31); } } regNum.EnsureWritable(); var num9 = num3; while (true) { var num10 = num9 - 1; num9 = num10; if (num10 < 0) { break; } var num = num9 + num1 > regNum._iuLast ? 0 : regNum._bits[num9 + num1]; var num11 = num; var num12 = NumericHelper.BuildUInt64(num11, regNum._bits[num9 + num1 - 1]); var num13 = regNum._bits[num9 + num1 - 2]; if (num7 > 0) { num12 = num12 << (num7 & 63) | num13 >> (num8 & 31); num13 = num13 << (num7 & 31); if (num9 + num1 >= 3) { num13 = num13 | regNum._bits[num9 + num1 - 3] >> (num8 & 31); } } var num14 = num12 / num5; var num15 = (ulong)(uint)(num12 % num5); if (num14 > uint.MaxValue) { num15 += num5 * (num14 - uint.MaxValue); num14 = uint.MaxValue; } while (num15 <= uint.MaxValue && num14 * num6 > NumericHelper.BuildUInt64((uint)num15, num13)) { num14--; num15 += num5; } if (num14 > 0) { var num16 = (ulong)0; for (var i = 0; i < num1; i++) { num16 = num16 + regDen._bits[i] * num14; var num17 = (uint)num16; num16 = num16 >> 32; if (regNum._bits[num9 + i] < num17) { num16 = num16 + 1; } regNum._bits[num9 + i] = regNum._bits[num9 + i] - num17; } if (num11 < num16) { uint num18 = 0; for (var j = 0; j < num1; j++) { num18 = AddCarry(ref regNum._bits[num9 + j], regDen._bits[j], num18); } num14 = num14 - 1; } regNum._iuLast = num9 + num1 - 1; } if (fQuo) { if (num3 != 1) { regQuo._bits[num9] = (uint)num14; } else { regQuo._uSmall = (uint)num14; } } } regNum._iuLast = num1 - 1; regNum.Trim(); }
private static void LehmerGcd(ref BigIntegerBuilder reg1, ref BigIntegerBuilder reg2) { var num = 1; while (true) { var num1 = reg1._iuLast + 1; var num2 = reg2._iuLast + 1; if (num1 < num2) { NumericHelper.Swap(ref reg1, ref reg2); NumericHelper.Swap(ref num1, ref num2); } if (num2 == 1) { if (num1 == 1) { reg1._uSmall = NumericHelper.GCD(reg1._uSmall, reg2._uSmall); } else if (reg2._uSmall != 0) { reg1.Set(NumericHelper.GCD(Mod(ref reg1, reg2._uSmall), reg2._uSmall)); } return; } if (num1 == 2) { break; } if (num2 > num1 - 2) { var high2 = reg1.GetHigh2(num1); var high21 = reg2.GetHigh2(num1); var num3 = NumericHelper.CbitHighZero(high2 | high21); if (num3 > 0) { high2 = high2 << (num3 & 63) | reg1._bits[num1 - 3] >> (32 - num3 & 31); high21 = high21 << (num3 & 63) | reg2._bits[num1 - 3] >> (32 - num3 & 31); } if (high2 < high21) { NumericHelper.Swap(ref high2, ref high21); NumericHelper.Swap(ref reg1, ref reg2); } if (high2 == ulong.MaxValue || high21 == ulong.MaxValue) { high2 = high2 >> 1; high21 = high21 >> 1; } if (high2 == high21) { reg1.Sub(ref num, ref reg2); } else if (NumericHelper.GetHi(high21) != 0) { uint num4 = 1; uint num5 = 0; uint num6 = 0; uint num7 = 1; while (true) { uint num8 = 1; var num9 = high2 - high21; while (num9 >= high21 && num8 < 32) { num9 = num9 - high21; num8++; } if (num9 >= high21) { var num10 = high2 / high21; if (num10 <= uint.MaxValue) { num8 = (uint)num10; num9 = high2 - num8 * high21; } else { break; } } var num11 = num4 + num8 * (ulong)num6; var num12 = num5 + num8 * (ulong)num7; if (num11 > 2147483647 || num12 > 2147483647) { break; } if (num9 < num12 || num9 + num11 > high21 - num6) { break; } num4 = (uint)num11; num5 = (uint)num12; high2 = num9; if (high2 > num5) { num8 = 1; num9 = high21 - high2; while (num9 >= high2 && num8 < 32) { num9 = num9 - high2; num8++; } if (num9 >= high2) { var num13 = high21 / high2; if (num13 <= uint.MaxValue) { num8 = (uint)num13; num9 = high21 - num8 * high2; } else { break; } } num11 = num7 + num8 * (ulong)num5; num12 = num6 + num8 * (ulong)num4; if (num11 > 2147483647 || num12 > 2147483647) { break; } if (num9 < num12 || num9 + num11 > high2 - num5) { break; } num7 = (uint)num11; num6 = (uint)num12; high21 = num9; if (high21 <= num6) { break; } } else { break; } } if (num5 != 0) { reg1.SetSizeKeep(num2, 0); reg2.SetSizeKeep(num2, 0); var num14 = 0; var num15 = 0; for (var i = 0; i < num2; i++) { var num16 = reg1._bits[i]; var num17 = reg2._bits[i]; var num18 = (long)num16 * num4 - (long)num17 * num5 + num14; var num19 = (long)num17 * num7 - (long)num16 * num6 + num15; num14 = (int)(num18 >> 32); num15 = (int)(num19 >> 32); reg1._bits[i] = (uint)num18; reg2._bits[i] = (uint)num19; } reg1.Trim(); reg2.Trim(); } else if (high2 / 2 < high21) { reg1.Sub(ref num, ref reg2); } else { reg1.Mod(ref reg2); } } else { reg1.Mod(ref reg2); } } else { reg1.Mod(ref reg2); } } reg1.Set(NumericHelper.GCD(reg1.GetHigh2(2), reg2.GetHigh2(2))); }
private static int Log2SoftwareFallback(uint value) { return(value == 0 ? 0 : NumericHelper.Log2(value)); }
/// <summary> /// Create a data instance from the raw ProcessLineOfSight output /// </summary> public SightLineData(Tuple <bool, float, float, float, MtaElement, float, float, Tuple <float, int, float, int, int, float, float, Tuple <float, float, float, float, int> > > d) { DidHit = d.Item1; if (DidHit) { CollisionPosition = new Vector3(d.Item2, d.Item3, d.Item4); if (d.Item5 != null) { HitElement = ElementManager.Instance.GetElement <PhysicalElement>(d.Item5); } Normal = new Vector3(d.Item6, d.Item7, d.Rest.Item1); SurfaceMaterial = (SurfaceMaterialType)d.Rest.Item2; Lighting = d.Rest.Item3; piece = d.Rest.Item4; WorldModelID = d.Rest.Item5; WorldModelMatrix = Matrix4x4.CreateTranslation(d.Rest.Item6, d.Rest.Item7, d.Rest.Rest.Item1) + Matrix4x4.CreateFromQuaternion(NumericHelper.EulerToQuaternion(new Vector3(d.Rest.Rest.Item2, d.Rest.Rest.Item3, d.Rest.Rest.Item4))); WorldLODModelID = d.Rest.Item5; } }
/// <summary> /// This method is used to parse DataIndex objects. /// </summary> public DataIndex ParseDataIndex(ref DataIndex dataIndex, XmlNode xmlNode) { // if the dataIndex object exists and the xmlNode exists if ((dataIndex != null) && (xmlNode != null)) { // get the full name of this node string fullName = xmlNode.GetFullName(); // Check the name of this node to see if it is mapped to a property switch (fullName) { case "Database.Tables.DataTable.Indexes.DataIndex.AllowPageLocks": // Set the value for dataIndex.AllowPageLocks dataIndex.AllowPageLocks = BooleanHelper.ParseBoolean(xmlNode.FormattedNodeValue, false, false); // required break; case "Database.Tables.DataTable.Indexes.DataIndex.AllowRowLocks": // Set the value for dataIndex.AllowRowLocks dataIndex.AllowRowLocks = BooleanHelper.ParseBoolean(xmlNode.FormattedNodeValue, false, false); // required break; case "Database.Tables.DataTable.Indexes.DataIndex.Clustered": // Set the value for dataIndex.Clustered dataIndex.Clustered = BooleanHelper.ParseBoolean(xmlNode.FormattedNodeValue, false, false); // required break; case "Database.Tables.DataTable.Indexes.DataIndex.DataSpaceId": // Set the value for dataIndex.DataSpaceId dataIndex.DataSpaceId = NumericHelper.ParseInteger(xmlNode.FormattedNodeValue, 0, -1); // required break; case "Database.Tables.DataTable.Indexes.DataIndex.FillFactor": // Set the value for dataIndex.FillFactor dataIndex.FillFactor = NumericHelper.ParseInteger(xmlNode.FormattedNodeValue, 0, -1); // required break; case "Database.Tables.DataTable.Indexes.DataIndex.FilterDefinition": // Set the value for dataIndex.FilterDefinition dataIndex.FilterDefinition = xmlNode.FormattedNodeValue; // required break; case "Database.Tables.DataTable.Indexes.DataIndex.HasFilter": // Set the value for dataIndex.HasFilter dataIndex.HasFilter = BooleanHelper.ParseBoolean(xmlNode.FormattedNodeValue, false, false); // required break; case "Database.Tables.DataTable.Indexes.DataIndex.IgnoreDuplicateKey": // Set the value for dataIndex.IgnoreDuplicateKey dataIndex.IgnoreDuplicateKey = BooleanHelper.ParseBoolean(xmlNode.FormattedNodeValue, false, false); // required break; case "Database.Tables.DataTable.Indexes.DataIndex.IndexId": // Set the value for dataIndex.IndexId dataIndex.IndexId = NumericHelper.ParseInteger(xmlNode.FormattedNodeValue, 0, -1); // required break; case "Database.Tables.DataTable.Indexes.DataIndex.IndexType": // Set the value for dataIndex.IndexType dataIndex.IndexType = EnumHelper.GetEnumValue <DataJuggler.Net5.Enumerations.IndexTypeEnum>(xmlNode.FormattedNodeValue, DataJuggler.Net5.Enumerations.IndexTypeEnum.Unknown); // required break; case "Database.Tables.DataTable.Indexes.DataIndex.IsDisabled": // Set the value for dataIndex.IsDisabled dataIndex.IsDisabled = BooleanHelper.ParseBoolean(xmlNode.FormattedNodeValue, false, false); // required break; case "Database.Tables.DataTable.Indexes.DataIndex.IsHypothetical": // Set the value for dataIndex.IsHypothetical dataIndex.IsHypothetical = BooleanHelper.ParseBoolean(xmlNode.FormattedNodeValue, false, false); // required break; case "Database.Tables.DataTable.Indexes.DataIndex.IsPadded": // Set the value for dataIndex.IsPadded dataIndex.IsPadded = BooleanHelper.ParseBoolean(xmlNode.FormattedNodeValue, false, false); // required break; case "Database.Tables.DataTable.Indexes.DataIndex.IsPrimary": // Set the value for dataIndex.IsPrimary dataIndex.IsPrimary = BooleanHelper.ParseBoolean(xmlNode.FormattedNodeValue, false, false); // required break; case "Database.Tables.DataTable.Indexes.DataIndex.IsUnique": // Set the value for dataIndex.IsUnique dataIndex.IsUnique = BooleanHelper.ParseBoolean(xmlNode.FormattedNodeValue, false, false); // required break; case "Database.Tables.DataTable.Indexes.DataIndex.IsUniqueConstraint": // Set the value for dataIndex.IsUniqueConstraint dataIndex.IsUniqueConstraint = BooleanHelper.ParseBoolean(xmlNode.FormattedNodeValue, false, false); // required break; case "Database.Tables.DataTable.Indexes.DataIndex.Name": // Set the value for dataIndex.Name dataIndex.Name = xmlNode.FormattedNodeValue; // required break; case "Database.Tables.DataTable.Indexes.DataIndex.ObjectId": // Set the value for dataIndex.ObjectId dataIndex.ObjectId = NumericHelper.ParseInteger(xmlNode.FormattedNodeValue, 0, -1); // required break; case "Database.Tables.DataTable.Indexes.DataIndex.TypeDescription": // Set the value for dataIndex.TypeDescription dataIndex.TypeDescription = xmlNode.FormattedNodeValue; // required break; } // if there are ChildNodes if (xmlNode.HasChildNodes) { // iterate the child nodes foreach (XmlNode childNode in xmlNode.ChildNodes) { // append to this DataIndex dataIndex = ParseDataIndex(ref dataIndex, childNode); } } } // return value return(dataIndex); }
/// <summary> /// Make this element face another element /// </summary> /// <param name="target">The element to face</param> public virtual void FaceElement(PhysicalElement target) { Rotation = NumericHelper.RotationBetweenPositions(Position, target.Position); }
/// <summary> /// This method Check For Updated Version /// </summary> private void CheckForUpdatedVersion() { // locals double latestVersion = 0; string url = ""; try { // get the url for the Xml info url = "http://www.datajuggler.com/Regionizer/CommentDictionaryInfo.xml"; // create an xml reader XmlTextReader reader = new XmlTextReader(url); // read the xml line per line while (reader.Read()) { // determine what to do by the text string nodeName = reader.Name; // determine the action by the nodeName switch (nodeName) { case "LatestVersion": // set the latestVersion latestVersion = NumericHelper.ParseDouble(reader.ReadInnerXml(), 0, -1); // required break; case "Url": // set the latestVersion url = reader.ReadInnerXml(); // required break; } } // close the reader reader.Close(); // if the latestVersion is set if ((latestVersion > 0) && (TextHelper.Exists(url))) { // set the content this.AvailableVersionValueLabel.Content = latestVersion.ToString(); this.AvailableVersionValueLabel.Visibility = System.Windows.Visibility.Visible; this.CheckForUpdateButton.Visibility = System.Windows.Visibility.Hidden; this.DownloadUrl = url; // enable the Download button if a newer version is available UIEnable(); } } catch (Exception error) { // for debugging only string err = error.ToString(); } }
private void Search_B_Click(System.Object sender, System.EventArgs e) { DV.Rows.Clear(); DV.Columns.Clear(); DV.Columns.Add("row", "ردیف"); DV.Columns.Add("Cost_Id_Total", "کد و نام دستگاه"); DV.Columns.Add("Cost_Num_Failure", "مجموع تعداد خرابی"); DV.Columns.Add("Cost_Time_Stop_Repair", "مجموع ساعت تعمیرات "); DV.Columns.Add("Cost_Time_Befor_Work", "مجموع کارکرد دستگاه"); DV.Columns.Add("Cost_MTTR", "MTTR شاخص"); DV.Columns.Add("Cost_MTBF", "MTBF شاخص"); DV.Columns["row"].Width = 50; DV.Columns["Cost_Id_Total"].Width = 300; DV.Columns["Cost_Num_Failure"].Width = 120; DV.Columns["Cost_Time_Stop_Repair"].Width = 120; DV.Columns["Cost_Time_Befor_Work"].Width = 120; DV.Columns["Cost_MTTR"].Width = 100; DV.Columns["Cost_MTBF"].Width = 100; DV.AllowUserToAddRows = false; DV.EditMode = DataGridViewEditMode.EditProgrammatically; f_serch = ""; if (Cost_Id_Total.Text.Length != 0) { f_serch += "and Cost_Id_Total LIKE N'" + data.Is_Number(Cost_Id_Total.Text) + "'"; } if (Cost_Id_Request.Text.Length != 0) { f_serch += "and Cost_Id_Request LIKE N'" + data.Is_Number(Cost_Id_Request.Text) + "'"; } if (Cost_Num_Request.Text.Length != 0) { f_serch += "and Cost_Num_Request LIKE N'" + Cost_Num_Request.Text + "'"; } if (data.Is_date(Az_Cost_Date_Request.T_D)) { f_serch += "and Cost_Date_Request >= '" + NumericHelper.Val((Az_Cost_Date_Request.T_D).Replace("/", "")) + "'"; } if (data.Is_date(Ta_Cost_Date_Request.T_D)) { f_serch += "and Cost_Date_Request <= '" + NumericHelper.Val((Ta_Cost_Date_Request.T_D).Replace("/", "")) + "'"; } if (data.Is_date(Az_Cost_Date_Sabt.T_D)) { f_serch += "and Cost_Date_Sabt >= '" + NumericHelper.Val((Az_Cost_Date_Sabt.T_D).Replace("/", "")) + "'"; } if (data.Is_date(Ta_Cost_Date_Sabt.T_D)) { f_serch += "and Cost_Date_Sabt <= '" + NumericHelper.Val((Ta_Cost_Date_Sabt.T_D).Replace("/", "")) + "'"; } if (Cost_Repair_description.Text.Length != 0) { f_serch += "and Cost_Repair_description LIKE N'%" + Cost_Repair_description.Text + "%'"; } if (Cost_Work_description.Text.Length != 0) { f_serch += "and Cost_Work_description LIKE N'%" + Cost_Work_description.Text + "%'"; } if (Cost_Stop_Defect.Text.Length != 0) { f_serch += "and Cost_Stop_Defect LIKE N'" + data.Is_Number(Cost_Stop_Defect.Text) + "'"; } if (MDIParent1.DefaultInstance.N_Admin.Text == "False") { f_serch += "and Repair_Area = " + MDIParent1.DefaultInstance.N_Id_Area.Text + ""; } f_serch = Microsoft.VisualBasic.Strings.Replace(f_serch, "and", "", 1, 1); if (string.IsNullOrEmpty(f_serch)) { modMessage.ShowMessage("کاربر محترم" + " :" + MDIParent1.DefaultInstance.I_N.Text, " موردی برای جستجو مشخص نشده آیا کلیه اقلام جستجو شوند ؟", frmMessage.mIcon.mserch, frmMessage.mButtons.myes_No); if (modMessage.MessageValue == 5) { f_serch = "SELECT repair_code,Repair_Name,Count(Cost_Id_Total)as C_Count ," + "sum(CAST(SUBSTRING([Cost_Time_Stop_Repair],1,2) AS int)) AS Hrs_Stop ," + "sum(CAST(SUBSTRING([Cost_Time_Stop_Repair],4,5) AS int)) AS Min_Stop ," + "sum(CAST(SUBSTRING([Cost_Time_Befor_Work],1,2) AS int)) AS Hrs_Befor ," + "sum(CAST(SUBSTRING([Cost_Time_Befor_Work],4,5) AS int)) AS Min_Befor " + "FROM Repair_Cost A LEFT JOIN Repair_Total B on a.Cost_Id_Total=b.Repair_Id GROUP BY repair_code,Repair_Name"; } else { return; } } else { f_serch = "SELECT repair_code,Repair_Name,Count(Cost_Id_Total)as C_Count ," + "sum(CAST(SUBSTRING([Cost_Time_Stop_Repair],1,2) AS int)) AS Hrs_Stop ," + "sum(CAST(SUBSTRING([Cost_Time_Stop_Repair],4,5) AS int)) AS Min_Stop ," + "sum(CAST(SUBSTRING([Cost_Time_Befor_Work],1,2) AS int)) AS Hrs_Befor ," + "sum(CAST(SUBSTRING([Cost_Time_Befor_Work],4,5) AS int)) AS Min_Befor " + "FROM Repair_Cost A LEFT JOIN Repair_Total B on a.Cost_Id_Total=b.Repair_Id where " + f_serch + " GROUP BY repair_code,Repair_Name"; } DataSet serch = data.PDataset("" + f_serch + ""); if (serch.Tables[0].Rows.Count == 0) { modMessage.ShowMessage("کاربر محترم" + " :" + MDIParent1.DefaultInstance.I_N.Text, " اطلاعات مورد نظر شما در سیستم وجود ندارد", frmMessage.mIcon.mserch, frmMessage.mButtons.mAccept); } else { foreach (DataRow Dr in serch.Tables[0].Rows) { DV.Rows.Add(); System.Windows.Forms.DataGridViewRow tempVar = DV.Rows[DV.Rows.Count - 1]; tempVar.Cells["row"].Value = DV.Rows.Count; tempVar.Cells["Cost_Id_Total"].Value = Dr["repair_code"].ToString() + "-" + Dr["Repair_Name"].ToString(); tempVar.Cells["Cost_Num_Failure"].Value = Dr["C_Count"]; int hh_Stop = 0; int mm_Stop = 0; int hh_Befor = 0; int mm_Befor = 0; if (Convert.ToInt32(Dr["Min_Stop"]) > 59) { hh_Stop = ((Dr["Hrs_Stop"] * 60) + Dr["Min_Stop"]) / 60; mm_Stop = Convert.ToInt32(((Dr["Hrs_Stop"] * 60) + Dr["Min_Stop"]) - (hh_Stop * 60)); } else { hh_Stop = Convert.ToInt32(Dr["Hrs_Stop"]); mm_Stop = Convert.ToInt32(Dr["Min_Stop"]); } tempVar.Cells["Cost_Time_Stop_Repair"].Value = hh_Stop + ":" + mm_Stop; if (Convert.ToInt32(Dr["Min_Befor"]) > 59) { hh_Befor = ((Dr["Hrs_Befor"] * 60) + Dr["Min_Befor"]) / 60; mm_Befor = Convert.ToInt32(((Dr["Hrs_Befor"] * 60) + Dr["Min_Befor"]) - (hh_Befor * 60)); } else { hh_Befor = Convert.ToInt32(Dr["Hrs_Befor"]); mm_Befor = Convert.ToInt32(Dr["Min_Befor"]); } if (Check.Checked == true) { tempVar.Cells["Cost_Time_Befor_Work"].Value = Cost_Time_Befor_Work.Text; tempVar.Cells["Cost_MTTR"].Value = Math.Round(((NumericHelper.Val(hh_Stop) * 60) + NumericHelper.Val(mm_Stop)) / Dr["C_Count"], 2); tempVar.Cells["Cost_MTBF"].Value = Math.Round(Dr["C_Count"] / ((NumericHelper.Val(Cost_Time_Befor_Work.Text.Substring(0, 2)) * 60) + NumericHelper.Val(Cost_Time_Befor_Work.Text.Substring(3, 5))), 2); }
/// <summary> /// This method returns the GameManager. It first attempts to load the values from the settings /// and if not found the default GameManager.Options and GameManager.Players are created. /// </summary> private GameManager LoadGameManager() { // initial value GameManager gameManager = null; // local so the Settings file only has to be loaded once SecureUserData security = new SecureUserData(); // this is used during development so everything default is restored, this has to be taken out or commented out // security.LastSavedDate = new DateTime(1900, 1, 1); // save (this needs to be taken out or commented out also) // security.Save(); // We must load our five PlayerControls List <BlackJackPlayerControl> playerControls = GetPlayerControls(); // if the security object has a LastSavedDate we can load a GameManager from it if (security.HasLastSavedDate) { // convert the settings to a gameManager object gameManager = SecureUserDataFactory.Export(security, playerControls, this); } else { // Create a new instance of a 'GameManager' object. gameManager = new GameManager(NumericHelper.ParseInteger(Properties.Resources.TimesToShuffle, 0, -1), this); // Now we must load the Options and Players from the Settings gameManager.HouseRules = Options.CreateDefault(); // Load the players from the Settings or create them gameManager.Players = CreateDefaultPlayers(gameManager.HouseRules); } //// Create a new instance of an 'OptionsForm' object. OptionsForm optionsForm = new OptionsForm(this); // Setup the form optionsForm.Setup(gameManager); //// Show the dialog optionsForm.ShowDialog(); // if the user did not cancel if (!optionsForm.UserCancelled) { // set the return value this.GameManager = optionsForm.GameManager; } else { // if the GameManager does not exist if (!this.HasGameManager) { // Close this app Environment.Exit(0); } } // return value return(gameManager); }
/// <summary> /// Make this ped face a specific physical element /// </summary> /// <param name="target">The element to face</param> public override void FaceElement(PhysicalElement target) { Rotation = NumericHelper.RotationBetweenPositions(target.Position, Position); }
private void Seasonal_Gross_Price_TextChanged(dynamic sender, System.EventArgs e) { sender.Text = NumericHelper.Val(sender.Text.Trim().Replace(",", "")).ToString("#,0"); //& aa sender.SelectionStart = sender.TextLength; double _Value = Convert.ToInt64(sender.Text.Replace(",", "")); }
/// <summary> /// This method Set Update Parameters /// </summary> public static void SetUpdateParameters(string updateText, ref PixelQuery pixelQuery) { // if the updateText exists and the pixelQuery object exists if ((TextHelper.Exists(updateText)) && (NullHelper.Exists(pixelQuery))) { // if the updateText starts with the word set (else this is not a proper BQL Update query). if (updateText.StartsWith("set")) { // only use a space as a delimiter character char[] delimiterChars = { ' ' }; // Get a list of words from this text List <Word> words = WordParser.GetWords(updateText); // If the words collection exists and has one or more items if (ListHelper.HasOneOrMoreItems(words)) { // if there are six words. // Example: Set Color 100 150 200 40 - (Red = 100, Green = 150, Blue = 200, Alpha = 40) if (words.Count == 6) { // Set to red pixelQuery.Red = NumericHelper.ParseInteger(words[2].Text, -1, -2); pixelQuery.Green = NumericHelper.ParseInteger(words[3].Text, -1, -2); pixelQuery.Blue = NumericHelper.ParseInteger(words[4].Text, -1, -2); pixelQuery.Alpha = NumericHelper.ParseInteger(words[5].Text, -1, -2); // verify everything is valid if ((pixelQuery.Red >= 0) && (pixelQuery.Green >= 0) && (pixelQuery.Red >= 0) && (pixelQuery.Alpha >= 0)) { // Set the Color pixelQuery.Color = Color.FromArgb(pixelQuery.Alpha, pixelQuery.Red, pixelQuery.Green, pixelQuery.Blue); } } // if there are 5 words // Example: Set Color 100 150 200 - (Red = 100, Green = 150, Blue = 200, Alpha = 255 default value) else if (words.Count == 5) { // Set to red pixelQuery.Red = NumericHelper.ParseInteger(words[2].Text, -1, -2); pixelQuery.Green = NumericHelper.ParseInteger(words[3].Text, -1, -2); pixelQuery.Blue = NumericHelper.ParseInteger(words[4].Text, -1, -2); pixelQuery.Alpha = 255; // verify everything is valid if ((pixelQuery.Red >= 0) && (pixelQuery.Green >= 0) && (pixelQuery.Red >= 0) && (pixelQuery.Alpha >= 0)) { // Set the Color pixelQuery.Color = Color.FromArgb(pixelQuery.Alpha, pixelQuery.Red, pixelQuery.Green, pixelQuery.Blue); } // Set the Color pixelQuery.Color = Color.FromArgb(pixelQuery.Alpha, pixelQuery.Red, pixelQuery.Green, pixelQuery.Blue); } // if there are 3 words // Example: Set Color Orchid (the color must be a named color) else if (words.Count == 3) { // Set the Color pixelQuery.Color = Color.FromName(words[2].Text); pixelQuery.Alpha = 255; } } } } }
/// <summary> /// This method returns the Pixel Criteria /// </summary> public static PixelCriteria CreatePixelCriteria(string text, ActionTypeEnum actionType, int lineNumber, PixelCriteria existingCriteria = null) { // initial value PixelCriteria pixelCriteria = null; // only use a space as a delimiter character char[] delimiterChars = { ' ' }; // If the text string exists if (TextHelper.Exists(text)) { // Set the BackColor if (actionType == ActionTypeEnum.SetBackColor) { // Create a new instance of a 'PixelCriteria' object. pixelCriteria = new PixelCriteria(); // Get the words List <Word> words = WordParser.GetWords(text, delimiterChars); // If the words collection exists and has one or more items if (ListHelper.HasOneOrMoreItems(words)) { // if there are 3 words if (words.Count == 3) { // if the third word is null if (words[2].Text.ToLower() == "null") { // Set the value for the property 'RemoveBackColor' to true pixelCriteria.RemoveBackColor = true; } else { // Set the BackColor pixelCriteria.BackColor = Color.FromName(words[2].Text); } } else if (words.Count == 5) { // set the value for Red, Green & Blue int red = NumericHelper.ParseInteger(words[2].Text, -1, -1); int green = NumericHelper.ParseInteger(words[3].Text, -1, -1); int blue = NumericHelper.ParseInteger(words[4].Text, -1, -1); // if all the RGB values are set if ((red >= 0) && (green >= 0) && (blue >= 0)) { // Set the BackColor pixelCriteria.BackColor = Color.FromArgb(red, green, blue); } } } } // if this is a draw line else if (actionType == ActionTypeEnum.DrawLine) { // if the existingCriteria if (NullHelper.IsNull(existingCriteria)) { // Create a new instance of a 'PixelCriteria' object. pixelCriteria = new PixelCriteria(); } else { // use the existing criteria so more properties can be set on it pixelCriteria = existingCriteria; } // Set to DrawLine pixelCriteria.PixelType = PixelTypeEnum.DrawLine; // if this is the first line if (lineNumber == 1) { // Get the words List <Word> words = WordParser.GetWords(text, delimiterChars); // If the words collection exists and has one or more items if (ListHelper.HasOneOrMoreItems(words)) { // Get the lastWord Word lastWord = words[words.Count - 1]; // Set the thickness pixelCriteria.Thickness = NumericHelper.ParseInteger(lastWord.Text, -1000, -1001); } } else if (lineNumber == 3) { // Set the RepeatType and the repeating attributes pixelCriteria.RepeatType = SetRepeatType(text); // if the repeat type was found if (pixelCriteria.RepeatType != RepeatTypeEnum.NoRepeat) { // get the text after the repeat string repeatText = GetRepeatText(text, pixelCriteria.RepeatType); // get the words List <Word> words = WordParser.GetWords(repeatText); // if there are exactly two words if ((ListHelper.HasOneOrMoreItems(words)) && (words.Count == 2)) { // set the repititions pixelCriteria.Repititions = NumericHelper.ParseInteger(words[0].Text, 0, -1); // set the Distance pixelCriteria.Distance = NumericHelper.ParseInteger(words[1].Text, 0, -1); } } } } else if (lineNumber > 1) { // Create a new instance of a 'PixelCriteria' object. pixelCriteria = new PixelCriteria(); // if this text contains bluegreen if (text.Contains("x")) { // Set the PixelType pixelCriteria.PixelType = PixelTypeEnum.X; } else if (text.Contains("y")) { // Set the PixelType pixelCriteria.PixelType = PixelTypeEnum.Y; } else if (text.Contains("bluegreen")) { // Set the PixelType pixelCriteria.PixelType = PixelTypeEnum.BlueGreen; } // if this text contains bluegreen else if (text.Contains("bluered")) { // Set the PixelType pixelCriteria.PixelType = PixelTypeEnum.BlueRed; } // if this text contains bluegreen else if (text.Contains("greenred")) { // Set the PixelType pixelCriteria.PixelType = PixelTypeEnum.GreenRed; } else if (text.Contains("red")) { // Set the PixelType pixelCriteria.PixelType = PixelTypeEnum.Red; } else if (text.Contains("green")) { // Set the PixelType pixelCriteria.PixelType = PixelTypeEnum.Green; } else if (text.Contains("blue")) { // Set the PixelType pixelCriteria.PixelType = PixelTypeEnum.Blue; } else if (text.Contains("total")) { // Set the PixelType pixelCriteria.PixelType = PixelTypeEnum.Total; } } } // return value return(pixelCriteria); }
/// <summary> /// Initializes a new instance of the <see cref="FixedSizeQueue{T}" /> class. /// </summary> /// <param name="capacity">The capacity.</param> public FixedSizeQueue(int capacity) { _capacity = NumericHelper.PopulationCount(capacity) == 1 ? capacity : NumericHelper.NextPowerOf2(capacity); _preCount = 0; _indexEnqueue = 0; _indexDequeue = 0; _entries = new FixedSizeBucket <T>(_capacity); }
/// <summary> /// This class is used to Shuffle a list of type 'T'. /// </summary> /// <typeparam name="T"></typeparam> /// <param name="list"></param> public static List <T> Shuffle <T>(this IList <T> list) { // List List <T> shuffledList = new List <T>(); // locals int randomIndex = -1; int cycles = 1; // Use the RNGCryptoServiceProvider to create random zeros or 1 RNGCryptoServiceProvider crypto = new RNGCryptoServiceProvider(); // Create the byte array that serves asa byte[] container = new byte[1]; // if the list exists if ((list != null) && (list.Count > 0)) { // we can't use the collection count it changes int listCount = list.Count; // set the cycles cycles = (listCount / 255) + 1; // now we have to 'Randomly' pull items and add them to the end results for (int x = 0; x < listCount; x++) { // reset randomIndex = -1; // Fill the topOrBottom byteArray crypto.GetBytes(container); // iterate the cycles for (int c = 0; c < cycles; c++) { // Get the value of topOrBottom object randomByte = container.GetValue(0); // if the randomByte exists if (NullHelper.Exists(randomByte)) { // get a randomValue int randomValue = NumericHelper.ParseInteger(randomByte.ToString(), -1, -1); // set the randomIndex to the modulas of the the listCount randomIndex += randomValue; } } // ensure in range randomIndex = (randomIndex % list.Count); // verify the index is in range if ((randomIndex < list.Count) && (randomIndex >= 0)) { // Add this integer shuffledList.Add(list[randomIndex]); // if the index is in rage if ((list.Count > 0) && (list.Count > randomIndex)) { // Remove the item from the sourceList now that we have it list.RemoveAt(randomIndex); } } } } // return value return(shuffledList); }
/// <summary> /// Creates a dictionary-like object used for caches. /// </summary> /// <param name="capacity">The maximum number of elements to store will be this number aligned to next ^2.</param> public CacheDict(int capacity) { _entries = new Entry[NumericHelper.PopulationCount(capacity) == 1 ? capacity : NumericHelper.NextPowerOf2(capacity)]; }
/// <summary> /// Attach this attachable to a toAttachable with a vector describing the position offset and a quaternion describing the rotation offset /// </summary> public void AttachTo(PhysicalElement toElement, Vector3 positionOffset, Quaternion rotationOffset) { AttachTo(toElement, positionOffset, NumericHelper.QuaternionToEuler(rotationOffset)); }
public void IsNonNegativeTest(bool expected, double value) => Assert.Equal(expected, NumericHelper.IsNonNegative(value));
public IEnumerable <SlipInvoiceViewModel> LoadInvoiceInfo(string invoiceNo) { var model = new SlipInvoiceViewModel(); using (var ctx = new VIPDCEntities()) { var invoice = ctx.Invoices.SingleOrDefault(inv => inv.InvoiceNo == invoiceNo); if (invoice != null) { var confirmationLetter = invoice.ConfirmationLetter; var customer = confirmationLetter.Customer; model.InvoiceNo = invoice.InvoiceNo; model.InvoiceDate = invoice.Date; model.LetterNo = confirmationLetter.LetterNo; model.PaymentDueDate = invoice.PaymentDueDate; model.TrainingDatesString = String.Empty; foreach (var date in confirmationLetter.ConfirmationLetterSchedules.Select(d => d.Date)) { model.TrainingDatesString += @"<li>" + date.ToLongDateString() + "</li>"; } model.TrainingDatesString = @"<ol>" + model.TrainingDatesString + @"</ol>"; model.AccountManagerName = confirmationLetter.Employee.Name; model.CustomerName = customer.Name; model.InvoiceDate = invoice.Date; model.Price = invoice.Price; model.Discount = invoice.Discount; model.Tax = invoice.Tax; model.PPH = invoice.PPH; model.TotalPrice = invoice.TotalPrice; model.Terbilang = NumericHelper.Terbilang(model.TotalPrice); var configuration = ctx.Configurations.SingleOrDefault(config => config.Key == "InvoicingSignName"); if (configuration != null) { model.SignName = configuration.Value; } configuration = ctx.Configurations.SingleOrDefault(config => config.Key == "InvoicingSignOccupation"); if (configuration != null) { model.SignOccupation = configuration.Value; } configuration = ctx.Configurations.SingleOrDefault(config => config.Key == "CompanyName"); if (configuration != null) { model.CompanyName = configuration.Value; } if (confirmationLetter.Bank != null) { model.BankName = confirmationLetter.Bank.Name; model.BankAccountNo = confirmationLetter.Bank.AccountNumber; model.BankAccountName = confirmationLetter.Bank.AccountName; } } } yield return(model); }