public void Init() { storage = new StorageDisk(FolderPath); scoreboard = new Scoreboard(storage); storageMock = new StorageMock(); scoreboardMocked = new Scoreboard(storageMock); }
public bool TrySendData(StorageDisk other) { if (other.Available < Used) { return(false); } other.Used += Used; Used = 0; return(true); }
public static int DescendingAvailable(StorageDisk left, StorageDisk right) => right.Available.CompareTo(left.Available);
public static int DescendingUsed(StorageDisk left, StorageDisk right) => right.Used.CompareTo(left.Used);
public bool Equals(StorageDisk other) => X == other.X && Y == other.Y;
internal static void Main_MessageReceived(object sender, EventArgsValue <Message> e) { if (e.Value.Msg != (int)WindowsMessages.WM_DEVICECHANGE || e.Value.LParam == IntPtr.Zero) { return; } DEV_BROADCAST_VOLUME dbcv = (DEV_BROADCAST_VOLUME)Marshal.PtrToStructure(e.Value.LParam, typeof(DEV_BROADCAST_VOLUME)); if (dbcv.dbcv_devicetype != (int)DBT.DEVTYP_VOLUME) { return; // we were not even allowed to transform to DEV_BROADCAST_VOLUME =) But who cares... } switch ((DBT)((int)e.Value.WParam)) { #region case DBT.DEVICEARRIVLE: case DBT.DEVICEARRIVAL: StorageDisk device = StorageDisk.FromUnitMask(dbcv.dbcv_unitmask); ((List <StorageDisk>)oldStaticValues[EventType.DeviceRemoved]).Add(device); if (dbcv.dbcv_flags == 1 /*DBFT_MEDIA*/) { if (OnMediaInserted != null) { OnMediaInserted(null, new EventArgsValue <Classes.Device.Device>(device)); } } else if (dbcv.dbcv_flags == 2 /*DBFT_NET*/) { if (OnNetworkVolumeArrived != null) { OnNetworkVolumeArrived(null, new EventArgsValue <Classes.Device.Device>(device)); } } else { if (OnDeviceArrived != null) { OnDeviceArrived(null, new EventArgsValue <Classes.Device.Device>(device)); } } break; #endregion #region case DBT.DEVICEQUERYREMOVE: case DBT.DEVICEQUERYREMOVE: throw new NotImplementedException("\"Device Query remove\" is not implemented"); #endregion #region case DBT.DEVICEQUERYREMOVEFAILED: case DBT.DEVICEQUERYREMOVEFAILED: throw new NotImplementedException("\"Device Query remove failed\" is not implemented"); #endregion #region case DBT.DEVICEREMOVECOMPLETE: case DBT.DEVICEREMOVECOMPLETE: if (OnDeviceRemoved == null) { break; } char removedDiskLetter = StorageDisk.FirstDriveFromMask(dbcv.dbcv_unitmask); List <StorageDisk> oldDisks = (List <StorageDisk>)oldStaticValues[EventType.DeviceRemoved]; foreach (StorageDisk oldDisk in oldDisks) { if (oldDisk.DriveLetters.Contains(removedDiskLetter)) { OnDeviceRemoved(null, new EventArgsValue <Classes.Device.Device>(oldDisk)); oldDisks.Remove(oldDisk); break; } } break; #endregion } }
public void Init() { storage = new StorageDisk(FolderPath); }