Exemplo n.º 1
0
        private void ListViewDetailPage_ItemSelected(object sender, SelectedItemChangedEventArgs e)
        {
            var item = e.SelectedItem as HomePageDetailEntryItem;

            if (item == null)
            {
                return;
            }

            T_Entry t_Entry = new T_Entry();

            t_Entry.Id        = item.Id;
            t_Entry.Icon      = item.Icon;
            t_Entry.IconTitle = item.IconTitle;
            t_Entry.IconIndex = item.IconIndex;
            t_Entry.Title     = item.Title;
            t_Entry.Content   = item.Content;

            //var page = (Page)Activator.CreateInstance(item.TargetType);
            //page.Title = item.Title;

            MainViewModel.GetInstance().ViewItem = new ViewItemViewModel(t_Entry);
            Application.Current.MainPage.Navigation.PushAsync(new ViewItemPage());

            //Detail = new NavigationPage(page);
            IsPresented = false;

            DetailPage.ListViewDetailPage.SelectedItem = null;
        }
Exemplo n.º 2
0
        public ViewItemViewModel(T_Entry data)
        {
            var platform = DependencyService.Get <ISQLitePlatform>();

            db = platform.GetConnection();

            if (data.Id != 0)
            {
                this.EntryData = data;
                this.Icon      = data.Icon;
                this.IconTitle = data.IconTitle;
                this.Title     = data.Title;
                this.Content   = Base64Decode(data.Content);
            }
        }
Exemplo n.º 3
0
        public EditItemViewModel(T_Entry data)
        {
            var platform = DependencyService.Get <ISQLitePlatform>();

            db = platform.GetConnection();

            #region List Types Items
            ItemType        itemType;
            List <ItemType> itemTypes = new List <ItemType>();
            itemType          = new ItemType();
            itemType.iconType = "pass_item";
            itemType.nameType = Languages.ItemTypeLiteral1;
            itemTypes.Add(itemType);
            itemType          = new ItemType();
            itemType.iconType = "bank_item";
            itemType.nameType = Languages.ItemTypeLiteral2;
            itemTypes.Add(itemType);
            itemType          = new ItemType();
            itemType.iconType = "phone_item";
            itemType.nameType = Languages.ItemTypeLiteral3;
            itemTypes.Add(itemType);
            itemType          = new ItemType();
            itemType.iconType = "card_item";
            itemType.nameType = Languages.ItemTypeLiteral4;
            itemTypes.Add(itemType);
            itemType          = new ItemType();
            itemType.iconType = "text_item";
            itemType.nameType = Languages.ItemTypeLiteral5;
            itemTypes.Add(itemType);
            TypesList = itemTypes;
            #endregion

            if (data.Id != 0)
            {
                EntryData          = new T_Entry();
                EntryData          = data;
                this.TypeItemIndex = data.IconIndex;
                this.TitleItem     = data.Title;
                this.ContentItem   = Base64Decode(data.Content);
            }
        }
Exemplo n.º 4
0
        private async void Save()
        {
            if (this.TypeItem == null)
            {
                await Application.Current.MainPage.DisplayAlert(
                    Languages.ExceptionLiteral1,
                    Languages.AddItemLiteral1,
                    Languages.ExceptionLiteral3);

                return;
            }

            if (string.IsNullOrEmpty(this.TitleItem))
            {
                await Application.Current.MainPage.DisplayAlert(
                    Languages.ExceptionLiteral1,
                    Languages.AddItemLiteral2,
                    Languages.ExceptionLiteral3);

                return;
            }

            if (string.IsNullOrEmpty(this.ContentItem))
            {
                await Application.Current.MainPage.DisplayAlert(
                    Languages.ExceptionLiteral1,
                    Languages.AddItemLiteral3,
                    Languages.ExceptionLiteral3);

                return;
            }

            bool result = await Application.Current.MainPage.DisplayAlert(
                Languages.AppLiteral1,
                Languages.AddItemLiteral4,
                Languages.ViewItemLiteral3,
                Languages.ViewItemLiteral4);

            if (result)
            {
                try
                {
                    var registerData = new T_Entry {
                        Icon = TypeItem.iconType, IconTitle = TypeItem.nameType, IconIndex = TypeItemIndex, Title = TitleItem, Content = Base64Encode(ContentItem)
                    };
                    var resultDB = db.Insert(registerData);
                    if (resultDB == 1)
                    {
                        TypeItemIndex = -1;
                        TitleItem     = string.Empty;
                        ContentItem   = string.Empty;
                        DependencyService.Get <Toast>().Show(Languages.AppLiteral6);
                        MainViewModel.GetInstance().HomePageDetail = new HomePageDetailViewModel();
                        await Application.Current.MainPage.Navigation.PushAsync(new HomePage());
                    }
                    else
                    {
                        await Application.Current.MainPage.DisplayAlert(
                            Languages.ExceptionLiteral1,
                            Languages.AddItemLiteral5,
                            Languages.ExceptionLiteral3);

                        return;
                    }
                }
                catch (SQLiteException sqlex)
                {
                    await Application.Current.MainPage.DisplayAlert(
                        Languages.ExceptionLiteral1,
                        Languages.ExceptionLiteral2,
                        Languages.ExceptionLiteral3);

                    return;
                }
            }
        }