public async Task UpdatePuzzlesList() { allPuzzles.Clear(); if (await LogicHelper.IsInternet()) { puzzlesDownloaded = false; OnPropertyChanged(nameof(PuzzlesDownloading)); GameTypes gamesType; if (selectedCategory == CategoryEnum.MyFriends) { gamesType = GameTypes.PuzzleListFromFriends; } else if (selectedCategory == CategoryEnum.Challenges) { gamesType = GameTypes.ChallengeListAllCahllenges; } else { gamesType = GameTypes.AllPuzzles; } var result = await Game.GetGameList(LogicHelper.GetLangString(selectedLanguage), GameSort.CreatedDesc, gamesType); foreach (var puzzle in result) { allPuzzles.Add(puzzle); } } puzzlesDownloaded = true; OnPropertyChanged(nameof(PuzzlesDownloading)); OnPropertyChanged(nameof(ShowNoPuzzlesMessage)); LoadImage(); }
private IActor[] CheckForIntruders(IActor actor) { var foundIntruders = new List <IActor>(); foreach (var target in _actorManager.Items) { if (target.Owner == actor.Owner) { continue; } if (target.Person.Survival.IsDead) { continue; } var isVisible = LogicHelper.CheckTargetVisible(_map, actor.Node, target.Node); if (!isVisible) { continue; } foundIntruders.Add(target); } return(foundIntruders.ToArray()); }
public static async Task <GameEndResponse> EndGame(string gameId, int score) { //salt - de86cc2bab8e407e85f67587b7511395 //game_end_221c5656cvf56rtf67gyr45545de67340/ try { string gid = gameId; string uid = AppInfo.AppUser.UserId; string hash = LogicHelper.CreateMD5(uid, "de86cc2bab8e407e85f67587b7511395"); List <string> prms = new List <string> { "?hash=" + hash, "&uid=" + uid, "&gid=" + gid, "&score=" + score }; HttpHelper helper = new HttpHelper(); string response = await helper.Get("game_end_221c5656cvf56rtf67gyr45545de67340/", prms); List <GameEndResponse> obj = JsonConvert.DeserializeObject <List <GameEndResponse> >(response); GameEndResponse result = obj.First(); return(result); } catch (Exception) { return(null); } }
public void StartGame() { while (_current < _finish) { LogicHelper.Line(); PrintReport(); int select; CheckSelection(out select); switch (select) { case 1: AddOne(); break; case 2: MultiTwo(); break; case 3: ToOne(); break; } } Console.WriteLine(Current > Finish ? "Текущее число вышло за пределы! Вы проиграли." : "Поздравляем! Вы выиграли!"); }
public static async Task <GameStartResponse> StartGame(string gameId) { //salt - 13032c9256e73dde7v4fd1eaqw12158 //game_start_440593f67221c50b647de6734734674/ try { string uid = AppInfo.AppUser.UserId; string hash = LogicHelper.CreateMD5(uid, "13032c9256e73dde7v4fd1eaqw12158"); string gid = gameId; List <string> prms = new List <string> { "?hash=" + hash, "&uid=" + uid, "&gid=" + gid }; HttpHelper helper = new HttpHelper(); string response = await helper.Get("game_start_440593f67221c50b647de6734734674/", prms); List <GameStartResponse> obj = JsonConvert.DeserializeObject <List <GameStartResponse> >(response); GameStartResponse result = obj.First(); return(result); } catch (Exception ex) { GameStartResponse result = new GameStartResponse(); result.StatusCode = 123; return(result); } }
private async void PostPuzzle_Click(object sender, RoutedEventArgs e) { if (!await LogicHelper.IsInternet()) { return; } ProgRing.IsActive = true; BackToEnterBtn.IsEnabled = false; Scramble.IsEnabled = false; PostPuzzle.IsEnabled = false; var result = await ViewModel.PostPuzzle(); ProgRing.IsActive = false; BackToEnterBtn.IsEnabled = true; Scramble.IsEnabled = true; PostPuzzle.IsEnabled = true; var dialog = new MessageDialog("", ""); if (result?.Status != GameCreateStatus.Ok) { dialog.Title = "Failed to create puzzle"; dialog.Content = "An error occurred when trying to create puzzle. Please try again later."; await dialog.ShowAsync(); } //if (result?.Status == GameCreateStatus.Ok) //{ // Frame.GoBack(); //} }
public void PushUserToken() //TODO: Learn how it works! { //salt - 112fffa02cad313d433d4114b39250d7 Guid guid = Guid.NewGuid(); string token = ""; string hash = LogicHelper.CreateMD5(token, "112fffa02cad313d433d4114b39250d7"); }
private void FillSupportedFeatures() { _SupportedFeatures[(int)StateFeature.NativeCommandQueuing] = LogicHelper.CheckBit(word076, Bits.Bit08); _SupportedFeatures[(int)StateFeature.PhyEventCounters] = LogicHelper.CheckBit(word076, Bits.Bit10); _SupportedFeatures[(int)StateFeature.DmaSetupAutoActivate] = LogicHelper.CheckBit(word078, Bits.Bit02); _SupportedFeatures[(int)StateFeature.InOrderDataDelivery] = LogicHelper.CheckBit(word078, Bits.Bit04); _SupportedFeatures[(int)StateFeature.SoftwareSettingsPreservation] = LogicHelper.CheckBit(word078, Bits.Bit06); _SupportedFeatures[(int)StateFeature.Smart] = LogicHelper.CheckBit(word082, Bits.Bit00); _SupportedFeatures[(int)StateFeature.SecurityMode] = LogicHelper.CheckBit(word082, Bits.Bit01); _SupportedFeatures[(int)StateFeature.WriteCache] = LogicHelper.CheckBit(word082, Bits.Bit05); _SupportedFeatures[(int)StateFeature.ReadLookAhead] = LogicHelper.CheckBit(word082, Bits.Bit06); _SupportedFeatures[(int)StateFeature.ReleaseInterrupt] = LogicHelper.CheckBit(word082, Bits.Bit07); _SupportedFeatures[(int)StateFeature.AdvancedPowerManagement] = LogicHelper.CheckBit(word083, Bits.Bit03); _SupportedFeatures[(int)StateFeature.PowerUpInStandby] = LogicHelper.CheckBit(word083, Bits.Bit05); _SupportedFeatures[(int)StateFeature.AutomaticAcousticManagement] = LogicHelper.CheckBit(word083, Bits.Bit09); _SupportedFeatures[(int)StateFeature.Bit48Lba] = LogicHelper.CheckBit(word083, Bits.Bit10); _SupportedFeatures[(int)StateFeature.DeviceConfigurationOverlay] = LogicHelper.CheckBit(word083, Bits.Bit11); _SupportedFeatures[(int)StateFeature.SmartErrorLogging] = LogicHelper.CheckBit(word084, Bits.Bit00); _SupportedFeatures[(int)StateFeature.SmartSelfTest] = LogicHelper.CheckBit(word084, Bits.Bit01); _SupportedFeatures[(int)StateFeature.Streaming] = LogicHelper.CheckBit(word084, Bits.Bit04); _SupportedFeatures[(int)StateFeature.PowerManagement] = LogicHelper.CheckBit(word085, Bits.Bit03); _SupportedFeatures[(int)StateFeature.HostProtectedArea] = LogicHelper.CheckBit(word085, Bits.Bit10); _SupportedFeatures[(int)StateFeature.GeneralPurposeLogging] = LogicHelper.CheckBit(word087, Bits.Bit05); _SupportedFeatures[(int)StateFeature.TaggedCommandQueuing] = false; }
static void Main(string[] args) { //Переменная пути к файлу string path = "Array.vt"; //Создаем и выводим на массив заполненный одним значением - к примеру, 4. DoubleArray arr1 = new DoubleArray(5, 2, 4); Console.WriteLine(arr1); LogicHelper.Line(); //Создаем и выводим на массив заполненный случайными числами в диапазоне по умолчанию DoubleArray arr2 = new DoubleArray(5, 6); Console.WriteLine(arr2); //Сохраняем полученный случайный массив в файл arr2.SaveToFile(path); //Выводи на печать максимальный элемент и координаты его первого (если их несколько) вхождения в массив int v, h; arr2.NumberOfMax(out v, out h); Console.WriteLine($"Максимальный элемент массива: {arr2.Max}\nЕго координаты: ({v};{h})"); LogicHelper.Line(); //Воссоздаем массив из файла, куда ранее сохранили предыдущий массив DoubleArray arr3 = DoubleArray.LoadFromFile(path); //Выводи полученный из файла массив на печать для сравнения с его "исходником" Console.WriteLine(arr3); LogicHelper.Pause(); }
/// <summary> /// Initializes a new instance of the <see cref="SmbiosStructureHeaderInfo"/> class. /// </summary> /// <param name="rawData">The raw data.</param> internal SmbiosStructureHeaderInfo(byte[] rawData) { StructureType = (SmbiosStructure)rawData[0x00]; Length = rawData[0x01]; Handle = LogicHelper.Word(rawData[0x02], rawData[0x03]); RawData = rawData; }
public AddNewGameViewModel(PictureSourceEnum selectedPictureSource) { scrambledWord = new ObservableCollection <Cell>(); resultWord = new ObservableCollection <Cell>(); enteredWord = new ObservableCollection <Cell>(); enteredWord.Add(new Cell { BackgroundColor = new SolidColorBrush(Color.FromArgb(0xFF, 0xDA, 0x95, 0x00)), Letter = "" }); for (int i = 0; i < 7; i++) { enteredWord.Add(new Cell { Letter = "", BackgroundColor = new SolidColorBrush(Color.FromArgb(0xff, 0xA8, 0xA8, 0xA8)), ForeColor = new SolidColorBrush(Color.FromArgb(255, 255, 255, 255)) }); } puzzle = new Puzzle { CreatorName = AppInfo.AppUser.Name, Language = AppInfo.AppUser.SelectedLanguage }; LanguageImage = new BitmapImage(new Uri(@"ms-appx:///Assets/Graphics/Languages/language_empty.png")); PictureSource = selectedPictureSource; LogicHelper.DownloadPhoto(LogicHelper.CreateImageUrl(ImageTypeToDownload.ProfilePhotoBig, AppInfo.AppUser.UserId), PhotoDownloaded); }
public async Task UpdatePuzzlesList() { //this.profilePhoto = allPuzzles.Clear(); if (await LogicHelper.IsInternet()) { puzzlesDownloaded = false; OnPropertyChanged(nameof(PuzzlesDownloading)); GameTypes gamesType; if (selectedCategory == ActivityCategoryEnum.Created) { gamesType = GameTypes.MyPuzzleList; } else if (selectedCategory == ActivityCategoryEnum.Played) { gamesType = GameTypes.MyPlayedPuzzleList; } else { gamesType = GameTypes.MyCallengesList; } var result = await Game.GetGameList("all", GameSort.CreatedDesc, gamesType); foreach (var puzzle in result) { //puzzle.CreatorPhoto = profilePhoto; allPuzzles.Add(puzzle); } } puzzlesDownloaded = true; OnPropertyChanged(nameof(PuzzlesDownloading)); OnPropertyChanged(nameof(ShowNoPuzzlesMessage)); LoadImage(); }
protected async override void OnAppearing() { try { StepCountController stepCountController = new StepCountController(); List <StepCount> stepCounts = await stepCountController.GetAllStepCountsAsync(); PlotModel plotModel = new PlotModel(); plotModel.Axes.Add(new LinearAxis { MajorGridlineStyle = LineStyle.Solid, MinorGridlineStyle = LineStyle.Dot, IsPanEnabled = false, Minimum = 0 }); DateTime dateTime = DateTime.Today; plotModel.Axes.Add(new DateTimeAxis { MajorGridlineStyle = LineStyle.Solid, MinorGridlineStyle = LineStyle.Dot, Position = AxisPosition.Bottom, Minimum = DateTimeAxis.ToDouble(dateTime.AddDays(-14)), Maximum = DateTimeAxis.ToDouble(dateTime) }); LineSeries lineSeries = new LineSeries(); lineSeries.Points.AddRange(stepCountController.GetStepCountDataPoints(stepCounts)); plotModel.Series.Add(lineSeries); plotView.Model = plotModel; } catch (ApiException ex) { await DisplayAlert(AppResources.ErrorTitle, LogicHelper.ErrorMessage(ex.ErrorCode), AppResources.DialogOk); } catch (ConnectionException) { await DisplayAlert(AppResources.ErrorTitle, AppResources.ConnectionException, AppResources.DialogOk); } }
private async void SendChallengeBtn_Click(object sender, RoutedEventArgs e) { if (!await LogicHelper.IsInternet()) { return; } ProgRing.IsActive = true; SendChallengeBtn.IsEnabled = false; BackChallengekBtn.IsEnabled = false; var result = await ViewModel.SendChallenges(ContactsGridView.SelectedItems); ProgRing.IsActive = false; SendChallengeBtn.IsEnabled = true; BackChallengekBtn.IsEnabled = true; if (result == null || result.Status != CreateChallengeStatus.Ok) { var dialog = new MessageDialog("An error occurred when trying to create challende(s). Please try again later."); await dialog.ShowAsync(); } else { var dialog = new MessageDialog("Challenge created successfully"); await dialog.ShowAsync(); //ViewModel.HideChallengeControl(); Frame.GoBack(); } }
private async void LogoTapped(object sender, EventArgs e) { try { Image image = (Image)sender; ExerciseViewModel exercise = (ExerciseViewModel)image.BindingContext; if (exercise.Type == ExerciseType.Normal) { if (await exerciseController.FavoriteExerciseAsync(exercise)) { exercise.Type = ExerciseType.Favorite; SortAndRefresh(); } } else if (exercise.Type == ExerciseType.Favorite) { if (await exerciseController.UnfavoriteExerciseAsync(exercise)) { exercise.Type = ExerciseType.Normal; SortAndRefresh(); } } } catch (ApiException ex) { await DisplayAlert(AppResources.ErrorTitle, LogicHelper.ErrorMessage(ex.ErrorCode), AppResources.DialogOk); } catch (ConnectionException) { await DisplayAlert(AppResources.ErrorTitle, AppResources.ConnectionException, AppResources.DialogOk); } }
private static IEnumerable <IActor> CheckForIntruders(IActor actor, ISectorMap map, IActorManager actorManager) { foreach (var target in actorManager.Items) { if (target.Person.Fraction == actor.Person.Fraction || (target.Person.Fraction == Fractions.MilitiaFraction && actor.Person.Fraction == Fractions.MainPersonFraction) || (target.Person.Fraction == Fractions.MainPersonFraction && actor.Person.Fraction == Fractions.MilitiaFraction) || (target.Person.Fraction == Fractions.InterventionistFraction && actor.Person.Fraction == Fractions.TroublemakerFraction) || (target.Person.Fraction == Fractions.TroublemakerFraction && actor.Person.Fraction == Fractions.InterventionistFraction)) { continue; } if (target.Person.CheckIsDead()) { continue; } var isVisible = LogicHelper.CheckTargetVisible(map, actor.Node, target.Node); if (!isVisible) { continue; } yield return(target); } }
public async Task <GameCreateResponseModel> PostPuzzle() { GameCreateResponseModel result; try { result = await Game.CreateGame(new GameModel { CreatorUid = AppInfo.AppUser.UserId, CreateGameType = "A", Language = LogicHelper.GetLangString(puzzle.Language), Word = puzzle.Word, Photo = this.Photo }); if (result.Status == GameCreateStatus.Ok) { AppInfo.AppUser.TotalCreatedPuzzles++; wordEntered = false; NeedDisplayFinalyControl = true; OnPropertyChanged(nameof(NeedDisplayScrambledWordControl)); OnPropertyChanged(nameof(NeedDisplayFinalyControl)); } } catch { result = new GameCreateResponseModel(); result.Status = GameCreateStatus.PostError; result.GameId = String.Empty; } return(result); }
private async void ChangePictureBtn_Click(object sender, RoutedEventArgs e) { var pictureDialog = new SelectPictureSourceDialog(false); await pictureDialog.ShowAsync(); if (pictureDialog.Result == DialogResultEnum.Cancel) { return; } ProgRing.IsActive = true; StorageFile imgFile; if (pictureDialog.SelectedPicrureStore == PictureSourceEnum.Gallery) { imgFile = await LogicHelper.OpenImage(); } else { CameraCaptureUI captureUI = new CameraCaptureUI(); captureUI.PhotoSettings.Format = CameraCaptureUIPhotoFormat.Jpeg; imgFile = await captureUI.CaptureFileAsync(CameraCaptureUIMode.Photo); } await UpdatePhoto(imgFile); ProgRing.IsActive = false; }
static void Main(string[] args) { //Создадим две дроби дял демонстрации работы: Fraction fraction1 = new Fraction(4, 5); Fraction fraction2 = new Fraction(3, 2); //Выводим их на печать (благодаря переопределенному методу ToString() мы получим приятный глазу результат) Console.WriteLine($"Первая дробь: {fraction1}"); Console.WriteLine($"Вторая дробь: {fraction2}"); //Создаем объект типа дроби, который будет принимать значения результатов математических операций Fraction fraction; //Создаем шаблон сообщения для вывода на печать const string res = "Результат {0} дробей {1} и {2}:\t{3}"; //Суммируем две дроби: fraction = fraction1 + fraction2; Console.WriteLine(res, "сложения", fraction1, fraction2, fraction); //Вычитаем две дроби: fraction = fraction1 - fraction2; Console.WriteLine(res, "вычитания", fraction1, fraction2, fraction); //Умножаем две дроби: fraction = fraction1 * fraction2; Console.WriteLine(res, "умножения", fraction1, fraction2, fraction); //Делим две дроби: fraction = fraction1 / fraction2; Console.WriteLine(res, "деления", fraction1, fraction2, fraction); LogicHelper.Pause(); }
public DigitalReadSuccessResponsePacket(Int32 _index, Logic _value) { Tag = "succeed"; Index = _index; Args = new List <KeyValuePair <String, String> >(); Args.Add(new KeyValuePair <String, String>("value", LogicHelper.ToString(_value))); }
public async Task <bool> Initialize() { //var result = await Game.StartGame(puzzle.GameId); //if (result.Status != GameStartStatus.Ok) //{ // var dialog = new MessageDialog("You have already played this game or an error occurred. Please select another one.", "Can't start this game"); // await dialog.ShowAsync(); // return false; //} //Image = puzzle.Background; //OnPropertyChanged(nameof(Image)); //puzzle.Word = result.WordToGuess; if (string.IsNullOrWhiteSpace(puzzle?.Word)) { return(false); } Background = await LogicHelper.GetBluredImage(puzzle.GamePhotoNoSplitUrl); OnPropertyChanged(nameof(Background)); resultWord = new ObservableCollection <Cell>(); for (int i = 0; i < puzzle.Word.Length; i++) { resultWord.Add(new Cell { Letter = puzzle.Word[i].ToString(), BackgroundColor = new SolidColorBrush(Color.FromArgb(0xff, 0xE4, 0xE4, 0xE4)), ForeColor = new SolidColorBrush(Color.FromArgb(0xff, 0x47, 0x47, 0x47)), }); } LogicHelper.DownloadPhoto(puzzle.GamePhotoNoSplitUrl, PhotoDownloaded); OnPropertyChanged(nameof(ResultWord)); return(true); }
private async void Submit_PressedAsync(object sender, EventArgs e) { if (Password1.Text != Password2.Text) { await DisplayAlert("Password mismatch", "Passwords do not match", "OK"); } else { try { Patient patient = await patientController.CreatePatientAsync(FirstName.Text, LastName.Text, Email.Text, Password1.Text); await DisplayAlert("Success", "Account created", "OK"); Application.Current.MainPage = new MasterPage(); } catch (ApiException ex) { await DisplayAlert(AppResources.ErrorTitle, LogicHelper.ErrorMessage(ex.ErrorCode), AppResources.DialogOk); } catch (ConnectionException) { await DisplayAlert(AppResources.ErrorTitle, AppResources.ConnectionException, AppResources.DialogOk); } } }
private async void Page_Loaded(object sender, RoutedEventArgs e) { ProgRing.IsActive = true; NoInternetStackPanel.Visibility = Visibility.Collapsed; //bool connection = await LogicHelper.CheckInternetConnection(); if (await LogicHelper.IsInternet()) { var user = await AppInfo.InitializeUser(); ProgRing.IsActive = false; if (user == null) { ButtonsGrid.Visibility = Visibility.Visible; } else { Frame.Navigate(typeof(MainPage)); } } else { NoInternetStackPanel.Visibility = Visibility.Visible; ProgRing.IsActive = false; } }
private async void Edit_PressedAsync(object sender, EventArgs e) { string h = Height.Text; short height = Convert.ToInt16(h); string w = Weight.Text; short weight = Convert.ToInt16(w); if ((CurrentPassword.Text != null || NewPassword.Text != null || NewPassword2.Text != null) && (NewPassword.Text != NewPassword2.Text || CurrentPassword.Text == null)) { await DisplayAlert("Password error", "Passwords do not match or you're missing a field", "OK"); } else { try { if (ZipCode.Text != null) { patient.ZipCode = ZipCode.Text; } if (Address.Text != null) { patient.Address = Address.Text; } if (PhoneNumber.Text != null) { patient.Phone = PhoneNumber.Text; } if (Height.Text != null) { patient.Height = height; } if (Weight.Text != null) { patient.Weight = weight; } patient.BirthDate = datePicked; patient.Sex = sex; patient.CountryCode = country.Code; await patientController.UpdatePatientAsync(patient, CurrentPassword.Text, NewPassword.Text); await DisplayAlert("Success", "Profile updated", "OK"); Application.Current.MainPage = new MasterPage(); } catch (ApiException ex) { await DisplayAlert(AppResources.ErrorTitle, LogicHelper.ErrorMessage(ex.ErrorCode), AppResources.DialogOk); } catch (ConnectionException) { await DisplayAlert(AppResources.ErrorTitle, AppResources.ConnectionException, AppResources.DialogOk); } } }
static void Main() { string path = "students_4.csv"; TestStudentsDbClass(path); LogicHelper.Pause(); }
static void Main(string[] args) { Doubler doubler = new Doubler(100); doubler.StartGame(); LogicHelper.Pause(); }
static void Main(string[] args) { string path = @"C:\VTariko\Education\Repository\shop_VTariko"; FindImgInDir(path); LogicHelper.Line(); LogicHelper.Pause(); }
static void Main() { //Демонстрация части А: Console.WriteLine(NumberEnter()); //Демонстрация части Б: Console.WriteLine(NumberEnterTry()); LogicHelper.Pause(); }
static void Main(string[] args) { RecursePrint(1, 6); //Вывод на печать чисел от a=1 до b=6 LogicHelper.Line(); //Проводим линию-разделитель int summ = RecurseSumm(1, 9); //Считаем сумму чисел от a=1 до b=9 Console.WriteLine(summ); //Выводим полученную сумму на экран LogicHelper.Pause(); //Ожидаем ввода с клавиатуры перед завершением программы }
public DigitalReadCallbackPacket(String _deviceID, Int32 _pin, Logic _value) { Tag = "digital-pin"; Index = null; Args = new List <KeyValuePair <String, String> >(); Args.Add(new KeyValuePair <String, String>("device_id", _deviceID)); Args.Add(new KeyValuePair <String, String>("pin", _pin.ToString())); Args.Add(new KeyValuePair <String, String>("value", LogicHelper.ToString(_value))); }