示例#1
0
        private void _update()
        {
            GDbTab tab = _editor.FindTopmostTab();

            if (tab != null)
            {
                try {
                    if (_cbAttribute.ItemsSource != null && _tab == tab)
                    {
                        _buttonOk.IsEnabled    = true;
                        _cbAttribute.IsEnabled = true;
                        return;
                    }

                    _tab = tab;
                    _cbAttribute.ItemsSource = _tab.DbComponent.AttributeList.Attributes.Skip(1).Where(p => (p.Visibility & VisibleState.VisibleAndForceShow) != 0).Select(p => new DbAttributeWrapper(p));
                    _buttonOk.IsEnabled      = true;
                    _cbAttribute.IsEnabled   = true;
                    return;
                }
                catch (Exception err) {
                    ErrorHandler.HandleException(err);
                }
            }

            _cbAttribute.ItemsSource = null;
            _buttonOk.IsEnabled      = false;
            _cbAttribute.IsEnabled   = false;
        }
示例#2
0
        private void _update()
        {
            GDbTab tab = _editor.FindTopmostTab();

            if (tab != null)
            {
                try {
                    if (_boxes.Count > 0 && _tab == tab)
                    {
                        _buttonOk.IsEnabled = true;
                        return;
                    }

                    _tab = tab;

                    _gridCopy.Children.Clear();
                    _boxes.Clear();

                    int index = 0;

                    foreach (DbAttribute attribute in _tab.DbComponent.AttributeList.Attributes)
                    {
                        if (attribute.Index == 0)
                        {
                            continue;
                        }

                        if ((attribute.Visibility & VisibleState.VisibleAndForceShow) != 0)
                        {
                            CheckBox box = new CheckBox {
                                Margin = new Thickness(3, 3, 10, 3)
                            };
                            box.Content = attribute.DisplayName ?? attribute.AttributeName;
                            box.Tag     = attribute;
                            box.SetValue(Grid.RowProperty, index / _gridCopy.ColumnDefinitions.Count);
                            box.SetValue(Grid.ColumnProperty, index % _gridCopy.ColumnDefinitions.Count);
                            box.IsChecked = _cbSelectAll.IsChecked;
                            WpfUtils.AddMouseInOutEffectsBox(box);
                            _gridCopy.Children.Add(box);
                            _boxes.Add(box);
                            index++;
                        }
                    }

                    _buttonOk.IsEnabled = true;
                    return;
                }
                catch (Exception err) {
                    ErrorHandler.HandleException(err);
                }
            }

            _gridCopy.Children.Clear();
            _boxes.Clear();
            _buttonOk.IsEnabled = false;
        }
示例#3
0
        public AddRangeDialog(SdeEditor editor)
            : base("Add range...", "add.png", SizeToContent.WidthAndHeight, ResizeMode.NoResize)
        {
            InitializeComponent();

            _tab = editor.FindTopmostTab();

            if (_tab == null)
            {
                throw new Exception("No table selected.");
            }

            if (!(_tab is GDbTabWrapper <int, ReadableTuple <int> >))
            {
                throw new Exception("This table doesn't support this operation.");
            }

            List <ServerDbs> dbSources = new List <ServerDbs>();

            dbSources.Add(_tab.DbComponent.DbSource);

            if (_tab.DbComponent.DbSource.AdditionalTable != null)
            {
                dbSources.Add(_tab.DbComponent.DbSource.AdditionalTable);
            }

            _destTable.ItemsSource   = dbSources;
            _destTable.SelectedIndex = 0;

            WpfUtils.AddMouseInOutEffects(_imReset);

            this.Loaded += delegate {
                _tbRange.Text = "1";
                _tbFrom.Text  = "0";

                if (_tab._listView.SelectedItem != null)
                {
                    _based              = (Tuple)_tab._listView.SelectedItem;
                    _tbBasedOn.Text     = _based.GetKey <int>().ToString(CultureInfo.InvariantCulture);
                    _imReset.Visibility = System.Windows.Visibility.Visible;

                    _tbFrom.Text = (_based.GetKey <int>() + 1).ToString(CultureInfo.InvariantCulture);
                }
            };

            WindowStartupLocation = WindowStartupLocation.CenterOwner;
            Owner = WpfUtilities.TopWindow;
        }
示例#4
0
        private void _update()
        {
            try {
                GDbTab tab = _editor.FindTopmostTab();
                _tab  = tab;
                _item = null;

                if (tab != null && (tab.DbComponent.DbSource == ServerDbs.Mobs || tab.DbComponent.DbSource == ServerDbs.Mobs2))
                {
                    ReadableTuple <int> tuple = tab._listView.SelectedItem as ReadableTuple <int>;
                    _mobDb = (AbstractDb <int>)tab.DbComponent;

                    if (tab.DbComponent.DbSource == ServerDbs.Mobs && !_bind1)
                    {
                        tab._listView.SelectionChanged += (e, s) => _update();
                        _bind1 = true;
                    }

                    if (tab.DbComponent.DbSource == ServerDbs.Mobs2 && !_bind2)
                    {
                        tab._listView.SelectionChanged += (e, s) => _update();
                        _bind2 = true;
                    }

                    if (tuple != null)
                    {
                        _item = _mobDb.Table.GetTuple(tuple.Key);

                        _eventsDisabled = true;
                        _level          = _item.GetValue <int>(ServerMobAttributes.Lv);

                        for (int i = 0; i < 6; i++)
                        {
                            _rates[i] = _item.GetValue <int>(ServerMobAttributes.Str.Index + i);
                        }

                        _gpRate.SetPosition(_level / Limit, false);
                        _setValues();
                        _eventsDisabled = false;
                    }
                }
            }
            catch (Exception err) {
                ErrorHandler.HandleException(err);
            }
        }
        private void _buttonOk_Click(object sender, RoutedEventArgs e)
        {
            string tempFile = TemporaryFilesManager.GetTemporaryFilePath("script_tmp_{0:0000}.py");

            try {
                if (_oldHeight != default(GridLength) && _rowConsole.Height.Value > 0)
                {
                    _oldHeight = new GridLength(_rowConsole.Height.Value);
                }

                if (!_editor.ProjectDatabase.AllTables.Any(p => p.Value.IsLoaded))
                {
                    throw new Exception("No databases loaded.");
                }

                File.WriteAllText(tempFile, _textEditor.Text);

                _tbOutput.Text = new ScriptInterpreter().Execute(_editor.FindTopmostTab(), tempFile);

                if (_tbOutput.Text != "")
                {
                    _tbOutput.Text       = ">>> CONSOLE OUTPUT\r\n" + _tbOutput.Text;
                    _tbOutput.Visibility = Visibility.Visible;

                    if (_oldHeight == default(GridLength))
                    {
                        _oldHeight = new GridLength(150);
                    }

                    _rowConsole.Height = _oldHeight;
                }
                else
                {
                    _button_ConsoleClose_Click(null, null);
                }
            }
            catch (Exception err) {
                ErrorHandler.HandleException(err);
            }
            finally {
                GrfPath.Delete(tempFile);
            }
        }