//public async Task<string> MagicCalc() //{ // var encoded = ""; // await Dispatcher.BeginInvoke(new ThreadStart(delegate // { // var sb = new StringBuilder(); // var tmp = Encoding.ASCII.GetBytes(sb.ToString()); // var h = ((HashAlgorithm) CryptoConfig.CreateFromName("MD5")).ComputeHash(tmp); // encoded = BitConverter.ToString(h).Replace("-", string.Empty).ToLower(); // })); // if (InitialMagic != "" && InitialMagic != encoded) // { // throw new Exception("Can't touch this!"); // } // return encoded; //} public void SetBot(BotWindowData bot) { LoadingUi = true; Bot = bot; authBox.SelectedItem = Bot.GlobalSettings.Auth.AuthType; if (Bot.GlobalSettings.Auth.AuthType == AuthType.Google) { loginBox.Text = Bot.GlobalSettings.Auth.GoogleUsername; passwordBox.Password = Bot.GlobalSettings.Auth.GooglePassword; } else { loginBox.Text = Bot.GlobalSettings.Auth.PtcUsername; passwordBox.Password = Bot.GlobalSettings.Auth.PtcPassword; } foreach (var uiElem in SettingsGrid.GetLogicalChildCollection <TextBox>()) { string val; if (UiHandlers.GetValueByName(uiElem.Name.Substring(2), Bot.GlobalSettings, out val)) { uiElem.Text = val; } } foreach (var uiElem in SettingsGrid.GetLogicalChildCollection <PasswordBox>()) { string val; if (UiHandlers.GetValueByName(uiElem.Name.Substring(2), Bot.GlobalSettings, out val)) { uiElem.Password = val; } } foreach (var uiElem in SettingsGrid.GetLogicalChildCollection <CheckBox>()) { bool val; if (UiHandlers.GetValueByName(uiElem.Name.Substring(2), Bot.GlobalSettings, out val)) { uiElem.IsChecked = val; } } foreach (var uiElem in SettingsGrid.GetLogicalChildCollection <ComboBox>()) { Enum val; if (UiHandlers.GetValueByName(uiElem.Name.Substring(2), Bot.GlobalSettings, out val)) { var valType = val.GetType(); uiElem.ItemsSource = Enum.GetValues(valType); uiElem.SelectedItem = val; } } CustomRouteComboBox.SelectedItem = _globalSettings.Routes.FirstOrDefault(x => x.Name == Bot.GlobalSettings.LocationSettings.CustomRouteName); if (ScheduleOrganizer.Visibility == Visibility.Visible) { ScheduleOrganizer.SetNewBotAndShow(bot); } LoadingUi = false; }
private void btn_OpenSchedule_Click(object sender, RoutedEventArgs e) { ScheduleOrganizer.SetNewBotAndShow(Bot); }