public CustomManagerProperty(TextBox textBox, string grfPath, string ext, int row, int col, int rSpan, int cSpan) { _image = new Image { Stretch = Stretch.None, HorizontalAlignment = HorizontalAlignment.Center, VerticalAlignment = VerticalAlignment.Center }; _image.SetValue(RenderOptions.BitmapScalingModeProperty, BitmapScalingMode.NearestNeighbor); _viewer = new ScrollViewer(); Grid grid = new Grid(); //grid.ColumnDefinitions.Add(new ColumnDefinition) WpfUtilities.SetGridPosition(_viewer, row, rSpan, col, cSpan); _viewer.HorizontalScrollBarVisibility = ScrollBarVisibility.Auto; _viewer.VerticalScrollBarVisibility = ScrollBarVisibility.Auto; _viewer.Content = _image; _textBox = textBox; _grfPath = grfPath.Trim('\\'); _ext = ext; _attribute = null; _textBox.TextChanged += _textBox_TextChanged; VirtualFileDataObject.SetDraggable(_image, _wrapper); _viewer.SizeChanged += delegate { _viewer.MaxHeight = _viewer.ActualHeight; }; }
private void _addSearchAttributeSub(Grid searchGrid, string attribute, int row, int column) { CheckBox box = new CheckBox(); box.Margin = new Thickness(3); TextBlock block = new TextBlock { Text = attribute }; box.MouseEnter += delegate { block.Foreground = new SolidColorBrush(Color.FromArgb(255, 5, 119, 193)); block.Cursor = Cursors.Hand; block.TextDecorations = TextDecorations.Underline; }; box.MouseLeave += delegate { block.Foreground = Brushes.Black; block.Cursor = Cursors.Arrow; block.TextDecorations = null; }; box.Content = block; while (searchGrid.RowDefinitions.Count <= row) { searchGrid.RowDefinitions.Add(new RowDefinition { Height = new GridLength(-1, GridUnitType.Auto) }); } WpfUtilities.SetGridPosition(box, row, column); _itemsSearchSettings.Link(box, attribute); searchGrid.Children.Add(box); }
private void _addSearch(Grid searchGrid, string display, FrameworkElement element, int row, int column, bool isItalic = false) { Label label = new Label(); label.Content = display; if (isItalic) { label.FontStyle = FontStyles.Italic; } while (searchGrid.RowDefinitions.Count <= row) { searchGrid.RowDefinitions.Add(new RowDefinition { Height = new GridLength(-1, GridUnitType.Auto) }); } WpfUtilities.SetGridPosition(label, row, column); if (element != null) { WpfUtilities.SetGridPosition(element, row, column + 2); element.Margin = new Thickness(2); searchGrid.Children.Add(element); } searchGrid.Children.Add(label); }
public ClickSelectTextBoxEffect() { this.Loaded += delegate { this.BorderThickness = new System.Windows.Thickness(0); //this.Padding = new System.Windows.Thickness(0); if (this.Parent is Border) { WpfUtilities.AddFocus(this); } else { Panel parent = this.Parent as Panel; if (parent != null) { int oldPosition = parent.Children.IndexOf(this); parent.Children.Remove(this); Border border = new Border(); border.VerticalAlignment = this.VerticalAlignment; border.HorizontalAlignment = this.HorizontalAlignment; border.BorderThickness = new System.Windows.Thickness(1); border.Child = this; border.Margin = this.Margin; this.Margin = new System.Windows.Thickness(0); parent.Children.Insert(oldPosition, border); WpfUtilities.SetGridPosition(border, (int)this.GetValue(Grid.RowProperty), (int)this.GetValue(Grid.ColumnProperty)); WpfUtilities.AddFocus(this); } } }; }
public Grid AddGrid(int row, int col, int rowSpan, int colSpan) { Grid element = new Grid(); WpfUtilities.SetGridPosition(element, row, rowSpan, col, colSpan); _deployControls.Add(new Tuple <FrameworkElement, FrameworkElement>(element, null)); return(element); }
private CheckBox _addSearchAttributeSub(Grid searchGrid, string attribute, int row, int column) { CheckBox box = new CheckBox(); box.Margin = new Thickness(3); box.SetValue(TextBlock.ForegroundProperty, Application.Current.Resources["TextForeground"] as Brush); TextBlock block = new TextBlock { Text = attribute }; block.SetValue(TextBlock.ForegroundProperty, Application.Current.Resources["TextForeground"] as Brush); box.MouseEnter += delegate { block.Foreground = Application.Current.Resources["MouseOverTextBrush"] as Brush; block.Cursor = Cursors.Hand; block.TextDecorations = TextDecorations.Underline; }; box.MouseLeave += delegate { block.Foreground = Application.Current.Resources["TextForeground"] as Brush; block.Cursor = Cursors.Arrow; block.TextDecorations = null; }; box.Content = block; while (searchGrid.RowDefinitions.Count <= row) { searchGrid.RowDefinitions.Add(new RowDefinition { Height = new GridLength(-1, GridUnitType.Auto) }); } WpfUtilities.SetGridPosition(box, row, column); _itemsSearchSettings.Link(box, attribute); searchGrid.Children.Add(box); return(box); }
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 } })));
private void _loadAutocomplete() { Binder.Bind(_cbAcIdDn, () => ProjectConfiguration.AutocompleteIdDisplayName); Binder.Bind(_cbAcUnDn, () => ProjectConfiguration.AutocompleteUnDisplayName); Binder.Bind(_cbAcIdRn, () => ProjectConfiguration.AutocompleteIdResourceName); Binder.Bind(_cbAcUnRn, () => ProjectConfiguration.AutocompleteUnResourceName); Binder.Bind(_cbAcIdDesc, () => ProjectConfiguration.AutocompleteIdDescription); Binder.Bind(_cbAcUnDesc, () => ProjectConfiguration.AutocompleteUnDescription); Binder.Bind(_tbPropFormat, () => ProjectConfiguration.AutocompleteDescriptionFormat); Binder.Bind(_cbAcNumberOfSlot, () => ProjectConfiguration.AutocompleteNumberOfSlot); Binder.Bind(_cbAcEmptyFields, () => ProjectConfiguration.AutocompleteFillOnlyEmptyFields); Binder.Bind(_tbUnDesc, () => ProjectConfiguration.AutocompleteUnDescriptionFormat); Binder.Bind(_tbDescNotSet, () => ProjectConfiguration.AutocompleteDescNotSet); Binder.Bind(_cbWriteNeutralProperty, () => ProjectConfiguration.AutocompleteNeutralProperty); Binder.Bind(_cbAcViewId, () => ProjectConfiguration.AutocompleteViewId); int index = 0; List <TextBox> boxes = new List <TextBox>(); foreach (ParameterHolderKeys property in ParameterHolderKeys.Keys) { ParameterHolderKeys key = property; Label label = new Label { Padding = new Thickness(0), Margin = new Thickness(3), Content = property.Key }; TextBox box = new TextBox { Text = SdeAppConfiguration.ConfigAsker["Autocompletion - " + key.Key, key.Key], Margin = new Thickness(3) }; WpfUtilities.SetGridPosition(label, index, 1, 0, 1); WpfUtilities.SetGridPosition(box, index, 1, 2, 1); _gridDescProp.Children.Add(label); _gridDescProp.Children.Add(box); _gridDescProp.RowDefinitions.Add(new RowDefinition { Height = new GridLength(-1, GridUnitType.Auto) }); SdeAppConfiguration.Bind(box, v => SdeAppConfiguration.ConfigAsker["Autocompletion - " + key.Key] = box.Text, p => p); index++; } index = 0; foreach (string property in ParameterHolder.Properties) { TextBox box = new TextBox { Text = ProjectConfiguration.AutocompleteProperties[index], Margin = new Thickness(3) }; TextBlock block = new TextBlock { Text = property, Margin = new Thickness(3), VerticalAlignment = VerticalAlignment.Center }; WpfUtilities.SetGridPosition(block, index / 2 + 4, 2 * (index % 2)); WpfUtilities.SetGridPosition(box, index / 2 + 4, 2 * (index % 2) + 1); boxes.Add(box); _gridDescription.Children.Add(box); _gridDescription.Children.Add(block); SdeAppConfiguration.Bind(box, v => ProjectConfiguration.AutocompleteProperties = v, q => boxes.Select(p => p.Text).ToList()); index++; } DisplayablePropertyHelper.FindAll <CheckBox>(_gridAutocomplete).ForEach(WpfUtils.AddMouseInOutEffectsBox); }
private void _loadShortcuts() { int row = 0; foreach (var keyPair in ApplicationShortcut.KeyBindings2) { string actionName = keyPair.Key; if (actionName == SdeStrings.AutoGenerated) { continue; } var binding = keyPair.Value; Label l = new Label { Content = actionName }; WpfUtilities.SetGridPosition(l, row, 0); _gridShortcuts.Children.Add(l); Border b = new Border(); b.Margin = new Thickness(3); b.BorderThickness = new Thickness(1); b.BorderBrush = WpfUtilities.LostFocusBrush; Grid grid = new Grid(); grid.ColumnDefinitions.Add(new ColumnDefinition()); grid.ColumnDefinitions.Add(new ColumnDefinition { Width = new GridLength(-1, GridUnitType.Auto) }); TextBox tb = new TextBox { Text = binding.KeyGesture.DisplayString }; tb.BorderThickness = new Thickness(0); tb.Padding = new Thickness(0); tb.IsReadOnly = true; b.Child = tb; grid.Children.Add(b); FancyButton button = new FancyButton(); button.ImagePath = "reset.png"; button.Width = 20; button.Height = 20; button.Visibility = Visibility.Collapsed; button.Margin = new Thickness(0, 0, 3, 0); button.Click += delegate { button.Visibility = Visibility.Collapsed; binding.Reset(); tb.Text = binding.KeyGesture.DisplayString; SdeAppConfiguration.Remapper.Remove(actionName); b.BorderBrush = WpfUtilities.LostFocusBrush; }; if (binding.CanReset) { button.Visibility = Visibility.Visible; } WpfUtilities.SetGridPosition(button, 0, 1); grid.Children.Add(button); WpfUtilities.SetGridPosition(grid, row, 1); _gridShortcuts.Children.Add(grid); _gridShortcuts.RowDefinitions.Add(new RowDefinition { Height = new GridLength(-1, GridUnitType.Auto) }); tb.GotFocus += delegate { b.BorderThickness = new Thickness(2); if (b.BorderBrush == Brushes.Red) { return; } b.BorderBrush = WpfUtilities.GotFocusBrush; }; tb.LostFocus += delegate { b.BorderThickness = new Thickness(1); if (b.BorderBrush == Brushes.Red) { return; } b.BorderBrush = WpfUtilities.LostFocusBrush; }; tb.PreviewKeyDown += delegate(object sender, KeyEventArgs e) { if (e.Key == Key.Escape || e.Key == Key.Tab) { return; } bool valid; tb.Text = _make(e.Key, Keyboard.Modifiers, out valid); try { if (!valid) { throw new Exception(); } var b2 = binding; var shortcut = ApplicationShortcut.Make(null, e.Key, Keyboard.Modifiers); while (b2 != null) { b2.Set(shortcut); b2 = b2.Next; } if (binding.CanReset) { button.Visibility = Visibility.Visible; } else { button.Visibility = Visibility.Collapsed; } SdeAppConfiguration.Remapper[actionName] = tb.Text; ApplicationShortcut.OverrideBindings(SdeAppConfiguration.Remapper); b.BorderThickness = new Thickness(2); b.BorderBrush = WpfUtilities.GotFocusBrush; } catch { b.BorderThickness = new Thickness(2); b.BorderBrush = Brushes.Red; button.Visibility = Visibility.Visible; } e.Handled = true; }; row++; } }
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); } }); }
private void _addSearchAttribute(Grid searchGrid, DbAttribute attribute, int row, int column) { if (attribute.DataType.BaseType == typeof(Enum)) { Grid grid = new Grid(); Label display = new Label(); display.Margin = new Thickness(3); display.Padding = new Thickness(0); display.Content = attribute.DisplayName; display.VerticalAlignment = VerticalAlignment.Center; ComboBox box = new ComboBox(); box.Margin = new Thickness(3); List <string> items = Enum.GetValues(attribute.DataType).Cast <Enum>().Select(Description.GetDescription).ToList(); items.Insert(0, "All"); box.ItemsSource = items; box.SelectedIndex = 0; box.SetValue(Grid.ColumnProperty, 1); List <int> values = Enum.GetValues(attribute.DataType).Cast <int>().ToList(); _itemsSearchSettings[attribute] = false; box.PreviewMouseDown += delegate(object sender, MouseButtonEventArgs args) { ComboBoxItem item = WpfUtilities.FindParentControl <ComboBoxItem>((Mouse.DirectlyOver as DependencyObject)); if (item != null) { StackPanel panel = WpfUtilities.FindParentControl <StackPanel>(item); if (panel != null) { if (panel.Children.Count == 1) { return; } } item.IsSelected = true; args.Handled = true; } }; box.SelectionChanged += delegate { if (box.SelectedIndex > 0) { attribute.AttachedAttribute = values[box.SelectedIndex - 1].ToString(CultureInfo.InvariantCulture); } _itemsSearchSettings[attribute] = box.SelectedIndex != 0; }; WpfUtilities.SetGridPosition(grid, row, column); grid.ColumnDefinitions.Add(new ColumnDefinition { Width = new GridLength(-1, GridUnitType.Auto) }); grid.ColumnDefinitions.Add(new ColumnDefinition()); grid.Children.Add(display); grid.Children.Add(box); searchGrid.Children.Add(grid); } else { _addSearchAttributeSub(searchGrid, attribute.DisplayName, row, column); } }
public GenericFlagDialog(DbAttribute attribute, string text, Type enumType, FlagTypeData flagTypeData, string description) : base(description, "cde.ico", SizeToContent.WidthAndHeight, ResizeMode.CanResize) { InitializeComponent(); _value = text.ToLong(); if (flagTypeData != null) { List <long> valuesEnum = flagTypeData.Values.Where(p => (p.DataFlag & FlagDataProperty.Hide) == 0).Select(p => p.Value).ToList(); var values = flagTypeData.Values.Where(p => (p.DataFlag & FlagDataProperty.Hide) == 0).ToList(); GridIndexProvider provider = _findGrid(values); var toolTips = new string[values.Count]; for (int i = 0; i < values.Count; i++) { toolTips[i] = _getTooltip(values[i].Description); } AbstractProvider iProvider = new DefaultIndexProvider(0, values.Count); ToolTipsBuilder.Initialize(toolTips, this); int row; int col; for (int i = 0; i < values.Count; i++) { provider.Next(out row, out col); int index = (int)iProvider.Next(); CheckBox box = new CheckBox { Content = values[index].Name, Margin = new Thickness(3, 6, 3, 6), VerticalAlignment = VerticalAlignment.Center }; var menu = new ContextMenu(); MenuItem item = new MenuItem(); item.Header = "Restrict search to [" + values[index].Name + "]"; box.ContextMenu = menu; menu.Items.Add(item); item.Click += delegate { var selected = SdeEditor.Instance.Tabs.FirstOrDefault(p => p.IsSelected); if (selected != null) { selected._dbSearchPanel._searchTextBox.Text = "([" + attribute.AttributeName + "] & " + "Flags." + values[index].Name + ") != 0"; } }; box.Tag = valuesEnum[index]; WpfUtils.AddMouseInOutEffectsBox(box); _boxes.Add(box); _upperGrid.Children.Add(box); WpfUtilities.SetGridPosition(box, row, 2 * col); } _boxes.ForEach(_addEvents); } else { if (enumType.BaseType != typeof(Enum)) { throw new Exception("Invalid argument type, excepted an enum."); } if (enumType == typeof(MobModeType)) { if (DbPathLocator.GetServerType() == ServerType.RAthena && !ProjectConfiguration.UseOldRAthenaMode) { enumType = typeof(MobModeTypeNew); } } List <long> valuesEnum = Enum.GetValues(enumType).Cast <int>().Select(p => (long)p).ToList(); var values = Enum.GetValues(enumType).Cast <Enum>().ToList(); string[] commands = Description.GetAnyDescription(enumType).Split('#'); if (commands.Any(p => p.StartsWith("max_col_width:"))) { _maxColWidth = Int32.Parse(commands.First(p => p.StartsWith("max_col_width")).Split(':')[1]); } GridIndexProvider provider = _findGrid(values); var toolTips = new string[values.Count]; if (!commands.Contains("disable_tooltips")) { for (int i = 0; i < values.Count; i++) { toolTips[i] = _getTooltip(Description.GetDescription(values[i])); } } AbstractProvider iProvider = new DefaultIndexProvider(0, values.Count); if (commands.Any(p => p.StartsWith("order:"))) { List <int> order = commands.First(p => p.StartsWith("order:")).Split(':')[1].Split(',').Select(Int32.Parse).ToList(); for (int i = 0; i < values.Count; i++) { if (!order.Contains(i)) { order.Add(i); } } iProvider = new SpecifiedIndexProvider(order); } ToolTipsBuilder.Initialize(toolTips, this); int row; int col; ServerType currentType = DbPathLocator.GetServerType(); for (int i = 0; i < values.Count; i++) { provider.Next(out row, out col); int index = (int)iProvider.Next(); CheckBox box = new CheckBox { Content = _getDisplay(Description.GetDescription(values[index])), Margin = new Thickness(3, 6, 3, 6), VerticalAlignment = VerticalAlignment.Center }; ServerType type = _getEmuRestrition(Description.GetDescription(values[index])); if ((type & currentType) != currentType) { box.IsEnabled = false; } var menu = new ContextMenu(); MenuItem item = new MenuItem(); item.Header = "Restrict search to [" + _getDisplay(Description.GetDescription(values[index])) + "]"; box.ContextMenu = menu; menu.Items.Add(item); item.Click += delegate { var selected = SdeEditor.Instance.Tabs.FirstOrDefault(p => p.IsSelected); if (selected != null) { selected._dbSearchPanel._searchTextBox.Text = "([" + attribute.AttributeName + "] & " + valuesEnum[index] + ") != 0"; } }; box.Tag = valuesEnum[index]; WpfUtils.AddMouseInOutEffectsBox(box); _boxes.Add(box); _upperGrid.Children.Add(box); WpfUtilities.SetGridPosition(box, row, 2 * col); } _boxes.ForEach(_addEvents); } }
public GenericFlagDialog(string text, Type enumType) : base(_getDisplay(Description.GetAnyDescription(enumType)), "cde.ico", SizeToContent.WidthAndHeight, ResizeMode.CanResize) { InitializeComponent(); _value = text.ToInt(); if (enumType.BaseType != typeof(Enum)) { throw new Exception("Invalid argument type, excepted an enum."); } if (enumType == typeof(MobModeType)) { if (DbPathLocator.GetServerType() == ServerType.RAthena && !ProjectConfiguration.UseOldRAthenaMode) { enumType = typeof(MobModeTypeNew); } } var values = Enum.GetValues(enumType).Cast <Enum>().ToList(); var valuesEnum = Enum.GetValues(enumType).Cast <int>().ToList(); string[] commands = Description.GetAnyDescription(enumType).Split('#'); if (commands.Any(p => p.StartsWith("max_col_width:"))) { _maxColWidth = Int32.Parse(commands.First(p => p.StartsWith("max_col_width")).Split(':')[1]); } GridIndexProvider provider = _findGrid(values); var toolTips = new string[values.Count]; if (!commands.Contains("disable_tooltips")) { for (int i = 0; i < values.Count; i++) { toolTips[i] = _getTooltip(Description.GetDescription(values[i])); } } AbstractProvider iProvider = new DefaultIndexProvider(0, values.Count); if (commands.Any(p => p.StartsWith("order:"))) { List <int> order = commands.First(p => p.StartsWith("order:")).Split(':')[1].Split(',').Select(Int32.Parse).ToList(); for (int i = 0; i < values.Count; i++) { if (!order.Contains(i)) { order.Add(i); } } iProvider = new SpecifiedIndexProvider(order); } ToolTipsBuilder.Initialize(toolTips, this); int row; int col; ServerType currentType = DbPathLocator.GetServerType(); for (int i = 0; i < values.Count; i++) { provider.Next(out row, out col); int index = (int)iProvider.Next(); CheckBox box = new CheckBox { Content = _getDisplay(Description.GetDescription(values[index])), Margin = new Thickness(3, 6, 3, 6), VerticalAlignment = VerticalAlignment.Center }; ServerType type = _getEmuRestrition(Description.GetDescription(values[index])); if ((type & currentType) != currentType) { box.IsEnabled = false; } box.Tag = valuesEnum[index]; WpfUtils.AddMouseInOutEffectsBox(box); _boxes.Add(box); _upperGrid.Children.Add(box); WpfUtilities.SetGridPosition(box, row, 2 * col); } _boxes.ForEach(_addEvents); }
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 } })));
public void Init(GDbTabWrapper <TKey, TValue> tab, DisplayableProperty <TKey, TValue> dp) { _tab = tab; Grid grid = new Grid(); WpfUtilities.SetGridPosition(grid, _row, _rSpan, _col, _cSpan); 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); _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); WpfUtils.DisableContextMenuIfEmpty(_lv); Extensions.GenerateListViewTemplate(_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[] { "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 drop chance", Icon = new Image { Source = (BitmapSource)ApplicationManager.PreloadResourceImage("properties.png") } }; MenuItem miRemoveDrop = new MenuItem { Header = "Remove", Icon = new Image { Source = (BitmapSource)ApplicationManager.PreloadResourceImage("delete.png") } }; _lv.ContextMenu.Items.Add(miSelect); _lv.ContextMenu.Items.Add(miEditDrop); _lv.ContextMenu.Items.Add(miRemoveDrop); miSelect.Click += new RoutedEventHandler(_miSelect_Click); miEditDrop.Click += new RoutedEventHandler(_miEditDrop_Click); miRemoveDrop.Click += new RoutedEventHandler(_miRemoveDrop_Click); dp.AddUpdateAction(new Action <TValue>(_update)); grid.Children.Add(label); grid.Children.Add(_lv); ((GenericDatabase)tab.Database).Commands.CommandIndexChanged += _commands_CommandIndexChanged; tab.PropertiesGrid.Children.Add(grid); dp.AddResetField(_lv); }