Esempio n. 1
0
        protected override void OnCreate(Bundle bundle)
        {
            base.OnCreate(bundle);
            SetContentView(Resource.Layout.Napominanie);
            // Create your application here

            mToolbar      = FindViewById <SupportToolbar>(Resource.Id.toolBar1);
            mDrawerLayout = FindViewById <DrawerLayout>(Resource.Id.Drawer_layout1);
            mLeftDrawer   = FindViewById <ListView>(Resource.Id.left_drawer1);
            listView      = FindViewById <ListView>(Resource.Id.listView1);
            SetSupportActionBar(mToolbar);

            mLeftDataSet = new List <string>();
            mLeftDataSet.Add("Расписание");
            // mLeftDataSet.Add("Преподаватели");
            mLeftDataSet.Add("Напоминание");
            //mLeftDataSet.Add("Местоположение");
            mLeftDataSet.Add("Выход");
            mLeftAdapter        = new ArrayAdapter <string>(this, Android.Resource.Layout.SimpleListItem1, mLeftDataSet);
            mLeftDrawer.Adapter = mLeftAdapter;
            mDrawerToggle       = new MyActionBarDrawerToggle(
                this,                        //host activity
                mDrawerLayout,               //DrawerLayout
                Resource.String.naponinanie, //открыто сообщение
                Resource.String.naponinanie  //зактрыто сообщение
                );
            mLeftDrawer.ItemClick += mLeftDrawer_ItemClick;

            Create_Database dbr = new Create_Database();
            var             res = dbr.GetAllRecords();

            if (res != "")
            {
                string[] str = res.Split('\n');
                for (int i = 0; i < str.Length - 1; i++)
                {
                    string   str2 = "";
                    string[] str1 = str[i].Split(' ');
                    for (int j = 3; j < str1.Length; j++)
                    {
                        str2 += str1[j] + " ";
                    }
                    tableItems.Add(new TableItem()
                    {
                        Heading = str1[1] + " " + str1[2], SubHeading = str2
                    });
                }
                listView.Adapter = new HomeScreenAdapter(this, tableItems);
            }

            listView.ItemClick     += listView_ItemClick;
            listView.ItemLongClick += listView_ItemLongClick;


            mDrawerLayout.SetDrawerListener(mDrawerToggle);
            SupportActionBar.SetDisplayHomeAsUpEnabled(true);
            SupportActionBar.SetHomeButtonEnabled(true);
            SupportActionBar.SetDisplayShowTitleEnabled(true);
            mDrawerToggle.SyncState();
        }
Esempio n. 2
0
        void listView_ItemLongClick(object sender, AdapterView.ItemLongClickEventArgs e)
        {
            Android.Support.V7.App.AlertDialog.Builder alert = new Android.Support.V7.App.AlertDialog.Builder(this);
            //alert.SetTitle("Confirm delete");
            alert.SetMessage("Удалить напоминание?");
            alert.SetPositiveButton("Удалить", (senderAlert, args) =>
            {
                int id = 0;
                Create_Database dbr = new Create_Database();
                var res             = dbr.GetAllRecords();
                if (res != "")
                {
                    string[] str  = res.Split('\n');
                    string[] str1 = str[e.Position].Split(' ');
                    id            = Convert.ToInt32(str1[0]);
                }
                var res1 = dbr.RemoveTask(id);
                Toast.MakeText(this, res1, ToastLength.Short).Show();
                var res2 = dbr.GetAllRecords();
                tableItems.Clear();
                if (res2 != "")
                {
                    string[] str = res2.Split('\n');
                    for (int i = 0; i < str.Length - 1; i++)
                    {
                        string str2   = "";
                        string[] str1 = str[i].Split(' ');
                        for (int j = 3; j < str1.Length; j++)
                        {
                            str2 += str1[j] + " ";
                        }
                        tableItems.Add(new TableItem()
                        {
                            Heading = str1[1] + " " + str1[2], SubHeading = str2
                        });
                    }
                }
                listView.Adapter = new HomeScreenAdapter(this, tableItems);
            });

            alert.SetNegativeButton("Отмена", (senderAlert, args) => { });

            Dialog dialog = alert.Create();

            dialog.Show();
        }
Esempio n. 3
0
        protected override void OnCreate(Bundle bundle)
        {
            base.OnCreate(bundle);

            // Create your application here
            SetContentView(Resource.Layout.Add_Napominanie);

            Time        = FindViewById <Button>(Resource.Id.button2);
            Data        = FindViewById <Button>(Resource.Id.button1);
            Save        = FindViewById <Button>(Resource.Id.Save);
            Cancel      = FindViewById <Button>(Resource.Id.Cancel);
            mToolbar    = FindViewById <SupportToolbar>(Resource.Id.toolBarr);
            Napominalka = FindViewById <EditText>(Resource.Id.Napominanie);
            SetSupportActionBar(mToolbar);


            Time.Click  += (object sender, EventArgs e) => ShowDialog(Chas);
            Data.Click  += (object sender, EventArgs e) => ShowDialog(Den);
            nomer_striki = Intent.GetIntExtra("id", 0);
            hour         = DateTime.Now.Hour;
            minute       = DateTime.Now.Minute;
            data         = DateTime.Today;
            if (nomer_striki < 0)
            {
                UpdateTextVremia();
                UpdateTextData();
            }
            else
            {
                Create_Database dbr = new Create_Database();
                var             res = dbr.GetAllRecords();
                if (res != "")
                {
                    string[] str  = res.Split('\n');
                    string   str2 = "";
                    string[] str1 = str[nomer_striki].Split(' ');
                    id        = Convert.ToInt32(str1[0]);
                    Data.Text = str1[1];
                    Time.Text = str1[2];
                    for (int j = 3; j < str1.Length; j++)
                    {
                        str2 += str1[j] + " ";
                    }
                    Napominalka.Text = str2;
                }
            }


            Save.Click   += Save_Click;
            Cancel.Click += Cancel_Click;
        }