// TODO: The TabGenerator class works better than these custom generators public static GDbTab LoadSItemsTab <TKey>(GenericDatabase database, TabControl control, BaseDb gdb) { AbstractDb <TKey> db = gdb.To <TKey>(); AttributeList list = ServerItemProperties.AttributeList; GDbTabWrapper <TKey, ReadableTuple <TKey> > tab = new GDbTabWrapper <TKey, ReadableTuple <TKey> >(); GTabSettings <TKey, ReadableTuple <TKey> > settings = new GTabSettings <TKey, ReadableTuple <TKey> >(db); SInit(settings); settings.AttributeList = list; settings.AttId = list.PrimaryAttribute; settings.AttDisplay = ServerItemProperties.Name; DisplayableProperty <TKey, ReadableTuple <TKey> > generalProperties = new DisplayableProperty <TKey, ReadableTuple <TKey> >(); generalProperties.Spacing = 0; int line = 0; Print(ref line, new SpecifiedRangeIndexProvider(new int[] { ServerItemProperties.Id.Index, 1, ServerItemProperties.Type.Index, 1, ServerItemProperties.AegisName.Index, 2, ServerItemProperties.Buy.Index, 2, ServerItemProperties.Weight.Index, 16 }), generalProperties, list); generalProperties.AddCustomProperty(new CustomQueryViewerMobDroppedBy <TKey, ReadableTuple <TKey> >(line, 0, 1, 2)); generalProperties.SetRow(line, new GridLength(1, GridUnitType.Star)); Grid grid = PrintGrid(ref line, 3, 1, 2, new DefaultIndexProvider(ServerItemProperties.BindOnEquip.Index, 8), -1, 0, -1, 0, generalProperties, list); generalProperties.AddDeployAction(delegate { grid.Children[0].IsEnabled = false; grid.Children[1].IsEnabled = false; grid.Children[4].IsEnabled = false; grid.Children[5].IsEnabled = false; }); settings.DisplayablePropertyMaker = generalProperties; settings.ClientDatabase = database; settings.SearchEngine.SetAttributes( settings.AttId, settings.AttDisplay, ServerItemProperties.AegisName, null, ServerItemProperties.ApplicableJob, ServerItemProperties.Script, ServerItemProperties.OnEquipScript, ServerItemProperties.OnUnequipScript, ServerItemProperties.Type, ServerItemProperties.Gender ); settings.SearchEngine.SetSettings(ServerItemProperties.Id, true); settings.SearchEngine.SetSettings(ServerItemProperties.Name, true); settings.SearchEngine.SetSettings(ServerItemProperties.AegisName, true); settings.SearchEngine.SetupImageDataGetter = delegate(ReadableTuple <TKey> tuple) { tuple.GetImageData = delegate { try { var cDb = database.GetTable <int>(ServerDbs.ClientResourceDb); if (cDb == null) { return(null); } int id = tuple.GetKey <int>(); if (!cDb.ContainsKey(id)) { return(null); } byte[] data = database.MetaGrf.GetData(EncodingService.FromAnyToDisplayEncoding(@"data\texture\À¯ÀúÀÎÅÍÆäÀ̽º\item\" + cDb.GetTuple(id).GetValue <string>(ClientResourceAttributes.ResourceName) + ".bmp")); if (data != null) { GrfImage gimage = new GrfImage(ref data); gimage.MakePinkTransparent(); return(gimage.Cast <BitmapSource>()); } return(null); } catch { return(null); } }; }; settings.AddedCommands.Add(new GItemCommand <TKey, ReadableTuple <TKey> > { AllowMultipleSelection = true, DisplayName = "Copy entries to clipboard (rAthena)", ImagePath = "export.png", InsertIndex = 3, Shortcut = ApplicationShortcut.Copy, AddToCommandsStack = false, GenericCommand = delegate(List <ReadableTuple <TKey> > items) { StringBuilder builder = new StringBuilder(); DbWriterMethods.DbItemsWriterSub(builder, db, items.OrderBy(p => p.GetKey <TKey>()), ServerType.RAthena); Clipboard.SetText(builder.ToString()); } }); settings.AddedCommands.Add(new GItemCommand <TKey, ReadableTuple <TKey> > { AllowMultipleSelection = true, DisplayName = "Copy entries to clipboard (Hercules)", ImagePath = "export.png", InsertIndex = 4, Shortcut = ApplicationShortcut.Copy2, AddToCommandsStack = false, GenericCommand = delegate(List <ReadableTuple <TKey> > items) { StringBuilder builder = new StringBuilder(); DbWriterMethods.DbItemsWriterSub(builder, db, items, ServerType.Hercules); Clipboard.SetText(builder.ToString(), TextDataFormat.UnicodeText); } }); settings.Table = db.Table; tab.Initialize(settings); AddTagGeneratorTabChangedEvent(control, tab, settings, gdb); return(tab); }