public void AddFirstFieldToList(Note note) { string fieldName = note.Model["flds"].GetArray().GetObjectAt(0).GetNamedString("name");; NoteField firstField = new NoteField(note.Id, fieldName, 0, HtmlEditor.RemoveDivWrap(note.Fields[0]).Trim()); FirstFields.Insert(0, firstField); }
private void ValidateField(NoteValue e, NoteField noteField) { // required if (noteField.Required && e.Value == "") { throw new AppException(string.Format("Field '{0}' is required.", noteField.Title)); } // types if (e.Value == "") // return if there is no value to be converted { return; } if ((noteField.Type == "datetime" || noteField.Type == "date") && !DateTime.TryParse(e.Value, out _)) { throw new AppException(String.Format("Field '{0}' does not contain a valid date.", noteField.Title)); } if ((noteField.Type == "boolean" || noteField.Type == "bool") && !bool.TryParse(e.Value, out _)) { throw new AppException(String.Format("Field '{0}' does not contain a valid bool.", noteField.Title)); } if (noteField.Type == "number" && !double.TryParse(e.Value, out _)) { throw new AppException(String.Format("Field '{0}' does not contain a valid number.", noteField.Title)); } }
public void RemoveFirstFieldFromList(NoteField note) { for (int i = 0; i < FirstFields.Count; i++) { if (FirstFields[i].Content == note.Content) { FirstFields.RemoveAt(i); } } }
private static Control CreateNoteFieldControl(SPField field, SPList list, SPListItem item, SPControlMode mode) { NoteField nf = new NoteField(); nf.ListId = list.ID; nf.ItemId = item.ID; nf.FieldName = field.Title; nf.ID = field.Title; nf.ControlMode = mode; return(nf); }
public NoteFieldsViewModel(JsonObject model) { List <NoteField> temp = new List <NoteField>(); foreach (var json in model.GetNamedArray("flds")) { var field = json.GetObject(); NoteField f = new NoteField(); f.Order = (int)field.GetNamedNumber("ord"); f.Name = field.GetNamedString("name"); temp.Add(f); } Fields = new ObservableCollection <NoteField>(temp); }
private async Task RenameField(object sender) { await CoreWindow.GetForCurrentThread().Dispatcher.RunAsync(CoreDispatcherPriority.Normal, () => { fieldToRename = (sender as Button).DataContext as NoteField; fieldListView.Hide(); if (renameFieldFlyout == null) { renameFieldFlyout = new NameEnterFlyout(); renameFieldFlyout.OkButtonClickEvent += RenameFieldFlyoutOkButtonClickEventHandler; } renameFieldFlyout.Show(editModelButton, fieldToRename.Name); }); }
public MultiNoteFieldsSelectViewModel(IEnumerable <JsonObject> models) { //Use dictionary to ensure unique field name Dictionary <NoteField, bool> temp = new Dictionary <NoteField, bool>(); foreach (var model in models) { foreach (var json in model.GetNamedArray("flds")) { var field = json.GetObject(); NoteField f = new NoteField(); f.Order = (int)field.GetNamedNumber("ord"); f.Name = field.GetNamedString("name"); temp[f] = true; } } Fields = new ObservableCollection <NoteField>(temp.Keys); }
private async Task DeleteField(object sender) { NoteField field = (sender as Button).DataContext as NoteField; fieldListView.Hide(); var noteCount = collection.Models.NoteUseCount(currentNote.Model); bool isContinue = await UIHelper.AskUserConfirmation(String.Format(UIConst.WARN_DELETE_FIELD, noteCount)); if (!isContinue) { return; } var model = currentNote.Model; var fieldJson = model.GetNamedArray("flds").GetObjectAt((uint)field.Order); collection.Models.RemoveField(model, fieldJson); currentNote = collection.NewNote(); await noteFieldView.DeleteField(field.Name, field.Order, currentNote); SavePrefs(); }
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(); } }
private void FieldButtonClick(object sender, RoutedEventArgs e) { var buttonShowMenu = sender as Button; fieldShowMenu = buttonShowMenu.DataContext as NoteField; }