public override void handleUpdate(List <PackageUpdate> updates) { if (updates.Any(x => x.change == PackageChange.Names)) { hostedControl.SignalNamelistAboutToUpdate(); NamesList.ReplaceAll(Pcc.Names.Select((name, i) => new IndexedName(i, name))); //we replaceall so we don't add one by one and trigger tons of notifications hostedControl.SignalNamelistChanged(); } //Put code to reload the export here foreach (var update in updates) { if ((update.change == PackageChange.ExportAdd || update.change == PackageChange.ExportData) && update.index == LoadedExport.Index) { if (hostedControl is CurveEditor) { //CurveEditor handles its own refresh continue; } hostedControl.LoadExport(LoadedExport); //reload export return; } } }
public async Task GetNames() { if (UserLoggedIn.User != null) { using (var c = new HttpClient()) { try { c.DefaultRequestHeaders.Add("x-access-token", UserLoggedIn.Token); var response = await c.GetAsync(ConnectionLinks.UsersAddress); Debug.WriteLine(response); var content = await response.Content.ReadAsStringAsync(); NamesList = JsonConvert.DeserializeObject <ObservableCollection <User> >(content); NamesList = new ObservableCollection <User>(NamesList.OrderBy(i => i.LastName)); Debug.WriteLine(NamesList); //IsLoading = false; } catch (Exception e) { //IsLoading = false; Debug.WriteLine(e.Message); MessagingCenter.Send(this, Constants.MessagingCenter.NewRoomReservationPage.GoneWrong); } } } else { //IsLoading = false; MessagingCenter.Send(this, Constants.MessagingCenter.NewRoomReservationPage.GoneWrong); } }
/// <summary> /// Transfer a given AssemblyLineMap's contents to this one /// </summary> /// <param name="alm"></param> /// <remarks></remarks> private void Transfer(AssemblyLineMap alm) { // transfer Internal variables over this.AddressToLineMap = alm.AddressToLineMap; this.Symbols = alm.Symbols; this.Names = alm.Names; }
public bool AddName(string word) { if (string.IsNullOrEmpty(word) || _namesEtcList.Contains(word)) { return(false); } _namesEtcList.Add(word); _namesEtcListUppercase.Add(word.ToUpper()); if (_languageName.StartsWith("en_", StringComparison.Ordinal) && !word.EndsWith('s')) { _namesEtcList.Add(word + "s"); _namesEtcListUppercase.Add(word.ToUpper() + "S"); } if (!word.EndsWith('s')) { _namesEtcListWithApostrophe.Add(word + "'s"); _namesEtcListUppercase.Add(word.ToUpper() + "'S"); } if (!word.EndsWith('\'')) { _namesEtcListWithApostrophe.Add(word + "'"); } var namesList = new NamesList(Configuration.DictionariesDirectory, _languageName, Configuration.Settings.WordLists.UseOnlineNames, Configuration.Settings.WordLists.NamesUrl); namesList.Add(word); return(true); }
public PVM() { RowDictionary = DictonaryImporter.RowDictionaryProvider(); foreach (var item in RowDictionary) { NamesList.Add(item.Value.ParamName); } }
private void OnRemove() { if (SelectedName != null) { NamesList.Remove(SelectedName); SelectedName = null; } }
static void Main(string[] args) { // calls a new nameslist then both functions within Readline to keep the window open var list = new NamesList(); list.AddPeople(); list.PrintAll(); Console.ReadLine(); }
private void FindAllNames() { string language = LanguageAutoDetect.AutoDetectGoogleLanguage(_subtitle); if (string.IsNullOrEmpty(language)) { language = "en_US"; } var namesList = new NamesList(Configuration.DictionariesDirectory, language, Configuration.Settings.WordLists.UseOnlineNames, Configuration.Settings.WordLists.NamesUrl); // Will contains both one word names and multi names var namesEtcList = namesList.GetAllNames(); string text = HtmlUtil.RemoveHtmlTags(_subtitle.GetAllTexts()); string textToLower = text.ToLower(); listViewNames.BeginUpdate(); foreach (string name in namesEtcList) { int startIndex = textToLower.IndexOf(name.ToLower(), StringComparison.Ordinal); if (startIndex >= 0) { while (startIndex >= 0 && startIndex < text.Length && textToLower.Substring(startIndex).Contains(name.ToLower()) && name.Length > 1 && name != name.ToLower()) { bool startOk = (startIndex == 0) || (text[startIndex - 1] == ' ') || (text[startIndex - 1] == '-') || (text[startIndex - 1] == '"') || (text[startIndex - 1] == '\'') || (text[startIndex - 1] == '>') || (Environment.NewLine.EndsWith(text[startIndex - 1].ToString(CultureInfo.InvariantCulture))); if (startOk) { int end = startIndex + name.Length; bool endOk = end <= text.Length; if (endOk) { endOk = end == text.Length || ExpectedEndChars.Contains(text[end]); } if (endOk && text.Substring(startIndex, name.Length) != name) // do not add names where casing already is correct { if (!_usedNames.Contains(name)) { _usedNames.Add(name); AddToListViewNames(name); break; // break while } } } startIndex = textToLower.IndexOf(name.ToLower(), startIndex + 2, StringComparison.Ordinal); } } } listViewNames.EndUpdate(); groupBoxNames.Text = string.Format(Configuration.Settings.Language.ChangeCasingNames.NamesFoundInSubtitleX, listViewNames.Items.Count); }
// Use this for initialization void Start() { //PopulateCollages(); //PopulateUni(); NamesList = GetComponent <NamesList>(); NamesList.NameListResource(); Ammount = 10; PopulateMotherboard(); }
private void spawnHen() { string newName = NamesList.getNextName(); int breedn = Random.Range(0, 3); HenBreed breed = (HenBreed)breedn; spawnHen(new HenInfo(newName, breed, 0, 0, 0, 0)); }
public void NamesListNotInList() { // Arrange var namesList = new NamesList(Directory.GetCurrentDirectory(), "en", false, null); // Act var exists = namesList.GetNames().Contains("JonesASDFLKJCKJXFLKJSLDKFJASDF"); // Assert Assert.IsFalse(exists); }
public virtual void SetSampleData(NamesList names, int count) { this.Name = names.GetName(); this.ID = "10000" + count.ToString(); this.Aff = "US"; this.IsActive = GetPercentage(90); this.IsConfidential = GetPercentage(10); this.IsInternational = GetPercentage(10); this.Entry = new DateTime(_random.Next(1950, 2010), _random.Next(1, 13), _random.Next(1, 28)); this.GroupSize = 0; }
/// <summary> /// Find a container by name /// </summary> /// <param name="name">container name</param> /// <returns>Searched <see cref="ContainerNames"/> or null if thery is no container with that name</returns> public ContainerNames Find(string name) { if (NamesList.ContainsKey(name)) { return(NamesList[name]); } else { return(null); } }
protected void AddTextField(string name, string tag = null) { NamesList.Add(name); Widget widget = new TextField(); WidgetsList.Add(widget); if (tag == null) { tag = name.ToLower().Replace(' ', '_'); } FieldMap[tag] = widget; }
public void NamesListIsInNamesEtcMultiWordList() { // Arrange var namesList = new NamesList(Directory.GetCurrentDirectory(), "en", false, null); // Act namesList.Add("Charlie Parker123"); var exists = namesList.IsInNamesEtcMultiWordList("This is Charlie Parker123!", "Charlie Parker123"); // Assert Assert.IsTrue(exists); }
public void NameSelectedOnList(string name) { TypedName = name; NamesWindow.List.Close(); int classId = NamesList.GetClassId(); ClassWindow.SetListItem(classId); if (classId != 0) { ClassWindow.DisableList = true; } }
private void OnAdd() { if (!FirstName.IsNullOrEmpty() && !LastName.IsNullOrEmpty() && !NamesList.Contains(FullName)) { NamesList.Add(FullName); FirstName = null; LastName = null; } }
public void NamesListAddWord() { // Arrange var namesList = new NamesList(Directory.GetCurrentDirectory(), "en", false, null); // Act namesList.Add("Jones"); var exists = namesList.GetNames().Contains("Jones"); // Assert Assert.IsTrue(exists); }
private void MakeSureNamesListIsLoaded() { if (_namesEtcList == null) { _namesEtcList = new List <string>(); string languageTwoLetterCode = LanguageAutoDetect.AutoDetectGoogleLanguage(_subtitle); // Will contains both one word names and multi names var namesList = new NamesList(Configuration.DictionariesFolder, languageTwoLetterCode, Configuration.Settings.WordLists.UseOnlineNamesEtc, Configuration.Settings.WordLists.NamesEtcUrl); _namesEtcList = namesList.GetAllNames(); } }
public void NamesListAddMultiWord() { // Arrange var namesList = new NamesList(Directory.GetCurrentDirectory(), "en", false, null); // Act namesList.Add("Charlie Parker123"); var exists = namesList.GetMultiNames().Contains("Charlie Parker123"); // Assert Assert.IsTrue(exists); }
public void NamesListRemove() { // Arrange var namesList = new NamesList(Directory.GetCurrentDirectory(), "en", false, null); namesList.Add("Jones123"); // Act namesList.Remove("Jones123"); // Assert Assert.IsFalse(namesList.GetNames().Contains("Jones123")); }
public VM() { RowDictionary = DictonaryImporter.RowObjectDictionaryProvider(); foreach (var item in RowDictionary) { // Names list is what is showing on the window NamesList.Add(item.Value.Name); } RowParamDictionary = DictonaryImporter.RowDictionaryProvider(); foreach (var item in RowParamDictionary) { ParamNamesList.Add(item.Value.ParamName); } }
internal void FixCasing(Subtitle subtitle, string language) { var namesList = new NamesList(Configuration.DictionariesFolder, language, Configuration.Settings.WordLists.UseOnlineNamesEtc, Configuration.Settings.WordLists.NamesEtcUrl); var namesEtc = namesList.GetAllNames(); // Longer names must be first namesEtc.Sort((s1, s2) => s2.Length.CompareTo(s1.Length)); string lastLine = string.Empty; foreach (Paragraph p in subtitle.Paragraphs) { p.Text = FixCasing(p.Text, lastLine, namesEtc); // fix casing of English alone i to I if (radioButtonNormal.Checked && language.StartsWith("en") && p.Text.Contains('i')) { Match match = AloneI.Match(p.Text); while (match.Success) { if (p.Text[match.Index] == 'i') { string prev = string.Empty; string next = string.Empty; if (match.Index > 0) { prev = p.Text[match.Index - 1].ToString(CultureInfo.InvariantCulture); } if (match.Index + 1 < p.Text.Length) { next = p.Text[match.Index + 1].ToString(CultureInfo.InvariantCulture); } if (prev != ">" && next != ">") { string oldText = p.Text; p.Text = p.Text.Substring(0, match.Index) + "I"; if (match.Index + 1 < oldText.Length) { p.Text += oldText.Substring(match.Index + 1); } } } match = match.NextMatch(); } } lastLine = p.Text; } }
public override void SetSampleData(NamesList names, int count) { base.SetSampleData(names, count); this.Volume = new VolumeContainer() { BonusPeriod = 201410, Results = new List <VolumeResult>() { new VolumeResult() { BV = 131.13, PV = 140.11 } } }; }
public void Initialize(Subtitle subtitle) { _subtitle = subtitle; string language = LanguageAutoDetect.AutoDetectGoogleLanguage(_subtitle); if (string.IsNullOrEmpty(language)) { language = "en_US"; } _namesList = new NamesList(Configuration.DictionariesDirectory, language, Configuration.Settings.WordLists.UseOnlineNames, Configuration.Settings.WordLists.NamesUrl); _namesListInclMulti = _namesList.GetAllNames(); // Will contains both one word names and multi names FindAllNames(); GeneratePreview(); }
public void wineDataGridShow() { try { winesList = new NamesList(); TabControl_Wines_TabItem_WineData_Grid.ItemsSource = dataLoad <WineGrid>(new WineGrid(options), winesList); } catch (NameCollisionException exception) { System.Windows.MessageBox.Show(exception.Message); throw exception; } catch (IndexOutOfRangeException indexException) { System.Windows.MessageBox.Show("File " + options.wineSource + " is invalid. Not every data lines could be loaded.\n\n" + indexException.ToString()); } dataGridSetWidth(TabControl_Wines_TabItem_WineData_Grid, 650); }
private void OnKeyboardTextChange(string text) { TypedName = text; if (!string.IsNullOrEmpty(text)) { NamesList.UpdateListView(text); } if (NamesList.ContaisName(TypedName)) { ClassWindow.DisableList = true; ClassWindow.SetListItem(ClassList.GetSelectedClassIndex()); } else { ClassWindow.DisableList = false; ClassWindow.ClearLabel(); } }
private DataView dataLoad <T>(T dataGridType, NamesList names) where T : GridType_Parameters, GridType { DataTable table = dataGridType.columnNamesLoad(); string[] source = System.IO.File.ReadAllLines(dataGridType.dataSource, Encoding.GetEncoding("Windows-1250")); string[] row = null; foreach (string fileRow in source) { row = fileRow.Split(';'); if (!names.checkIfAlreadyExists(row[0])) { names.add(row[0]); } else { throw new NameCollisionException(true, dataGridType.dataSource, row[0]); } if (dataGridType.specialColumns) { try { row = dataGridType.convertSpecialColumns(row, codeTypes); } catch (IndexOutOfRangeException indexException) { System.Windows.MessageBox.Show(row[0] + " has invalid format: " + fileRow); throw indexException; } } table.Rows.Add(row); } DataView dv = new DataView(table); dv.Sort = dataGridType.sortMethod; return(dv); }
public static List <string> GetRandomNames(int nbNames) { if (nbNames > CurrentNamesList.names.Count) { throw new Exception("Asking for more random names than there actually are!"); } NamesList copy = new NamesList(); copy.names = new List <string>(CurrentNamesList.names); List <string> result = new List <string>(); for (int i = 0; i < nbNames; i++) { int rnd = UnityEngine.Random.Range(0, copy.names.Count); result.Add(copy.names[rnd]); copy.names.RemoveAt(rnd); } return(result); }
internal void FixCasing(Subtitle subtitle, string language) { var namesList = new NamesList(Configuration.DictionariesFolder, language, Configuration.Settings.WordLists.UseOnlineNamesEtc, Configuration.Settings.WordLists.NamesEtcUrl); var namesEtc = namesList.GetAllNames(); // Longer names must be first namesEtc.Sort((s1, s2) => s2.Length.CompareTo(s1.Length)); string lastLine = string.Empty; foreach (Paragraph p in subtitle.Paragraphs) { p.Text = FixCasing(p.Text, lastLine, namesEtc); // fix casing of English alone i to I if (radioButtonNormal.Checked && language.StartsWith("en", StringComparison.Ordinal)) { p.Text = FixEnglishAloneILowerToUpper(p.Text); } lastLine = p.Text; } }
private static Boolean KawigiEdit_RunTest(int testNum, string[] p0, int p1, Boolean hasAnswer, string p2) { Console.Write("Test " + testNum + ": [" + "{"); for (int i = 0; p0.Length > i; ++i) { if (i > 0) { Console.Write(","); } Console.Write("\"" + p0[i] + "\""); } Console.Write("}" + "," + p1); Console.WriteLine("]"); NamesList obj; string answer; obj = new NamesList(); DateTime startTime = DateTime.Now; answer = obj.popularInitial(p0, p1); DateTime endTime = DateTime.Now; Boolean res; res = true; Console.WriteLine("Time: " + (endTime - startTime).TotalSeconds + " seconds"); if (hasAnswer) { Console.WriteLine("Desired answer:"); Console.WriteLine("\t" + "\"" + p2 + "\""); } Console.WriteLine("Your answer:"); Console.WriteLine("\t" + "\"" + answer + "\""); if (hasAnswer) { res = answer == p2; } if (!res) { Console.WriteLine("DOESN'T MATCH!!!!"); } else if ((endTime - startTime).TotalSeconds >= 2) { Console.WriteLine("FAIL the timeout"); res = false; } else if (hasAnswer) { Console.WriteLine("Match :-)"); } else { Console.WriteLine("OK, but is it right?"); } Console.WriteLine(""); return res; }
private void LoadSpellingDictionariesViaDictionaryFileName(string threeLetterIsoLanguageName, CultureInfo culture, string dictionaryFileName, bool resetSkipList) { fiveLetterWordListLanguageName = Path.GetFileNameWithoutExtension(dictionaryFileName); if (fiveLetterWordListLanguageName != null && fiveLetterWordListLanguageName.Length > 5) { fiveLetterWordListLanguageName = fiveLetterWordListLanguageName.Substring(0, 5); } string dictionary = Utilities.DictionaryFolder + fiveLetterWordListLanguageName; if (resetSkipList) { wordSkipList = new HashSet<string> { Configuration.Settings.Tools.MusicSymbol, "*", "%", "#", "+", "$" }; } // Load names etc list (names/noise words) namesList = new NamesList(Configuration.DictionariesFolder, fiveLetterWordListLanguageName, Configuration.Settings.WordLists.UseOnlineNamesEtc, Configuration.Settings.WordLists.NamesEtcUrl); namesEtcList = namesList.GetNames(); namesEtcMultiWordList = namesList.GetMultiNames(); namesEtcListUppercase = new HashSet<string>(); foreach (string name in namesEtcList) { namesEtcListUppercase.Add(name.ToUpper()); } namesEtcListWithApostrophe = new HashSet<string>(); if (threeLetterIsoLanguageName.Equals("eng", StringComparison.OrdinalIgnoreCase)) { foreach (string namesItem in namesEtcList) { if (!namesItem.EndsWith('s')) { namesEtcListWithApostrophe.Add(namesItem + "'s"); } else { namesEtcListWithApostrophe.Add(namesItem + "'"); } } } // Load user words userWordList = new HashSet<string>(); userWordListXmlFileName = Utilities.LoadUserWordList(userWordList, fiveLetterWordListLanguageName); // Find abbreviations abbreviationList = new HashSet<string>(); foreach (string name in namesEtcList.Where(name => name.EndsWith('.'))) { abbreviationList.Add(name); } if (threeLetterIsoLanguageName.Equals("eng", StringComparison.OrdinalIgnoreCase)) { if (!abbreviationList.Contains("a.m.")) { abbreviationList.Add("a.m."); } if (!abbreviationList.Contains("p.m.")) { abbreviationList.Add("p.m."); } if (!abbreviationList.Contains("o.r.")) { abbreviationList.Add("o.r."); } } foreach (string name in userWordList.Where(name => name.EndsWith('.'))) { abbreviationList.Add(name); } // Load Hunspell spell checker try { if (!File.Exists(dictionary + ".dic")) { var fileMatches = Directory.GetFiles(Utilities.DictionaryFolder, fiveLetterWordListLanguageName + "*.dic"); if (fileMatches.Length > 0) { dictionary = fileMatches[0].Substring(0, fileMatches[0].Length - 4); } } if (hunspell != null) { hunspell.Dispose(); } hunspell = Hunspell.GetHunspell(dictionary); IsDictionaryLoaded = true; spellCheckDictionaryName = dictionary; DictionaryCulture = culture; } catch { IsDictionaryLoaded = false; } }
public void ProcessReply(object sender, Reply reply) { // todo maybe check parm[0] for "name" before continuing // parm 0 is always channel name on text and nickname on code?!? // not sure why we bother to test this!?! //if (reply.Params[0] != _client.Nickname) //return; // todo maybe handle text only in client and delgate codes to the domain classes switch (reply.Command) { case "JOIN" : if (reply.Params.Count <= 0 || reply.Params[0] != Name) OnJoined(new User(_client, reply.Prefix.Substring(0, reply.Prefix.IndexOf('!')))); break; case "PRIVMSG" : { if (reply.Params.Count == 0 || reply.Params[0] != Name) return; var user = new User(_client, reply.Prefix.Substring(0, reply.Prefix.IndexOf('!'))); OnMessage(new Message(user, reply.Trailing)); break; } case "QUIT" : if (reply.Params.Count <= 0 || reply.Params[0] != Name) { var user = new User(_client, reply.Prefix.Substring(0, reply.Prefix.IndexOf('!'))) { LeaveMessage = reply.Trailing }; OnParted(user); } break; } int code; if (!int.TryParse(reply.Command, out code)) return; switch ((ReplyCode) code) { case ReplyCode.RplTopic : if (reply.Params[1] != Name) return; Topic = new Topic(reply.Trailing); OnTopicChanged(); break; case ReplyCode.RplTopicSetBy: if (reply.Params[1] != Name) // not this channel return; // 0 is client nickname // todo may not use this _client.Logger("Topic set by " + reply.Params[2]); break; case ReplyCode.RplNameReply: if(_names == null) _names = new NamesList(); foreach (var user in reply.Trailing.Split().Select(name => new User(_client, name))) _names.Add(user); break; case ReplyCode.RplEndOfNames: OnNamesList(new NamesList(_names)); break; case ReplyCode.RplNoTopic: Topic = new Topic(); break; } }
private void OnNamesList(NamesList e) { EventHandler<NamesList> handler = NamesList; if (handler != null) handler(this, e); }
private void ButtonOkClick(object sender, EventArgs e) { if (string.IsNullOrWhiteSpace(textBoxAddName.Text)) { return; } NewName = textBoxAddName.Text.Trim(); string languageName = null; _language = Configuration.Settings.Language.Main; if (!string.IsNullOrEmpty(Configuration.Settings.General.SpellCheckLanguage)) { languageName = Configuration.Settings.General.SpellCheckLanguage; } else { List<string> list = Utilities.GetDictionaryLanguages(); if (list.Count > 0) { string name = list[0]; int start = name.LastIndexOf('['); int end = name.LastIndexOf(']'); if (start > 0 && end > start) { start++; name = name.Substring(start, end - start); languageName = name; } else { MessageBox.Show(string.Format(_language.InvalidLanguageNameX, name)); return; } } } languageName = Utilities.AutoDetectLanguageName(languageName, _subtitle); if (comboBoxDictionaries.Items.Count > 0) { string name = comboBoxDictionaries.SelectedItem.ToString(); int start = name.LastIndexOf('['); int end = name.LastIndexOf(']'); if (start >= 0 && end > start) { start++; name = name.Substring(start, end - start); languageName = name; } } if (string.IsNullOrEmpty(languageName)) languageName = "en_US"; var namesList = new NamesList(Configuration.DictionariesFolder, languageName, Configuration.Settings.WordLists.UseOnlineNamesEtc, Configuration.Settings.WordLists.NamesEtcUrl); if (namesList.Add(textBoxAddName.Text)) DialogResult = DialogResult.OK; else DialogResult = DialogResult.Cancel; }