/// <summary> /// Shows the file exists drag and drop dialog. /// </summary> /// <returns></returns> /// <remarks>Documented by Dev08, 2009-03-02</remarks> private TaskDialogResult ShowFileExistsDragAndDropDialog() { EmulatedTaskDialog dialog = new EmulatedTaskDialog(); dialog.Title = Resources.DRAG_FILE_EXISTS_TITLE; dialog.MainInstruction = Resources.DRAG_LM_EXISTS_DIALOG_MAININTRODUCTION; dialog.Content = string.Empty; dialog.CommandButtons = Resources.DRAG_LM_EXISTS_DIALOG_BUTTONS; dialog.Buttons = TaskDialogButtons.None; dialog.MainIcon = TaskDialogIcons.Question; dialog.MainImages = new Image[] { Resources.edit_find_replace, Resources.MLIcon32, Resources.process_stop }; dialog.HoverImages = new Image[] { Resources.edit_find_replace, Resources.MLIcon32, Resources.process_stop }; dialog.CenterImages = true; dialog.BuildForm(); DialogResult dialogResult = dialog.ShowDialog(); TaskDialogResult result = new TaskDialogResult(); result.CommandButtonsIndex = dialog.CommandButtonClickedIndex; return result; }
/// <summary> /// Shows the resize dialog. /// </summary> /// <returns></returns> /// <remarks>Documented by Dev05, 2007-11-29</remarks> private TaskDialogResult ShowResizeDialog() { EmulatedTaskDialog dialog = new EmulatedTaskDialog(); dialog.Title = Resources.CARD_EDIT_RESIZE_TITLE; dialog.MainInstruction = Resources.CARD_EDIT_RESIZE_TEXT; dialog.Content = Resources.CARD_EDIT_RESIZE_DESCRIPTION; dialog.CommandButtons = string.Format(Resources.CARD_EDIT_RESIZE_BUTTONS, new object[] { Settings.Default.resizeSmall.Width, Settings.Default.resizeSmall.Height, Settings.Default.resizeMedium.Width, Settings.Default.resizeMedium.Height, Settings.Default.resizeLarge.Width, Settings.Default.resizeLarge.Height }); dialog.VerificationText = Resources.CARD_EDIT_RESIZE_CHECKBOX; dialog.VerificationCheckBoxChecked = true; dialog.Buttons = TaskDialogButtons.Cancel; dialog.MainIcon = TaskDialogIcons.Question; dialog.FooterIcon = TaskDialogIcons.Warning; dialog.MainImages = new Image[] { Resources.resizeS, Resources.resizeM, Resources.resizeL, Resources.resize }; dialog.HoverImages = new Image[] { Resources.resizeS, Resources.resizeM, Resources.resizeL, Resources.resize }; dialog.CenterImages = true; dialog.BuildForm(); DialogResult dialogResult = dialog.ShowDialog(); if (dialog.VerificationCheckBoxChecked && dialogResult != DialogResult.Cancel) { changingCheckstate = true; checkBoxResizeAnswer.Checked = (dialog.CommandButtonClickedIndex < 3); checkBoxResizeQuestion.Checked = (dialog.CommandButtonClickedIndex < 3); changingCheckstate = false; } TaskDialogResult result = new TaskDialogResult(); result.CommandButtonsIndex = dialog.CommandButtonClickedIndex; result.VerificationChecked = dialog.VerificationCheckBoxChecked; return result; }
/// <summary> /// GUI logic for Drag and Drop /// </summary> /// <param name="file">The file.</param> /// <remarks>Documented by Dev08, 2009-03-02</remarks> public void DoDragAndDrop(string file) { bool draggedLearningModuleIsOpen = false; string appConfigFile = Setup.GlobalConfigPath; string usrConfigFile = Setup.UserConfigPath; ConnectionStringHandler handler = new ConnectionStringHandler(appConfigFile, usrConfigFile); IConnectionString defaultConString = handler.ConnectionStrings.Find(c => c.IsDefault || c.ConnectionType == DatabaseType.Unc); TaskDialogResult result; //No default connection available if (defaultConString == null) { TaskDialog.MessageBox(Resources.DRAG_NO_DEFAULT_CONNECTION_AVAILABLE_TITLE, Resources.DRAG_NO_DEFAULT_CONNECTION_AVAILABLE_MAININTRODUCTION, Resources.DRAG_NO_DEFAULT_CONNECTION_AVAILABLE_CONTENT, TaskDialogButtons.OK, TaskDialogIcons.Error); return; } //User draged a LM from a available UNC connection to the ML else if (ConnectionStringHandler.IsFileInUncConnection(file, appConfigFile, usrConfigFile)) //(Path.GetDirectoryName(file) == defaultConString.ConnectionString) { OpenLearningModule(file); return; } //File already exists else if (File.Exists(Path.Combine(defaultConString.ConnectionString, Path.GetFileName(file)))) { //User draged the LM which is currently opened into MemoryLifter. (only possible while user is learning) //[Check if the future place of the LM is currently opened (e.g. the older LM is open)] if (LearnLogic != null && LearnLogic.CurrentLearningModule != null && LearnLogic.CurrentLearningModule.ConnectionString.ConnectionString == Path.Combine(defaultConString.ConnectionString, Path.GetFileName(file))) draggedLearningModuleIsOpen = true; TaskDialogResult resultFileExists = ShowFileExistsDragAndDropDialog(); switch (resultFileExists.CommandButtonsIndex) { // Replace case 0: if (draggedLearningModuleIsOpen) { if (!LearnLogic.CloseLearningModule()) return; } try { ConnectionStringHandler.PutLearningModuleToDefaultUNC(file, defaultConString.ConnectionString, false, true); } catch (Exception exc) { TaskDialog.MessageBox(Resources.DRAG_COPY_ERROR_TITLE, Resources.DRAG_COPY_ERROR_MAININTRODUCTION, exc.Message, exc.ToString(), string.Empty, string.Empty, TaskDialogButtons.OK, TaskDialogIcons.Error, TaskDialogIcons.Error); } OpenLearningModule(Path.Combine(defaultConString.ConnectionString, Path.GetFileName(file))); break; //Just learn case 1: OpenLearningModule(file); break; //Cancel case 2: default: break; } return; } else if (Path.GetExtension(file) == Helper.DzpExtension) result = new TaskDialogResult() { CommandButtonsIndex = 2, VerificationChecked = false }; else result = ShowDefaultDragAndDropDialog(); //User draged the LM which is currently opened into MemoryLifter. (only possible while user is learning) //[Check if currently ] if (LearnLogic != null && LearnLogic.CurrentLearningModule != null && LearnLogic.CurrentLearningModule.ConnectionString.ConnectionString == file) draggedLearningModuleIsOpen = true; switch (result.CommandButtonsIndex) { //Copy case 0: try { ConnectionStringHandler.PutLearningModuleToDefaultUNC(file, defaultConString.ConnectionString, false); } catch (Exception exc) { TaskDialog.MessageBox(Resources.DRAG_COPY_ERROR_TITLE, Resources.DRAG_COPY_ERROR_MAININTRODUCTION, exc.Message, exc.ToString(), string.Empty, string.Empty, TaskDialogButtons.OK, TaskDialogIcons.Error, TaskDialogIcons.Error); } OpenLearningModule(Path.Combine(defaultConString.ConnectionString, Path.GetFileName(file))); break; //Move case 1: if (draggedLearningModuleIsOpen) { if (!LearnLogic.CloseLearningModule()) return; } try { ConnectionStringHandler.PutLearningModuleToDefaultUNC(file, defaultConString.ConnectionString, true); } catch (Exception exc) { TaskDialog.MessageBox(Resources.DRAG_COPY_ERROR_TITLE, Resources.DRAG_COPY_ERROR_MAININTRODUCTION, exc.Message, exc.ToString(), string.Empty, string.Empty, TaskDialogButtons.OK, TaskDialogIcons.Error, TaskDialogIcons.Error); } OpenLearningModule(Path.Combine(defaultConString.ConnectionString, Path.GetFileName(file))); break; //Just open case 2: OpenLearningModule(file); break; //Cancel case 3: default: break; } }