protected override void OnClicked(int controlId, GUIControl control, Action.ActionType actionType) { base.OnClicked(controlId, control, actionType); if (facade != null && controlId == facade.GetID) { switch (actionType) { case Action.ActionType.ACTION_SELECT_ITEM: newGUIHandler.ItemSelected(); break; case Action.ActionType.ACTION_NEXT_ITEM: newGUIHandler.LaunchDocument(); break; } } else if (control == goodmergeList) { newGUIHandler.GoodMergeClicked(actionType); } //Layout button else if (buttonLayout != null && controlId == buttonLayout.GetID) { int view = MenuPresenter.ShowLayoutDialog(GetID); if (view < 0) { return; } newGUIHandler.setLayout(view, true); } //Most played button else if (buttonSort == control) { ListItemProperty sortProperty = MenuPresenter.ShowSortDialog(GetID, newGUIHandler.SortEnabled); if (sortProperty != ListItemProperty.NONE && sortProperty != newGUIHandler.SortProperty) { newGUIHandler.SortProperty = sortProperty; newGUIHandler.Sort(); } } else if (buttonViews == control) { newGUIHandler.SwitchView(); } else if (details_play == control) { newGUIHandler.LaunchGame(); } else if (buttonImport == control) { newGUIHandler.RestartImporter(); } }
public void SetLabel2(ListItemProperty property) { if (associatedGame == null) { return; } switch (property) { case ListItemProperty.COMPANY: Label2 = associatedGame.Company; break; case ListItemProperty.GRADE: Label2 = associatedGame.Grade.ToString(); break; case ListItemProperty.LASTPLAYED: if (associatedGame.Latestplay != DateTime.MinValue) { Label2 = associatedGame.Latestplay.ToShortDateString(); } else { Label2 = Translator.Instance.never; } break; case ListItemProperty.PLAYCOUNT: Label2 = associatedGame.Playcount.ToString(); break; case ListItemProperty.YEAR: if (ReleaseYear > 0) { Label2 = ReleaseYear.ToString(); } else { Label2 = ""; } break; default: Label2 = ""; break; } }
public void SetLabel2(ListItemProperty property) { if (associatedGame == null) return; switch (property) { case ListItemProperty.COMPANY: Label2 = associatedGame.Developer; break; case ListItemProperty.GRADE: Label2 = associatedGame.Grade.ToString(); break; case ListItemProperty.LASTPLAYED: if (associatedGame.Latestplay != DateTime.MinValue) Label2 = associatedGame.Latestplay.ToShortDateString(); else Label2 = Translator.Instance.never; break; case ListItemProperty.PLAYCOUNT: Label2 = associatedGame.PlayCount.ToString(); break; case ListItemProperty.YEAR: if (ReleaseYear > 0) Label2 = ReleaseYear.ToString(); else Label2 = ""; break; default: Label2 = ""; break; } }
private static ConfigItemNode GetNode(object configItem, DescriptorInfo descriptor) { ConfigItemNode result = new ConfigItemNode { Properties = new ObservableCollection <ConfigItemProperty>(), SubNodes = new ObservableCollection <ConfigItemNode>() }; var propertyInfos = configItem.GetType().GetProperties(BindingFlags.Public | BindingFlags.GetProperty | BindingFlags.Instance); foreach (var pInfo in propertyInfos) { var setter = pInfo.GetSetMethod(); if (setter == null) { continue; } var value = pInfo.GetValue(configItem); var valueDescriptor = GetOrCreateDescriptorInfo(pInfo.Name, pInfo.PropertyType, descriptor.PropertyDescriptors, pInfo.GetCustomAttribute(typeof(DescriptorAttribute)) as DescriptorAttribute); if (IsValue(pInfo.PropertyType, out bool isList)) { //property if (value == null && isList) { //构造默认list value = valueDescriptor.DefaultValue ?? new ObservableCollection <object>(); } if (isList) { value = ConvertToListValue(value, valueDescriptor); } ConfigItemProperty tmpP = null; if (isList) { tmpP = new ListItemProperty(); } else { tmpP = new ConfigItemProperty(); } tmpP.Descriptor = valueDescriptor; tmpP.Value = value; if (value == null && valueDescriptor.DefaultValue != null) { //没有值,就使用默认值 tmpP.Value = valueDescriptor.DefaultValue; } result.Properties.Add(tmpP); } else { //node if (value == null) { value = Activator.CreateInstance(pInfo.PropertyType); } var subPropertyTypes = value.GetType().GetProperties(BindingFlags.Public | BindingFlags.GetProperty | BindingFlags.Instance); var tmpNode = GetNode(value, valueDescriptor); result.SubNodes.Add(tmpNode); } } //拷贝,不破坏元对象。只需要保留当前级的信息,节约内存 string oldPropertyName = descriptor.PropertyName; descriptor = DeepClone(descriptor); //因为propertyName没有 setter,所以需要重新复制 DescriptorInfo.SetPropertyName(oldPropertyName, descriptor); result.Descriptor = descriptor; return(result); }
set => SetValue(ListItemProperty, value);