public ViewItem(L4D2MM.ModInfo mod) { Mod = mod; ID = mod.Mod.FileName + (mod.Mod.Title.Length > 0? (" (" + mod.Mod.Title + ')') : ""); //Source = mod.Source.GetString(); //State = mod.ModState.GetString(); //Size = mod.Mod.FileSize.ToFileSize(); }
private void ListViewSelectionChanged(object sender, SelectionChangedEventArgs e) { if (e.AddedItems.Count == 1) { ViewItem item = e.AddedItems[0] as ViewItem; if (m_manager.Mods.ContainsKey(item.Key)) { Logging.Log("view list select item : " + item.Key); L4D2MM.ModInfo mod = m_manager.Mods[item.Key]; LoadModInfo(mod); } } }
private void LoadModInfo(L4D2MM.ModInfo mod) { if (mod == null) { return; } LoadedModInfo = mod; var fontSize = this.FontSize; m_displayedKey = mod.Key; ctlFrameText.Document.Blocks.Clear(); if (mod.Mod.ImageMemoryStream != null) { ctlImage.SetSource(mod.Mod.GetAndResetImageMemoryStream()); } else { ctlImage.SetSource(null);//or show the default image } if (mod.Mod.Title.Length > 0) { Run run = new Run(mod.Mod.Title); run.FontSize = fontSize + 4; run.Foreground = new SolidColorBrush(Colors.Black); run.FontWeight = FontWeights.Bold; ctlFrameText.Document.Blocks.Add(new Paragraph(run)); } if (mod.Mod.Category.Count > 0) { Run run = new Run(StringAdapter.GetResource("Category") + " : " + mod.Mod.Category.Aggregate("", (s, c) => s += ", " + c.ToString()).Substring(2)); run.FontSize = fontSize; run.Foreground = new SolidColorBrush(Colors.Gray); run.FontWeight = FontWeights.Normal; ctlFrameText.Document.Blocks.Add(new Paragraph(run)); } foreach (var box in CustomInformation.Instance.ViewBoxes) { if (CheckModInfoReflection(box.Reflection)) { string content = (box.TryTranslate ? StringAdapter.GetResource(box.Header) : box.Header) + " : \r\n"; string reflection = typeof(L4D2Mod).InvokeMember(box.Reflection, System.Reflection.BindingFlags.GetProperty, null, mod.Mod, null).Display(); if (reflection.Length > 0) { Run run = new Run(content + reflection); run.FontSize = fontSize; run.Foreground = new SolidColorBrush(box.Color); run.FontWeight = FontWeights.Normal; ctlFrameText.Document.Blocks.Add(new Paragraph(run)); } } } if (ctlFrameText.Document.Blocks.Count <= 0) { Run run = new Run('(' + StringAdapter.GetResource("No_Information") + ')'); run.FontSize = fontSize; run.Foreground = new SolidColorBrush(Colors.Gray); run.FontWeight = FontWeights.Normal; ctlFrameText.Document.Blocks.Add(new Paragraph(run)); } }