예제 #1
0
        public bool ReloadDatabase()
        {
            try {
                if (ShouldCancelDbReload())
                {
                    return(false);
                }

                for (int i = 0; i < GdTabs.Count; i++)
                {
                    if (GdTabs[i].DbComponent.IsCustom)
                    {
                        GDbTab tab = GdTabs[i];
                        _mainTabControl.Dispatch(p => p.Items.Remove(tab));
                        GdTabs.RemoveAt(i);
                        _holder.RemoveTable(tab.DbComponent);
                        i--;
                    }
                }

                if (_asyncOperation.IsRunning)
                {
                    _reloadDatabase(true);
                }
                else
                {
                    _asyncOperation.SetAndRunOperation(new GrfThread(() => _reloadDatabase(false), this, 200, null, false, true));
                }
                return(true);
            }
            catch (Exception err) {
                ErrorHandler.HandleException(err);
                return(false);
            }
        }
예제 #2
0
        public ViewIdPreviewDialog(SdeEditor editor, GDbTab tab) : base("View ID preview", "eye.png", SizeToContent.Manual, ResizeMode.CanResize)
        {
            _tab    = tab;
            _editor = editor;
            _editor._mainTabControl.SelectionChanged += _mainTabControl_SelectionChanged;

            InitializeComponent();
            WindowStartupLocation = WindowStartupLocation.CenterOwner;
            Owner       = WpfUtilities.TopWindow;
            WindowStyle = WindowStyle.ToolWindow;

            _helper = new PreviewHelper(_listView, _tab.DbComponent.To <int>(), _selector, _frameViewer, _gridSpriteMissing, _tbSpriteMissing);

            this.Loaded += delegate {
                Width    = 400;
                Height   = 300;
                IsOpened = true;
            };

            ListViewDataTemplateHelper.GenerateListViewTemplateNew(_listView, new ListViewDataTemplateHelper.GeneralColumnInfo[] {
                new ListViewDataTemplateHelper.RangeColumnInfo {
                    Header = "Job Name", DisplayExpression = "Name", SearchGetAccessor = "Name", IsFill = true, ToolTipBinding = "Name", TextWrapping = TextWrapping.Wrap
                }
            }, null, new string[] { "Normal", "{DynamicResource TextForeground}" });

            _tupleUpdate();
        }
예제 #3
0
        private void _replace <T>(GDbTab tab, Tuple tuple)
        {
            var aDb = tab.DbComponent.To <T>();

            aDb.Table.Commands.Begin();

            try {
                List <DbAttribute> attributes = _boxes.Where(p => p.IsChecked == true).Select(p => (DbAttribute)p.Tag).ToList();
                //List<ITableCommand<T, ReadableTuple<T>>> commands = new List<ITableCommand<T, ReadableTuple<T>>>();

                foreach (ReadableTuple <T> item in tab._listView.SelectedItems)
                {
                    for (int index = 0; index < attributes.Count; index++)
                    {
                        aDb.Table.Commands.Set(item, attributes[index], tuple.GetValue(attributes[index]));
                    }
                }

                //aDb.Table.Commands.StoreAndExecute(new GroupCommand<T, ReadableTuple<T>>(commands));
            }
            catch {
                aDb.Table.Commands.CancelEdit();
            }
            finally {
                aDb.Table.Commands.End();
                tab.Update();
            }
        }
예제 #4
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;
        }
예제 #5
0
        private void _replace()
        {
            try {
                if (_cbAttribute.SelectedIndex < 0)
                {
                    throw new Exception("No attribute selected.");
                }

                DbAttribute attribute = ((DbAttributeWrapper)_cbAttribute.SelectedItem).Attribute;
                GDbTab      tab       = _tab;

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

                if (tab._listView.SelectedItems.Count == 0)
                {
                    throw new Exception("No items selected (select the items to replace in the list).");
                }

                if (tab.DbComponent is AbstractDb <int> )
                {
                    _replace <int>(tab, attribute);
                }
                else if (tab.DbComponent is AbstractDb <string> )
                {
                    _replace <string>(tab, attribute);
                }
            }
            catch (Exception err) {
                ErrorHandler.HandleException(err);
            }
        }
예제 #6
0
 public SelectionChanged(string tabName, object tuple, ListView view, GDbTab tab)
 {
     _tabName = tabName;
     _tuple   = tuple;
     _view    = view;
     _tab     = tab;
 }
예제 #7
0
        public void Read(ReadableTuple <int> tuple, GDbTab tab)
        {
            PreviewSprite = null;
            KeepPreviousPreviewPosition = true;
            RemoveJobs();
            RemoveError();
            List <Job> jobs;

            _lastTuple  = tuple;
            _metaGrf    = tab.ProjectDatabase.MetaGrf;
            _currentTab = tab;

            foreach (var preview in _previews)
            {
                if (preview.CanRead(tuple))
                {
                    if (_lastMatch != preview)
                    {
                        KeepPreviousPreviewPosition = false;
                    }

                    _lastMatch = preview;
                    string job = tuple.GetValue <string>(ServerItemAttributes.ApplicableJob);
                    jobs = JobList.GetJobsFromHex("0x" + ((job == "") ? "FFFFFFFF" : job), tuple.GetIntNoThrow(ServerItemAttributes.Upper));
                    preview.Read(tuple, this, jobs);
                    break;
                }
            }

            if (_listView.Items.Count > 0)
            {
                _listView.SelectedItem = PreferredJob;

                if (_listView.SelectedItem == null)
                {
                    if (_oldJob != null)
                    {
                        _listView.SelectedItem = _oldJob;
                    }

                    if (_listView.SelectedItem == null)
                    {
                        _listView.SelectedIndex = 0;
                    }
                }
            }
            else
            {
                _updatePreview(SpriteDefault);
            }

            if (!KeepPreviousPreviewPosition)
            {
                _selector.SetAction(_lastMatch.SuggestedAction);
            }
        }
예제 #8
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;
        }
예제 #9
0
        private static void _waitForFilter(GDbTab tab)
        {
            int max = 20;

            while (tab.IsFiltering && max > 0)
            {
                Thread.Sleep(200);
                max--;
            }
        }
예제 #10
0
        public void Add(TabControl mainTabControl, DbHolder holder, TabNavigation tabEngine, SdeEditor editor)
        {
            holder.AddTable(_adb);
            GDbTab copy = holder.GetTab(_adb, mainTabControl);

            if (_adb is AbstractDb <int> )
            {
                _adb.To <int>().Table.Commands.CommandIndexChanged += (e, a) => editor.UpdateTabHeader(_adb.To <int>());
            }
            else if (_adb is AbstractDb <string> )
            {
                _adb.To <string>().Table.Commands.CommandIndexChanged += (e, a) => editor.UpdateTabHeader(_adb.To <string>());
            }

            copy._listView.SelectionChanged += delegate(object sender, SelectionChangedEventArgs args) {
                if (sender is ListView)
                {
                    ListView view = (ListView)sender;
                    tabEngine.StoreAndExecute(new SelectionChanged(copy.Header.ToString(), view.SelectedItem, view, copy));
                }
            };

            ((DisplayLabel)copy.Header).ContextMenu.Items.Cast <MenuItem>().ToList().ForEach(p => p.IsEnabled = true);

            MenuItem mitem = new MenuItem();

            mitem.Icon = new Image {
                Source = ApplicationManager.GetResourceImage("delete.png")
            };
            mitem.Header = "Delete table";
            mitem.Click += delegate {
                holder.RemoveTable(_adb);
                mainTabControl.Items.Remove(copy);

                List <string> tabs = ProjectConfiguration.CustomTabs;
                tabs.Remove(_file);
                ProjectConfiguration.CustomTabs = tabs.Distinct().ToList();
            };

            ((DisplayLabel)copy.Header).ContextMenu.Items.Add(mitem);

            mainTabControl.Items.Insert(mainTabControl.Items.Count, copy);
            _adb.LoadDb();

            if (_adb is AbstractDb <int> )
            {
                copy.To <int>().SearchEngine.Filter(this);
            }
            else if (_adb is AbstractDb <string> )
            {
                copy.To <string>().SearchEngine.Filter(this);
            }

            editor.GdTabs.Add(copy);
        }
예제 #11
0
 private void _mainTabControl_SelectionChanged(object sender, SelectionChangedEventArgs e)
 {
     try {
         if (_editor._mainTabControl.SelectedIndex >= 0 && _editor._mainTabControl.Items[_editor._mainTabControl.SelectedIndex] is GDbTab)
         {
             _tab = (GDbTab)_editor._mainTabControl.Items[_editor._mainTabControl.SelectedIndex];
             _tupleUpdate();
         }
     }
     catch (Exception err) {
         ErrorHandler.HandleException(err);
     }
 }
예제 #12
0
        public bool ReloadDatabase(bool checkReload = true)
        {
            try {
                if (checkReload && ShouldCancelDbReload())
                {
                    return(false);
                }

                for (int i = 0; i < GdTabs.Count; i++)
                {
                    if (GdTabs[i].DbComponent.IsCustom)
                    {
                        GDbTab tab = GdTabs[i];
                        _mainTabControl.Dispatch(p => p.Items.Remove(tab));
                        GdTabs.RemoveAt(i);
                        _holder.RemoveTable(tab.DbComponent);
                        i--;
                    }
                }

                // Rechecks the paths
                _listItemClientTxtFiles.Dispatcher.Invoke(new Action(delegate {
                    foreach (TextViewItem tvi in _listItemClientTxtFiles.Items)
                    {
                        tvi.CheckValid();
                    }

                    foreach (TextViewItem tvi in _listItemClientLuaFiles.Items)
                    {
                        tvi.CheckValid();
                    }

                    _tviItemDb.CheckValid();
                }));

                if (_asyncOperation.IsRunning)
                {
                    _reloadDatabase(true);
                }
                else
                {
                    _asyncOperation.SetAndRunOperation(new GrfThread(() => _reloadDatabase(false), this, 200, null, false, true));
                }
                return(true);
            }
            catch (Exception err) {
                ErrorHandler.HandleException(err);
                return(false);
            }
        }
예제 #13
0
        private void _genericExecute(Action <GDbTab> command)
        {
            try {
                GDbTab tab = _getGenericTab();

                if (tab != null)
                {
                    command(tab);
                }
            }
            catch (Exception err) {
                ErrorHandler.HandleException(err);
            }
        }
예제 #14
0
        private bool _containsAny(GDbTab tab, List <Tuple> tuples)
        {
            return(tab.Dispatch(new Func <bool>(delegate {
                for (int i = 0; i < tuples.Count; i++)
                {
                    if (tab._listView.Items.Contains(tuples[i]))
                    {
                        return true;
                    }
                }

                return false;
            })));
        }
예제 #15
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;
        }
예제 #16
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);
            }
        }
예제 #17
0
        private void _replace <T>(GDbTab tab, DbAttribute attribute)
        {
            var aDb = tab.DbComponent.To <T>();

            try {
                if (attribute.DataType == typeof(bool) && attribute.DataConverter.GetType() == typeof(DefaultValueConverter))
                {
                    aDb.Table.Commands.Set(tab._listView.SelectedItems.Cast <ReadableTuple <T> >().ToList(), attribute, Boolean.Parse(_tbNewValue.Text));
                }
                else
                {
                    aDb.Table.Commands.Set(tab._listView.SelectedItems.Cast <ReadableTuple <T> >().ToList(), attribute, _tbNewValue.Text);
                }
            }
            finally {
                tab.Update();
            }
        }
예제 #18
0
        private void _replace()
        {
            try {
                if (_boxes.TrueForAll(p => p.IsChecked == false))
                {
                    throw new Exception("No attribute selected.");
                }

                GDbTab tab = _tab;

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

                if (tab._listView.SelectedItems.Count == 0)
                {
                    throw new Exception("No items selected (select the items to replace in the list).");
                }

                if (tab._listView.SelectedItems.Count == 1)
                {
                    throw new Exception("You must select more than one item to copy (the currently selected one is the source).");
                }

                var tuple = tab._listView.SelectedItem as Tuple;

                if (tab.DbComponent is AbstractDb <int> )
                {
                    _replace <int>(tab, tuple);
                }
                else if (tab.DbComponent is AbstractDb <string> )
                {
                    _replace <string>(tab, tuple);
                }
            }
            catch (Exception err) {
                ErrorHandler.HandleException(err);
            }
        }
예제 #19
0
        public CopyToDialog(GDbTab tab, List <Database.Tuple> tuples, BaseDb currentDb, BaseDb destDb)
            : base("Copy to advanced...", "imconvert.png", SizeToContent.WidthAndHeight, ResizeMode.NoResize)
        {
            _tab      = tab;
            _tuples   = tuples;
            _sourceDb = currentDb;
            _destDb   = destDb;

            InitializeComponent();
            WindowStartupLocation = WindowStartupLocation.CenterOwner;
            Owner = WpfUtilities.TopWindow;

            _tbNewId.Loaded += delegate {
                _tuples       = _tuples.OrderBy(p => p.GetKey <int>()).ToList();
                _tbNewId.Text = _tuples[0].GetKey <int>().ToString(CultureInfo.InvariantCulture);
                _tbNewId.Focus();
                _tbNewId.SelectAll();
            };

            _gridItems.IsEnabled = (ServerDbs.ServerItems & destDb.DbSource) != 0;

            Binder.Bind(_cbOverwrite, () => SdeAppConfiguration.CmdCopyToOverwrite);
            Binder.Bind(_cbCopyClientItems, () => SdeAppConfiguration.CmdCopyToClientItems);
            Binder.Bind(_cbAegisName, () => SdeAppConfiguration.CmdCopyToAegisNameEnabled);
            Binder.Bind(_tbAegisNameInput, () => SdeAppConfiguration.CmdCopyToAegisNameFormatInput);
            Binder.Bind(_tbAegisNameOutput, () => SdeAppConfiguration.CmdCopyToAegisNameFormatOutput);
            Binder.Bind(_cbName, () => SdeAppConfiguration.CmdCopyToNameEnabled);
            Binder.Bind(_tbNameInput, () => SdeAppConfiguration.CmdCopyToNameFormatInput);
            Binder.Bind(_tbNameOutput, () => SdeAppConfiguration.CmdCopyToNameFormatOutput);

            WpfUtils.AddMouseInOutEffectsBox(_cbName);
            WpfUtils.AddMouseInOutEffectsBox(_cbAegisName);
            WpfUtils.AddMouseInOutEffectsBox(_cbOverwrite);
            WpfUtils.AddMouseInOutEffectsBox(_cbCopyClientItems);

            //ContextMenu menu = _createMenu(_tbAegisNameInput, _buttonAegisNameInput);
        }
예제 #20
0
        public string Execute(GDbTab core, string code)
        {
            MemoryStream stream = new MemoryStream();
            string       output = "";

            _core = core;
            Script script = new Script();

            try {
                TableHelper.EnableTupleTrace = true;

                if (_core == null)
                {
                    throw new Exception("No database tab selected.");
                }

                _selected = new ObservableList <Tuple>();

                foreach (var tuple in _core._listView.SelectedItems.OfType <Tuple>().OrderBy(p => p))
                {
                    _selected.Add(tuple);
                }

                _selectionChanged = false;

                _selected.CollectionChanged += delegate { _selectionChanged = true; };

                _mEngine.Runtime.IO.SetOutput(stream, EncodingService.DisplayEncoding);
                _mEngine.Runtime.IO.SetErrorOutput(stream, EncodingService.DisplayEncoding);

                _mScope = _mEngine.CreateScope();

                List <object> dbs = new List <object>();

                foreach (var serverDb in ServerDbs.ListDbs)
                {
                    var db = _core.DbComponent.TryGetDb(serverDb);

                    if (db != null)
                    {
                        if (db.AttributeList.PrimaryAttribute.DataType == typeof(int))
                        {
                            var adb = (AbstractDb <int>)db;
                            dbs.Add(adb);
                            TableHelper.Tables.Add(adb.Table);
                            _mScope.SetVariable(serverDb.Filename.ToLower().Replace(" ", "_"), adb.Table);
                        }
                        else if (db.AttributeList.PrimaryAttribute.DataType == typeof(string))
                        {
                            var adb = (AbstractDb <string>)db;
                            dbs.Add(adb);
                            TableHelper.Tables.Add(adb.Table);
                            _mScope.SetVariable(serverDb.Filename.ToLower().Replace(" ", "_"), adb.Table);
                        }
                    }
                }

                _mScope.SetVariable("item_db_m", _core.DbComponent.GetMeta <int>(ServerDbs.Items));
                _mScope.SetVariable("mob_db_m", _core.DbComponent.GetMeta <int>(ServerDbs.Mobs));
                _mScope.SetVariable("mob_skill_db_m", _core.DbComponent.GetMeta <string>(ServerDbs.MobSkills));
                _mScope.SetVariable("selection", _selected);
                _mScope.SetVariable("database", _core.ProjectDatabase);
                _mScope.SetVariable("script", script);

                //_mScope.SetVariable("ServerDbs", DynamicHelpers.GetPythonTypeFromType(typeof(ServerDbs)));
                _selectedDb = null;

                _to <int>(_core.DbComponent, p => {
                    _selectedDb = p.Table;
                    _mScope.SetVariable("selected_db", p.Table);
                });
                _to <string>(_core.DbComponent, p => {
                    _selectedDb = p.Table;
                    _mScope.SetVariable("selected_db", p.Table);
                });

                string temp = TemporaryFilesManager.GetTemporaryFilePath("python_script_{0:0000}.py");

                byte[]   file     = File.ReadAllBytes(code);
                Encoding encoding = EncodingService.DetectEncoding(file);

                using (StreamWriter writer = new StreamWriter(File.Create(temp), encoding))
                    using (StreamReader reader = new StreamReader(code)) {
                        writer.WriteLine("#!/usr/bin/env python");
                        writer.WriteLine("# -*- coding: {0} -*- ", encoding.CodePage);

                        while (!reader.EndOfStream)
                        {
                            string line = reader.ReadLine();

                            if (line == null)
                            {
                                continue;
                            }

                            writer.WriteLine(EncodingService.FromAnyTo(line, encoding));
                        }
                    }

                ScriptSource source = _mEngine.CreateScriptSourceFromFile(temp);

                foreach (var db in dbs)
                {
                    _to <int>(db, _onBegin);
                    _to <string>(db, _onBegin);
                }

                try {
                    try {
                        source.Execute(_mScope);
                    }
                    catch (OperationCanceledException) {
                    }

                    if (stream.Position > 0)
                    {
                        stream.Seek(0, SeekOrigin.Begin);
                        byte[] data = new byte[stream.Length];
                        stream.Read(data, 0, data.Length);

                        output = EncodingService.DisplayEncoding.GetString(data);
                        Clipboard.SetDataObject(EncodingService.DisplayEncoding.GetString(data));
                    }
                }
                catch {
                    foreach (var db in dbs)
                    {
                        _to <int>(db, p => p.Table.Commands.CancelEdit());
                        _to <string>(db, p => p.Table.Commands.CancelEdit());
                    }

                    throw;
                }
                finally {
                    foreach (var db in dbs)
                    {
                        _to <int>(db, _onEnd);
                        _to <string>(db, _onEnd);
                    }

                    stream.Close();
                    _core.Filter();
                    _core.Update();
                }
            }
            catch (Exception err) {
                ErrorHandler.HandleException(err);
            }
            finally {
                TableHelper.EnableTupleTrace = false;
                TableHelper.Tables.Clear();
            }

            return(output);
        }
예제 #21
0
        private void _selectInternal <TKey>(ServerDbs tabName, List <TKey> tuplesGen, bool changeTab)
        {
            try {
                lock (_lock) {
                    IsSelecting = true;

                    if (tabName.AdditionalTable == null)
                    {
                        TabItem item = _tab.Dispatch(() => _tab.Items.Cast <TabItem>().FirstOrDefault(p => p.Header.ToString() == tabName));

                        if (item is GDbTab)
                        {
                            GDbTab tab = (GDbTab)item;

                            var          table  = tab.To <TKey>().Table;
                            List <Tuple> tuples = tuplesGen.Select(table.TryGetTuple).Where(p => p != null).Select(p => (Tuple)p).ToList();

                            if (tuples.Count == 0)
                            {
                                if (changeTab)
                                {
                                    ErrorHandler.HandleException((tuplesGen.Count > 1 ? "Items do" : "Item does") + " not exist in [" + tabName.DisplayName + "].", ErrorLevel.NotSpecified);
                                }
                                return;
                            }

                            if (!_containsAny(tab, tuples))
                            {
                                tab.IgnoreFilterOnce();
                                tab.Filter();
                                _waitForFilter(tab);

                                if (!_containsAny(tab, tuples))
                                {
                                    if (changeTab)
                                    {
                                        ErrorHandler.HandleException((tuplesGen.Count > 1 ? "Items" : "Item") + " not found in [" + tabName.DisplayName + "]. Try clearing the search filter on the specified table.", ErrorLevel.NotSpecified);
                                    }
                                    return;
                                }
                            }

                            tab.Dispatch(p => p.IsSelected = true);
                            _waitForFilter(tab);
                            tab.Dispatch(p => p.SelectItems(tuples));
                        }
                        else
                        {
                            if (item == null)
                            {
                                return;
                            }

                            if (changeTab)
                            {
                                item.Dispatch(p => p.IsSelected = true);
                            }
                        }
                    }
                    else
                    {
                        TabItem item  = _tab.Dispatch(() => _tab.Items.Cast <TabItem>().FirstOrDefault(p => p.Header.ToString() == tabName));
                        TabItem item2 = _tab.Dispatch(() => _tab.Items.Cast <TabItem>().FirstOrDefault(p => p.Header.ToString() == tabName.AdditionalTable));

                        if (item is GDbTab && item2 is GDbTab)
                        {
                            GDbTab tab  = (GDbTab)item;
                            GDbTab tab2 = (GDbTab)item2;

                            var          table   = tab.To <TKey>().Table;
                            var          table2  = tab2.To <TKey>().Table;
                            List <Tuple> tuples  = tuplesGen.Select(table.TryGetTuple).Where(p => p != null).Select(p => (Tuple)p).ToList();
                            List <Tuple> tuples2 = tuplesGen.Select(table2.TryGetTuple).Where(p => p != null).Select(p => (Tuple)p).ToList();

                            if (tuples.Count == 0 && tuples2.Count == 0)
                            {
                                if (changeTab)
                                {
                                    ErrorHandler.HandleException((tuplesGen.Count > 1 ? "Items do" : "Item does") + " not exist in either [" + tabName.DisplayName + "] or [" + tabName.AdditionalTable.DisplayName + "].", ErrorLevel.NotSpecified);
                                }
                                return;
                            }

                            if (!_containsAny(tab, tuples))
                            {
                                tab.IgnoreFilterOnce();
                                tab.Filter();
                                _waitForFilter(tab);
                            }

                            if (!_containsAny(tab2, tuples))
                            {
                                tab2.IgnoreFilterOnce();
                                tab2.Filter();
                                _waitForFilter(tab2);
                            }

                            if (!_containsAny(tab, tuples) && !_containsAny(tab2, tuples2))
                            {
                                if (!_containsAny(tab, tuples) && !_containsAny(tab2, tuples2))
                                {
                                    if (changeTab)
                                    {
                                        ErrorHandler.HandleException((tuplesGen.Count > 1 ? "Items" : "Item") + " not found in either [" + tabName.DisplayName + "] or [" + tabName.AdditionalTable.DisplayName + "], but . Try clearing the search filter on the specified table.", ErrorLevel.NotSpecified);
                                    }
                                    return;
                                }
                            }

                            GDbTab tabToSelect = _containsAny(tab2, tuples2) ? tab2 : tab;

                            if (changeTab)
                            {
                                tabToSelect.Dispatch(p => p.IsSelected = true);
                            }

                            _waitForFilter(tabToSelect);
                            tabToSelect.Dispatch(p => p.SelectItems(tabToSelect == tab ? tuples : tuples2));
                        }
                        else
                        {
                            if (item == null)
                            {
                                return;
                            }
                            if (changeTab)
                            {
                                item.Dispatch(p => p.IsSelected = true);
                            }
                        }
                    }
                }
            }
            catch {
            }
            finally {
                IsSelecting = false;
            }
        }
예제 #22
0
		public SelectionChanged(string tabName, object tuple, ListView view, GDbTab tab) {
			_tabName = tabName;
			_tuple = tuple;
			_view = view;
			_tab = tab;
		}