private void _reload() { ID = _tuple.GetValue <int>(_index); Name = ""; if (_itemsTable.ContainsKey(ID)) { Name = (string)_itemsTable.GetTuple(ID).GetRawValue(ServerItemAttributes.Name.Index); } DropOriginal = Int32.Parse(((string)_tuple.GetRawValue(_index + 1))); Drop = String.Format("{0:0.00} %", DropOriginal / 100f); MVP = _index < ServerMobAttributes.Drop1ID.Index ? "MVP" : ""; if (DbPathLocator.IsYamlMob()) { int b = (AttributeIndex - ServerMobAttributes.Drop1ID.Index) / 2; int distRandGroup = ServerMobAttributes.Drop1RandomOptionGroup.Index + b; int distSteal = ServerMobAttributes.Drop1Flags.Index + b; StealProtected = Boolean.Parse(_tuple.GetRawValue <string>(distSteal)); RandomOptionGroup = (_tuple.GetRawValue(distRandGroup) ?? "").ToString(); } }
private void _miCopy_Click(object sender, RoutedEventArgs e) { if (_lv.SelectedItems.Count > 0) { StringBuilder builder = new StringBuilder(); if (DbPathLocator.IsYamlMob()) { foreach (MobDropView item in _lv.SelectedItems) { builder.Append(item.ID); builder.Append(","); builder.Append(item.DropOriginal); builder.Append(","); builder.Append(item.StealProtected); builder.Append(","); builder.Append(item.RandomOptionGroup); builder.Append(","); } } else { foreach (MobDropView item in _lv.SelectedItems) { builder.Append(item.ID); builder.Append(","); builder.Append(item.DropOriginal); builder.Append(","); } } string res = builder.ToString().Trim(','); Clipboard.SetDataObject(res); } }
public static void CheckAttributeRestrictions <TKey>(GDbTabWrapper <TKey, ReadableTuple <TKey> > tab, GTabSettings <TKey, ReadableTuple <TKey> > settings, BaseDb gdb) { foreach (var attributeS in settings.AttributeList.Attributes) { DbAttribute attribute = attributeS; if (attribute.Requirements.Renewal == RenewalType.Both && attribute.Requirements.Server == ServerType.Both) { continue; } tab.PropertiesGrid.Dispatch(delegate { var gridAttributes = GetAll(tab.PropertiesGrid, attribute); RenewalType rType = DbPathLocator.GetIsRenewal() ? RenewalType.Renewal : RenewalType.PreRenewal; ServerType sType = DbPathLocator.GetServerType(); gridAttributes.ForEach(p => p.IsEnabled = false); if ((attribute.Requirements.Renewal & rType) == rType && (attribute.Requirements.Server & sType) == sType) { gridAttributes.ForEach(p => p.IsEnabled = true); } else { gridAttributes.ForEach(p => p.IsEnabled = false); } }); } }
public static void DbDirectCopyWriter <TKey>(DbDebugItem <TKey> debug, AbstractDb <TKey> db) { try { if (debug.OldPath != debug.FilePath) { var storeCompareList = db.Attached["StoreCompare"] as List <string>; if (storeCompareList != null) { foreach (var path in storeCompareList) { var oldPath = DbPathLocator.GetStoredFile(path); if (!IOHelper.SameFile(oldPath, path)) { // Test their modified date IOHelper.Delete(path); IOHelper.Copy(oldPath, path); } } } else if (!IOHelper.SameFile(debug.OldPath, debug.FilePath)) { // Test their modified date IOHelper.Delete(debug.FilePath); IOHelper.Copy(debug.OldPath, debug.FilePath); } } } catch (Exception err) { debug.ReportException(err); } }
public DisplayLabel() { FocusVisualStyle = null; Margin = new Thickness(-4, -4, 0, -4); Padding = new Thickness(0); FontSize = 12; MouseEnter += delegate { if (_dbSource != null) { if (FtpHelper.HasBeenMapped()) { ToolTip = DbPathLocator.DetectPath(_dbSource); } else { ToolTip = "Directory has not been mapped yet. Load the database first."; } } if (ToolTip == null) { ToolTip = "File not found. This database will be disabled."; } }; SizeChanged += delegate { if (!_isLoaded) { Grid presenter = WpfUtilities.FindParentControl <Grid>(this); TextBox box = (TextBox)presenter.Children[2]; if (box.Text == "Visible") { Foreground = _stateBrush; } else { Foreground = _stateInactiveBrush; } box.TextChanged += delegate { if (box.Text == "Visible") { Foreground = _stateBrush; } else { Foreground = _stateInactiveBrush; } }; _isLoaded = true; } }; }
public void Show(ServerType serverType, bool?renewal, params DbAttribute[] attributes) { bool enable = DbPathLocator.GetServerType() == serverType; if (renewal == null || renewal.Value == DbPathLocator.GetIsRenewal()) { Show(enable, attributes); } }
/// <summary> /// Reloads the database. /// </summary> /// <param name="progress">The progress object.</param> public void Reload(IProgress progress) { DbDebugHelper.OnUpdate("Reloading database..."); OnPreviewReloaded(); try { IOHelper.SetupFileManager(); Commands.ClearCommands(); DbPathLocator.ClearStoredFiles(); ResetAllSettings(); var dbs = _dbs.Values.ToList(); for (int i = 0; i < dbs.Count; i++) { dbs[i].Clear(); DbDebugHelper.OnCleared(dbs[i].DbSource, null, dbs[i]); } DbDebugHelper.OnUpdate("All database tables have been cleared."); for (int i = 0; i < dbs.Count; i++) { var db = dbs[i]; if (db.CanBeLoaded) { CLHelper.CStart(i); db.LoadDb(); if (progress != null) { progress.Progress = (i + 1f) / dbs.Count * 100f; //ErrorHandler.HandleException("Now at " + progress.Progress + "% done."); } CLHelper.CStopAndDisplay(db.DbSource.DisplayName, i); } if (progress != null) { AProgress.IsCancelling(progress); } } ClearCommands(); } finally { DbDebugHelper.OnUpdate("Database reloaded..."); } OnReloaded(); SdeEditor.Instance.Dispatch(p => p.OnSelectionChanged()); }
private static ServerType _convertServerType(string type) { ServerType sType = (ServerType)Enum.Parse(typeof(ServerType), type); if (sType == ServerType.Unknown) { sType = DbPathLocator.GetServerType(); } return(sType); }
/// <summary> /// Saves the database. /// </summary> /// <param name="ap">The progress object.</param> /// <param name="progress"> </param> public virtual void Save(AsyncOperation ap, IProgress progress) { string dbPath = GrfPath.GetDirectoryName(ProjectConfiguration.DatabasePath); string subPath = ProjectConfiguration.DatabasePath.Replace(dbPath, "").TrimStart('\\', '/'); ServerType serverType = DbPathLocator.GetServerType(); DbDebugHelper.OnUpdate("Saving tables."); MetaGrf.Clear(); try { BackupEngine.Instance.Start(ProjectConfiguration.DatabasePath); var dbs = _dbs.Values.ToList(); IOHelper.SetupFileManager(); for (int i = 0; i < dbs.Count; i++) { var db = dbs[i]; db.WriteDb(dbPath, subPath, serverType); if (progress != null) { progress.Progress = AProgress.LimitProgress((i + 1f) / dbs.Count * 100f); } } foreach (var db in dbs) { db.SaveCommandIndex(); } Commands.SaveCommandIndex(); } catch (Exception err) { ErrorHandler.HandleException(err); } finally { if (ap != null && progress != null) { progress.Progress = ap.ProgressBar.GetIntermediateState("Backup manager"); } BackupEngine.Instance.Stop(); DbDebugHelper.OnUpdate("Finished saving tables."); } }
private void _lv_PreviewMouseRightButtonUp(object sender, MouseButtonEventArgs e) { try { if (DbPathLocator.IsYamlMob()) { bool hasItems = _lv.GetObjectAtPoint <ListViewItem>(e.GetPosition(_lv)) != null; _lv.ContextMenu.Items.Cast <UIElement>().Take(5).ToList().ForEach(p => p.Visibility = hasItems ? Visibility.Visible : Visibility.Collapsed); _lv.ContextMenu.Items.Cast <UIElement>().Last().Visibility = Visibility.Collapsed; } else { bool hasItems = _lv.GetObjectAtPoint <ListViewItem>(e.GetPosition(_lv)) != null; _lv.ContextMenu.Items.Cast <UIElement>().Take(5).ToList().ForEach(p => p.Visibility = hasItems ? Visibility.Visible : Visibility.Collapsed); } } catch (Exception err) { ErrorHandler.HandleException(err); } }
public static void DbSqlMobs(DbDebugItem <int> debug, AbstractDb <int> db) { DbSqlWriter writer = new DbSqlWriter(); writer.Init(debug); if (DbPathLocator.DetectPath(debug.DbSource).EndsWith(".conf")) { object value = db.Attached["EntireRewrite"]; db.Attached["EntireRewrite"] = true; DbIOMethods.DbWriterComma(debug, db); db.Attached["EntireRewrite"] = value; } else { DbIOMethods.DbWriterComma(debug, db); } if (debug.DestinationServer == ServerType.RAthena) { writer.AppendHeader(ResourceString.Get("RAthenaMobDbSqlHeader")); } else if (debug.DestinationServer == ServerType.Hercules) { writer.AppendHeader(ResourceString.Get("HerculesMobDbSqlHeader"), writer.TableName.Replace("_re", "")); writer.TableName = "mob_db"; } foreach (string line in writer.Read()) { string[] elements = TextFileHelper.ExcludeBrackets(line.Trim('\t')); if (!_getMob(writer.IsHercules, writer.TableName, writer.Builder, elements)) { writer.Line(writer.IsHercules ? line.ReplaceFirst("//", "--" + (writer.NumberOfLinesProcessed > 1 ? " " : "")) : line.ReplaceFirst("//", "#")); } else { writer.NumberOfLinesProcessed++; } } writer.Write(); }
public static void DbItemsWriter(DbDebugItem <int> debug, AbstractDb <int> db) { try { StringBuilder builder = new StringBuilder(); if (debug.FileType == FileType.Txt) { if (DbPathLocator.GetServerType() == ServerType.RAthena) { DbIOMethods.DbWriterComma(debug, db, 0, ServerItemAttributes.OnUnequipScript.Index + 1, (tuple, items) => { if (db.ProjectDatabase.IsRenewal) { string value = tuple.GetValue <string>(ServerItemAttributes.Matk) ?? ""; if (value == "" || value == "0") { return; } string atk = items[ServerItemAttributes.Attack.Index].ToString(); items[ServerItemAttributes.Attack.Index] = (atk == "" ? "0" : atk) + ":" + value; } }); return; } DbItemsWriterSub(builder, db, db.Table.FastItems.OrderBy(p => p.GetKey <int>()), ServerType.RAthena); FtpHelper.WriteAllText(debug.FilePath, builder.ToString()); } else if (debug.FileType == FileType.Conf) { DbIOMethods.DbIOWriterConf(debug, db, (r, q) => WriteEntry(db, r, q)); } else if (debug.FileType == FileType.Sql) { SqlParser.DbSqlItems(debug, db); } } catch (Exception err) { debug.ReportException(err); } }
public static bool IsTabEnabled(GTabSettings <TKey, ReadableTuple <TKey> > settings, BaseDb gdb) { if (DbPathLocator.DetectPath(settings.DbData) == null) { return(false); } if (!gdb.IsEnabled) { return(false); } if (!Boolean.Parse(ProjectConfiguration.ConfigAsker["[Server database editor - Enabled state - " + settings.DbData.DisplayName + "]", true.ToString()])) { return(false); } return(true); }
private void _miRemoveDrop_Click(object sender, RoutedEventArgs e) { if (_lv.SelectedItems.Count <= 0) { return; } Table <int, ReadableTuple <int> > btable = _tab.ProjectDatabase.GetMetaTable <int>(ServerDbs.Mobs); btable.Commands.Begin(); try { for (int i = 0; i < _lv.SelectedItems.Count; i++) { var selectedItem = (MobDropView)_lv.SelectedItems[i]; var p = (ReadableTuple <int>)_tab.List.SelectedItem; btable.Commands.Set(p, selectedItem.AttributeIndex, 0); btable.Commands.Set(p, selectedItem.AttributeIndex + 1, 0); if (DbPathLocator.IsYamlMob()) { int b = (selectedItem.AttributeIndex - ServerMobAttributes.Drop1ID.Index) / 2; int distRandGroup = ServerMobAttributes.Drop1RandomOptionGroup.Index + b; int distSteal = ServerMobAttributes.Drop1Flags.Index + b; btable.Commands.Set(p, distRandGroup, 0); btable.Commands.Set(p, distSteal, "false"); } ((RangeObservableCollection <MobDropView>)_lv.ItemsSource).Remove(selectedItem); i--; } } catch (Exception err) { ErrorHandler.HandleException(err); } btable.Commands.EndEdit(); }
public static void Writer2 <TKey>(ReadableTuple <TKey> item, ServerType destServer, StringBuilder builder, BaseDb db, List <string> aegisNames, List <string> names) { var itemCopy = new ReadableTuple <TKey>(item.GetKey <TKey>(), item.Attributes); itemCopy.Copy(item); item = itemCopy; int key = item.GetKey <int>(); if (destServer == ServerType.RAthena) { var itemDb = db.GetMeta <int>(ServerDbs.Items); ServerType source = DbPathLocator.GetServerType(); if (source == ServerType.Hercules) { List <string> constantsList = Constants.Keys.ToList(); Table <int, ReadableTuple <int> > table = db.GetMeta <int>(ServerDbs.Items); var tuple = item; var res2 = table.TryGetTuple(key); if (res2 != null) { string name = res2.GetValue(ServerItemAttributes.AegisName).ToString(); int low = Int32.MaxValue; int index = -1; for (int j = 0; j < Constants.Count; j++) { int dist = Methods.LevenshteinDistance(name, constantsList[j]); if (dist < low) { low = dist; index = j; } } string closestString = constantsList[index]; int groupId = Constants[closestString]; tuple.SetRawValue(0, groupId); } } Dictionary <int, ReadableTuple <int> > dico = (Dictionary <int, ReadableTuple <int> >)item.GetRawValue(1); key = item.GetKey <int>(); foreach (var pair in dico.OrderBy(p => p.Key)) { var dbTuple = itemDb.TryGetTuple(pair.Key); List <string> items = ServerItemGroupSubAttributes.AttributeList.Attributes.Select(p => pair.Value.GetValue <string>(p)).ToList(); RemoveDefaultValues(items); builder.AppendLine(key + "," + string.Join(",", items.ToArray()) + (dbTuple == null ? "" : "\t// " + dbTuple.GetValue(ServerItemAttributes.Name))); } builder.AppendLine(); } else if (destServer == ServerType.Hercules) { builder.AppendLine(ItemGroupParser.ToHerculesDbEntry(db, item.GetKey <int>(), aegisNames, names)); builder.AppendLine(); } }
private void _validateMobDb(MetaTable <int> db, List <ValidationErrorView> errors) { foreach (var tuple in db.FastItems) { if (SdeAppConfiguration.DbValidMaxItemDbId >= 0) { if (tuple.Key <= 1000 || tuple.Key > SdeAppConfiguration.DbValidMaxMobDbId) { errors.Add(new TableError(ValidationErrors.TbMobId, tuple.Key, String.Format("Invalid monster ID {0}, allowed values {1} < ID <= {2} (MAX_MOB_DB).", tuple.Key, 1000, SdeAppConfiguration.DbValidMaxMobDbId), ServerDbs.Mobs, this)); } } if (_pcCheckId((uint)tuple.Key)) { errors.Add(new TableError(ValidationErrors.TbReservedId, tuple.Key, String.Format("Invalid monster ID {0}, reserved for player classes.", tuple.Key), ServerDbs.Mobs, this)); } if (tuple.Key >= (SdeAppConfiguration.DbValidMaxMobDbId - 999) && tuple.Key < SdeAppConfiguration.DbValidMaxMobDbId) { errors.Add(new TableError(ValidationErrors.TbInvalidRange, tuple.Key, String.Format("Invalid monster ID {0}. Range {1}-{2} is reserved for player clones. Please increase MAX_MOB_DB ({3}).", tuple.Key, SdeAppConfiguration.DbValidMaxMobDbId - 999, SdeAppConfiguration.DbValidMaxMobDbId - 1, SdeAppConfiguration.DbValidMaxMobDbId), ServerDbs.Mobs, this)); } var level = tuple.GetIntNoThrow(ServerMobAttributes.Lv); var minAtk = tuple.GetIntNoThrow(ServerMobAttributes.Atk1); var maxAtk = tuple.GetIntNoThrow(ServerMobAttributes.Atk2); var def = tuple.GetIntNoThrow(ServerMobAttributes.Def); var mdef = tuple.GetIntNoThrow(ServerMobAttributes.Mdef); //var baseExp = tuple.GetIntNoThrow(ServerMobAttributes.Lv); //var jobExp = tuple.GetIntNoThrow(ServerMobAttributes.Lv); _capValue(level, "level", 1, 0xffff, tuple, errors); _capValue(minAtk, "minAtk", 0, 0xffff, tuple, errors); _capValue(maxAtk, "maxAtk", 0, 0xffff, tuple, errors); var isRenewal = DbPathLocator.GetIsRenewal(); _capValue(def, "def", isRenewal ? -32768 : -128, isRenewal ? 32767 : 127, tuple, errors); _capValue(mdef, "mdef", isRenewal ? -32768 : -128, isRenewal ? 32767 : 127, tuple, errors); for (int i = 0; i < 6; i++) { var value = tuple.GetIntNoThrow(ServerMobAttributes.Str.Index + i); _capValue(value, ServerMobAttributes.AttributeList.Attributes[ServerMobAttributes.Str.Index + i].DisplayName, 0, 0xffff, tuple, errors); } var defEle = tuple.GetIntNoThrow(ServerMobAttributes.Element) % 10; var eleLevel = tuple.GetIntNoThrow(ServerMobAttributes.Element) / 20; if (defEle >= SdeAppConfiguration.DbValidMaxMobDbElement) { errors.Add(new TableError(ValidationErrors.TbElementType, tuple.Key, String.Format("Invalid element type {0} for monster ID {1} (max = {2}).", defEle, tuple.Key, SdeAppConfiguration.DbValidMaxMobDbElement - 1), ServerDbs.Mobs, this)); } if (eleLevel < 1 || eleLevel > 4) { errors.Add(new TableError(ValidationErrors.TbElementLevel, tuple.Key, String.Format("Invalid element level {0} for monster ID {1}, must be in range 1-4.", eleLevel, tuple.Key), ServerDbs.Mobs, this)); } var adelay = tuple.GetIntNoThrow(ServerMobAttributes.AttackDelay); var amotion = tuple.GetIntNoThrow(ServerMobAttributes.AttackMotion); var hp = (long)tuple.GetIntNoThrow(ServerMobAttributes.Hp); var mexp = (long)tuple.GetIntNoThrow(ServerMobAttributes.MvpExp); _capValue(adelay, "aDelay", 0, 4000, tuple, errors); _capValue(amotion, "aMotion", 0, 2000, tuple, errors); _capValue(hp, "HP", 0, Int32.MaxValue, tuple, errors); _capValue(mexp, "MExp", 0, Int32.MaxValue, tuple, errors); } }
private void _miAddCardDrop_Click(object sender, RoutedEventArgs e) { if (DbPathLocator.IsYamlMob()) { return; } TValue item = (TValue)_tab.List.SelectedItem; if (item.GetValue <int>(ServerMobAttributes.DropCardid) != 0) { _lv.SelectedItem = _lv.Items.OfType <MobDropView>().FirstOrDefault(p => p.IsCard); _miEditDrop_Click(sender, e); return; } Table <int, ReadableTuple <int> > btable = _tab.ProjectDatabase.GetMetaTable <int>(ServerDbs.Mobs); try { DropEditDialog dialog = new DropEditDialog("", "", ServerDbs.Items, _tab.ProjectDatabase, true); dialog.Owner = WpfUtilities.TopWindow; if (dialog.ShowDialog() == true) { string sid = dialog.Id; string svalue = dialog.DropChance; int value; int id; Int32.TryParse(sid, out id); if (id <= 0) { return; } if (!Extensions.GetIntFromFloatValue(svalue, out value)) { ErrorHandler.HandleException("Invalid format (integer or float value only)"); return; } try { btable.Commands.Begin(); int startIndex = ServerMobAttributes.DropCardid.Index; for (int i = 0; i < 2; i += 2) { if (item.GetValue <int>(startIndex + i) == 0) { btable.Commands.Set((ReadableTuple <int>)(object) item, startIndex + i, id); btable.Commands.Set((ReadableTuple <int>)(object) item, startIndex + i + 1, value); break; } } } finally { btable.Commands.EndEdit(); } //_lv.Items.OfType<MobDropView>().ToList().ForEach(p => p.RemoveEvents()); _lv.ItemsSource = null; _updateAction(item); } } catch (Exception err) { ErrorHandler.HandleException(err); } }
private void _miEditDrop_Click(object sender, RoutedEventArgs e) { if (_lv.SelectedItems.Count <= 0) { return; } Table <int, ReadableTuple <int> > btable = _tab.ProjectDatabase.GetMetaTable <int>(ServerDbs.Mobs); try { var selectedItem = (MobDropView)_lv.SelectedItem; DropEditDialog dialog = new DropEditDialog(selectedItem.ID.ToString(CultureInfo.InvariantCulture), selectedItem.DropOriginal.ToString(CultureInfo.InvariantCulture), ServerDbs.Items, _tab.ProjectDatabase, false, DbPathLocator.IsYamlMob() ? 2 : 0); if (DbPathLocator.IsYamlMob()) { dialog._tbRandGroup.Text = selectedItem.RandomOptionGroup; } dialog.Owner = WpfUtilities.TopWindow; if (dialog.ShowDialog() == true) { string sid = dialog.Id; string svalue = dialog.DropChance; string randGroup = ""; int value; int id; if (DbPathLocator.IsYamlMob()) { randGroup = dialog.RandGroup; } Int32.TryParse(sid, out id); if (id <= 0) { return; } if (!Extensions.GetIntFromFloatValue(svalue, out value)) { ErrorHandler.HandleException("Invalid format (integer or float value only)"); return; } try { btable.Commands.Begin(); btable.Commands.Set(selectedItem.Tuple, selectedItem.AttributeIndex, id); btable.Commands.Set(selectedItem.Tuple, selectedItem.AttributeIndex + 1, value); if (DbPathLocator.IsYamlMob()) { int b = (selectedItem.AttributeIndex - ServerMobAttributes.Mvp1ID.Index) / 2; int distRandGroup = ServerMobAttributes.Mvp1RandomOptionGroup.Index + b; btable.Commands.Set(selectedItem.Tuple, distRandGroup, randGroup); } } finally { btable.Commands.EndEdit(); } selectedItem.Update(); } } catch (Exception err) { ErrorHandler.HandleException(err); } btable.Commands.EndEdit(); }
private void _miPaste_Click(object sender, RoutedEventArgs e) { try { if (_lv.Items.Count >= 3) { ErrorHandler.HandleException("You cannot add more than 3 drops. Delete an item and then add a new one."); return; } if (_tab.List.SelectedItem == null) { return; } if (!Clipboard.ContainsText()) { return; } string text = Clipboard.GetText(); string[] elementsToAdd = text.Split(','); if (DbPathLocator.IsYamlMob()) { if (elementsToAdd.Length % 3 != 0) { throw new Exception("The number of arguments must be even."); } Table <int, ReadableTuple <int> > btable = _tab.ProjectDatabase.GetMetaTable <int>(ServerDbs.Mobs); try { TValue item = (TValue)_tab.List.SelectedItem; try { btable.Commands.Begin(); int startIndex = ServerMobAttributes.Mvp1ID.Index; int i = 0; for (int j = 0; j < elementsToAdd.Length; j += 3) { string sid = elementsToAdd[j]; string svalue = elementsToAdd[j + 1]; string randGroup = elementsToAdd[j + 2]; int value; int id; Int32.TryParse(sid, out id); if (id <= 0) { return; } if (!Extensions.GetIntFromFloatValue(svalue, out value)) { ErrorHandler.HandleException("Invalid format (integer or float value only)"); return; } for (; i < 6; i += 2) { if (item.GetValue <int>(startIndex + i) == 0) { btable.Commands.Set((ReadableTuple <int>)(object) item, startIndex + i, id); btable.Commands.Set((ReadableTuple <int>)(object) item, startIndex + i + 1, value); btable.Commands.Set((ReadableTuple <int>)(object) item, ServerMobAttributes.Mvp1RandomOptionGroup.Index + (i / 2), randGroup); i += 2; break; } } } } finally { btable.Commands.EndEdit(); } _lv.ItemsSource = null; _updateAction(item); } catch (Exception err) { ErrorHandler.HandleException(err); } } else { if (elementsToAdd.Length % 2 != 0) { throw new Exception("The number of arguments must be even."); } Table <int, ReadableTuple <int> > btable = _tab.ProjectDatabase.GetMetaTable <int>(ServerDbs.Mobs); try { TValue item = (TValue)_tab.List.SelectedItem; try { btable.Commands.Begin(); int startIndex = ServerMobAttributes.Mvp1ID.Index; int i = 0; for (int j = 0; j < elementsToAdd.Length; j += 2) { string sid = elementsToAdd[j]; string svalue = elementsToAdd[j + 1]; int value; int id; Int32.TryParse(sid, out id); if (id <= 0) { return; } if (!Extensions.GetIntFromFloatValue(svalue, out value)) { ErrorHandler.HandleException("Invalid format (integer or float value only)"); return; } for (; i < 6; i += 2) { if (item.GetValue <int>(startIndex + i) == 0) { btable.Commands.Set((ReadableTuple <int>)(object) item, startIndex + i, id); btable.Commands.Set((ReadableTuple <int>)(object) item, startIndex + i + 1, value); i += 2; break; } } } } finally { btable.Commands.EndEdit(); } _lv.ItemsSource = null; _updateAction(item); } catch (Exception err) { ErrorHandler.HandleException(err); } } } catch (Exception err) { ErrorHandler.HandleException(err); } }
private void _miAddDrop_Click(object sender, RoutedEventArgs e) { if (_lv.Items.Count >= 3) { ErrorHandler.HandleException("You cannot add more than 3 MVP drops. Delete an item and then add a new one."); return; } Table <int, ReadableTuple <int> > btable = _tab.ProjectDatabase.GetMetaTable <int>(ServerDbs.Mobs); try { DropEditDialog dialog = new DropEditDialog("", "", ServerDbs.Items, _tab.ProjectDatabase, false, (DbPathLocator.IsYamlMob() ? 2 : 0)); dialog.Owner = WpfUtilities.TopWindow; if (dialog.ShowDialog() == true) { string sid = dialog.Id; string svalue = dialog.DropChance; string randGroup = ""; int value; int id; if (DbPathLocator.IsYamlMob()) { randGroup = dialog.RandGroup; } Int32.TryParse(sid, out id); if (id <= 0) { return; } if (!Extensions.GetIntFromFloatValue(svalue, out value)) { ErrorHandler.HandleException("Invalid format (integer or float value only)"); return; } TValue item = (TValue)_tab.List.SelectedItem; try { btable.Commands.Begin(); int startIndex = ServerMobAttributes.Mvp1ID.Index; for (int i = 0; i < 6; i += 2) { if (item.GetValue <int>(startIndex + i) == 0) { btable.Commands.Set((ReadableTuple <int>)(object) item, startIndex + i, id); btable.Commands.Set((ReadableTuple <int>)(object) item, startIndex + i + 1, value); if (DbPathLocator.IsYamlMob()) { btable.Commands.Set((ReadableTuple <int>)(object) item, ServerMobAttributes.Mvp1RandomOptionGroup.Index + (i / 2), randGroup); } break; } } } finally { btable.Commands.EndEdit(); } _lv.ItemsSource = null; _updateAction(item); } } catch (Exception err) { ErrorHandler.HandleException(err); } }
public static void DbItemsWriterSub <TKey>(StringBuilder builder, AbstractDb <TKey> db, IEnumerable <ReadableTuple <TKey> > tuples, ServerType to) { if (to == ServerType.RAthena) { bool fromTxtDb = DbPathLocator.DetectPath(db.DbSource).IsExtension(".txt"); foreach (ReadableTuple <TKey> tuple in tuples) { List <string> rawElements = tuple.GetRawElements().Take(22).Select(p => p.ToString()).ToList(); if (tuple.Normal && fromTxtDb && tuple.GetValue <int>(ServerItemAttributes.Matk) == 0) { builder.AppendLine(String.Join(",", rawElements.ToArray())); continue; } string script1 = tuple.GetValue <string>(19); string script2 = tuple.GetValue <string>(20); string script3 = tuple.GetValue <string>(21); string refine = tuple.GetValue <string>(17); if (refine == "") { } else if (refine == "true" || refine == "1") { refine = "1"; } else { refine = "0"; } string atk = DbIOFormatting.ZeroDefault(rawElements[7]); if (db.ProjectDatabase.IsRenewal) { string matk = tuple.GetValue <string>(ServerItemAttributes.Matk) ?? ""; if (matk != "" && matk != "0") { atk = (atk == "" ? "0" : atk) + ":" + matk; } } builder.AppendLine(String.Join(",", new string[] { rawElements[0], // ID rawElements[1], // AegisName rawElements[2], // Name DbIOFormatting.OutputInteger(rawElements[3]), // Type DbIOFormatting.ZeroDefault(rawElements[4]), // Buy DbIOFormatting.ZeroDefault(rawElements[5]), // Sell String.IsNullOrEmpty(rawElements[6]) ? "0" : rawElements[6], // Weight atk, // ATK + matk DbIOFormatting.ZeroDefault(rawElements[8]), DbIOFormatting.ZeroDefault(rawElements[9]), DbIOFormatting.ZeroDefault(rawElements[10]), // Slots String.IsNullOrEmpty(rawElements[11]) ? "0xFFFFFFFF" : !rawElements[11].StartsWith("0x") ? "0x" + Int32.Parse(rawElements[11]).ToString("X8") : rawElements[11], DbIOFormatting.HexToInt(rawElements[12]), // Upper DbIOFormatting.ZeroDefault(rawElements[13]), DbIOFormatting.ZeroDefault(DbIOFormatting.HexToInt(rawElements[14])), DbIOFormatting.ZeroDefault(rawElements[15]), DbIOFormatting.ZeroDefault(rawElements[16]), refine, DbIOFormatting.ZeroDefault(rawElements[18]), String.IsNullOrEmpty(script1) ? "{}" : "{ " + script1 + " }", String.IsNullOrEmpty(script2) ? "{}" : "{ " + script2 + " }", String.IsNullOrEmpty(script3) ? "{}" : "{ " + script3 + " }" })); } } else if (to == ServerType.Hercules) { foreach (var tuple in tuples.OrderBy(p => p.GetKey <int>()).OfType <ReadableTuple <int> >()) { WriteEntry(db, builder, tuple); builder.AppendLine(); } } }
public SdeEditor() : base("Server database editor", "cde.ico", SizeToContent.Manual, ResizeMode.CanResize) { SplashDialog loading = new SplashDialog(); loading.Show(); Loaded += delegate { loading.Terminate(); }; try { ApplicationShortcut.OverrideBindings(SdeAppConfiguration.Remapper); } catch (Exception err) { SdeAppConfiguration.Remapper.Clear(); ApplicationShortcut.OverrideBindings(SdeAppConfiguration.Remapper); ErrorHandler.HandleException("Failed to load the custom key bindings. The bindings will be reset to their default values.", err); } string configFile = _parseCommandLineArguments(); GrfPath.Delete(ProjectConfiguration.DefaultFileName); InitializeComponent(); Instance = this; ShowInTaskbar = true; _asyncOperation = new AsyncOperation(_progressBar); _clientDatabase = new SdeDatabase(_metaGrf); _loadMenu(); if (configFile == null) { ProjectConfiguration.ConfigAsker = new ConfigAsker(ProjectConfiguration.DefaultFileName); if (SdeAppConfiguration.AlwaysReopenLatestProject) { if (_recentFilesManager.Files.Count > 0 && File.Exists(_recentFilesManager.Files[0])) { ProjectConfiguration.ConfigAsker = new ConfigAsker(configFile = _recentFilesManager.Files[0]); } } } else if (File.Exists(configFile)) { ProjectConfiguration.ConfigAsker = new ConfigAsker(configFile); } _loadSettingsTab(); if (configFile != null) { ReloadSettings(configFile); } _loadGenericTab(); _clientDatabase.Commands.ModifiedStateChanged += new AbstractCommand <IGenericDbCommand> .AbstractCommandsEventHandler(_commands_ModifiedStateChanged); ApplicationShortcut.Link(ApplicationShortcut.Undo, () => _clientDatabase.Commands.Undo(), this); ApplicationShortcut.Link(ApplicationShortcut.UndoGlobal, () => _clientDatabase.Commands.Undo(), this); ApplicationShortcut.Link(ApplicationShortcut.Redo, () => _clientDatabase.Commands.Redo(), this); ApplicationShortcut.Link(ApplicationShortcut.RedoGlobal, () => _clientDatabase.Commands.Redo(), this); ApplicationShortcut.Link(ApplicationShortcut.Search, () => _execute(v => v.Search()), this); ApplicationShortcut.Link(ApplicationShortcut.Delete, () => _execute(v => v.DeleteItems()), this); ApplicationShortcut.Link(ApplicationShortcut.Rename, () => _execute(v => v.ChangeId()), this); ApplicationShortcut.Link(ApplicationShortcut.NavigationBackward, () => _tabEngine.Undo(), this); ApplicationShortcut.Link(ApplicationShortcut.NavigationBackward2, () => _tabEngine.Redo(), this); ApplicationShortcut.Link(ApplicationShortcut.NavigationForward, () => _tabEngine.Redo(), this); ApplicationShortcut.Link(ApplicationShortcut.Change, () => _execute(v => v.ChangeId()), this); ApplicationShortcut.Link(ApplicationShortcut.Restrict, () => _execute(v => v.ShowSelectedOnly()), this); ApplicationShortcut.Link(ApplicationShortcut.CopyTo, () => _execute(v => v.CopyItemTo()), this); ApplicationShortcut.Link(ApplicationShortcut.New, () => _execute(v => v.AddNewItem()), this); ApplicationShortcut.Link(ApplicationShortcut.Save, () => _menuItemDatabaseSave_Click(this, null), this); ApplicationShortcut.Link(ApplicationShortcut.Replace, () => { if (_menuItemReplaceAll.IsEnabled) { _menuItemReplaceAll_Click(this, null); } }, this); ApplicationShortcut.Link(ApplicationShortcut.FromString("Ctrl-Enter", "Select next entry"), () => _execute(v => v.SelectNext()), this); ApplicationShortcut.Link(ApplicationShortcut.FromString("Ctrl-Shift-Enter", "Select previous entry"), () => _execute(v => v.SelectPrevious()), this); Configuration.EnableDebuggerTrace = false; _tnbUndo.SetUndo(_tabEngine); _tnbRedo.SetRedo(_tabEngine); _tmbUndo.SetUndo(_clientDatabase.Commands); _tmbRedo.SetRedo(_clientDatabase.Commands); Extensions.GenerateListViewTemplate(_debugList, new ListViewDataTemplateHelper.GeneralColumnInfo[] { new ListViewDataTemplateHelper.GeneralColumnInfo { Header = "#", DisplayExpression = "ErrorNumber", SearchGetAccessor = "ErrorNumber", FixedWidth = 35, ToolTipBinding = "ErrorNumber", TextAlignment = TextAlignment.Right }, new ListViewDataTemplateHelper.ImageColumnInfo { Header = "", DisplayExpression = "DataImage", SearchGetAccessor = "Exception", FixedWidth = 20, MaxHeight = 24 }, new ListViewDataTemplateHelper.RangeColumnInfo { Header = "Exception", DisplayExpression = "Exception", SearchGetAccessor = "Exception", IsFill = true, TextAlignment = TextAlignment.Left, ToolTipBinding = "OriginalException", TextWrapping = TextWrapping.Wrap, MinWidth = 120 }, new ListViewDataTemplateHelper.GeneralColumnInfo { Header = "Id", DisplayExpression = "Id", SearchGetAccessor = "Id", FixedWidth = 90, TextAlignment = TextAlignment.Left, ToolTipBinding = "Id", TextWrapping = TextWrapping.Wrap }, new ListViewDataTemplateHelper.GeneralColumnInfo { Header = "File", DisplayExpression = "FileName", SearchGetAccessor = "FilePath", FixedWidth = 145, TextAlignment = TextAlignment.Left, ToolTipBinding = "FilePath", TextWrapping = TextWrapping.Wrap }, new ListViewDataTemplateHelper.GeneralColumnInfo { Header = "Line", DisplayExpression = "Line", SearchGetAccessor = "Line", FixedWidth = 40, TextAlignment = TextAlignment.Left, ToolTipBinding = "Line" }, }, null, new string[] { "Added", "Blue", "Default", "Black" }); ApplicationShortcut.Link(ApplicationShortcut.Copy, () => WpfUtils.CopyContent(_debugList), _debugList); _debugItems = new ObservableCollection <DebugItemView>(); _debugList.ItemsSource = _debugItems; DbIOErrorHandler.ClearListeners(); DbIOErrorHandler.AddListener(this); _clientDatabase.PreviewReloaded += delegate { this.BeginDispatch(delegate { foreach (TabItem tabItem in _mainTabControl.Items) { tabItem.IsEnabled = true; var tabItemHeader = tabItem.Header as DisplayLabel; if (tabItemHeader != null) { tabItemHeader.ResetEnabled(); } } }); }; _clientDatabase.Reloaded += delegate { _mainTabControl.Dispatch(p => p.RaiseEvent(new SelectionChangedEventArgs(Selector.SelectionChangedEvent, new List <object>(), _mainTabControl.SelectedItem == null ? new List <object>() : new List <object> { _mainTabControl.SelectedItem }))); ServerType serverType = DbPathLocator.GetServerType(); bool renewal = DbPathLocator.GetIsRenewal(); string header = String.Format("Current ({0} - {1})", serverType == ServerType.RAthena ? "rA" : "Herc", renewal ? "Renewal" : "Pre-Renewal"); this.BeginDispatch(delegate { _menuItemExportDbCurrent.IsEnabled = true; _menuItemExportDbCurrent.Header = header; _menuItemExportSqlCurrent.IsEnabled = true; _menuItemExportSqlCurrent.Header = header; }); }; SelectionChanged += _sdeEditor_SelectionChanged; }
private static void _loadItemsGroupdDb(AbstractDb <int> db, ServerDbs serverDb, string file) { int numberOfErrors = 3; TextFileHelper.LatestFile = file; if (String.IsNullOrEmpty(file)) { DbIOErrorHandler.Handle(StackTraceException.GetStrackTraceException(), "File not found " + ServerDbs.ItemGroups + ".", ErrorLevel.NotSpecified); return; } var itemDb1 = db.ProjectDatabase.GetDb <int>(ServerDbs.Items); var itemDb2 = db.ProjectDatabase.GetDb <int>(ServerDbs.Items2); if (!itemDb1.IsLoaded) { itemDb1.LoadDb(); } if (!itemDb2.IsLoaded) { itemDb2.LoadDb(); } var itemDb = new MetaTable <int>(ServerItemAttributes.AttributeList); itemDb.AddTable(itemDb1.Table); itemDb.AddTable(itemDb2.Table); itemDb.MergeOnce(); Dictionary <string, ReadableTuple <int> > bufferredTuples = new Dictionary <string, ReadableTuple <int> >(); foreach (var tuple in itemDb.FastItems) { bufferredTuples[tuple.GetStringValue(ServerItemAttributes.AegisName.Index)] = tuple; } var table = db.Table; if (db.Attached[serverDb] == null) { db.Attached[serverDb] = new Utilities.Extension.Tuple <ServerDbs, HashSet <int> >(serverDb, new HashSet <int>()); } HashSet <int> loadedIds = ((Utilities.Extension.Tuple <ServerDbs, HashSet <int> >)db.Attached[serverDb]).Item2; foreach (string[] elements in TextFileHelper.GetElementsByCommas(IOHelper.ReadAllBytes(file))) { try { int itemId; int iItemId; if (Int32.TryParse(elements[0], out iItemId)) { itemId = iItemId; } else { var constantDb = db.ProjectDatabase.GetDb <string>(ServerDbs.Constants); if (!constantDb.IsLoaded) { constantDb.LoadDb(); } var tuple = constantDb.Table.TryGetTuple(elements[0]); if (tuple == null) { if (DbPathLocator.GenericErrorHandler(ref numberOfErrors, elements[0])) { return; } continue; } itemId = tuple.GetValue <int>(1); } string orate = elements[2]; int nameId; int rate; if (Int32.TryParse(elements[1], out nameId)) { } else { var tuple = bufferredTuples[elements[1]]; if (tuple == null) { if (DbPathLocator.GenericErrorHandler(ref numberOfErrors, elements[0])) { return; } continue; } nameId = tuple.Key; } Int32.TryParse(orate, out rate); var id = (object)itemId; loadedIds.Add((int)id); if (!table.ContainsKey(itemId)) { ReadableTuple <int> tuple = new ReadableTuple <int>(itemId, db.AttributeList); tuple.SetRawValue(ServerItemGroupAttributes.Table, new Dictionary <int, ReadableTuple <int> >()); table.Add(itemId, tuple); } Dictionary <int, ReadableTuple <int> > dico = (Dictionary <int, ReadableTuple <int> >)table.GetRaw(itemId, ServerItemGroupAttributes.Table); ReadableTuple <int> newTuple = new ReadableTuple <int>(nameId, ServerItemGroupSubAttributes.AttributeList); List <DbAttribute> attributes = new List <DbAttribute>(ServerItemGroupSubAttributes.AttributeList.Attributes); for (int i = 2; i < elements.Length; i++) { newTuple.SetRawValue(attributes[i - 1], elements[i]); } newTuple.SetRawValue(ServerItemGroupSubAttributes.ParentGroup, itemId); dico[nameId] = newTuple; } catch { if (DbPathLocator.GenericErrorHandler(ref numberOfErrors, elements[0])) { return; } } } }
public GenericFlagDialog(string text, Type enumType) : base(_getDisplay(Description.GetAnyDescription(enumType)), "cde.ico", SizeToContent.WidthAndHeight, ResizeMode.CanResize) { InitializeComponent(); _value = text.ToInt(); if (enumType.BaseType != typeof(Enum)) { throw new Exception("Invalid argument type, excepted an enum."); } if (enumType == typeof(MobModeType)) { if (DbPathLocator.GetServerType() == ServerType.RAthena && !ProjectConfiguration.UseOldRAthenaMode) { enumType = typeof(MobModeTypeNew); } } var values = Enum.GetValues(enumType).Cast <Enum>().ToList(); var valuesEnum = Enum.GetValues(enumType).Cast <int>().ToList(); string[] commands = Description.GetAnyDescription(enumType).Split('#'); if (commands.Any(p => p.StartsWith("max_col_width:"))) { _maxColWidth = Int32.Parse(commands.First(p => p.StartsWith("max_col_width")).Split(':')[1]); } GridIndexProvider provider = _findGrid(values); var toolTips = new string[values.Count]; if (!commands.Contains("disable_tooltips")) { for (int i = 0; i < values.Count; i++) { toolTips[i] = _getTooltip(Description.GetDescription(values[i])); } } AbstractProvider iProvider = new DefaultIndexProvider(0, values.Count); if (commands.Any(p => p.StartsWith("order:"))) { List <int> order = commands.First(p => p.StartsWith("order:")).Split(':')[1].Split(',').Select(Int32.Parse).ToList(); for (int i = 0; i < values.Count; i++) { if (!order.Contains(i)) { order.Add(i); } } iProvider = new SpecifiedIndexProvider(order); } ToolTipsBuilder.Initialize(toolTips, this); int row; int col; ServerType currentType = DbPathLocator.GetServerType(); for (int i = 0; i < values.Count; i++) { provider.Next(out row, out col); int index = (int)iProvider.Next(); CheckBox box = new CheckBox { Content = _getDisplay(Description.GetDescription(values[index])), Margin = new Thickness(3, 6, 3, 6), VerticalAlignment = VerticalAlignment.Center }; ServerType type = _getEmuRestrition(Description.GetDescription(values[index])); if ((type & currentType) != currentType) { box.IsEnabled = false; } box.Tag = valuesEnum[index]; WpfUtils.AddMouseInOutEffectsBox(box); _boxes.Add(box); _upperGrid.Children.Add(box); WpfUtilities.SetGridPosition(box, row, 2 * col); } _boxes.ForEach(_addEvents); }
private void _menuItemExportSqlCurrent_Click(object sender, RoutedEventArgs e) { _export(DbPathLocator.GetServerType(), DbPathLocator.GetIsRenewal() ? "re" : "pre-re", FileType.Sql); }
private void _miSelectInNotepad_Click(object sender, RoutedEventArgs e) { try { TValue item = _listView.SelectedItem as TValue; if (item != null) { string displayId = item.GetValue <string>(Settings.AttId); string path; //if (Settings.DbData == ServerDbs.ItemGroups) { // displayId = item.GetValue<string>(ServerItemGroupAttributes.Display); //} if ((path = DbPathLocator.DetectPath(Settings.DbData)) != null) { if (!IOHelper.IsSystemFile(path)) { ErrorHandler.HandleException("The file cannot be opened because it is not stored locally."); return; } string[] lines = File.ReadAllLines(path); string line = lines.FirstOrDefault(p => p.StartsWith(displayId + ",")); if (line == null) { line = lines.FirstOrDefault(p => p.StartsWith(displayId + "\t")); } if (line == null) { line = lines.FirstOrDefault(p => p.Contains("Id: " + displayId)); } if (line == null) { line = lines.FirstOrDefault(p => p.Contains("id: " + displayId)); } if (line == null) { line = lines.FirstOrDefault(p => p.Contains("[" + displayId + "] =")); } if (line == null) { line = lines.FirstOrDefault(p => p.StartsWith(displayId)); } if (line == null) { int ival; if (!Int32.TryParse(displayId, out ival)) { line = lines.FirstOrDefault(p => p.Contains(displayId + ":")); } } if (line != null) { GTabsMaker.SelectInNotepadpp(path, (lines.ToList().IndexOf(line) + 1).ToString(CultureInfo.InvariantCulture)); } } } } catch (Exception err) { ErrorHandler.HandleException(err); } }
public GenericFlagDialog(DbAttribute attribute, string text, Type enumType, FlagTypeData flagTypeData, string description) : base(description, "cde.ico", SizeToContent.WidthAndHeight, ResizeMode.CanResize) { InitializeComponent(); _value = text.ToLong(); if (flagTypeData != null) { List <long> valuesEnum = flagTypeData.Values.Where(p => (p.DataFlag & FlagDataProperty.Hide) == 0).Select(p => p.Value).ToList(); var values = flagTypeData.Values.Where(p => (p.DataFlag & FlagDataProperty.Hide) == 0).ToList(); GridIndexProvider provider = _findGrid(values); var toolTips = new string[values.Count]; for (int i = 0; i < values.Count; i++) { toolTips[i] = _getTooltip(values[i].Description); } AbstractProvider iProvider = new DefaultIndexProvider(0, values.Count); ToolTipsBuilder.Initialize(toolTips, this); int row; int col; for (int i = 0; i < values.Count; i++) { provider.Next(out row, out col); int index = (int)iProvider.Next(); CheckBox box = new CheckBox { Content = values[index].Name, Margin = new Thickness(3, 6, 3, 6), VerticalAlignment = VerticalAlignment.Center }; var menu = new ContextMenu(); MenuItem item = new MenuItem(); item.Header = "Restrict search to [" + values[index].Name + "]"; box.ContextMenu = menu; menu.Items.Add(item); item.Click += delegate { var selected = SdeEditor.Instance.Tabs.FirstOrDefault(p => p.IsSelected); if (selected != null) { selected._dbSearchPanel._searchTextBox.Text = "([" + attribute.AttributeName + "] & " + "Flags." + values[index].Name + ") != 0"; } }; box.Tag = valuesEnum[index]; WpfUtils.AddMouseInOutEffectsBox(box); _boxes.Add(box); _upperGrid.Children.Add(box); WpfUtilities.SetGridPosition(box, row, 2 * col); } _boxes.ForEach(_addEvents); } else { if (enumType.BaseType != typeof(Enum)) { throw new Exception("Invalid argument type, excepted an enum."); } if (enumType == typeof(MobModeType)) { if (DbPathLocator.GetServerType() == ServerType.RAthena && !ProjectConfiguration.UseOldRAthenaMode) { enumType = typeof(MobModeTypeNew); } } List <long> valuesEnum = Enum.GetValues(enumType).Cast <int>().Select(p => (long)p).ToList(); var values = Enum.GetValues(enumType).Cast <Enum>().ToList(); string[] commands = Description.GetAnyDescription(enumType).Split('#'); if (commands.Any(p => p.StartsWith("max_col_width:"))) { _maxColWidth = Int32.Parse(commands.First(p => p.StartsWith("max_col_width")).Split(':')[1]); } GridIndexProvider provider = _findGrid(values); var toolTips = new string[values.Count]; if (!commands.Contains("disable_tooltips")) { for (int i = 0; i < values.Count; i++) { toolTips[i] = _getTooltip(Description.GetDescription(values[i])); } } AbstractProvider iProvider = new DefaultIndexProvider(0, values.Count); if (commands.Any(p => p.StartsWith("order:"))) { List <int> order = commands.First(p => p.StartsWith("order:")).Split(':')[1].Split(',').Select(Int32.Parse).ToList(); for (int i = 0; i < values.Count; i++) { if (!order.Contains(i)) { order.Add(i); } } iProvider = new SpecifiedIndexProvider(order); } ToolTipsBuilder.Initialize(toolTips, this); int row; int col; ServerType currentType = DbPathLocator.GetServerType(); for (int i = 0; i < values.Count; i++) { provider.Next(out row, out col); int index = (int)iProvider.Next(); CheckBox box = new CheckBox { Content = _getDisplay(Description.GetDescription(values[index])), Margin = new Thickness(3, 6, 3, 6), VerticalAlignment = VerticalAlignment.Center }; ServerType type = _getEmuRestrition(Description.GetDescription(values[index])); if ((type & currentType) != currentType) { box.IsEnabled = false; } var menu = new ContextMenu(); MenuItem item = new MenuItem(); item.Header = "Restrict search to [" + _getDisplay(Description.GetDescription(values[index])) + "]"; box.ContextMenu = menu; menu.Items.Add(item); item.Click += delegate { var selected = SdeEditor.Instance.Tabs.FirstOrDefault(p => p.IsSelected); if (selected != null) { selected._dbSearchPanel._searchTextBox.Text = "([" + attribute.AttributeName + "] & " + valuesEnum[index] + ") != 0"; } }; box.Tag = valuesEnum[index]; WpfUtils.AddMouseInOutEffectsBox(box); _boxes.Add(box); _upperGrid.Children.Add(box); WpfUtilities.SetGridPosition(box, row, 2 * col); } _boxes.ForEach(_addEvents); } }