/// <summary> /// UpdateNotes this instance /// </summary> public async void UpdateNotes() { string uid = DependencyService.Get <IFirebaseAuthenticator>().User(); Note note = await this.notesRepository.GetNoteByKeyAsync(this.noteKeys, uid); editor.Text = note.Title; editorNote.Text = note.Notes; lists = note.LabelsList; // note.noteType = NoteType.isCollaborated; //var notesss = note.noteType; this.BackgroundColor = Color.FromHex(FrameColorSetter.GetHexColor(note)); ToolbarItems.Clear(); if (note.noteType == NoteType.isNote) { ToolbarItems.Add(this.archived); ToolbarItems.Add(this.alaram); ToolbarItems.Add(this.pincard); } else if (note.noteType == NoteType.isArchive) { ToolbarItems.Add(this.unarchived); ToolbarItems.Add(this.alaram); ToolbarItems.Add(this.pincard); } else if (note.noteType == NoteType.isTrash) { ToolbarItems.Add(this.deleted); ToolbarItems.Add(this.Restoredata); } else if (note.noteType == NoteType.ispin) { ToolbarItems.Add(this.PinCard1); } }
/// <summary> /// Edit the note data. /// </summary> public async void EditNoteData() { try { var uid = DependencyService.Get <IDatabaseInterface>().GetId(); ////Get note data of specified key var note = await this.FirebaseHelperVar.GetUserNote(this.noteKey); TitleText.Text = note.Title; NoteText.Text = note.UserNote; var placemarks = await Geocoding.GetPlacemarksAsync(note.NoteLocation.Latitude, note.NoteLocation.Longitude); var placemark = placemarks?.FirstOrDefault(); Location.Text = "Note created at " + placemark.AdminArea; list = note.LabelsList; //labelsList.ItemsSource = lists; this.CurrentNotetype = note.NoteType; this.BackgroundColor = Color.FromHex(FrameColorSetter.GetHexColor(note)); ToolbarItems.Clear(); if (note.NoteType == NoteType.isNote) { ToolbarItems.Add(this.PinnedNote); ToolbarItems.Add(this.ReminderNote); ToolbarItems.Add(this.ArchiveNote); } else if (note.NoteType == NoteType.isArchive) { ToolbarItems.Add(this.PinnedNote); ToolbarItems.Add(this.ReminderNote); ToolbarItems.Add(this.UnArchiveNote); } else if (note.NoteType == NoteType.ispin) { ToolbarItems.Add(this.UnPinNote); } } catch (Exception ex) { Console.WriteLine(ex.Message); } }
/// <summary> /// Edit the note data. /// </summary> public async void EditNoteData() { try { //// get the note data var note = await this.FirebaseHelperVar.GetUserNote(this.NoteKey); TitleText.Text = note.Title; NoteText.Text = note.UserNote; Lists = note.LabelsList; List1 = note.CollaboratosList; this.CurrentNotetype = note.NoteType; this.BackgroundColor = Color.FromHex(FrameColorSetter.GetHexColor(note)); ToolbarItems.Clear(); if (note.NoteType == NoteType.isNote) { ToolbarItems.Add(this.PinnedNote); ToolbarItems.Add(this.ReminderNote); ToolbarItems.Add(this.ArchiveNote); } else if (note.NoteType == NoteType.isArchive) { ToolbarItems.Add(this.PinnedNote); ToolbarItems.Add(this.ReminderNote); ToolbarItems.Add(this.UnArchiveNote); } else if (note.NoteType == NoteType.ispin) { ToolbarItems.Add(this.UnPinNote); } } catch (Exception ex) { Console.WriteLine(ex.Message); } }
/// <summary> /// Notes the grid for others. /// </summary> /// <param name="otherList">The other list.</param> private async void NoteGridForOthers(IList <Note> otherList) { var allLabels = await this.LabelHelper.GetAllLabels(); var allCollaboratos = await this.CollaboratorRepo.GetAllcollaborators(); var index = -1; try { //// for arranging two notes in one single row OthersGridLayout.ColumnDefinitions.Add(new ColumnDefinition { Width = new GridLength(170) }); OthersGridLayout.ColumnDefinitions.Add(new ColumnDefinition { Width = new GridLength(170) }); OthersGridLayout.Margin = 5; //// to count rows int rows = 0; //// when notes are added in single row then create new row definitions for (int rowindex = 0; rowindex < otherList.Count; rowindex++) { if (rowindex % 2 == 0) { //// add row OthersGridLayout.RowDefinitions.Add(new RowDefinition { Height = new GridLength(2, GridUnitType.Auto) }); //// increment row count rows++; } } for (int rowindex = 0; rowindex < rows; rowindex++) { for (int colindex = 0; colindex < 2; colindex++) { Note notedata = null; index++; if (index < otherList.Count) { notedata = otherList[index]; } //// add new label to the title var labelTitle = new Label { Text = notedata.Title, TextColor = Color.Black, FontAttributes = FontAttributes.Bold, FontSize = 15, VerticalOptions = LayoutOptions.Center, HorizontalOptions = LayoutOptions.Start, }; //// create new label to set identifier var labelId = new Label { Text = notedata.Key, IsVisible = false }; //// create the label to display the detail of note var labelUserNote = new Label { Text = notedata.UserNote, TextColor = Color.Black, VerticalOptions = LayoutOptions.Start, HorizontalOptions = LayoutOptions.Start, }; //// add stacklayout StackLayout stackLayout = new StackLayout() { Spacing = 2, Margin = 2, BackgroundColor = notedata.NoteColor }; //// add labels into stacklayout stackLayout.Children.Add(labelId); stackLayout.Children.Add(labelTitle); stackLayout.Children.Add(labelUserNote); //// create instance var tapGestureRecognizer = new TapGestureRecognizer(); //// adding instance of recognizer into stacklayout stackLayout.GestureRecognizers.Add(tapGestureRecognizer); //// create frame var frame = new Frame { BorderColor = Color.DarkGray, Content = stackLayout, BackgroundColor = notedata.NoteColor }; //BackgroundColor=FrameColorSetter.GetColor(notedata, frame); //// add label into note foreach (NoteLabel model in allLabels) { IList <string> lists = notedata.LabelsList; foreach (var labelsid in lists) { if (model.Labelkey.Equals(labelsid)) { var labelName = new Label { Text = model.Noteslabel, HorizontalOptions = LayoutOptions.Center, VerticalOptions = LayoutOptions.Start, FontSize = 11 }; var labelFrame = new Frame { CornerRadius = 28, HeightRequest = 14, Content = labelName, BorderColor = Color.Gray, BackgroundColor = Color.FromHex(FrameColorSetter.GetHexColor(notedata)) }; ////labelFrame.BackgroundColor = Color.White; stackLayout.Children.Add(labelFrame); } } } /* foreach (CollaboratorMadel model in allCollaboratos) * { * IList<string> lists = notedata.CollaboratosList; * foreach (var collboratorid in lists) * { * if (model.CKey.Equals(collboratorid)) * { * var imagebutton = new ImageButton() * { * Source = "Accountphoto.png", * VerticalOptions = LayoutOptions.Start, * HorizontalOptions = LayoutOptions.Start * }; * var labelFrame1 = new Frame * { * Content = imagebutton, * BorderColor = Color.Gray, * BackgroundColor = Color.FromHex(FrameColorSetter.GetHexColor(notedata)) * }; * ////labelFrame1.BackgroundColor = Color.White; * stackLayout.Children.Add(labelFrame1); * } * } * }*/ //// clicked event for note which is display onto another new page tapGestureRecognizer.Tapped += (object sender, EventArgs e) => { StackLayout layout = (StackLayout)sender; ////Add the tapped notes into list IList <View> item = layout.Children; //// taking id of the note Label labelid = (Label)item[0]; var idValue = labelid.Text; //// move to the edit page with given id Navigation.PushAsync(new EditNote(idValue)); }; OthersGridLayout.Children.Add(frame, colindex, rowindex); } } } catch (Exception ex) { Console.WriteLine(ex.Message); } }