示例#1
0
        public ScriptEditDialog(string text) : base("Script edit", "cde.ico", SizeToContent.Manual, ResizeMode.CanResize)
        {
            InitializeComponent();
            Extensions.SetMinimalSize(this);

            AvalonLoader.Load(_textEditor);
            AvalonLoader.SetSyntax(_textEditor, "Script");

            string script = ItemParser.Format(text, 0);

            _textEditor.Text = script;
            _textEditor.TextArea.TextEntered  += new TextCompositionEventHandler(_textArea_TextEntered);
            _textEditor.TextArea.TextEntering += new TextCompositionEventHandler(_textArea_TextEntering);

            _completionWindow = new CompletionWindow(_textEditor.TextArea);
            _li = _completionWindow.CompletionList;
            ListView lv = _li.ListBox;

            lv.SelectionMode = SelectionMode.Single;

            //Image
            Extensions.GenerateListViewTemplate(lv, new ListViewDataTemplateHelper.GeneralColumnInfo[] {
                new ListViewDataTemplateHelper.ImageColumnInfo {
                    Header = "", DisplayExpression = "Image", TextAlignment = TextAlignment.Center, FixedWidth = 22, MaxHeight = 22, SearchGetAccessor = "Commands"
                },
                new ListViewDataTemplateHelper.GeneralColumnInfo {
                    Header = "Commands", DisplayExpression = "Text", TextAlignment = TextAlignment.Left, IsFill = true, ToolTipBinding = "Description"
                }
            }, null, new string[] { }, "generateHeader", "false");

            _completionWindow.Content = null;
            _completionWindow         = null;

            WindowStartupLocation = WindowStartupLocation.CenterOwner;
        }
        public ConvertItemIdsDialog()
            : base("Convert item IDs in text", "convert.png", SizeToContent.Manual, ResizeMode.CanResize)
        {
            InitializeComponent();

            ShowInTaskbar = true;

            _tbSource.TextChanged += (e, a) => _updateDestination();

            _tbSource.PreviewKeyUp += _onCloseKey;
            _tbDest.PreviewKeyUp   += _onCloseKey;

            AvalonLoader.Load(_tbSource);
            AvalonLoader.SetSyntax(_tbSource, "Script");

            AvalonLoader.Load(_tbDest);
            AvalonLoader.SetSyntax(_tbDest, "Script");

            _tbSource.Text = Clipboard.GetText();

            try {
                _citemsDb = SdeEditor.Instance.ProjectDatabase.GetMetaTable <int>(ServerDbs.CItems);
            }
            catch {
                _citemsDb = null;
            }
        }
        private void _initBox(TextEditor box)
        {
            box.ShowLineNumbers = true;
            box.FontFamily      = new FontFamily("Consolas");
            AvalonLoader.Load(box);
            box.WordWrap = true;

            _realBox.AcceptsReturn = true;
            _realBox.AcceptsTab    = true;
        }
示例#4
0
        public DbDebugDialog(SdeEditor editor)
            : base("Debug tables...", "warning16.png", SizeToContent.Manual, ResizeMode.CanResize)
        {
            InitializeComponent();
            WindowStartupLocation = WindowStartupLocation.CenterOwner;
            Owner = WpfUtilities.TopWindow;

            AvalonLoader.Load(_textEditor);
            AvalonLoader.SetSyntax(_textEditor, "DebugDb");

            Log = "Database: Debugger Started...";

            DbDebugHelper.Cleared += delegate(object sender, ServerDbs primaryTable, string subFile, BaseDb db) {
                Log = String.Format("Table: {0}, Message: Table data cleared.", primaryTable);
            };

            DbDebugHelper.ExceptionThrown += delegate(object sender, ServerDbs primaryTable, string subFile, BaseDb db) {
                Log = String.Format("Table: {0}, File: {1}, Message: An exception occured while reading the table, continuing.", primaryTable, _getPath(subFile));
            };

            DbDebugHelper.Loaded += delegate(object sender, ServerDbs primaryTable, string subFile, BaseDb db) {
                Log = String.Format("Table: {0}, File: {1}, Message: Table loaded.", primaryTable, _getPath(subFile));
            };

            DbDebugHelper.Saved += delegate(object sender, ServerDbs primaryTable, string subFile, BaseDb db) {
                Log = String.Format("Table: {0}, File: {1}, Message: Table saved.", primaryTable, _getPath(subFile));
            };

            DbDebugHelper.Update += delegate(object sender, string message) {
                Log = String.Format("Database: {0}", message ?? "");
            };

            DbDebugHelper.SftpUpdate += delegate(object sender, string message) {
                Log = String.Format("Sftp: {0}", message ?? "");
            };

            DbDebugHelper.Update2 += delegate(object sender, ServerDbs primaryTable, string subFile, BaseDb db, string message) {
                Log = String.Format("Table: {0}, File: {1}, Message: {2}", primaryTable, _getPath(subFile), message ?? "");
            };

            DbDebugHelper.WriteStatusUpdate += delegate(object sender, ServerDbs primaryTable, string subFile, BaseDb db, string message) {
                Log = String.Format("Table: {0}, File: {1}, Message: {2}", primaryTable, _getPath(subFile), message ?? "");
            };

            DbDebugHelper.StoppedLoading += delegate(object sender, ServerDbs primaryTable, string subFile, BaseDb db) {
                Log = String.Format("Table: {0}, File: {1}, Message: Table loading has been stopped due to too many errors.", primaryTable, _getPath(subFile));
            };
        }
示例#5
0
        public ScriptEditDialog(string text) : base("Script edit", "cde.ico", SizeToContent.Manual, ResizeMode.CanResize)
        {
            InitializeComponent();

            AvalonLoader.Load(_textEditor);
            AvalonLoader.SetSyntax(_textEditor, "Script");

            string script = DbIOFormatting.ScriptFormat(text, 0);

            _textEditor.Text = script;
            _textEditor.TextArea.TextEntered  += new TextCompositionEventHandler(_textArea_TextEntered);
            _textEditor.TextArea.TextEntering += new TextCompositionEventHandler(_textArea_TextEntering);
            _textEditor.TextChanged           += (e, a) => OnValueChanged();
            //_textEditor.TextArea.IndentationStrategy = new CSharpIndentationStrategy();

            _completionWindow            = new CompletionWindow(_textEditor.TextArea);
            _completionWindow.Background = Application.Current.Resources["TabItemBackground"] as Brush;
            _li = _completionWindow.CompletionList;
            ListView lv = _li.ListBox;

            lv.SelectionMode = SelectionMode.Single;
            lv.Background    = Application.Current.Resources["TabItemBackground"] as Brush;

            //Image
            ListViewDataTemplateHelper.GenerateListViewTemplateNew(lv, new ListViewDataTemplateHelper.GeneralColumnInfo[] {
                new ListViewDataTemplateHelper.ImageColumnInfo {
                    Header = "", DisplayExpression = "Image", TextAlignment = TextAlignment.Center, FixedWidth = 22, MaxHeight = 22, SearchGetAccessor = "Commands"
                },
                new ListViewDataTemplateHelper.GeneralColumnInfo {
                    Header = "Commands", DisplayExpression = "Text", TextAlignment = TextAlignment.Left, IsFill = true, ToolTipBinding = "Description"
                }
            }, null, new string[] { }, "generateHeader", "false");

            _completionWindow.Content = null;
            _completionWindow         = null;

            WindowStartupLocation = WindowStartupLocation.CenterOwner;

            _textEditor.Loaded += delegate {
                _textEditor.Focus();
            };
        }
        private void _loadUi()
        {
            _rcm              = new WpfRecentFiles(SdeAppConfiguration.ConfigAsker, 6, _miLoadRecent, "Server database editor - IronPython recent files");
            _rcm.FileClicked += new RecentFilesManager.RFMFileClickedEventHandler(_rcm_FileClicked);

            Binder.Bind(_textEditor, () => SdeAppConfiguration.IronPythonScript);
            Binder.Bind(_miAutocomplete, () => SdeAppConfiguration.IronPythonAutocomplete);

            AvalonLoader.Load(_textEditor);
            AvalonLoader.SetSyntax(_textEditor, "Python");
            _textEditor.TextArea.TextEntered  += new TextCompositionEventHandler(_textArea_TextEntered);
            _textEditor.TextArea.TextEntering += new TextCompositionEventHandler(_textArea_TextEntering);

            this.PreviewKeyDown += new KeyEventHandler(_ironPythonDialog_PreviewKeyDown);

            _completionWindow            = new CompletionWindow(_textEditor.TextArea);
            _completionWindow.Background = Application.Current.Resources["TabItemBackground"] as Brush;
            _li = _completionWindow.CompletionList;
            ListView lv = _li.ListBox;

            lv.SelectionMode = SelectionMode.Single;
            lv.Background    = Application.Current.Resources["TabItemBackground"] as Brush;

            //Image
            ListViewDataTemplateHelper.GenerateListViewTemplateNew(lv, new ListViewDataTemplateHelper.GeneralColumnInfo[] {
                new ListViewDataTemplateHelper.ImageColumnInfo {
                    Header = "", DisplayExpression = "Image", TextAlignment = TextAlignment.Center, FixedWidth = 22, MaxHeight = 22, SearchGetAccessor = "Commands"
                },
                new ListViewDataTemplateHelper.GeneralColumnInfo {
                    Header = "Commands", DisplayExpression = "Text", TextAlignment = TextAlignment.Left, IsFill = true, ToolTipBinding = "Description"
                }
            }, null, new string[] { }, "generateHeader", "false");

            _completionWindow.Content  = null;
            _completionWindow          = null;
            _rowConsole.Height         = new GridLength(0);
            _buttonCloseConsole.Margin = new Thickness(0, 5, SystemParameters.HorizontalScrollBarButtonWidth + 2, 0);
            _textEditor.Drop          += new DragEventHandler(_textEditor_Drop);
        }
        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";
        }