private void _textBox_TextChanged(object sender, EventArgs e) { try { if (_avalonUpdate) { return; } if (_tab.ItemsEventsDisabled) { return; } try { _avalonUpdate = true; _realBox.Text = _textBox.Text; DisplayableProperty <TKey, TValue> .ApplyCommand(_tab, _attribute, _realBox.Text); } finally { _avalonUpdate = false; } } catch (Exception err) { ErrorHandler.HandleException(err); } }
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 { } }))); }
private void _textBox_TextChanged(object sender, TextChangedEventArgs e) { try { if (!_tab.ItemsEventsDisabled) { DisplayableProperty <TKey, TValue> .ApplyCommand(_tab, _attribute, _textBox.Text); } try { byte[] data = _tab.ProjectDatabase.MetaGrf.GetDataBuffered(EncodingService.FromAnyToDisplayEncoding(GrfPath.Combine(_grfPath1, _textBox.Text.ExpandString()) + _ext)); if (data != null) { WpfUtilities.TextBoxOk(_textBox); _wrapper1.Image = ImageProvider.GetImage(data, _ext); _wrapper1.Image.MakePinkTransparent(); _imageResource.Tag = _textBox.Text; _imageResource.Source = _wrapper1.Image.Cast <BitmapSource>(); } else { WpfUtilities.TextBoxError(_textBox); _wrapper1.Image = null; _imageResource.Source = null; } } catch (ArgumentException) { WpfUtilities.TextBoxError(_textBox); _wrapper1.Image = null; _imageResource.Source = null; } try { byte[] data2 = _tab.ProjectDatabase.MetaGrf.GetDataBuffered(EncodingService.FromAnyToDisplayEncoding(GrfPath.Combine(_grfPath2, _textBox.Text.ExpandString()) + _ext)); if (data2 != null) { _wrapper2.Image = ImageProvider.GetImage(data2, _ext); _wrapper2.Image.MakePinkTransparent(); _imagePreview.Tag = _textBox.Text; _imagePreview.Source = _wrapper2.Image.Cast <BitmapSource>(); //_imagePreview.Source.Freeze(); } else { _wrapper2.Image = null; _imagePreview.Source = null; } } catch (ArgumentException) { _wrapper2.Image = null; _imagePreview.Source = null; } } catch (Exception err) { ErrorHandler.HandleException(err); } }
public void Initialize(DbAttribute attribute, int row, int column, object displayableProperty, Grid parent = null) { _row = row; _column = column; _attribute = attribute; _parent = parent; _displayableProperty = (DisplayableProperty <TKey, TValue>)displayableProperty; OnInitialized(); }
public static void Update() { // Update UI stuff here largestDisplayNameWidth = 0; drawableProps = State.GetUIParamsList(); foreach (DisplayableProperty property in drawableProps) { Vector2 displayArea = Fonts.VerdanaBold.MeasureString(property.DisplayName); property.Rectangle = new Rectangle( Config.PLANET_RECT_SIZE + 2 * Config.PLANET_PADDING, 10 + property.Position * 20, (int)displayArea.X, (int)displayArea.Y); if (largestDisplayNameWidth < displayArea.X) { largestDisplayNameWidth = (int)displayArea.X; } property.Hovered = property.Rectangle.Contains(State.MouseX, State.MouseY); if (!State.MouseL) { lockedProperty = null; } else { if (property.Hovered && lockedProperty == null) { property.Locked = true; lockedProperty = property; } else if (lockedProperty != null && lockedProperty.Key == property.Key) { if (MouseStates.MouseMiddleClickPressed()) { State.SetDefaultValueFor(property.Key); } else { int mouseDelta = MouseStates.GetMouseWheelDelta(); if (mouseDelta != 0) { State.ModifyValueFor(property.Key, mouseDelta); } } property.Locked = true; } } } // Some offset to display the value a bit to the right largestDisplayNameWidth += 4; }
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); }
private void _textBox_TextChanged(object sender, TextChangedEventArgs e) { try { DisplayableProperty <int, ReadableTuple <int> > .ApplyCommand(_tab, _attribute, _textBox.Text); OnUpdate(); } catch (Exception err) { ErrorHandler.HandleException(err); } }
private void _textBox_TextChanged(object sender, TextChangedEventArgs e) { try { if (_enableEvents) { DisplayableProperty <TKey, ReadableTuple <TKey> > .ValidateUndo(_tab, _textBox.Text, _attribute); } } catch (Exception err) { ErrorHandler.HandleException(err); } }
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(); }
private object CreateTreeViewItemForProperty(PropertyInfo propertyInfo, string name) { TreeViewItem newItem = new TreeViewItem(); WrapPanel stack = new WrapPanel(); stack.MaxWidth = 400; stack.Orientation = Orientation.Horizontal; DisplayableProperty propertyData = propertyInfo.GetCustomAttribute <DisplayableProperty>(); Label propertyLabel = new Label(); propertyLabel.Content = propertyData.name; propertyLabel.Width = 200; propertyLabel.HorizontalContentAlignment = System.Windows.HorizontalAlignment.Right; propertyLabel.Margin = new Thickness(0, 0, 5, 0); TextBox propertyText = new TextBox(); propertyText.Text = propertyInfo.GetValue(null).ToString(); propertyText.Tag = propertyInfo; propertyText.Width = 100; propertyText.Margin = new Thickness(2); propertyText.TextChanged += propertyText_TextChanged; propertyText.IsTabStop = true; propertyText.TabIndex = tabStopIndex++; TextBlock descriptionLabel = new TextBlock(); descriptionLabel.Text = propertyData.description; descriptionLabel.Width = 300; descriptionLabel.TextAlignment = TextAlignment.Justify; descriptionLabel.Margin = new Thickness(0, 0, 5, 0); descriptionLabel.FontSize = 10; descriptionLabel.VerticalAlignment = System.Windows.VerticalAlignment.Top; descriptionLabel.TextWrapping = TextWrapping.Wrap; descriptionLabel.Padding = new Thickness(3, 0, 3, 10); stack.Children.Add(propertyLabel); stack.Children.Add(propertyText); if (!String.IsNullOrEmpty(propertyData.description)) { stack.Children.Add(descriptionLabel); } stack.Background = new SolidColorBrush(Color.FromRgb(220, 220, 220)); stack.Margin = new Thickness(0); newItem.Header = stack; KeyboardNavigation.SetTabNavigation(newItem, KeyboardNavigationMode.Continue); return(newItem); }
/// <summary>Sets the isolated state of this batch.</summary> public void IsIsolated(DisplayableProperty property) { if (Isolated && Setup) { // No change. return; } Setup = true; Isolated = true; FontAtlas = null; GraphicsAtlas = null; IsolatedProperty = property; }
/// <summary>Applies the given particle system gameObject to this particles tag. /// Essentially makes it get laid out by the UI. /// Usually you'd use the path=".." attribute (or anElement["path"]) rather than calling this directly.</summary> public void ApplySystem(GameObject gameObject) { if (BatchProperty == null) { // Create the BP now: BatchProperty = new DisplayableProperty(RenderData); // It's always isolated (as the particle system is on a layer of it's own): BatchProperty.Isolate(); } // Get the material: ParticleSystemRenderer partRenderer = gameObject.GetComponent <ParticleSystemRenderer>(); if (partRenderer == null) { Debug.LogError("The gameObject '" + gameObject.name + "' wasn't a particle system on a <particles> tag (it has no ParticleSystemRenderer)"); return; } // Apply: Particles = gameObject; // Apply material: ParticleMaterial = partRenderer.material; // Get the transform: Transform transform = gameObject.transform; ParticleTransform = transform; // PowerUI layer, unless we're on a WorldUI: if (htmlDocument.worldUI == null) { // Update the layer: gameObject.layer = UI.Layer; } // parent to GUINode: transform.parent = rootGameObject.transform; // Zero local position: ParticleTransform.localPosition = Vector3.zero; // Update scale/rotation: Relocate(); // Request a layout: htmlDocument.RequestLayout(); }
/// <summary>Sets the isolated state of this batch.</summary> public void NotIsolated(TextureAtlas graphics, TextureAtlas font, float alias) { if (!Isolated && Setup) { return; } Setup = true; Isolated = false; IsolatedProperty = null; Mesh.SetGlobalMaterial(); SetFontAtlas(font, alias); SetGraphicsAtlas(graphics); }
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 <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 { } }))); }
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(); }
private void _textBox_TextChanged(object sender, TextChangedEventArgs e) { try { DisplayableProperty <TKey, ReadableTuple <TKey> > .ValidateUndo(_tab, _textBox.Text, _attribute); UpdatePreview(); if (_textPreview.Text == "") { _textPreview.Visibility = Visibility.Collapsed; } else { _textPreview.Visibility = Visibility.Visible; } } catch (Exception err) { ErrorHandler.HandleException(err); } }
/// <summary>Sets the isolated state of this batch.</summary> public void NotIsolated(TextureAtlas graphics, TextureAtlas font) { if (!Isolated && Setup) { return; } Setup = true; Isolated = false; IsolatedProperty = null; if (Renderer.CurrentShaderSet.UsesLighting && Mesh.Normals == null) { // Normals are required: Mesh.RequireNormals(); } Mesh.SetGlobalMaterial(Renderer.CurrentShaderSet.Normal); SetFontAtlas(font); SetGraphicsAtlas(graphics); }
/// <summary>Permanently destroys this UI batch.</summary> public void Destroy() { if (Renderer == null) { return; } if (IsolatedProperty != null) { IsolatedProperty.Isolated = false; IsolatedProperty.OnBatchDestroy(); IsolatedProperty = null; } if (Mesh != null) { Mesh.Destroy(); Mesh = null; } Renderer = null; }
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); 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; }
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 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 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 abstract void Init(GDbTabWrapper <TKey, TValue> tab, DisplayableProperty <TKey, TValue> displayableProperty);
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; 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 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 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 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); }