示例#1
0
 public void Test_FileWithOptions_Read_01()
 {
     var x = new FileWithOptions(@"/readonly/E:\Virtual Disks\Install.vhd");
     Assert.AreEqual(@"E:\Virtual Disks\Install.vhd", x.FileName );
     Assert.AreEqual(true, x.ReadOnly);
     Assert.AreEqual(false, x.NoDriveLetter);
 }
示例#2
0
 public void Test_FileWithOptions_Read_02()
 {
     var x = new FileWithOptions(@"E:\Virtual Disks\Floppy.vhd");
     Assert.AreEqual(@"E:\Virtual Disks\Floppy.vhd", x.FileName);
     Assert.AreEqual(false, x.ReadOnly);
     Assert.AreEqual(false, x.NoDriveLetter);
 }
示例#3
0
        public string GetSettingFileName()
        {
            var fwo = new FileWithOptions(this.FileName);

            fwo.ReadOnly      = this.IsReadOnly;
            fwo.NoDriveLetter = this.HasNoDriveLetter;
            return(fwo.ToString());
        }
        public void Test_FileWithOptions_Read_02()
        {
            var x = new FileWithOptions(@"E:\Virtual Disks\Floppy.vhd");

            Assert.AreEqual(@"E:\Virtual Disks\Floppy.vhd", x.FileName);
            Assert.AreEqual(false, x.ReadOnly);
            Assert.AreEqual(false, x.NoDriveLetter);
        }
        public void Test_FileWithOptions_Read_01()
        {
            var x = new FileWithOptions(@"/readonly/E:\Virtual Disks\Install.vhd");

            Assert.AreEqual(@"E:\Virtual Disks\Install.vhd", x.FileName);
            Assert.AreEqual(true, x.ReadOnly);
            Assert.AreEqual(false, x.NoDriveLetter);
        }
示例#6
0
 public void Test_FileWithOptions_Write_01()
 {
     var x = new FileWithOptions("Test.vhd");
     x.ReadOnly = true;
     Assert.AreEqual("Test.vhd", x.FileName);
     Assert.AreEqual(true, x.ReadOnly);
     Assert.AreEqual(false, x.NoDriveLetter);
     Assert.AreEqual("/readonly/Test.vhd", x.ToString());
 }
        public void Test_FileWithOptions_Write_01()
        {
            var x = new FileWithOptions("Test.vhd");

            x.ReadOnly = true;
            Assert.AreEqual("Test.vhd", x.FileName);
            Assert.AreEqual(true, x.ReadOnly);
            Assert.AreEqual(false, x.NoDriveLetter);
            Assert.AreEqual("/readonly/Test.vhd", x.ToString());
        }
示例#8
0
        public ListViewVhdItem(FileWithOptions fwo)
        {
            this.FileName         = fwo.FileName;
            this.IsReadOnly       = fwo.ReadOnly;
            this.HasNoDriveLetter = fwo.NoDriveLetter;

            try {
                var file = new FileInfo(this.FileName);
                base.Text = file.Name;

                try {
                    if (file.Exists)
                    {
                        if (file.IsReadOnly)
                        {
                            this.ToolTipText = "File is read-only." + Environment.NewLine + this.FileName;
                            this.ImageIndex  = 1;
                        }
                        else
                        {
                            this.ToolTipText = this.FileName;
                            this.ImageIndex  = (this.IsReadOnly) ? 4 : 0;
                        }
                    }
                    else
                    {
                        this.ToolTipText = "File not found." + Environment.NewLine + this.FileName;
                        this.ImageIndex  = 2;
                    }
                } catch (Exception ex) {
                    this.ToolTipText = ex.Message + Environment.NewLine + this.FileName;
                    this.ImageIndex  = 3;
                }
            } catch (ArgumentException) {
                var segments = this.FileName.Split(new char[] { Path.DirectorySeparatorChar, Path.AltDirectorySeparatorChar }, StringSplitOptions.RemoveEmptyEntries);
                if (segments.Length > 0)
                {
                    base.Text = segments[segments.Length - 1];
                }
                else
                {
                    base.Text = this.FileName;
                }
                this.ToolTipText = "Cannot parse file name \"" + this.FileName + "\"";
                this.ImageIndex  = 3;
            }
        }
示例#9
0
        public ListViewVhdItem(FileWithOptions fwo)
        {
            this.FileName = fwo.FileName;
            this.IsReadOnly = fwo.ReadOnly;
            this.HasNoDriveLetter = fwo.NoDriveLetter;

            try {
                var file = new FileInfo(this.FileName);
                base.Text = file.Name;

                try {
                    if (file.Exists) {
                        if (file.IsReadOnly) {
                            this.ToolTipText = "File is read-only." + Environment.NewLine + this.FileName;
                            this.ImageIndex = 1;
                        } else {
                            this.ToolTipText = this.FileName;
                            this.ImageIndex = (this.IsReadOnly) ? 4 : 0;
                        }
                    } else {
                        this.ToolTipText = "File not found." + Environment.NewLine + this.FileName;
                        this.ImageIndex = 2;
                    }
                } catch (Exception ex) {
                    this.ToolTipText = ex.Message + Environment.NewLine + this.FileName;
                    this.ImageIndex = 3;
                }
            } catch (ArgumentException) {
                var segments = this.FileName.Split(new char[] { Path.DirectorySeparatorChar, Path.AltDirectorySeparatorChar }, StringSplitOptions.RemoveEmptyEntries);
                if (segments.Length > 0) {
                    base.Text = segments[segments.Length - 1];
                } else {
                    base.Text = this.FileName;
                }
                this.ToolTipText = "Cannot parse file name \"" + this.FileName + "\"";
                this.ImageIndex = 3;
            }
        }
示例#10
0
 public string GetSettingFileName()
 {
     var fwo = new FileWithOptions(this.FileName);
     fwo.ReadOnly = this.IsReadOnly;
     fwo.NoDriveLetter = this.HasNoDriveLetter;
     return fwo.ToString();
 }