private static CharacterExtended GetMyCe(Character input) { CharacterExtended ce = null; var found = (from a in MainForm.OpenCharacterForms where a.CharacterObject == input select a) .FirstOrDefault(); if (found == null) { return(ce); } TabPage sinnertab = null; TabControl.TabPageCollection myCollection = null; if (found is frmCreate foundcreate) { myCollection = foundcreate.TabCharacterTabs.TabPages; } if (found is frmCareer foundcareer) { myCollection = foundcareer.TabCharacterTabs.TabPages; } if (myCollection == null) { return(ce); } foreach (TabPage tab in myCollection) { if (tab.Name == "SINners") { sinnertab = tab; break; } } if (sinnertab == null) { return(ce); } ucSINnersUserControl myUcSIN = null; foreach (ucSINnersUserControl ucSIN in sinnertab.Controls) { myUcSIN = ucSIN; break; } if (myUcSIN == null) { return(ce); } ce = myUcSIN.MyCE; return(ce); }
IEnumerable <TabPage> IPlugin.GetTabPages(frmCreate input) { ucSINnersUserControl uc = new ucSINnersUserControl(); var ce = uc.SetCharacterFrom(input); TabPage page = new TabPage("SINners"); page.Name = "SINners"; page.Controls.Add(uc); return(new List <TabPage>() { page }); }
public async Task LoadCharacter() { Settings.Default.SINnerUrl = "https://sinners.azurewebsites.net/"; Debug.WriteLine("Unit test initialized for: LoadCharacter()"); string path = AppDomain.CurrentDomain.SetupInformation.ApplicationBase; path = Path.Combine(path, "data"); DirectoryInfo d = new DirectoryInfo(path); //Assuming Test is your Folder FileInfo[] Files = d.GetFiles("*.chum5"); //Getting Text files foreach (FileInfo file in Files) { try { Debug.WriteLine("Loading: " + file.Name); using (Character c = await MainForm.LoadCharacter(file.FullName)) { if (c == null) { continue; } Debug.WriteLine("Character loaded: " + c.Name); using (CharacterShared frmCharacterForm = c.Created ? (CharacterShared) new frmCareer(c) : new frmCreate(c)) { frmCharacterForm.MdiParent = MainForm; frmCharacterForm.WindowState = FormWindowState.Minimized; frmCharacterForm.Show(); using (ucSINnersUserControl sINnersUsercontrol = new ucSINnersUserControl()) { var ce = await sINnersUsercontrol.SetCharacterFrom(frmCharacterForm); await Utils.PostSINnerAsync(ce); await Utils.UploadChummerFileAsync(ce); } frmCharacterForm.Close(); } } } catch (Exception e) { string msg = "Exception while loading " + file.FullName + ":"; msg += Environment.NewLine + e; Debug.Write(msg); throw; } } }
IEnumerable <TabPage> IPlugin.GetTabPages(frmCreate input) { ucSINnersUserControl uc = new ucSINnersUserControl(); var ce = uc.SetCharacterFrom(input); if (ce.Status == TaskStatus.Faulted) { ChummerHub.Client.Backend.Utils.HandleError(ce.Exception); return(new List <TabPage>()); } TabPage page = new TabPage("SINners"); page.Name = "SINners"; page.Controls.Add(uc); return(new List <TabPage>() { page }); }
IEnumerable <TabPage> IPlugin.GetTabPages(frmCareer input) { if (ChummerHub.Client.Properties.Settings.Default.UserModeRegistered == false) { return(null); } ucSINnersUserControl uc = new ucSINnersUserControl(); var ce = uc.SetCharacterFrom(input); if (ce.Status == TaskStatus.Faulted) { ChummerHub.Client.Backend.Utils.HandleError(ce.Exception); return(new List <TabPage>()); } TabPage page = new TabPage("SINners"); page.Name = "SINners"; page.Controls.Add(uc); return(new List <TabPage>() { page }); }
private static CharacterExtended GetMyCe(Character input) { CharacterShared found = null; if (MainForm?.OpenCharacterForms != null) { foreach (CharacterShared a in (MainForm?.OpenCharacterForms)) { if (a?.CharacterObject != input) { continue; } found = a; break; } } if (found == null) { return(null); } TabPage sinnertab = null; TabControl.TabPageCollection myCollection = null; switch (found) { case frmCreate foundcreate: myCollection = foundcreate.TabCharacterTabs.TabPages; break; case frmCareer foundcareer: myCollection = foundcareer.TabCharacterTabs.TabPages; break; } if (myCollection == null) { return(null); } foreach (TabPage tab in myCollection) { if (tab.Name == "SINners") { sinnertab = tab; break; } } CharacterExtended ce; if (sinnertab == null) { ce = new CharacterExtended(input, null); } else { ucSINnersUserControl myUcSIN = null; foreach (ucSINnersUserControl ucSIN in sinnertab.Controls) { myUcSIN = ucSIN; break; } ce = myUcSIN == null ? new CharacterExtended(input, null) : myUcSIN.MyCE; } return(ce); }
public async Task LoadCharacter() { Properties.Settings.Default.SINnerUrl = "https://sinners.azurewebsites.net/"; Debug.WriteLine("Unit test initialized for: LoadCharacter()"); string path = AppDomain.CurrentDomain.SetupInformation.ApplicationBase; if (MainForm == null) { MainForm = new frmChummerMain(true); } path = System.IO.Path.Combine(path, "data"); DirectoryInfo d = new DirectoryInfo(path); //Assuming Test is your Folder FileInfo[] Files = d.GetFiles("*.chum5"); //Getting Text files foreach (FileInfo file in Files) { try { Debug.WriteLine("Loading: " + file.Name); Character c = await MainForm.LoadCharacter(file.FullName); if (c == null) { continue; } Debug.WriteLine("Character loaded: " + c.Name); if (c.Created) { using (frmCareer career = new frmCareer(c)) { career.Show(); ucSINnersUserControl sINnersUsercontrol = new ucSINnersUserControl(); var ce = await sINnersUsercontrol.SetCharacterFrom(career); await ChummerHub.Client.Backend.Utils.PostSINnerAsync(ce); await ChummerHub.Client.Backend.Utils.UploadChummerFileAsync(ce); career.Hide(); career.Dispose(); } } else { using (frmCreate create = new frmCreate(c)) { create.Show(); ucSINnersUserControl sINnersUsercontrol = new ucSINnersUserControl(); var ce = await sINnersUsercontrol.SetCharacterFrom(create); await ChummerHub.Client.Backend.Utils.PostSINnerAsync(ce); await ChummerHub.Client.Backend.Utils.UploadChummerFileAsync(ce); create.Hide(); create.Dispose(); } } } catch (Exception e) { string msg = "Exception while loading " + file.FullName + ":"; msg += Environment.NewLine + e.ToString(); Debug.Write(msg); throw; } } }