Пример #1
0
        /// <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);
            }
        }
Пример #3
0
        /// <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);
            }
        }
Пример #4
0
        /// <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);
            }
        }
Пример #5
0
        /// <summary>
        /// Lists the grid view.
        /// </summary>
        /// <param name="list">The list.</param>
        public void ListGridView(IList <Note> list)
        {
            try
            {
                GridLayout.ColumnDefinitions.Add(new ColumnDefinition {
                    Width = new GridLength(350)
                });
                GridLayout.Margin = 5;
                int rowCount = list.Count;
                ////ListView listView = new ListView() { HasUnevenRows = true };
                var productIndex = 0;
                var indexe       = -1;
                //// Iterate a single row at a time to add two notes in one row
                for (int rowIndex = 0; rowIndex < rowCount; rowIndex++)
                {
                    //// iterating column to add per note in each column in a single row
                    for (int columnIndex = 0; columnIndex < 1; columnIndex++)
                    {
                        Note data = null;
                        indexe++;

                        //// to maintain the size of array to avoid exception
                        if (indexe < list.Count)
                        {
                            data = list[indexe];
                        }

                        //// Once every note is added in respective column and row than it will break
                        if (productIndex >= list.Count)
                        {
                            break;
                        }

                        productIndex += 1;
                        var index = rowIndex * columnIndex + columnIndex;
                        var label = new Xamarin.Forms.Label
                        {
                            Text              = data.Title,
                            TextColor         = Color.Black,
                            FontAttributes    = FontAttributes.Bold,
                            VerticalOptions   = LayoutOptions.Center,
                            HorizontalOptions = LayoutOptions.Start,
                        };

                        var labelKey = new Xamarin.Forms.Label
                        {
                            Text      = data.Key,
                            IsVisible = false
                        };

                        var content = new Xamarin.Forms.Label
                        {
                            Text              = data.Notes,
                            VerticalOptions   = LayoutOptions.Center,
                            HorizontalOptions = LayoutOptions.Start,
                        };

                        StackLayout layout = new StackLayout()
                        {
                            Spacing = 2,
                            Margin  = 2,
                            //// BackgroundColor = Color.White
                        };
                        var tapGestureRecognizer = new TapGestureRecognizer();
                        layout.Children.Add(labelKey);
                        layout.Children.Add(label);
                        layout.Children.Add(content);
                        layout.GestureRecognizers.Add(tapGestureRecognizer);
                        layout.Spacing = 2;
                        layout.Margin  = 2;
                        ////  layout.BackgroundColor = Color.White;

                        var frame = new Frame();
                        frame.BorderColor  = Color.Black;
                        frame.CornerRadius = 25;
                        FrameColorSetter.GetColor(data, frame);
                        frame.Content = layout;
                        tapGestureRecognizer.Tapped += (object sender, EventArgs args) =>
                        {
                            StackLayout         layout123 = (StackLayout)sender;
                            IList <View>        item      = layout123.Children;
                            Xamarin.Forms.Label KeyValue  = (Xamarin.Forms.Label)item[0];
                            var Keyval = KeyValue.Text;
                            Navigation.PushAsync(new UpdateNote(Keyval));
                        };

                        GridLayout.Children.Add(frame, columnIndex, rowIndex);
                    }
                }
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.Message);
            }
        }