Ejemplo n.º 1
0
        public static void SetVirtualMemoryOfDrive(Drive drive, int sizeMb)
        {
            List <VirtualMemory> list  = GetPagingFiles();
            VirtualMemory        exist = list.FirstOrDefault(a => a.DriveName == drive.Name);

            if (exist != null)
            {
                exist.MinSizeMb = sizeMb;
                exist.MaxSizeMb = sizeMb;
            }
            else
            {
                list.Add(new VirtualMemory()
                {
                    DriveName = drive.Name,
                    MinSizeMb = sizeMb,
                    MaxSizeMb = sizeMb
                });
            }
            string[] value = list.Select(a => a.ToString()).ToArray();

            Windows.Registry.SetValue(Microsoft.Win32.Registry.LocalMachine, MemoryManagementSubKey, "PagingFiles", value);
            DriveSet.Current.Refresh();
            DrivesViewModel.Current.IsNeedRestartWindows = VirtualMemory.IsStateChanged;
            drive.OptionalVirtualMemories.OnPropertyChanged(nameof(drive.OptionalVirtualMemories.List));
        }
Ejemplo n.º 2
0
 public OptionalVirtualMemory(Drive drive, int sizeG)
 {
     this.Set = new DelegateCommand(() => {
         VirtualMemory.SetVirtualMemoryOfDrive(Drive, SizeMb);
     });
     _drive = drive;
     _sizeG = sizeG;
 }
Ejemplo n.º 3
0
 public Drive(DriveInfo driveInfo)
 {
     _driveInfo = driveInfo;
     if (driveInfo.DriveType != DriveType.Fixed)
     {
         throw new InvalidProgramException();
     }
     this.ClearVirtualMemory = new DelegateCommand(() => {
         VirtualMemory.ClearVirtualMemory(this);
     });
 }
Ejemplo n.º 4
0
 public void Refresh()
 {
     VirtualMemory.RefreshVirtualMemories();
     foreach (var driveInfo in DriveInfo.GetDrives().Where(a => a.DriveType == DriveType.Fixed))
     {
         Drive drive = _drives.FirstOrDefault(a => a.Name == driveInfo.Name);
         drive?.Refresh(driveInfo);
     }
     OnPropertyChanged(nameof(Drives));
     OnPropertyChanged(nameof(TotalVirtualMemoryGb));
     OnPropertyChanged(nameof(TotalVirtualMemoryGbText));
 }
Ejemplo n.º 5
0
        public static void ClearVirtualMemory(Drive drive)
        {
            List <VirtualMemory> list  = GetPagingFiles();
            VirtualMemory        exist = list.FirstOrDefault(a => a.DriveName == drive.Name);

            if (exist == null)
            {
                return;
            }
            list.Remove(exist);
            string[] value = list.Select(a => a.ToString()).ToArray();

            Windows.Registry.SetValue(Microsoft.Win32.Registry.LocalMachine, MemoryManagementSubKey, "PagingFiles", value);
            DriveSet.Current.Refresh();
            DrivesViewModel.Current.IsNeedRestartWindows = VirtualMemory.IsStateChanged;
            drive.OptionalVirtualMemories.OnPropertyChanged(nameof(drive.OptionalVirtualMemories.List));
        }
Ejemplo n.º 6
0
        private static List <VirtualMemory> Parse(string[] vmReg)
        {
            List <VirtualMemory> list = new List <VirtualMemory>();

            try {
                foreach (string item in vmReg)
                {
                    VirtualMemory vm = Parse(item);
                    if (vm != null)
                    {
                        list.Add(vm);
                    }
                }
            }
            catch (Exception e) {
                Global.Logger.Error(e);
            }
            return(list);
        }
Ejemplo n.º 7
0
 public OptionalVirtualMemories(Drive drive, long awailableSpace, VirtualMemory vm)
 {
     _drive          = drive;
     _awailableSpace = awailableSpace;
     _vm             = vm;
 }