public void GenerateGridDefault(ref int line, TabSettings <TKey> settings) { if (settings.Gdb.LayoutIndexes != null) { AbstractProvider metaProvider = AbstractProvider.GetProvider(settings.Gdb.LayoutIndexes); if (metaProvider is GroupIndexProvider) { AbstractProvider gridProvider = AbstractProvider.GetProvider(settings.Gdb.GridIndexes); gridProvider.GroupAs = typeof(SpecifiedIndexProvider); bool col = false; foreach (IIndexProvider provider in metaProvider.Providers) { AbstractProvider gridLayout = gridProvider.Next <AbstractProvider>(); GTabsMaker.PrintGrid(ref line, (col = !col) ? 0 : 3, 1, 2, provider, gridLayout, settings.GeneralProperties, settings.Gdb.AttributeList); if (col) { line--; } } } else { GTabsMaker.Print(ref line, metaProvider, settings.GeneralProperties, settings.Gdb.AttributeList); } } else { GTabsMaker.Print(ref line, new SpecifiedRangeIndexProvider(new int[] { 0, settings.Gdb.AttributeList.Attributes.Count }), settings.GeneralProperties, settings.Gdb.AttributeList); } }
public override void OnDeplayTable() { int line = 0; Grid subGrid = GTabsMaker.PrintGrid(ref line, 2, 1, 1, new SpecifiedIndexProvider(new int[] { -1, -1, ServerMobGroupSubAttributes.Rate.Index, -1, ServerMobGroupSubAttributes.DummyName.Index, -1, }), -1, 0, -1, -1, _dp, ServerMobGroupSubAttributes.AttributeList); subGrid.VerticalAlignment = VerticalAlignment.Top; Label label = new Label(); label.Content = ""; label.FontStyle = FontStyles.Italic; label.Padding = new Thickness(0); label.Margin = new Thickness(3); subGrid.Children.Add(label); _tab.PropertiesGrid.RowDefinitions.Clear(); _tab.PropertiesGrid.RowDefinitions.Add(new RowDefinition()); _tab.PropertiesGrid.ColumnDefinitions.Clear(); _tab.PropertiesGrid.ColumnDefinitions.Add(new ColumnDefinition { Width = new GridLength(340) }); _tab.PropertiesGrid.ColumnDefinitions.Add(new ColumnDefinition { Width = new GridLength(10) }); _tab.PropertiesGrid.ColumnDefinitions.Add(new ColumnDefinition()); }
private void _miOpenNotepad_Click(object sender, RoutedEventArgs e) { try { DebugItemView view = (DebugItemView)_debugList.SelectedItem; GTabsMaker.SelectInNotepadpp(view.FilePath, view.Line); } catch (Exception err) { ErrorHandler.HandleException(err); } }
public DbHomuns() { LayoutIndexes = new int[] { 0, 10 }; DbSource = ServerDbs.Homuns; AttributeList = ServerHomunAttributes.AttributeList; TabGenerator.OnGenerateGrid = delegate(ref int line, GenericDatabase database, TabControl control, DisplayableProperty <int, ReadableTuple <int> > generalProperties, BaseDb gdb) { generalProperties.AddLabel("Base stats", line++, 0, true); GTabsMaker.PrintGrid(ref line, 0, 1, 2, new DefaultIndexProvider(ServerHomunAttributes.BHp.Index, 8), -1, 0, -1, 0, generalProperties, gdb.AttributeList); generalProperties.AddLabel("Growth stats", line, 0, true); generalProperties.AddLabel("Evolution stats", line, 3, true); line++; GTabsMaker.PrintGrid(ref line, 0, 1, 2, new DefaultIndexProvider(ServerHomunAttributes.GnHp.Index, 16), -1, 0, -1, 0, generalProperties, gdb.AttributeList); line--; GTabsMaker.PrintGrid(ref line, 3, 1, 2, new DefaultIndexProvider(ServerHomunAttributes.EnHp.Index, 16), -1, 0, -1, 0, generalProperties, gdb.AttributeList); }; DbWriter = DbWriterMethods.DbIntComma; }
public DbItemGroups() { DbSource = ServerDbs.ItemGroups; AttributeList = ServerItemGroupAttributes.AttributeList; DbLoader = DbLoaderMethods.DbItemGroups; DbWriter = DbWriterMethods.DbItemGroupWriter; TabGenerator.OnTabVisualUpdate += GTabsMaker.LoadSItemGroupVisualUpdate; TabGenerator.OnInitSettings += delegate(GDbTabWrapper <int, ReadableTuple <int> > tab, GTabSettings <int, ReadableTuple <int> > settings, BaseDb gdb) { settings.CanBeDelayed = false; ServerItemGroupAttributes.Display.AttachedObject = gdb; }; TabGenerator.GenerateGrid = delegate(ref int line, GenericDatabase database, TabControl control, DisplayableProperty <int, ReadableTuple <int> > generalProperties, BaseDb gdb) { generalProperties.AddProperty(ServerItemGroupAttributes.Table, 0, 1); }; TabGenerator.OnSetCustomCommands = delegate(GDbTabWrapper <int, ReadableTuple <int> > tab, GTabSettings <int, ReadableTuple <int> > settings, BaseDb gdb) { settings.AddedCommands.Add(new GItemCommand <int, ReadableTuple <int> > { AllowMultipleSelection = true, DisplayName = "Copy entries to clipboard (rAthena)", ImagePath = "export.png", Shortcut = ApplicationShortcut.Copy, InsertIndex = 3, AddToCommandsStack = false, GenericCommand = items => GTabsMaker.ItemGroupCopyEntries(items, gdb, settings.Control, ServerType.RAthena) }); settings.AddedCommands.Add(new GItemCommand <int, ReadableTuple <int> > { AllowMultipleSelection = true, DisplayName = "Copy entries to clipboard (Hercules)", ImagePath = "export.png", Shortcut = ApplicationShortcut.Copy2, InsertIndex = 4, AddToCommandsStack = false, GenericCommand = items => GTabsMaker.ItemGroupCopyEntries(items, gdb, settings.Control, ServerType.Hercules) }); }; }
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 void InitStyle(GDbTabWrapper <TKey, ReadableTuple <TKey> > tab, GTabSettings <TKey, ReadableTuple <TKey> > settings, BaseDb gdb) { GTabsMaker.SInit(tab, settings, gdb); }
public override void Init(GDbTabWrapper <TKey, ReadableTuple <TKey> > tab, DisplayableProperty <TKey, ReadableTuple <TKey> > dp) { _tab = tab; _initSettings(tab, dp); _tab.Settings.NewItemAddedFunction += item => item.SetRawValue(ServerItemGroupAttributes.Table, new Dictionary <int, ReadableTuple <int> >()); GenericDatabase gdb = ((GenericDatabase)_tab.Database); _itemGroupsTable.Commands.PreviewCommandUndo += _previewCommandChanged; _itemGroupsTable.Commands.PreviewCommandRedo += _previewCommandChanged; _itemGroupsTable.Commands.PreviewCommandExecuted += _previewCommandChanged; _itemGroupsTable.Commands.CommandUndo += _commandChanged; _itemGroupsTable.Commands.CommandRedo += _commandChanged; _itemGroupsTable.Commands.CommandExecuted += _commandChanged; gdb.Commands.PreviewCommandUndo += _previewCommandChanged2; gdb.Commands.PreviewCommandRedo += _previewCommandChanged2; gdb.Commands.PreviewCommandExecuted += _previewCommandChanged2; gdb.Commands.CommandUndo += _commandChanged2; gdb.Commands.CommandRedo += _commandChanged2; gdb.Commands.CommandExecuted += _commandChanged2; Grid grid = new Grid(); grid.SetValue(Grid.RowProperty, _row); grid.SetValue(Grid.ColumnProperty, 0); grid.SetValue(Grid.ColumnSpanProperty, 1); grid.RowDefinitions.Add(new RowDefinition { Height = new GridLength(-1, GridUnitType.Auto) }); grid.RowDefinitions.Add(new RowDefinition()); grid.ColumnDefinitions.Add(new ColumnDefinition()); Label label = new Label(); label.Content = "Item IDs"; label.FontStyle = FontStyles.Italic; label.Padding = new Thickness(0); label.Margin = new Thickness(3); _lv = new RangeListView(); _lv.SetValue(TextSearch.TextPathProperty, "ID"); _lv.SetValue(WpfUtils.IsGridSortableProperty, true); _lv.SetValue(ScrollViewer.HorizontalScrollBarVisibilityProperty, ScrollBarVisibility.Disabled); _lv.SetValue(Grid.RowProperty, 1); _lv.FocusVisualStyle = null; _lv.Margin = new Thickness(3); _lv.BorderThickness = new Thickness(1); _lv.HorizontalAlignment = HorizontalAlignment.Left; _lv.SelectionChanged += _lv_SelectionChanged; Extensions.GenerateListViewTemplate(_lv, new ListViewDataTemplateHelper.GeneralColumnInfo[] { new ListViewDataTemplateHelper.GeneralColumnInfo { Header = ServerItemAttributes.Id.DisplayName, DisplayExpression = "ID", SearchGetAccessor = "ID", FixedWidth = 60, TextAlignment = TextAlignment.Right, ToolTipBinding = "ID" }, new ListViewDataTemplateHelper.RangeColumnInfo { Header = ServerItemAttributes.Name.DisplayName, DisplayExpression = "Name", SearchGetAccessor = "Name", IsFill = true, ToolTipBinding = "Name", TextWrapping = TextWrapping.Wrap, MinWidth = 70 }, new ListViewDataTemplateHelper.GeneralColumnInfo { Header = "Freq", DisplayExpression = "Drop", SearchGetAccessor = "Rate", ToolTipBinding = "Rate", FixedWidth = 40, TextAlignment = TextAlignment.Right }, new ListViewDataTemplateHelper.GeneralColumnInfo { Header = "Drop %", DisplayExpression = "Chance", SearchGetAccessor = "ChanceInt", ToolTipBinding = "Chance", FixedWidth = 60, TextAlignment = TextAlignment.Right } }, new DefaultListViewComparer <ItemView>(), new string[] { "Added", "Blue", "Modified", "Green", "Normal", "Black" }); _lv.ContextMenu = new ContextMenu(); _lv.MouseDoubleClick += new MouseButtonEventHandler(_lv_MouseDoubleClick); MenuItem miSelect = new MenuItem { Header = "Select", Icon = new Image { Source = (BitmapSource)ApplicationManager.PreloadResourceImage("arrowdown.png") } }; MenuItem miEditDrop = new MenuItem { Header = "Edit", Icon = new Image { Source = (BitmapSource)ApplicationManager.PreloadResourceImage("properties.png") } }; MenuItem miRemoveDrop = new MenuItem { Header = "Remove", Icon = new Image { Source = (BitmapSource)ApplicationManager.PreloadResourceImage("delete.png") } }; MenuItem miAddDrop = new MenuItem { Header = "Add", Icon = new Image { Source = (BitmapSource)ApplicationManager.PreloadResourceImage("add.png") } }; _lv.ContextMenu.Items.Add(miSelect); _lv.ContextMenu.Items.Add(miEditDrop); _lv.ContextMenu.Items.Add(miRemoveDrop); _lv.ContextMenu.Items.Add(miAddDrop); dp.AddResetField(_lv); miSelect.Click += new RoutedEventHandler(_miSelect_Click); miEditDrop.Click += new RoutedEventHandler(_miEditDrop_Click); miRemoveDrop.Click += new RoutedEventHandler(_miRemoveDrop_Click); miAddDrop.Click += new RoutedEventHandler(_miAddDrop_Click); dp.AddUpdateAction(new Action <ReadableTuple <TKey> >(delegate(ReadableTuple <TKey> item) { Dictionary <int, ReadableTuple <int> > groups = (Dictionary <int, ReadableTuple <int> >)item.GetRawValue(1); if (groups == null) { groups = new Dictionary <int, ReadableTuple <int> >(); item.SetRawValue(1, groups); } Table <int, ReadableTuple <int> > btable = ((GenericDatabase)tab.Database).GetMetaTable <int>(ServerDbs.Items); if (groups.Count == 0) { _lv.ItemsSource = new RangeObservableCollection <ItemView>(); return; } List <ItemView> result = new List <ItemView>(); try { int chances = groups.Where(p => p.Key != 0).Sum(p => p.Value.GetValue <int>(ServerItemGroupSubAttributes.Rate)); result.AddRange(groups.Select(keypair => new ItemView(btable, groups, keypair.Key, chances)).OrderBy(p => p, Extensions.BindDefaultSearch <ItemView>(_lv, "ID"))); } catch { } _lv.ItemsSource = new RangeObservableCollection <ItemView>(result); })); _dp = new DisplayableProperty <TKey, ReadableTuple <TKey> >(); int line = 0; Grid subGrid = GTabsMaker.PrintGrid(ref line, 2, 1, 1, new SpecifiedIndexProvider(new int[] { //ServerItemGroupSubAttributes.Id.Index, -1, ServerItemGroupSubAttributes.Rate.Index, -1, ServerItemGroupSubAttributes.Amount.Index, -1, ServerItemGroupSubAttributes.Random.Index, -1, ServerItemGroupSubAttributes.IsAnnounced.Index, -1, ServerItemGroupSubAttributes.Duration.Index, -1, ServerItemGroupSubAttributes.IsNamed.Index, -1, ServerItemGroupSubAttributes.IsBound.Index, -1 }), -1, 0, -1, -1, _dp, ServerItemGroupSubAttributes.AttributeList); subGrid.VerticalAlignment = VerticalAlignment.Top; grid.Children.Add(label); grid.Children.Add(_lv); tab.PropertiesGrid.RowDefinitions.Clear(); tab.PropertiesGrid.RowDefinitions.Add(new RowDefinition()); tab.PropertiesGrid.ColumnDefinitions.Clear(); tab.PropertiesGrid.ColumnDefinitions.Add(new ColumnDefinition { Width = new GridLength(340) }); tab.PropertiesGrid.ColumnDefinitions.Add(new ColumnDefinition { Width = new GridLength(10) }); tab.PropertiesGrid.ColumnDefinitions.Add(new ColumnDefinition()); tab.PropertiesGrid.Children.Add(grid); _dp.Deploy(_tab, null, true); foreach (var update in _dp.Updates) { Tuple <DbAttribute, FrameworkElement> x = update; if (x.Item1.DataType == typeof(int)) { TextBox element = (TextBox)x.Item2; _dp.AddUpdateAction(new Action <ReadableTuple <TKey> >(item => element.Dispatch( delegate { Debug.Ignore(() => element.Text = item.GetValue <int>(x.Item1).ToString(CultureInfo.InvariantCulture)); element.UndoLimit = 0; element.UndoLimit = int.MaxValue; }))); element.TextChanged += delegate { if (tab.ItemsEventsDisabled) { return; } try { if (tab.List.SelectedItem != null && _lv.SelectedItem != null) { _setSelectedItem(x.Item1, element.Text); } } catch (Exception err) { ErrorHandler.HandleException(err); } }; } else if (x.Item1.DataType == typeof(bool)) { CheckBox element = (CheckBox)x.Item2; _dp.AddUpdateAction(new Action <ReadableTuple <TKey> >(item => element.Dispatch(p => Debug.Ignore(() => p.IsChecked = item.GetValue <bool>(x.Item1))))); element.Checked += delegate { if (tab.ItemsEventsDisabled) { return; } try { if (tab.List.SelectedItem != null && _lv.SelectedItem != null) { _setSelectedItem(x.Item1, true); } } catch (Exception err) { ErrorHandler.HandleException(err); } }; element.Unchecked += delegate { if (tab.ItemsEventsDisabled) { return; } try { if (tab.List.SelectedItem != null && _lv.SelectedItem != null) { _setSelectedItem(x.Item1, false); } } catch (Exception err) { ErrorHandler.HandleException(err); } }; } else if (x.Item1.DataType == typeof(string)) { TextBox element = (TextBox)x.Item2; _dp.AddUpdateAction(new Action <ReadableTuple <TKey> >(item => element.Dispatch( delegate { try { string val = item.GetValue <string>(x.Item1); if (val == element.Text) { return; } element.Text = item.GetValue <string>(x.Item1); element.UndoLimit = 0; element.UndoLimit = int.MaxValue; } catch { } }))); element.TextChanged += delegate { if (tab.ItemsEventsDisabled) { return; } _validateUndo(tab, element.Text, x.Item1); if (ReferenceEquals(x.Item1, ServerItemGroupSubAttributes.Rate)) { ((RangeObservableCollection <ItemView>)_lv.ItemsSource).ToList().ForEach(p => p.VisualUpdate()); } }; } } }