private void ShowFeatsFragment() { if (!Feat.FeatsLoaded) { if (!_LoadingFragment) { _LoadingFragment = true; _ProgressDialog = new ProgressDialog(this, (int)ProgressDialogStyle.Spinner); _ProgressDialog.SetCanceledOnTouchOutside(false); _ProgressDialog.SetMessage("Loading"); _ProgressDialog.Show(); Thread t = new Thread(() => { Feat.LoadFeats(); RunOnUiThread(() => { _LoadingFragment = false; _ProgressDialog.Dismiss(); FinishShowFeatsFragment(); }); }); t.Start(); } } else { FinishShowFeatsFragment(); } }
public addNewAncestryWindow() { InitializeComponent(); feats = Feat.LoadFeats("Class Feat"); lstAvailableFeats.ItemsSource = feats; lstSelectedFeats.ItemsSource = selectedFeats; }
public addNewFeatWindow() { InitializeComponent(); feats = new List <Feat>(); feats = Feat.LoadFeats(); listBoxFeats.ItemsSource = feats; }
public addNewBackground() { InitializeComponent(); feats = Feat.LoadFeats(); lstAvailableFeats.ItemsSource = feats; lstSelectedFeats.ItemsSource = selectedFeats; skills = Skill.FillSkillList(); //can this be done with a list? fillSkillListBox(SkillsGrid); }
//TODO save and add are very similar, they could probably be made one function and take a query string as a parameter private void SaveButton_Click(object sender, RoutedEventArgs e) { int lvl = int.Parse(txtLevel.Text);//TODO error checking TextRange textRange = new TextRange(TextBoxDescription.Document.ContentStart, TextBoxDescription.Document.ContentEnd); string query = "Update Feats set feat_level=@lvl,feat_name=@name,feat_type=@type,feat_description=@description where id_feat=@id;"; SQLiteConnection conn = new SQLiteConnection(Properties.Settings.Default.ConnectionString); conn.Open(); SQLiteCommand cmd = new SQLiteCommand(query, conn); cmd.Parameters.AddWithValue("@lvl", lvl); cmd.Parameters.AddWithValue("@name", FeatNameTextBox.Text); cmd.Parameters.AddWithValue("@type", FeatTypeComboBox.Text); cmd.Parameters.AddWithValue("@description", textRange.Text); conn.Close(); feats = Feat.LoadFeats(); listBoxFeats.ItemsSource = feats; }
private void button2_Click_1(object sender, RoutedEventArgs e) { Feat.LoadFeats(); StreamReader str = new StreamReader("NewFeat.txt"); String bigText = str.ReadToEnd(); List <Feat> feats = new List <Feat>(); bigText = Regex.Replace(bigText, "(\\<a href[^\\>]+>)|(\\</a\\>)|\\</?i\\>", delegate(Match asd) { return(""); }); bigText = Regex.Replace(bigText, " ?\\<br/\\>", "\r\n"); bigText = Regex.Replace(bigText, "–", "-"); Regex x = new Regex("\\<h2 id\\=\"[-\\p{L}0-9()]+\"\\>(?<name>[-\\p{L} '0-9]+)( \\((?<type>[^)]+)\\))?\\</h2\\>[ \\t\\r\\n]*" + "\\<p\\>(?<short>([^\\<]|\\</?i\\>)+)\\</p\\>[ \\t\\r\\n]*" + "(\\<p\\>\\<b\\>Prerequisites?\\</b\\>: (?<prereq>[^\\<]+)\\</p\\>[ \\t\\r\\n]*)?" + "(\\<p\\>\\<b\\>Benefits?\\</b\\>: (?<benefit>[^\\<]+)\\</p\\>[ \\t\\r\\n]*)?" + "(?<beneextra>(\\<p\\>([^\\<]|\\</?i\\>)+\\</p\\>[ \\t\\r\\n]*)+)?" + "(\\<p\\>\\<b\\>Special\\</b\\>: (?<special>[^\\<]+)\\</p\\>[ \\t\\r\\n]*)?" + "(\\<p id=\"normal\"\\>\\<b\\>Normal\\</b\\>: (?<normal>[^\\<]+)\\</p\\>[ \\t\\r\\n]*)?" + "(\\<p id=\"note\"\\>\\<b\\>Note\\</b\\>: (?<note>[^\\<]+)\\</p\\>[ \\t\\r\\n]*)?" + ""); Match m = x.Match(bigText); int count = 0; int prereq = 0; int bene = 0; int beneextra = 0; int special = 0; int normal = 0; int note = 0; while (m.Success) { count++; if (m.Groups["prereq"].Success) { prereq++; } if (m.Groups["benefit"].Success) { bene++; } else { System.Diagnostics.Debug.WriteLine(m.Groups["name"]); } if (m.Groups["beneextra"].Success) { beneextra++; } if (m.Groups["special"].Success) { special++; } if (m.Groups["normal"].Success) { normal++; } if (m.Groups["note"].Success) { note++; } Feat f = new Feat(); f.Name = m.Value("name"); f.Summary = m.Value("short"); string benefitText = m.Value("benefit").Trim(); if (m.GroupSuccess("beneextra")) { string bx = m.Value("beneextra"); bx = Regex.Replace(bx, "\\<p\\>", "\r\n"); bx = Regex.Replace(bx, "\t|\\</p\\>", ""); benefitText += bx; } if (m.GroupSuccess("note")) { benefitText += "\r\nNote: " + m.Value("note"); } benefitText = Regex.Replace(benefitText, "( )|(\\t)", ""); benefitText = benefitText.Trim(new char[] { '\r', '\n', ' ', '\t' }); benefitText = Regex.Replace(benefitText, "(\\r\\n)*\\r\\n", "\r\n\r\n"); f.Benefit = benefitText; f.Normal = m.Value("normal"); f.Special = m.Value("special"); f.Prerequistites = m.Value("prereq"); if (m.GroupSuccess("type")) { f.Type = m.Value("type"); } else { f.Type = "General"; } f.Source = "APG"; string name = m.Groups["name"].Value; if (!Feat.FeatMap.ContainsKey(name)) { System.Diagnostics.Debug.WriteLine(name); feats.Add(f); } m = m.NextMatch(); } XmlListLoader <Feat> .Save(feats, "NewFeats.xml"); MessageBox.Show(count.ToString() + "\r\npre: " + prereq + "\r\nbene: " + bene + "\r\nextra: " + beneextra + "\r\nspecial: " + special + "\r\nnormal: " + normal + "\r\nnote: " + note); }