Example #1
0
 private void ImageViewNameEdit_Click(object sender, EventArgs e)
 {
     if (viewSwitcherName.CurrentView == linearLayoutDisplayName)
     {
         if (IsAdmin)
         {
             btnAudited.Visibility = ViewStates.Gone;
             viewSwitcherName.ShowNext();
             viewSwitcherInfo.ShowNext();
         }
         else
         {
             viewSwitcherName.ShowNext();
         }
     }
     else
     {
         if (IsAdmin)
         {
             btnAudited.Visibility = ViewStates.Visible;
             viewSwitcherName.ShowPrevious();
             viewSwitcherInfo.ShowPrevious();
         }
         else
         {
             viewSwitcherName.ShowPrevious();
         }
     }
 }
 protected void ShowEmptyview()
 {
     if (viewSwitcher.NextView.Id == Resource.Id.baseViewer_emptyText)
     {
         viewSwitcher.ShowNext();
     }
 }
Example #3
0
		static System.Threading.Thread LoadThread; //Поток, отвечающий за загрузку расписания

		protected override void OnCreate (Bundle bundle)
		{
			context = this;
			groups = Resources.GetTextArray (Resource.Array.group_codes);

			base.OnCreate (bundle);

			SetContentView (Resource.Layout.Main);
			//RequestWindowFeature (WindowFeatures.NoTitle);
			text = FindViewById<TextView> (Resource.Id.text);
			Button today = FindViewById<Button> (Resource.Id.today);
			Button tomorrow = FindViewById<Button> (Resource.Id.tomorrow);
			Button OnDate = FindViewById<Button> (Resource.Id.toDate);
			spinner = FindViewById<Spinner> (Resource.Id.spinner1);
			viewSwitcher = FindViewById<ViewSwitcher> (Resource.Id.viewSwitcher1);
			DateTime dateToday = DateTime.Today;
			DateTime dateTomorrow = DateTime.Today.AddDays (1);
			DatePicker datePicker = FindViewById<DatePicker> (Resource.Id.datePicker);
			ConnectivityManager cm = (ConnectivityManager)GetSystemService (Context.ConnectivityService);

			spinner.SetSelection (loadingGroup ());

		
			//Обработчики нажатий кнопок

			today.Click += delegate { //На сегодня
				savingGroup (spinner.SelectedItemPosition);
				if (cm.ActiveNetworkInfo != null) { //Если присутствует соединение с интернетом - запустить функцию, 
					StartLoadingThread (dateToday);// получающую расписание с сайта
				} else {
					text.Text = "Проверьте соединение с интернетом";//Иначе, выводит ошибку
					viewSwitcher.ShowNext ();
				}

			};
			tomorrow.Click += delegate { //На завтра
				savingGroup (spinner.SelectedItemPosition);
				if (cm.ActiveNetworkInfo != null) {
					StartLoadingThread (dateTomorrow);
				} else {
					text.Text = "Проверьте соединение с интернетом";
					viewSwitcher.ShowNext ();
				}

			};
			OnDate.Click += delegate {//На дату
				savingGroup (spinner.SelectedItemPosition);
				if (cm.ActiveNetworkInfo != null) {
					StartLoadingThread (datePicker.DateTime);
				} else {
					text.Text = "Проверьте соединение с интернетом";
					viewSwitcher.ShowNext ();
				}

			};
		}
 private void ShowEmptyviewIfNecessary()
 {
     if (_adapter.ItemCount == 0 && _viewSwitcher.NextView.Id == _emptyDraftLettersText.Id)
     {
         _viewSwitcher.ShowNext();
     }
     else if (_adapter.ItemCount > 0 && _viewSwitcher.CurrentView.Id != _lettersRecyclerView.Id)
     {
         _viewSwitcher.ShowNext();
     }
 }
Example #5
0
 private void ImageViewInfoEdit_Click(object sender, EventArgs e)
 {
     if (viewSwitcherInfo.CurrentView == linearLayoutDisplayInfo)
     {
         viewSwitcherInfo.ShowNext();
     }
     else
     {
         viewSwitcherInfo.ShowPrevious();
     }
 }
        protected void ShowEmptyview(string textToShow = null)
        {
            if (!string.IsNullOrWhiteSpace(textToShow))
            {
                emptyText.Text = textToShow;
            }

            if (viewSwitcher.NextView.Id == Resource.Id.baseViewer_emptyText)
            {
                viewSwitcher.ShowNext();
            }
        }
Example #7
0
        protected void ShowEmptyviewIfNecessary(List <Legislator> legislators)
        {
            if (legislators.Count > 0)
            {
                _legislatorsViewer.SetupCtrl(this, legislators, false);
            }
            else if (legislators.Count() == 0 && viewSwitcher.NextView.Id == Resource.Id.favortieLegislatorsFrag_emptyText)
            {
                viewSwitcher.ShowNext();
            }

            else if (legislators.Count() > 0 && viewSwitcher.CurrentView.Id != Resource.Id.favortieLegislatorsFrag_legislatorsViewer)
            {
                viewSwitcher.ShowNext();
            }
        }
        protected override void OnStart()
        {
            base.OnStart();
            active = true;
            var connectivityManager = (ConnectivityManager)GetSystemService(ConnectivityService);
            var activeConnection    = connectivityManager.ActiveNetworkInfo;

            if ((activeConnection == null) || !activeConnection.IsConnected)
            {
                // brak połączenia z siecią
                AlertDialog.Builder alert = new AlertDialog.Builder(this);

                alert.SetTitle("Błąd:");
                alert.SetMessage("Brak połączenia z internetem!");
                alert.SetPositiveButton("Ok", (senderAlert, args) => {
                    //
                });
                alert.Create().Show();
            }
            else
            {
                if (viewSwitcher.CurrentView != progressLayout)
                {
                    viewSwitcher.ShowNext();
                }
                GetData();
            }
        }
        /// Method Name     : SetEditModeViewSwitcherClick
        /// Author          : Sanket Prajapati
        /// Creation Date   : 2 Dec 2017
        /// Purpose         : Use for ViewSwitcher switch layout
        /// Revision        :
        /// </summary>
        private void SetEditModeViewSwitcherClick()
        {
            tvUpdates.Click += delegate
            {
                if (ViewSwitcher.CurrentView == relativeLayoutDisplay)
                {
                    ViewSwitcher.ShowNext();
                    tvback.Text = "Cancel";
                    tvNext.Text = "Next Step";
                    txtWMM.Text = tvWMMtitle.Text;
                }
            };

            tvSubmitChanges.Click += delegate
            {
                if (ViewSwitcher.CurrentView == relativeLayoutEdit)
                {
                    string strValidation = ValidationWMM();
                    if (string.IsNullOrEmpty(strValidation))
                    {
                        ViewSwitcher.ShowPrevious();
                        tvback.Text     = "Back";
                        tvNext.Text     = "Yes, Captured Correctly";
                        tvWMMtitle.Text = txtWMM.Text;
                        EditData();
                    }
                    else
                    {
                        AlertMessage(strValidation);
                    }
                }
            };
        }
 public override void OnStart()
 {
     base.OnStart();
     if (viewSwitcher.CurrentView != progressLayout)
     {
         viewSwitcher.ShowNext();
     }
     GetSpeechData();
 }
Example #11
0
 public override void OnStart()
 {
     base.OnStart();
     if (fragmentsTabs.Count > 0)
     {
         return;
     }
     if (viewSwitcher.CurrentView != progressLayout)
     {
         viewSwitcher.ShowNext();
     }
     GetData();
 }
Example #12
0
        /// Method Name     : SetEditModeViewSwitcherClick
        /// Author          : Sanket Prajapati
        /// Creation Date   : 2 Dec 2017
        /// Purpose         : Use for ViewSwitcher switch layout
        /// Revision        :
        /// </summary>
        private void SetEditModeViewSwitcherClick()
        {
            tvUpdatedneedes.Click += delegate
            {
                if (viewSwitcher.CurrentView == linearLayoutDisplay)
                {
                    viewSwitcher.ShowNext();
                    txtDeclaredvalue.Text = UtilityPCL.RemoveCurrencyFormat(tvDisplayDeclaredvalue.Text);
                    var list = UtilityPCL.ValuationDeductibleList();
                    valuationDeductible = new ValuationDeductibleModel();
                    valuationDeductible = list.FirstOrDefault(rc => rc.DeductibleName == tvDisplayCoverage.Text);
                    if (valuationDeductible != null)
                    {
                        spinnerCoverage.SetSelection(valuationDeductible.Index);
                    }
                    else
                    {
                        spinnerCoverage.SetSelection(1);
                    }
                    txtCost.Text = UtilityPCL.RemoveCurrencyFormat(tvDisplayCost.Text);
                    tvBack.Text  = StringResource.wizBtnCancel;
                    tvNext.Text  = StringResource.wizBtnNextStep;
                }
            };

            tvSubmitChanges.Click += delegate
            {
                if (viewSwitcher.CurrentView == linearLayoutEdit && Validation())
                {
                    viewSwitcher.ShowPrevious();
                    tvDisplayDeclaredvalue.Text = UtilityPCL.CurrencyFormat(txtDeclaredvalue.Text);
                    if (valuationDeductible != null)
                    {
                        tvDisplayCoverage.Text = valuationDeductible.DeductibleName;
                    }
                    else
                    {
                        var list = UtilityPCL.ValuationDeductibleList();
                        valuationDeductible    = new ValuationDeductibleModel();
                        valuationDeductible    = list.FirstOrDefault(rc => rc.DeductibleName == tvDisplayCoverage.Text);
                        tvDisplayCoverage.Text = valuationDeductible.DeductibleName;
                    }
                    tvDisplayCost.Text = UtilityPCL.CurrencyFormat(txtCost.Text);
                    EditData();
                    tvBack.Text = StringResource.wizBtnBack;
                    tvNext.Text = StringResource.wizYesCapturedCorrectly;
                }
            };
        }
Example #13
0
        /// Method Name     : SetEditModeViewSwitcherClick
        /// Author          : Sanket Prajapati
        /// Creation Date   : 2 Dec 2017
        /// Purpose         : Use for ViewSwitcher switch layout
        /// Revision        :
        /// </summary>
        private void SetEditModeViewSwitcherClick()
        {
            tvChangeDates.Click += delegate
            {
                if (viewSwitcher.CurrentView == linearLayoutDisplay)
                {
                    viewSwitcher.ShowNext();

                    tvDateEditPack.Text = tvDisplayPack.Text;
                    tvDateEditLoad.Text = tvDisplayLoad.Text;
                    tvDateEditMove.Text = tvDisplayMove.Text;

                    tvback.Text = "Cancel";
                    tvNext.Text = "Next Step";
                }
            };

            tvSubmitChanges.Click += delegate
            {
                if (viewSwitcher.CurrentView == linearLayoutEdit)
                {
                    string strValidate = ValidEditDate(false);
                    if (string.IsNullOrEmpty(strValidate))
                    {
                        viewSwitcher.ShowPrevious();
                        tvback.Text        = "Back";
                        tvNext.Text        = "Dates Are Accurate";
                        tvDisplayPack.Text = tvDateEditPack.Text;
                        tvDisplayLoad.Text = tvDateEditLoad.Text;
                        tvDisplayMove.Text = tvDateEditMove.Text;
                        EditData();
                    }
                    else
                    {
                        AlertMessage(strValidate);
                    }
                }
            };
        }
Example #14
0
        /// Method Name     : SetEditModeViewSwitcherClick
        /// Author          : Sanket Prajapati
        /// Creation Date   : 2 Dec 2017
        /// Purpose         : Use for ViewSwitcher switch layout
        /// Revision        :
        /// </summary>
        private void SetEditModeViewSwitcherClick()
        {
            textViewUpdatesAddresses.Click += delegate
            {
                if (viewSwitcher.CurrentView == linearLayoutDisplay)
                {
                    viewSwitcher.ShowNext();
                    tvback.Text = "Cancel";
                    tvNext.Text = "Next Step";

                    txtEditOriginAddress.Text      = txtDisplayOriginAddress.Text;
                    txtEditDestinationAddress.Text = txtDisplayDestinationAddress.Text;
                }
            };

            textViewSubmitChanges.Click += delegate
            {
                if (viewSwitcher.CurrentView == linearLayoutEdit)
                {
                    string strValidation = ValidationAddress();
                    if (string.IsNullOrEmpty(strValidation))
                    {
                        viewSwitcher.ShowPrevious();
                        tvback.Text = "Back";
                        tvNext.Text = "Yes, Captured Correctly";

                        txtDisplayOriginAddress.Text      = txtEditOriginAddress.Text;
                        txtDisplayDestinationAddress.Text = txtEditDestinationAddress.Text;
                        EditData();
                    }
                    else
                    {
                        AlertMessage(strValidation);
                    }
                }
            };
        }
Example #15
0
        static System.Threading.Thread LoadThread; //Поток, отвечающий за загрузку расписания

        protected override void OnCreate(Bundle bundle)
        {
            context = this;
            groups  = Resources.GetTextArray(Resource.Array.group_codes);

            base.OnCreate(bundle);

            SetContentView(Resource.Layout.Main);
            //RequestWindowFeature (WindowFeatures.NoTitle);
            text = FindViewById <TextView> (Resource.Id.text);
            Button today    = FindViewById <Button> (Resource.Id.today);
            Button tomorrow = FindViewById <Button> (Resource.Id.tomorrow);
            Button OnDate   = FindViewById <Button> (Resource.Id.toDate);

            spinner      = FindViewById <Spinner> (Resource.Id.spinner1);
            viewSwitcher = FindViewById <ViewSwitcher> (Resource.Id.viewSwitcher1);
            DateTime            dateToday    = DateTime.Today;
            DateTime            dateTomorrow = DateTime.Today.AddDays(1);
            DatePicker          datePicker   = FindViewById <DatePicker> (Resource.Id.datePicker);
            ConnectivityManager cm           = (ConnectivityManager)GetSystemService(Context.ConnectivityService);

            spinner.SetSelection(loadingGroup());


            //Обработчики нажатий кнопок

            today.Click += delegate {              //На сегодня
                savingGroup(spinner.SelectedItemPosition);
                if (cm.ActiveNetworkInfo != null)  //Если присутствует соединение с интернетом - запустить функцию,
                {
                    StartLoadingThread(dateToday); // получающую расписание с сайта
                }
                else
                {
                    text.Text = "Проверьте соединение с интернетом";                    //Иначе, выводит ошибку
                    viewSwitcher.ShowNext();
                }
            };
            tomorrow.Click += delegate {             //На завтра
                savingGroup(spinner.SelectedItemPosition);
                if (cm.ActiveNetworkInfo != null)
                {
                    StartLoadingThread(dateTomorrow);
                }
                else
                {
                    text.Text = "Проверьте соединение с интернетом";
                    viewSwitcher.ShowNext();
                }
            };
            OnDate.Click += delegate {            //На дату
                savingGroup(spinner.SelectedItemPosition);
                if (cm.ActiveNetworkInfo != null)
                {
                    StartLoadingThread(datePicker.DateTime);
                }
                else
                {
                    text.Text = "Проверьте соединение с интернетом";
                    viewSwitcher.ShowNext();
                }
            };
        }
Example #16
0
 private void OnTransitionEnded(object sender, KenBurnsView.TransitionEndEventArgs e)
 {
     viewSwitcher.ShowNext();
 }
Example #17
0
        protected override void OnCreate(Bundle bundle)
        {
            base.OnCreate(bundle);


            tripItem = JsonConvert.DeserializeObject <TripItem>(Intent.GetStringExtra("Trip"));
            friends  = new ObservableCollection <UserItem>();
            friends  = JsonConvert.DeserializeObject <ObservableCollection <UserItem> >(Intent.GetStringExtra("Friends"));
            try
            {
                paymentItem = JsonConvert.DeserializeObject <PaymentItem>(Intent.GetStringExtra("Payment"));
            }
            catch (Exception) {
                paymentItem = null;
            }

            friendsList.Add(new UserItem {
                Name = "Choose friend"
            });
            friendsList.AddRange(friends);
            // Set our view from the "main" layout resource
            SetContentView(Resource.Layout.PaymentAddLayout);
            Android.Support.V7.Widget.Toolbar toolbar = FindViewById <Android.Support.V7.Widget.Toolbar>(Resource.Id.toolbarAddPay);
            SetSupportActionBar(toolbar);
            SupportActionBar.SetDefaultDisplayHomeAsUpEnabled(true);



            Spinner spinner = FindViewById <Spinner>(Resource.Id.spinnerFriendsToPayment);

            listView     = FindViewById <ListView>(Resource.Id.listViewFriendsToPayment);
            editText     = FindViewById <TextView>(Resource.Id.textView6);
            viewSwitcher = FindViewById <ViewSwitcher>(Resource.Id.viewSwitcher1);
            //viewSwitcher.ShowNext();
            payName       = viewSwitcher.FindViewById <EditText>(Resource.Id.editTextName);
            payNameStatic = viewSwitcher.FindViewById <TextView>(Resource.Id.editTextNameNot);
            payNameStatic.SetFilters(new IInputFilter[] { new InputFilterLengthFilter(20) });
            payName.SetFilters(new IInputFilter[] { new InputFilterLengthFilter(20) });

            //editText.TextChanged += EditText_TextChanged;
            var swipeContainer = FindViewById <SwipeRefreshLayout>(Resource.Id.swipeContainer);

            swipeContainer.SetColorSchemeResources(Android.Resource.Color.HoloBlueLight, Android.Resource.Color.HoloGreenLight, Android.Resource.Color.HoloOrangeLight, Android.Resource.Color.HoloRedLight);
            swipeContainer.Refresh += SwipeContainer_Refresh;
            var button  = FindViewById <Button>(Resource.Id.button1);
            var button2 = FindViewById <Button>(Resource.Id.button2);

            button.Click += delegate {
                buttonClicked();
            };

            button2.Click        += Button2_Click;
            spinner.ItemSelected += spinner_ItemSelected;

            var adapter = new ArrayAdapter <UserItem>(this, Android.Resource.Layout.SimpleSpinnerItem, friendsList);

            spinner.Adapter  = adapter;
            friendsToPayment = new List <Tuple <string, decimal> >();
            if (paymentItem != null)
            {
                var friends_List = new List <UserItem>(friends);
                editText.Text      = "" + paymentItem.Amount;
                payNameStatic.Text = paymentItem.Name;
                button.Text        = "Edit";
                button2.Visibility = ViewStates.Visible;
                viewSwitcher.ShowNext();

                // foreach (var pay in payments)
                // {
                //   var item = friends_List.Find(i => i.Id == pay.UserId);
                //    Tuple <string, decimal> tup = new Tuple<string, decimal>(item.Name, pay.Amount);
                //    friendsToPayment.Add(tup);
                //}
            }
            getPayments();
            //var adapterPayemnt = new PaymentAddAdapter(this, friendsToPayment);

            //listView.Adapter = adapterPayemnt;
        }
Example #18
0
        protected override void OnCreate(Bundle bundle)
        {
            base.OnCreate(bundle);
            ActionBar.NavigationMode = ActionBarNavigationMode.Tabs;
            // Set our view from the "main" layout resource
            SetContentView(Resource.Layout.Main);

            ActionBar.Tab tab = ActionBar.NewTab();
            tab.SetText(Resources.GetString(Resource.String.calcTab));
            tab.TabSelected += (sender, args) =>
            {
                // Do something when tab is selected
            };
            ActionBar.AddTab(tab);

            tab = ActionBar.NewTab();
            tab.SetText(Resources.GetString(Resource.String.convertTab));
            tab.TabSelected += (sender, args) =>
            {
                // Do something when tab is selected
            };
            ActionBar.AddTab(tab);

            Button button0 = FindViewById <Button>(Resource.Id.Button0);
            Button button1 = FindViewById <Button>(Resource.Id.Button1);
            Button button2 = FindViewById <Button>(Resource.Id.Button2);
            Button button3 = FindViewById <Button>(Resource.Id.Button3);
            Button button4 = FindViewById <Button>(Resource.Id.Button4);
            Button button5 = FindViewById <Button>(Resource.Id.Button5);
            Button button6 = FindViewById <Button>(Resource.Id.Button6);
            Button button7 = FindViewById <Button>(Resource.Id.Button7);
            Button button8 = FindViewById <Button>(Resource.Id.Button8);
            Button button9 = FindViewById <Button>(Resource.Id.Button9);

            Button buttonAddition       = FindViewById <Button>(Resource.Id.ButtonAdd);
            Button buttonDivision       = FindViewById <Button>(Resource.Id.ButtonDiv);
            Button buttonFraction       = FindViewById <Button>(Resource.Id.ButtonFraction);
            Button buttonMultiplication = FindViewById <Button>(Resource.Id.ButtonMulti);
            Button buttonNegation       = FindViewById <Button>(Resource.Id.ButtonNegate);
            Button buttonSqrt           = FindViewById <Button>(Resource.Id.ButtonSqrt);
            Button buttonSubstraction   = FindViewById <Button>(Resource.Id.ButtonSub);
            Button buttonEqual          = FindViewById <Button>(Resource.Id.ButtonEqual);
            Button buttonBackspace      = FindViewById <Button>(Resource.Id.ButtonBackspace);
            Button buttonComma          = FindViewById <Button>(Resource.Id.ButtonComma);

            Button buttonC = FindViewById <Button>(Resource.Id.ButtonC);

            TextView resultField = FindViewById <TextView>(Resource.Id.textView1);
            TextView txt         = FindViewById <TextView>(Resource.Id.TextView);

            Button sin  = FindViewById <Button>(Resource.Id.sin);
            Button asin = FindViewById <Button>(Resource.Id.asin);
            Button cos  = FindViewById <Button>(Resource.Id.cos);
            Button acos = FindViewById <Button>(Resource.Id.acos);
            Button tan  = FindViewById <Button>(Resource.Id.tan);
            Button atan = FindViewById <Button>(Resource.Id.atan);
            Button ctg  = FindViewById <Button>(Resource.Id.ctg);
            Button actg = FindViewById <Button>(Resource.Id.actg);
            Button ln   = FindViewById <Button>(Resource.Id.ln);  // e
            Button log  = FindViewById <Button>(Resource.Id.log); // 10
            Button pi   = FindViewById <Button>(Resource.Id.pi);
            Button exp  = FindViewById <Button>(Resource.Id.exp);
            Button pov  = FindViewById <Button>(Resource.Id.pov);
            Button rand = FindViewById <Button>(Resource.Id.rand);
            Button mod  = FindViewById <Button>(Resource.Id.mod);
            Button div  = FindViewById <Button>(Resource.Id.div);

            #region button[0-9] handlers

            button0.Click += (object sender, EventArgs e) =>
            {
                if (_lastKeyInput == Keys.Operator)
                {
                    resultField.Text = "";
                }
                resultField.Text += 0;
                _lastKeyInput     = Keys.Digit;
            };

            button1.Click += (object sender, EventArgs e) =>
            {
                if (_lastKeyInput == Keys.Operator)
                {
                    resultField.Text = "";
                }
                resultField.Text += 1;
                _lastKeyInput     = Keys.Digit;
            };

            button2.Click += (object sender, EventArgs e) =>
            {
                if (_lastKeyInput == Keys.Operator)
                {
                    resultField.Text = "";
                }
                resultField.Text += 2;
                _lastKeyInput     = Keys.Digit;
            };

            button3.Click += (object sender, EventArgs e) =>
            {
                if (_lastKeyInput == Keys.Operator)
                {
                    resultField.Text = "";
                }
                resultField.Text += 3;
                _lastKeyInput     = Keys.Digit;
            };

            button4.Click += (object sender, EventArgs e) =>
            {
                if (_lastKeyInput == Keys.Operator)
                {
                    resultField.Text = "";
                }
                resultField.Text += 4;
                _lastKeyInput     = Keys.Digit;
            };

            button5.Click += (object sender, EventArgs e) =>
            {
                if (_lastKeyInput == Keys.Operator)
                {
                    resultField.Text = "";
                }
                resultField.Text += 5;
                _lastKeyInput     = Keys.Digit;
            };

            button6.Click += (object sender, EventArgs e) =>
            {
                if (_lastKeyInput == Keys.Operator)
                {
                    resultField.Text = "";
                }
                resultField.Text += 6;
                _lastKeyInput     = Keys.Digit;
            };

            button7.Click += (object sender, EventArgs e) =>
            {
                if (_lastKeyInput == Keys.Operator)
                {
                    resultField.Text = "";
                }
                resultField.Text += 7;
                _lastKeyInput     = Keys.Digit;
            };

            button8.Click += (object sender, EventArgs e) =>
            {
                if (_lastKeyInput == Keys.Operator)
                {
                    resultField.Text = "";
                }
                resultField.Text += 8;
                _lastKeyInput     = Keys.Digit;
            };

            button9.Click += (object sender, EventArgs e) =>
            {
                if (_lastKeyInput == Keys.Operator)
                {
                    resultField.Text = "";
                }
                resultField.Text += 9;
                _lastKeyInput     = Keys.Digit;
            };

            #endregion

            buttonAddition.Click += (object sender, EventArgs e) =>
            {
                if (_lastKeyInput == Keys.Digit || _lastKeyInput == Keys.Sign)
                {
                    parameters.Add(resultField.Text);
                    txt.Text        += resultField.Text + "+";
                    resultField.Text = "";

                    if (parameters.Count == 2)
                    {
                        double[] p = this.Parse(parameters);
                        double   r = op.Calculate(p);
                        resultField.Text = r.ToString();
                        parameters.Clear();
                        parameters.Add(r.ToString());
                    }

                    if (op == null || op.GetType() != typeof(Addition))
                    {
                        op = new Addition();
                    }
                    _lastKeyInput = Keys.Operator;
                    return;
                }

                if (_lastKeyInput == Keys.Operator)
                {
                    if (op == null || op.GetType() != typeof(Addition))
                    {
                        op       = new Addition();
                        txt.Text = ReplaceLastChar(txt.Text, '+');
                    }
                    _lastKeyInput = Keys.Operator;
                }
            };

            buttonSubstraction.Click += (object sender, EventArgs e) =>
            {
                if (_lastKeyInput == Keys.Digit || _lastKeyInput == Keys.Sign)
                {
                    parameters.Add(resultField.Text);
                    txt.Text        += resultField.Text + "-";
                    resultField.Text = "";

                    if (parameters.Count == 2)
                    {
                        double[] p = this.Parse(parameters);
                        double   r = op.Calculate(p);
                        resultField.Text = r.ToString();
                        parameters.Clear();
                        parameters.Add(r.ToString());
                    }

                    if (op == null || op.GetType() != typeof(Subtraction))
                    {
                        op = new Subtraction();
                    }
                    _lastKeyInput = Keys.Operator;
                    return;
                }

                if (_lastKeyInput == Keys.Operator)
                {
                    if (op == null || op.GetType() != typeof(Subtraction))
                    {
                        op       = new Subtraction();
                        txt.Text = ReplaceLastChar(txt.Text, '-');
                    }
                    _lastKeyInput = Keys.Operator;
                }
            };

            buttonMultiplication.Click += (object sender, EventArgs e) =>
            {
                if (_lastKeyInput == Keys.Digit || _lastKeyInput == Keys.Sign)
                {
                    parameters.Add(resultField.Text);
                    txt.Text        += resultField.Text + "*";
                    resultField.Text = "";

                    if (parameters.Count == 2)
                    {
                        double[] p = this.Parse(parameters);
                        double   r = op.Calculate(p);
                        resultField.Text = r.ToString();
                        parameters.Clear();
                        parameters.Add(r.ToString());
                    }

                    if (op == null || op.GetType() != typeof(Multiplication))
                    {
                        op = new Multiplication();
                    }

                    _lastKeyInput = Keys.Operator;
                    return;
                }

                if (_lastKeyInput == Keys.Operator)
                {
                    if (op == null || op.GetType() != typeof(Multiplication))
                    {
                        op       = new Multiplication();
                        txt.Text = ReplaceLastChar(txt.Text, '*');
                    }
                    _lastKeyInput = Keys.Operator;
                }
            };

            buttonDivision.Click += (object sender, EventArgs e) =>
            {
                if (_lastKeyInput == Keys.Digit || _lastKeyInput == Keys.Sign)
                {
                    parameters.Add(resultField.Text);
                    txt.Text        += resultField.Text + "/";
                    resultField.Text = "";

                    if (parameters.Count == 2)
                    {
                        double[] p = this.Parse(parameters);
                        double   r = op.Calculate(p);
                        resultField.Text = r.ToString();
                        parameters.Clear();
                        parameters.Add(r.ToString());
                    }
                    if (op == null || op.GetType() != typeof(Division))
                    {
                        op = new Division();
                    }

                    _lastKeyInput = Keys.Operator;
                    return;
                }

                if (_lastKeyInput == Keys.Operator)
                {
                    if (op == null || op.GetType() != typeof(Division))
                    {
                        op       = new Division();
                        txt.Text = ReplaceLastChar(txt.Text, '/');
                    }
                    _lastKeyInput = Keys.Operator;
                }
            };

            buttonEqual.Click += (object sender, EventArgs e) =>
            {
                if (_lastKeyInput == Keys.Digit || _lastKeyInput == Keys.Sign)
                {
                    parameters.Add(resultField.Text);
                    txt.Text = string.Empty;
                    if (parameters.Count == 2)
                    {
                        double r = op.Calculate(this.Parse(parameters));
                        resultField.Text = r.ToString();
                    }
                    _lastKeyInput = Keys.Equal;
                    return;
                }

                if (_lastKeyInput == Keys.Operator)
                {
                    txt.Text         = "";
                    resultField.Text = op.Calculate(double.Parse(parameters[0]), double.Parse(resultField.Text)).ToString();
                    parameters.Clear();
                    _lastKeyInput = Keys.Equal;
                    return;
                }

                if (_lastKeyInput == Keys.Equal && op != null)
                {
                    resultField.Text = op.Calculate(double.Parse(resultField.Text), double.Parse(resultField.Text)).ToString();
                    _lastKeyInput    = Keys.Equal;
                }
            };

            buttonNegation.Click += (object sender, EventArgs e) =>
            {
                if (_lastKeyInput == Keys.Digit || _lastKeyInput == Keys.Sign || _lastKeyInput == Keys.Equal)
                {
                    //if (op == null || op.GetType() != typeof(Negation))
                    //   op = new Negation();

                    resultField.Text = new Negation().Calculate(double.Parse(resultField.Text)).ToString();
                    //resultField.Text = op.Calculate(double.Parse(resultField.Text)).ToString();
                    _lastKeyInput = Keys.Sign;
                }
            };

            buttonSqrt.Click += (object sender, EventArgs e) =>
            {
                if (_lastKeyInput == Keys.Digit ||
                    _lastKeyInput == Keys.Sign ||
                    _lastKeyInput == Keys.Equal)
                {
                    resultField.Text = new Sqrt().Calculate(double.Parse(resultField.Text)).ToString();
                }
            };

            buttonFraction.Click += (object sender, EventArgs e) =>
            {
                if (_lastKeyInput == Keys.Digit || _lastKeyInput == Keys.Sign || _lastKeyInput == Keys.Equal)
                {
                    resultField.Text = new Fraction().Calculate(double.Parse(resultField.Text)).ToString();
                }
            };

            buttonBackspace.Click += (object sender, EventArgs e) =>
            {
                if (_lastKeyInput == Keys.Digit || _lastKeyInput == Keys.Equal)
                {
                    if (!(string.IsNullOrEmpty(resultField.Text)))
                    {
                        resultField.Text = resultField.Text.Substring(0, resultField.Text.Length - 1);
                    }
                }
            };

            buttonComma.Click += (object sender, EventArgs e) =>
            {
                if (_lastKeyInput == Keys.Digit || _lastKeyInput == Keys.Sign || _lastKeyInput == Keys.Equal)
                {
                    if (!(string.IsNullOrEmpty(resultField.Text)))
                    {
                        resultField.Text += '.';
                        _lastKeyInput     = Keys.DecimalPoint;
                    }
                    else
                    {
                        resultField.Text += "0.";
                    }
                }
                _lastKeyInput = Keys.DecimalPoint;
            };

            buttonC.Click += (object sender, EventArgs e) =>
            {
                op = null;
                resultField.Text = string.Empty;
                txt.Text         = string.Empty;
                parameters.Clear();
            };

            ViewSwitcher viewSwitcher = FindViewById <ViewSwitcher>(Resource.Id.viewSwitcher);
            LinearLayout calcView1    = FindViewById <LinearLayout>(Resource.Id.calcView1);
            LinearLayout calcView2    = FindViewById <LinearLayout>(Resource.Id.calcView2);
            Button       functions    = FindViewById <Button>(Resource.Id.functions);
            Button       standart     = FindViewById <Button>(Resource.Id.standart);

            functions.Click += (object sender, EventArgs e) =>
            {
                if (viewSwitcher.CurrentView != calcView2)
                {
                    viewSwitcher.ShowNext();
                }
            };

            standart.Click += (object sender, EventArgs e) =>
            {
                if (viewSwitcher.CurrentView == calcView2)
                {
                    viewSwitcher.ShowPrevious();
                }
            };
        }
Example #19
0
        protected override void OnCreate(Bundle savedInstanceState)
        {
            base.OnCreate(savedInstanceState);

            RequestWindowFeature(WindowFeatures.NoTitle);
            Window.AddFlags(WindowManagerFlags.KeepScreenOn);

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

            FindViewById <Button>(Resource.Id.paCloseB).Click += (sender, e) => {
                Finish();
            };

            FindViewById <Button>(Resource.Id.paExitAppB).Click += (sender, e) => {
                int count = 0;

                count += MainDatabase.CountItemsToSync <Attendance>();
                count += MainDatabase.CountItemsToSync <CompetitorData>();
                count += MainDatabase.CountItemsToSync <ContractData>();
                count += MainDatabase.CountItemsToSync <CoterieData>();
                count += MainDatabase.CountItemsToSync <DistributionData>();
                count += MainDatabase.CountItemsToSync <Pharmacy>();
                count += MainDatabase.CountItemsToSync <Employee>();

                count += MainDatabase.CountItemsToSync <GPSData>();

                count += MainDatabase.CountItemsToSync <Hospital>();
                count += MainDatabase.CountItemsToSync <HospitalData>();

                //var monthFinanceDatas = MainDatabase.GetItemsToSync<FinanceDataByMonth>();
                //var quarterFinanceDatas = MainDatabase.GetItemsToSync<FinanceDataByQuarter>();
                //var monthSaleDatas = MainDatabase.GetItemsToSync<SaleDataByMonth>();
                //var quarterSaleDatas = MainDatabase.GetItemsToSync<SaleDataByQuarter>();

                count += MainDatabase.CountItemsToSync <MessageData>();

                count += MainDatabase.CountItemsToSync <PresentationData>();
                count += MainDatabase.CountItemsToSync <PromotionData>();
                count += MainDatabase.CountItemsToSync <ResumeData>();
                count += MainDatabase.CountItemsToSync <RouteItem>();

                count += MainDatabase.CountItemsToSync <RouteItem>();

                count += MainDatabase.CountItemsToSync <PhotoData>();

                if (count > 0)
                {
                    new AlertDialog.Builder(this)
                    .SetTitle(Resource.String.warning_caption)
                    .SetMessage("Перед выходом необходимо синхронизировать все данные!!!")
                    .SetCancelable(true)
                    .SetPositiveButton("OK", (caller, arguments) => {
                        if (caller is Dialog)
                        {
                            (caller as Dialog).Dismiss();
                        }
                    })
                    .Show();
                }
                else
                {
                    GetSharedPreferences(MainActivity.C_MAIN_PREFS, FileCreationMode.Private)
                    .Edit()
                    .PutString(SigninDialog.C_USERNAME, string.Empty)
                    .Commit();
                    MainDatabase.Dispose();
                    Finish();
                }
            };

            Content = FindViewById <LinearLayout>(Resource.Id.paAttendanceByWeekLL);
            Table   = FindViewById <ListView>(Resource.Id.paAttendanceByWeekTable);

            int weeksCount = 14;

            Dates = new DateTimeOffset[weeksCount];
            var header = (LinearLayout)LayoutInflater.Inflate(Resource.Layout.AttendanceByWeekTableHeader, Table, false);

            (header.GetChildAt(0) as TextView).Text = @"Недели";
            for (int w = 0; w < weeksCount; w++)
            {
                Dates[w] = DateTimeOffset.UtcNow.AddDays(-7 * (weeksCount - 1 - w));
                var hView = header.GetChildAt(w + 1);
                if (hView is TextView)
                {
                    (hView as TextView).Text = Helper.GetIso8601WeekOfYear(Dates[w].UtcDateTime.Date).ToString();
                }
            }
            Content.AddView(header, 1);

            var shared = GetSharedPreferences(MainActivity.C_MAIN_PREFS, FileCreationMode.Private);

            FindViewById <TextView>(Resource.Id.paUsernameTV).Text = shared.GetString(SigninDialog.C_USERNAME, string.Empty);

            var agentUUID = shared.GetString(SigninDialog.C_AGENT_UUID, string.Empty);

            try {
                var agent = MainDatabase.GetItem <Agent>(agentUUID);
                FindViewById <TextView>(Resource.Id.paShortNameTV).Text = agent.shortName;
            } catch (Exception ex) {
                System.Diagnostics.Debug.WriteLine(ex.Message);
            }

            SearchSwitcher = FindViewById <ViewSwitcher>(Resource.Id.paSearchVS);
            SearchSwitcher.SetInAnimation(this, Android.Resource.Animation.SlideInLeft);
            SearchSwitcher.SetOutAnimation(this, Android.Resource.Animation.SlideOutRight);

            SearchImage        = FindViewById <ImageView>(Resource.Id.paSearchIV);
            SearchImage.Click += (sender, e) => {
                if (CurrentFocus != null)
                {
                    var imm = (InputMethodManager)GetSystemService(InputMethodService);
                    imm.HideSoftInputFromWindow(CurrentFocus.WindowToken, HideSoftInputFlags.None);
                }

                SearchSwitcher.ShowNext();
            };

            SearchEditor = FindViewById <EditText>(Resource.Id.paSearchET);

            SearchEditor.AfterTextChanged += (sender, e) => {
                var text = e.Editable.ToString();

                (Table.Adapter as AttendanceByWeekAdapter).SetSearchText(text);
            };
        }
Example #20
0
        protected override void OnCreate(Bundle savedInstanceState)
        {
            base.OnCreate(savedInstanceState);

            RequestWindowFeature(WindowFeatures.NoTitle);
            Window.AddFlags(WindowManagerFlags.KeepScreenOn);

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

            FindViewById <Button>(Resource.Id.raCloseB).Click += (s, e) => {
                MainDatabase.Dispose();
                Finish();
            };

            PharmacyTable            = FindViewById <ListView>(Resource.Id.raPharmacyTable);
            PharmacyTable.ItemClick += (sender, e) => {
                var ll      = (ListView)sender;
                var adapter = (RoutePharmacyAdapter)ll.Adapter;
                adapter.SwitchVisibility(e.Position);

                var row = LayoutInflater.Inflate(Resource.Layout.RouteItem, RouteTable, false);
                row.SetTag(Resource.String.Position, e.Position);

                RouteSearchItem item;
                if (string.IsNullOrEmpty(SearchEditor.Text))
                {
                    item = RouteSearchItems[e.Position];
                }
                else
                {
                    item = SearchedItems[e.Position];
                }

                //TODO: rename vars
                using (var trans = MainDatabase.BeginTransaction()){
                    var newRouteItem = MainDatabase.Create2 <RouteItem>();
                    newRouteItem.Pharmacy = item.UUID;
                    newRouteItem.Order    = RouteTable.ChildCount;
                    newRouteItem.Date     = SelectedDate;
                    trans.Commit();
                    row.SetTag(Resource.String.RouteItemUUID, newRouteItem.UUID);
                }
                row.SetTag(Resource.String.PharmacyUUID, item.UUID);

                row.FindViewById <TextView>(Resource.Id.riPharmacyTV).Text = item.Name;
                row.SetTag(Resource.String.RouteItemOrder, RouteTable.ChildCount);
                row.FindViewById <TextView>(Resource.Id.riOrderTV).Text = (RouteTable.ChildCount + 1).ToString();

                row.FindViewById <ImageView>(Resource.Id.riDeleteIV).Click += RowDelete_Click;
                row.LongClick += Row_LongClick;
                row.Drag      += Row_Drag;

                RouteTable.AddView(row);
            };

            RouteSearchItemsSource = new List <RouteSearchItem>();
            var pharmacies = MainDatabase.GetItems <Pharmacy>();

            foreach (var item in pharmacies)
            {
                RouteSearchItemsSource.Add(
                    new RouteSearchItem(
                        item.UUID,
                        string.IsNullOrEmpty(item.GetName()) ? string.Empty : item.GetName(),
                        string.IsNullOrEmpty(item.Subway) ? string.Empty : MainDatabase.GetItem <Subway>(item.Subway).name,
                        string.IsNullOrEmpty(item.Region) ? string.Empty : MainDatabase.GetItem <Region>(item.Region).name,
                        string.IsNullOrEmpty(item.Brand) ? string.Empty : item.Brand,
                        string.IsNullOrEmpty(item.Address) ? string.Empty : item.Address
                        )
                    );
            }
            SearchedItems  = new List <RouteSearchItem>();
            SearchSwitcher = FindViewById <ViewSwitcher>(Resource.Id.raSearchVS);
            SearchSwitcher.SetInAnimation(this, Android.Resource.Animation.SlideInLeft);
            SearchSwitcher.SetOutAnimation(this, Android.Resource.Animation.SlideOutRight);

            SearchImage        = FindViewById <ImageView>(Resource.Id.raSearchIV);
            SearchImage.Click += (sender, e) => {
                if (CurrentFocus != null)
                {
                    var imm = (InputMethodManager)GetSystemService(InputMethodService);
                    imm.HideSoftInputFromWindow(CurrentFocus.WindowToken, HideSoftInputFlags.None);
                }

                SearchSwitcher.ShowNext();
            };

            SearchEditor = FindViewById <EditText>(Resource.Id.raSearchET);

            SearchEditor.AfterTextChanged += (sender, e) => {
                var text = e.Editable.ToString();

                if (string.IsNullOrEmpty(text))
                {
                    foreach (var item in RouteSearchItems)
                    {
                        item.Match = string.Empty;
                    }
                    PharmacyTable.Adapter = new RoutePharmacyAdapter(this, RouteSearchItems);
                    return;
                }

                var w = new SDiag.Stopwatch();
                w.Start();
                SearchedItems = new List <RouteSearchItem>();
                var matchFormat = @"Совпадение: {0}";
                var culture     = CultureInfo.GetCultureInfo("ru-RU");
                // 2 поиск
                foreach (var item in RouteSearchItems)
                {
                    if (item.IsVisible)
                    {
                        //item.Subway = null;
                        if (culture.CompareInfo.IndexOf(item.Subway, text, CompareOptions.IgnoreCase) >= 0)
                        {
                            item.Match = string.Format(matchFormat, @"метро=" + item.Subway);
                            SearchedItems.Add(item);
                            //if (SearchedItems.Count > C_ITEMS_IN_RESULT) break;
                            continue;
                        }

                        if (culture.CompareInfo.IndexOf(item.Region, text, CompareOptions.IgnoreCase) >= 0)
                        {
                            item.Match = string.Format(matchFormat, @"район=" + item.Region);
                            SearchedItems.Add(item);
                            //if (SearchedItems.Count > C_ITEMS_IN_RESULT) break;
                            continue;
                        }

                        if (culture.CompareInfo.IndexOf(item.Brand, text, CompareOptions.IgnoreCase) >= 0)
                        {
                            item.Match = string.Format(matchFormat, @"бренд=" + item.Brand);
                            SearchedItems.Add(item);
                            //if (SearchedItems.Count > C_ITEMS_IN_RESULT) break;
                            continue;
                        }

                        if (culture.CompareInfo.IndexOf(item.Address, text, CompareOptions.IgnoreCase) >= 0)
                        {
                            item.Match = string.Format(matchFormat, @"адрес");
                            SearchedItems.Add(item);
                            //if (SearchedItems.Count > C_ITEMS_IN_RESULT) break;
                            continue;
                        }
                    }
                }
                w.Stop();
                SDiag.Debug.WriteLine(@"Search: поиск={0}", w.ElapsedMilliseconds);

                PharmacyTable.Adapter = new RoutePharmacyAdapter(this, SearchedItems);
            };

            RouteTable = FindViewById <LinearLayout>(Resource.Id.raRouteTable);

            FindViewById <Button>(Resource.Id.raSelectDateB).Click += (sender, e) => {
                DatePickerFragment frag = DatePickerFragment.NewInstance(delegate(DateTime date) {
                    SDiag.Debug.WriteLine("DatePicker:{0}", date.ToLongDateString());
                    SDiag.Debug.WriteLine("DatePicker:{0}", new DateTimeOffset(date));
                    SelectedDate = new DateTimeOffset(date, new TimeSpan(0, 0, 0));;
                    RefreshTables();
                });
                frag.Show(FragmentManager, DatePickerFragment.TAG);
            };

            Info      = FindViewById <TextView>(Resource.Id.raInfoTV);
            Info.Text = string.Format(@"Период планирования: {0} недели ({1} дней)", Helper.WeeksInRoute, Helper.WeeksInRoute * 5);

            var switcher = FindViewById <ViewSwitcher>(Resource.Id.raSwitchViewVS);

            FindViewById <ImageView>(Resource.Id.raSwitchIV).Click += (sender, e) => {
                SDiag.Debug.WriteLine(@"switcher:{0}; Resource{1}", switcher.CurrentView.Id, Resource.Id.raContainerVP);
                if (switcher.CurrentView.Id != Resource.Id.raContainerVP)
                {
                    Info.Text = string.Format(
                        @"Период планирования: {0} недели ({1} дней). Номер недели: {2}",
                        Helper.WeeksInRoute, Helper.WeeksInRoute * 5, 1
                        );
                    var pager = FindViewById <ViewPager>(Resource.Id.raContainerVP);
                    pager.AddOnPageChangeListener(this);
                    pager.Adapter = new RoutePagerAdapter(SupportFragmentManager);
                }
                else
                {
                    Info.Text = string.Format(@"Период планирования: {0} недели ({1} дней)", Helper.WeeksInRoute, Helper.WeeksInRoute * 5);
                }
                switcher.ShowNext();
            };
        }