async void LoadAccountsIntoPicker() { AccountManagement.AccountManager accountManger = new AccountManagement.AccountManager(); var activeAccount = await accountManager.GetActiveAccountAsync(); if (activeAccount == null) { await Navigation.PushModalAsync(new LacunaExpress.Pages.AccountPages.Login()); } }
async Task <bool> LoadMessagesAsync(string category) { var acntMgr = new AccountManagement.AccountManager(); account = await acntMgr.GetActiveAccountAsync(); if (account == null) { await Navigation.PushAsync(new Login()); return(false); } else { messageList.Clear(); string json; switch (category) { case "All": json = Inbox.ViewInbox(account.SessionID); break; case "Sent": json = Inbox.ViewSent(account.SessionID); break; case "Trashed": json = Inbox.ViewTrash(account.SessionID); break; case "Archived": json = Inbox.ViewArchive(account.SessionID); break; default: json = Inbox.ViewInbox(account.SessionID, category); break; } try { var s = new Server(); var response = await s.GetHttpResultAsync(account.Server, Inbox.url, json); foreach (var m in response.result.messages) { messageList.Add(new MessageData(m.from, m.subject, m.body_preview, m.id.ToString())); } } catch (Exception e) { var f = e.Message; } } return(true); }
async void GetActiveAccount() { var accm = new AccountManagement.AccountManager(); activeAccount = await accm.GetActiveAccountAsync(); if (activeAccount == null) { await Navigation.PushModalAsync(new Login()); //GetActiveAccount(); } }
async Task <AccountModel> GetActiveAccountAsync() { var accm = new AccountManagement.AccountManager(); var account = await accm.GetActiveAccountAsync(); if (account == null) { await Navigation.PushModalAsync(new Login()); account = await GetActiveAccountAsync(); } return(account); }
public StationsMain() { var mainLayout = new StackLayout { BackgroundColor = Color.FromRgb(0, 0, 128), Children = { pickerLabel, stationPicker, viewStation, parliamentBtn } }; Content = mainLayout; if (Device.OS == TargetPlatform.iOS) { mainLayout.Padding = new Thickness(0, 20, 0, 0); } this.Appearing += async(sender, e) => { AccountManagement.AccountManager accountMngr = new AccountManagement.AccountManager(); activeAccount = await accountMngr.GetActiveAccountAsync(); var stationNames = activeAccount.Stations.Values.ToList(); stationNames.Sort(); foreach (var s in stationNames) { stationPicker.Items.Add(s); } }; viewStation.IsVisible = false; parliamentBtn.IsVisible = false; stationPicker.SelectedIndexChanged += (sender, e) => { selectedStation = stationPicker.Items[stationPicker.SelectedIndex]; ActivateButtons(); }; viewStation.Clicked += async(sender, e) => { await Navigation.PushAsync(new StationBuildings(activeAccount, selectedStation)); }; parliamentBtn.Clicked += async(sender, e) => { if (activeAccount.Stations.Count > 0) { await Navigation.PushAsync(new Parliament(activeAccount, selectedStation)); } }; }
async void LoadAccountsIntoPicker() { AccountManagement.AccountManager accountManger = new AccountManagement.AccountManager(); accounts = await accountManager.LoadAccountsAsync(); selectedAccount = await accountManager.GetActiveAccountAsync(); if (accounts != null) { foreach (var a in accounts.AccountList) accountPicker.Items.Add(a.DisplayName); } else { await Navigation.PushModalAsync(new LacunaExpress.Pages.AccountPages.Login()); } }
public StationsMain() { var mainLayout = new StackLayout { BackgroundColor = Color.FromRgb (0, 0, 128), Children = { pickerLabel, stationPicker, viewStation, parliamentBtn } }; Content = mainLayout; if (Device.OS == TargetPlatform.iOS) { mainLayout.Padding = new Thickness (0, 20, 0, 0); } this.Appearing += async (sender, e) => { AccountManagement.AccountManager accountMngr = new AccountManagement.AccountManager(); activeAccount = await accountMngr.GetActiveAccountAsync(); var stationNames = activeAccount.Stations.Values.ToList(); stationNames.Sort(); foreach (var s in stationNames) { stationPicker.Items.Add(s); } }; viewStation.IsVisible = false; parliamentBtn.IsVisible = false; stationPicker.SelectedIndexChanged += (sender, e) => { selectedStation = stationPicker.Items[stationPicker.SelectedIndex]; ActivateButtons(); }; viewStation.Clicked += async (sender, e) => { await Navigation.PushAsync(new StationBuildings(activeAccount, selectedStation)); }; parliamentBtn.Clicked += async (sender, e) => { if(activeAccount.Stations.Count >0) await Navigation.PushAsync(new Parliament(activeAccount, selectedStation)); }; }
async Task<bool> LoadMessagesAsync(string category) { var acntMgr = new AccountManagement.AccountManager(); account = await acntMgr.GetActiveAccountAsync(); if (account == null) { await Navigation.PushAsync(new Login()); return false; } else { messageList.Clear(); string json; switch (category) { case "All": json = Inbox.ViewInbox(account.SessionID); break; case "Sent": json = Inbox.ViewSent(account.SessionID); break; case "Trashed": json = Inbox.ViewTrash(account.SessionID); break; case "Archived": json = Inbox.ViewArchive(account.SessionID); break; default: json = Inbox.ViewInbox(account.SessionID, category); break; } try { var s = new Server(); var response = await s.GetHttpResultAsync(account.Server, Inbox.url, json); foreach (var m in response.result.messages) messageList.Add(new MessageData(m.from, m.subject, m.body_preview, m.id.ToString())); } catch (Exception e) { var f = e.Message; } } return true; }
async void LoadAccountsIntoPicker() { AccountManagement.AccountManager accountManger = new AccountManagement.AccountManager(); accounts = await accountManager.LoadAccountsAsync(); selectedAccount = await accountManager.GetActiveAccountAsync(); if (accounts != null) { foreach (var a in accounts.AccountList) { accountPicker.Items.Add(a.DisplayName); } } else { await Navigation.PushModalAsync(new LacunaExpress.Pages.AccountPages.Login()); } }
public MapMain() { Resources = Styles.Styles.StyleDictionary; Button cacheStarMapBtn = new Button { Text = "Cache Map", Style = (Style)Styles.Styles.StyleDictionary[Styles.Styles.StyleName.RegularButton.ToString()] //TextColor = Color.White, //BorderWidth = 2, //BorderColor = Color.White, //BackgroundColor = Color.Blue, //FontAttributes = FontAttributes.Bold }; var mainLayout = new StackLayout { BackgroundColor = Color.FromRgb(0, 0, 128), Children = { cacheStarMapBtn } }; Content = mainLayout; if (Device.OS == TargetPlatform.iOS) { mainLayout.Padding = new Thickness(0, 20, 0, 0); } this.Appearing += async(sender, e) => { AccountManagement.AccountManager accountMngr = new AccountManagement.AccountManager(); activeAccount = await accountMngr.GetActiveAccountAsync(); }; cacheStarMapBtn.Clicked += async(sender, e) => { var s = await MapScripts.GetAllStarsInRange300(activeAccount, 0, 0); Data.FileStorage.SaveStarsAsync(s); }; }
public MapMain() { Resources = Styles.Styles.StyleDictionary; Button cacheStarMapBtn = new Button { Text = "Cache Map", Style = (Style)Styles.Styles.StyleDictionary[Styles.Styles.StyleName.RegularButton.ToString()] //TextColor = Color.White, //BorderWidth = 2, //BorderColor = Color.White, //BackgroundColor = Color.Blue, //FontAttributes = FontAttributes.Bold }; var mainLayout = new StackLayout { BackgroundColor = Color.FromRgb (0, 0, 128), Children = { cacheStarMapBtn } }; Content = mainLayout; if (Device.OS == TargetPlatform.iOS) { mainLayout.Padding = new Thickness (0, 20, 0, 0); } this.Appearing += async (sender, e) => { AccountManagement.AccountManager accountMngr = new AccountManagement.AccountManager(); activeAccount = await accountMngr.GetActiveAccountAsync(); }; cacheStarMapBtn.Clicked += async (sender, e) => { var s = await MapScripts.GetAllStarsInRange300(activeAccount, 0, 0); Data.FileStorage.SaveStarsAsync(s); }; }
public Login() { //This gets the styles Dictionary and sets it on this page. Resources = Styles.Styles.StyleDictionary; BoxView topheader = new BoxView { VerticalOptions = LayoutOptions.StartAndExpand }; #region controls Entry Username = new Entry() { Placeholder = "Empire Name", Style = (Style)Styles.Styles.StyleDictionary[Styles.Styles.StyleName.EntryStyle.ToString()] }; Entry Password = new Entry() { Placeholder = "Pass Code", Style = (Style)Styles.Styles.StyleDictionary[Styles.Styles.StyleName.EntryStyle.ToString()] }; Label ServerTitle = new Label() { VerticalOptions = LayoutOptions.Center, Text = "Server", Style = (Style)Styles.Styles.StyleDictionary[Styles.Styles.StyleName.TitleLabel.ToString()], }; Label Serverlbl = new Label() { Text = "https://us1.lacunaexpanse.com", TextColor = Color.Gray, FontAttributes = FontAttributes.Italic, }; Label Usernamelbl = new Label() { VerticalOptions = LayoutOptions.Center, Text = "Empire Name", Style = (Style)Styles.Styles.StyleDictionary[Styles.Styles.StyleName.TitleLabel.ToString()], }; Label Passwordlbl = new Label() { Text = "Password", Style = (Style)Styles.Styles.StyleDictionary[Styles.Styles.StyleName.TitleLabel.ToString()], }; Label Resultlbl = new Label() { Text = "" }; Button Submit = new Button() { VerticalOptions = LayoutOptions.EndAndExpand, Text = "Submit", Style = (Style)Styles.Styles.StyleDictionary[Styles.Styles.StyleName.RegularButton.ToString()] }; StackLayout switchLayout = new StackLayout { Orientation = StackOrientation.Horizontal }; Label activeLbl = new Label { Text = "Make Account Primary", Style = (Style)Styles.Styles.StyleDictionary[Styles.Styles.StyleName.TitleLabel.ToString()], }; Switch activeSwitch = new Switch { IsToggled = false }; #endregion switchLayout.Children.Add(activeLbl); switchLayout.Children.Add(activeSwitch); var mainLayout = new StackLayout { Padding = new Thickness(6, 6, 6, 6), BackgroundColor = Color.FromRgb(0, 0, 128), Children = { topheader, Usernamelbl, Username, Passwordlbl, Password, Serverlbl, switchLayout, Submit, Resultlbl } }; Content = mainLayout; if (Device.OS == TargetPlatform.iOS) { mainLayout.Padding = new Thickness(0, 20, 0, 0); } Submit.Clicked += async(sender, e) => { activeSwitch.IsEnabled = false; Submit.IsEnabled = false; var aMgr = new AccountManagement.AccountManager(); var status = await aMgr.CreateAndAddAccountAsync(Username.Text, Password.Text, Serverlbl.Text, activeSwitch.IsToggled); if (status) { //await Navigation.PushAsync(new MessageList()); await Navigation.PopModalAsync(); } else { Resultlbl.Text = "Request Failed, try again"; } activeSwitch.IsEnabled = true; Submit.IsEnabled = true; }; }
public PlanetMenu() { var mainLayout = new StackLayout { BackgroundColor = Color.FromRgb (0, 0, 128), Children = { planetPicker, spyOptions, shipOptions, buildingOptions, // tradeOptions, buildingsBtn, planetMapBtn } }; Content = mainLayout; if (Device.OS == TargetPlatform.iOS) { mainLayout.Padding = new Thickness (0, 20, 0, 0); } this.Appearing += async (sender, e) => { AccountManagement.AccountManager accountMngr = new AccountManagement.AccountManager(); activeAccount = await accountMngr.GetActiveAccountAsync(); selectedPlanet = activeAccount.Capital; var plist = activeAccount.Colonies.Values.ToList(); plist.Sort(); foreach (var p in plist) { planetPicker.Items.Add(p); } planetPicker.SelectedIndex = planetPicker.Items.IndexOf(selectedPlanet); }; planetPicker.SelectedIndexChanged += async (sender, e) => { selectedPlanet = planetPicker.Items[planetPicker.SelectedIndex]; }; buildingsBtn.Clicked += async (sender, e) => { await Navigation.PushAsync(new PlanetBuildings(activeAccount, selectedPlanet)); }; spyOptions.Clicked += async (sender, e) => { await Navigation.PushAsync(new SpiesMain(activeAccount, selectedPlanet)); }; buildingOptions.Clicked += async (sender, e) => { await Navigation.PushAsync(new BuildingToolsView(activeAccount, selectedPlanet)); }; shipOptions.Clicked += async (sender, e) => { await Navigation.PushAsync(new ShipTools(activeAccount, selectedPlanet)); }; planetMapBtn.Clicked += async (sender, e) => { await Navigation.PushAsync(new PlanetMap(activeAccount, selectedPlanet)); }; }
public Login() { //This gets the styles Dictionary and sets it on this page. Resources = Styles.Styles.StyleDictionary; BoxView topheader = new BoxView { VerticalOptions = LayoutOptions.StartAndExpand }; #region controls Entry Username = new Entry() { Placeholder = "Empire Name", Style = (Style)Styles.Styles.StyleDictionary[Styles.Styles.StyleName.EntryStyle.ToString()] }; Entry Password = new Entry() { Placeholder = "Pass Code", Style = (Style)Styles.Styles.StyleDictionary[Styles.Styles.StyleName.EntryStyle.ToString()] }; Label ServerTitle = new Label() { VerticalOptions = LayoutOptions.Center, Text = "Server", Style = (Style)Styles.Styles.StyleDictionary[Styles.Styles.StyleName.TitleLabel.ToString()], }; Label Serverlbl = new Label() { Text = "https://us1.lacunaexpanse.com", TextColor = Color.Gray, FontAttributes = FontAttributes.Italic, }; Label Usernamelbl = new Label() { VerticalOptions = LayoutOptions.Center, Text = "Empire Name", Style = (Style)Styles.Styles.StyleDictionary[Styles.Styles.StyleName.TitleLabel.ToString()], }; Label Passwordlbl = new Label() { Text = "Password", Style = (Style)Styles.Styles.StyleDictionary[Styles.Styles.StyleName.TitleLabel.ToString()], }; Label Resultlbl = new Label() { Text = "" }; Button Submit = new Button() { VerticalOptions = LayoutOptions.EndAndExpand, Text = "Submit", Style = (Style)Styles.Styles.StyleDictionary[Styles.Styles.StyleName.RegularButton.ToString()] }; StackLayout switchLayout = new StackLayout { Orientation = StackOrientation.Horizontal }; Label activeLbl = new Label { Text = "Make Account Primary", Style = (Style)Styles.Styles.StyleDictionary[Styles.Styles.StyleName.TitleLabel.ToString()], }; Switch activeSwitch = new Switch { IsToggled = false }; #endregion switchLayout.Children.Add(activeLbl); switchLayout.Children.Add(activeSwitch); var mainLayout = new StackLayout { Padding = new Thickness(6, 6, 6, 6), BackgroundColor = Color.FromRgb (0, 0, 128), Children = { topheader, Usernamelbl, Username, Passwordlbl, Password, Serverlbl, switchLayout, Submit, Resultlbl } }; Content = mainLayout; if (Device.OS == TargetPlatform.iOS) { mainLayout.Padding = new Thickness (0, 20, 0, 0); } Submit.Clicked += async (sender, e) => { activeSwitch.IsEnabled = false; Submit.IsEnabled = false; var aMgr = new AccountManagement.AccountManager(); var status = await aMgr.CreateAndAddAccountAsync(Username.Text, Password.Text, Serverlbl.Text, activeSwitch.IsToggled); if (status) { //await Navigation.PushAsync(new MessageList()); await Navigation.PopModalAsync(); } else Resultlbl.Text = "Request Failed, try again"; activeSwitch.IsEnabled = true; Submit.IsEnabled = true; }; }
public PlanetMenu() { var mainLayout = new StackLayout { BackgroundColor = Color.FromRgb(0, 0, 128), Children = { planetPicker, spyOptions, shipOptions, buildingOptions, // tradeOptions, buildingsBtn, planetMapBtn } }; Content = mainLayout; if (Device.OS == TargetPlatform.iOS) { mainLayout.Padding = new Thickness(0, 20, 0, 0); } this.Appearing += async(sender, e) => { AccountManagement.AccountManager accountMngr = new AccountManagement.AccountManager(); activeAccount = await accountMngr.GetActiveAccountAsync(); selectedPlanet = activeAccount.Capital; var plist = activeAccount.Colonies.Values.ToList(); plist.Sort(); foreach (var p in plist) { planetPicker.Items.Add(p); } planetPicker.SelectedIndex = planetPicker.Items.IndexOf(selectedPlanet); }; planetPicker.SelectedIndexChanged += async(sender, e) => { selectedPlanet = planetPicker.Items[planetPicker.SelectedIndex]; }; buildingsBtn.Clicked += async(sender, e) => { await Navigation.PushAsync(new PlanetBuildings(activeAccount, selectedPlanet)); }; spyOptions.Clicked += async(sender, e) => { await Navigation.PushAsync(new SpiesMain(activeAccount, selectedPlanet)); }; buildingOptions.Clicked += async(sender, e) => { await Navigation.PushAsync(new BuildingToolsView(activeAccount, selectedPlanet)); }; shipOptions.Clicked += async(sender, e) => { await Navigation.PushAsync(new ShipTools(activeAccount, selectedPlanet)); }; planetMapBtn.Clicked += async(sender, e) => { await Navigation.PushAsync(new PlanetMap(activeAccount, selectedPlanet)); }; }
async Task<AccountModel> GetActiveAccountAsync() { var accm = new AccountManagement.AccountManager(); var account = await accm.GetActiveAccountAsync(); if (account == null) { await Navigation.PushModalAsync(new Login()); account = await GetActiveAccountAsync(); } return account; }