private void _copyTo(TValue item) { try { if (item == null) { return; } TKey id = _getNewItemId(item.GetKey <TKey>(), true); TKey oldId = item.GetValue <TKey>(Settings.AttributeList.PrimaryAttribute); if (Table.ContainsKey(id)) { if (WindowProvider.ShowDialog("An item with this ID already exists (\"" + Table.TryGetTuple(id)[Settings.AttDisplay.Index].ToString().RemoveBreakLines() + "\"). Do you want to replace it?", "Item already exists", MessageBoxButton.YesNoCancel) != MessageBoxResult.Yes) { return; } } Table.Commands.StoreAndExecute(new CopyTupleTo <TKey, TValue>(oldId, id, _copyToCallback)); } catch (KeyInvalidException) { } catch (Exception err) { ErrorHandler.HandleException(err); } }
private bool _validateNewContainer() { try { if (!_validateState()) { return(false); } if (_cache.Commands.IsModified) { MessageBoxResult res = WindowProvider.ShowDialog("The map cache has been modified, do you want to save it first?", "Modified map cache", MessageBoxButton.YesNoCancel); if (res == MessageBoxResult.Yes) { _menuItemSaveAs_Click(null, null); return(false); } if (res == MessageBoxResult.Cancel) { return(false); } } } catch { return(true); } return(true); }
protected override void OnClosing(CancelEventArgs e) { try { if (_cache != null && _cache.Commands.IsModified) { MessageBoxResult res = WindowProvider.ShowDialog("The map cache has been modified, do you want to save it first?", "Modified map cache", MessageBoxButton.YesNoCancel); if (res == MessageBoxResult.Yes) { _menuItemSaveAs_Click(null, null); e.Cancel = true; return; } if (res == MessageBoxResult.Cancel) { e.Cancel = true; return; } } ApplicationManager.Shutdown(); base.OnClosing(e); } catch (Exception err) { try { ErrorHandler.HandleException("The application hasn't ended properly. Please report this issue.", err); } catch { } } }
public bool ShouldCancelDbReload() { if (_clientDatabase.IsModified) { MessageBoxResult result = WindowProvider.ShowDialog("The database has been modified, would you like to save it first?", "Modified database", MessageBoxButton.YesNoCancel); if (result == MessageBoxResult.Yes || result == MessageBoxResult.Cancel) { return(true); } } _clientDatabase.IsModified = false; return(false); }
private void _copyTo(TValue item) { try { if (item == null) { return; } if (typeof(TKey) == typeof(string)) { if ((DbComponent.DbSource & ServerDbs.MobSkillsItems) != 0) { TKey old = item.GetValue <TKey>(Settings.AttributeList.PrimaryAttribute); string newId = (string)(object)old + Methods.RandomString(30); Table.Commands.CopyTupleTo(old, (TKey)(object)newId, _copyToCallback); return; } } TKey id = _getNewItemId(item.GetKey <TKey>(), true); TKey oldId = item.GetValue <TKey>(Settings.AttributeList.PrimaryAttribute); if (Table.ContainsKey(id)) { if (WindowProvider.ShowDialog("An item with this ID already exists (\"" + Table.TryGetTuple(id)[Settings.AttDisplay.Index].ToString().RemoveBreakLines() + "\"). Do you want to replace it?", "Item already exists", MessageBoxButton.YesNoCancel) != MessageBoxResult.Yes) { return; } } if (DbComponent.DbSource == ServerDbs.MobGroups || DbComponent.DbSource == ServerDbs.ItemGroups) { throw new InvalidOperationException("DicoCopyTo is not supported."); } Table.Commands.CopyTupleTo(oldId, id, _copyToCallback); } catch (KeyInvalidException) { } catch (Exception err) { ErrorHandler.HandleException(err); } }
private void _changeId(object selectedItem) { if (!Settings.CanChangeId) { ErrorHandler.HandleException("This type of database does not support identifiers edit."); return; } TValue item = (TValue)selectedItem; if (item == null) { ErrorHandler.HandleException("No item has been selected.", ErrorLevel.NotSpecified); return; } try { TKey id = _getNewItemId(item.GetKey <TKey>(), true); if (Table.ContainsKey(id)) { if (WindowProvider.ShowDialog("An item with this ID already exists. Would you like to replace it?", "ID already exists", MessageBoxButton.YesNoCancel) == MessageBoxResult.Yes) { try { Table.Commands.Begin(); Table.Commands.Delete(id); Table.Commands.ChangeKey(item.GetValue <TKey>(Settings.AttributeList.PrimaryAttribute), id, _changeKeyCallback); _listView.ScrollToCenterOfView(_listView.SelectedItem); } finally { Table.Commands.End(); } } return; } Table.Commands.ChangeKey(item.GetValue <TKey>(Settings.AttributeList.PrimaryAttribute), id, _changeKeyCallback); _listView.ScrollToCenterOfView(_listView.SelectedItem); } catch (KeyInvalidException) { } catch (Exception err) { ErrorHandler.HandleException(err); } }