public static DriveConfiguration14 Parse(string prefix, string str) { if (str.Length < 2) { return(null); } DriveConfiguration14 config = null; string[] parts = str.Substring(2).Split(new char[] { ConfigurationSuffix14.DriveLabelSeparator }, 2); if (str[1] == ConfigurationSuffix14.DriveWithoutPrefix) { config = new DriveConfiguration14(ConfigurationSuffix14.UnescapeString(parts[0]), char.ToUpper(str[0]), (parts.Length == 2 ? ConfigurationSuffix14.UnescapeString(parts[1]) : "")); } else if (str[1] == ConfigurationSuffix14.DriveWithPrefix) { config = new DriveConfiguration14(prefix + ConfigurationSuffix14.UnescapeString(parts[0]), char.ToUpper(str[0]), (parts.Length == 2 ? ConfigurationSuffix14.UnescapeString(parts[1]) : "")); } else { return(null); } if (config.driveLetter < 'A' || config.driveLetter > 'Z') { return(null); } return(config); }
private void btnS2N_Click(object sender, EventArgs e) { QuasaroConfig14 dialog = new QuasaroConfig14(); if (dialog.ShowDialog() == DialogResult.OK) { string domain = dialog.Domain; if (!domain.StartsWith("https://", StringComparison.InvariantCultureIgnoreCase) && !domain.StartsWith("http://", StringComparison.InvariantCultureIgnoreCase) && !domain.StartsWith("\\\\", StringComparison.InvariantCultureIgnoreCase)) { domain = "https://" + domain; } if (!domain.EndsWith("/")) { domain += "/"; } DriveConfiguration14[] drives = new DriveConfiguration14[2]; drives[0] = new DriveConfiguration14(domain + "webdav/Projects", 'P', "Projects"); drives[1] = new DriveConfiguration14(domain + "webdav/My", 'M', "My"); ListViewItem[] items = new ListViewItem[drives.Length]; for (int i = 0; i < items.Length; i++) { items[i] = new ListViewItem(new string[] { drives[i].DriveLetter.ToString(), drives[i].RemoteAddress, drives[i].DriveLabel }); items[i].Tag = drives[i]; } lvwDrives.Items.AddRange(items); ConfigToSuffix(); } }
private void btnAddDrive_Click(object sender, EventArgs e) { DriveConfiguration14 drive = new DriveConfiguration14(); DriveDetails14 dialog = new DriveDetails14(drive); if (dialog.ShowDialog() == DialogResult.OK) { ListViewItem item = new ListViewItem(new string[] { drive.DriveLetter.ToString(), drive.RemoteAddress, drive.DriveLabel }); item.Tag = drive; lvwDrives.Items.Add(item); ConfigToSuffix(); } }
public DriveDetails14(DriveConfiguration14 drive) { InitializeComponent(); for (char c = 'A'; c <= 'Z'; c++) { cbxDriveLetter.Items.Add(c + ":"); } this.drive = drive; tbxRemoteAddress.Text = this.drive.RemoteAddress; cbxDriveLetter.Text = char.ToUpper(this.drive.DriveLetter) + ":"; tbxDriveLabel.Text = this.drive.DriveLabel; }
private void btnEditDrive_Click(object sender, EventArgs e) { if (lvwDrives.SelectedItems.Count == 1) { ListViewItem selected = lvwDrives.SelectedItems[0]; DriveConfiguration14 drive = (DriveConfiguration14)selected.Tag; DriveDetails14 dialog = new DriveDetails14(drive); if (dialog.ShowDialog() == DialogResult.OK) { selected.SubItems[0].Text = drive.DriveLetter.ToString(); selected.SubItems[1].Text = drive.RemoteAddress; selected.SubItems[2].Text = drive.DriveLabel; ConfigToSuffix(); } } }
public ConfigurationSuffix14(string str) : this() { // normalize suffix string if (str.StartsWith(SuffixInitiator.ToString())) { str = str.Substring(1); } if (str.StartsWith(ShowConfigSymbol.ToString())) { this.showConfigWindow = true; str = str.Substring(1); } else { this.showConfigWindow = false; } string[] parts = str.Split(SuffixSeparator); // no configuration set? if (parts.Length == 0) { return; } // save server address string prefix = UnescapeString(parts[0]); if (prefix.EndsWith(NameShorthand.ToString())) { prefix = prefix.Substring(0, prefix.Length - 1) + "/webdav/"; } if (parts.Length == 1) { return; } // parse drive configuration for (int i = 1; i < parts.Length; i++) { DriveConfiguration14 config = DriveConfiguration14.Parse(prefix, parts[i]); if (config != null) { this.drives.Add(config); } } // parse office configuration if (parts.Length > (1 + this.drives.Count)) { foreach (char c in parts[1 + this.drives.Count].ToUpper()) { if (c == 'E') { this.disableProtectedViewExcel = true; } else if (c == 'W') { this.disableProtectedViewWord = true; } else if (c == 'P') { this.disableProtectedViewPowerPoint = true; } } } }
public void RemoveDrive(DriveConfiguration14 drive) { this.drives.Remove(drive); }
public void AddDrive(DriveConfiguration14 drive) { this.drives.Add(drive); }