private void ParseInformation(UserInformation currentUser) { string icon = null; try { icon = currentUser.Icon; if (string.IsNullOrEmpty(icon) || icon == "default.jpg" || icon == "default") { icon = "http://qc.cdorey.net/default.jpg"; } Icon = new BitmapImage(new Uri(icon)); } catch (UriFormatException ex) { //检查导致解析头像崩溃的原因 ex.ToExceptionless().AddObject(icon).AddObject(currentUser).Submit(); } try { AvailableRate = currentUser.SpaceUsed * 100 / currentUser.SpaceCapacity; } catch (Exception) { AvailableRate = 100; } FrendlySpaceCapacity = $"总计:{Calculators.SizeCalculator(currentUser.SpaceCapacity)}{Environment.NewLine}已用:{Calculators.SizeCalculator(currentUser.SpaceUsed)}"; Name = currentUser.Name; OnPropertyChanged(nameof(Icon)); OnPropertyChanged(nameof(AvailableRate)); OnPropertyChanged(nameof(FrendlySpaceCapacity)); OnPropertyChanged(nameof(Name)); }
public FileListItemViewModel(FileListViewModel parent, FileMetaData fileMetaData) { Parent = parent; Name = fileMetaData.Name; MTime = Calculators.UnixTimeStampConverter(fileMetaData.Mtime); ATime = Calculators.UnixTimeStampConverter(fileMetaData.Atime); CTime = Calculators.UnixTimeStampConverter(fileMetaData.Ctime); Locking = fileMetaData.Locking; Preview = fileMetaData.Preview; Directory = fileMetaData.Directory; Size = Calculators.SizeCalculator(fileMetaData.Size); UUID = fileMetaData.UUID; Mime = fileMetaData.Mime; Path = fileMetaData.Path; PreviewType = fileMetaData.PreviewType; CopyCommand = new DependencyCommand(Copy, AlwaysCan); CutCommand = new DependencyCommand(Cut, AlwaysCan); DeleteCommand = new AsyncCommand(Delete, AlwaysCan); RenameCommand = new DependencyCommand(Rename, AlwaysCan); ConfirmCommand = new AsyncCommand(Confirm, CanConfirm); DownloadCommand = new DependencyCommand(Download, CanDownload); MoreCommand = new DependencyCommand(More, AlwaysCan); if (Directory) { Icon = IconDictionary["folder"]; } else { string eName = System.IO.Path.GetExtension(Name); Icon = IconDictionary.ContainsKey(eName) ? IconDictionary[eName] : IconDictionary["default"]; } }
private double GetHeightInCm(int field) { var userProfileId = Helper_Classes.UserHelpers.GetUserProfile().Id; var heightInCm = _context.UserProfiles .SingleOrDefault(m => m.Id == userProfileId) .HeightInCm ; var heightUnit = Helper_Classes.UserHelpers.GetHeightUnit(); double val = 0; if (heightUnit == HeightUnits.Cm && field == 1) { val = heightInCm; } else if (heightUnit == HeightUnits.Feetandinches) { if (field == 1) { val = Calculators.CmToFt(heightInCm); } else if (field == 2) { val = Calculators.CmToInches(heightInCm); } } return(val); }
private void GetResults(object sender, GetFinishedOrdersForRemoteCalculationCompletedEventArgs e) { _client.GetFinishedOrdersForRemoteCalculationCompleted -= GetResults; foreach (var res in e.Result) { if (res.Parameters != null) { Results.Add(new ResultDescription() { Id = res.Id, DateFrom = res.DateFrom.ToShortDateString(), DateTo = res.DateTo.ToShortDateString(), InstrumentName = res.InstrumentName, Period = PeriodsList[res.Period], StrategyName = Calculators.Single(o => o.Id == _selectedCalcId).StrategyName, Parameters = string.Join("-", res.Parameters), StopLoss = res.StopLoss, Balance = res.TotalBalance, Gap = res.Gap, SelectCoeff = res.TotalBalance * res.TotalBalance / res.Gap }); } } Results = new ObservableCollection <ResultDescription>(Results.OrderByDescending(o => o.SelectCoeff)); SelectedContent = new Results(); }
private UserAnalysisModel Analyze(IList <UserModel> users) { UserAnalysisModel model = new UserAnalysisModel(); var femalePercentage = Calculators.PercentageFemale(users); var malePercentage = 1 - femalePercentage; model.Gender = (femalePercentage, malePercentage); var firstNameLeftPercentage = Calculators.PercentageFirstNameMidpoint(users); var firstNameRightPercentage = 1 - firstNameLeftPercentage; model.FirstName = (firstNameLeftPercentage, firstNameRightPercentage); var lastNameLeftPercentage = Calculators.PercentageLastNameMidpoint(users); var lastNameRightPercentage = 1 - lastNameLeftPercentage; model.LastName = (lastNameLeftPercentage, lastNameRightPercentage); model.StatePercentages = Calculators.PercentagePeopleInState(users); model.FemaleStatePercentages = Calculators.PercentageFemalesInState(users); model.MaleStatePercentages = Calculators.PercentageMalesInState(users); model.AgeRangePercentages = Calculators.PercentageAgeRanges(users); model.StateAverageAge = Calculators.StateAverageAge(users); return(model); }
/// <summary> /// Assigns the Token's creation time based on information received the Crestron processor /// </summary> /// <param name="creationDateString">The formatted string value received from the processor</param> public void SetCreation(string creationDateString) { DateTime dateVal; dateVal = GetDateFromString(creationDateString); created_at = Calculators.GetUtcDateFromDateTime(dateVal); }
public ActionResult NewCheckInForm(string pageFrom) { //Used when creating a new check in //If no log found for that date, fetch blank log page. If existing log found, fetch existing info into page CheckInFormViewModel viewModel; var userProfileId = Helper_Classes.UserHelpers.GetUserProfile().Id; string weightInputA = ""; string weightInputB = ""; var weightUnit = Helper_Classes.UserHelpers.GetWeightUnit(); double weight = 0.0; if (_context.UserProgressLogs.SingleOrDefault(g => g.UserProfileId == userProfileId && g.Date == DateTime.Today) == null) { viewModel = new CheckInFormViewModel { UserProgressLog = new UserProgressLog() } } ; else { viewModel = new CheckInFormViewModel { UserProgressLog = _context.UserProgressLogs.SingleOrDefault(g => g.UserProfileId == userProfileId && g.Date == DateTime.Today), }; weight = (double)viewModel.UserProgressLog.WeightInKg; } viewModel.BodyFat = viewModel.UserProgressLog.BodyFat; if (weightUnit.Equals(WeightUnits.Kg)) { weightInputA = Convert.ToInt32(weight).ToString(); } else if (weightUnit.Equals(WeightUnits.Lbs)) { weightInputA = Convert.ToInt32(Calculators.KgsToLbs(weight)).ToString(); } else if (weightUnit.Equals(WeightUnits.LbsAndStone)) { weightInputA = Convert.ToInt32(Calculators.KgsToStone(weight)).ToString(); weightInputB = Convert.ToInt32(Calculators.KgsToLbsRemainingFromStone(weight)).ToString(); } viewModel.WeightInputA = weightInputA; viewModel.WeightInputB = weightInputB; viewModel.WeightUnit = weightUnit; viewModel.RedirectionPage = pageFrom; viewModel.IsBodyFatCalculation = Helper_Classes.UserHelpers.GetCurrentGoal().CalculationBasis == CalculationBasis.BodyFat ? true : false; return(View(viewModel)); }
public object Convert(object value, Type targetType, object parameter, CultureInfo culture) { if (value is long size) { return(Calculators.SizeCalculator(size)); } return("未知"); }
public object Convert(object value, Type targetType, object parameter, CultureInfo culture) { if (value is long time) { return(Calculators.UnixTimeStampConverter(time)); } return("未知"); }
public void Test2() { Calculators calculator = new Calculators(); decimal calculatedMinute = calculator.GetMinuteWithHour(3); Assert.Equal(180, calculatedMinute); }
protected override void InitializeCalculators() { Calculators.Add(new fsDensityConcentrationCalculator()); Calculators.Add(new fsPorosityCalculator()); Calculators.Add(new fsPermeabilityCalculator()); Calculators.Add(new fsRm0Hce0Calculator()); AddCakeFormationCalculator(); }
static void Main(string[] args) { var calculator = new Calculators(); calculator.Calculate(); Console.ReadLine(); }
private Thermo1CalculatorMgr() { Calculators.Add(new A117VcCalculator().Create()); Calculators.Add(new A117FullModuleCalculator().Create()); Calculators.Add(new A147VcCalculator().Create()); Calculators.Add(new A147FullModuleCalculator().Create()); Calculators.Add(new X1311Calculator().Create()); }
public StatCalc(Calculators calculator) { InitializeComponent(); host = new ElementHost(); host.Dock = DockStyle.Fill; switch (calculator) { case Calculators.TwoByTwo: control = new EpiDashboard.StatCalc.TwoByTwo(); break; case Calculators.PopulationSurvey: control = new EpiDashboard.StatCalc.PopulationSurvey(); break; case Calculators.Poisson: control = new EpiDashboard.StatCalc.Poisson(); break; case Calculators.Binomial: control = new EpiDashboard.StatCalc.Binomial(); break; case Calculators.UnmatchedCaseControl: control = new EpiDashboard.StatCalc.UnmatchedCaseControl(); break; case Calculators.Cohort: control = new EpiDashboard.StatCalc.Cohort(); break; case Calculators.ChiSquareForTrend: control = new EpiDashboard.StatCalc.ChiSquareControl(); //((EpiDashboard.StatCalc.ChiSquareControl)control).SizeChanged += new System.Windows.SizeChangedEventHandler(StatCalc_SizeChanged); break; case Calculators.MatchedPairCaseControl: control = new EpiDashboard.Gadgets.StatCalc.MatchedPairCaseControlGadget(); (control as EpiDashboard.Gadgets.StatCalc.MatchedPairCaseControlGadget).IsHostedInOwnWindow = true; break; default: break; } if (control != null) { if (control is EpiDashboard.StatCalc.IStatCalcControl) { host.Child = control; this.Controls.Add(host); this.Width = ((EpiDashboard.StatCalc.IStatCalcControl)control).PreferredUIWidth; this.Height = ((EpiDashboard.StatCalc.IStatCalcControl)control).PreferredUIHeight + 10; ((EpiDashboard.StatCalc.IStatCalcControl)control).HideCloseIcon(); } else if (control is EpiDashboard.Gadgets.IStatCalcControl) { host.Child = control; this.Controls.Add(host); this.Width = ((EpiDashboard.Gadgets.IStatCalcControl)control).PreferredUIWidth; this.Height = ((EpiDashboard.Gadgets.IStatCalcControl)control).PreferredUIHeight + 10; } } }
/// <summary> /// Assigns the expiration time/date based o information received from the Crestron processor /// </summary> /// <param name="expirationDateString">The formatted string value received </param> public void SetExpiration(string expirationDateString) { DateTime dateVal; double totalVal; double expiresInVal; dateVal = GetDateFromString(expirationDateString); // Get the DateTime value from the received string totalVal = Calculators.GetUtcDateFromDateTime(dateVal); // Get the UNIX converted value from the date expiresInVal = totalVal - created_at; // Subtract the created date from the expires date }
private void CalculateCPM() { int index = ActivityComboBox.SelectedIndex; double activity = activityTab[index]; ushort cPM = Calculators.CPMCalculator((ushort)HeightNumericUpDown.Value, (double)WeightNumericUpDown.Value, (byte)AgeNumericUpDown.Value, SexComboBox.Text, activity, ReductionCheckBox.Checked); CPMValueLabel.Text = cPM.ToString("F0"); }
public void Test1() { //Hazırlama Aşaması Calculators calculator = new Calculators(); //Hareket Aşaması - Act decimal calculatedHour = calculator.GetHourWithMinute(60); //İddia Etme Aşaması - Assert Assert.Equal(1, calculatedHour); }
public void DeleteSelectedCalc() { if (SelectedCalc != null) { _client.RemoveRemoteCalculationAsync(SelectedCalc.Id); Calculators.Remove(SelectedCalc); } else { MessageBox.Show("Выберите расчет для удаления!"); } }
public void TestProvidedExamples() { double tolerance = 0.0000001; Assert.AreEqual(Calculators.CalcPrice(0.10, 5, 1000, 0.15), 832.3922451, tolerance); Assert.AreEqual(Calculators.CalcYield(0.10, 5, 1000, 832.4), 0.149997376, tolerance); Assert.AreEqual(Calculators.CalcPrice(0.15, 5, 1000, 0.15), 1000.0000000, tolerance); Assert.AreEqual(Calculators.CalcPrice(0.10, 5, 1000, 1000), 0.100000000, tolerance); Assert.AreEqual(Calculators.CalcPrice(0.10, 5, 1000, 0.08), 1079.8542007, tolerance); Assert.AreEqual(Calculators.CalcYield(0.10, 5, 1000, 1079.85), 0.080000999, tolerance); Assert.AreEqual(Calculators.CalcPrice(0.10, 30, 1000, 0.19), 528.8807463, tolerance); Assert.AreEqual(Calculators.CalcYield(0.10, 30, 1000, 528.8807463), 0.190000000, tolerance); }
private void UpdateDbWithNewCheckIn(CheckInFormViewModel formUserProgressLog) { currentUserProfile = Helper_Classes.UserHelpers.GetUserProfile(); var userProfileId = currentUserProfile.Id; double startWeight = 0.0; double targetWeight = 0.0; if (Helper_Classes.UserHelpers.GetWeightUnit().Equals(WeightUnits.Kg)) { startWeight = Convert.ToDouble(formUserProgressLog.WeightInputA); } else if (Helper_Classes.UserHelpers.GetWeightUnit().Equals(WeightUnits.Lbs)) { startWeight = Calculators.LbsToKG(Convert.ToDouble(formUserProgressLog.WeightInputA)); } else if (Helper_Classes.UserHelpers.GetWeightUnit().Equals(WeightUnits.LbsAndStone)) { startWeight = Calculators.StToKg(Convert.ToDouble(formUserProgressLog.WeightInputA)) + Calculators.LbsToKG(Convert.ToDouble(formUserProgressLog.WeightInputB)); } formUserProgressLog.UserProgressLog.WeightInKg = Convert.ToDouble(startWeight); //Check for log on the same date, if it doesn't exist, insert, else update if (_context.UserProgressLogs.SingleOrDefault(g => g.UserProfileId == userProfileId && g.Date == formUserProgressLog.UserProgressLog.Date) == null) { //Insert formUserProgressLog.UserProgressLog.UserProfileId = userProfileId; _context.UserProgressLogs.Add(formUserProgressLog.UserProgressLog); } else { var photoManager = new PhotoManager(); var progressLogId = _context.UserProgressLogs.SingleOrDefault(g => g.UserProfileId == userProfileId && g.Date == formUserProgressLog.UserProgressLog.Date).Id; formUserProgressLog.UserProgressLog.Id = progressLogId; formUserProgressLog.UserProgressLog.UserProfileId = userProfileId; _context.Entry(_context.UserProgressLogs. SingleOrDefault(g => g.UserProfileId == userProfileId && g.Date == formUserProgressLog.UserProgressLog.Date)) .CurrentValues .SetValues(formUserProgressLog.UserProgressLog); } _context.SaveChanges(); //Update }
public bool willMoveHit(PokemonData attackingPokemon, PokemonData defendingPokemon, Move move) { float accuracyBase = move.accuracy; float accuracy = Calculators.evasionAccuracyFlatToPercentage(attackingPokemon.accuracyStatisticsChange); float evasion = Calculators.evasionAccuracyFlatToPercentage(defendingPokemon.evasionStatisticsChange); float calculatedAccuracy = (accuracyBase * (accuracy / evasion)); if (calculatedAccuracy >= Random.Range(1, 100)) { return(true); } return(false); }
// GET: Profile public ActionResult Index() { var userProfile = Helper_Classes.UserHelpers.GetUserProfile(); if (userProfile == null) { return(RedirectToAction("Edit")); } var userId = userProfile.Id; string heightToDisplay = ""; string heightUnit = _context.UserProfiles.Where(m => m.Id == userId).Select(m => m.HeightUnit.Name).SingleOrDefault(); double heightInCm = _context.UserProfiles.Where(m => m.Id == userId).Select(m => m.HeightInCm) .SingleOrDefault(); if (heightUnit == HeightUnits.Cm) { heightToDisplay = heightInCm.ToString() + "cm"; } else if (heightUnit == HeightUnits.Feetandinches) { heightToDisplay = Calculators.CmToFt(heightInCm).ToString() + "ft" + Calculators.CmToInches(heightInCm).ToString() + "in"; } ProfileViewModel viewModel = new ProfileViewModel { HeightToDisplay = heightToDisplay, UserProfile = _context.UserProfiles. Include(m => m.Sex). Include(m => m.HeightUnit). Include(m => m.WeightUnit). Include(m => m.ActivityLevel). ToList(). SingleOrDefault(m => m.Id == userId), }; if (_context.UserPhotos.SingleOrDefault(m => m.Id == userProfile.UserPhotoId)?.Photo != null) { viewModel.Photo = Convert.ToBase64String(_context.UserPhotos.SingleOrDefault(m => m.Id == userProfile.UserPhotoId)?.Photo); } return(View(viewModel)); }
private static string GetWeightString(double val) { switch (Helper_Classes.UserHelpers.GetWeightUnit()) { case WeightUnits.Kg: return(Math.Round(val, 1) + "kg"); case WeightUnits.Lbs: return(Convert.ToInt32(Calculators.KgsToLbs(val)) + "lbs"); case WeightUnits.LbsAndStone: return(Convert.ToInt32(Calculators.KgsToStone(val)) + "st" + Convert.ToInt32(Calculators.KgsToLbsRemainingFromStone(val)) + "lb"); } return("Weight Unit Not Found"); }
public void TestDivideException(int a, int b, int expected) { string thrown = ""; try { var result = Calculators.Divide(a, b); } catch (Exception e) { thrown = e.Message; } Assert.AreEqual("cannot divide by 0", thrown); //Assert.Throws<DivideByZeroException>(() => Calculators.Divide(a, b)); //don't think it works }
public int calculateDamage(PokemonData attacking, PokemonData defending, Move move) { int attack = attacking.getAttackStat(); int defense = defending.getDefenseStat(); attack = Mathf.RoundToInt(attack * Calculators.statusModifierFlatToPerccentage(attacking.attackStatisticsChange)); defense = Mathf.RoundToInt(defense * Calculators.statusModifierFlatToPerccentage(defending.defenseStatisticsChange)); if (move.effect == Effect.Special) { attack = attacking.getSpecialStat(); defense = defending.getSpecialStat(); } return(Mathf.RoundToInt( (((((attacking.pokemonLevel * 2) / 5) + 2) * move.power * attack / defense) / 50) + 2)); }
private void BSqrt_Click(object sender, RoutedEventArgs e) { if (number1 > 0) { result = Calculators.Root(number1); Resultbox.Text = $"sqrt({number1}) = {result}"; //this way you are ready to add the second number FullText.Text = $"sqrt({number1}) = {result}"; printed = true; } else { operation = "sqrt(0)"; //this also ensures that the else statements run for the num buttons Resultbox.Text = "sqrt(0)"; //this way you are ready to add the second number FullText.Text = "sqrt(0)"; } }
//Used when 'editing' a check in from the tracker public ActionResult NewCheckInForm(int id) { //If no log found for that date, fetch blank log page. If existing log found, fetch existing info into page CheckInFormViewModel viewModel; var userProfileId = Helper_Classes.UserHelpers.GetUserProfile().Id; string weightInputA = ""; string weightInputB = ""; var weightUnit = Helper_Classes.UserHelpers.GetWeightUnit(); UserProgressLog userProgressLog = _context.UserProgressLogs.SingleOrDefault(m => m.Id == id); double weight = userProgressLog.WeightInKg.Value; if (weightUnit.Equals(WeightUnits.Kg)) { weightInputA = Convert.ToInt32(weight).ToString(); } else if (weightUnit.Equals(WeightUnits.Lbs)) { weightInputA = Convert.ToInt32(Calculators.KgsToLbs(weight)).ToString(); } else if (weightUnit.Equals(WeightUnits.LbsAndStone)) { weightInputA = Convert.ToInt32(Calculators.KgsToStone(weight)).ToString(); weightInputB = Convert.ToInt32(Calculators.KgsToLbsRemainingFromStone(weight)).ToString(); } viewModel = new CheckInFormViewModel { UserProgressLog = userProgressLog, WeightInputA = weightInputA, WeightInputB = weightInputB, WeightUnit = weightUnit, PageTitlePrefix = "Edit", RedirectionPage = "Tracker" }; viewModel.BodyFat = viewModel.UserProgressLog.BodyFat; viewModel.IsBodyFatCalculation = Helper_Classes.UserHelpers.GetCurrentGoal().CalculationBasis == CalculationBasis.BodyFat ? true : false; return(View("NewCheckInForm", viewModel)); }
private static void Clear() { if (ObjectManager.Player.ManaPercent < Helper.Slider("clear.mana")) { return; } var minion = MinionManager.GetMinions(ObjectManager.Player.Position, Spells.Q.Range, MinionTypes.All, MinionTeam.Enemy, MinionOrderTypes.MaxHealth); if (minion.Count == 0) { return; } if (Spells.Q.IsReady() && Helper.Enabled("q.clear")) { if (Spells.Q.CanCast(minion[0])) { if (minion[0].Health < Calculators.Q(minion[0]) && minion[1].Health < Calculators.Q(minion[1]) || minion[0].Health <Calculators.Q(minion[0]) && minion[1].Health> Calculators.Q(minion[1])) { Spells.Q.Cast(Spells.Q.GetPrediction(minion[0]).CastPosition); } if (minion[1].Health <Calculators.Q(minion[1]) && minion[0].Health> Calculators.Q(minion[0])) { Spells.Q.Cast(Spells.Q.GetPrediction(minion[1]).CastPosition); } } } if (Spells.E.IsReady() && Helper.Enabled("e.clear")) { if (Spells.E.CanCast(minion[0]) && Spells.E.GetCircularFarmLocation(minion).MinionsHit >= Helper.Slider("e.minion.hit.count")) { Spells.E.Cast(Spells.E.GetCircularFarmLocation(minion).Position); } if (Helper.LuxE != null && Helper.EInsCheck() == 2) { Spells.E.Cast(); } } }
static void Main(string[] args) { //var test = new SimpleCalculator<> //var test = Calculators.SimpleCalculator(5, 5, '+'); var test1 = Calculators.MainCalculator("2*(5+7)"); //Calculation operations = new Calculation(5,5, new SummFunctions().Execute); //Calculation operations1 = new Calculation(operations, 5, new SummFunctions().Execute); //Calculation operations2 = new Calculation(operations, operations1, new SummFunctions().Execute); //Calculation operations = new Calculation(5,5d, new SummFunctions().Execute); //Calculation operations1 = new Calculation(operations, 5d, new SummFunctions().Execute); //Calculation operations2 = new Calculation(operations, operations1, new SummFunctions().Execute); //double test = operations2.Execute(); Console.ReadKey(); }
protected override void AddCakeFormationCalculator() { Calculators.Add(new fsBeltFiltersWithReversibleTraysCalculator()); }
protected override void InitializeCalculators() { Calculators.Add(m_calculator); }
public override double Operate(Calculators.Extensibility.Operate operate) { return _contract.Operate(new OperateViewToContractHostAdapter(operate)); }
public CalculatorContractToViewHostAdapter(Calculators.Extensibility.Contracts.ICalculatorContract contract) { _contract = contract; _handle = new System.AddIn.Pipeline.ContractHandle(contract); }
public OperateContractToViewAddInAdapter(Calculators.Extensibility.Contracts.IOperateContract contract) { _contract = contract; _handle = new System.AddIn.Pipeline.ContractHandle(contract); }
public virtual double Operate(Calculators.Extensibility.Contracts.IOperateContract operate) { return _view.Operate(new OperateContractToViewAddInAdapter(operate)); }
public CalculatorViewToContractAddInAdapter(Calculators.Extensibility.Calculator view) { _view = view; }
public OperateViewToContractHostAdapter(Calculators.Extensibility.Operate view) { _view = view; }