public Article(NewsfeedTable NF, int argc) { ReactionNR = 1337; Tag = NF.Category.Split(new[] { ", " }, StringSplitOptions.None)[0]; ID = NF.Article; Header = NF.Header.Replace("*", "-").Replace(""", "'"); IMGSource = NF.Image; if (!NF.Ingress.Any()) { HasIngress = false; Ingress = NF.Ingress; } else { Ingress = NF.Ingress; var properties = App.Current.Properties; if (properties.ContainsKey("showingress")) { HasIngress = (bool)properties["showingress"]; } else { HasIngress = true; } Ingress = NF.Ingress; int IL = 40; int IH = 17; if (Ingress.Length < IL) { INGHR = IH; } else if (Ingress.Length < IL * 2) { INGHR = IH * 2; } else if (Ingress.Length < IL * 3) { INGHR = IH * 3; } /* * //If the ingress is more than X characters, then shorten it until it's not. * while (Ingress.Length > 120) * { * Ingress = Ingress.Remove(Ingress.Length - 1); * } * while (!Ingress.EndsWith(" ")) * { * Ingress = Ingress.Remove(Ingress.Length - 1); * } * * * /*string[] words = Ingress.Split(' '); * string myLastWord = words[words.Length - 1]; * int wordIndex = Ingress.IndexOf(myLastWord); * Ingress.Remove(wordIndex); * * if (Ingress.EndsWith(" ")) * Ingress = Ingress.Remove(Ingress.Length - 1); * if (Ingress.EndsWith(",")) * Ingress = Ingress.Remove(Ingress.Length - 1); * if (Ingress.EndsWith("!")) * Ingress = Ingress.Remove(Ingress.Length - 1); * if (Ingress.EndsWith(".")) * Ingress = Ingress.Remove(Ingress.Length - 1); */ Ingress = "● " + Ingress + "..."; /* * if (Ingress.Length < 80) * { * HasIngress = false; * }*/ } DatePublished = NF.DatePosted; datePub = DatePublished.Day + "/" + DatePublished.Month + "/" + DatePublished.Year; DateLength = (datePub.Length * 7); Full = true; CategoryBig = true; CategorySmall = false; if (NF.Category == "") { } TagLength = (Tag.Length * 7); Plus = Convert.ToBoolean(NF.Plus); int BL = 100; int BH = 60; if (Header.Length < BL) { HeaderLength = BH; } else if (Header.Length < BL * 2) { HeaderLength = BH * 2; } else if (Header.Length < BL * 3) { HeaderLength = BH * 3; } if (IMGSource.ToString() == Defaultimage) { IMGSource = ""; IHR = 1; CBWR = 7; CBHR = HeaderLength; BHR = HeaderLength; CBHO = LayoutOptions.Start; CBVO = LayoutOptions.FillAndExpand; Full = false; CategoryBig = false; CategorySmall = true; INGHR = 36; } else { IHR = 200; BHR = 200 + HeaderLength; CBWR = 200; CBHR = 7; CBHO = LayoutOptions.FillAndExpand; CBVO = LayoutOptions.Start; INGHR = 54; } if (argc != 0) { IsNormalfeed = false; HasIngress = false; TagVisible = false; } else { IsNormalfeed = true; } ArticleReactions = NF.ArtikelReactions; ReactionSum = NF.ReactionSum; var ReactionList = JsonConvert.DeserializeObject <List <ReactionTable> >(ReactionSum); foreach (ReactionTable Reaction in ReactionList) { if (Reaction.User == App.LoggedinUser.ID) { ReactionSrc = "reactions_" + Reaction.Reaktion + ".png"; break; } else { ReactionSrc = "reactions_gray.png"; } } int MaxValue = 0; int MostPicked = 0; for (int i = 0; i < 8; i++) { int CurValue = 0; foreach (ReactionTable Reaction in ReactionList) { if (Reaction.Reaktion == i) { CurValue++; } } if (CurValue > MaxValue) { MaxValue = CurValue; MostPicked = i; } } ReactionSrcOthers = "reactions_" + MostPicked + ".png"; ReactionNR = MaxValue; Console.WriteLine("Artikel Klar"); }
public Article(NewsfeedTable NF, int argc) { ReactionNR = 1337; Tag = NF.Category.Split(new[] { ", " }, StringSplitOptions.None)[0]; ID = NF.Article; Header = NF.Header.Replace("*", "-").Replace(""", "'"); IMGSource = NF.Image; if (!NF.Ingress.Any()) // If the ingress is empty, skip construction otherwise make a window whose size is based on the length of the Ingress. { HasIngress = false; Ingress = NF.Ingress; } else { Ingress = NF.Ingress; var properties = App.Current.Properties; if (properties.ContainsKey("showingress")) { HasIngress = (bool)properties["showingress"]; } else { HasIngress = true; } Ingress = NF.Ingress; int IL = 40; int IH = 17; if (Ingress.Length < IL) { INGHR = IH; } else if (Ingress.Length < IL * 2) { INGHR = IH * 2; } else if (Ingress.Length < IL * 3) { INGHR = IH * 3; } Ingress = "● " + Ingress + "..."; } DatePublished = NF.DatePosted; datePub = DatePublished.Day + "/" + DatePublished.Month + "/" + DatePublished.Year; DateLength = (datePub.Length * 7); Full = true; CategoryBig = true; CategorySmall = false; if (NF.Category == "") { } TagLength = (Tag.Length * 7); Plus = Convert.ToBoolean(NF.Plus); int BL = 100; int BH = 60; if (Header.Length < BL) { HeaderLength = BH; } else if (Header.Length < BL * 2) { HeaderLength = BH * 2; } else if (Header.Length < BL * 3) { HeaderLength = BH * 3; } if (IMGSource.ToString() == Defaultimage) { IMGSource = ""; IHR = 1; CBWR = 7; CBHR = HeaderLength; BHR = HeaderLength; CBHO = LayoutOptions.Start; CBVO = LayoutOptions.FillAndExpand; Full = false; CategoryBig = false; CategorySmall = true; INGHR = 36; } else { IHR = 200; BHR = 200 + HeaderLength; CBWR = 200; CBHR = 7; CBHO = LayoutOptions.FillAndExpand; CBVO = LayoutOptions.Start; INGHR = 54; } if (argc != 0) { IsNormalfeed = false; HasIngress = false; TagVisible = false; } else { IsNormalfeed = true; } ArticleReactions = NF.ArtikelReactions; ReactionSum = NF.ReactionSum; var ReactionList = JsonConvert.DeserializeObject <List <ReactionTable> >(ReactionSum); foreach (ReactionTable Reaction in ReactionList) { if (Reaction.User == App.LoggedinUser.ID) { ReactionSrc = "reactions_" + Reaction.Reaktion + ".png"; break; } else { ReactionSrc = "reactions_gray.png"; } } int MaxValue = 0; int MostPicked = 0; for (int i = 0; i < 8; i++) { int CurValue = 0; foreach (ReactionTable Reaction in ReactionList) { if (Reaction.Reaktion == i) { CurValue++; } } if (CurValue > MaxValue) { MaxValue = CurValue; MostPicked = i; } } ReactionSrcOthers = "reactions_" + MostPicked + ".png"; ReactionNR = MaxValue; Console.WriteLine("Artikel Klar"); }