private void HandleTags() { if (Tags != null && Tags.Length > 0) { foreach (var v in Tags) { var tag = v.ToLower(); if (FastCategoryMatchMap.ContainsKey(tag)) { if (FastCategoryMatchMap[tag] != null) { Category.Add(FastCategoryMatchMap[tag]); } } else { var match = L4D2Type.Match(v); if (match != null) { Category.Add(match); } FastCategoryMatchMap.Add(v, match); } } } }
private void LoadComboItem() { MainComboList.Clear(); MainComboList.Add(ComboItem.All); foreach (var v in L4D2Type.GetCategory()) { MainComboList.Add(new ComboItem(v, v)); } MainComboList.Add(ComboItem.Uncategorized); MainComboList.Add(ComboItem.IgnoreList); MainComboList.Add(ComboItem.Conflicted); SubComboList.Clear(); SubComboList.Add(ComboItem.All); MainComboBox.SelectedIndex = 0; SubComboBox.SelectedIndex = 0; MainComboBox.Items.Refresh(); SubComboBox.Items.Refresh(); }
public void LoadLocalFile(FileInfo file, bool enableVpk) { //find image foreach (var ext in ImageExtensions) { var filename = file.FullName.Replace(".vpk", '.' + ext); if (File.Exists(filename)) { ReadImageFromFile(filename); break; } } FileName = file.Name; FileSize = file.Length; if (enableVpk) { List <KeyValuePair <string, Action <L4D2Mod, SharpVPK.VpkDirectory> > > m_responces = new List <KeyValuePair <string, Action <L4D2Mod, SharpVPK.VpkDirectory> > >(); Action <string, Action <L4D2Mod, SharpVPK.VpkDirectory> > AppendResponce = (regex, responce) => m_responces.Add(new KeyValuePair <string, Action <L4D2Mod, SharpVPK.VpkDirectory> >(regex, responce)); AppendResponce(" ", HandleRoot); AppendResponce("models/prop.*", HandleProps); AppendResponce("models/infected", HandleInfected); AppendResponce("models/survivors", HandleSurvivor); AppendResponce("models/v_models", HandleModelVItem); AppendResponce(".*", HandleOthers); //deal with information from vpk or directory var vpk = new SharpVPK.VpkArchive(); vpk.Load(file.FullName); vpk.MergeDirectories(); foreach (var directory in vpk.Directories) { if (directory.Path.Length > 0) { foreach (var regex in m_responces) { if (Regex.Match(directory.Path, regex.Key).Length == directory.Path.Length) { //Logging.Log("load " + vpk.ArchivePath.Split('/').Last().Split('\\').Last() + " , directory : " + directory.Path + " matches " + regex.Key.ToString()); regex.Value.Invoke(this, directory); break; } } } } var regexHandle = new L4D2Type.RegexClassifierHandle(); //regexHandle.HandleRegex(FileName); regexHandle.HandleRegex("<title>" + Title); regexHandle.HandleRegex("<author>" + Author); foreach (var directory in vpk.Directories) { if (directory.Path.Length > 0) { foreach (var entry in directory.Entries) { var name = directory.Path + '/' + entry.Filename + '.' + entry.Extension; regexHandle.HandleRegex(name); if (regexHandle.Completed) { goto RegexEnd; } } } } RegexEnd: try { var regexResults = regexHandle.Match(); foreach (var v in regexResults) { if (FastCategoryMatchMap.ContainsKey(v)) { if (FastCategoryMatchMap[v] != null) { Category.Add(FastCategoryMatchMap[v]); } } else { var match = L4D2Type.Match(v); if (match != null) { Category.Add(match); } FastCategoryMatchMap.Add(v, match); } } } catch (L4D2Type.SyntaxError e) { Logging.Log(e.Message, "Syntax Error"); } } }