public frmSelectFile(string folder, SelectFileMode mode) { SelectFile(folder, mode, false); }
/// <summary> /// Initiation method /// </summary> /// <param name="folder"></param> /// <param name="mode"></param> /// <param name="newPoll"></param> private void SelectFile(string folder, SelectFileMode mode, bool newPoll) { Cursor.Current = Cursors.WaitCursor; InitializeComponent(); OpenMode = mode; // Make available throughout module PollName = ""; // Initialize public variable FileFolder = Tools.EnsureFullPath(folder); FullPathInfo = new ArrayList(); if (mode == SelectFileMode.RunPoll) { labelInstructions.Text = (newPoll) ? "Which poll would you like to run:" : "Which poll would you like to resume:"; NewPoll = newPoll; // Make available throughout module // Set visibility of Respondent info depending on setting of 'newPoll' labelRespondents.Visible = !newPoll; textBoxRespondents.Visible = !newPoll; string[] availFiles = Directory.GetFiles(folder, "*" + Tools.GetAppExt()); if (availFiles.Length > 0) { OkayToShow = true; Array.Sort(availFiles); PopulateFileList(availFiles); Cursor.Current = Cursors.Default; this.BringToFront(); } else { string caption = ""; string msg = ""; if (newPoll) { caption = "No Available Templates"; msg = "There are no poll templates available. You first need to sync your mobile device to obtain the current set of templates."; } else { caption = "No Polls Available"; msg = "There are no previous polls available to open. You must start a new poll."; } OkayToShow = false; PollName = ""; // Need to reset before leaving Cursor.Current = Cursors.Default; Tools.ShowMessage(msg, caption, MessageBoxButtons.OK, MessageBoxIcon.Exclamation); } } else // Must be 'ReviewData' { labelInstructions.Text = "Which poll would you like to review:"; // Prepare ImageList of icons to differentiate different kinds of files listBoxFiles.ImageList = new ImageList(); Icon icon = Multimedia.Images.GetIcon("ReviewPoll0q"); // 0 - Blank icon (for no questions) listBoxFiles.ImageList.Images.Add(icon); icon = Multimedia.Images.GetIcon("ReviewPoll0r"); // 1 - Blank icon (for no respondents) listBoxFiles.ImageList.Images.Add(icon); icon = Multimedia.Images.GetIcon("ReviewPoll1"); // 2 - Green triangle (like a "spare" in bowling) listBoxFiles.ImageList.Images.Add(icon); icon = Multimedia.Images.GetIcon("ReviewPoll2"); // 3 - Blue square (like a "strike" in bowling) listBoxFiles.ImageList.Images.Add(icon); icon = Multimedia.Images.GetIcon("ReviewPoll3"); // 4 - Red circle with line through it listBoxFiles.ImageList.Images.Add(icon); // There may be files to review in either the 'Data' or 'Completed' folders, // so we need to examine both. In the listbox, we'll represent each type // with a different kind of symbol. string filter = "*" + Tools.GetAppExt(); string[] availFiles = Directory.GetFiles(folder, filter); // Data folder string[] availFiles2 = Directory.GetFiles(FileFolder + "Completed", filter); // Completed sub-folder if (availFiles.Length + availFiles2.Length > 0) { OkayToShow = true; if (availFiles.Length > 0) { Array.Sort(availFiles); PopulateFileList(availFiles, 2); // Display with green triangle } if (availFiles2.Length > 0) { Array.Sort(availFiles2); PopulateFileList(availFiles2, 3); // Display with blue square } Cursor.Current = Cursors.Default; this.BringToFront(); } else { string caption = "No Polls Available"; string msg = "There are no previous polls available to review."; OkayToShow = false; PollName = ""; // Need to reset before leaving Cursor.Current = Cursors.Default; Tools.ShowMessage(msg, caption, MessageBoxButtons.OK, MessageBoxIcon.Exclamation); } } InitializeScreen(); // This must be at the end or for some reason the listBoxFiles height doesn't "stick" this.Resize += new System.EventHandler(this.frmSelectFile_Resize); }
private SelectFileMode OpenMode; // Set by the 'mode' parameter, passed to the constructor /// <summary> /// Constructors /// </summary> /// <param name="folder"></param> /// <param name="mode"></param> true - Open to Add to false - Open for Review /// <param name="newPoll"></param> public frmSelectFile(string folder, SelectFileMode mode, bool newPoll) { SelectFile(folder, mode, newPoll); }