void SetSelectedItemUpdateMethod(UpdateMethod method) { var items = SelectedItems.Cast<ListViewItem>().Where(s => GetFileUpdateMethod(((KeyValuePair<string, FileInfo>)s.Tag).Key) != method).ToArray(); if (items.Length == 0) return; var group = Groups[(int)method]; var project = UpdatePackageBuilder.Instance.AuProject; var verifyLevel = FileVerificationLevel.Hash | FileVerificationLevel.Size | FileVerificationLevel.Version; if (method == UpdateMethod.VersionCompare) { var dlg = new Dialogs.SelectVerificationLevel() { FileVerificationLevel = verifyLevel }; if (dlg.ShowDialog() != DialogResult.OK) return; verifyLevel = dlg.FileVerificationLevel; if ((verifyLevel & FileVerificationLevel.Version) != FileVerificationLevel.None && items.Any(s => _versions[((KeyValuePair<string, FileInfo>)s.Tag).Key].IsIllegal()) && MessageBox.Show("您已经选择版本比较选项,但当前选择的文件中有一个或多个无法识别出有效的版本(主版本号为0),是否确认继续?", "警告", MessageBoxButtons.YesNo, MessageBoxIcon.Exclamation) != DialogResult.Yes ) { return; } } foreach (var item in items) { var tag = (KeyValuePair<string, FileInfo>)item.Tag; var path = tag.Key; if (GetFileUpdateMethod(path) == method) continue; item.Group = group; //处理更新方式 if (method != UpdateMethod.VersionCompare && _verifyLevels.ContainsKey(path)) { _verifyLevels.Remove(path); } if (method == UpdateMethod.Always) { if (_updateMethods.ContainsKey(path)) _updateMethods.Remove(path); } else { if (_updateMethods.ContainsKey(path)) _updateMethods[path] = method; else _updateMethods.Add(path, method); } if (method == UpdateMethod.VersionCompare) { if (_verifyLevels.ContainsKey(path)) _verifyLevels[path] = verifyLevel; else _verifyLevels.Add(path, verifyLevel); } UpdateVerificationLevelDesc(item); //处理包项目 var pi = project.Files.FirstOrDefault(s => string.Compare(s.Path, path, true) == 0); if (pi == null) { pi = new ProjectItem(); pi.Path = path; project.Files.Add(pi); } pi.UpdateMethod = method; pi.FileVerificationLevel = verifyLevel; } AutoResizeColumns(ColumnHeaderAutoResizeStyle.ColumnContent); }
void ChangeState(UpdateMethod method, FileVerificationLevel level) { var proj = UpdatePackageBuilder.Instance.AuProject; if (proj == null) return; if (method == UpdateMethod.AsProject) { //跟随项目,则删除 var pi = proj.FindProjectItem(RelativePath); if (pi != null) proj.Files.Remove(pi); } else { var pi = proj.FindProjectItem(RelativePath); if (pi == null) { pi = new ProjectItem() { Path = RelativePath }; proj.Files.Add(pi); } pi.FileVerificationLevel = level; pi.UpdateMethod = method; } }