public void Version_serialize_should_be_correct_format() { VersionClass versionClass = new VersionClass("1.0.0.0", "2.0.0.0"); string json = JsonSerializer.ToJson(versionClass); string expectedJson = "{\"StringProperty1\":\"StringProperty1\",\"Version1\":{\"Major\":1,\"Minor\":0,\"Build\":0,\"Revision\":0,\"MajorRevision\":0,\"MinorRevision\":0},\"Version2\":{\"Major\":2,\"Minor\":0,\"Build\":0,\"Revision\":0,\"MajorRevision\":0,\"MinorRevision\":0},\"StringProperty2\":\"StringProperty2\"}"; Assert.AreEqual(expectedJson, json); }
public void Version_deserialize_should_be_correct() { Version expectedVersion1 = new Version("1.0.0.0"); Version expectedVersion2 = new Version("2.0.0.0"); string json = string.Format(@"{{""StringProperty1"": ""StringProperty1"", ""Version1"": ""{0}"", ""Version2"": ""{1}"", ""StringProperty2"": ""StringProperty2""}}", "1.0.0.0", "2.0.0.0"); VersionClass versionClass = JsonSerializer.ToObject <VersionClass>(json); Assert.AreEqual("StringProperty1", versionClass.StringProperty1); Assert.AreEqual(expectedVersion1, versionClass.Version1); Assert.AreEqual(expectedVersion2, versionClass.Version2); Assert.AreEqual("StringProperty2", versionClass.StringProperty2); }
protected QtTranslation(XmlDocument document) : base(new Dictionary <string, QtTranslationContext>()) { XmlElement ts = document.FirstElement("TS"); if (ts == null) { throw new QtTranslationException("Invalid Translation file. The root node isn't 'TS'."); } if (!ts.HasAttribute("language")) { throw QtTranslationException.InvalideNoNodeFound("TS", "language"); } if (!ts.HasAttribute("version")) { throw QtTranslationException.InvalideNoNodeFound("TS", "version"); } if (ts.GetAttribute("version") != "2.1") { throw new QtTranslationException("Unsuported version of QtTranslation file.\nThe 2.1 version is the only supported."); } try { Language = CultureInfo.GetCultureInfo(ts.GetAttribute("language")); Version = new VersionClass(ts.GetAttribute("version")); } catch (Exception ex) { throw new QtTranslationException(ex); } XmlElement[] context = ts.GetElements("context"); if (context.Length == 0) { throw QtTranslationException.InvalideNoNodeFound("context"); } foreach (XmlElement item in context) { try { AddContext(new QtTranslationContext(item)); } catch { } } }
private async void CheckUpdateButton_Click(object sender, RoutedEventArgs e) { try { CheckUpdateButton.Content = "アップデートを確認しています....."; var vc = await VersionClass.GetUpdaterAsync(); if (vc.IsUpdateAvailable()) { //show updater screen CheckUpdateButton.Content = "\u203Cアップデートが利用可能です"; CheckUpdateButton.Background = new SolidColorBrush((Color)ColorConverter.ConvertFromString("#f5ad3b")); //get parent Window var window = Matsuri.SeaSlug.GetAncestorOfType <MetroWindow>((Button)sender); var diagret = await window.ShowMessageAsync($"バージョン{vc.AppVersion}が利用可能です", $"{vc.UpdateMessage}\n\nアップデートページを開きますか?", MessageDialogStyle.AffirmativeAndNegative); if (diagret == MessageDialogResult.Affirmative) { var processStartInfo = new ProcessStartInfo(vc.UpdateNotifyUrl) { UseShellExecute = true, Verb = "open" }; Process.Start(processStartInfo); } } else { //change text CheckUpdateButton.Content = "\u2714最新版をご利用です"; CheckUpdateButton.Background = new SolidColorBrush((Color)ColorConverter.ConvertFromString("#5abfb7")); } } catch (Exception ex) { CheckUpdateButton.Content = "\u274Cアップデートを確認できませんでした"; CheckUpdateButton.Background = new SolidColorBrush((Color)ColorConverter.ConvertFromString("#d7385f")); Trace.WriteLine($"[UpdateChecker]Could not check update.(Err={ex.Message})"); } }
public void SearchMatch() { string SummonerName = ""; string Region = ""; int MenuListCount = 0; TextBoxSummonerName.Invoke(new MethodInvoker(delegate { SummonerName = TextBoxSummonerName.Text; })); regionsComboBox.Invoke(new MethodInvoker(delegate { Region = regionsComboBox.Text; })); VersionClass ver = GetVersion.ReturnVersion(Region, apiKey); version = ver.n.champion; this.Invoke((MethodInvoker) delegate { MenuListCount = MenuControls.Count; }); try { for (int a = 0; a < MenuListCount; a++) { SetControlPropertyThreadSafe(MenuControls[a], "Enabled", false); } SummonerInfo summonerInfo = GetSummoner.ReturnSummoner(SummonerName, Region, apiKey); MatchInfo = MatchSearch.GetMatch(Region, summonerInfo.id, apiKey); string[] Keys = MatchSearch.GetKeys(JSON, MatchInfo); string[] Names = MatchSearch.GetName(JSON, MatchInfo); SetControlPropertyThreadSafe(Summoner1, "Text", MatchInfo.participants[0].summonerName); SetControlPropertyThreadSafe(Summoner2, "Text", MatchInfo.participants[1].summonerName); SetControlPropertyThreadSafe(Summoner3, "Text", MatchInfo.participants[2].summonerName); SetControlPropertyThreadSafe(Summoner4, "Text", MatchInfo.participants[3].summonerName); SetControlPropertyThreadSafe(Summoner5, "Text", MatchInfo.participants[4].summonerName); SetControlPropertyThreadSafe(Summoner6, "Text", MatchInfo.participants[5].summonerName); SetControlPropertyThreadSafe(Summoner7, "Text", MatchInfo.participants[6].summonerName); SetControlPropertyThreadSafe(Summoner8, "Text", MatchInfo.participants[7].summonerName); SetControlPropertyThreadSafe(Summoner9, "Text", MatchInfo.participants[8].summonerName); SetControlPropertyThreadSafe(Summoner10, "Text", MatchInfo.participants[9].summonerName); PictureBox[] pb = new PictureBox[10] { TeamMatePictureBox0, TeamMatePictureBox1, TeamMatePictureBox2, TeamMatePictureBox3, TeamMatePictureBox4, TeamMatePictureBox5, TeamMatePictureBox6, TeamMatePictureBox7, TeamMatePictureBox8, TeamMatePictureBox9 }; for (int i = 0; i < 10; i++) { pb[i].Load("http://ddragon.leagueoflegends.com/cdn/" + version + "/img/champion/" + Keys[i] + ".png"); this.Invoke((MethodInvoker) delegate { LoLToolTip.SetToolTip(pb[i], Names[i]); }); } if (MatchInfo.gameQueueConfigId == 4 || MatchInfo.gameQueueConfigId == 6 || MatchInfo.gameQueueConfigId == 9 || MatchInfo.gameQueueConfigId == 41 || MatchInfo.gameQueueConfigId == 42) { PictureBox[] pbBans = new PictureBox[6] { banPB1, banPB2, banPB3, banPB4, banPB5, banPB6 }; for (int i = 10; i < Keys.Length; i++) { pbBans[i - 10].Load("http://ddragon.leagueoflegends.com/cdn/" + version + "/img/champion/" + Keys[i] + ".png"); this.Invoke((MethodInvoker) delegate { LoLToolTip.SetToolTip(pbBans[i - 10], Names[i]); }); } } PictureBox[] summonerSpell_1 = new PictureBox[10] { Summoner1Spell1, Summoner2Spell1, Summoner3Spell1, Summoner4Spell1, Summoner5Spell1, Summoner6Spell1, Summoner7Spell1, Summoner8Spell1, Summoner9Spell1, Summoner10Spell1 }; PictureBox[] summonerSpell_2 = new PictureBox[10] { Summoner1Spell2, Summoner2Spell2, Summoner3Spell2, Summoner4Spell2, Summoner5Spell2, Summoner6Spell2, Summoner7Spell2, Summoner8Spell2, Summoner9Spell2, Summoner10Spell2 }; List <Spells> summonerSpell = SummonerSpells.GetSpells(Region, apiKey); int x = 0; string[] SummID = new string[10]; foreach (Participant part in MatchInfo.participants) { SummID[x] = part.summonerId.ToString(); foreach (var item in summonerSpell) { if (item.Id == part.spell1Id) { summonerSpell_1[x].Load("http://ddragon.leagueoflegends.com/cdn/" + version + "/img/spell/" + item.Key + ".png"); this.Invoke((MethodInvoker) delegate { LoLToolTip.SetToolTip(summonerSpell_1[x], item.Name); }); } if (item.Id == part.spell2Id) { summonerSpell_2[x].Load("http://ddragon.leagueoflegends.com/cdn/" + version + "/img/spell/" + item.Key + ".png"); this.Invoke((MethodInvoker) delegate { LoLToolTip.SetToolTip(summonerSpell_2[x], item.Name); }); } } x++; } PictureBox[] DivisionsPB = new PictureBox[10] { divPb1, divPB2, divPB3, divPB4, divPB5, divPB6, divPB7, divPB8, divPB9, divPB10 }; Label[] divLabels = new Label[10] { DivString1, DivString2, DivString3, DivString4, DivString5, DivString6, DivString7, DivString8, DivString9, DivString10 }; ReturnDivision divisionsImages = ReturnDivisionInfo.GetDivisions(Region, apiKey, SummID); for (int i = 0; i < divisionsImages.divList.Count(); i++) { SetControlPropertyThreadSafe(divLabels[i], "Text", divisionsImages.divList[i].Division); SetControlPropertyThreadSafe(DivisionsPB[i], "Image", divisionsImages.image[i]); this.Invoke((MethodInvoker) delegate { LoLToolTip.SetToolTip((Control)DivisionsPB[i], divisionsImages.divList[i].Name); }); } //-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------// SetControlPropertyThreadSafe(LoadCircle, "Visible", false); for (int a = 0; a < MenuListCount; a++) { SetControlPropertyThreadSafe(MenuControls[a], "Enabled", true); } this.Invoke((MethodInvoker) delegate { basicPage.Hide(); FIVEvsFIVEpanel.Show(); FIVEvsFIVEpanel.BringToFront(); }); } catch (WebException ex) { MessageBox.Show(ex.ToString()); if (ex.Status == WebExceptionStatus.ProtocolError) { var response = (HttpWebResponse)ex.Response; if (response.StatusCode == HttpStatusCode.NotFound) { SetControlPropertyThreadSafe(MessageLabel, "Visible", true); SetControlPropertyThreadSafe(MessageLabel, "Text", "The summoner " + SummonerName + " is not currently in a game!"); this.Invoke((MethodInvoker) delegate { emptyTextBoxControlTimer.Enabled = true; }); SetControlPropertyThreadSafe(LoadCircle, "Visible", false); for (int a = 0; a < MenuListCount; a++) { SetControlPropertyThreadSafe(MenuControls[a], "Enabled", true); } } } for (int a = 0; a < MenuListCount; a++) { SetControlPropertyThreadSafe(MenuControls[a], "Enabled", true); } SetControlPropertyThreadSafe(LoadCircle, "Visible", false); } }