public void SetWatch(Emu.MemoryDomain domain, IEnumerable <Watch> watches = null, Mode mode = Mode.New) { if (watches != null) { Watches.AddRange(watches); } _mode = mode; DomainDropDown.Items.Clear(); DomainDropDown.Items.AddRange(MemoryDomains .Select(d => d.ToString()) .Cast <object>() .ToArray()); DomainDropDown.SelectedItem = domain.ToString(); SetTitle(); }
public void AddTrackingItem(ProductMasterItem item) { if (!Watches.Contains(item)) { double currentInv = 0; var inv = StaticInventoryTracker.InventoryItems.FirstOrDefault(x => x.MasterID == item.MasterID); if (inv != null) { currentInv = inv.Units; } Watches.Add(item); foreach (var trackingDay in TrackingDays) { currentInv = trackingDay.AddTracking(item, currentInv); } } }
public SliceWatchView GetSliceWatch(string watch, int groupsInRow, int nGroups) { int laneDataOffset; if (watch == "System") { laneDataOffset = 0; } else { var watchIndex = Watches.IndexOf(watch); if (watchIndex == -1) { return(null); } laneDataOffset = watchIndex + 1; } return(new SliceWatchView(_data, groupsInRow, GroupSize, WaveSize, GetGroupCount(GroupSize, WaveSize, nGroups), laneDataOffset, _laneDataSize, watch)); }
public TimeViewModel(IEnumerable <TestStopwatch> times) { Watches = times.OrderBy(t => t.Ticks).ToArray(); var ts = Watches.Select(t => t.Ticks).ToList(); var count = ts.Count; foreach (var w in Watches) { w.Time = new TimeSpan(w.Ticks); } var ticks = count == 1 ? ts[0] : count == 2 ? (long)ts.Average(t => t) : count <= 5 ? (long)ts.Skip(1).Take(count - 2).Average(t => t) : count <= 10 ? (long)ts.Skip(2).Take(count - 4).Average(t => t) : (long)ts.Skip(count / 5).Take(count - count / 5 * 2).Average(t => t); Time = new TimeSpan(ticks); }
private void DoEdit() { if (Watches.Count == 1) { Watches[0].Notes = NotesBox.Text; } if (_changedSize) { for (var i = 0; i < Watches.Count; i++) { var size = SizeDropDown.SelectedIndex switch { 1 => WatchSize.Word, 2 => WatchSize.DWord, _ => WatchSize.Byte }; Watches[i] = Watch.GenerateWatch( Watches[i].Domain, Watches.Count == 1 ? AddressBox.ToRawInt() ?? 0 : Watches[i].Address, size, Watches[i].Type, Watches[i].BigEndian, Watches[i].Notes); } } if (_changedDisplayType) { Watches.ForEach(x => x.Type = Watch.StringToDisplayType(DisplayTypeDropDown.SelectedItem.ToString())); } if (BigEndianCheckBox.CheckState != CheckState.Indeterminate) { Watches.ForEach(x => x.BigEndian = BigEndianCheckBox.Checked); } }
public void Load() { try { using (FileStream stream = File.OpenRead(saveFile)) { BinaryFormatter formatter = new BinaryFormatter(); Watches.Clear(); int watchCount = (int)formatter.Deserialize(stream); for (; watchCount > 0; watchCount--) { ProductMasterItem watch = (ProductMasterItem)formatter.Deserialize(stream); Watches.Add(watch); } } } catch (Exception e) { Console.WriteLine(e.Message); } }
public Watches Update(Watches watchesUpdate) { _ctx.Attach(watchesUpdate).State = EntityState.Modified; _ctx.SaveChanges(); return(watchesUpdate); }
public Watches CreateWatch(Watches watches) { _ctx.Attach(watches).State = EntityState.Added; _ctx.SaveChanges(); return(watches); }
private void RamWatchNewWatch_Load(object sender, EventArgs e) { if (InitialLocation.X > 0 || InitialLocation.Y > 0) { Location = InitialLocation; } _loading = false; SetAddressBoxProperties(); switch (_mode) { default: case Mode.New: SizeDropDown.SelectedItem = MemoryDomains.First().WordSize switch { 1 => SizeDropDown.Items[0], 2 => SizeDropDown.Items[1], 4 => SizeDropDown.Items[2], _ => SizeDropDown.Items[0] }; break; case Mode.Duplicate: case Mode.Edit: SizeDropDown.SelectedItem = Watches[0].Size switch { WatchSize.Byte => SizeDropDown.Items[0], WatchSize.Word => SizeDropDown.Items[1], WatchSize.DWord => SizeDropDown.Items[2], _ => SizeDropDown.SelectedItem }; var index = DisplayTypeDropDown.Items.IndexOf(Watch.DisplayTypeToString(Watches[0].Type)); DisplayTypeDropDown.SelectedItem = DisplayTypeDropDown.Items[index]; if (Watches.Count > 1) { NotesBox.Enabled = false; NotesBox.Text = ""; AddressBox.Enabled = false; AddressBox.Text = Watches.Select(a => a.AddressString).Aggregate((addrStr, nextStr) => $"{addrStr},{nextStr}"); BigEndianCheckBox.ThreeState = true; if (Watches.Select(s => s.Size).Distinct().Count() > 1) { DisplayTypeDropDown.Enabled = false; } } else { NotesBox.Text = Watches[0].Notes; AddressBox.SetFromLong(Watches[0].Address); } SetBigEndianCheckBox(); DomainDropDown.Enabled = false; break; } }
public void AddWatch(Watch watch) { Watches.Add(watch); }
public void Initialization() { WatchDates.Clear(); PeriodValues.Clear(); WatchesList.Clear(); Watches = db.Watches .Include(w => w.Exam) .Include(w => w.WatcherWatches).ThenInclude(ww => ww.Room) .Include(w => w.WatcherWatches).ThenInclude(ww => ww.Watcher) .Where( w => w.ExamId == CurrentExamId ) .OrderByDescending(w => w.WatchDate).ToList(); SelectedWatch = Watches.FirstOrDefault(); foreach (DateTime?d in Watches.Select(x => x.WatchDate).Distinct().ToList()) { WatchDates.Add(d); } foreach (short?p in Watches.Select(x => x.PeriodId).Distinct().ToList()) { PeriodValues.Add(p); } //WatcherWatchesList = new List<WatcherWatch>(); WatchTableViewModel row; foreach (DateTime date in WatchDates) { foreach (short p in PeriodValues) { foreach (Watch w in Watches) { if (w.PeriodId.Equals(p) && w.WatchDate.Equals(date)) { var RoomsWatches = w.WatcherWatches.GroupBy(ww => ww.RoomId) .Select(grp => grp.ToList()); foreach (var r in RoomsWatches) { row = new WatchTableViewModel() { Room = db.Rooms.Find(r.FirstOrDefault().RoomId), Watch = w }; foreach (var ww in r) { row.WatcherWatchesList.Add(ww); if (ww.WatcherType.Equals("1")) { row.RoomChiefsList.Add(ww.Watcher.FullName); } else if (ww.WatcherType.Equals("2")) { row.RoomSecretariesList.Add(ww.Watcher.FullName); } else if (ww.WatcherType.Equals("3")) { row.RoomWatchersList.Add(ww.Watcher.FullName); } } row.RoomChiefs = string.Join(", ", row.RoomChiefsList.ToArray()); row.RoomSecretaries = string.Join(", ", row.RoomSecretariesList.ToArray()); row.RoomWatchers = string.Join(", ", row.RoomWatchersList.ToArray()); WatchesList.Add(row); } } } } } }
public IEnumerable <Watch> Get() { Watches watches = new Watches(new WatchDataContex()); return(watches.GetWatches()); }
public string WatchSelector() { watch = (Watches)EditorGUILayout.EnumPopup("Device:", watch); return(watch.ToString()); }
public void Update() { RunningTotalsDictionary.Clear(); TrackingDays.Clear(); Window.DayControls.Clear(); // update inventory data foreach (var inventoryItem in StaticInventoryTracker.AllInventoryItems) { if (Watches.Any(w => w.MasterID == inventoryItem.MasterID)) { ProductMasterItem keyMasterItem = null; keyMasterItem = StaticInventoryTracker.ProductMasterList.FirstOrDefault( m => m.MasterID == inventoryItem.MasterID); // if master item exists. if (keyMasterItem != null) { RunningTotalsDictionary[keyMasterItem.MasterID] = inventoryItem.Units; } } } // update WiP data foreach (var inventoryItem in StaticInventoryTracker.WiPItems) { if (Watches.Any(w => w.MasterID == inventoryItem.MasterID)) { ProductMasterItem keyMasterItem = null; keyMasterItem = StaticInventoryTracker.ProductMasterList.FirstOrDefault( m => m.MasterID == inventoryItem.MasterID); // if master item exists. if (keyMasterItem != null) { RunningTotalsDictionary[keyMasterItem.MasterID] = inventoryItem.Units; } } } if (CoatingSchedule.CurrentSchedule == null) { return; } foreach (var coatingScheduleLogic in CoatingSchedule.CurrentSchedule.ChildrenLogic) { var day = coatingScheduleLogic as CoatingScheduleDay; AddDay(new TrackingDay(day)); } //foreach (var productMasterItem in Watches) //{ // double currentInv = 0; // var inv = StaticInventoryTracker.InventoryItems.FirstOrDefault(x => x.MasterID == productMasterItem.MasterID); // if (inv != null) // currentInv = inv.Units; // foreach (var trackingDay in TrackingDays) // { // currentInv = trackingDay.AddTracking(productMasterItem, currentInv); // } //} }