public Pathfinding(Shoppinglist p)
        {
            this.products = p.Products;
            assetmap      = BitmapFactory.DecodeStream(assets.Open("Supermarket.bmp"));
            Bitmap tmpmap = BitmapFactory.DecodeStream(assets.Open("Supermarket.bmp"));

            finalmap = tmpmap.Copy(tmpmap.GetConfig(), true);
        }
        public static void StoreList(Shoppinglist shoplist)
        {
            var path     = System.Environment.GetFolderPath(System.Environment.SpecialFolder.ApplicationData);
            var filename = Path.Combine(path, "lists.csv");

            if (File.Exists(filename) == false)
            {
                FileStream fs = new FileStream(filename, FileMode.Create);
                fs.Close();
            }

            //if (shoplist.Products != null)
            //{
            // Erst alle Shoppinglisten einlesen
            List <Shoppinglist> Listen = new List <Shoppinglist>();
            List <string>       Names  = loadListNames();

            foreach (string nam in Names)
            {
                Listen.Add(LoadList(nam));
            }

            //Alle Listen bis auf die geänderte in die Datei schreiben
            using (StreamWriter sw = new StreamWriter(filename))
            {
                foreach (Shoppinglist shp in Listen)
                {
                    if (shp.Name != shoplist.Name) // geänderte Datei wird nicht geschrieben
                    {
                        sw.WriteLine(shp.Name);
                        if (shp.Products != null)
                        {
                            foreach (Product prod in shp.Products)
                            {
                                sw.WriteLine(prod.Name + ";" + prod.Category + ";" + prod.Pos_x + ";" + prod.Pos_y);
                            }
                        }
                    }
                }

                // Als letztes wird die geänderte Liste wieder in die Datei schreiben
                sw.WriteLine(shoplist.Name);
                if (shoplist.Products != null)
                {
                    foreach (Product prod in shoplist.Products)
                    {
                        sw.WriteLine(prod.Name + ";" + prod.Category + ";" + prod.Pos_x + ";" + prod.Pos_y);
                    }
                }
            }
            //}
        }
예제 #3
0
        private void MListView_ItemClick(object sender, AdapterView.ItemClickEventArgs e)
        {
            //Needs implementation to write item to list and return to Shoppinglist listview
            string auswahl = mItems[e.Position];

            //Needs to load Product
            Classes.Product newProduct = Classes.Database.returnProduct(auswahl);
            //Load List (name = getStringExtra)
            Classes.Shoppinglist sl = Classes.ListStorer.LoadList(listName);
            //Needs to add Product to list
            sl.addProduct(newProduct);
            //Store list
            Classes.ListStorer.StoreList(sl);
            //Parse back name
            Intent intent = new Intent(this, typeof(ListEditorActivity));

            intent.PutExtra("listname", listName);
            //Give controll to listeditoractivity
            this.StartActivity(intent);
        }
        public static Shoppinglist LoadList(string listName)
        {
            var path     = System.Environment.GetFolderPath(System.Environment.SpecialFolder.ApplicationData);
            var filename = Path.Combine(path, "lists.csv");

            if (File.Exists(filename) == false)
            {
                FileStream fs = new FileStream(filename, FileMode.Create);
                fs.Close();
            }

            Shoppinglist list = new Shoppinglist();

            using (StreamReader sr = new StreamReader(filename))
            {
                string line = sr.ReadLine();

                while (line != null)
                {
                    if (line == listName) //Liste mit dem eingegebenen Namen suchen
                    {
                        list      = new Shoppinglist();
                        list.Name = line;
                        line      = sr.ReadLine();

                        while (line != null && line.Contains(";"))
                        {
                            string[] zeile = line.Split(';');
                            Product  prod  = new Product(zeile[0], zeile[1], Convert.ToInt32(zeile[2]), Convert.ToInt32(zeile[3]));
                            list.addProduct(prod);
                            line = sr.ReadLine();
                        } // Wenn die Zeile keinen ; mehr enthält beginnt eine neue Liste
                        return(list);
                    }
                    line = sr.ReadLine();
                }
                return(null); // Wenn die Liste nicht gefunden wurde
            }
        }
        protected override void OnCreate(Bundle bundle)
        {
            base.OnCreate(bundle);

            SetContentView(Resource.Layout.bitmap_viewer);

            AssetManager assets = Android.App.Application.Context.Assets;

            Classes.Shoppinglist shopinglist = new Classes.Shoppinglist();
            shopinglist = Classes.ListStorer.LoadList(Intent.GetStringExtra("Lname"));

            Classes.Pathfinding path = new Classes.Pathfinding(shopinglist);//Shoppinglist


            ImageView bitmap;

            bitmap = (ImageView)FindViewById(Resource.Id.marketpath);
            //System.IO.Stream si1 = assets.Open("Supermarket.bmp");
            //Bitmap bitmap1 = BitmapFactory.DecodeStream(si1);
            Bitmap bitmap1 = path.FindPath();
            Bitmap show    = Bitmap.CreateScaledBitmap(bitmap1, 1200, 1300, true);

            bitmap.SetImageBitmap(show);
        }
예제 #6
0
        protected override void OnCreate(Bundle bundle)
        {
            base.OnCreate(bundle);

            //Ctg-Name entpacken
            listname = Intent.GetStringExtra("listname");

            SetContentView(Resource.Layout.listeditor);


            //check if a shoppinglist-name was given
            if (listname != null)
            {
                //Check if a list already exists
                shoppinglist = Classes.ListStorer.LoadList(listname);
                if (shoppinglist == null)
                {
                    //Create new shoppinglist
                    shoppinglist      = new Classes.Shoppinglist();
                    shoppinglist.Name = listname;
                }
            }
            else
            {
                throw new ArgumentException("Missing list name");
            }


            var toolbar = FindViewById <Toolbar>(Resource.Id.main_toolbar);

            SetActionBar(toolbar);
            ActionBar.Title = listname;



            mListView = FindViewById <ListView>(Resource.Id.myListView);

            mItems = new List <string>();
            if (shoppinglist.Products != null)
            {
                //Produkte von Shoppinglist in mItems schreiben
                foreach (Classes.Product item in shoppinglist.Products)
                {
                    mItems.Add(item.ToString());
                }
            }


            /*
             * mItems = new List<string>();
             * mItems.Add("Weihenstephan Milch");
             * mItems.Add("Roggen Brot");
             * mItems.Add("Pink Lady Apfel");
             */

            MyListViewAdapter adapter = new MyListViewAdapter(this, mItems);

            mListView.Adapter = adapter;


            Button addItem;

            addItem        = FindViewById <Button>(Resource.Id.newItem);
            addItem.Click += addbtn_Click;

            Button startpath;

            startpath        = FindViewById <Button>(Resource.Id.startpath);
            startpath.Click += pathfinding_Click;
        }