public override void Init(GDbTabWrapper <int, ReadableTuple <int> > tab, DisplayableProperty <int, ReadableTuple <int> > dp) { _parent = _parent ?? tab.PropertiesGrid; _comboBoxLevel = new ComboBox { Margin = new Thickness(3), ItemsSource = new List <int> { 1, 2, 3, 4 } }; _comboBoxElement = new ComboBox { Margin = new Thickness(0, 3, 3, 3), ItemsSource = Enum.GetValues(typeof(MobElementType)) }; _comboBoxLevel.SelectionChanged += _comboBox_SelectionChanged; _comboBoxElement.SelectionChanged += _comboBox_SelectionChanged; _tab = tab; dp.AddResetField(_comboBoxLevel); dp.AddResetField(_comboBoxElement); Grid grid = new Grid(); grid.SetValue(Grid.RowProperty, _row); grid.SetValue(Grid.ColumnProperty, _column); grid.ColumnDefinitions.Add(new ColumnDefinition { Width = new GridLength(40) }); grid.ColumnDefinitions.Add(new ColumnDefinition()); _comboBoxLevel.SetValue(Grid.ColumnProperty, 0); _comboBoxElement.SetValue(Grid.ColumnProperty, 1); grid.Children.Add(_comboBoxLevel); grid.Children.Add(_comboBoxElement); _parent.Children.Add(grid); dp.AddUpdateAction(new Action <ReadableTuple <int> >(item => grid.Dispatch(delegate { try { int value = Get(item); if (value < 0) { _comboBoxLevel.SelectedIndex = -1; _comboBoxElement.SelectedIndex = -1; } else { int level = value / 10; int property = value - level * 10; level = level / 2 - 1; _comboBoxLevel.SelectedIndex = level; _comboBoxElement.SelectedIndex = property; } } catch { } }))); }
public override void Init(GDbTabWrapper <TKey, ReadableTuple <TKey> > tab, DisplayableProperty <TKey, ReadableTuple <TKey> > dp) { base.Init(tab, dp); _lv.MouseDoubleClick += delegate { EditSelection(ServerMobGroupSubAttributes.Rate); }; MenuItem miSelect = new MenuItem { Header = "Select", Icon = new Image { Source = ApplicationManager.PreloadResourceImage("arrowdown.png") } }; MenuItem miCopy = new MenuItem { Header = "Copy to clipboard", Icon = new Image { Source = ApplicationManager.PreloadResourceImage("copy.png") }, InputGestureText = ApplicationShortcut.Copy.DisplayString }; MenuItem miPaste = new MenuItem { Header = "Paste from clipboard", Icon = new Image { Source = ApplicationManager.PreloadResourceImage("paste.png") }, InputGestureText = ApplicationShortcut.Paste.DisplayString }; MenuItem miEditDrop = new MenuItem { Header = "Edit", Icon = new Image { Source = ApplicationManager.PreloadResourceImage("properties.png") } }; MenuItem miRemoveDrop = new MenuItem { Header = "Remove", Icon = new Image { Source = ApplicationManager.PreloadResourceImage("delete.png") }, InputGestureText = ApplicationShortcut.Delete.DisplayString }; MenuItem miAddDrop = new MenuItem { Header = "Add", Icon = new Image { Source = ApplicationManager.PreloadResourceImage("add.png") }, InputGestureText = ApplicationShortcut.New.DisplayString }; _lv.ContextMenu.Items.Add(miSelect); _lv.ContextMenu.Items.Add(miEditDrop); _lv.ContextMenu.Items.Add(miCopy); _lv.ContextMenu.Items.Add(miPaste); _lv.ContextMenu.Items.Add(miRemoveDrop); _lv.ContextMenu.Items.Add(miAddDrop); miSelect.Click += (q, r) => SelectItem(); miEditDrop.Click += (q, r) => EditSelection(ServerMobGroupSubAttributes.Rate); miCopy.Click += (q, r) => CopyItems(); miPaste.Click += (q, r) => PasteItems(); miRemoveDrop.Click += (q, r) => DeleteSelection(); miAddDrop.Click += (q, r) => AddItem("", "1", true, ServerMobGroupSubAttributes.Rate); ApplicationShortcut.Link(ApplicationShortcut.New, () => AddItem("", "1", true, ServerMobGroupSubAttributes.Rate), _lv); ApplicationShortcut.Link(ApplicationShortcut.Copy, CopyItems, _lv); ApplicationShortcut.Link(ApplicationShortcut.Paste, PasteItems, _lv); ApplicationShortcut.Link(ApplicationShortcut.Delete, DeleteSelection, _lv); }
public override void Init(GDbTabWrapper <TKey, ReadableTuple <TKey> > tab, DisplayableProperty <TKey, ReadableTuple <TKey> > dp) { _textBox = new TextBox(); _textBox.Margin = new Thickness(3); _textBox.TextChanged += new TextChangedEventHandler(_textBox_TextChanged); _tab = tab; DisplayableProperty <TKey, ReadableTuple <TKey> > .RemoveUndoAndRedoEvents(_textBox, _tab); dp.AddResetField(_textBox); _grid = new Grid(); _grid.SetValue(Grid.RowProperty, _row); _grid.SetValue(Grid.ColumnProperty, _column); _grid.ColumnDefinitions.Add(new ColumnDefinition()); _grid.ColumnDefinitions.Add(new ColumnDefinition { Width = new GridLength(-1, GridUnitType.Auto) }); _textPreview = new TextBlock(); _textPreview.Margin = new Thickness(0, 3, 3, 3); _textPreview.Visibility = Visibility.Collapsed; _textPreview.VerticalAlignment = VerticalAlignment.Center; _textPreview.TextAlignment = TextAlignment.Right; _textPreview.Foreground = Brushes.DarkGray; _textPreview.SetValue(Grid.ColumnProperty, 1); _textBox.SetValue(Grid.ColumnProperty, 0); _grid.Children.Add(_textBox); _grid.Children.Add(_textPreview); _parent = _parent ?? tab.PropertiesGrid; _parent.Children.Add(_grid); dp.AddUpdateAction(new Action <ReadableTuple <TKey> >(item => _textBox.Dispatch(delegate { try { string sval = item.GetValue <string>(_attribute); if (sval == _textBox.Text) { return; } _textBox.Text = sval; _textBox.UndoLimit = 0; _textBox.UndoLimit = int.MaxValue; } catch { } }))); _onInitalized(); }
public override void Init(GDbTabWrapper <int, ReadableTuple <int> > tab, DisplayableProperty <int, ReadableTuple <int> > dp) { _parent = _parent ?? tab.PropertiesGrid; _tab = tab; Grid grid = new Grid(); grid.SetValue(Grid.RowProperty, _row); grid.SetValue(Grid.ColumnProperty, _column); grid.ColumnDefinitions.Add(new ColumnDefinition()); for (int i = 0; i < 4; i++) { grid.RowDefinitions.Add(new RowDefinition { Height = new GridLength(-1, GridUnitType.Auto) }); CheckBox box = new CheckBox(); box.MinWidth = 140; box.Content = new TextBlock { Text = _constStrings[i], VerticalAlignment = VerticalAlignment.Center, TextWrapping = TextWrapping.Wrap }; box.Margin = new Thickness(3); box.VerticalAlignment = VerticalAlignment.Center; box.SetValue(Grid.RowProperty, i); _boxes.Add(box); dp.AddResetField(box); grid.Children.Add(box); } _boxes[0].IsEnabled = false; for (int i = 1; i < 4; i++) { CheckBox box = _boxes[i]; box.Tag = 1 << (i - 1); box.Checked += _box_Changed; box.Unchecked += _box_Changed; } _parent.Children.Add(grid); dp.AddUpdateAction(new Action <ReadableTuple <int> >(item => grid.Dispatch(delegate { try { _updateFields(item); } catch { } }))); }
private void _initSettings(GDbTabWrapper <TKey, ReadableTuple <TKey> > tab, DisplayableProperty <TKey, ReadableTuple <TKey> > dp) { var settings = tab.Settings; var gdb = ((GenericDatabase)tab.Database).GetDb <int>(ServerDbs.ItemGroups); List <DbAttribute> attributes = ServerItemGroupSubAttributes.AttributeList.Attributes; if (attributes.Any(p => p.IsSkippable)) { foreach (var attributeIntern in attributes.Where(p => p.IsSkippable)) { var attribute = attributeIntern; var menuItemSkippable = new MenuItem { Header = attribute.DisplayName + " [" + attribute.AttributeName + ", " + attribute.Index + "]", Icon = new Image { Source = (BitmapSource)ApplicationManager.PreloadResourceImage("add.png") } }; menuItemSkippable.IsEnabled = false; menuItemSkippable.Click += delegate { gdb.Attached["EntireRewrite"] = true; gdb.Attached[attribute.DisplayName] = gdb.Attached[attribute.DisplayName] != null && !(bool)gdb.Attached[attribute.DisplayName]; gdb.To <TKey>().TabGenerator.OnTabVisualUpdate(tab, settings, gdb); }; settings.ContextMenu.Items.Add(menuItemSkippable); } gdb.Attached.CollectionChanged += delegate { int index = 2; foreach (var attributeIntern in attributes.Where(p => p.IsSkippable)) { var attribute = attributeIntern; int index1 = index; settings.ContextMenu.Dispatch(delegate { var menuItemSkippable = (MenuItem)settings.ContextMenu.Items[index1]; menuItemSkippable.IsEnabled = true; bool isSet = gdb.Attached[attribute.DisplayName] == null || (bool)gdb.Attached[attribute.DisplayName]; menuItemSkippable.Icon = new Image { Source = (BitmapSource)ApplicationManager.PreloadResourceImage(isSet ? "delete.png" : "add.png") }; }); index++; } }; } }
public override void Init(GDbTabWrapper <TKey, ReadableTuple <TKey> > tab, DisplayableProperty <TKey, ReadableTuple <TKey> > dp) { if (_textBox == null) { _textBox = new TextBox(); } _textBox.Margin = new Thickness(3); _textBox.TextChanged += new TextChangedEventHandler(_textBox_TextChanged); _textBox.TabIndex = dp.ZIndex++; _tab = tab; DisplayableProperty <TKey, ReadableTuple <TKey> > .RemoveUndoAndRedoEvents(_textBox, _tab); dp.AddResetField(_textBox); _grid = new Grid(); _grid.SetValue(Grid.RowProperty, _row); _grid.SetValue(Grid.ColumnProperty, _column); _grid.ColumnDefinitions.Add(new ColumnDefinition()); _grid.ColumnDefinitions.Add(new ColumnDefinition { Width = new GridLength(-1, GridUnitType.Auto) }); _button = new Button(); _button.Width = 22; _button.Height = 22; _button.Margin = new Thickness(0, 3, 3, 3); _button.Content = "..."; _button.Click += _button_Click; _button.SetValue(Grid.ColumnProperty, 1); _textBox.SetValue(Grid.ColumnProperty, 0); _textBox.VerticalAlignment = VerticalAlignment.Center; _grid.Children.Add(_textBox); _grid.Children.Add(_button); _parent = _parent ?? tab.PropertiesGrid; _parent.Children.Add(_grid); dp.AddUpdateAction(new Action <ReadableTuple <TKey> >(_updateAction)); _onInitalized(); }
public static void ReplaceFields <TKey>(GDbTabWrapper <TKey, ReadableTuple <TKey> > tab) { try { string[] files = PathRequest.OpenFilesCde("filter", FileFormat.MergeFilters(Format.All, Format.Txt, Format.Lua)); if (files == null || files.Length == 0) { return; } foreach (var file in files) { _readFile(file, tab); } } catch (OperationCanceledException) { } catch (Exception err) { ErrorHandler.HandleException(err); } }
public void Map <TKey>(GDbTabWrapper <TKey, ReadableTuple <TKey> > tab, string file, DbAttribute[] mappedFields) { AbstractDb <TKey> db = GetCopyDb <TKey>(DbImport); db.DummyInit(tab.ProjectDatabase); if (db.DbSource == ServerDbs.CItems) { if (file.IsExtension(".lua", ".lub")) { db.DbLoader = (d, idb) => DbIOClientItems.LoadEntry((AbstractDb <int>)(object) db, file); } else { db.DbLoader = (d, idb) => DbIOClientItems.LoadData((AbstractDb <int>)(object) db, file, mappedFields[0], _allowCutLine); } } var method = db.DbLoader; db.DbLoader = (d, idb) => { db.Table.EnableRawEvents = false; method(d, idb); }; try { if ((tab.DbComponent.DbSource & ServerDbs.CItems) != ServerDbs.CItems) { DebugStreamReader.ToServerEncoding = true; } else { DebugStreamReader.ToClientEncoding = true; } db.LoadFromClipboard(file); } finally { DebugStreamReader.ToServerEncoding = false; DebugStreamReader.ToClientEncoding = false; } var table = tab.Table; table.Commands.Begin(); try { foreach (var cTuple in db.Table.FastItems) { var sTuple = table.TryGetTuple(cTuple.Key); if (sTuple == null) { continue; } for (int i = 0; i < mappedFields.Length; i += 2) { var cValue = cTuple.GetValue <string>(mappedFields[i]); var sValue = sTuple.GetValue <string>(mappedFields[i + 1]); if (cValue != sValue) { if (_isNoEmptyFields(mappedFields[i + 1], cValue, sValue)) { continue; } table.Commands.Set(sTuple, mappedFields[i + 1], cValue); } } } } catch (Exception err) { ErrorHandler.HandleException(err); table.Commands.CancelEdit(); } finally { table.Commands.EndEdit(); } }
public void Init(GDbTabWrapper <TKey, TValue> tab, DisplayableProperty <TKey, TValue> dp) { _tab = tab; Grid grid = tab.PropertiesGrid.Children.OfType <Grid>().Last(); Label label = new Label(); label.Content = "MVP drops"; label.SetValue(TextBlock.ForegroundProperty, Application.Current.Resources["TextForeground"] as Brush); label.FontStyle = FontStyles.Italic; label.Padding = new Thickness(0); label.Margin = new Thickness(3); label.SetValue(Grid.ColumnProperty, 1); _lv = new RangeListView(); _lv.SetValue(TextSearch.TextPathProperty, "ID"); _lv.SetValue(WpfUtils.IsGridSortableProperty, true); _lv.SetValue(ScrollViewer.HorizontalScrollBarVisibilityProperty, ScrollBarVisibility.Disabled); _lv.SetValue(Grid.RowProperty, _row); _lv.SetValue(Grid.ColumnProperty, 1); _lv.FocusVisualStyle = null; _lv.Margin = new Thickness(3); _lv.BorderThickness = new Thickness(1); _lv.PreviewMouseRightButtonUp += _lv_PreviewMouseRightButtonUp; _lv.Background = Application.Current.Resources["TabItemBackground"] as Brush; ListViewDataTemplateHelper.GenerateListViewTemplateNew(_lv, new ListViewDataTemplateHelper.GeneralColumnInfo[] { new ListViewDataTemplateHelper.GeneralColumnInfo { Header = ServerItemAttributes.Id.DisplayName, DisplayExpression = "ID", SearchGetAccessor = "ID", FixedWidth = 45, TextAlignment = TextAlignment.Right, ToolTipBinding = "ID" }, new ListViewDataTemplateHelper.RangeColumnInfo { Header = ServerItemAttributes.Name.DisplayName, DisplayExpression = "Name", SearchGetAccessor = "Name", IsFill = true, ToolTipBinding = "Name", TextWrapping = TextWrapping.Wrap, MinWidth = 40 }, new ListViewDataTemplateHelper.GeneralColumnInfo { Header = "Drop %", DisplayExpression = "Drop", SearchGetAccessor = "DropOriginal", ToolTipBinding = "DropOriginal", FixedWidth = 60, TextAlignment = TextAlignment.Right }, }, new DefaultListViewComparer <MobDropView>(), new string[] { "Default", "{DynamicResource TextForeground}", "IsMvp", "{DynamicResource CellBrushMvp}", "IsRandomGroup", "{DynamicResource CellBrushLzma}" }); _lv.ContextMenu = new ContextMenu(); _lv.MouseDoubleClick += new MouseButtonEventHandler(_lv_MouseDoubleClick); MenuItem miSelect = new MenuItem { Header = "Select", Icon = new Image { Source = ApplicationManager.PreloadResourceImage("arrowdown.png") } }; MenuItem miEditDrop = new MenuItem { Header = "Edit", Icon = new Image { Source = ApplicationManager.PreloadResourceImage("properties.png") } }; MenuItem miRemoveDrop = new MenuItem { Header = "Remove", Icon = new Image { Source = ApplicationManager.PreloadResourceImage("delete.png") }, InputGestureText = "Del" }; MenuItem miCopy = new MenuItem { Header = "Copy", Icon = new Image { Source = ApplicationManager.PreloadResourceImage("copy.png") }, InputGestureText = "Ctrl-C" }; MenuItem miPaste = new MenuItem { Header = "Paste", Icon = new Image { Source = ApplicationManager.PreloadResourceImage("paste.png") }, InputGestureText = "Ctrl-V" }; MenuItem miAddDrop = new MenuItem { Header = "Add", Icon = new Image { Source = ApplicationManager.PreloadResourceImage("add.png") } }; ApplicationShortcut.Link(ApplicationShortcut.Copy, () => _miCopy_Click(null, null), _lv); ApplicationShortcut.Link(ApplicationShortcut.Paste, () => _miPaste_Click(null, null), _lv); ApplicationShortcut.Link(ApplicationShortcut.Delete, () => _miRemoveDrop_Click(null, null), _lv); _lv.ContextMenu.Items.Add(miSelect); _lv.ContextMenu.Items.Add(miEditDrop); _lv.ContextMenu.Items.Add(miRemoveDrop); _lv.ContextMenu.Items.Add(new Separator()); _lv.ContextMenu.Items.Add(miCopy); _lv.ContextMenu.Items.Add(miPaste); _lv.ContextMenu.Items.Add(miAddDrop); miSelect.Click += _miSelect_Click; miEditDrop.Click += _miEditDrop_Click; miRemoveDrop.Click += _miRemoveDrop_Click; miAddDrop.Click += _miAddDrop_Click; miCopy.Click += new RoutedEventHandler(_miCopy_Click); miPaste.Click += new RoutedEventHandler(_miPaste_Click); _updateAction = new Action <TValue>(_update); _lv.PreviewMouseDown += delegate { Keyboard.Focus(_lv); }; tab.ProjectDatabase.Commands.CommandIndexChanged += _commands_CommandIndexChanged; dp.AddUpdateAction(_updateAction); dp.AddResetField(_lv); grid.Children.Add(label); grid.Children.Add(_lv); }
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()); } }; } } }
public override void Init(GDbTabWrapper <int, ReadableTuple <int> > tab, DisplayableProperty <int, ReadableTuple <int> > dp) { _parent = _parent ?? tab.PropertiesGrid; _textBox = new TextBox(); _textBox.Margin = new Thickness(3); _textBox.TextChanged += new TextChangedEventHandler(_textBox_TextChanged); _textBox.TabIndex = dp.ZIndex++; _tab = tab; DisplayableProperty <int, ReadableTuple <int> > .RemoveUndoAndRedoEvents(_textBox, _tab); dp.AddResetField(_textBox); Grid grid = new Grid(); grid.SetValue(Grid.RowProperty, _row); grid.SetValue(Grid.ColumnProperty, _column); grid.ColumnDefinitions.Add(new ColumnDefinition()); _textBox.SetValue(Grid.ColumnProperty, 0); _textPreview = new TextBlock(); _textPreview.Margin = new Thickness(7, 0, 0, 0); _textPreview.VerticalAlignment = VerticalAlignment.Center; _textPreview.TextAlignment = TextAlignment.Left; _textPreview.Foreground = Brushes.DarkGray; _textPreview.SetValue(Grid.ColumnProperty, 0); _textPreview.IsHitTestVisible = false; dp.Deployed += delegate { try { if (_attribute.AttachedObject != null) { foreach (var attribute in (DbAttribute[])_attribute.AttachedObject) { var textBox = DisplayablePropertyHelper.Find <TextBox>(_parent, attribute).First(); textBox.TextChanged += (e, a) => OnUpdate(); } } else { var textBox = DisplayablePropertyHelper.Find <TextBox>(_parent, _attribute.AttachedAttribute as DbAttribute).First(); textBox.TextChanged += (e, a) => OnUpdate(); } } catch (Exception err) { ErrorHandler.HandleException(err); } }; grid.Children.Add(_textBox); grid.Children.Add(_textPreview); _parent.Children.Add(grid); dp.AddUpdateAction(new Action <ReadableTuple <int> >(item => _textBox.Dispatch(delegate { try { string sval = item.GetValue <string>(_attribute); if (sval == _textBox.Text) { return; } _textBox.Text = sval; _textBox.UndoLimit = 0; _textBox.UndoLimit = int.MaxValue; } catch { } OnUpdate(); }))); _textBox.GotFocus += delegate { _textPreview.Visibility = Visibility.Collapsed; }; _textBox.LostFocus += delegate { OnUpdate(); }; }
public void Init(GDbTabWrapper <TKey, TValue> tab, DisplayableProperty <TKey, TValue> dp) { _tab = tab; Grid grid = tab.PropertiesGrid.Children.OfType <Grid>().Last(); Label label = new Label(); label.Content = "MVP drops"; label.FontStyle = FontStyles.Italic; label.Padding = new Thickness(0); label.Margin = new Thickness(3); label.SetValue(Grid.ColumnProperty, 1); _lv = new RangeListView(); _lv.SetValue(TextSearch.TextPathProperty, "ID"); _lv.SetValue(WpfUtils.IsGridSortableProperty, true); _lv.SetValue(ScrollViewer.HorizontalScrollBarVisibilityProperty, ScrollBarVisibility.Disabled); _lv.SetValue(Grid.RowProperty, _row); _lv.SetValue(Grid.ColumnProperty, 1); _lv.FocusVisualStyle = null; _lv.Margin = new Thickness(3); _lv.BorderThickness = new Thickness(1); _lv.PreviewMouseRightButtonUp += _lv_PreviewMouseRightButtonUp; Extensions.GenerateListViewTemplate(_lv, new ListViewDataTemplateHelper.GeneralColumnInfo[] { new ListViewDataTemplateHelper.GeneralColumnInfo { Header = ServerItemAttributes.Id.DisplayName, DisplayExpression = "ID", SearchGetAccessor = "ID", FixedWidth = 45, TextAlignment = TextAlignment.Right, ToolTipBinding = "ID" }, new ListViewDataTemplateHelper.RangeColumnInfo { Header = ServerItemAttributes.Name.DisplayName, DisplayExpression = "Name", SearchGetAccessor = "Name", IsFill = true, ToolTipBinding = "Name", TextWrapping = TextWrapping.Wrap, MinWidth = 40 }, new ListViewDataTemplateHelper.GeneralColumnInfo { Header = "Drop %", DisplayExpression = "Drop", SearchGetAccessor = "DropOriginal", ToolTipBinding = "DropOriginal", FixedWidth = 60, TextAlignment = TextAlignment.Right }, }, new DefaultListViewComparer <MobDropView>(), new string[] { "Modified", "Green", "Added", "Blue", "Default", "Black", "IsMvp", "#FFBA6200" }); _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); miSelect.Click += _miSelect_Click; miEditDrop.Click += _miEditDrop_Click; miRemoveDrop.Click += _miRemoveDrop_Click; miAddDrop.Click += _miAddDrop_Click; _updateAction = new Action <TValue>(_update); tab.GenericDatabase.Commands.CommandIndexChanged += _commands_CommandIndexChanged; dp.AddUpdateAction(_updateAction); dp.AddResetField(_lv); grid.Children.Add(label); grid.Children.Add(_lv); }
public void Init(GDbTabWrapper <TKey, TValue> tab, DisplayableProperty <TKey, TValue> dp) { _tab = tab; Grid grid = new Grid(); grid.SetValue(Grid.RowProperty, _row); grid.SetValue(Grid.RowSpanProperty, _rSpan); grid.SetValue(Grid.ColumnProperty, 0); grid.SetValue(Grid.ColumnSpanProperty, 5); grid.RowDefinitions.Add(new RowDefinition { Height = new GridLength(-1, GridUnitType.Auto) }); grid.RowDefinitions.Add(new RowDefinition()); grid.ColumnDefinitions.Add(new ColumnDefinition() { Width = new GridLength(3, GridUnitType.Star) }); grid.ColumnDefinitions.Add(new ColumnDefinition() { Width = new GridLength(6, GridUnitType.Star) }); Label label = new Label(); label.Content = "Evolutions"; label.SetValue(TextBlock.ForegroundProperty, Application.Current.Resources["TextForeground"] as Brush); 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, _row); _lv.FocusVisualStyle = null; _lv.Margin = new Thickness(3); _lv.BorderThickness = new Thickness(1); _lv.PreviewMouseRightButtonUp += _lv_PreviewMouseRightButtonUp; _evolutionSorter = new DefaultListViewComparer <PetEvolutionView>(true); ListViewDataTemplateHelper.GenerateListViewTemplateNew(_lv, new ListViewDataTemplateHelper.GeneralColumnInfo[] { new ListViewDataTemplateHelper.GeneralColumnInfo { Header = ServerMobAttributes.Id.DisplayName, DisplayExpression = "ID", SearchGetAccessor = "ID", FixedWidth = 60, TextAlignment = TextAlignment.Right, ToolTipBinding = "ID" }, new ListViewDataTemplateHelper.RangeColumnInfo { Header = "Name", DisplayExpression = "EvolutionName", SearchGetAccessor = "EvolutionName", IsFill = true, ToolTipBinding = "EvolutionName", TextWrapping = TextWrapping.Wrap, MinWidth = 40 }, }, _evolutionSorter, new string[] { "Default", "{DynamicResource TextForeground}" }); _lv.ContextMenu = new ContextMenu(); _lv.MouseDoubleClick += new MouseButtonEventHandler(_lv_MouseDoubleClick); MenuItem miSelect = new MenuItem { Header = "Select", Icon = new Image { Source = ApplicationManager.PreloadResourceImage("arrowdown.png") } }; MenuItem miEditDrop = new MenuItem { Header = "Edit", Icon = new Image { Source = ApplicationManager.PreloadResourceImage("properties.png") } }; MenuItem miRemoveDrop = new MenuItem { Header = "Remove", Icon = new Image { Source = ApplicationManager.PreloadResourceImage("delete.png") }, InputGestureText = "Del" }; MenuItem miCopy = new MenuItem { Header = "Copy", Icon = new Image { Source = ApplicationManager.PreloadResourceImage("copy.png") }, InputGestureText = "Ctrl-C" }; MenuItem miPaste = new MenuItem { Header = "Paste", Icon = new Image { Source = ApplicationManager.PreloadResourceImage("paste.png") }, InputGestureText = "Ctrl-V" }; MenuItem miAddEvolution = new MenuItem { Header = "Add evolution", Icon = new Image { Source = ApplicationManager.PreloadResourceImage("add.png") } }; ApplicationShortcut.Link(ApplicationShortcut.Copy, () => _miCopy_Click(null, null, _lv), _lv); ApplicationShortcut.Link(ApplicationShortcut.Paste, () => _miPaste_Click(null, null), _lv); ApplicationShortcut.Link(ApplicationShortcut.Delete, () => _miRemoveDrop_Click <PetEvolutionView>(null, null, _lv), _lv); _lv.ContextMenu.Items.Add(miSelect); _lv.ContextMenu.Items.Add(miEditDrop); _lv.ContextMenu.Items.Add(miRemoveDrop); _lv.ContextMenu.Items.Add(new Separator()); _lv.ContextMenu.Items.Add(miCopy); _lv.ContextMenu.Items.Add(miPaste); _lv.ContextMenu.Items.Add(miAddEvolution); _lv.SelectionChanged += new SelectionChangedEventHandler(_lv_SelectionChanged); miSelect.Click += (sender, e) => _miSelect_Click(sender, e, _lv, ServerDbs.Pet); miEditDrop.Click += new RoutedEventHandler(_miEditDrop_Click); miRemoveDrop.Click += (sender, e) => _miRemoveDrop_Click <PetEvolutionView>(sender, e, _lv); miAddEvolution.Click += new RoutedEventHandler(_miAddDrop_Click); miCopy.Click += (sender, e) => _miCopy_Click(sender, e, _lv); miPaste.Click += new RoutedEventHandler(_miPaste_Click); _updateAction = new Action <TValue>(_update); _lv.PreviewMouseDown += delegate { Keyboard.Focus(_lv); }; dp.AddUpdateAction(_updateAction); dp.AddResetField(_lv); grid.Children.Add(label); grid.Children.Add(_lv); tab.PropertiesGrid.Children.Add(grid); _initRequirementGrid(); }
public void Init(GDbTabWrapper <TKey, TValue> tab, DisplayableProperty <TKey, TValue> dp) { _tab = tab; Grid grid = tab.PropertiesGrid.Children.OfType <Grid>().Last(); Label label = new Label(); label.Content = "Mob skills"; label.SetValue(TextBlock.ForegroundProperty, Application.Current.Resources["TextForeground"] as Brush); label.FontStyle = FontStyles.Italic; label.Padding = new Thickness(0); label.Margin = new Thickness(3); label.SetValue(Grid.ColumnProperty, 2); _lv = new RangeListView(); _lv.SetValue(TextSearch.TextPathProperty, "ID"); _lv.SetValue(WpfUtils.IsGridSortableProperty, true); _lv.SetValue(ScrollViewer.HorizontalScrollBarVisibilityProperty, ScrollBarVisibility.Disabled); _lv.SetValue(Grid.RowProperty, _row); _lv.SetValue(Grid.ColumnProperty, 2); _lv.FocusVisualStyle = null; _lv.Margin = new Thickness(3); _lv.BorderThickness = new Thickness(1); _lv.Background = Application.Current.Resources["TabItemBackground"] as Brush; ListViewDataTemplateHelper.GenerateListViewTemplateNew(_lv, new ListViewDataTemplateHelper.GeneralColumnInfo[] { new ListViewDataTemplateHelper.GeneralColumnInfo { Header = "Skill", DisplayExpression = "Name", SearchGetAccessor = "Name", ToolTipBinding = "SkillId", FixedWidth = 60, TextWrapping = TextWrapping.Wrap }, new ListViewDataTemplateHelper.GeneralColumnInfo { Header = "Condition", DisplayExpression = "Condition", SearchGetAccessor = "Condition", ToolTipBinding = "Condition", IsFill = true, TextAlignment = TextAlignment.Left, TextWrapping = TextWrapping.Wrap } }, new DefaultListViewComparer <MobSkillView>(), new string[] { "Default", "{DynamicResource TextForeground}" }); _lv.ContextMenu = new ContextMenu(); _lv.MouseDoubleClick += new MouseButtonEventHandler(_lv_MouseDoubleClick); MenuItem miSelectSkills = new MenuItem { Header = "Select skill", Icon = new Image { Source = ApplicationManager.PreloadResourceImage("arrowdown.png") } }; MenuItem miSelectMobSkills = new MenuItem { Header = "Select mob skill", Icon = new Image { Source = ApplicationManager.PreloadResourceImage("arrowdown.png") } }; MenuItem miRemoveDrop = new MenuItem { Header = "Remove mob skill", Icon = new Image { Source = ApplicationManager.PreloadResourceImage("delete.png") }, InputGestureText = "Del" }; MenuItem miCopy = new MenuItem { Header = "Copy", Icon = new Image { Source = ApplicationManager.PreloadResourceImage("copy.png") }, InputGestureText = "Ctrl-C" }; MenuItem miPaste = new MenuItem { Header = "Paste", Icon = new Image { Source = ApplicationManager.PreloadResourceImage("paste.png") }, InputGestureText = "Ctrl-V" }; ApplicationShortcut.Link(ApplicationShortcut.Copy, () => _miCopy_Click(null, null), _lv); ApplicationShortcut.Link(ApplicationShortcut.Paste, () => _miPaste_Click(null, null), _lv); ApplicationShortcut.Link(ApplicationShortcut.Delete, () => _miRemoveDrop_Click(null, null), _lv); _lv.ContextMenu.Items.Add(miSelectSkills); _lv.ContextMenu.Items.Add(miSelectMobSkills); _lv.ContextMenu.Items.Add(miRemoveDrop); _lv.ContextMenu.Items.Add(new Separator()); _lv.ContextMenu.Items.Add(miCopy); _lv.ContextMenu.Items.Add(miPaste); miSelectSkills.Click += new RoutedEventHandler(_miSelect_Click); miSelectMobSkills.Click += new RoutedEventHandler(_miSelect2_Click); miRemoveDrop.Click += new RoutedEventHandler(_miRemoveDrop_Click); miCopy.Click += new RoutedEventHandler(_miCopy_Click); miPaste.Click += new RoutedEventHandler(_miPaste_Click); _lv.MouseRightButtonUp += (MouseButtonEventHandler)((sender, e) => { try { 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); } }); _lv.PreviewMouseDown += delegate { Keyboard.Focus(_lv); //_lv.Focus(); }; dp.AddUpdateAction(new Action <TValue>(_update)); tab.ProjectDatabase.Commands.CommandIndexChanged += _commands_CommandIndexChanged; grid.Children.Add(label); grid.Children.Add(_lv); dp.AddResetField(_lv); }
public override void Init(GDbTabWrapper <TKey, ReadableTuple <TKey> > tab, DisplayableProperty <TKey, ReadableTuple <TKey> > dp) { _tab = tab; _configuration = (CustomTableInitializer)tab.Settings.AttributeList[1].AttachedObject; _configuration.AttributeTable = tab.Settings.AttributeList[1]; _tab.Settings.NewItemAddedFunction += item => item.SetRawValue(_configuration.AttributeTable, new Dictionary <int, ReadableTuple <int> >()); SdeDatabase gdb = _tab.ProjectDatabase; _table.Commands.CommandUndo += _commandChanged; _table.Commands.CommandRedo += _commandChanged; _table.Commands.CommandExecuted += _commandChanged; _table.Commands.ModifiedStateChanged += _visualUpdate; 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()); _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.Width = 334; _lv.FocusVisualStyle = null; _lv.Margin = new Thickness(3); _lv.BorderThickness = new Thickness(1); _lv.HorizontalAlignment = HorizontalAlignment.Left; _lv.SelectionChanged += _lv_SelectionChanged; SdeEditor.Instance.ProjectDatabase.Reloaded += _database_Reloaded; OnInitListView(); _lv.PreviewMouseDown += delegate { _lv.Focus(); Keyboard.Focus(_lv); }; _lv.ContextMenu = new ContextMenu(); _configuration.ListView = _lv; dp.AddResetField(_lv); dp.AddUpdateAction(_updateTable); _dp = new DisplayableProperty <TKey, ReadableTuple <TKey> >(); _dp.IsDico = true; _dp.DicoConfiguration = _configuration; grid.Children.Add(_lv); OnDeplayTable(); _tab.PropertiesGrid.Children.Add(grid); _dp.Deploy(_tab, null, true); DbSearchPanel dbSearchPanel = new DbSearchPanel(); dbSearchPanel._border1.BorderThickness = new Thickness(1); dbSearchPanel.Margin = new Thickness(3, 0, 3, 0); grid.Children.Add(dbSearchPanel); Settings = new GTabSettings <TKey, ReadableTuple <TKey> >(ServerDbs.MobGroups, tab.DbComponent); var attributes = _configuration.SubTableAttributeList.Take(_configuration.MaxElementsToCopy).Where(p => !p.IsSkippable).ToList(); if (!attributes.Any(p => p.IsDisplayAttribute)) { var att = _configuration.SubTableAttributeList.Attributes.FirstOrDefault(p => p.IsDisplayAttribute); if (att != null) { attributes.Insert(1, att); } } if (attributes.Count % 2 != 0) { attributes.Add(null); } Settings.AttributeList = _configuration.SubTableAttributeList; Settings.DbData = _configuration.ServerDb; Settings.AttId = attributes[0]; Settings.AttDisplay = attributes[1]; SearchEngine = Settings.SearchEngine; SearchEngine.SetAttributes(); SearchEngine.SetSettings(attributes[0], true); SearchEngine.SetSettings(attributes[1], true); SearchEngine.SetAttributes(attributes); SearchEngine.Init(dbSearchPanel, _lv, () => { var dico = _getSelectedGroups(); if (dico == null) { return(new List <ReadableTuple <TKey> >()); } return(dico.Values.Cast <ReadableTuple <TKey> >().ToList()); }); ApplicationShortcut.Link(ApplicationShortcut.Cut, Cut, _lv); foreach (var update in _dp.Updates) { Tuple <DbAttribute, FrameworkElement> x = update; 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 { _dp.ApplyDicoCommand(_tab, _lv, (ReadableTuple <TKey>)_tab.List.SelectedItem, _configuration.AttributeTable, (ReadableTuple <TKey>)_lv.SelectedItem, x.Item1, true); }; element.Unchecked += delegate { _dp.ApplyDicoCommand(_tab, _lv, (ReadableTuple <TKey>)_tab.List.SelectedItem, _configuration.AttributeTable, (ReadableTuple <TKey>)_lv.SelectedItem, x.Item1, false); }; } else if ( x.Item1.DataType == typeof(string) || x.Item1.DataType == typeof(int)) { // This will convert integers to strings, but the database engine // is smart enough to auto-convert them to integers afterwards. 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 { _dp.ApplyDicoCommand(_tab, _lv, (ReadableTuple <TKey>)_tab.List.SelectedItem, _configuration.AttributeTable, (ReadableTuple <TKey>)_lv.SelectedItem, x.Item1, element.Text); }; } } foreach (var property in _dp.FormattedProperties) { //property.Initialize() property.Init(tab, _dp); } }
public void Init(GDbTabWrapper <TKey, TValue> tab, DisplayableProperty <TKey, TValue> dp) { _tab = tab; DisplayableProperty <TKey, TValue> .RemoveUndoAndRedoEvents(_textBox, _tab); dp.AddResetField(_textBox); Grid grid = new Grid(); grid.SetValue(Grid.RowProperty, _gridRow); grid.SetValue(Grid.ColumnProperty, _gridColumn); grid.ColumnDefinitions.Add(new ColumnDefinition()); grid.ColumnDefinitions.Add(new ColumnDefinition { Width = new GridLength(-1, GridUnitType.Auto) }); grid.ColumnDefinitions.Add(new ColumnDefinition { Width = new GridLength(-1, GridUnitType.Auto) }); grid.ColumnDefinitions.Add(new ColumnDefinition { Width = new GridLength(-1, GridUnitType.Auto) }); _imageResource.SetValue(Grid.ColumnProperty, 2); Button button = new Button(); button.Width = 22; button.Height = 22; button.Margin = new Thickness(3); button.Content = "..."; button.Click += new RoutedEventHandler(_button_Click); button.SetValue(Grid.ColumnProperty, 3); _button = button; _textBox.SetValue(Grid.ColumnProperty, 0); Image image = new Image(); image.Visibility = Visibility.Collapsed; image.SetValue(RenderOptions.BitmapScalingModeProperty, BitmapScalingMode.NearestNeighbor); image.Source = ApplicationManager.GetResourceImage("warning16.png"); image.Width = 16; image.Height = 16; image.VerticalAlignment = VerticalAlignment.Center; image.Margin = new Thickness(1); image.ToolTip = "Invalid encoding detected. Click this button to correct the value."; image.SetValue(Grid.ColumnProperty, 1); _image = image; _image.MouseLeftButtonUp += new MouseButtonEventHandler(_image_MouseLeftButtonUp); WpfUtils.AddMouseInOutEffects(image); grid.Children.Add(_imageResource); grid.Children.Add(_textBox); grid.Children.Add(button); grid.Children.Add(image); tab.PropertiesGrid.Children.Add(grid); dp.AddUpdateAction(new Action <TValue>(item => _textBox.Dispatch(delegate { try { string sval = item.GetValue <string>(_attribute); if (sval == _textBox.Text) { return; } _textBox.Text = sval; _textBox.UndoLimit = 0; _textBox.UndoLimit = int.MaxValue; } catch { } }))); _button.ContextMenu = new ContextMenu(); _button.ContextMenu.Placement = PlacementMode.Bottom; MenuItem fromGrf = new MenuItem(); fromGrf.Header = "Select from GRF..."; fromGrf.Icon = new Image { Source = ApplicationManager.PreloadResourceImage("find.png"), Stretch = Stretch.Uniform, Width = 16, Height = 16 }; fromGrf.Click += _selectFromGrf_Click; MenuItem selectFromList = new MenuItem(); selectFromList.Header = "Autocomplete"; selectFromList.Icon = new Image { Source = ApplicationManager.PreloadResourceImage("revisionUpdate.png"), Stretch = Stretch.None }; selectFromList.Click += _autocomplete_Click; button.ContextMenu.Items.Add(fromGrf); button.ContextMenu.Items.Add(selectFromList); _button.ContextMenu.PlacementTarget = _button; _button.PreviewMouseRightButtonUp += _disableButton; }
private void _validateUndo(GDbTabWrapper <TKey, ReadableTuple <TKey> > tab, string text, DbAttribute attribute) { try { if (tab.List.SelectedItem != null && !tab.ItemsEventsDisabled && _lv.SelectedItem != null) { ReadableTuple <TKey> tuple = (ReadableTuple <TKey>)tab.List.SelectedItem; int tupleKey = ((ItemView)_lv.SelectedItem).ID; ITableCommand <TKey, ReadableTuple <TKey> > command = tab.Table.Commands.Last(); if (command is ChangeTupleDicoProperty <TKey, ReadableTuple <TKey>, TKey, ReadableTuple <TKey> > ) { ChangeTupleDicoProperty <TKey, ReadableTuple <TKey>, TKey, ReadableTuple <TKey> > changeCommand = (ChangeTupleDicoProperty <TKey, ReadableTuple <TKey>, TKey, ReadableTuple <TKey> >)command; IGenericDbCommand last = tab.GenericDatabase.Commands.Last(); if (last != null) { if (last is GenericDbCommand <TKey> ) { GenericDbCommand <TKey> nLast = (GenericDbCommand <TKey>)last; if (ReferenceEquals(nLast.Table, tab.Table)) { // The last command of the table is being edited if (changeCommand.Tuple != tuple || tupleKey != (int)(object)changeCommand.DicoKey || changeCommand.Attribute.Index != attribute.Index) { //tab.Table.Commands.Set(tuple, attribute, text); } else { ItemView itemView = ((ItemView)_lv.SelectedItem); changeCommand.NewValue.SetValue(attribute, text); changeCommand.Execute(tab.Table); if (changeCommand.NewValue.CompareWith(changeCommand.InitialValue)) { nLast.Undo(); tab.GenericDatabase.Commands.RemoveCommands(1); tab.Table.Commands.RemoveCommands(1); //changeCommand.InitialValue.Modified = changeCommand.SubModified; _lv.Dispatch(p => p.SelectedItem = ((RangeObservableCollection <ItemView>)_lv.ItemsSource).FirstOrDefault(q => q.ID == itemView.ID)); } itemView.VisualUpdate(); return; } } } } _setSelectedItem(attribute, text); } else { _setSelectedItem(attribute, text); } } } catch (Exception err) { ErrorHandler.HandleException(err); } }
public abstract void Init(GDbTabWrapper <TKey, TValue> tab, DisplayableProperty <TKey, TValue> displayableProperty);
private static void _readFile <TKey>(string file, GDbTabWrapper <TKey, ReadableTuple <TKey> > tab) { try { FieldMapper fieldMapper = new FieldMapper(tab.GetDb <TKey>(tab.Settings.DbData).TabGenerator.MaxElementsToCopyInCustomMethods, tab.ProjectDatabase.AllTables); fieldMapper.DbDest = tab.Settings.DbData; if ((tab.Settings.DbData & ServerDbs.AllItemTables) != 0) { if (file.IsExtension(".lua", ".lub")) { fieldMapper.DbImport = ServerDbs.CItems; if ((tab.Settings.DbData & ServerDbs.ServerItems) != 0) { fieldMapper.Mapping = new DbAttribute[] { ClientItemAttributes.IdentifiedDisplayName, ServerItemAttributes.Name, ClientItemAttributes.UnidentifiedDisplayName, ServerItemAttributes.Name, ClientItemAttributes.ClassNumber, ServerItemAttributes.ClassNumber, ClientItemAttributes.NumberOfSlots, ServerItemAttributes.NumberOfSlots }; } else { fieldMapper.Mapping = new DbAttribute[] { ClientItemAttributes.IdentifiedDisplayName, ClientItemAttributes.IdentifiedDisplayName, ClientItemAttributes.IdentifiedDescription, ClientItemAttributes.IdentifiedDescription, ClientItemAttributes.IdentifiedResourceName, ClientItemAttributes.IdentifiedResourceName, ClientItemAttributes.UnidentifiedDisplayName, ClientItemAttributes.UnidentifiedDisplayName, ClientItemAttributes.UnidentifiedDescription, ClientItemAttributes.UnidentifiedDescription, ClientItemAttributes.UnidentifiedResourceName, ClientItemAttributes.UnidentifiedResourceName, ClientItemAttributes.ClassNumber, ClientItemAttributes.ClassNumber, ClientItemAttributes.NumberOfSlots, ClientItemAttributes.NumberOfSlots }; } } else if (file.IsExtension(".txt", ".conf")) { if (file.Contains("item_db")) { fieldMapper.DbImport = ServerDbs.Items; if ((tab.Settings.DbData & ServerDbs.ClientItems) != 0) { fieldMapper.Mapping = new DbAttribute[] { ServerItemAttributes.Name, ClientItemAttributes.IdentifiedDisplayName, ServerItemAttributes.ClassNumber, ClientItemAttributes.ClassNumber, ServerItemAttributes.NumberOfSlots, ClientItemAttributes.NumberOfSlots }; } } else { fieldMapper.DbImport = ServerDbs.CItems; if (file.Contains("idnum2itemdisplaynametable")) { if ((tab.Settings.DbData & ServerDbs.ClientItems) != 0) { fieldMapper.Mapping = new DbAttribute[] { ClientItemAttributes.IdentifiedDisplayName, ClientItemAttributes.IdentifiedDisplayName } } ; else { fieldMapper.Mapping = new DbAttribute[] { ClientItemAttributes.IdentifiedDisplayName, ServerItemAttributes.Name } }; } else if (file.Contains("num2itemdisplaynametable")) { if ((tab.Settings.DbData & ServerDbs.ClientItems) != 0) { fieldMapper.Mapping = new DbAttribute[] { ClientItemAttributes.UnidentifiedDisplayName, ClientItemAttributes.UnidentifiedDisplayName } } ; else { fieldMapper.Mapping = new DbAttribute[] { ClientItemAttributes.UnidentifiedDisplayName, ServerItemAttributes.Name } }; } else if (file.Contains("idnum2itemdesctable")) { if ((tab.Settings.DbData & ServerDbs.ClientItems) != 0) { fieldMapper.Mapping = new DbAttribute[] { ClientItemAttributes.IdentifiedDescription, ClientItemAttributes.IdentifiedDescription }; } else { throw new Exception("File not supported."); } } else if (file.Contains("num2itemdesctable")) { if ((tab.Settings.DbData & ServerDbs.ClientItems) != 0) { fieldMapper.Mapping = new DbAttribute[] { ClientItemAttributes.UnidentifiedDescription, ClientItemAttributes.UnidentifiedDescription }; } else { throw new Exception("File not supported."); } } else if (file.Contains("idnum2itemresnametable")) { if ((tab.Settings.DbData & ServerDbs.ClientItems) != 0) { fieldMapper.Mapping = new DbAttribute[] { ClientItemAttributes.IdentifiedResourceName, ClientItemAttributes.IdentifiedResourceName }; fieldMapper.AllowCutLine = false; } else { throw new Exception("File not supported."); } } else if (file.Contains("num2itemresnametable")) { if ((tab.Settings.DbData & ServerDbs.ClientItems) != 0) { fieldMapper.Mapping = new DbAttribute[] { ClientItemAttributes.UnidentifiedResourceName, ClientItemAttributes.UnidentifiedResourceName }; fieldMapper.AllowCutLine = false; } else { throw new Exception("File not supported."); } } else if (file.Contains("num2cardillustnametable")) { if ((tab.Settings.DbData & ServerDbs.ClientItems) != 0) { fieldMapper.Mapping = new DbAttribute[] { ClientItemAttributes.Illustration, ClientItemAttributes.Illustration }; } else { throw new Exception("File not supported."); } } else if (file.Contains("cardprefixnametable")) { if ((tab.Settings.DbData & ServerDbs.ClientItems) != 0) { fieldMapper.Mapping = new DbAttribute[] { ClientItemAttributes.Affix, ClientItemAttributes.Affix }; } else { throw new Exception("File not supported."); } } else { throw new Exception("File not supported."); } } } else { throw new Exception("File name not recognized (must be item_db or idnum2itemdisplaynametable."); } fieldMapper.Map(tab, file, fieldMapper.GetMappingFields()); } else { fieldMapper.DbImport = tab.Settings.DbData; fieldMapper.Map(tab, file, fieldMapper.GetMappingFields()); } } catch (OperationCanceledException) { throw new OperationCanceledException(); } catch (Exception err) { ErrorHandler.HandleException(err); } }
public void Init(GDbTabWrapper <TKey, TValue> tab, DisplayableProperty <TKey, TValue> dp) { _tab = tab; Grid grid = tab.PropertiesGrid.Children.OfType <Grid>().Last(); Label label = new Label(); label.Content = "Mob skills"; label.FontStyle = FontStyles.Italic; label.Padding = new Thickness(0); label.Margin = new Thickness(3); label.SetValue(Grid.ColumnProperty, 2); _lv = new RangeListView(); _lv.SetValue(TextSearch.TextPathProperty, "ID"); _lv.SetValue(WpfUtils.IsGridSortableProperty, true); _lv.SetValue(ScrollViewer.HorizontalScrollBarVisibilityProperty, ScrollBarVisibility.Disabled); _lv.SetValue(Grid.RowProperty, _row); _lv.SetValue(Grid.ColumnProperty, 2); _lv.FocusVisualStyle = null; _lv.Margin = new Thickness(3); _lv.BorderThickness = new Thickness(1); WpfUtils.DisableContextMenuIfEmpty(_lv); Extensions.GenerateListViewTemplate(_lv, new ListViewDataTemplateHelper.GeneralColumnInfo[] { new ListViewDataTemplateHelper.GeneralColumnInfo { Header = "Skill", DisplayExpression = "Name", SearchGetAccessor = "Name", ToolTipBinding = "SkillId", FixedWidth = 60, TextWrapping = TextWrapping.Wrap }, new ListViewDataTemplateHelper.GeneralColumnInfo { Header = "Condition", DisplayExpression = "Condition", SearchGetAccessor = "Condition", ToolTipBinding = "Condition", IsFill = true, TextAlignment = TextAlignment.Left, TextWrapping = TextWrapping.Wrap } }, new DefaultListViewComparer <MobSkillView>(), new string[] { "Modified", "Green", "Added", "Blue", "Default", "Black" }); _lv.ContextMenu = new ContextMenu(); _lv.MouseDoubleClick += new MouseButtonEventHandler(_lv_MouseDoubleClick); MenuItem miSelectSkills = new MenuItem { Header = "Select skill", Icon = new Image { Source = (BitmapSource)ApplicationManager.PreloadResourceImage("arrowdown.png") } }; MenuItem miSelectMobSkills = new MenuItem { Header = "Select mob skill", Icon = new Image { Source = (BitmapSource)ApplicationManager.PreloadResourceImage("arrowdown.png") } }; MenuItem miRemoveDrop = new MenuItem { Header = "Remove mob skill", Icon = new Image { Source = (BitmapSource)ApplicationManager.PreloadResourceImage("delete.png") } }; _lv.ContextMenu.Items.Add(miSelectSkills); _lv.ContextMenu.Items.Add(miSelectMobSkills); _lv.ContextMenu.Items.Add(miRemoveDrop); miSelectSkills.Click += new RoutedEventHandler(_miSelect_Click); miSelectMobSkills.Click += new RoutedEventHandler(_miSelect2_Click); miRemoveDrop.Click += new RoutedEventHandler(_miRemoveDrop_Click); dp.AddUpdateAction(new Action <TValue>(_update)); tab.GenericDatabase.Commands.CommandIndexChanged += _commands_CommandIndexChanged; grid.Children.Add(label); grid.Children.Add(_lv); dp.AddResetField(_lv); }
public void Init(GDbTabWrapper <TKey, TValue> tab, DisplayableProperty <TKey, TValue> dp) { _tab = tab; Table <int, ReadableTuple <int> > btable = _tab.ProjectDatabase.GetMetaTable <int>(ServerDbs.Mobs); _queryThread = new QueryThread <TKey, TValue>(btable, this); Grid grid = new Grid(); WpfUtilities.SetGridPosition(grid, _row, _rSpan, _col, _cSpan); grid.Dispatcher.ShutdownStarted += delegate { _queryThread.Stop(); }; _queryThread.Start(); grid.RowDefinitions.Add(new RowDefinition { Height = new GridLength(-1, GridUnitType.Auto) }); grid.RowDefinitions.Add(new RowDefinition()); Label label = new Label(); label.Content = "Dropped by"; label.FontStyle = FontStyles.Italic; label.Padding = new Thickness(0); label.Margin = new Thickness(3); label.SetValue(TextBlock.ForegroundProperty, Application.Current.Resources["TextForeground"] as Brush); _lv = new RangeListView(); _lv.SetValue(TextSearch.TextPathProperty, "ID"); _lv.SetValue(WpfUtils.IsGridSortableProperty, true); _lv.SetValue(ScrollViewer.HorizontalScrollBarVisibilityProperty, ScrollBarVisibility.Disabled); _lv.SetValue(Grid.RowProperty, _row); _lv.FocusVisualStyle = null; _lv.Margin = new Thickness(3); _lv.BorderThickness = new Thickness(1); _lv.Background = Application.Current.Resources["TabItemBackground"] as Brush; ListViewDataTemplateHelper.GenerateListViewTemplateNew(_lv, new ListViewDataTemplateHelper.GeneralColumnInfo[] { new ListViewDataTemplateHelper.GeneralColumnInfo { Header = ServerMobAttributes.Id.DisplayName, DisplayExpression = "ID", SearchGetAccessor = "ID", FixedWidth = 60, TextAlignment = TextAlignment.Right, ToolTipBinding = "ID" }, new ListViewDataTemplateHelper.RangeColumnInfo { Header = ServerMobAttributes.KRoName.DisplayName, DisplayExpression = "Name", SearchGetAccessor = "Name", IsFill = true, ToolTipBinding = "Name", TextWrapping = TextWrapping.Wrap, MinWidth = 40 }, new ListViewDataTemplateHelper.GeneralColumnInfo { Header = "Drop %", DisplayExpression = "Drop", SearchGetAccessor = "DropOriginal", ToolTipBinding = "DropOriginal", FixedWidth = 60, TextAlignment = TextAlignment.Right }, new ListViewDataTemplateHelper.GeneralColumnInfo { Header = "Type", DisplayExpression = "MVP", SearchGetAccessor = "MVP", FixedWidth = 45, TextAlignment = TextAlignment.Center }, }, new DefaultListViewComparer <MobDropView>(), new string[] { "Default", "{DynamicResource TextForeground}", "IsMvp", "{DynamicResource CellBrushMvp}" }); _lv.ContextMenu = new ContextMenu(); _lv.MouseDoubleClick += new MouseButtonEventHandler(_lv_MouseDoubleClick); MenuItem miSelect = new MenuItem { Header = "Select", Icon = new Image { Source = ApplicationManager.PreloadResourceImage("arrowdown.png") } }; MenuItem miEditDrop = new MenuItem { Header = "Edit drop chance", Icon = new Image { Source = ApplicationManager.PreloadResourceImage("properties.png") } }; MenuItem miRemoveDrop = new MenuItem { Header = "Remove", Icon = new Image { Source = ApplicationManager.PreloadResourceImage("delete.png") } }; MenuItem miAddDrop = new MenuItem { Header = "Add as normal drop", Icon = new Image { Source = ApplicationManager.PreloadResourceImage("add.png") } }; MenuItem miAddMvpDrop = new MenuItem { Header = "Add as MVP drop", Icon = new Image { Source = ApplicationManager.PreloadResourceImage("add.png") } }; _lv.ContextMenu.Items.Add(miSelect); _lv.ContextMenu.Items.Add(miEditDrop); _lv.ContextMenu.Items.Add(miRemoveDrop); _lv.ContextMenu.Items.Add(new Separator()); _lv.ContextMenu.Items.Add(miAddDrop); _lv.ContextMenu.Items.Add(miAddMvpDrop); miSelect.Click += new RoutedEventHandler(_miSelect_Click); miEditDrop.Click += new RoutedEventHandler(_miEditDrop_Click); miRemoveDrop.Click += new RoutedEventHandler(_miRemoveDrop_Click); miAddDrop.Click += (a, e) => _miAddDrop_Click(false); miAddMvpDrop.Click += (a, e) => _miAddDrop_Click(true); dp.AddUpdateAction(new Action <TValue>(_update)); grid.Children.Add(label); grid.Children.Add(_lv); tab.ProjectDatabase.Commands.CommandIndexChanged += _commands_CommandIndexChanged; tab.PropertiesGrid.Children.Add(grid); dp.AddResetField(_lv); _lv.MouseRightButtonUp += (MouseButtonEventHandler)((sender, e) => { try { bool hasItems = _lv.GetObjectAtPoint <ListViewItem>(e.GetPosition(_lv)) != null; _lv.ContextMenu.Items.Cast <UIElement>().Take(4).ToList().ForEach(p => p.Visibility = hasItems ? Visibility.Visible : Visibility.Collapsed); } catch (Exception err) { ErrorHandler.HandleException(err); } }); }
public void Init(GDbTabWrapper <TKey, TValue> tab, DisplayableProperty <TKey, TValue> dp) { _tab = tab; _tab.PropertiesGrid.Children.Add(_viewer); }
public void Init(GDbTabWrapper <TKey, TValue> tab, DisplayableProperty <TKey, TValue> dp) { _tab = tab; DisplayableProperty <TKey, TValue> .RemoveUndoAndRedoEvents(_textBox, _tab); //_autocompleteService = new AutocompleteService(_tab.List, _tbIdResource, _tbUnResource, _tbIdDisplayName, _tbUnDisplayName, _tbIdDesc, _tbUnDesc); dp.AddResetField(_textBox); dp.AddResetField(_realBox); Border border = new Border(); border.BorderBrush = SystemColors.ActiveBorderBrush; border.BorderThickness = new Thickness(1); border.Child = _textBox; border.SetValue(Grid.RowProperty, _gridRow); border.SetValue(Grid.ColumnProperty, _gridColumn + 1); border.Margin = new Thickness(3); _tab.PropertiesGrid.Children.Add(border); StackPanel panel = new StackPanel(); panel.SetValue(Grid.RowProperty, _gridRow); panel.SetValue(Grid.ColumnProperty, _gridColumn); Label label = new Label { Content = "Description" }; label.SetValue(TextBlock.ForegroundProperty, Application.Current.Resources["TextForeground"] as Brush); Button button = new Button(); button.Margin = new Thickness(3); panel.Children.Add(label); panel.Children.Add(button); _textBox.GotFocus += delegate { _lastAccessed = _textBox; }; if (_quickEdit) { _tab.List.SelectionChanged += new SelectionChangedEventHandler(_list_SelectionChanged); button.Content = "Quick edit..."; button.Click += new RoutedEventHandler(_buttonQuickEdit_Click); TextEditorColorControl colorControl = new TextEditorColorControl(); Label label2 = new Label { Content = "Color picker" }; label2.SetValue(TextBlock.ForegroundProperty, Application.Current.Resources["TextForeground"] as Brush); _tecc = colorControl; _lastAccessed = _textBox; colorControl.Init(_getActive); Button itemScript = new Button { Margin = new Thickness(3), Content = "Item bonus" }; itemScript.Click += delegate { itemScript.IsEnabled = false; var meta = _tab.GetMetaTable <int>(ServerDbs.Items); var item = _tab._listView.SelectedItem as ReadableTuple <int>; _update = new Func <ReadableTuple <int>, string>(tuple => { var output = new StringBuilder(); if (tuple != null) { var entry = meta.TryGetTuple(tuple.Key); if (entry != null) { output.AppendLine("-- Script --"); output.AppendLine(entry.GetValue <string>(ServerItemAttributes.Script)); output.AppendLine("-- OnEquipScript --"); output.AppendLine(entry.GetValue <string>(ServerItemAttributes.OnEquipScript)); output.AppendLine("-- OnUnequipScript --"); output.AppendLine(entry.GetValue <string>(ServerItemAttributes.OnUnequipScript)); } else { output.AppendLine("-- Not found in item_db_m --"); } } else { output.AppendLine("-- No entry selected --"); } return(output.ToString()); }); _scriptEdit = new ScriptEditDialog(_update(item)); _scriptEdit.Closed += delegate { itemScript.IsEnabled = true; _scriptEdit = null; }; _scriptEdit._textEditor.IsReadOnly = true; _scriptEdit.DisableOk(); _scriptEdit.Show(); _scriptEdit.Owner = WpfUtilities.FindParentControl <Window>(_tab); }; panel.Children.Add(itemScript); panel.Children.Add(label2); panel.Children.Add(colorControl); } else { if (_tecc != null) { var t = _lastAccessed; _lastAccessed = _textBox; _tecc.Init(_getActive); _lastAccessed = t; } button.Content = "Copy >"; button.Click += new RoutedEventHandler(_buttonAutocomplete_Click); } tab.PropertiesGrid.Children.Add(panel); dp.AddUpdateAction(new Action <TValue>(item => _textBox.Dispatch(delegate { Debug.Ignore(() => _realBox.Text = item.GetValue <string>(_attribute)); //Debug.Ignore(() => _textBox.Text = item.GetValue<string>(_attribute)); _realBox.UndoLimit = 0; _realBox.UndoLimit = int.MaxValue; //Debug.Ignore(() => _textBox.Text = item.GetValue<string>(_attribute)); _textBox.Document.UndoStack.SizeLimit = 0; _textBox.Document.UndoStack.SizeLimit = int.MaxValue; }))); _realBox.TextChanged += delegate { WpfUtilities.UpdateRtb(_previewTextBox, _realBox.Text, true); if (_avalonUpdate) { return; } _textBox.Text = _realBox.Text; }; }
public override void Init(GDbTabWrapper <TKey, ReadableTuple <TKey> > tab, DisplayableProperty <TKey, ReadableTuple <TKey> > dp) { _tab = tab; Grid grid = new Grid(); WpfUtilities.SetGridPosition(grid, _row, null, _column - 1, 2); for (int i = 0; i < _numOfItems; i++) { grid.RowDefinitions.Add(new RowDefinition { Height = new GridLength(-1, GridUnitType.Auto) }); grid.RowDefinitions.Add(new RowDefinition { Height = new GridLength(0) }); } grid.ColumnDefinitions.Add(new ColumnDefinition { Width = new GridLength(-1, GridUnitType.Auto) }); grid.ColumnDefinitions.Add(new ColumnDefinition()); grid.ColumnDefinitions.Add(new ColumnDefinition { Width = new GridLength(-1, GridUnitType.Auto) }); for (int i = 0; i < _numOfItems; i++) { Label label = new Label(); label.Content = "ID" + (i + 1); label.VerticalAlignment = VerticalAlignment.Center; label.Margin = new Thickness(3); label.Padding = new Thickness(0); label.SetValue(Grid.RowProperty, 2 * i); label.SetValue(TextBlock.ForegroundProperty, Application.Current.Resources["TextForeground"] as Brush); Label spacer = new Label(); spacer.Height = 3; spacer.Content = ""; spacer.SetValue(Grid.RowProperty, 2 * i + 1); TextBlock preview = new TextBlock(); preview.HorizontalAlignment = HorizontalAlignment.Left; preview.VerticalAlignment = VerticalAlignment.Center; preview.Margin = new Thickness(7, 0, 4, 0); preview.Padding = new Thickness(0); preview.SetValue(Grid.RowProperty, 2 * i); preview.Foreground = Application.Current.Resources["TextBoxOverlayBrush"] as SolidColorBrush; preview.SetValue(Grid.ColumnProperty, 1); preview.IsHitTestVisible = false; Button button = new Button(); button.Width = 22; button.Height = 22; button.Margin = new Thickness(0, 3, 3, 3); button.Content = new Image { Stretch = Stretch.None, Source = ApplicationManager.PreloadResourceImage("arrowdown.png") }; button.Click += new RoutedEventHandler(_button_Click); button.SetValue(Grid.ColumnProperty, 2); button.SetValue(Grid.RowProperty, 2 * i); button.ContextMenu = new ContextMenu(); button.ContextMenu.Placement = PlacementMode.Bottom; button.ContextMenu.PlacementTarget = button; button.PreviewMouseRightButtonUp += delegate(object sender, MouseButtonEventArgs e) { e.Handled = true; }; MenuItem select = new MenuItem(); select.Header = "Select ''"; select.Icon = new Image { Source = ApplicationManager.PreloadResourceImage("find.png"), Stretch = Stretch.Uniform, Width = 16, Height = 16 }; select.Click += _select_Click; select.Tag = button; MenuItem selectFromList = new MenuItem(); selectFromList.Header = "Select..."; selectFromList.Icon = new Image { Source = ApplicationManager.PreloadResourceImage("treeList.png"), Stretch = Stretch.None }; selectFromList.Click += _selectFromList_Click; selectFromList.Tag = button; button.ContextMenu.Items.Add(select); button.ContextMenu.Items.Add(selectFromList); TextBox textBox = new TextBox(); textBox.Margin = new Thickness(3); textBox.TextChanged += new TextChangedEventHandler(_textBox_TextChanged); textBox.SetValue(Grid.ColumnProperty, 1); textBox.SetValue(Grid.RowProperty, 2 * i); textBox.TextChanged += new TextChangedEventHandler(_textBox2_TextChanged); dp.AddResetField(textBox); button.Tag = textBox; textBox.Tag = preview; textBox.GotFocus += delegate { preview.Visibility = Visibility.Collapsed; textBox.Foreground = Application.Current.Resources["TextForeground"] as Brush; }; textBox.LostFocus += (sender, e) => _textBox2_TextChanged(sender, null); _boxes.Add(textBox); grid.Children.Add(spacer); grid.Children.Add(textBox); grid.Children.Add(button); grid.Children.Add(label); grid.Children.Add(preview); DisplayableProperty <TKey, ReadableTuple <TKey> > .RemoveUndoAndRedoEvents(textBox, _tab); } tab.PropertiesGrid.Children.Add(grid); dp.AddUpdateAction(new Action <ReadableTuple <TKey> >(item => grid.Dispatch(delegate { try { TextBox textBox; string value = item.GetValue <string>(_attribute); List <string> values = value.Split(':').ToList(); while (values.Count < _numOfItems) { values.Add(""); } for (int i = 0; i < _numOfItems; i++) { textBox = _boxes[i]; textBox.Text = values[i]; textBox.UndoLimit = 0; textBox.UndoLimit = int.MaxValue; } } #if SDE_DEBUG catch (Exception err) { Debug.PrintStack(err); #else catch { #endif } })));
public override void Init(GDbTabWrapper <TKey, ReadableTuple <TKey> > tab, DisplayableProperty <TKey, ReadableTuple <TKey> > dp) { _tab = tab; Grid grid = new Grid(); WpfUtilities.SetGridPosition(grid, _row, null, _column - 1, 2); for (int i = 0; i < _numOfItems; i++) { grid.RowDefinitions.Add(new RowDefinition { Height = new GridLength(-1, GridUnitType.Auto) }); grid.RowDefinitions.Add(new RowDefinition { Height = new GridLength(0) }); } grid.ColumnDefinitions.Add(new ColumnDefinition { Width = new GridLength(-1, GridUnitType.Auto) }); grid.ColumnDefinitions.Add(new ColumnDefinition { Width = new GridLength(100) }); grid.ColumnDefinitions.Add(new ColumnDefinition { Width = new GridLength(-1, GridUnitType.Auto) }); grid.ColumnDefinitions.Add(new ColumnDefinition { Width = new GridLength(-1, GridUnitType.Auto) }); grid.ColumnDefinitions.Add(new ColumnDefinition()); for (int i = 0; i < _numOfItems; i++) { Label label = new Label(); label.Content = "ID" + (i + 1); label.VerticalAlignment = VerticalAlignment.Center; label.Margin = new Thickness(3); label.Padding = new Thickness(0); label.SetValue(Grid.RowProperty, 2 * i); Label spacer = new Label(); spacer.Height = 3; spacer.Content = ""; spacer.SetValue(Grid.RowProperty, 2 * i + 1); Label preview = new Label(); preview.Content = ""; preview.HorizontalAlignment = HorizontalAlignment.Left; preview.VerticalAlignment = VerticalAlignment.Center; preview.Margin = new Thickness(3); preview.Padding = new Thickness(0); preview.SetValue(Grid.RowProperty, 2 * i); preview.SetValue(Grid.ColumnProperty, 3); Button button = new Button(); button.Width = 22; button.Height = 22; button.Margin = new Thickness(0, 3, 3, 3); button.Content = new Image { Stretch = Stretch.None, Source = ApplicationManager.PreloadResourceImage("arrowdown.png") as ImageSource }; button.Click += new RoutedEventHandler(_button_Click); button.SetValue(Grid.ColumnProperty, 2); button.SetValue(Grid.RowProperty, 2 * i); button.TabIndex = dp.ZIndex++; TextBox textBox = new TextBox(); textBox.Margin = new Thickness(3); textBox.TextChanged += new TextChangedEventHandler(_textBox_TextChanged); textBox.SetValue(Grid.ColumnProperty, 1); textBox.SetValue(Grid.RowProperty, 2 * i); textBox.TextChanged += new TextChangedEventHandler(_textBox2_TextChanged); dp.AddResetField(textBox); button.Tag = textBox; textBox.Tag = preview; _boxes.Add(textBox); grid.Children.Add(spacer); grid.Children.Add(button); grid.Children.Add(label); grid.Children.Add(textBox); grid.Children.Add(preview); DisplayableProperty <TKey, ReadableTuple <TKey> > .RemoveUndoAndRedoEvents(textBox, _tab); } tab.PropertiesGrid.Children.Add(grid); dp.AddUpdateAction(new Action <ReadableTuple <TKey> >(item => grid.Dispatch(delegate { try { TextBox textBox; string value = item.GetValue <string>(_attribute); List <string> values = value.Split(':').ToList(); while (values.Count < _numOfItems) { values.Add(""); } for (int i = 0; i < _numOfItems; i++) { textBox = _boxes[i]; textBox.Text = values[i]; textBox.UndoLimit = 0; textBox.UndoLimit = int.MaxValue; } } #if SDE_DEBUG catch (Exceptionerr) { Debug.PrintStack(err); #else catch { #endif } })));