Esempio n. 1
0
 /// <summary>
 /// Drive transmission by velocity.
 /// </summary>
 /// <param name="velocity">Velocity of drive.</param>
 /// <param name="type">Type of drive.</param>
 public override void Drive(float velocity, DriveType type)
 {
     foreach (var unit in mechanismUnits)
     {
         unit.mechanism.Drive(velocity * unit.coefficient, type);
     }
 }
Esempio n. 2
0
        internal void ReadFromDrive(string drive, List <string> elementsToRead, ref long runningFileCount, ref long runningFileSize, bool useSize, DlgReadingProgress dlgReadingProgress, DiscInDatabase discToReplace)
        {
            ReadFromFolder(drive, elementsToRead, ref runningFileCount, ref runningFileSize, useSize, dlgReadingProgress, discToReplace);
            DriveInfo di = new DriveInfo(drive);

            driveFormat        = di.DriveFormat;
            driveType          = di.DriveType;
            totalFreeSpace     = di.TotalFreeSpace;
            totalSize          = di.TotalSize;
            volumeLabel        = di.VolumeLabel;
            serialNumber       = Win32.GetVolumeSerialNumber(drive);
            scannedCrc         = Properties.Settings.Default.ComputeCrc;
            scannedZip         = Properties.Settings.Default.BrowseInsideCompressed;
            scannedFileVersion = Properties.Settings.Default.ReadFileInfo;
            fromDrive          = drive;
            if (discToReplace != null)
            {
                if ((Keywords != string.Empty) && (discToReplace.Keywords != string.Empty))
                {
                    Keywords = Keywords + ";";
                }
                Keywords = Keywords + discToReplace.Keywords;
                if ((physicalLocation != string.Empty) && (discToReplace.physicalLocation != string.Empty))
                {
                    physicalLocation = physicalLocation + ";";
                }
                physicalLocation = physicalLocation + discToReplace.physicalLocation;
                foreach (LogicalFolder logicalFolder in discToReplace.LogicalFolders)
                {
                    logicalFolder.AddItem(this);
                }
            }
        }
        private static DriveType DriveTypeSelector()
        {
            Console.WriteLine("Please use 1-3 to select drive type of vehicle you would like to update:\n" +
                              "1. Electric\n" +
                              "2. Gas\n" +
                              "3. Hybrid\n");

            int menuChoice = int.Parse(Console.ReadLine());

            DriveType driveType = new DriveType();

            switch (menuChoice)
            {
            case 1:
                driveType = DriveType.ElectricDrive;
                break;

            case 2:
                driveType = DriveType.HybridDrive;
                break;

            case 3:
                driveType = DriveType.GasDrive;
                break;
            }

            return(driveType);
        }
Esempio n. 4
0
        public bool DeleteVehicle(DriveType driveType, string make, string model, int milesDriven)
        {
            bool complete = false;

            switch (driveType)
            {
            case DriveType.ElectricDrive:
                var vehicles = _electricVehicles.Single(p => p.Make == make && p.Model == model && p.MilesDriven == milesDriven);

                _electricVehicles.Remove(vehicles);
                complete = true;
                return(complete);

            case DriveType.GasDrive:
                var vehicles2 = _gasVehicles.Single(p => p.Make == make && p.Model == model && p.MilesDriven == milesDriven);

                _gasVehicles.Remove(vehicles2);
                complete = true;
                return(complete);

            case DriveType.HybridDrive:
                var vehicles3 = _hybridVeicles.Single(p => p.Make == make && p.Model == model && p.MilesDriven == milesDriven);

                _hybridVeicles.Remove(vehicles3);

                complete = true;
                return(complete);

            default:
                complete = false;
                return(complete);
            }
        }
Esempio n. 5
0
        public static void listdrives(DataGridView dataGridView1, CheckBox optimize, CheckBox optimizemft, CheckBox uncompress, string settingsfile)
        {
            DriveInfo[]   driveInfo = DriveInfo.GetDrives().Where(x => x.IsReady).ToArray();
            List <string> drives    = new List <string>();

            foreach (DriveInfo drive in driveInfo)
            {
                DriveType driveType = Native.GetDriveType(drive.Name);
                if (
                    driveType != DriveType.Fixed
                    &&
                    driveType != DriveType.Removable
                    &&
                    driveType != DriveType.RAMDisk
                    )
                {
                    continue;
                }
                if (!is_virtual(drive.Name[0]))
                {
                    drives.Add(drive.Name);
                }
                double driveSizeGB      = Math.Round((double)drive.TotalSize / (1024 * 1024 * 1024), 2);
                double driveFreeSpaceGB = Math.Round((double)drive.AvailableFreeSpace / (1024 * 1024 * 1024), 2);
                double drivefreeSpacep  = Math.Round((driveFreeSpaceGB / driveSizeGB) * 100, 2);
                if (drive.Name == "C:\\" && drivefreeSpacep < 35)
                {
                    uncompress.CheckState = CheckState.Unchecked;
                    uncompress.Enabled    = false;
                    PCS.IniWriteValue(settingsfile, "main", "uncompress", "False");
                }
                dataGridView1.Rows.Add(true, drive.Name, driveFreeSpaceGB + " GB", drivefreeSpacep);
            }
            DiskDefragger.read_defragsettings(dataGridView1, optimize, optimizemft, uncompress, settingsfile, true);
        }
Esempio n. 6
0
        public UnusedSpaceErasureTargetConfigurer()
        {
            InitializeComponent();
            Theming.ApplyTheme(this);

            //Populate the drives list
            foreach (VolumeInfo volume in VolumeInfo.Volumes.Concat(VolumeInfo.NetworkDrives))
            {
                DriveType driveType = volume.VolumeType;
                if (driveType != DriveType.Unknown &&
                    driveType != DriveType.NoRootDirectory &&
                    driveType != DriveType.CDRom)
                {
                    //Skip drives which are not mounted: we cannot erase their unused space.
                    if (!volume.IsMounted)
                    {
                        continue;
                    }

                    DriveItem     item = new DriveItem();
                    DirectoryInfo root = volume.MountPoints[0];

                    item.Drive = root.FullName;
                    item.Label = root.GetDescription();
                    item.Icon  = root.GetIcon();
                    unusedDisk.Items.Add(item);
                }
            }

            if (unusedDisk.Items.Count != 0)
            {
                unusedDisk.SelectedIndex = 0;
            }
        }
            /// <summary>
            /// TotalHd_AvailableHd
            /// </summary>
            /// <returns></returns>
            private Dictionary <string, string> TotalHd_AvailableHd()
            {
                Dictionary <string, string> data = new Dictionary <string, string>();

                DriveInfo[] allDrives = DriveInfo.GetDrives();
                foreach (DriveInfo dInfo in allDrives)
                {
                    if (dInfo.IsReady == true)
                    {
                        string    driveName = dInfo.Name; // C:\, E:\, etc:\
                        DriveType driveType = dInfo.DriveType;
                        switch (driveType)
                        {
                        case System.IO.DriveType.Fixed:
                            if (!driveName.ToLower().Contains("C"))
                            {
                                Console.WriteLine("Available space to current user:{0, 15} bytes", dInfo.AvailableFreeSpace);
                                double total  = Convert.ToDouble(dInfo.AvailableFreeSpace / (1024 * 1024));
                                int    t      = Convert.ToInt32(Math.Ceiling(total / 1024).ToString());
                                string memory = t.ToString();    // ram detail
                                Console.WriteLine("total available space" + " " + memory);
                                data.Add("AvailableDiskSpace", Convert.ToInt32(memory).ToString());

                                total  = Convert.ToDouble(dInfo.TotalSize / (1024 * 1024));
                                t      = Convert.ToInt32(Math.Ceiling(total / 1024).ToString());
                                memory = t.ToString();
                                Console.WriteLine("Total size of drive" + " " + memory);
                                data.Add("TotalDiskSpace", Convert.ToInt32(memory).ToString());
                            }
                            break;
                        }
                    }
                }
                return(data);
            }
Esempio n. 8
0
        public DriveItem(DriveInfo driveInfo)
        {
            label     = driveInfo.DriveType == DriveType.Network ? "" : driveInfo.VolumeLabel;
            letter    = driveInfo.Name[0];
            driveType = driveInfo.DriveType;


            switch (driveInfo.DriveType)
            {
            case DriveType.Fixed:
                if (letter == 'C')
                {
                    icon = icons[0];
                }
                else
                {
                    icon = icons[1];
                }
                break;

            case DriveType.Network:
                icon = icons[2];
                break;

                // TODO Add more drive types
            }
        }
Esempio n. 9
0
        private void DrawDriveButtonsForEditor(List <AgentType.DefaultDrive> defaultDrives, DriveType currentDriveType,
                                               float x, float y, int numColumns)
        {
            float buttonWidth  = 125;
            float buttonHeight = 25;
            int   driveNum     = 0;

            foreach (AgentType.DefaultDrive defaultDrive in defaultDrives)
            {
                if (defaultDrive.driveType != null)
                {
                    string name = defaultDrive.driveType.name;
                    if (currentDriveType != null && currentDriveType == defaultDrive.driveType)
                    {
                        name = "*" + name + "*";
                    }
                    int row = driveNum / numColumns;
                    if (GUI.Button(new Rect(x + buttonWidth * (driveNum % numColumns), y + buttonHeight * row, buttonWidth, buttonHeight), name))
                    {
                        selectedDrive = defaultDrive.driveType;
                    }
                    ++driveNum;
                }
            }
        }
Esempio n. 10
0
    public string getDrives()
    {
        string d = "";

        foreach (var drive in DriveInfo.GetDrives())
        {
            int       index      = 0;
            int       flag       = 0;
            string    drivename  = drive.Name;
            DriveType drivetypes = drive.DriveType;
            switch (drivetypes)
            {
            case DriveType.Fixed:
                d     = drivename;
                index = d.IndexOf('C');
                if (index == -1)
                {
                    d    = drivename;
                    flag = 1;
                }
                break;
            }
            if (flag == 1)
            {
                break;
            }
        }
        return(d);
    }
Esempio n. 11
0
        private PlaceType ToPlaceType(DriveType driveType)
        {
            switch (driveType)
            {
            case DriveType.Unknown:
                return(PlaceType.Unknown);

            case DriveType.NoRootDirectory:
                return(PlaceType.NoRootDirectory);

            case DriveType.Removable:
                return(PlaceType.Removable);

            case DriveType.Fixed:
                return(PlaceType.Fixed);

            case DriveType.Network:
                return(PlaceType.Network);

            case DriveType.CDRom:
                return(PlaceType.CDRom);

            case DriveType.Ram:
                return(PlaceType.Ram);

            default:
                throw new ArgumentOutOfRangeException("driveType");
            }
        }
Esempio n. 12
0
        public void UpdateVehicleMileageInRepository(int id, DriveType driveType, int newMileage)
        {
            switch (driveType)
            {
            case DriveType.ElectricDrive:
                /*var dict = _electricVehicles.ToDictionary(x => x.ID);
                 * Vehicle found;
                 * if (dict.TryGetValue(mileage, out found)) found.Mileage = newMileage;
                 * break;*/

                var thing = _electricVehicles.Find(p => p.ID == id);
                thing.Mileage = newMileage;
                break;

            case DriveType.GasDrive:
                /*var dict2 = _gasVehicles.ToDictionary(x => x.ID);
                 * Vehicle found2;
                 * if (dict2.TryGetValue(mileage, out found2)) found2.Mileage = newMileage;*/

                var thing2 = _gasVehicles.Find(p => p.ID == id);
                thing2.Mileage = newMileage;

                break;

            case DriveType.HybridDrive:
                /*var dict3 = _hybridVeicles.ToDictionary(x => x.Mileage);
                 * Vehicle found3;
                 * if (dict3.TryGetValue(mileage, out found3)) found3.Mileage = newMileage;*/

                var thing3 = _hybridVeicles.Find(p => p.ID == id);
                thing3.Mileage = newMileage;

                break;
            }
        }
Esempio n. 13
0
 /// <summary>
 /// Drive synchronizer by velocity.
 /// </summary>
 /// <param name="velocity">Velocity of drive.</param>
 /// <param name="type">Type of drive.</param>
 public override void Drive(float velocity, DriveType type)
 {
     foreach (var mechanism in mechanisms)
     {
         mechanism.Drive(velocity, type);
     }
 }
Esempio n. 14
0
        /// <summary>
        /// 获取磁盘类型
        /// </summary>
        /// <param name="t"></param>
        /// <returns></returns>
        public static string GetDriveType(DriveType t)
        {
            switch (t)
            {
            case DriveType.Unknown:
                return("未知的驱动器类型");

            case DriveType.NoRootDirectory:
                return("驱动器没有根目录");

            case DriveType.Removable:
                return("可移动存储设备");

            case DriveType.Fixed:
                return("本地固定磁盘");

            case DriveType.Network:
                return("网络驱动器");

            case DriveType.CDRom:
                return("光盘设备");

            case DriveType.Ram:
                return("RAM 磁盘");

            default:
                return("未知的驱动器类型");
            }
        }
Esempio n. 15
0
        private void SetImage(DriveType type)
        {
            switch (type)
            {
            case DriveType.Removable:
                Name        = drive.VolumeLabel;
                ImageSource = new Uri("/Images/Icons/USB2.png", UriKind.Relative);
                break;

            case DriveType.Fixed:
                Name        = "Dysk lokalny " + drive.Name;
                ImageSource = new Uri("/Images/Icons/HDD.png", UriKind.Relative);
                break;

            case DriveType.Network:
                ImageSource = new Uri("/Images/Icons/Cloud-Storage.png", UriKind.Relative);
                break;

            case DriveType.CDRom:
                ImageSource = new Uri("/Images/Icons/CD.png", UriKind.Relative);
                break;

            default:
                ImageSource = new Uri("/Images/Icons/HDD.png", UriKind.Relative);
                break;
            }
            this.Image = new BitmapImage(this.ImageSource);
        }
Esempio n. 16
0
        public void NewDisk(DriveType type, string path)
        {
            switch (type)
            {
            case DriveType.Invalid:
            //
            // For Invalid (i.e. unloaded or unspecified disks)
            // we assume an SA1004 geometry, but will always
            // return Not Ready.
            //
            case DriveType.SA1004:
                _geometry = Geometry.SA1004;
                break;

            case DriveType.Q2040:
                _geometry = Geometry.Q2040;
                break;

            case DriveType.Q2080:
                _geometry = Geometry.Q2080;
                break;
            }

            _tracks        = new uint[_geometry.Cylinders, _geometry.Heads, _wordsPerTrack];
            _type          = type;
            _diskImagePath = path;
        }
Esempio n. 17
0
        public void listdrives()
        {
            DriveInfo[]   driveInfo = DriveInfo.GetDrives();
            List <string> drives    = new List <string>();

            foreach (DriveInfo drive in driveInfo)
            {
                DriveType driveType = Native.GetDriveType(drive.Name);
                if (
                    driveType != DriveType.Fixed
                    &&
                    driveType != DriveType.Removable
                    &&
                    driveType != DriveType.RAMDisk
                    )
                {
                    continue;
                }
                if (!is_virtual(drive.Name[0]))
                {
                    drives.Add(drive.Name);
                }
                double driveSizeGB      = Math.Round((double)drive.TotalSize / (1024 * 1024 * 1024), 2);
                double driveFreeSpaceGB = Math.Round((double)drive.AvailableFreeSpace / (1024 * 1024 * 1024), 2);
                dataGridView1.Rows.Add(true, drive.Name, driveFreeSpaceGB + " GB", Math.Round((driveFreeSpaceGB / driveSizeGB) * 100, 2));
            }
            read_defragsettings(true);
        }
 public static Packet GetPacket(DriveType drive, int shipType, int unknown, string shipName)
 {
     SetShipSettingsSubPacket ssp = new SetShipSettingsSubPacket(drive, shipType, unknown, shipName);
     ShipActionPacket sap = new ShipActionPacket(ssp);
     Packet p = new Packet(sap);
     return p;
 }
 public SetShipSettingsSubPacket(DriveType drive, int shipType, int unknown, string shipName) : base( ShipActionSubPacketType.SetShipSettingsSubPacket, (int)drive)
 {
    
     ShipType = shipType;
     Unknown = unknown;
     ShipName = new ArtemisString(shipName);
 }
Esempio n. 20
0
        /// <summary>
        /// 操作driverInfo类
        /// </summary>
        private void GetDrivers()
        {
            DriveInfo[] drivers = DriveInfo.GetDrives();
            foreach (DriveInfo driver in drivers)
            {
                // 指示驱动器上的可用空闲空间量
                long availableFreeSpace = driver.AvailableFreeSpace;
                // 获取文件系统的名称,例如NTFS或FAT32
                string driveFormat = driver.DriveFormat;
                // 获取驱动器类型
                DriveType driveType = driver.DriveType;
                // 获取一个指示驱动器是否已准备好的值
                bool isReady = driver.IsReady;
                // 获取驱动器的名称
                string name = driver.Name;
                // 获取驱动器的根目录
                DirectoryInfo rootDirectory = driver.RootDirectory;
                // 获取驱动器上的可用空闲空间总量
                long totalFreeSpace = driver.TotalFreeSpace;
                // 获取驱动器上存储空间的总大小
                long totalSize = driver.TotalSize;
                // 获取或设置驱动器的卷标
                string volumeLabel = driver.VolumeLabel;

                textBoxOutput.Text += string.Format("驱动器名称:{0}\r\n", driver.Name);
                textBoxOutput.Text += string.Format("\t可用空闲空间量:{0}\t文件系统名称:{1}\r\n", availableFreeSpace, driveFormat);
                textBoxOutput.Text += string.Format("\t驱动器类型:{0}\t\t是否已准备好:{1}\r\n", driveType, isReady);
                textBoxOutput.Text += string.Format("\t驱动器的根目录:{0}\t\t可用空闲空间总量:{1}\r\n", rootDirectory, totalFreeSpace);
                textBoxOutput.Text += string.Format("\t存储空间的总大小:{0}\t驱动器的卷标:{1}\r\n", totalSize, volumeLabel);
                textBoxOutput.Select(textBoxOutput.TextLength, 0);
                textBoxOutput.ScrollToCaret();
            }
        }
Esempio n. 21
0
        private string GetFixedOrRemovableDrivers(DriveType driveType)
        {
            var jArray = new JArray();

            var drivers = DriveInfo.GetDrives();

            foreach (var driver in drivers)
            {
                if (driver.DriveType != driveType)
                {
                    continue;
                }

                jArray.Add(new JObject
                {
                    ["Name"]          = driver.Name,
                    ["DriveType"]     = (int)driver.DriveType,
                    ["DriveFormat"]   = driver.DriveFormat,
                    ["VolumeLabel"]   = driver.VolumeLabel,
                    ["RootDirectory"] = driver.RootDirectory.FullName
                });
            }

            return(jArray.ToString());
        }
Esempio n. 22
0
        private static DriveType ConvertDriveType(UInt32 driveType)
        {
            DriveType type = DriveType.Other;

            switch (driveType)
            {
            case 0:
            case 1:
            case 4:
            case 5:
            default:
                type = DriveType.Other;
                break;

            case 2:
                type = DriveType.Removable;
                break;

            case 3:
                type = DriveType.Local;
                break;

            case 6:
                type = DriveType.RAM;
                break;
            }

            return(type);
        }
 public int ManageDriveType(DriveType driveTypeObj)
 {
     if (driveTypeObj != null)
     {
         var existringDriveType = _context.DriveTypes
                                  .Where(x => x.DriveTypeName.ToLower().Equals(driveTypeObj.DriveTypeName.ToLower()))
                                  .FirstOrDefault();
         if (existringDriveType != null)
         {
             existringDriveType.DriveTypeName = driveTypeObj.DriveTypeName;
             _context.SaveChanges();
             return(existringDriveType.Id);
         }
         else
         {
             _context.DriveTypes.Add(driveTypeObj);
             _context.SaveChanges();
             return(driveTypeObj.Id);
         }
     }
     else
     {
         return(0);
     }
 }
Esempio n. 24
0
 private void buttonSubmit_Click(object sender, EventArgs e)
 {
     if (procesor == null || video == null)
     {
         MessageBox.Show("You need to set processor and videocard first");
     }
     else
     {
         try
         {
             int          memory      = Helper.GetIntValue(textMemorySize);
             int          driveSize   = Helper.GetIntValue(textDriveSize);
             DateTime     datePurchse = datePurchaseDate.Value;
             ComputerType compType    = GetComputerType();
             RAMType      ramType     = GetRAMType();
             DriveType    driveType   = GetDriveType();
             comp = new Computer(compType, procesor, video, ramType, driveSize, driveType, datePurchse, memory);
             this.DialogResult = DialogResult.OK;
             this.Close();
         }
         catch (FormValueError ex)
         {
             MessageBox.Show(ex.Message);
         }
     }
 }
Esempio n. 25
0
        private StackPanel GetClrtDisplayableTypeStackPanel(Folder folder)
        {
            var stackPanel = new StackPanel()
            {
                Orientation = Orientation.Horizontal
            };

            Image image = new Image();

            if (folder.IsDrive)
            {
                DriveType driveType = folder.DriveType;
                switch (driveType)
                {
                case DriveType.Fixed:
                    image.Source = ((Image)Application.Current.FindResource("HardDiskPng")).Source;
                    break;

                default:
                    image.Source = ((Image)Application.Current.FindResource("HardDiskPng")).Source;
                    break;
                }
            }
            else
            {
                image.Source = ((Image)Application.Current.FindResource("FolderPng")).Source;
            }

            stackPanel.Children.Add(image);
            stackPanel.Children.Add(GetClrtDisplayableTypeTextBlock(folder));
            return(stackPanel);
        }
        /// <summary>
        /// Drive vibrator by angular velocity.
        /// </summary>
        /// <param name="velocity">Angular velocity of drive.</param>
        /// <param name="type">Invalid parameter (CentrifugalVibrator can only drived by angular velocity).</param>
        public override void Drive(float velocity, DriveType type = DriveType.Ignore)
        {
            currentAngle += velocity * Time.deltaTime;
            var direction = Quaternion.AngleAxis(currentAngle, transform.forward) * transform.right;

            transform.localPosition = StartPosition + GetLocalDirection(direction) * amplitudeRadius;
        }
Esempio n. 27
0
        /// <summary>
        /// Checks if the given path is a network drive.
        /// </summary>
        /// <param name="path">The path to check.</param>
        /// <returns></returns>
        public static bool isNetworkDrive(string path)
        {
            if (String.IsNullOrWhiteSpace(path))
            {
                Log.Debug("UNCTools: isNetworkDrive: The path argument was null or whitespace.");
            }

            if (!Path.IsPathRooted(path))
            {
                Log.Debug(
                    string.Format("UNCTools: isNetworkDrive: The path '{0}' was not a rooted path and ResolveToRootUNC does not support relative paths.",
                                  path)
                    );
            }

            if (path.StartsWith(@"\\"))
            {
                return(true);
            }

            // Get just the drive letter for WMI call
            string driveletter = GetDriveLetter(path);

            // Query WMI if the drive letter is a network drive
            using (ManagementObject mo = new ManagementObject())
            {
                mo.Path = new ManagementPath(string.Format("Win32_LogicalDisk='{0}'", driveletter));
                DriveType driveType = (DriveType)((uint)mo["DriveType"]);
                return(driveType == DriveType.Network);
            }
        }
Esempio n. 28
0
        private void CreateNewVehicle()
        {
            Console.WriteLine("Please enter the Make of the Vehicle: ");
            string make = Console.ReadLine();

            Console.WriteLine("Please enter the Model of the Vehicle: ");
            string model = Console.ReadLine();

            Console.WriteLine("Please enter the Year of the Vehicle: ");
            int year = int.Parse(Console.ReadLine());

            DriveType driveType = DriveTypeSelector();

            Console.WriteLine("Please enter Vehicle Mileage: ");
            int mileage = int.Parse(Console.ReadLine());

            Console.WriteLine("Please Enter Vehicle Cost: ");
            decimal cost = decimal.Parse(Console.ReadLine());

            Console.WriteLine("Please enter Vehicle Miles Driven: ");
            int milesDriven = int.Parse(Console.ReadLine());

            Console.WriteLine("How many Baby Seals have been made decease by this Vehicle: ");
            int babySeals = int.Parse(Console.ReadLine());

            int id = 12345 + VehicleRepository.ShowAllVehicles().Count;

            Vehicle vehicle = new Vehicle(id, make, model, year, driveType, mileage, cost, milesDriven, babySeals);

            VehicleRepository.AddVehicleToRepository(vehicle, driveType);

            Console.WriteLine("New Vehicle has been Added!!");
        }
Esempio n. 29
0
        /// <summary>
        /// 初始化DriveDataBase对象
        /// </summary>
        /// <param name="DriveFolder">驱动器文件夹</param>
        /// <param name="Thumbnail">缩略图</param>
        /// <param name="PropertiesRetrieve">额外信息</param>
        protected DriveDataBase(StorageFolder DriveFolder, BitmapImage Thumbnail, IDictionary <string, object> PropertiesRetrieve, DriveType DriveType)
        {
            this.DriveFolder = DriveFolder ?? throw new FileNotFoundException();
            this.Thumbnail   = Thumbnail;
            this.DriveType   = DriveType;

            UIS = new UISettings();
            UIS.ColorValuesChanged += UIS_ColorValuesChanged;

            if (PropertiesRetrieve != null)
            {
                if (PropertiesRetrieve.TryGetValue("System.Capacity", out object TotalByteRaw) && TotalByteRaw is ulong TotalByte)
                {
                    this.TotalByte = TotalByte;
                }

                if (PropertiesRetrieve.TryGetValue("System.FreeSpace", out object FreeByteRaw) && FreeByteRaw is ulong FreeByte)
                {
                    this.FreeByte = FreeByte;
                }

                if (PropertiesRetrieve.TryGetValue("System.Volume.FileSystem", out object FileSystemRaw) && FileSystemRaw is string FileSystem)
                {
                    this.FileSystem = FileSystem;
                }
            }
        }
Esempio n. 30
0
 public USBDevice(string name, ComState comState, Button button, DriveType driveType)
 {
     Name      = name;
     ComState  = comState;
     Button    = button;
     DriveType = driveType;
 }
Esempio n. 31
0
        private static string GetDriveDetails(DriveInfo d)
        {
            string driveDetails = string.Empty;

            if (d != null)
            {
                DriveType type = d.DriveType;
                driveDetails = type.ToString();
                if (type != DriveType.CDRom)
                {
                    try
                    {
                        long free;
                        long freeUser;
                        long total;
                        if (NativeMethods.GetDiskFreeSpaceEx(d.Name, out freeUser, out total, out free))
                        {
                            driveDetails += String.Format(" {0}, {1} total, {2} free", d.DriveFormat, total.ToSize(), free.ToSize());
                            if (freeUser < free)
                            {
                                driveDetails += String.Format(", {0} available", freeUser.ToSize());
                            }

                            if (type == DriveType.Network)
                            {
                                string uncPath = PathUtil.GetUNCPath(d.Name);
                                driveDetails += String.Format(", {0}", uncPath);
                            }
                        }
                    }
                    catch { }
                }
            }
            return(driveDetails);
        }
Esempio n. 32
0
        private async void DeviceAdded(DeviceWatcher sender, DeviceInformation args)
        {
            var deviceId = args.Id;

            var root = StorageDevice.FromId(deviceId);

            // If drive already in list, skip.
            if (Drives.Any(x => x.tag == root.Name))
            {
                return;
            }

            DriveType type = DriveType.Removable;

            var driveItem = new DriveItem(
                root,
                Visibility.Visible,
                type);

            // Update the collection on the ui-thread.
            try
            {
                CoreApplication.MainView.Dispatcher.RunAsync(CoreDispatcherPriority.Low, () => { Drives.Add(driveItem); });
            }
            catch (Exception e)
            {
                // Ui-Thread not yet created.
                Drives.Add(driveItem);
            }
        }
Esempio n. 33
0
 public List<DriveInfo> GetCurrentDrives(DriveType type)
 {
     List<DriveInfo> drives = new List<DriveInfo>();
       foreach (DriveInfo drive in DriveInfo.GetDrives())
     if (drive.DriveType == type)
       drives.Add(drive);
       return drives;
 }
Esempio n. 34
0
        public KeepAliveDrive(String Path)
        {
            // Expecting Path values like: "C:\"
            DrivePath = Path;

            var driveInfo = new DriveInfo(Path);
            _driveType = driveInfo.DriveType;
        }
Esempio n. 35
0
 /// <summary>
 /// Creates and initializes a new instance of the Drive class.
 /// </summary>
 /// <param name="drivealgorithm">The algorithm we can use to generate the serial number.</param>
 /// <param name="driveinterface">The drive interface.</param>
 /// <param name="drivename">The name of the drive.</param>
 /// <param name="drivesize">The size of the drive.</param>
 /// <param name="drivetype">The type of drive.</param>
 public SeagateDrive(string drivealgorithm, DriveInterface driveinterface, string drivename, string drivesize, DriveType drivetype)
 {
     m_algorithm = drivealgorithm;
     m_interface = driveinterface;
     m_name = drivename;
     m_size = drivesize;
     m_type = drivetype;
 }
Esempio n. 36
0
 public Disk(string name, string path, DriveType diskType, IFieldElement prev)
 {
     Name = name;
     Path = path;
     DiskType = diskType;
     Type = GetDiskType(diskType);
     Prev = prev;
     Next = null;
 }
Esempio n. 37
0
        public ProcMount(DriveType driveType, string name, string mount, string type, Dictionary<string, string> options)
        {
            DriveType = driveType;
            Name = name;
            RootDirectory = mount;
            DriveFormat = type;

            _unixDriveInfo = new UnixDriveInfo(mount);
        }
Esempio n. 38
0
 /// <summary>
 /// Determines whether this application is configured to perform the "Keep Alive" process on the specified type of drive.
 /// </summary>
 /// <param name="TypeOfDrive">The type of drive.</param>
 /// <returns>
 ///   <c>true</c> if the application is configured to keep the drive from spinning down; otherwise, <c>false</c>.
 /// </returns>
 public static Boolean IsKeepaliveEnabled(DriveType TypeOfDrive)
 {
     String driveType = Enum.GetName(typeof(DriveType), TypeOfDrive);
     String keyName = "EnableDriveType" + driveType;
     Boolean? settingValue = GetConfigurationValueBoolean(keyName);
     if (settingValue.HasValue)
     {
         return settingValue.Value;
     }
     return false;
 }
Esempio n. 39
0
 public Drive(long availableFreeSpace, string driveFormat, DriveType driveType, bool isReady, string name, long totalFreeSpace, long totalSize, string volumeLabel)
 {
     AvailableFreeSpace = availableFreeSpace;
     DriveFormat = driveFormat;
     DriveType = driveType;
     IsReady = isReady;
     Name = name;
     TotalFreeSpace = totalFreeSpace;
     TotalSize = totalSize;
     VolumeLabel = volumeLabel;
 }
        public InsertDriveNotifyDialog(string reqLabel, string desc, string reqLabelEx, DriveType reqDriveType) :
            base("TXT_INSERT_DISK")
        {
            _reqLabel = reqLabel;
            _reqLabelEx = reqLabelEx;
            _reqDriveType = reqDriveType;
            _desc = desc;

            InitializeComponent();

            this.Load += new EventHandler(DriveNotifyForm_Load);
        }
Esempio n. 41
0
 internal DriveInfo()
 {
     this.volumeLabel = string.Empty;
     this.totalSize = 0L;
     this.rootPath = string.Empty;
     this.device = string.Empty;
     this.driveType = DriveType.Unknown;
     this.filesystem = string.Empty;
     this.isMounted = false;
     this.isReady = false;
     this.hasAudioCdVolume = false;
 }
Esempio n. 42
0
 public static string DriveTypeName(DriveType type)
 {
     switch (type)
     {
         case DriveType.Fixed:
             return "Local Disk";
         case DriveType.Network:
             return "Network Drive";
         case DriveType.Removable:
             return "Removable Drive";
         default:
             return type.ToString();
     }
 }
 public static List<DriveInfo> GetDrives(this DriveInfo drive,
         DriveType type)
 {
     List<DriveInfo> list = new List<DriveInfo>();
         foreach (string s in DriveInfoX.DefaultInstance.GetATOZLetters())
         {
             DriveInfo newDrive = new DriveInfo(s);
             DirectoryInfo di = newDrive.RootDirectory;
             if(drive.DriveType == type && di.Exists)
             {
                 list.Add(newDrive);
             }
         }
         return list;
 }
Esempio n. 44
0
 private Image GetIconDriveType(DriveType driveType)
 {
     Image iconImage = Properties.Resource.Alert;
     switch (driveType)
     {
         case DriveType.Fixed:
             iconImage = Properties.Resource.HDD;
             break;
         case DriveType.CDRom:
             iconImage = Properties.Resource.DVD;
             break;
         case DriveType.Removable:
             iconImage = Properties.Resource.USB;
             break;
     }
     return iconImage;
 }
Esempio n. 45
0
 public static string DriveTypeToString(DriveType t)
 {
     switch (t)
     {
         case DriveType.CDRom:
             return "CD Rom";
         case DriveType.Network:
             return "Network";
         case DriveType.Fixed:
             return "Fixed";
         case DriveType.Removable:
             return "Removable";
         case DriveType.Ram:
             return "Ram";
         case DriveType.NoRootDirectory:
             return "No root directory";
     }
     return "Unknown";
 }
Esempio n. 46
0
 /// <summary>获取驱动器中文名称</summary>
 /// <param name="type">驱动器类型</param>
 /// <returns>驱动器的中文名称</returns>
 public static string GetDriveTypeName(DriveType type)
 {
     return type.GetLocalization_(Localization.Resources.ResourceManager);
 }
Esempio n. 47
0
        /// <summary>
        /// Initializes the list of drives to work with.
        /// </summary>
        /// <param name="type">The type of drives to get.</param>
        /// <returns>The result of the initialization.</returns>
        protected DriveStatus Initialize(DriveType type)
        {
            this.drives = new List<DriveInfo>();
            var result = DriveStatus.Ready;

            DriveInfo[] devices = DriveInfo.GetDrives();

            foreach (var drive in devices)
            {
                if (drive.DriveType == type)
                {
                    this.drives.Add(drive);
                }
            }

            if (this.Drives.Count <= 0)
            {
                result = DriveStatus.NoDevices;
            }

            return result;
        }
        /// <summary>
        /// List of physical drives on the current machine
        /// </summary>
        /// <param name="requestedType">DriveType being searched for</param>
        /// <returns>List of DriveInfo objects found</returns>
        public static IList<DriveInfo> GetDrives(DriveType requestedType)
        {
            IList<DriveInfo> requested_drives = new List<DriveInfo>();

            DriveInfo[] allDrives = DriveInfo.GetDrives();
            foreach (DriveInfo drive in allDrives)
            {
                if (drive.DriveType == requestedType)
                {
                    requested_drives.Add(drive);
                }
            }
            return requested_drives;
        }
Esempio n. 49
0
 public void ShowTree(DriveType driveType)
 {
     var drives = DriveInfo.GetDrives();
     foreach (var current in
         from driveInfo in drives
         where driveInfo.DriveType == driveType
         select driveInfo)
     {
         ShowTree(current.Name, false, "", false);
     }
 }
 /// <summary>
 /// Returns an image relevent to the specified DriveType enumeration.
 /// </summary>
 /// <param name="nDriveType">Specifies the DriveType enumeration.</param>
 /// <returns></returns>
 private Image GetImageFromDriveType(DriveType nDriveType)
 {
     switch (nDriveType)
     {
         case DriveType.CDRom:
             return Resources.cd_rom_16x16;
         case DriveType.Fixed:
             return Resources.hard_drive_16x16;
         case DriveType.Removable:
             return Resources.removable_disk_16x16;
         case DriveType.Ram:
             return Resources.ram_16x16;
         case DriveType.Network:
             return Resources.network_drive_16x16;
         case DriveType.Unknown:
             return Resources.unknown_drive_16x16;
         default:
             return Resources.unknown_drive_16x16;
     }
 }
 internal VolumeInfo(string volume, string volumeLabel, uint type)
 {
     VolumePath = volume;
     VolumeLabel = volumeLabel;
     DriveType = ToDriveType(type);
     enumerate_mounted_paths(VolumePath, MountedPaths.Add);
 }
Esempio n. 52
0
 /// <summary>
 /// Changes the speed of a drive to the value set in configuration
 /// </summary>
 /// <param name="strFile"></param>
 private static void ChangeDriveSpeed(string strFile, DriveType drivetype)
 {
   if (!driveSpeedLoaded)
   {
     LoadDriveSpeed();
   }
   if (!driveSpeedControlEnabled)
   {
     return;
   }
   try
   {
     // is the DVD inserted in a Drive for which we need to control the speed
     string rootPath = Path.GetPathRoot(strFile);
     string speed = string.Empty;
     if (rootPath != null)
     {
       if (rootPath.Length > 1)
       {
         int driveindex = _driveLetters.IndexOf(rootPath.Substring(0, 1));
         if (driveindex > -1 && driveindex < _driveSpeedCD.Length)
         {
           if (drivetype == DriveType.CD && _disableCDSpeed[driveindex] == "N")
           {
             speed = _driveSpeedCD[driveindex];
           }
           else if (drivetype == DriveType.DVD && _disableDVDSpeed[driveindex] == "N")
           {
             speed = _driveSpeedDVD[driveindex];
           }
           else
           {
             return;
           }
           BassCd.BASS_CD_SetSpeed(driveindex, Convert.ToSingle(speed));
           Log.Info("g_player: Playback Speed on Drive {0} reduced to {1}", rootPath.Substring(0, 1), speed);
           driveSpeedReduced = true;
         }
       }
     }
   }
   catch (Exception) {}
 }
 /// <summary>
 /// Returns a NodeImageType enumeration specified by the drive type.
 /// </summary>
 /// <param name="nDriveType">Specifies the DriveType enumeration.</param>
 /// <returns></returns>
 private NodeImageType GetNodeImageFromDriveType(DriveType nDriveType)
 {
     switch (nDriveType)
     {
         case DriveType.CDRom:
             return NodeImageType.CDRom;
         case DriveType.Fixed:
             return NodeImageType.HDD;
         case DriveType.Removable:
             return NodeImageType.Removable;
         case DriveType.Ram:
             return NodeImageType.Ram;
         case DriveType.Network:
             return NodeImageType.NetworkDrive;
         case DriveType.Unknown:
             return NodeImageType.UnknownDrive;
         default:
             return NodeImageType.UnknownDrive;
     }
 }
Esempio n. 54
0
 public Archive(string name, DriveType driveType, string label)
 {
     Name = name;
     DriveType = driveType;
     Label = label;
 }
Esempio n. 55
0
 /// <summary>
 /// Copies the members from.
 /// </summary>
 /// <param name="source">Source.</param>
 public override void CopyMembersFrom(Artefact source)
 {
     base.CopyMembersFrom(source);
     Drive srcDrive = (Drive)source;
     Disk = srcDrive.Disk;
     Partition = srcDrive.Partition;
     Label = srcDrive.Label;
     Format = srcDrive.Format;
     Type = srcDrive.Type;
     Size = srcDrive.Size;
     FreeSpace = srcDrive.FreeSpace;
     AvailableFreeSpace = srcDrive.AvailableFreeSpace;
 }
Esempio n. 56
0
 internal static int GetFormatInfoForMountPoint(string name, out DriveType type)
 {
     string temp;
     return GetFormatInfoForMountPoint(name, out temp, out type);
 }
Esempio n. 57
0
        private static int GetFormatInfoForMountPoint(string name, out string format, out DriveType type)
        {
            unsafe
            {
                byte* formatBuffer = stackalloc byte[MountPointFormatBufferSizeInBytes];    // format names should be small
                long numericFormat;
                int result = GetFormatInfoForMountPoint(name, formatBuffer, MountPointFormatBufferSizeInBytes, &numericFormat);
                if (result == 0)
                {
                    // Check if we have a numeric answer or string
                    format = numericFormat != -1 ?
                        Enum.GetName(typeof(UnixFileSystemTypes), numericFormat) :
                        Marshal.PtrToStringAnsi((IntPtr)formatBuffer);
                    type = GetDriveType(format);
                }
                else
                {
                    format = string.Empty;
                    type = DriveType.Unknown;
                }

                return result;
            }
        }
Esempio n. 58
0
 internal DrvInfo(FileSystemManager parent, string name, string label, string path, DriveType type, bool isReady, bool loadDirectories = false, bool loadFiles = false) : base(parent, name, path, loadDirectories, loadFiles)
 {
     Type = type;
     Label = label;
     IsReady = isReady;
 }
    private void AddStaticShares(DriveType driveType, string defaultName)
    {
      string[] drives = Environment.GetLogicalDrives();

      foreach (string drive in drives)
      {
        if (Util.Utils.getDriveType(drive) == (int)driveType)
        {
          bool driveFound = false;
          string driveName = Util.Utils.GetDriveName(drive);

          if (driveName.Length == 0)
          {
            string driveLetter = drive.Substring(0, 1).ToUpperInvariant();
            driveName = String.Format("{0} {1}:", defaultName, driveLetter);
          }

          //
          // Check if the share already exists
          //
          foreach (GUIListItem listItem in _shareListControl)
          {
            if (listItem.Path == drive)
            {
              driveFound = true;
              break;
            }
          }

          if (driveFound == false)
          {
            //
            // Add share
            //
            string name = "";
            switch (driveType)
            {
              case DriveType.Removable:
                name = String.Format("({0}:) Removable", drive.Substring(0, 1).ToUpperInvariant());
                break;
              case DriveType.Fixed:
                name = String.Format("({0}:) Fixed", drive.Substring(0, 1).ToUpperInvariant());
                break;
              case DriveType.RemoteDisk:
                name = String.Format("({0}:) Remote", drive.Substring(0, 1).ToUpperInvariant());
                break;
              case DriveType.DVD: // or cd
                name = String.Format("({0}:) CD/DVD", drive.Substring(0, 1).ToUpperInvariant());
                break;
              case DriveType.RamDisk:
                name = String.Format("({0}:) Ram", drive.Substring(0, 1).ToUpperInvariant());
                break;
            }
            if (driveType == DriveType.Fixed || driveType == DriveType.RemoteDisk)
            {
              AddShare(new ShareData(name, drive, string.Empty, true), false);
            }
            else
            {
              AddShare(new ShareData(name, drive, string.Empty, false), false);
            }
          }
        }
      }
    }
Esempio n. 60
0
		public static List<DriveInfo> GetDrivesByType(DriveType type = DriveType.Fixed) => (from d in DriveInfo.GetDrives() where d.DriveType == DriveType.Fixed select d).ToList();