Exemple #1
0
        private void _initMenus()
        {
            foreach (GItemCommand <TKey, TValue> commandCopy in Settings.AddedCommands)
            {
                GItemCommand <TKey, TValue> command = commandCopy;
                MenuItem item = new MenuItem();
                item.Header = command.DisplayName;
                item.Click += (e, a) => _menuItem_Click(command);

                Image image = new Image();
                image.Source = (BitmapSource)ApplicationManager.PreloadResourceImage(command.ImagePath);
                item.Icon    = image;

                if (command.Shortcut != null)
                {
                    ApplicationShortcut.Link(command.Shortcut, () => _menuItem_Click(command), List);
                    item.InputGestureText = command.Shortcut.DisplayString;
                }

                _listView.ContextMenu.Items.Insert(command.InsertIndex, item);
            }

            _miDelete.Click          += _menuItemDeleteItem_Click;
            _miCopyTo.Click          += _menuItemCopyItemTo_Click;
            _miShowSelected.Click    += _menuItemKeepSelectedItemsOnly_Click;
            _buttonOpenSubMenu.Click += _buttonOpenSubMenu_Click;
            _miChangeId.Click        += _miChangeId_Click;
            _miSelectInNotepad.Click += _miSelectInNotepad_Click;
            _miCut.Click             += _miCut_Click;

            if (!Settings.CanChangeId)
            {
                _miChangeId.Visibility = Visibility.Collapsed;
            }
        }
 private UIApplicationShortcutItem createIosShortcut(ApplicationShortcut shortcut)
 => new UIApplicationShortcutItem(
     shortcut.Type.ToString(),
     shortcut.Title,
     shortcut.Subtitle,
     icons[shortcut.Type],
     userInfoFor(shortcut)
     );
Exemple #3
0
 private void _fbResetShortcuts_Click(object sender, RoutedEventArgs e)
 {
     SdeAppConfiguration.Remapper.Clear();
     _gridShortcuts.Children.Clear();
     ApplicationShortcut.ResetBindings();
     ApplicationShortcut.OverrideBindings(SdeAppConfiguration.Remapper);
     _loadShortcuts();
 }
Exemple #4
0
        public MapcacheDialog(string text)
            : base("Mapcache", "cache.png", SizeToContent.Manual, ResizeMode.CanResize)
        {
            InitializeComponent();

            ShowInTaskbar         = true;
            WindowStartupLocation = WindowStartupLocation.CenterOwner;
            Owner = WpfUtilities.TopWindow;

            _cache = new Mapcache();
            _cache.Commands.ModifiedStateChanged += _commands_ModifiedStateChanged;
            _asyncOperation = new AsyncOperation(_progressBar);

            ListViewDataTemplateHelper.GenerateListViewTemplateNew(_listView, new ListViewDataTemplateHelper.GeneralColumnInfo[] {
                new ListViewDataTemplateHelper.GeneralColumnInfo {
                    Header = "Name", DisplayExpression = "MapName", SearchGetAccessor = "MapName", ToolTipBinding = "MapName", TextWrapping = TextWrapping.Wrap, TextAlignment = TextAlignment.Center, FixedWidth = 140
                },
                new ListViewDataTemplateHelper.GeneralColumnInfo {
                    Header = "Width", DisplayExpression = "Xs", SearchGetAccessor = "Xs", ToolTipBinding = "Xs", TextAlignment = TextAlignment.Center, FixedWidth = 80
                },
                new ListViewDataTemplateHelper.GeneralColumnInfo {
                    Header = "Height", DisplayExpression = "Ys", SearchGetAccessor = "Ys", ToolTipBinding = "Ys", TextAlignment = TextAlignment.Center, FixedWidth = 80
                },
                new ListViewDataTemplateHelper.GeneralColumnInfo {
                    Header = "Size", DisplayExpression = "DisplaySize", SearchGetAccessor = "Len", ToolTipBinding = "DisplaySize", TextAlignment = TextAlignment.Center, FixedWidth = 150
                },
            }, new DefaultListViewComparer <MapInfo>(), new string[] { "Added", "{DynamicResource CellBrushAdded}" });

            _tmbUndo.SetUndo(_cache.Commands);
            _tmbRedo.SetRedo(_cache.Commands);
            _commands_ModifiedStateChanged(null, null);
            _listView.ItemsSource = _cache.ViewMaps;

            ApplicationShortcut.Link(ApplicationShortcut.Save, () => _menuItemSave_Click(null, null), this);
            ApplicationShortcut.Link(ApplicationShortcut.Undo, () => _cache.Commands.Undo(), this);
            ApplicationShortcut.Link(ApplicationShortcut.Redo, () => _cache.Commands.Redo(), this);
            ApplicationShortcut.Link(ApplicationShortcut.New, () => _menuItemNew_Click(null, null), this);
            ApplicationShortcut.Link(ApplicationShortcut.Open, () => _menuItemOpenFrom_Click(null, null), this);
            ApplicationShortcut.Link(ApplicationShortcut.Delete, () => _miDelete_Click(null, null), this);

            _recentFilesManager              = new WpfRecentFiles(Configuration.ConfigAsker, 6, _menuItemRecentFiles, "Mapcache");
            _recentFilesManager.FileClicked += _recentFilesManager_FileClicked;

            if (text != null)
            {
                _recentFilesManager.AddRecentFile(text);
                _load(text);
            }
            else
            {
                // Open the latest file
                if (_recentFilesManager.Files.Count > 0 && File.Exists(_recentFilesManager.Files[0]))
                {
                    _load(_recentFilesManager.Files[0]);
                }
            }
        }
Exemple #5
0
 private void _miCut_Click(object sender, RoutedEventArgs e)
 {
     try {
         ApplicationShortcut.Execute(ApplicationShortcut.Copy.KeyGesture, this);
         _deleteItems();
     }
     catch (Exception err) {
         ErrorHandler.HandleException(err);
     }
 }
Exemple #6
0
        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 MultiGrfExplorer(MultiGrfReader metaGrf, string explorerPath, string filter, string selected)
            : base("Meta GRF explorer", "cde.ico", SizeToContent.Manual, ResizeMode.CanResize)
        {
            InitializeComponent();

            ShowInTaskbar = true;
            _explorerPath = explorerPath.ToLower();
            _metaGrf      = metaGrf;
            //metaGrf.Lock();

            if (filter != "")
            {
                _entries.AddRange(metaGrf.FilesInDirectory(_explorerPath).Select(metaGrf.GetEntry).Where(p => p.RelativePath.IndexOf(filter, StringComparison.OrdinalIgnoreCase) > -1));
            }
            else
            {
                _entries.AddRange(metaGrf.FilesInDirectory(_explorerPath).Select(metaGrf.GetEntry));
            }

            _entriesAll.AddRange(_entries);

            foreach (FileEntry entry in _entries)
            {
                entry.DataImage = entry.DisplayRelativePath;
            }

            _loadEncoding();

            ListViewDataTemplateHelper.GenerateListViewTemplateNew(_items, new ListViewDataTemplateHelper.GeneralColumnInfo[] {
                new ListViewDataTemplateHelper.RangeColumnInfo {
                    Header = "File name", DisplayExpression = "DataImage", ToolTipBinding = "RelativePath", IsFill = true, MinWidth = 60, TextWrapping = TextWrapping.Wrap
                },
                new ListViewDataTemplateHelper.GeneralColumnInfo {
                    Header = "Type", DisplayExpression = "FileType", FixedWidth = 40, TextAlignment = TextAlignment.Right, ToolTipBinding = "FileType"
                },
                new ListViewDataTemplateHelper.GeneralColumnInfo {
                    Header = "Size", DisplayExpression = "DisplaySize", FixedWidth = 60, TextAlignment = TextAlignment.Right, ToolTipBinding = "DisplaySize"
                },
            }, new MetaGrfSorter(), new string[] { });

            _items.MouseDoubleClick += new MouseButtonEventHandler(_items_MouseDoubleClick);

            _items.ItemsSource = _entries;
            VirtualFileDataObject.SetDraggable(_imagePreview, _wrapper);

            ApplicationShortcut.Link(ApplicationShortcut.Copy, _copyItems, _items);
            ApplicationShortcut.Link(ApplicationShortcut.Confirm, () => _buttonSelect_Click(null, null), _items);

            this.Loaded += delegate {
                _items.SelectedItem = _entries.FirstOrDefault(p => String.CompareOrdinal(p.DisplayRelativePath, selected.ToDisplayEncoding(true) + ".bmp") == 0);
                _items.ScrollToCenterOfView(_items.SelectedItem);
            };

            this.Owner = WpfUtilities.TopWindow;
        }
Exemple #8
0
        private ShortcutInfo androidShortcut(ApplicationShortcut shortcut)
        {
            var droidShortcut =
                new ShortcutInfo.Builder(context, shortcut.Title)
                .SetLongLabel($"{shortcut.Title} {shortcut.Subtitle}")
                .SetShortLabel(shortcut.Title)
                .SetIcon(getIcon(shortcut.Type))
                .SetIntent(new Intent(Intent.ActionView).SetData(Uri.Parse(shortcut.Url)))
                .Build();

            return(droidShortcut);
        }
Exemple #9
0
        public GDbTab()
        {
            InitializeComponent();

            _miDelete.InputGestureText          = ApplicationShortcut.FindDislayName(ApplicationShortcut.Delete);
            _miChangeId.InputGestureText        = ApplicationShortcut.FindDislayName(ApplicationShortcut.Change);
            _miCopyTo.InputGestureText          = ApplicationShortcut.FindDislayName(ApplicationShortcut.CopyTo);
            _miCut.InputGestureText             = ApplicationShortcut.FindDislayName(ApplicationShortcut.Cut);
            _miShowSelected.InputGestureText    = ApplicationShortcut.FindDislayName(ApplicationShortcut.Restrict);
            _miSelectInNotepad.InputGestureText = ApplicationShortcut.FindDislayName(ApplicationShortcut.FromString("Ctrl-W", "Open in Notepad++"));
            //_miChangeId.InputGestureText = ApplicationShortcut.FindDislayName(ApplicationShortcut.);
        }
 private void _textEditor_KeyDown(object sender, KeyEventArgs e)
 {
     if (ApplicationShortcut.Is(ApplicationShortcut.MoveLineUp))
     {
         _move(true);
         e.Handled = true;
     }
     else if (ApplicationShortcut.Is(ApplicationShortcut.MoveLineDown))
     {
         _move(false);
         e.Handled = true;
     }
 }
Exemple #11
0
 public void Init(DbSearchPanel panel, ListView view, Func <List <TValue> > getItemsFunction)
 {
     // The initialization is delayed, it will start when loading the tab
     _searchDrop       = panel._gridSearchContent;
     _items            = view;
     _getItemsFunction = getItemsFunction;
     _tbSearchItems    = panel._searchTextBox;
     panel._buttonResetSearch.Click += (sender, args) => Reset();
     ApplicationShortcut.Link(ApplicationShortcut.Search, () => {
         panel._searchTextBox.SelectAll();
         Keyboard.Focus(panel._searchTextBox);
     }, view);
 }
Exemple #12
0
        private void _initMenus()
        {
            foreach (GItemCommand <TKey, TValue> commandCopy in Settings.AddedCommands)
            {
                if (commandCopy.Visibility != Visibility.Visible)
                {
                    continue;
                }

                GItemCommand <TKey, TValue> command = commandCopy;
                MenuItem item = new MenuItem();
                item.Header = command.DisplayName;
                item.Click += (e, a) => _menuItem_Click(command);

                Image image = new Image();
                image.Source = ApplicationManager.PreloadResourceImage(command.ImagePath);
                item.Icon    = image;

                if (command.Shortcut != null)
                {
                    ApplicationShortcut.Link(command.Shortcut, () => _menuItem_Click(command), this);
                    item.InputGestureText = ApplicationShortcut.FindDislayName(command.Shortcut);
                }

                _listView.ContextMenu.Items.Insert(command.InsertIndex, item);
            }

            _miDelete.Click          += _menuItemDeleteItem_Click;
            _miCopyTo.Click          += _menuItemCopyItemTo_Click;
            _miShowSelected.Click    += _menuItemKeepSelectedItemsOnly_Click;
            _miChangeId.Click        += _miChangeId_Click;
            _miSelectInNotepad.Click += _miSelectInNotepad_Click;
            _miCut.Click             += _miCut_Click;

            if (!Settings.CanChangeId)
            {
                _miChangeId.Visibility = Visibility.Collapsed;
            }

            var shortcut = ApplicationShortcut.FromString("Ctrl-W", "Open in Notepad++");

            ApplicationShortcut.Link(shortcut, () => _miSelectInNotepad_Click(null, null), this);
        }
        private void _ironPythonDialog_PreviewKeyDown(object sender, KeyEventArgs e)
        {
            try {
                if (
                    ApplicationShortcut.Is(ApplicationShortcut.FromString("Ctrl-Enter", null)))
                {
                    e.Handled = true;
                    _buttonOk_Click(null, null);
                }

                if (e.Key == Key.Escape)
                {
                    if (_completionWindow != null)
                    {
                        _completionWindow.Close();
                    }
                }
            }
            catch { }
        }
 private NSDictionary <NSString, NSObject> userInfoFor(ApplicationShortcut shortcut)
 => new NSDictionary <NSString, NSObject>(new NSString(nameof(ApplicationShortcut.Url)), new NSString(shortcut.Url));
        public ShopSimulatorDialog()
            : base("Shop simulator", "editor.png", SizeToContent.Height, ResizeMode.NoResize)
        {
            InitializeComponent();
            WindowStartupLocation = WindowStartupLocation.CenterOwner;
            Owner = WpfUtilities.TopWindow;

            _shopItems           = new RangeObservableCollection <ShopItem>();
            _lvItems.ItemsSource = _shopItems;

            Binder.Bind(_cbColorZeny, () => SdeAppConfiguration.UseZenyColors, () => _shopItems.ToList().ForEach(p => p.Update()));
            Binder.Bind(_cbDiscount, () => SdeAppConfiguration.UseDiscount, () => _shopItems.ToList().ForEach(p => p.Update()));
            Binder.Bind(_cbUseViewId, () => SdeAppConfiguration.AlwaysUseViewId, () => {
                if (!_enableEvents || _primaryShop == null)
                {
                    return;
                }

                try {
                    _enableEvents = false;

                    string viewId = _primaryShop.NpcViewId;
                    int ival;

                    if (SdeAppConfiguration.AlwaysUseViewId)
                    {
                        if (!Int32.TryParse(viewId, out ival))
                        {
                            var constDb = SdeEditor.Instance.ProjectDatabase.GetDb <string>(ServerDbs.Constants);
                            var tuple   = constDb.Table.TryGetTuple(viewId);

                            if (tuple != null)
                            {
                                ival = tuple.GetValue <int>(ServerConstantsAttributes.Value);
                            }
                            else
                            {
                                ival = -1;
                            }

                            _primaryShop.NpcViewId = ival.ToString(CultureInfo.InvariantCulture);
                            _tbNpcViewId.Text      = _primaryShop.NpcViewId;
                            _primaryShop.Reload();
                        }
                    }
                    else
                    {
                        if (Int32.TryParse(viewId, out ival))
                        {
                            viewId = _viewIdToString(ival);

                            if (!String.IsNullOrEmpty(viewId))
                            {
                                if (viewId.IsExtension(".act", ".spr"))
                                {
                                    _primaryShop.NpcViewId = Path.GetFileNameWithoutExtension(viewId.ToUpper());
                                }
                                else
                                {
                                    _primaryShop.NpcViewId = Path.GetFileName(viewId);
                                }

                                _tbNpcViewId.Text = _primaryShop.NpcViewId;
                                _primaryShop.Reload();
                            }
                        }
                    }
                }
                catch (Exception err) {
                    ErrorHandler.HandleException(err);
                }
                finally {
                    _enableEvents = true;
                }
            });

            _shop.TextChanged += new EventHandler(_shop_TextChanged);

            AvalonLoader.Load(_shop);
            WpfUtils.AddMouseInOutEffectsBox(_cbColorZeny, _cbDiscount, _cbUseViewId);

            _helper = new PreviewHelper(new RangeListView(), SdeEditor.Instance.ProjectDatabase.GetDb <int>(ServerDbs.Items), null, null, null, null);

            FrameViewerSettings settings = new FrameViewerSettings();

            settings.Act            = () => _act;
            settings.SelectedAction = () => _actIndexSelected.SelectedAction;
            settings.SelectedFrame  = () => _actIndexSelected.SelectedFrame;
            _frameViewer.InitComponent(settings);

            _actIndexSelected.Init(_frameViewer);
            _actIndexSelected.Load(_act);
            _actIndexSelected.FrameChanged  += (s, p) => _frameViewer.Update();
            _actIndexSelected.ActionChanged += (s, p) => {
                _frameViewer.Update();

                if (!_enableEvents || _primaryShop == null)
                {
                    return;
                }

                try {
                    _enableEvents = false;

                    var elements = _tbNpcPosition.Text.Split(',');
                    var dir      = _convertAction(_actIndexSelected.SelectedAction);

                    if (elements.Length == 4)
                    {
                        elements[3] = dir.ToString(CultureInfo.InvariantCulture);
                        _primaryShop.ShopLocation = string.Join(",", elements);
                        _primaryShop.Reload();
                    }
                    else
                    {
                        _primaryShop.ShopLocation = "prontera,150,150," + dir.ToString(CultureInfo.InvariantCulture);
                        _primaryShop.Reload();
                    }

                    _tbNpcPosition.Text = _primaryShop.ShopLocation;
                }
                catch (Exception err) {
                    ErrorHandler.HandleException(err);
                }
                finally {
                    _enableEvents = true;
                }
            };

            _actIndexSelected.SpecialFrameChanged += (s, p) => _frameViewer.Update();

            _lvItems.MouseRightButtonUp += new MouseButtonEventHandler(_lvItems_MouseRightButtonUp);
            _lvItems.SelectionChanged   += new SelectionChangedEventHandler(_lvItems_SelectionChanged);

            _tbItemId.TextChanged          += new TextChangedEventHandler(_tbItemId_TextChanged);
            _tbPrice.TextChanged           += new TextChangedEventHandler(_tbPrice_TextChanged);
            _tbNpcViewId.TextChanged       += new TextChangedEventHandler(_tbNpcViewId_TextChanged);
            _tbNpcPosition.TextChanged     += new TextChangedEventHandler(_tbNpcPosition_TextChanged);
            _tbNpcDisplayName.TextChanged  += new TextChangedEventHandler(_tbNpcDisplayName_TextChanged);
            _tbNpcShopCurrency.TextChanged += new TextChangedEventHandler(_tbNpcShopCurrency_TextChanged);

            _comboBoxShopType.SelectionChanged += new SelectionChangedEventHandler(_comboBoxShopType_SelectionChanged);

            _buttonResetPrice.Click += delegate {
                _tbPrice.Text = "-1";
            };

            _buttonCurItemQuery.Click += delegate {
                try {
                    Table <int, ReadableTuple <int> > btable = SdeEditor.Instance.ProjectDatabase.GetMetaTable <int>(ServerDbs.Items);

                    SelectFromDialog select = new SelectFromDialog(btable, ServerDbs.Items, _tbNpcShopCurrency.Text);
                    select.Owner = WpfUtilities.TopWindow;

                    if (select.ShowDialog() == true)
                    {
                        _tbNpcShopCurrency.Text = select.Id;
                    }
                }
                catch (Exception err) {
                    ErrorHandler.HandleException(err);
                }
            };

            _buttonViewIdQuery.Click += delegate {
                try {
                    MultiGrfExplorer dialog = new MultiGrfExplorer(SdeEditor.Instance.ProjectDatabase.MetaGrf, "data\\sprite\\npc", "", _viewIdToString(FormatConverters.IntOrHexConverter(_primaryShop.NpcViewId ?? "")));

                    if (dialog.ShowDialog() == true)
                    {
                        var    path = dialog.SelectedPath.GetFullPath();
                        string result;

                        if (path.IsExtension(".act", ".spr"))
                        {
                            result = Path.GetFileNameWithoutExtension(path.ToUpper());
                        }
                        else
                        {
                            result = Path.GetFileName(path);
                        }

                        if (SdeAppConfiguration.AlwaysUseViewId)
                        {
                            var constDb = SdeEditor.Instance.ProjectDatabase.GetDb <string>(ServerDbs.Constants);
                            var tuple   = constDb.Table.TryGetTuple(result);
                            int ival;

                            if (tuple != null)
                            {
                                ival = tuple.GetValue <int>(ServerConstantsAttributes.Value);
                            }
                            else
                            {
                                _tbNpcViewId.Text = result;
                                return;
                            }

                            if (!_enableEvents || _primaryShop == null)
                            {
                                return;
                            }

                            try {
                                _enableEvents = false;

                                _primaryShop.NpcViewId = ival.ToString(CultureInfo.InvariantCulture);
                                _tbNpcViewId.Text      = _primaryShop.NpcViewId;
                                _updateViewShop();
                                _primaryShop.Reload();
                            }
                            catch (Exception err) {
                                ErrorHandler.HandleException(err);
                            }
                            finally {
                                _enableEvents = true;
                            }
                        }
                        else
                        {
                            _tbNpcViewId.Text = result;
                        }
                    }
                }
                catch (Exception err) {
                    ErrorHandler.HandleException(err);
                }
            };

            _buttonQueryItem.Click += delegate {
                try {
                    Table <int, ReadableTuple <int> > btable = SdeEditor.Instance.ProjectDatabase.GetMetaTable <int>(ServerDbs.Items);

                    SelectFromDialog select = new SelectFromDialog(btable, ServerDbs.Items, _tbItemId.Text);
                    select.Owner = WpfUtilities.TopWindow;

                    if (select.ShowDialog() == true)
                    {
                        _tbItemId.Text = select.Id;
                    }
                }
                catch (Exception err) {
                    ErrorHandler.HandleException(err);
                }
            };

            _gridColumnPrimary.Width = new GridLength(230 + SystemParameters.VerticalScrollBarWidth + 7);

            this.Loaded += delegate {
                this.MinHeight  = this.ActualHeight + 10;
                this.MinWidth   = this.ActualWidth;
                this.ResizeMode = ResizeMode.CanResize;
                SizeToContent   = SizeToContent.Manual;
            };

            ApplicationShortcut.Link(ApplicationShortcut.Delete, () => _buttonDelete_Click(null, null), _lvItems);
            ApplicationShortcut.Link(ApplicationShortcut.New, () => _buttonNew_Click(null, null), this);
            ApplicationShortcut.Link(ApplicationShortcut.FromString("Ctrl-Up", "MoveUp"), () => _buttonUp_Click(null, null), _lvItems);
            ApplicationShortcut.Link(ApplicationShortcut.FromString("Ctrl-Down", "MoveDown"), () => _buttonDown_Click(null, null), _lvItems);
            ApplicationShortcut.Link(ApplicationShortcut.Undo, () => _undo(), this);
            ApplicationShortcut.Link(ApplicationShortcut.Redo, () => _redo(), this);
            //_shop.Text = "alberta_in,182,97,0	shop	Tool Dealer#alb2	73,1750:-1,611:-1,501:-1,502:-1,503:-1,504:-1,506:-1,645:-1,656:-1,601:-1,602:-1,2243:-1";
        }
Exemple #16
0
        public static void RemoveUndoAndRedoEvents(FrameworkElement box, GDbTabWrapper <TKey, TValue> tab)
        {
            box.PreviewKeyDown += delegate(object sender, KeyEventArgs args) {
                if (ApplicationShortcut.Is(ApplicationShortcut.UndoGlobal))
                {
                    tab.Undo();
                    args.Handled = true;
                }

                if (ApplicationShortcut.Is(ApplicationShortcut.RedoGlobal))
                {
                    tab.Redo();
                    args.Handled = true;
                }

                if (ApplicationShortcut.Is(ApplicationShortcut.Undo))
                {
                    TextBox    tBox = box as TextBox;
                    TextEditor eBox = box as TextEditor;

                    if (tBox != null)
                    {
                        if (!tBox.CanRedo && !tBox.CanUndo)
                        {
                            tab.Undo();
                        }
                        else if (tBox.CanUndo)
                        {
                            tBox.Undo();
                        }
                    }
                    else if (eBox != null)
                    {
                        if (!eBox.CanRedo && !eBox.CanUndo)
                        {
                            tab.Undo();
                        }
                        else if (eBox.CanUndo)
                        {
                            eBox.Undo();
                        }
                    }
                    else
                    {
                        tab.Undo();
                    }

                    args.Handled = true;
                }

                if (ApplicationShortcut.Is(ApplicationShortcut.Redo))
                {
                    TextBox    tBox = box as TextBox;
                    TextEditor eBox = box as TextEditor;

                    if (tBox != null)
                    {
                        if (!tBox.CanRedo && !tBox.CanRedo)
                        {
                            tab.Redo();
                        }
                        else if (tBox.CanRedo)
                        {
                            tBox.Redo();
                        }
                    }
                    else if (eBox != null)
                    {
                        if (!eBox.CanRedo && !eBox.CanRedo)
                        {
                            tab.Redo();
                        }
                        else if (eBox.CanRedo)
                        {
                            eBox.Redo();
                        }
                    }
                    else
                    {
                        tab.Redo();
                    }

                    args.Handled = true;
                }
            };
        }
Exemple #17
0
        public void Initialize(GTabSettings <TKey, TValue> settings)
        {
            Settings = settings;
            _unclickableBorder.Init(_cbSubMenu);
            Database     = settings.ClientDatabase;
            DbComponent  = GenericDatabase.GetDb <TKey>(settings.DbData);
            Table        = Settings.Table;
            Header       = Settings.TabName;
            Style        = TryFindResource(settings.Style) as Style ?? Style;
            SearchEngine = settings.SearchEngine;
            SearchEngine.Init(_gridSearchContent, _searchTextBox, this);

            if (Settings.SearchEngine.SetupImageDataGetter != null)
            {
                Extensions.GenerateListViewTemplate(_listView, new ListViewDataTemplateHelper.GeneralColumnInfo[] {
                    new ListViewDataTemplateHelper.GeneralColumnInfo {
                        Header = Settings.AttId.DisplayName, DisplayExpression = "[" + Settings.AttId.Index + "]", SearchGetAccessor = Settings.AttId.AttributeName, FixedWidth = Settings.AttIdWidth, TextAlignment = TextAlignment.Right, ToolTipBinding = "[" + Settings.AttId.Index + "]"
                    },
                    new ListViewDataTemplateHelper.ImageColumnInfo {
                        Header = "", DisplayExpression = "DataImage", SearchGetAccessor = Settings.AttId.AttributeName, FixedWidth = 26, MaxHeight = 24
                    },
                    new ListViewDataTemplateHelper.RangeColumnInfo {
                        Header = Settings.AttDisplay.DisplayName, DisplayExpression = "[" + Settings.AttDisplay.Index + "]", SearchGetAccessor = Settings.AttDisplay.AttributeName, IsFill = true, ToolTipBinding = "[" + Settings.AttDisplay.Index + "]", MinWidth = 100, TextWrapping = TextWrapping.Wrap
                    }
                }, new DatabaseItemSorter(Settings.AttributeList), new string[] { "Deleted", "Red", "Modified", "Green", "Added", "Blue", "Normal", "Black" }, "generateStyle", "false");
            }
            else
            {
                Extensions.GenerateListViewTemplate(_listView, new ListViewDataTemplateHelper.GeneralColumnInfo[] {
                    new ListViewDataTemplateHelper.GeneralColumnInfo {
                        Header = Settings.AttId.DisplayName, DisplayExpression = "[" + Settings.AttId.Index + "]", SearchGetAccessor = Settings.AttId.AttributeName, FixedWidth = Settings.AttIdWidth, TextAlignment = TextAlignment.Right, ToolTipBinding = "[" + Settings.AttId.Index + "]"
                    },
                    new ListViewDataTemplateHelper.RangeColumnInfo {
                        Header = Settings.AttDisplay.DisplayName, DisplayExpression = "[" + Settings.AttDisplay.Index + "]", SearchGetAccessor = Settings.AttDisplay.AttributeName, IsFill = true, ToolTipBinding = "[" + Settings.AttDisplay.Index + "]", MinWidth = 100, TextWrapping = TextWrapping.Wrap
                    }
                }, new DatabaseItemSorter(Settings.AttributeList), new string[] { "Deleted", "Red", "Modified", "Green", "Added", "Blue", "Normal", "Black" }, "generateStyle", "false");
            }

#if SDE_DEBUG
            CLHelper.WA = CLHelper.CP(-10);
#endif
            if (!Settings.CanBeDelayed || Settings.AttributeList.Attributes.Any(p => p.IsSkippable))
            {
                _deployTabControls();
            }
#if SDE_DEBUG
            CLHelper.WA = ", deploy time : " + CLHelper.CS(-10) + CLHelper.CD(-10) + "ms";
#endif
            _initTableEvents();

            if (Settings.ContextMenu != null)
            {
                if (Header is Control)
                {
                    ((Control)Header).ContextMenu = Settings.ContextMenu;
                }
            }

            if (Settings.Loaded != null)
            {
                Settings.Loaded((GDbTabWrapper <TKey, ReadableTuple <TKey> >)(object) this, (GTabSettings <TKey, ReadableTuple <TKey> >)(object) Settings, ((GenericDatabase)Database).GetDb <TKey>(Settings.DbData));
            }

            if (Settings.DisplayablePropertyMaker.OnTabVisible != null)
            {
                Settings.DisplayablePropertyMaker.OnTabVisible(this);
            }

            Loaded += delegate {
                TabControl parent = WpfUtilities.FindParentControl <TabControl>(this);

                if (parent != null)
                {
                    parent.SelectionChanged += new SelectionChangedEventHandler(_parent_SelectionChanged);
                }
            };

            _listView.PreviewMouseDown += delegate {
                _listView.Focus();
            };

            ApplicationShortcut.Link(ApplicationShortcut.Paste, () => ImportFromFile("clipboard"), _listView);
            ApplicationShortcut.Link(ApplicationShortcut.Cut, () => _miCut_Click(null, null), _listView);
        }
Exemple #18
0
        public void Initialize(GTabSettings <TKey, TValue> settings)
        {
            Settings = settings;

            _displayGrid = new Grid();
            _displayGrid.SetValue(Grid.ColumnProperty, 2);
            _displayGrid.ColumnDefinitions.Add(new ColumnDefinition()
            {
                Width = new GridLength(1, GridUnitType.Auto)
            });
            _displayGrid.ColumnDefinitions.Add(new ColumnDefinition());
            _displayGrid.ColumnDefinitions.Add(new ColumnDefinition()
            {
                Width = new GridLength(10)
            });
            _displayGrid.ColumnDefinitions.Add(new ColumnDefinition()
            {
                Width = new GridLength(1, GridUnitType.Auto)
            });
            _displayGrid.ColumnDefinitions.Add(new ColumnDefinition());

            if (Settings.DbData == ServerDbs.ClientItems ||
                Settings.DbData == ServerDbs.Pet ||
                Settings.DbData == ServerDbs.Pet2 ||
                Settings.DbData == ServerDbs.Mobs ||
                Settings.DbData == ServerDbs.Mobs2 ||
                Settings.DbData == ServerDbs.MobGroups ||
                Settings.DbData == ServerDbs.Items ||
                Settings.DbData == ServerDbs.Items2)
            {
                _viewGrid.Children.Add(_displayGrid);
            }
            else
            {
                ScrollViewer sv = new ScrollViewer();
                sv.SetValue(Grid.ColumnProperty, 2);
                sv.SetValue(ScrollViewer.VerticalScrollBarVisibilityProperty, ScrollBarVisibility.Auto);
                sv.Focusable = false;
                sv.Content   = _displayGrid;
                _viewGrid.Children.Add(sv);
            }

            ProjectDatabase = settings.ClientDatabase;
            DbComponent     = ProjectDatabase.GetDb <TKey>(settings.DbData);
            Table           = Settings.Table;
            Header          = Settings.TabName;
            Style           = TryFindResource(settings.Style) as Style ?? Style;
            SearchEngine    = settings.SearchEngine;
            SearchEngine.Init(_dbSearchPanel, this);
            Table.TableUpdated += new Table <TKey, TValue> .UpdateTableEventHandler(_table_TableUpdated);

            if (Settings.SearchEngine.SetupImageDataGetter != null)
            {
                ListViewDataTemplateHelper.GenerateListViewTemplateNew(_listView, new ListViewDataTemplateHelper.GeneralColumnInfo[] {
                    new ListViewDataTemplateHelper.GeneralColumnInfo {
                        Header = Settings.AttId.DisplayName, DisplayExpression = "[" + Settings.AttId.Index + "]", SearchGetAccessor = Settings.AttId.AttributeName, FixedWidth = Settings.AttIdWidth, TextAlignment = TextAlignment.Right, ToolTipBinding = "[" + Settings.AttId.Index + "]"
                    },
                    new ListViewDataTemplateHelper.ImageColumnInfo {
                        Header = "", DisplayExpression = "DataImage", SearchGetAccessor = Settings.AttId.AttributeName, FixedWidth = 26, MaxHeight = 24
                    },
                    new ListViewDataTemplateHelper.RangeColumnInfo {
                        Header = Settings.AttDisplay.DisplayName, DisplayExpression = "[" + Settings.AttDisplay.Index + "]", SearchGetAccessor = Settings.AttDisplay.AttributeName, IsFill = true, ToolTipBinding = "[" + Settings.AttDisplay.Index + "]", MinWidth = 100, TextWrapping = TextWrapping.Wrap
                    }
                }, new DatabaseItemSorter(Settings.AttributeList), new string[] { "Deleted", "{DynamicResource CellBrushRemoved}", "Modified", "{DynamicResource CellBrushModified}", "Added", "{DynamicResource CellBrushAdded}", "Normal", "{DynamicResource TextForeground}" });
            }
            else
            {
                ListViewDataTemplateHelper.GenerateListViewTemplateNew(_listView, new ListViewDataTemplateHelper.GeneralColumnInfo[] {
                    new ListViewDataTemplateHelper.GeneralColumnInfo {
                        Header = Settings.AttId.DisplayName, DisplayExpression = "[" + Settings.AttId.Index + "]", SearchGetAccessor = Settings.AttId.AttributeName, FixedWidth = Settings.AttIdWidth, TextAlignment = TextAlignment.Right, ToolTipBinding = "[" + Settings.AttId.Index + "]"
                    },
                    new ListViewDataTemplateHelper.RangeColumnInfo {
                        Header = Settings.AttDisplay.DisplayName, DisplayExpression = "[" + Settings.AttDisplay.Index + "]", SearchGetAccessor = Settings.AttDisplay.AttributeName, IsFill = true, ToolTipBinding = "[" + Settings.AttDisplay.Index + "]", MinWidth = 100, TextWrapping = TextWrapping.Wrap
                    }
                }, new DatabaseItemSorter(Settings.AttributeList), new string[] { "Deleted", "{DynamicResource CellBrushRemoved}", "Modified", "{DynamicResource CellBrushModified}", "Added", "{DynamicResource CellBrushAdded}", "Normal", "{DynamicResource TextForeground}" });
            }

            if (!Settings.CanBeDelayed || Settings.AttributeList.Attributes.Any(p => p.IsSkippable))
            {
                _deployTabControls();
            }

            _initTableEvents();

            if (Settings.ContextMenu != null)
            {
                if (Header is Control)
                {
                    ((Control)Header).ContextMenu = Settings.ContextMenu;
                }
            }

            if (Settings.Loaded != null)
            {
                Settings.Loaded((GDbTabWrapper <TKey, ReadableTuple <TKey> >)(object) this, (GTabSettings <TKey, ReadableTuple <TKey> >)(object) Settings, ProjectDatabase.GetDb <TKey>(Settings.DbData));
            }

            if (Settings.DisplayablePropertyMaker.OnTabVisible != null)
            {
                Settings.DisplayablePropertyMaker.OnTabVisible(this);
            }

            Loaded += delegate {
                TabControl parent = WpfUtilities.FindParentControl <TabControl>(this);

                if (parent != null)
                {
                    parent.SelectionChanged += new SelectionChangedEventHandler(_parent_SelectionChanged);
                }
            };

            _listView.PreviewMouseDown += delegate { _listView.Focus(); };

            _listView.Loaded += delegate {
                try {
                    if (IsVisible)
                    {
                        Keyboard.Focus(_listView);
                    }
                }
                catch {
                }
            };

            ApplicationShortcut.Link(ApplicationShortcut.Paste, () => ImportFromFile("clipboard"), _listView);
            ApplicationShortcut.Link(ApplicationShortcut.AdvancedPaste, () => ImportFromFile("clipboard", true), this);
            ApplicationShortcut.Link(ApplicationShortcut.AdvancedPaste2, () => ImportFromFile("clipboard", true), this);
            ApplicationShortcut.Link(ApplicationShortcut.Cut, () => _miCut_Click(null, null), _listView);
            ApplicationShortcut.Link(ApplicationShortcut.FromString("F3", "Search next empty ID"), () => {
                if (_listView.SelectedItems.Count > 0)
                {
                    ReadableTuple <int> item = (_listView.SelectedItems[_listView.SelectedItems.Count - 1]) as ReadableTuple <int>;
                    var original             = item;

                    if (item != null)
                    {
                        int id = item.Key;

                        while (true)
                        {
                            id++;
                            var idGeneric = (TKey)(object)id;

                            var tuple = (ReadableTuple <int>)(object) Table.TryGetTuple(idGeneric);

                            if (tuple == null && item != original && item != null)
                            {
                                TabNavigation.SelectList(DbComponent.DbSource, new TKey[] { item.GetKey <TKey>() });
                                break;
                            }

                            item = tuple;
                        }
                    }
                }
            }, _listView);
        }
Exemple #19
0
        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);
        }
Exemple #20
0
        private void _initRequirementGrid()
        {
            Grid grid = _tab.PropertiesGrid.Children.OfType <Grid>().Last();

            grid.Background = Application.Current.Resources["TabItemBackground"] as Brush;

            Label label = new Label();

            label.Content = "Requirements";
            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);

            _lvRequirements = new RangeListView();
            _lvRequirements.SetValue(TextSearch.TextPathProperty, "ID");
            _lvRequirements.SetValue(WpfUtils.IsGridSortableProperty, true);
            _lvRequirements.SetValue(ScrollViewer.HorizontalScrollBarVisibilityProperty, ScrollBarVisibility.Disabled);
            _lvRequirements.SetValue(Grid.RowProperty, _row);
            _lvRequirements.SetValue(Grid.ColumnProperty, 1);
            _lvRequirements.FocusVisualStyle           = null;
            _lvRequirements.Margin                     = new Thickness(3);
            _lvRequirements.BorderThickness            = new Thickness(1);
            _lvRequirements.PreviewMouseRightButtonUp += _lvRequirements_PreviewMouseRightButtonUp;

            _evolutionTargetSorter = new DefaultListViewComparer <PetEvolutionTargetView>(true);

            ListViewDataTemplateHelper.GenerateListViewTemplateNew(_lvRequirements, new ListViewDataTemplateHelper.GeneralColumnInfo[] {
                new ListViewDataTemplateHelper.GeneralColumnInfo {
                    Header = "Item ID", DisplayExpression = "ID", SearchGetAccessor = "ID", FixedWidth = 60, TextAlignment = TextAlignment.Right, ToolTipBinding = "ID"
                },
                new ListViewDataTemplateHelper.ImageColumnInfo {
                    Header = "", DisplayExpression = "DataImage", SearchGetAccessor = "ID", FixedWidth = 26, MaxHeight = 24
                },
                new ListViewDataTemplateHelper.RangeColumnInfo {
                    Header = "Name", DisplayExpression = "Name", SearchGetAccessor = "Name", IsFill = true, ToolTipBinding = "Name", TextWrapping = TextWrapping.Wrap, MinWidth = 40
                },
                new ListViewDataTemplateHelper.GeneralColumnInfo {
                    Header = "Amount", DisplayExpression = "Amount", SearchGetAccessor = "Amount", ToolTipBinding = "Amount", FixedWidth = 60, TextAlignment = TextAlignment.Right
                },
            }, _evolutionTargetSorter, new string[] { "Default", "{DynamicResource TextForeground}" });

            _lvRequirements.ContextMenu       = new ContextMenu();
            _lvRequirements.MouseDoubleClick += new MouseButtonEventHandler(_lvRequirements_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 miAddTarget = new MenuItem {
                Header = "Add requirement", Icon = new Image {
                    Source = ApplicationManager.PreloadResourceImage("add.png")
                }
            };

            ApplicationShortcut.Link(ApplicationShortcut.Copy, () => _miCopy_Click(null, null, _lvRequirements), _lvRequirements);
            ApplicationShortcut.Link(ApplicationShortcut.Paste, () => _miPasteRequirement_Click(null, null), _lvRequirements);
            ApplicationShortcut.Link(ApplicationShortcut.Delete, () => _miRemoveDrop_Click <PetEvolutionTargetView>(null, null, _lvRequirements), _lvRequirements);

            _lvRequirements.ContextMenu.Items.Add(miSelect);
            _lvRequirements.ContextMenu.Items.Add(miEditDrop);
            _lvRequirements.ContextMenu.Items.Add(miRemoveDrop);
            _lvRequirements.ContextMenu.Items.Add(new Separator());
            _lvRequirements.ContextMenu.Items.Add(miCopy);
            _lvRequirements.ContextMenu.Items.Add(miPaste);
            _lvRequirements.ContextMenu.Items.Add(miAddTarget);

            miSelect.Click     += (sender, e) => _miSelect_Click(sender, e, _lvRequirements, ServerDbs.Items);
            miEditDrop.Click   += new RoutedEventHandler(_miEditRequirement_Click);
            miRemoveDrop.Click += (sender, e) => _miRemoveDrop_Click <PetEvolutionTargetView>(sender, e, _lvRequirements);
            miAddTarget.Click  += new RoutedEventHandler(_miAddRequirement_Click);
            miCopy.Click       += (sender, e) => _miCopy_Click(sender, e, _lvRequirements);
            miPaste.Click      += new RoutedEventHandler(_miPasteRequirement_Click);

            _lvRequirements.PreviewMouseDown += delegate { Keyboard.Focus(_lvRequirements); };
            _lvRequirements.SelectionChanged += new SelectionChangedEventHandler(_lvRequirements_SelectionChanged);

            grid.Children.Add(label);
            grid.Children.Add(_lvRequirements);
        }
Exemple #21
0
        public SdeEditor() : base("Server database editor", "cde.ico", SizeToContent.Manual, ResizeMode.CanResize)
        {
            SplashDialog loading = new SplashDialog();

            loading.Show();
            Loaded += delegate {
                loading.Terminate();
            };

            try {
                ApplicationShortcut.OverrideBindings(SdeAppConfiguration.Remapper);
            }
            catch (Exception err) {
                SdeAppConfiguration.Remapper.Clear();
                ApplicationShortcut.OverrideBindings(SdeAppConfiguration.Remapper);
                ErrorHandler.HandleException("Failed to load the custom key bindings. The bindings will be reset to their default values.", err);
            }

            string configFile = _parseCommandLineArguments();

            GrfPath.Delete(ProjectConfiguration.DefaultFileName);

            InitializeComponent();
            Instance      = this;
            ShowInTaskbar = true;

            _asyncOperation = new AsyncOperation(_progressBar);
            _clientDatabase = new SdeDatabase(_metaGrf);
            _loadMenu();

            if (configFile == null)
            {
                ProjectConfiguration.ConfigAsker = new ConfigAsker(ProjectConfiguration.DefaultFileName);

                if (SdeAppConfiguration.AlwaysReopenLatestProject)
                {
                    if (_recentFilesManager.Files.Count > 0 && File.Exists(_recentFilesManager.Files[0]))
                    {
                        ProjectConfiguration.ConfigAsker = new ConfigAsker(configFile = _recentFilesManager.Files[0]);
                    }
                }
            }
            else if (File.Exists(configFile))
            {
                ProjectConfiguration.ConfigAsker = new ConfigAsker(configFile);
            }

            _loadSettingsTab();
            if (configFile != null)
            {
                ReloadSettings(configFile);
            }
            _loadGenericTab();

            _clientDatabase.Commands.ModifiedStateChanged += new AbstractCommand <IGenericDbCommand> .AbstractCommandsEventHandler(_commands_ModifiedStateChanged);

            ApplicationShortcut.Link(ApplicationShortcut.Undo, () => _clientDatabase.Commands.Undo(), this);
            ApplicationShortcut.Link(ApplicationShortcut.UndoGlobal, () => _clientDatabase.Commands.Undo(), this);
            ApplicationShortcut.Link(ApplicationShortcut.Redo, () => _clientDatabase.Commands.Redo(), this);
            ApplicationShortcut.Link(ApplicationShortcut.RedoGlobal, () => _clientDatabase.Commands.Redo(), this);
            ApplicationShortcut.Link(ApplicationShortcut.Search, () => _execute(v => v.Search()), this);
            ApplicationShortcut.Link(ApplicationShortcut.Delete, () => _execute(v => v.DeleteItems()), this);
            ApplicationShortcut.Link(ApplicationShortcut.Rename, () => _execute(v => v.ChangeId()), this);
            ApplicationShortcut.Link(ApplicationShortcut.NavigationBackward, () => _tabEngine.Undo(), this);
            ApplicationShortcut.Link(ApplicationShortcut.NavigationBackward2, () => _tabEngine.Redo(), this);
            ApplicationShortcut.Link(ApplicationShortcut.NavigationForward, () => _tabEngine.Redo(), this);
            ApplicationShortcut.Link(ApplicationShortcut.Change, () => _execute(v => v.ChangeId()), this);
            ApplicationShortcut.Link(ApplicationShortcut.Restrict, () => _execute(v => v.ShowSelectedOnly()), this);
            ApplicationShortcut.Link(ApplicationShortcut.CopyTo, () => _execute(v => v.CopyItemTo()), this);
            ApplicationShortcut.Link(ApplicationShortcut.New, () => _execute(v => v.AddNewItem()), this);
            ApplicationShortcut.Link(ApplicationShortcut.Save, () => _menuItemDatabaseSave_Click(this, null), this);
            ApplicationShortcut.Link(ApplicationShortcut.Replace, () => { if (_menuItemReplaceAll.IsEnabled)
                                                                          {
                                                                              _menuItemReplaceAll_Click(this, null);
                                                                          }
                                     }, this);
            ApplicationShortcut.Link(ApplicationShortcut.FromString("Ctrl-Enter", "Select next entry"), () => _execute(v => v.SelectNext()), this);
            ApplicationShortcut.Link(ApplicationShortcut.FromString("Ctrl-Shift-Enter", "Select previous entry"), () => _execute(v => v.SelectPrevious()), this);
            Configuration.EnableDebuggerTrace = false;

            _tnbUndo.SetUndo(_tabEngine);
            _tnbRedo.SetRedo(_tabEngine);

            _tmbUndo.SetUndo(_clientDatabase.Commands);
            _tmbRedo.SetRedo(_clientDatabase.Commands);

            Extensions.GenerateListViewTemplate(_debugList, new ListViewDataTemplateHelper.GeneralColumnInfo[] {
                new ListViewDataTemplateHelper.GeneralColumnInfo {
                    Header = "#", DisplayExpression = "ErrorNumber", SearchGetAccessor = "ErrorNumber", FixedWidth = 35, ToolTipBinding = "ErrorNumber", TextAlignment = TextAlignment.Right
                },
                new ListViewDataTemplateHelper.ImageColumnInfo {
                    Header = "", DisplayExpression = "DataImage", SearchGetAccessor = "Exception", FixedWidth = 20, MaxHeight = 24
                },
                new ListViewDataTemplateHelper.RangeColumnInfo {
                    Header = "Exception", DisplayExpression = "Exception", SearchGetAccessor = "Exception", IsFill = true, TextAlignment = TextAlignment.Left, ToolTipBinding = "OriginalException", TextWrapping = TextWrapping.Wrap, MinWidth = 120
                },
                new ListViewDataTemplateHelper.GeneralColumnInfo {
                    Header = "Id", DisplayExpression = "Id", SearchGetAccessor = "Id", FixedWidth = 90, TextAlignment = TextAlignment.Left, ToolTipBinding = "Id", TextWrapping = TextWrapping.Wrap
                },
                new ListViewDataTemplateHelper.GeneralColumnInfo {
                    Header = "File", DisplayExpression = "FileName", SearchGetAccessor = "FilePath", FixedWidth = 145, TextAlignment = TextAlignment.Left, ToolTipBinding = "FilePath", TextWrapping = TextWrapping.Wrap
                },
                new ListViewDataTemplateHelper.GeneralColumnInfo {
                    Header = "Line", DisplayExpression = "Line", SearchGetAccessor = "Line", FixedWidth = 40, TextAlignment = TextAlignment.Left, ToolTipBinding = "Line"
                },
            }, null, new string[] { "Added", "Blue", "Default", "Black" });

            ApplicationShortcut.Link(ApplicationShortcut.Copy, () => WpfUtils.CopyContent(_debugList), _debugList);

            _debugItems            = new ObservableCollection <DebugItemView>();
            _debugList.ItemsSource = _debugItems;

            DbIOErrorHandler.ClearListeners();
            DbIOErrorHandler.AddListener(this);

            _clientDatabase.PreviewReloaded += delegate {
                this.BeginDispatch(delegate {
                    foreach (TabItem tabItem in _mainTabControl.Items)
                    {
                        tabItem.IsEnabled = true;

                        var tabItemHeader = tabItem.Header as DisplayLabel;

                        if (tabItemHeader != null)
                        {
                            tabItemHeader.ResetEnabled();
                        }
                    }
                });
            };

            _clientDatabase.Reloaded += delegate {
                _mainTabControl.Dispatch(p => p.RaiseEvent(new SelectionChangedEventArgs(Selector.SelectionChangedEvent, new List <object>(), _mainTabControl.SelectedItem == null ? new List <object>() : new List <object> {
                    _mainTabControl.SelectedItem
                })));
                ServerType serverType = DbPathLocator.GetServerType();
                bool       renewal    = DbPathLocator.GetIsRenewal();
                string     header     = String.Format("Current ({0} - {1})", serverType == ServerType.RAthena ? "rA" : "Herc", renewal ? "Renewal" : "Pre-Renewal");

                this.BeginDispatch(delegate {
                    _menuItemExportDbCurrent.IsEnabled = true;
                    _menuItemExportDbCurrent.Header    = header;

                    _menuItemExportSqlCurrent.IsEnabled = true;
                    _menuItemExportSqlCurrent.Header    = header;
                });
            };

            SelectionChanged += _sdeEditor_SelectionChanged;
        }
Exemple #22
0
        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++;
            }
        }
Exemple #23
0
        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);
            }
        }
Exemple #24
0
        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();
        }
Exemple #25
0
        public SdeEditor() : base("Server database editor", "cde.ico", SizeToContent.Manual, ResizeMode.CanResize)
        {
            SplashDialog loading = new SplashDialog();

            loading.Show();
            Loaded += delegate {
                loading.Terminate();
            };

            string configFile = _parseCommandLineArguments();

            GrfPath.Delete(ProjectConfiguration.DefaultFileName);

            if (configFile == null)
            {
                ProjectConfiguration.ConfigAsker = new ConfigAsker(ProjectConfiguration.DefaultFileName);
            }
            else if (File.Exists(configFile))
            {
                ProjectConfiguration.ConfigAsker = new ConfigAsker(configFile);
            }

            InitializeComponent();
            ShowInTaskbar = true;

            _asyncOperation = new AsyncOperation(_progressBar);
            _clientDatabase = new GenericDatabase(_metaGrf);

            _loadMenu();
            _loadSettingsTab();
            if (configFile != null)
            {
                ReloadSettings(configFile);
            }
            _loadGenericTab();

            _clientDatabase.Modified += new BaseGenericDatabase.ClientDatabaseEventHandler(_clientDatabase_Modified);

            _cbAssociate.Checked  -= new RoutedEventHandler(_cbAssociate_Checked);
            _cbAssociate.IsChecked = (SdeAppConfiguration.FileShellAssociated & FileAssociation.Sde) == FileAssociation.Sde;
            _cbAssociate.Checked  += new RoutedEventHandler(_cbAssociate_Checked);

            ApplicationShortcut.Link(ApplicationShortcut.Undo, () => _clientDatabase.Commands.Undo(), this);
            ApplicationShortcut.Link(ApplicationShortcut.UndoGlobal, () => _clientDatabase.Commands.Undo(), this);
            ApplicationShortcut.Link(ApplicationShortcut.Redo, () => _clientDatabase.Commands.Redo(), this);
            ApplicationShortcut.Link(ApplicationShortcut.RedoGlobal, () => _clientDatabase.Commands.Redo(), this);
            ApplicationShortcut.Link(ApplicationShortcut.Search, () => _execute(v => v.Search()), this);
            ApplicationShortcut.Link(ApplicationShortcut.Delete, () => _execute(v => v.DeleteItems()), this);
            ApplicationShortcut.Link(ApplicationShortcut.Rename, () => _execute(v => v.ChangeId()), this);
            ApplicationShortcut.Link(ApplicationShortcut.NavigationBackward, () => _tabEngine.Undo(), this);
            ApplicationShortcut.Link(ApplicationShortcut.NavigationBackward2, () => _tabEngine.Redo(), this);
            ApplicationShortcut.Link(ApplicationShortcut.NavigationForward, () => _tabEngine.Redo(), this);
            ApplicationShortcut.Link(ApplicationShortcut.Change, () => _execute(v => v.ChangeId()), this);
            ApplicationShortcut.Link(ApplicationShortcut.Restrict, () => _execute(v => v.ShowSelectedOnly()), this);
            ApplicationShortcut.Link(ApplicationShortcut.CopyTo, () => _execute(v => v.CopyItemTo()), this);
            ApplicationShortcut.Link(ApplicationShortcut.New, () => _execute(v => v.AddNewItem()), this);
            ApplicationShortcut.Link(ApplicationShortcut.Save, () => _menuItemDatabaseSave_Click(this, null), this);
            ApplicationShortcut.Link(ApplicationShortcut.SaveAll, () => _menuItemDatabaseSaveAll_Click(this, null), this);

            SdeAppConfiguration.Bind(_cbStackTrace, () => Configuration.EnableDebuggerTrace, v => {
                Configuration.EnableDebuggerTrace = v;
                SdeErrorHandler.ShowStackTraceViewer();
            });

            _tnbUndo.SetUndo(_tabEngine);
            _tnbRedo.SetRedo(_tabEngine);

            _tmbUndo.SetUndo(_clientDatabase.Commands);
            _tmbRedo.SetRedo(_clientDatabase.Commands);

            Extensions.GenerateListViewTemplate(_debugList, new ListViewDataTemplateHelper.GeneralColumnInfo[] {
                new ListViewDataTemplateHelper.GeneralColumnInfo {
                    Header = "#", DisplayExpression = "ErrorNumber", SearchGetAccessor = "ErrorNumber", FixedWidth = 35, ToolTipBinding = "ErrorNumber", TextAlignment = TextAlignment.Right
                },
                new ListViewDataTemplateHelper.ImageColumnInfo {
                    Header = "", DisplayExpression = "DataImage", SearchGetAccessor = "Exception", FixedWidth = 20, MaxHeight = 24
                },
                new ListViewDataTemplateHelper.RangeColumnInfo {
                    Header = "Exception", DisplayExpression = "Exception", SearchGetAccessor = "Exception", IsFill = true, TextAlignment = TextAlignment.Left, ToolTipBinding = "OriginalException", TextWrapping = TextWrapping.Wrap, MinWidth = 120
                },
                new ListViewDataTemplateHelper.GeneralColumnInfo {
                    Header = "Id", DisplayExpression = "Id", SearchGetAccessor = "Id", FixedWidth = 90, TextAlignment = TextAlignment.Left, ToolTipBinding = "Id", TextWrapping = TextWrapping.Wrap
                },
                new ListViewDataTemplateHelper.GeneralColumnInfo {
                    Header = "File", DisplayExpression = "FileName", SearchGetAccessor = "FilePath", FixedWidth = 130, TextAlignment = TextAlignment.Left, ToolTipBinding = "FilePath", TextWrapping = TextWrapping.Wrap
                },
                new ListViewDataTemplateHelper.GeneralColumnInfo {
                    Header = "Line", DisplayExpression = "Line", SearchGetAccessor = "Line", FixedWidth = 40, TextAlignment = TextAlignment.Left, ToolTipBinding = "Line"
                },
            }, null, new string[] { "Added", "Blue", "Default", "Black" });

            ApplicationShortcut.Link(ApplicationShortcut.Copy, () => WpfUtils.CopyContent(_debugList), _debugList);

            _debugItems            = new ObservableCollection <DebugItemView>();
            _debugList.ItemsSource = _debugItems;

            DbLoaderErrorHandler.ClearListeners();
            DbLoaderErrorHandler.AddListener(this);

            _clientDatabase.PreviewReloaded += delegate {
                this.BeginDispatch(delegate {
                    foreach (TabItem tabItem in _mainTabControl.Items)
                    {
                        tabItem.IsEnabled = true;

                        var tabItemHeader = tabItem.Header as DisplayLabel;

                        if (tabItemHeader != null)
                        {
                            tabItemHeader.ResetEnabled();
                        }
                    }
                });
            };

            _clientDatabase.Reloaded += delegate {
                _mainTabControl.Dispatch(p => p.RaiseEvent(new SelectionChangedEventArgs(Selector.SelectionChangedEvent, new List <object>(), _mainTabControl.SelectedItem == null ? new List <object>() : new List <object> {
                    _mainTabControl.SelectedItem
                })));
                ServerType serverType = AllLoaders.GetServerType();
                bool       renewal    = AllLoaders.GetIsRenewal();

                string header = String.Format("Current ({0} - {1})", serverType == ServerType.RAthena ? "rA" : "Herc", renewal ? "Renewal" : "Pre-Renewal");

                this.BeginDispatch(delegate {
                    _menuItemExportDbCurrent.IsEnabled = true;
                    _menuItemExportDbCurrent.Header    = header;

                    _menuItemExportSqlCurrent.IsEnabled = true;
                    _menuItemExportSqlCurrent.Header    = header;
                });
            };
        }
 private NSDictionary <NSString, NSObject> userInfoFor(ApplicationShortcut shortcut)
 => new NSDictionary <NSString, NSObject>(new NSString(nameof(ApplicationShortcut.Type)), new NSNumber((int)shortcut.Type));
Exemple #27
0
        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);
        }