コード例 #1
0
        protected override Java.Lang.Object DoInBackground(params Java.Lang.Object[] @params)
        {
            List <Models.Synchronization> list = LDbConnection.GetSynchronization();

            for (int i = 0; i < list.Count; i++)
            {
                if (list.ElementAt(i).Expo_Id != -1 && list.ElementAt(i).User_Id != -1)
                {
                    DbConnection.FetchUserJoinExpoAsync(LDbConnection.GetUser(), LDbConnection.GetUserExpo(list.ElementAt(i).Expo_Id));
                }
                else if (list.ElementAt(i).Expo_Id != -1 && list.ElementAt(i).Company_Id != -1)
                {
                    //DbConnection.FetchCompanyJoinExpoAsync(LDbConnection.GetCompany(), LDbConnection.GetUserExpo(list.ElementAt(i).Expo_Id));
                }
                else if (list.ElementAt(i).History_Id != -1)
                {
                    DbConnection.FetchUserHistoryAsync(LDbConnection.GetHistoryUser(list.ElementAt(i).History_Id));
                }
                else if (list.ElementAt(i).User_Id != -1)
                {
                    //DbConnection.FetchUserSync(LDbConnection.GetUser());
                }
                else if (list.ElementAt(i).Company_Id != -1)
                {
                    //  DbConnection.FetchCompanySync(LDbConnection.GetCompany());
                }
            }
            return("Zsycnchronizowano");
        }
コード例 #2
0
        private async System.Threading.Tasks.Task SaveUserChangesAsync(String Email, String ForName, String SurName, long Phone, String Nationality)
        {
            User u = null;

            if (this.Intent.GetStringExtra("Action") == "Register")
            {
                u = new User();
            }
            else if (this.Intent.GetStringExtra("Action") == "Edit")
            {
                u = LDbConnection.GetUser();
            }
            u.ForName     = ForName;
            u.SurName     = SurName;
            u.Phone       = Phone;
            u.Email       = Email;
            u.Nationality = Nationality;
            if (await DbConnection.FetchUserEditAsync(u))
            {
                if (imageUri != null)
                {
                    await DbConnection.UploadImageUser
                        (this, imageUri, Email);

                    LDbConnection.InsertUser(this, await DbConnection.FetchUserAsync(Email));
                }
                else
                {
                    LDbConnection.InsertUser(await DbConnection.FetchUserAsync(Email));
                }
                var NxtAct = new Intent(this, typeof(StartActivity));
                StartActivity(NxtAct);
                Finish();
            }
        }
コード例 #3
0
        private async Task parseandsetAsync()
        {
            expos = LDbConnection.GetUserExpo();
            MyExpoListViewAdapter adapter = new MyExpoListViewAdapter(expos, this);

            list.SetAdapter(adapter);
        }
コード例 #4
0
        protected async void OnClickAsync()
        {
            TextView    email    = FindViewById <TextView>(Resource.Id.Email);
            TextView    password = FindViewById <TextView>(Resource.Id.Password);
            MobileLogin ml       = await DbConnection.FetchLoginAsync(email.Text, password.Text);

            if (ml.UserAndPasswordCorrect == true)
            {
                Login l = new Login
                {
                    Name     = email.Text,
                    Password = password.Text,
                    Typ      = ml.UserType
                };
                LDbConnection.InsertLogin(l);
                if (ml.UserType == "User")
                {
                    LDbConnection.InsertUser(this, await DbConnection.FetchUserAsync(email.Text));
                    LDbConnection.InsertUserExpos(await DbConnection.FetchUserExposAsync(LDbConnection.GetUser()));
                    //LDbConnection.InsertHistory(await DbConnection.FetchHistory(LDbConnection.GetUser()));
                }
                if (ml.UserType == "Company")
                {
                    LDbConnection.InsertCompany(this, await DbConnection.FetchCompanyAsync(email.Text));
                    LDbConnection.InsertUserExpos(await DbConnection.FetchUserExposAsync(LDbConnection.GetCompany()));
                    //LDbConnection.InsertHistory(await DbConnection.FetchHistory(LDbConnection.GetCompany()));
                }
                var NxtAct = new Intent(this, typeof(StartActivity));
                StartActivity(NxtAct);
                Finish();
            }
            else
            {
                if (TextUtils.IsEmpty(email.Text) || TextUtils.IsEmpty(password.Text))
                {
                    if (TextUtils.IsEmpty(email.Text))
                    {
                        email.RequestFocus();
                        email.SetError("Pole nie może być puste!", null);
                    }
                    if (TextUtils.IsEmpty(password.Text))
                    {
                        password.RequestFocus();
                        password.SetError("Pole nie może być puste!", null);
                    }
                }
                else if (ml.UserAndPasswordCorrect == false)
                {
                    email.RequestFocus();
                    email.SetError("Zły Email lub Hasło!", null);
                    password.RequestFocus();
                    password.SetError("Zły Email lub Hasło!", null);
                }
                return;
            }
        }
コード例 #5
0
        protected override void OnCreate(Bundle bundle)
        {
            base.OnCreate(bundle);
            SetContentView(Resource.Layout.History);
            ListView l = (ListView)FindViewById(Resource.Id.HistoryList);

            lista = LDbConnection.GetHistoryUser();
            HistoryAdapter adapter = new HistoryAdapter(lista, this);

            l.SetAdapter(adapter);
            l.ItemClick += List_ItemClick;
        }
コード例 #6
0
        private async System.Threading.Tasks.Task SaveCompanyChangesAsync(String Email, String ContactEmail, long UserPhone, long Phone, String CompanyName, String CompanyFullName, String CompanyAbout, String ProductsAbout, String Facebook, String Instagram, String Youtube, String WWW, String Adres, String ForName_And_SurName, String NIP)
        {
            Company c = null;

            if (this.Intent.GetStringExtra("Action") == "Register")
            {
                c = new Company();
            }
            else if (this.Intent.GetStringExtra("Action") == "Edit")
            {
                c = LDbConnection.GetCompany();
            }
            c.CompanyName         = CompanyName;
            c.CompanyFullName     = CompanyFullName;
            c.CompanyAbout        = CompanyAbout;
            c.ProductsAbout       = ProductsAbout;
            c.Email               = Email;
            c.ContactEmail        = ContactEmail;
            c.UserPhone           = UserPhone;
            c.Facebook            = Facebook;
            c.Instagram           = Instagram;
            c.Youtube             = Youtube;
            c.www                 = WWW;
            c.Phone               = Phone;
            c.Adress              = Adres;
            c.ForName_And_SurName = ForName_And_SurName;
            c.NIP                 = NIP;


            if (await DbConnection.FetchCompanyEditAsync(c))
            {
                if (imageUri1 != null || imageUri2 != null || imageUri3 != null || imageUri4 != null || imageUri5 != null || imageUril != null || imageUris != null)
                {
                    await DbConnection.UploadImageCompany(this, imageUril, imageUris, imageUri1, imageUri2, imageUri3, imageUri4, imageUri5, Email);
                }
                LDbConnection.InsertCompany(this, await DbConnection.FetchCompanyAsync(Email));

                var NxtAct = new Intent(this, typeof(StartActivity));
                StartActivity(NxtAct);
                Finish();
            }
        }
コード例 #7
0
        private async Task ParseAndReturnAsync()
        {
            // Extract the array of name/value results for the field name "weatherObservation".
            Models.Company c = await DbConnection.FetchCompanyAsync(this.Intent.GetStringExtra("Email"));

            // ID=Long.ParseLong(jsonR["ID"]),
            TextView CompanyName = FindViewById <TextView>(Resource.Id.company_name);

            CompanyName.Text = c.CompanyName;
            TextView CompanyFullName = FindViewById <TextView>(Resource.Id.company_fullname);

            CompanyFullName.Text = c.CompanyFullName;
            TextView CompanyAbout = FindViewById <TextView>(Resource.Id.company_about);

            CompanyAbout.Text = c.CompanyAbout;
            TextView ProductsAbout = FindViewById <TextView>(Resource.Id.company_product);

            ProductsAbout.Text = c.ProductsAbout;
            TextView ContactEmail = FindViewById <TextView>(Resource.Id.company_email);

            ContactEmail.Text   = c.ContactEmail;
            ContactEmail.Click += (s, e) =>
            {
                var uri    = Android.Net.Uri.Parse("mailto:" + c.ContactEmail);
                var intent = new Intent(Intent.ActionView, uri);
                StartActivity(intent);
            };
            TextView Phone = FindViewById <TextView>(Resource.Id.company_phone);

            Phone.Text = c.Phone.ToString();
            TextView Adress = FindViewById <TextView>(Resource.Id.company_adres);

            Adress.Text = c.Adress;
            TextView WWW = FindViewById <TextView>(Resource.Id.company_www);

            WWW.Text   = c.www;
            WWW.Click += (s, e) => {
                var uri    = Android.Net.Uri.Parse(c.www);
                var intent = new Intent(Intent.ActionView, uri);
                StartActivity(intent);
            };
            WebView     Youtube = FindViewById <WebView>(Resource.Id.company_youtube);
            WebSettings set     = Youtube.Settings;

            set.JavaScriptEnabled = true;
            Youtube.SetWebChromeClient(new WebChromeClient());
            Youtube.LoadUrl("https://www.youtube.com/embed/" + c.Youtube);
            ImageButton fb = FindViewById <ImageButton>(Resource.Id.company_facebook);

            fb.Click += (s, e) => {
                String uri    = "fb://facewebmodal/f?href=" + c.Facebook;
                Intent intent = new Intent(Intent.ActionView, Android.Net.Uri.Parse(uri));
                StartActivity(intent);
            };
            if (c.Facebook == null)
            {
                fb.Visibility = ViewStates.Invisible;
                fb.SetMaxHeight(0);
            }
            ImageButton insta = FindViewById <ImageButton>(Resource.Id.company_instagram);

            insta.Click += (s, e) => {
                String[] tab    = c.Instagram.ToString().Split('/');
                String   uri    = "instagram://user?username="******"http://expotest.somee.com/Images/Company/" + c.CompanyLogo));
            ImageView StandPhoto = FindViewById <ImageView>(Resource.Id.company_standphoto);

            StandPhoto.SetImageBitmap(DbConnection.GetImageBitmapFromUrl(this, "http://expotest.somee.com/Images/Company/" + c.StandPhoto));
            ImageView Photo1 = FindViewById <ImageView>(Resource.Id.company_photo1);

            Photo1.SetImageBitmap(DbConnection.GetImageBitmapFromUrl(this, "http://expotest.somee.com/Images/Company/" + c.Photo1));
            ImageView Photo2 = FindViewById <ImageView>(Resource.Id.company_photo2);

            Photo2.SetImageBitmap(DbConnection.GetImageBitmapFromUrl(this, "http://expotest.somee.com/Images/Company/" + c.Photo2));
            ImageView Photo3 = FindViewById <ImageView>(Resource.Id.company_photo3);

            Photo3.SetImageBitmap(DbConnection.GetImageBitmapFromUrl(this, "http://expotest.somee.com/Images/Company/" + c.Photo3));
            ImageView Photo4 = FindViewById <ImageView>(Resource.Id.company_photo4);

            Photo4.SetImageBitmap(DbConnection.GetImageBitmapFromUrl(this, "http://expotest.somee.com/Images/Company/" + c.Photo4));
            ImageView Photo5 = FindViewById <ImageView>(Resource.Id.company_photo5);

            Photo5.SetImageBitmap(DbConnection.GetImageBitmapFromUrl(this, "http://expotest.somee.com/Images/Company/" + c.Photo5));
            LayoutInflater layoutInflaterAndroid = LayoutInflater.From(this);
            View           popup = layoutInflaterAndroid.Inflate(Resource.Layout.HistoryWindowU, null);

            Android.Support.V7.App.AlertDialog.Builder alertDialogbuilder = new Android.Support.V7.App.AlertDialog.Builder(this);
            alertDialogbuilder.SetView(popup);

            var userContent = popup.FindViewById <EditText>(Resource.Id.History_description);

            alertDialogbuilder.SetCancelable(false)
            .SetPositiveButton("Dodaj", async delegate
            {
                HistoryU h = new HistoryU();
                //h.ID = LDbConnection.GetHistoryUser(this).Count;

                if (LDbConnection.getUserType() == "Uczestnik")
                {
                    h.Description  = userContent.Text;
                    h.User         = LDbConnection.GetUser().ID;
                    h.Expo         = Java.Lang.Long.ParseLong(this.Intent.GetIntExtra("expo_id", 1).ToString());
                    h.Wyszukiwanie = this.Intent.GetStringExtra("Search");
                    LDbConnection.InsertHistoryU(h);
                    if (await DbConnection.FetchUserHistoryAsync(h) == true)
                    {
                        Android.Widget.Toast.MakeText(this, "Zapisano w bazie", Android.Widget.ToastLength.Short).Show();
                    }
                    else
                    {
                        Android.Widget.Toast.MakeText(this, "SendError", Android.Widget.ToastLength.Short).Show();
                    }
                }
                else if (LDbConnection.getUserType() == "Wystawca")
                {
                    h.Description  = userContent.Text;
                    h.User         = LDbConnection.GetCompany().Id;
                    h.Expo         = Java.Lang.Long.ParseLong(this.Intent.GetIntExtra("expo_id", 1).ToString());
                    h.Wyszukiwanie = this.Intent.GetStringExtra("Search");
                    LDbConnection.InsertHistoryU(h);
                    if (await DbConnection.FetchCompanyHistoryAsync(h) == true)
                    {
                        Android.Widget.Toast.MakeText(this, "Zapisano w bazie", Android.Widget.ToastLength.Short).Show();
                    }
                    else
                    {
                        Android.Widget.Toast.MakeText(this, "SendError", Android.Widget.ToastLength.Short).Show();
                    }
                }
                Toast.MakeText(this, "Wysłano", ToastLength.Long).Show();
            }
                               ).SetNegativeButton("Zamknij", async delegate
            {
                HistoryU h = new HistoryU();
                //h.ID = LDbConnection.GetHistoryUser(this).Count;

                if (LDbConnection.getUserType() == "Uczestnik")
                {
                    h.Description  = "Skanowanie Nr: " + LDbConnection.GetHistoryUser().Count;
                    h.User         = LDbConnection.GetUser().ID;
                    h.Expo         = Java.Lang.Long.ParseLong(this.Intent.GetIntExtra("expo_id", 1).ToString());
                    h.Wyszukiwanie = this.Intent.GetStringExtra("Search");
                    LDbConnection.InsertHistoryU(h);
                    if (await DbConnection.FetchUserHistoryAsync(h) == true)
                    {
                        Android.Widget.Toast.MakeText(this, "Zapisano w bazie", Android.Widget.ToastLength.Short).Show();
                    }
                    else
                    {
                        Android.Widget.Toast.MakeText(this, "SendError", Android.Widget.ToastLength.Short).Show();
                    }
                }
                else if (LDbConnection.getUserType() == "Wystawca")
                {
                    h.Description  = "Skanowanie Nr: " + LDbConnection.GetHistoryUser().Count;
                    h.User         = LDbConnection.GetCompany().Id;
                    h.Expo         = Java.Lang.Long.ParseLong(this.Intent.GetIntExtra("expo_id", 1).ToString());
                    h.Wyszukiwanie = this.Intent.GetStringExtra("Search");
                    LDbConnection.InsertHistoryU(h);
                    if (await DbConnection.FetchCompanyHistoryAsync(h) == true)
                    {
                        Android.Widget.Toast.MakeText(this, "Zapisano w bazie", Android.Widget.ToastLength.Short).Show();
                    }
                    else
                    {
                        Android.Widget.Toast.MakeText(this, "SendError", Android.Widget.ToastLength.Short).Show();
                    }
                }
                alertDialogbuilder.Dispose();
            });
            Android.Support.V7.App.AlertDialog alertDialogAndroid = alertDialogbuilder.Create();
            if (this.Intent.GetBooleanExtra("Show", true))
            {
                alertDialogAndroid.Show();
            }
        }
コード例 #8
0
        private async Task ParseAndReturnAsync()
        {
            Models.Expo e = new Models.Expo();
            e.Id              = this.Intent.GetIntExtra("eid", 0);
            e.Name_Expo       = this.Intent.GetStringExtra("ename");
            e.Photo           = this.Intent.GetStringExtra("ephoto");
            e.MapPhoto        = this.Intent.GetStringExtra("emapphoto");
            e.Description     = this.Intent.GetStringExtra("eopis");
            e.DataTargowStart = DateTime.Parse(this.Intent.GetStringExtra("eDS"));
            e.DataTargowEnd   = DateTime.Parse(this.Intent.GetStringExtra("eDE"));
            e.Adres           = this.Intent.GetStringExtra("eadres");
            TextView ExpoName = FindViewById <TextView>(Resource.Id.expo_name);

            ExpoName.Text = e.Name_Expo;
            TextView ProductsAbout = FindViewById <TextView>(Resource.Id.expo_adres);

            ProductsAbout.Text = e.Adres;
            TextView ExpoDescription = FindViewById <TextView>(Resource.Id.expo_description);

            ExpoDescription.Text = e.Description;
            TextView ExpoStart = FindViewById <TextView>(Resource.Id.expo_data_start);

            ExpoStart.Text = e.DataTargowStart.ToString();
            TextView ExpoEnd = FindViewById <TextView>(Resource.Id.expo_data_end);

            ExpoEnd.Text = e.DataTargowEnd.ToString();
            ImageView ExpoPhoto = FindViewById <ImageView>(Resource.Id.expo_image);

            ExpoPhoto.SetImageBitmap(DbConnection.GetImageBitmapFromUrl(this, "http://expotest.somee.com/Images/Expo/" + e.Photo));
            Button btn = FindViewById <Button>(Resource.Id.expo_join);

            btn.Click += async delegate
            {
                LDbConnection.InsertUExpo(e);
                if (LDbConnection.getUserType() == "Uczestnik")
                {
                    if (await DbConnection.FetchUserJoinExpoAsync(LDbConnection.GetUser(), e))
                    {
                        Toast.MakeText(this, "Dołączono", ToastLength.Short).Show();
                    }
                    else
                    {
                        Toast.MakeText(this, "Brak połączenia", ToastLength.Short).Show();
                    }
                }
                else if (LDbConnection.getUserType() == "Wystawca")
                {
                    if (await DbConnection.FetchCompanyJoinExpoAsync(LDbConnection.GetCompany(), e))
                    {
                        Toast.MakeText(this, "Dołączono", ToastLength.Short).Show();
                    }
                    else
                    {
                        Toast.MakeText(this, "Brak połączenia", ToastLength.Short).Show();
                    }
                }
            };
            Button btn1 = FindViewById <Button>(Resource.Id.ExpoMap);

            btn1.Click += async delegate
            {
                var NxtAct = new Intent(this, typeof(MapActivity));
                NxtAct.PutExtra("mapphoto", e.MapPhoto);

                StartActivity(NxtAct);
            };
        }
コード例 #9
0
        protected async void LoadDAtaAsync()
        {
            User u = await DbConnection.FetchUserAsync(this.Intent.GetStringExtra("Email"));

            TextView ForName = FindViewById <TextView>(Resource.Id.user_forname);

            ForName.Text = u.ForName;
            TextView SurName = FindViewById <TextView>(Resource.Id.user_surname);

            SurName.Text = u.SurName;
            TextView Email = FindViewById <TextView>(Resource.Id.user_email);

            Email.Text = u.Email;
            TextView Phone = FindViewById <TextView>(Resource.Id.user_phone);

            Phone.Text = u.Phone.ToString();
            TextView Nationality = FindViewById <TextView>(Resource.Id.user_Nationality);

            Nationality.Text = u.Nationality;

            ImageView photo = FindViewById <ImageView>(Resource.Id.user_photo);

            photo.SetImageBitmap(DbConnection.GetImageBitmapFromUrl(this, "http://expotest.somee.com/Images/User/" + u.Photo));
            LayoutInflater layoutInflaterAndroid = LayoutInflater.From(this);
            View           popup = layoutInflaterAndroid.Inflate(Resource.Layout.HistoryWindowU, null);

            Android.Support.V7.App.AlertDialog.Builder alertDialogbuilder = new Android.Support.V7.App.AlertDialog.Builder(this);
            alertDialogbuilder.SetView(popup);

            var userContent = popup.FindViewById <EditText>(Resource.Id.History_description);

            alertDialogbuilder.SetCancelable(false)
            .SetPositiveButton("Dodaj", async delegate
            {
                HistoryU h = new HistoryU();
                //h.ID = LDbConnection.GetHistoryUser(this).Count;

                if (LDbConnection.getUserType() == "Uczestnik")
                {
                    h.Description  = userContent.Text;
                    h.User         = LDbConnection.GetUser().ID;
                    h.Expo         = Long.ParseLong(this.Intent.GetIntExtra("expo_id", 1).ToString());
                    h.Wyszukiwanie = this.Intent.GetStringExtra("Search");
                    LDbConnection.InsertHistoryU(h);
                    if (await DbConnection.FetchUserHistoryAsync(h) == true)
                    {
                        Android.Widget.Toast.MakeText(this, "Zapisano w bazie", Android.Widget.ToastLength.Short).Show();
                    }
                    else
                    {
                        Android.Widget.Toast.MakeText(this, "SendError", Android.Widget.ToastLength.Short).Show();
                    }
                }
                else if (LDbConnection.getUserType() == "Wystawca")
                {
                    h.Description  = userContent.Text;
                    h.User         = LDbConnection.GetCompany().Id;
                    h.Expo         = Long.ParseLong(this.Intent.GetIntExtra("expo_id", 1).ToString());
                    h.Wyszukiwanie = this.Intent.GetStringExtra("Search");
                    LDbConnection.InsertHistoryU(h);
                    if (await DbConnection.FetchCompanyHistoryAsync(h) == true)
                    {
                        Android.Widget.Toast.MakeText(this, "Zapisano w bazie", Android.Widget.ToastLength.Short).Show();
                    }
                    else
                    {
                        Android.Widget.Toast.MakeText(this, "SendError", Android.Widget.ToastLength.Short).Show();
                    }
                }
                Toast.MakeText(this, "Wysłano", ToastLength.Long).Show();
            }
                               ).SetNegativeButton("Zamknij", async delegate
            {
                HistoryU h = new HistoryU();
                //h.ID = LDbConnection.GetHistoryUser(this).Count;

                if (LDbConnection.getUserType() == "Uczestnik")
                {
                    h.Description  = "Skanowanie Nr: " + LDbConnection.GetHistoryUser().Count;
                    h.User         = LDbConnection.GetUser().ID;
                    h.Expo         = Long.ParseLong(this.Intent.GetIntExtra("expo_id", 1).ToString());
                    h.Wyszukiwanie = this.Intent.GetStringExtra("Search");
                    LDbConnection.InsertHistoryU(h);
                    if (await DbConnection.FetchUserHistoryAsync(h) == true)
                    {
                        Android.Widget.Toast.MakeText(this, "Zapisano w bazie", Android.Widget.ToastLength.Short).Show();
                    }
                    else
                    {
                        Android.Widget.Toast.MakeText(this, "SendError", Android.Widget.ToastLength.Short).Show();
                    }
                }
                else if (LDbConnection.getUserType() == "Wystawca")
                {
                    h.Description  = "Skanowanie Nr: " + LDbConnection.GetHistoryUser().Count;
                    h.User         = LDbConnection.GetCompany().Id;
                    h.Expo         = Long.ParseLong(this.Intent.GetIntExtra("expo_id", 1).ToString());
                    h.Wyszukiwanie = this.Intent.GetStringExtra("Search");
                    LDbConnection.InsertHistoryU(h);
                    if (await DbConnection.FetchCompanyHistoryAsync(h) == true)
                    {
                        Android.Widget.Toast.MakeText(this, "Zapisano w bazie", Android.Widget.ToastLength.Short).Show();
                    }
                    else
                    {
                        Android.Widget.Toast.MakeText(this, "SendError", Android.Widget.ToastLength.Short).Show();
                    }
                }
                alertDialogbuilder.Dispose();
            });
            Android.Support.V7.App.AlertDialog alertDialogAndroid = alertDialogbuilder.Create();
            if (this.Intent.GetBooleanExtra("Show", true))
            {
                alertDialogAndroid.Show();
            }
        }
コード例 #10
0
        protected override void OnCreate(Bundle bundle)
        {
            base.OnCreate(bundle);
            SetContentView(Resource.Layout.Start);
            lista = LDbConnection.GetActualUserExpo();
            var toolbar = FindViewById <Android.Support.V7.Widget.Toolbar>(Resource.Id.toolbar);

            SetSupportActionBar(toolbar);
            SupportActionBar.SetDisplayHomeAsUpEnabled(true);
            SupportActionBar.SetDisplayShowTitleEnabled(false);
            SupportActionBar.SetHomeButtonEnabled(true);
            SupportActionBar.SetHomeAsUpIndicator(Resource.Drawable.ic_menu);
            drawerLayout   = FindViewById <Android.Support.V4.Widget.DrawerLayout>(Resource.Id.drawer_layout);
            navigationView = FindViewById <Android.Support.Design.Widget.NavigationView>(Resource.Id.nav_view);
            navigationView.NavigationItemSelected += HomeNavigationView_NavigationItemSelected;
            var    qrcode = FindViewById <Android.Widget.ImageView>(Resource.Id.Start_qrcode);
            var    writer = new ZXing.QrCode.QRCodeWriter();
            String s      = "";

            if (LDbConnection.getUserType() == "Uczestnik")
            {
                s = "Uczestnik:" + LDbConnection.GetUser().Email;
            }
            else if (LDbConnection.getUserType() == "Wystawca")
            {
                s = "Wystawca:" + LDbConnection.GetCompany().Email;
            }
            ZXing.Common.BitMatrix  bm          = writer.encode(s, ZXing.BarcodeFormat.QR_CODE, 500, 500);
            Android.Graphics.Bitmap ImageBitmap = Android.Graphics.Bitmap.CreateBitmap(500, 500, Config.Argb8888);

            for (int i = 0; i < 500; i++)
            {     //width
                for (int j = 0; j < 500; j++)
                { //height
                    ImageBitmap.SetPixel(i, j, bm[i, j] ? Color.Black : Color.White);
                }
            }

            if (ImageBitmap != null)
            {
                qrcode.SetImageBitmap(ImageBitmap);
            }
            var expo_list = FindViewById <Android.Widget.Spinner>(Resource.Id.Start_targi);

            expo_list.ItemSelected += new System.EventHandler <Android.Widget.AdapterView.ItemSelectedEventArgs>(spinner_ItemSelected);
            var adapter = new MyExpoSingleListViewAdapter(lista, this);

            expo_list.Adapter = adapter;
            var btn1 = (Button)FindViewById(Resource.Id.Start_join);

            btn1.Visibility = Android.Views.ViewStates.Invisible;
            btn1.Click     += delegate
            {
                var NxtAct = new Android.Content.Intent(this, typeof(UserActivity));
                StartActivity(NxtAct);
            };
            var button = FindViewById <Android.Widget.Button>(Resource.Id.Start_scan);

            button.Click += async delegate
            {
                ZXing.Mobile.MobileBarcodeScanner scanner;
                ZXing.Mobile.MobileBarcodeScanner.Initialize(Application);
                scanner = new ZXing.Mobile.MobileBarcodeScanner();
                scanner.UseCustomOverlay = false;

                //We can customize the top and bottom text of the default overlay
                scanner.BottomText = "Poczekaj, aż kod kreskowy będzie automatycznie zeskanowany!";

                //Start scanning
                var result = await scanner.Scan();

                scanner.Cancel();
                if (result == null)
                {
                    scanner.Cancel();
                }
                else
                {
                    scanner.Cancel();
                    string[] scan = result.Text.Split(':');
                    if (scan[0] == "Wystawca")
                    {
                        var NxtAct = new Android.Content.Intent(this, typeof(CompanyActivity));
                        NxtAct.PutExtra("Email", scan[1]);
                        NxtAct.PutExtra("expo_id", lista[select].Id);
                        NxtAct.PutExtra("Search", result.Text);
                        NxtAct.PutExtra("Show", true);

                        StartActivity(NxtAct);
                    }
                    else if (scan[0].Contains("Uczestnik"))
                    {
                        System.Console.WriteLine("Uczestnik");
                        var NxtAct = new Android.Content.Intent(this, typeof(UserActivity));
                        NxtAct.PutExtra("Email", scan[1]);
                        NxtAct.PutExtra("expo_id", lista[select].Id);
                        NxtAct.PutExtra("Search", result.Text);
                        NxtAct.PutExtra("Show", true);

                        StartActivity(NxtAct);
                    }
                }
            };
            if (lista == null)
            {
                button.Visibility = Android.Views.ViewStates.Invisible;
                btn1.Visibility   = Android.Views.ViewStates.Visible;
            }
        }
コード例 #11
0
        public void HomeNavigationView_NavigationItemSelected(object sender, Android.Support.Design.Widget.NavigationView.NavigationItemSelectedEventArgs e)
        {
            var menuItem = e.MenuItem; menuItem.SetChecked(!menuItem.IsChecked);

            Android.Content.Intent intent;
            switch (menuItem.ItemId)
            {
            case Resource.Id.nav_my_expos:
                intent = new Android.Content.Intent(this, typeof(MyExposActivity));
                StartActivity(intent);
                break;

            case Resource.Id.nav_help:
                intent = new Android.Content.Intent(this, typeof(VideoActivity));
                StartActivity(intent);
                break;

            case Resource.Id.nav_expos:
                intent = new Android.Content.Intent(this, typeof(ExposActivity));
                StartActivity(intent);
                break;

            case Resource.Id.nav_prof:
                intent = new Android.Content.Intent(this, typeof(MyProfileActivity));
                StartActivity(intent);
                break;

            case Resource.Id.nav_history:
                intent = new Android.Content.Intent(this, typeof(HistoryActivity));
                StartActivity(intent);
                break;

            case Resource.Id.nav_logout:
                using (var conn = new SQLite.SQLiteConnection(System.IO.Path.Combine(System.Environment.GetFolderPath(System.Environment.SpecialFolder.Personal).ToString(), "database.sqlite")))
                {
                    conn.DeleteAll <Login>();
                    if (conn.ExecuteScalar <int>("SELECT count(*) FROM sqlite_master WHERE type = 'table' AND name = 'User'") != 0)
                    {
                        if (LDbConnection.GetCompany() != null)
                        {
                            Company c = conn.Table <Company>().First();
                            conn.DropTable <Company>();
                            conn.DropTable <Login>();
                            conn.DropTable <Expo>();
                            conn.DropTable <HistoryU>();
                            File.Delete(System.IO.Path.Combine(System.Environment.GetFolderPath(System.Environment.SpecialFolder.Personal) + c.Photo1));
                            File.Delete(System.IO.Path.Combine(System.Environment.GetFolderPath(System.Environment.SpecialFolder.Personal) + c.Photo2));
                            File.Delete(System.IO.Path.Combine(System.Environment.GetFolderPath(System.Environment.SpecialFolder.Personal) + c.Photo3));
                            File.Delete(System.IO.Path.Combine(System.Environment.GetFolderPath(System.Environment.SpecialFolder.Personal) + c.Photo4));
                            File.Delete(System.IO.Path.Combine(System.Environment.GetFolderPath(System.Environment.SpecialFolder.Personal) + c.Photo5));
                            File.Delete(System.IO.Path.Combine(System.Environment.GetFolderPath(System.Environment.SpecialFolder.Personal) + c.StandPhoto));
                            File.Delete(System.IO.Path.Combine(System.Environment.GetFolderPath(System.Environment.SpecialFolder.Personal) + c.CompanyLogo));
                        }
                        if (LDbConnection.GetUser() != null)
                        {
                            User u = conn.Table <User>().First();
                            conn.DropTable <User>();
                            conn.DropTable <Login>();
                            conn.DropTable <Expo>();
                            conn.DropTable <HistoryU>();
                            File.Delete(System.IO.Path.Combine(System.Environment.GetFolderPath(System.Environment.SpecialFolder.Personal) + u.Photo));
                        }
                        if (LDbConnection.GetUserExpo() != null)
                        {
                            conn.DropTable <Expo>();
                        }
                        if (LDbConnection.GetHistoryUser() != null)
                        {
                            if (LDbConnection.GetHistoryUser().Count != 0)
                            {
                                conn.DropTable <HistoryU>();
                            }
                        }
                    }
                    conn.Commit();
                    conn.Close();
                }
                intent = new Android.Content.Intent(this, typeof(MainActivity));
                StartActivity(intent);
                Finish();
                break;
            }
        }