Пример #1
0
 private void _commandChanged2(object sender, IGenericDbCommand command)
 {
     if (_tab.List.SelectedItem != null)
     {
         _lv_SelectionChanged(null, null);
     }
 }
Пример #2
0
        private void _commandChanged2(object sender, IGenericDbCommand command)
        {
            if (_tab.List.SelectedItem != null && _selectedItem != null)
            {
                ItemView itemView = (ItemView)_selectedItem;

                if (_lv.ItemsSource != null)
                {
                    _lv.Dispatch(p => p.SelectedItem = ((RangeObservableCollection <ItemView>)_lv.ItemsSource).FirstOrDefault(q => q.ID == itemView.ID));
                }

                if (_lv.SelectedItem != null)
                {
                    if (!((ItemView)_lv.SelectedItem).Exists())
                    {
                        return;
                    }

                    ((ItemView)_lv.SelectedItem).VisualUpdate();
                    _lv.ScrollToCenterOfView(_lv.SelectedItem);
                }

                _lv_SelectionChanged(null, null);
            }
        }
Пример #3
0
 private void _previewCommandChanged2(object sender, IGenericDbCommand command)
 {
     if (_lv.SelectedItem != null)
     {
         _selectedItem = _lv.SelectedItem;
     }
 }
Пример #4
0
 private void _commands_CommandIndexChanged(object sender, IGenericDbCommand command)
 {
     _tab.BeginDispatch(delegate {
         if (_tab.List.SelectedItem != null)
         {
             _update(_tab.List.SelectedItem as TValue);
         }
     });
 }
        public static void ValidateUndo(GDbTabWrapper <TKey, TValue> tab, string text, DbAttribute attribute)
        {
            try {
                if (tab.List.SelectedItem != null && !tab.ItemsEventsDisabled)
                {
                    TValue tuple = (TValue)tab.List.SelectedItem;
                    ITableCommand <TKey, TValue> command = tab.Table.Commands.Last();

                    if (command is ChangeTupleProperty <TKey, TValue> )
                    {
                        ChangeTupleProperty <TKey, TValue> changeCommand = (ChangeTupleProperty <TKey, TValue>)command;
                        IGenericDbCommand last = tab.GenericDatabase.Commands.Last();

                        if (last != null)
                        {
                            if (last is GenericDbCommand <TKey> )
                            {
                                GenericDbCommand <TKey> nLast = (GenericDbCommand <TKey>)last;

                                if (ReferenceEquals(nLast.Table, tab.Table))
                                {
                                    // The last command of the table is being edited

                                    if (changeCommand.Tuple != tuple || changeCommand.Attribute.Index != attribute.Index)
                                    {
                                        //tab.Table.Commands.Set(tuple, attribute, text);
                                    }
                                    else
                                    {
                                        changeCommand.NewValue = text;
                                        changeCommand.Execute(tab.Table);

                                        if (changeCommand.NewValue.ToString() == changeCommand.OldValue.ToString())
                                        {
                                            nLast.Undo();
                                            tab.GenericDatabase.Commands.RemoveCommands(1);
                                            tab.Table.Commands.RemoveCommands(1);
                                        }

                                        return;
                                    }
                                }
                            }
                        }

                        tab.Table.Commands.Set(tuple, attribute, text);
                    }
                    else
                    {
                        tab.Table.Commands.Set(tuple, attribute, text);
                    }
                }
            }
            catch (Exception err) {
                ErrorHandler.HandleException(err);
            }
        }
Пример #6
0
        private void _validateUndo(GDbTabWrapper <TKey, ReadableTuple <TKey> > tab, string text, DbAttribute attribute)
        {
            try {
                if (tab.List.SelectedItem != null && !tab.ItemsEventsDisabled && _lv.SelectedItem != null)
                {
                    ReadableTuple <TKey> tuple = (ReadableTuple <TKey>)tab.List.SelectedItem;
                    int tupleKey = ((ItemView)_lv.SelectedItem).ID;

                    ITableCommand <TKey, ReadableTuple <TKey> > command = tab.Table.Commands.Last();

                    if (command is ChangeTupleDicoProperty <TKey, ReadableTuple <TKey>, TKey, ReadableTuple <TKey> > )
                    {
                        ChangeTupleDicoProperty <TKey, ReadableTuple <TKey>, TKey, ReadableTuple <TKey> > changeCommand = (ChangeTupleDicoProperty <TKey, ReadableTuple <TKey>, TKey, ReadableTuple <TKey> >)command;
                        IGenericDbCommand last = tab.GenericDatabase.Commands.Last();

                        if (last != null)
                        {
                            if (last is GenericDbCommand <TKey> )
                            {
                                GenericDbCommand <TKey> nLast = (GenericDbCommand <TKey>)last;

                                if (ReferenceEquals(nLast.Table, tab.Table))
                                {
                                    // The last command of the table is being edited

                                    if (changeCommand.Tuple != tuple || tupleKey != (int)(object)changeCommand.DicoKey || changeCommand.Attribute.Index != attribute.Index)
                                    {
                                        //tab.Table.Commands.Set(tuple, attribute, text);
                                    }
                                    else
                                    {
                                        ItemView itemView = ((ItemView)_lv.SelectedItem);

                                        changeCommand.NewValue.SetValue(attribute, text);
                                        changeCommand.Execute(tab.Table);

                                        if (changeCommand.NewValue.CompareWith(changeCommand.InitialValue))
                                        {
                                            nLast.Undo();
                                            tab.GenericDatabase.Commands.RemoveCommands(1);
                                            tab.Table.Commands.RemoveCommands(1);
                                            //changeCommand.InitialValue.Modified = changeCommand.SubModified;
                                            _lv.Dispatch(p => p.SelectedItem = ((RangeObservableCollection <ItemView>)_lv.ItemsSource).FirstOrDefault(q => q.ID == itemView.ID));
                                        }

                                        itemView.VisualUpdate();
                                        return;
                                    }
                                }
                            }
                        }

                        _setSelectedItem(attribute, text);
                    }
                    else
                    {
                        _setSelectedItem(attribute, text);
                    }
                }
            }
            catch (Exception err) {
                ErrorHandler.HandleException(err);
            }
        }