public override void ViewDidLoad() { base.ViewDidLoad(); newSplit = new SplitItem(); CellHelper.CircleTheView(GrovealeImage, UIColor.White, 2); totalAmount = TotalAmount; splitBetween = SplitNumber; tipSwitch = TipSwitch; tipPercentage = TipPercentage; percentageLabel = PercentageLabel; splitButton = CalculateSplit; splitTotal = TotalSplitAmount; saveButton = SaveSplit; totalAmount.KeyboardType = UIKeyboardType.DecimalPad; splitBetween.KeyboardType = UIKeyboardType.DecimalPad; tipPercentage.KeyboardType = UIKeyboardType.DecimalPad; tipSwitch.ValueChanged += TipSwitch_ValueChanged; splitButton.TouchUpInside += SplitButton_TouchUpInside; saveButton.TouchUpInside += SaveButton_TouchUpInside; }
void HandleSplitItem(SplitItem splitItem) { if (splitItem.Inv.Items.Count != 0) { Log.outError(LogFilter.Network, "WORLD: HandleSplitItemOpcode - Invalid itemCount ({0})", splitItem.Inv.Items.Count); return; } ushort src = (ushort)((splitItem.FromPackSlot << 8) | splitItem.FromSlot); ushort dst = (ushort)((splitItem.ToPackSlot << 8) | splitItem.ToSlot); if (src == dst) { return; } if (splitItem.Quantity == 0) { return; //check count - if zero it's fake packet } if (!_player.IsValidPos(splitItem.FromPackSlot, splitItem.FromSlot, true)) { _player.SendEquipError(InventoryResult.ItemNotFound); return; } if (!_player.IsValidPos(splitItem.ToPackSlot, splitItem.ToSlot, false)) // can be autostore pos { _player.SendEquipError(InventoryResult.WrongSlot); return; } _player.SplitItem(src, dst, (uint)splitItem.Quantity); }
public static List <SplitItem> GenerateTempSplits(int number = 10) { List <SplitItem> splits = new List <SplitItem>(); for (int i = 0; i < number; i++) { Random rnd = new Random(i); int month = rnd.Next(1, 13); // month: >= 1 and < 13 int day = rnd.Next(1, 29); // day: >= 1 and < 29 (real date) int hour = rnd.Next(24); // hour: >= 0 and < 24 (real date) int min = rnd.Next(60); // min: >= 0 and < 60 (real date) int splitNumer = rnd.Next(1, 10); // number: >= 1 and < 9 (who has 9 friends) double amount = (rnd.NextDouble() * (100 - 10) + 10); // double: between 10 and 1000 SplitItem randomSplit = new SplitItem { Amount = amount, SplitType = (int)SplitHelper.SplitType.Personal, SplitBetween = splitNumer, Time = new DateTime(2017, month, day, hour, min, 0), Name = string.Format("Split {0}", i), Location = "Location - Coming Soon!" }; splits.Add(randomSplit); } return(splits); }
/// <summary> /// Occurs each time split gets completed. Allows for UI update by marshalling the call accordingly. /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void SplitGoalCompletedEventHandler(object sender, SplitsManager.SplitGoalCompletedEventArgs e) { if (!m_dispatcher.CheckAccess()) // are we currently on the UI thread? { // We're not in the UI thread, ask the dispatcher to call this same method in the UI thread, then exit m_dispatcher.BeginInvoke(new SplitGoalCompletedEventHandlerDelegate(SplitGoalCompletedEventHandler), new object[] { sender, e }); return; } SplitItem splitItem = new SplitItem(e.SplitNumber) { SplitNumber = e.SplitNumberStr, Time = e.SplitTimeStr, Speed = e.SplitSpeedStr, TotalDistance = e.TotalDistanceStr, TotalTime = e.TotalTimeStr, Delta = e.DeltaTimeStr, SplitsInKm = e.SplitsInKm }; if (lvSplits.Items.ContainsKey(splitItem.SplitNumber)) { SplitListViewItem item = (SplitListViewItem)lvSplits.Items[splitItem.SplitNumber]; item.SplitItem = splitItem; // Replace with current splitItem object and refresh item.Refresh(); } else { // This should not happen lvSplits.Items.Add(new SplitListViewItem(splitItem)); lvSplits.Sort(); } Logger.LogInformation($"SplitGoalCompletedEventHandler {splitItem.SplitNumber}, {splitItem.Time}, {splitItem.Speed}, {splitItem.TotalDistance}, {splitItem.TotalTime}"); }
static void Main_TestSplitItem() { DataSet ds; string Msg = string.Empty; String ConStrCustom; String ConstrStd; Cls_Connection t = new Cls_Connection(); ConStrCustom = t.GetConnectionString_Custom(); ConstrStd = t.GetConnectionString_Std(); clsDTSplitItem dtInput = new clsDTSplitItem(); dtInput.OrderItemId = 1000000245; dtInput.ItemNo = 10; dtInput.RequestReamQty = 40; // dtInput.RequestDate = DateTime.Parse("2019/9/7"); dtInput.AddRow(); dtInput.OrderItemId = -1; dtInput.ItemNo = 0; dtInput.RequestReamQty = 40; dtInput.RequestDate = DateTime.Parse("2019/9/7"); dtInput.AddRow(); SplitItem sp = new SplitItem(ConStrCustom, ConstrStd); ds = sp.Request(dtInput, 0, ref Msg); if (Msg.Length > 0) { Console.WriteLine($@"{Msg}"); } }
public void UpdateCell(SplitItem split) { AmountLabel.Text = string.Format("£{0:N}", split.Amount); NameLabel.Text = split.Name; LocationLabel.Text = split.Location; PersonImage.Image = SplitHelper.GenerateImage(PersonImage.Frame.Width, PersonImage.Frame.Height); }
private static string[] SubItemStrings(SplitItem item) { return(new string[] { item.Distance, item.Time, item.TotalDistance, item.TotalTime }); }
private static string[] SubItemStrings(SplitItem item) { return(new string[] { "", $"{item.Distance:#.0} {(item.SplitsInKm ? "km" : "mi")}", item.Time.Hours.ToString("0#") + ":" + item.Time.Minutes.ToString("0#") + ":" + item.Time.Seconds.ToString("0#"), $"{item.TotalDistance:#.0} {(item.SplitsInKm ? "km" : "mi")}", item.TotalTime.Hours.ToString("0#") + ":" + item.TotalTime.Minutes.ToString("0#") + ":" + item.TotalTime.Seconds.ToString("0#") }); }
static void Main_TestSplitConfirm() { string Msg = string.Empty; SplitItem sp = new SplitItem(); sp.Confirm(99, ref Msg); if (Msg.Length > 0) { Console.WriteLine($@"{Msg}"); } }
private static string[] SubItemStrings(SplitItem item) { return(new string[] { "", // dummy first column item.SplitNumber, item.Time, item.Speed, item.TotalDistance, item.TotalTime, item.Delta }); }
public void UpdateCell(SplitItem split) { //TextLabel.Text = string.Format("£{0:N}", split.Amount); if (Amount != null) { Amount.Text = string.Format("£{0:N}", (split.Amount * split.SplitBetween)); } TextLabel.Text = split.Name; DetailTextLabel.Text = string.Format("Your share: £{0:N}", split.Amount); ImageView.Image = SplitHelper.GenerateImage(32, 32); }
private void UpdateLabels(SplitItem theSplit) { totalAmount.Text = string.Format("£{0:N}", theSplit.Amount * theSplit.SplitBetween); splitNumber.Text = theSplit.SplitBetween.ToString(); splitShare.Text = string.Format("£{0:N}", theSplit.Amount); location.Text = theSplit.Location; time.Text = theSplit.Time.ToString("HH:mm"); date.Text = theSplit.Time.ToString("ddd, DD MMM"); }
public void throws_when_merger_returns_nothing() { // Arrange var m1 = MeetingHelper.CreateMeeting(0, 0); var m2 = MeetingHelper.CreateMeeting(1, 1); var meetings = new[] { m1, m2 }; var emptyMerge = new SplitItem <Meeting>[] { }; A.CallTo(() => _splitter.Split(m1, m2)).Returns(emptyMerge); Assert.That(() => sut.Merge(meetings).ToArray(), Throws.Exception.Message.EqualTo("The merger must not provided an empty result")); }
/// <summary> /// Occurs each time a split gets updated or completes. Allows for UI update by marshalling the call accordingly. /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void SplitEventHandler(object sender, SplitsManagerV2.SplitEventArgs e) { if (!m_dispatcher.CheckAccess()) // are we currently on the UI thread? { // We're not in the UI thread, ask the dispatcher to call this same method in the UI thread, then exit m_dispatcher.BeginInvoke(new SplitEventHandlerDelegate(SplitEventHandler), new object[] { sender, e }); return; } SplitItem splitItem = new SplitItem(e.SplitNumber, e.SplitTimeStr, e.SplitSpeedStr, e.TotalDistanceStr, e.TotalTimeStr, e.DeltaTimeStr, e.SplitsInKm, e.AheadOfGoalTime); //SplitItem splitItem = new SplitItem(e.SplitNumber) //{ // SplitNumber = e.SplitNumberStr, // Time = e.SplitTimeStr, // Speed = e.SplitSpeedStr, // TotalDistance = e.TotalDistanceStr, // TotalTime = e.TotalTimeStr, // Delta = e.DeltaTimeStr, // will return empty string if not a goal based split // SplitsInKm = e.SplitsInKm, // AheadOfGoalTime = e.AheadOfGoalTime // null if not a goal based split //}; if (lvSplits.Items.ContainsKey(splitItem.SplitNumber)) { SplitListViewItem item = (SplitListViewItem)lvSplits.Items[splitItem.SplitNumber]; item.SplitItem = splitItem; // Replace with current splitItem object and refresh item.Refresh(); } else { if (e.SplitNumber > 1) { // remove any color coding from previous split string prevSplit = (e.SplitNumber - 1).ToString(); if (lvSplits.Items.ContainsKey(prevSplit)) { SplitListViewItem item = (SplitListViewItem)lvSplits.Items[prevSplit]; item.ClearDeltaBackground(); } } lvSplits.Items.Add(new SplitListViewItem(splitItem)); lvSplits.Sort(); } //Logger.LogInformation($"SplitEventHandler {splitItem.SplitNumber}, {splitItem.Time}, {splitItem.Speed}, {splitItem.TotalDistance}, {splitItem.TotalTime}"); }
static void SplitSceneStrings() { sceneStrings.Clear(); SplitItem item; foreach (FileInfo file in sceneFiles) { item = new SplitItem(); item.full = file.FullName.Replace(Application.dataPath, ""); item.bits = ExplodeIntoWords(item.full).ToArray(); sceneStrings.Add(item); } }
void Start() { InventoryManager = GameObject.FindWithTag("InventoryManager").GetComponent<InventoryManager>(); Inventory = InventoryManager.Inventory; Equipment = InventoryManager.Equipment; //Crafting = InventoryManager.Crafting; SplitPanel = InventoryManager.SplitPanel; }
public ActionResult SubmitLootSplit(LootViewModel model, string lootSplitName) { var resultMessage = ResultMessages.JsonResultMessage(); resultMessage.Message = "Successfully Submitted Loot Split."; resultMessage.Success = true; //save if (model.SelectedLootSplitId == 0) { try { var failures = 0; var successes = 0; var result = resultMessage; LootSplit lootSplit = new LootSplit(); lootSplit.Name = model.Name; List <SplitItem> splitItems = new List <SplitItem>(); foreach (LootItem lootitem in model.LootItems) { if (lootitem.Quantity > 0) { SplitItem splitItem = new SplitItem(); splitItem.LootSplitId = lootSplit.LootSplitId; splitItem.LootItemId = lootitem.LootItemId; splitItem.LootItemQuantity = lootitem.Quantity; splitItems.Add(splitItem); } } lootSplit.SplitItems = splitItems; lootSplit = _lootManager.InsertLootSplit(lootSplit); //_lootManager.InsertSplitItems(splitItems, lootSplit.Id); if (failures > 0) { resultMessage.Success = false; resultMessage.Message = "Insert Failed "; return(Json(resultMessage)); } resultMessage.Success = true; resultMessage.Message = "Inserted {0} Loot Splits(s).".FormatWith(successes); } catch (Exception ex) { resultMessage.Success = false; resultMessage.Message = "Error Inserting Loot Split. " + ex.Message; } } //load else { model.LootSplitSelectList = new SelectList(_lootManager.GetLootSplitDropdownValues(), "LootSplitId", "Name"); model.LootItems = _lootManager.GetAllLootItems().ToList(); IEnumerable <SplitItem> splitItems = _lootManager.GetSplitItems(model.SelectedLootSplitId); foreach (LootItem lootItem in model.LootItems) { foreach (SplitItem splitItem in splitItems) { if (splitItem.LootItemId == lootItem.LootItemId) { lootItem.Quantity = splitItem.LootItemQuantity; } } } foreach (SelectListItem item in model.LootSplitSelectList) { if (item.Value == model.SelectedLootSplitId.ToString()) { item.Selected = true; } } } return(View("Index", model)); }
public SplitListViewItem(SplitItem item) : base(SubItemStrings(item)) { this.SplitItem = item; }
private void LoadSplitChart() { lvSplits.Items.Clear(); lblGoalSpeed.Text = ""; SplitsManager.SplitGoals splitGoals = SplitsManager.GetSplitGoals(); if (splitGoals == null) { return; } foreach (SplitsManager.SplitGoal goal in splitGoals.Goals) { SplitItem item = new SplitItem() { Distance = goal.SplitDistanceStr, Time = goal.SplitTimeStr, TotalDistance = goal.TotalDistanceStr, TotalTime = goal.TotalTimeStr }; lvSplits.Items.Add(new SplitListViewItem(item)); } lblGoalSpeed.Text = splitGoals.GoalSpeedStr; /* * if (!ckbShowSplits.Checked || !ckbCalculateGoal.Checked) * return; * * Splits splits = ZAMsettings.Settings.Splits; * * double numSplits = splits.GoalDistance / splits.SplitDistance; * if (numSplits < 1) * return; * * TimeSpan goalTime = new TimeSpan(splits.GoalHours, splits.GoalMinutes, splits.GoalSeconds); * if (goalTime.TotalSeconds < 1) * return; * * TimeSpan splitTime = new TimeSpan(0, 0, (int)Math.Round(goalTime.TotalSeconds / numSplits, 0)); * string splitTimeStr = splitTime.Hours.ToString("0#") + ":" + splitTime.Minutes.ToString("0#") + ":" + splitTime.Seconds.ToString("0#"); * * int curDistance = 0; * TimeSpan curTime = new TimeSpan(); * * for (int i=0; i<(int)numSplits; i++) * { * if (lvSplits.Items.Count >= 100) * break; * * int totalDistance = curDistance + splits.SplitDistance; * TimeSpan totalTime = curTime.Add(splitTime); * * SplitItem item = new SplitItem() * { * Distance = $"{splits.SplitDistance} {splits.SplitUom}", * Time = splitTimeStr, * TotalDistance = $"{totalDistance} {splits.SplitUom}", * TotalTime = $"{totalTime.Hours.ToString("0#") + ":" + totalTime.Minutes.ToString("0#") + ":" + totalTime.Seconds.ToString("0#")}" * }; * lvSplits.Items.Add(new SplitListViewItem(item)); * * curDistance = totalDistance; * curTime = totalTime; * } * * if (numSplits != (int)numSplits) * { * double lastSplitDistance = Math.Round(splits.GoalDistance - curDistance, 1); * TimeSpan lastSplitTime = goalTime.Subtract(curTime); * * SplitItem item = new SplitItem() * { * Distance = $"{lastSplitDistance} {splits.SplitUom}", * Time = $"{lastSplitTime.Hours.ToString("0#") + ":" + lastSplitTime.Minutes.ToString("0#") + ":" + lastSplitTime.Seconds.ToString("0#")}", * TotalDistance = $"{Math.Round(splits.GoalDistance, 1)} {splits.SplitUom}", * TotalTime = $"{goalTime.Hours.ToString("0#") + ":" + goalTime.Minutes.ToString("0#") + ":" + goalTime.Seconds.ToString("0#")}" * }; * lvSplits.Items.Add(new SplitListViewItem(item)); * } * * double goalSpeed = Math.Round((splits.GoalDistance / goalTime.TotalSeconds) * 3600, 1); * lblGoalSpeed.Text = $"{goalSpeed.ToString("#.#")} {(splits.SplitUom == "km" ? "km/h" : "mph")}"; */ }
public SplitListViewItem(SplitItem item) : base(SubItemStrings(item)) { this.SplitItem = item; this.Name = item.SplitNumber; // this is the Key in the listview.items collection }