private void Application_Startup(object sender, EventArgs e) { settings = ReeeportSettings.SettingsReader(settingsPath); sheetHandler = null; driveHandler = null; NoteType.ItemsSource = settings.NoteTypesArr; NoteType.SelectedIndex = 0; MainWindow mw = this; mw.Topmost = settings.AlwaysOnTop; }
private void NoteFiled_KeyDown(object sender, KeyEventArgs e) { if (e.Key == Key.Enter && e.KeyboardDevice.Modifiers == ModifierKeys.Control) { Note note = new Note(NoteType.Text, NoteField.Text, draggedFiles.ToArray()); sheetHandler = sheetHandler == null ? new GoogleHandlerSheet() : sheetHandler; driveHandler = driveHandler == null ? new GoogleHandlerDrive() : driveHandler; try { if (note.AttachedFiles != null && note.AttachedFiles.Length > 0) { string driveSubFolderId = driveHandler.CreateFolder(note.Id, settings.DriveFolderID); sheetHandler.AppendToSheet(note, settings.SpreadsheetID, settings.SheetRange, "=HYPERLINK(\"https://drive.google.com/drive/u/0/folders/" + driveSubFolderId + "\"" + ", \"Attachments\")"); foreach (var file in note.AttachedFiles) { driveHandler.UploadFile(file, driveSubFolderId); } } else { sheetHandler.AppendToSheet(note, settings.SpreadsheetID, settings.SheetRange, ""); } } catch (Exception) { MessageBox.Show("Something went wrong, and unfortunately we have no idea what exactly, since this this message handles every possible wrong scenario.\n\nPlease, check following:\n • Google Spreadsheet URL and Sheet Name are correct.\n • Internet connection is fine.\n", "Cannot Write to Google Drive"); } draggedFiles.Clear(); NoteField.Clear(); } }