public void Fluent_ConstructLoadNow_Issue1_WithRemotePath() //Issue #1 on github { using (var f = new TempfileLife(@"\MoalemYar\" + Path.GetRandomFileName())) { //validate Action act = () => JsonSettings.Construct <SettingsBag>(f.FileName).LoadNow().EnableAutosave(); act.ShouldNotThrow("LoadNow handles non existent folders and files."); } }
public DataManager(IGameDataRepository gameDataRepository, IMapper mapper) { _gameDataRepository = gameDataRepository; _mapper = mapper; string path = $"{AppDomain.CurrentDomain.BaseDirectory}{_settings.FileName}"; if (!File.Exists(path)) { _settings = JsonSettings.Construct <Settings>(); _settings.SetDefaultValues(); _settings.Save(); } try { _settings = JsonSettings.Load <Settings>(_settings.FileName); } catch (Exception e) { Debug.WriteLine(e); } }
public MyForm() { if (File.Exists("Config.json")) { Settings = JsonSettings.Load <MySettings>("Config.json"); } else { Settings = JsonSettings.Construct <MySettings>("Config.json"); } // sets the client (inner) size of the window for your content //this.ClientSize = new Eto.Drawing.Size(600, 400); this.ClientSize = Settings.windowSize; this.SizeChanged += (sender, args) => { Settings.windowSize = this.ClientSize; Settings.Save(); }; this.Title = "KruBot3"; var Twitch = new WebView(); var Pretzel = new WebView(); Twitch.OpenNewWindow += TwitchOnOpenNewWindow; Pretzel.OpenNewWindow += TwitchOnOpenNewWindow; //Nothing special is needed. Twitch.Url = new Uri("https://www.twitch.tv/popout/" + Settings.Username + "/chat?popout="); WebClient wb = new WebClient(); string Script = wb.DownloadString("https://cdn.frankerfacez.com/static/ffz_injector.user.js"); Twitch.DocumentLoaded += (sender, args) => // Twitch.ExecuteScript("");); Pretzel.Url = new Uri("https://app.pretzel.rocks/player"); var browserLayout = new Splitter(); browserLayout.Panel1 = Twitch; browserLayout.Panel2 = Pretzel; browserLayout.Orientation = Orientation.Horizontal; browserLayout.RelativePosition = 0.75; browserLayout.FixedPanel = SplitterFixedPanel.None; browserLayout.PositionChanged += (sender, args) => { Console.WriteLine(browserLayout.RelativePosition); Settings.splitPosition = browserLayout.RelativePosition; Settings.Save(); }; browserLayout.RelativePosition = Settings.splitPosition; var Tabs = new TabControl(); var TabPage1 = new TabPage(); TabPage1.Text = "Main Chat"; TabPage1.Content = browserLayout; Tabs.Pages.Add(TabPage1); var TabPage2 = new TabPage(); TabPage2.Text = "Settings"; var t2Contents = new StackLayout(); t2Contents.Padding = 50; Label Info = new Label(); Info.Text = "This page lets you configure the bot to be able to listen to your chat."; t2Contents.Items.Add(Info); Label Info2 = new Label(); Info2.Text = "Please enter your Username Below:"; t2Contents.Items.Add(Info2); TextBox userName = new TextBox(); userName.Size = new Size(400, userName.Height); if (Settings.Username == "Twitch") { userName.PlaceholderText = "Username"; } else { userName.Text = Settings.Username; } t2Contents.Items.Add(userName); Label Info3 = new Label(); Info3.Text = "And now we need an OAuth Code from that account:"; t2Contents.Items.Add(Info3); Button openOAuth = new Button(); openOAuth.Click += OpenOAuthOnClick; openOAuth.Text = "Open Website"; t2Contents.Items.Add(openOAuth); PasswordBox oAuth = new PasswordBox(); if (string.IsNullOrEmpty(Settings.oAuthToken)) { } else { oAuth.Text = Settings.oAuthToken; } oAuth.Size = new Size(400, oAuth.Height); t2Contents.Items.Add(oAuth); Label SaveNow = new Label(); SaveNow.Text = "Once you're done, click this button to save your settings!"; t2Contents.Items.Add(SaveNow); Button Save = new Button(); Save.Text = "Save!"; Save.Click += (sender, args) => { Settings.Username = userName.Text.ToLower(); Settings.oAuthToken = oAuth.Text; Settings.Save(); MessageBox.Show("Saved!"); Twitch.Url = new Uri("https://www.twitch.tv/popout/" + Settings.Username + "/chat?popout="); initBot(); }; t2Contents.Items.Add(Save); TabPage2.Content = t2Contents; Tabs.Pages.Add(TabPage2); this.Content = Tabs; #region Bringing up the bot if (string.IsNullOrEmpty(Settings.oAuthToken)) { Tabs.SelectedIndex = 1; } else { initBot(); } #endregion }