private void _showPreview() { WpfUtilities.UpdateRtb(_rtbItemDescription, _generateDescription()); }
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; }; }