private void rotateThroughSaveDialog(int direction) { object val = Convert.ChangeType(saveMenu, saveMenu.GetTypeCode()); int m = Convert.ToInt32(val); // should not rotate to UNKOWN = 0 if (direction == -1) { if (m == 1) { m = _maxSaveMode; } else { m--; } } else { m = Math.Max(1, (++m) % (_maxSaveMode + 1)); } saveMenu = (SaveDialog)Enum.ToObject(typeof(SaveDialog), m); comunicateSaveDialogSwitch(saveMenu); }