Example #1
0
        private async void loadURLS()
        {
            try
            {
                String DBPath = Path.Combine(Windows.Storage.ApplicationData.Current.LocalFolder.Path, "My_Fashion_Assistant.db");
                conn = new SQLiteConnection(DBPath);


                var allData = conn.Table <MyClothes>();

                if (allData != null)
                {
                    foreach (MyClothes player in allData)
                    {
                        clothes.Add(player);
                    }
                }

                for (int i = 0; i < allClothes.Count; i++)
                {
                    try
                    {
                        StorageFile file = await Windows.Storage.StorageFile.GetFileFromPathAsync(allClothes[i].imgPath);

                        if (file != null)
                        {
                            IRandomAccessStream fileStream = await file.OpenReadAsync();

                            BitmapImage bitmapImage = new BitmapImage();
                            bitmapImage.SetSource(fileStream);
                            bitmapImage.DecodePixelType   = DecodePixelType.Physical;
                            bitmapImage.CreateOptions     = BitmapCreateOptions.None;
                            bitmapImage.DecodePixelHeight = 50;
                            bitmapImage.DecodePixelWidth  = 50;
                            MyClothesImages mci = new MyClothesImages();
                            mci.nameClothes = allClothes[i].nameClothes;
                            mci.season      = allClothes[i].season;
                            mci.myImage     = bitmapImage;
                            mci.typeClothes = allClothes[i].typeClothes;
                            clothesImages.Add(mci);
                        }
                    }
                    catch
                    {
                        Debug.WriteLine("Exception accured while trying to conver the image path to a BitmapImage");
                    }
                }



                lst.DataContext          = clothesImages;
                mProgressRing.Visibility = Visibility.Collapsed;
                lst.Visibility           = Visibility.Visible;
            }
            catch
            {
                Debug.WriteLine("not ok !");
            }
        }
Example #2
0
        private async void loadURLS()
        {
            try
            {
                var query   = conn.Table <MyClothes>();
                var allData = await query.ToListAsync();


                allClothes = allData;

                for (int i = 0; i < allClothes.Count; i++)
                {
                    try
                    {
                        StorageFile file = await Windows.Storage.StorageFile.GetFileFromPathAsync(allClothes[i].imgPath);

                        if (file != null)
                        {
                            IRandomAccessStream fileStream = await file.OpenReadAsync();

                            BitmapImage bitmapImage = new BitmapImage();
                            bitmapImage.SetSource(fileStream);
                            bitmapImage.DecodePixelType   = DecodePixelType.Physical;
                            bitmapImage.CreateOptions     = BitmapCreateOptions.None;
                            bitmapImage.DecodePixelHeight = 50;
                            bitmapImage.DecodePixelWidth  = 50;
                            MyClothesImages mci = new MyClothesImages();
                            mci.nameClothes = allClothes[i].nameClothes;
                            mci.season      = allClothes[i].season;
                            mci.myImage     = bitmapImage;
                            mci.typeClothes = allClothes[i].typeClothes;
                            clothesImages.Add(mci);
                        }
                    }
                    catch
                    {
                        Debug.WriteLine("Exception accured while trying to conver the image path to a BitmapImage");
                    }
                }



                lst.DataContext          = clothesImages;
                mProgressRing.Visibility = Visibility.Collapsed;
                lst.Visibility           = Visibility.Visible;
            }
            catch
            {
                Debug.WriteLine("not ok !");
            }
        }
Example #3
0
        private void MenuFlyoutItem_Click(object sender, RoutedEventArgs e)
        {
            bool             trouve      = false;
            int              j           = 0;
            MyClothesImages  selectedOne = null;
            FrameworkElement element     = (FrameworkElement)e.OriginalSource;

            if (element.DataContext != null && element.DataContext is MyClothesImages)
            {
                selectedOne = (MyClothesImages)element.DataContext;
                // rest of the code
            }
            //Debug.WriteLine(lst..toString())
            for (int i = 0; i < clothesImages.Count; i++)
            {
                if (clothesImages[i] == selectedOne)
                {
                    trouve = true;
                    j      = i;
                }
            }
            if (trouve == true)
            {
                try
                {
                    Debug.WriteLine("tfass5et");

                    //remove from database
                    for (int gass = 0; gass < allClothes.Count; gass++)
                    {
                        if (selectedOne.nameClothes == allClothes[gass].nameClothes && selectedOne.season == allClothes[gass].season && selectedOne.typeClothes == allClothes[gass].typeClothes)
                        {
                            conn.DeleteAsync(allClothes[gass]);
                        }
                    }

                    //remove from current list
                    clothesImages.Remove(selectedOne);
                }
                catch
                {
                    Debug.WriteLine("unable to delate item ! 1 ");
                }
            }
        }
        private async void loadURLS()
        {
            try
            {
                String DBPath = Path.Combine(Windows.Storage.ApplicationData.Current.LocalFolder.Path, "My_Fashion_Assistant.db");
                conn = new SQLiteConnection(DBPath);


                var allData = conn.Table<MyClothes>();

                if (allData != null)
                {
                    foreach (MyClothes player in allData)
                    {
                        clothes.Add(player);
                    }
                }

                for (int i = 0; i < allClothes.Count; i++)
                {
                    try
                    {
                        StorageFile file = await Windows.Storage.StorageFile.GetFileFromPathAsync(allClothes[i].imgPath);

                        if (file != null)
                        {
                            IRandomAccessStream fileStream = await file.OpenReadAsync();
                            BitmapImage bitmapImage = new BitmapImage();
                            bitmapImage.SetSource(fileStream);
                            bitmapImage.DecodePixelType = DecodePixelType.Physical;
                            bitmapImage.CreateOptions = BitmapCreateOptions.None;
                            bitmapImage.DecodePixelHeight = 50;
                            bitmapImage.DecodePixelWidth = 50;
                            MyClothesImages mci = new MyClothesImages();
                            mci.nameClothes = allClothes[i].nameClothes;
                            mci.season = allClothes[i].season;
                            mci.myImage = bitmapImage;
                            mci.typeClothes = allClothes[i].typeClothes;
                            clothesImages.Add(mci);
                        }
                    }
                    catch
                    {
                        Debug.WriteLine("Exception accured while trying to conver the image path to a BitmapImage");
                    }
                }



                lst.DataContext = clothesImages;
                mProgressRing.Visibility = Visibility.Collapsed;
                lst.Visibility = Visibility.Visible;


            }
            catch
            {
                Debug.WriteLine("not ok !");
            }

        }
        private async void loadURLS()
        {
            try
            {

                var query = conn.Table<MyClothes>();
                var allData = await query.ToListAsync();


                allClothes = allData;

                for (int i = 0; i < allClothes.Count; i++)
                {
                    try
                    {
                        StorageFile file = await Windows.Storage.StorageFile.GetFileFromPathAsync(allClothes[i].imgPath);

                        if (file != null)
                        {
                            IRandomAccessStream fileStream = await file.OpenReadAsync();
                            BitmapImage bitmapImage = new BitmapImage();
                            bitmapImage.SetSource(fileStream);
                            bitmapImage.DecodePixelType = DecodePixelType.Physical;
                            bitmapImage.CreateOptions = BitmapCreateOptions.None;
                            bitmapImage.DecodePixelHeight = 50;
                            bitmapImage.DecodePixelWidth = 50;
                            MyClothesImages mci = new MyClothesImages();
                            mci.nameClothes = allClothes[i].nameClothes;
                            mci.season = allClothes[i].season;
                            mci.myImage = bitmapImage;
                            mci.typeClothes = allClothes[i].typeClothes;
                            clothesImages.Add(mci);
                        }
                    }
                    catch
                    {
                        Debug.WriteLine("Exception accured while trying to conver the image path to a BitmapImage");
                    }
                }



                lst.DataContext = clothesImages;
                mProgressRing.Visibility = Visibility.Collapsed;
                lst.Visibility = Visibility.Visible;


            }
            catch
            {
                Debug.WriteLine("not ok !");
            }

        }