示例#1
0
        public virtual Uri GetUri(string path, object name, AccessType type = AccessType.Public)
        {
            IDiskAccess access = _fileSettings.GetAccess(type);

            if (access == null)
            {
                throw new KeyNotFoundException($"'{type}' file storage not configured");
            }

            return(GetUri(access.BaseUri, path, name));
        }
示例#2
0
        public MainForm()
        {
            InitializeComponent();

            checkBoxUseMBR.Checked = true;

            MessageBoxEx.Owner = this.Handle;

            toolStripStatusLabel1.Text = @"Initialised. Licensed under GPLv3.";

            saveFileDialog1.OverwritePrompt = false;
            saveFileDialog1.Filter          = @"Image Files (*.img,*.bin,*.sdcard)|*.img;*.bin;*.sdcard|Compressed Files (*.zip,*.gz,*tgz)|*.zip;*.gz;*.tgz|All files (*.*)|*.*";

            // Set version into title
            var version = Assembly.GetEntryAssembly().GetName().Version;

            Text += @" v" + version;

            // Set app icon (not working on Mono/Linux)
            if (Environment.OSVersion.Platform != PlatformID.Unix)
            {
                Icon = Utility.GetAppIcon();
            }

            PopulateDrives();
            if (comboBoxDrives.Items.Count > 0)
            {
                EnableButtons();
            }
            else
            {
                DisableButtons(false);
            }

            // Read registry values
            var key = Registry.LocalMachine.CreateSubKey("SOFTWARE\\Dynamic Devices Ltd\\DiskImager");

            if (key != null)
            {
                var file = (string)key.GetValue("FileName", "");
                if (File.Exists(file))
                {
                    textBoxFileName.Text = file;
                }

                var drive = (string)key.GetValue("Drive", "");
                if (string.IsNullOrEmpty(drive))
                {
                    foreach (var cbDrive in comboBoxDrives.Items)
                    {
                        if ((string)cbDrive == drive)
                        {
                            comboBoxDrives.SelectedItem = cbDrive;
                        }
                    }
                }

                Globals.CompressionLevel = (int)key.GetValue("CompressionLevel", Globals.CompressionLevel);
                Globals.MaxBufferSize    = (int)key.GetValue("MaxBufferSize", Globals.MaxBufferSize);

                key.Close();
            }

            // Create disk object for media accesses
            var pid = Environment.OSVersion.Platform;

            if (pid == PlatformID.Unix)
            {
                _diskAccess = new LinuxDiskAccess();
            }
            else
            {
                _diskAccess = new Win32DiskAccess();
            }

            _disk = new Disk(_diskAccess);

            _disk.OnLogMsg   += _disk_OnLogMsg;
            _disk.OnProgress += _disk_OnProgress;

            // Detect insertions / removals
            _watcher.DeviceArrived += OnDriveArrived;
            _watcher.DeviceRemoved += OnDriveRemoved;
            StartListenForChanges();
        }
示例#3
0
 /// <summary>
 /// Construct Disk object with underlying platform specific disk access implementation
 /// </summary>
 /// <param name="diskAccess"></param>
 public Disk(IDiskAccess diskAccess)
 {
     _diskAccess = diskAccess;
 }
示例#4
0
 /// <summary>
 /// Construct Disk object with underlying platform specific disk access implementation
 /// </summary>
 /// <param name="diskAccess"></param>
 public Disk(IDiskAccess diskAccess)
 {
     _diskAccess = diskAccess;
 }