Example #1
0
        private void PopulateList()
        {
            MovieCardAdaptor moviesAdapter;
            MovieCardAdaptor moviesAdapter2;
            var rdbtnChecked = radioGroup.GetChildAt(radioGroup.CheckedRadioButtonId);

//            if (radioGroup.CheckedRadioButtonId == Resource.Id.radioNowPlaying)
            moviesAdapter = new MovieCardAdaptor(this, npMovies);
            //          else
            moviesAdapter2 = new MovieCardAdaptor(this, csMovies);


            if (NpGallery != null)
            {
                NpGallery.ItemClick += OnListItemClick;
                NpGallery.Adapter    = moviesAdapter;
            }
            if (CsGallery != null)
            {
                CsGallery.ItemClick += OnListItemClick;
                CsGallery.Adapter    = moviesAdapter2;
            }
            //else
            //{
            //    moviesListView.ItemClick += OnListItemClick;
            //    moviesListView.Adapter = moviesAdapter;
            //}
        }
        //
        // Other helpers
        //

        private static void SetChildrenEnabled(RadioGroup radioGroup, bool enabled)
        {
            for (int i = radioGroup.ChildCount - 1; i >= 0; i--)
            {
                radioGroup.GetChildAt(i).Enabled = enabled;
            }
        }
        private async void Populate()
        {
            var student = await Services.Student.GetStudent();

            if (student != null)
            {
                if (student.dob.HasValue)
                {
                    date.Text  = ParseTwoDigits(student.dob.Value.Day.ToString());
                    month.Text = ParseTwoDigits(student.dob.Value.Month.ToString());
                    year.Text  = student.dob.Value.Year.ToString();
                }
                if (student.country_origin != null)
                {
                    country.Adapter = GetCountries(student.country_origin);
                }

                if (student.first_language != null)
                {
                    language.Adapter = GetLanguages(student.first_language);
                }

                if (student.degree != null)
                {
                    degree.Check(degree.GetChildAt((student.degree.Trim() == "UG") ? 0 : 1).Id);
                }

                if (student.status != null)
                {
                    status.Check(status.GetChildAt((student.status.Trim() == "Permanent") ? 0 : 1).Id);
                }
            }
        }
Example #4
0
        private void VerifyQuestion()
        {
            int childCount = radioGroupAnswers.ChildCount;

            for (int i = 0; i < childCount; i++)
            {
                RadioButton child = (RadioButton)radioGroupAnswers.GetChildAt(i);
                child.Clickable = false;
                if ((bool)child.Tag)
                {
                    child.SetTextColor(Android.Graphics.Color.Green);
                }
                if (child.Checked)
                {
                    if ((bool)child.Tag)
                    {
                        ++questionsAnswered;
                        questions[questionIndex].is_answered = true;
                        progressAnswered.Progress            = questionsAnswered;
                    }
                    else
                    {
                        ++questions[questionIndex].wrong_answers;
                        child.SetTextColor(Android.Graphics.Color.Red);
                    }
                }
            }
            FindViewById <Button>(Resource.Id.btnVerify).Visibility = ViewStates.Gone;
            FindViewById <Button>(Resource.Id.btnNext).Visibility   = ViewStates.Visible;
        }
        /// <summary>
        /// Create the dialogue
        /// </summary>
        /// <param name="savedInstanceState"></param>
        /// <returns></returns>
        public override Dialog OnCreateDialog(Bundle savedInstanceState)
        {
            // Create the custom view and initialise to the current Autoplay record
            View         dialogView            = LayoutInflater.From(Context).Inflate(Resource.Layout.autoplay_options_dialogue_layout, null);
            RadioGroup   spreadGroup           = dialogView.FindViewById <RadioGroup>(Resource.Id.spreadGroup);
            RadioGroup   targetGroup           = dialogView.FindViewById <RadioGroup>(Resource.Id.targetGroup);
            RadioGroup   weightGroup           = dialogView.FindViewById <RadioGroup>(Resource.Id.weightGroup);
            Spinner      fastSpreadSpinner     = dialogView.FindViewById <Spinner>(Resource.Id.fastSpreadLimit);
            LinearLayout fastSpreadLimitLayout = dialogView.FindViewById <LinearLayout>(Resource.Id.fastSpreadLimitLayout);

            ArrayAdapter <int> adapter = new ArrayAdapter <int>(Context, Resource.Layout.select_dialog_item_material, new int[] { 0, 1, 2, 3, 4, 5 });

            fastSpreadSpinner.Adapter = adapter;

            // Only initialise if we are not restoring
            if (savedInstanceState == null)
            {
                spreadGroup.Check(spreadGroup.GetChildAt(( int )AutoplayModel.CurrentAutoplay.Spread).Id);
                targetGroup.Check(targetGroup.GetChildAt(( int )AutoplayModel.CurrentAutoplay.Target).Id);
                weightGroup.Check(weightGroup.GetChildAt(( int )AutoplayModel.CurrentAutoplay.Weight).Id);
                fastSpreadSpinner.SetSelection(AutoplayModel.CurrentAutoplay.FastSpreadLimit);
            }

            // Show or hide the spinner (and text)
            fastSpreadLimitLayout.Visibility = (AutoplayModel.CurrentAutoplay.Spread == Autoplay.SpreadType.Fast) ? ViewStates.Visible : ViewStates.Gone;

            // We need to know when Fast Spread has been selected so that the spinner can be show or hidden as appropriate
            spreadGroup.CheckedChange += (sender, args) =>
            {
                fastSpreadLimitLayout.Visibility = ((Autoplay.SpreadType)GetIndexOfSelectedChild(spreadGroup) == Autoplay.SpreadType.Fast)
                                        ? ViewStates.Visible : ViewStates.Gone;
            };

            // Set up the handlers for the buttons
            // This layout contains its own buttons so that their order and position can be controlled
            dialogView.FindViewById <Button>(Resource.Id.auto_cancel).Click += (sender, args) => { Dismiss(); };

            // Report back the new Autoplay record for the Play and Queue buttons
            dialogView.FindViewById <Button>(Resource.Id.auto_play).Click += (sender, args) =>
            {
                reporter.Invoke(CreateNewAutoplay(spreadGroup, targetGroup, weightGroup, fastSpreadSpinner.SelectedItemPosition), true);
                Dismiss();
            };

            dialogView.FindViewById <Button>(Resource.Id.auto_queue).Click += (sender, args) =>
            {
                reporter.Invoke(CreateNewAutoplay(spreadGroup, targetGroup, weightGroup, fastSpreadSpinner.SelectedItemPosition), false);
                Dismiss();
            };

            // Create the AlertDialog with the custom view and none of its own buttons
            return(new AlertDialog.Builder(Activity)
                   .SetTitle("Autoplay options")
                   .SetView(dialogView)
                   .Create());
        }
Example #6
0
 private void SetNotesDetails()
 {
     try
     {
         txt_notes_val.SetText(Html.FromHtml(noteObj.NotesDetail), TextView.BufferType.Spannable);
         txt_notes_header_val.Text = noteObj.NotesSubject;
         if (noteObj.PrivacyId.Equals("1"))
         {
             ((RadioButton)radio_group.GetChildAt(0)).Checked = true;
         }
         else if (noteObj.PrivacyId.Equals("2"))
         {
             ((RadioButton)radio_group.GetChildAt(1)).Checked = true;
         }
     }
     catch (Exception)
     {
     }
 }
Example #7
0
        public void RandomEquation()
        {
            var    rnd        = new Random();
            var    number1    = rnd.Next(1, 12);
            var    number2    = rnd.Next(1, 12);
            var    rndAnswer1 = rnd.Next(0, 145);
            var    rndAnswer2 = rnd.Next(0, 145);
            var    rndAnswer3 = rnd.Next(0, 145);
            var    rndAnswer4 = rnd.Next(0, 145);
            var    operation  = rnd.Next(1, 4);
            string operationString;


            switch (operation)
            {
            case 1:
                answer          = number1 + number2;
                operationString = "+";
                break;

            case 2:
                answer          = number1 - number2;
                operationString = "-";
                break;

            case 3:
                answer          = number1 * number2;
                operationString = "*";
                break;

            case 4:
                answer          = number1 / number2;
                operationString = "/";
                break;

            default:
                answer          = 0;
                operationString = "An error has occurred.";
                break;
            }

            lblNum1.Text     = Convert.ToString(number1);
            lblNum2.Text     = Convert.ToString(number2);
            lblOperator.Text = operationString;

            rbA1.Text = Convert.ToString(rndAnswer1);
            rbA2.Text = Convert.ToString(rndAnswer2);
            rbA3.Text = Convert.ToString(rndAnswer3);
            rbA4.Text = Convert.ToString(rndAnswer4);

            View        v    = rbGroup.GetChildAt(operation);
            RadioButton test = (RadioButton)v;

            test.Text = Convert.ToString(answer);
        }
Example #8
0
 private void SetControlsEnabled(bool enabled)
 {
     playButton.Enabled   = enabled;
     pauseButton.Enabled  = enabled;
     skipTo.Enabled       = enabled;
     videoChooser.Enabled = enabled;
     for (int i = 0; i < styleRadioGroup.ChildCount; i++)
     {
         styleRadioGroup.GetChildAt(i).Enabled = enabled;
     }
 }
Example #9
0
        private string createBoardConfig()
        {
            //Get the player count
            int        playerCount   = 3;
            RadioGroup NumberPlayers = FindViewById <RadioGroup>(Resource.Id.NumberPlayers);

            for (int i = 0; i < NumberPlayers.ChildCount; i++)
            {
                RadioButton v = (RadioButton)NumberPlayers.GetChildAt(i);
                if (v.Checked)
                {
                    playerCount = i + 3;
                }
            }

            //Get the game type
            string[]   gameTypes = { "base", "seafarers" };
            string     gameType  = "base";
            RadioGroup GameType  = FindViewById <RadioGroup>(Resource.Id.GameType);

            for (int i = 0; i < GameType.ChildCount; i++)
            {
                RadioButton v = (RadioButton)GameType.GetChildAt(i);
                if (v.Checked)
                {
                    gameType = gameTypes[i];
                }
            }

            //Get the Scenario Number
            int        scenarioNumber = 1;
            RadioGroup Scenario       = FindViewById <RadioGroup>(Resource.Id.Scenario);

            for (int i = 0; i < Scenario.ChildCount; i++)
            {
                RadioButton v = (RadioButton)Scenario.GetChildAt(i);
                if (v.Checked)
                {
                    scenarioNumber = i + 1;
                }
            }

            if (gameType == "base")
            {
                return(gameType + "_" + playerCount);
            }

            return(gameType + "_" + playerCount + "_" + scenarioNumber);
        }
Example #10
0
 protected override void OnCreate(Bundle bundle)
 {
     base.OnCreate(bundle);
     // Set our view from the "main" layout resource
     SetContentView(Resource.Layout.Main);
     radioGroup = FindViewById <RadioGroup>(Resource.Id.mGroup);
     //register focus change event for every sub radio button.
     for (int i = 0; i < radioGroup.ChildCount; i++)
     {
         var child = radioGroup.GetChildAt(i);
         if (child is RadioButton)
         {
             ((RadioButton)child).FocusChange += RadioButton_FocusChange;
         }
     }
 }
Example #11
0
        private void SetCurrentATask()
        {
            var curTask = test.GetATask(currentTaskNum);

            if (curTask != null)
            {
                taskNameLabel.Text = "A" + (currentTaskNum + 1);
                taskLabel.Text     = curTask.Desc;
                if (!String.IsNullOrEmpty(curTask.ImageLink))
                {
                    taskImage.Visibility = ViewStates.Visible;
                    using (Stream ims = Assets.Open(curTask.ImageLink)) {
                        Drawable d = Drawable.CreateFromStream(ims, null);
                        taskImage.SetImageDrawable(d);
                    }
                }
                RadioGroup variantGroup = new RadioGroup(this);
                variantGroup.CheckedChange += (object sender, RadioGroup.CheckedChangeEventArgs e) => {
                    if (e.CheckedId != -1)
                    {
                        for (int i = 0; i < variantGroup.ChildCount; i++)
                        {
                            RadioButton child = (RadioButton)variantGroup.GetChildAt(i);
                            if (child.Id == e.CheckedId)
                            {
                                aAnswers [currentTaskNum] = i;
                            }
                        }
                    }
                };
                variantGroup.Orientation = Orientation.Vertical;
                int index = 0;
                foreach (var variant in curTask.Variants)
                {
                    RadioButton variantRadio = new RadioButton(this);
                    variantRadio.Text = variant;
                    variantGroup.AddView(variantRadio);
                    if ((aAnswers[currentTaskNum] != NoSelectedAnswers) && (index == aAnswers[currentTaskNum]))
                    {
                        variantGroup.Check(variantRadio.Id);
                    }
                    index++;
                }

                variantsLayout.AddView(variantGroup);
            }
        }
        /// <summary>
        /// Programmatically generates RadioButtons and adds them to the given RadioGroup with a given list as Dictionary.
        /// </summary>
        /// <param name="context">Context</param>
        /// <param name="radioGroup">RadioGroup</param>
        /// <param name="list">List</param>
        /// <param name="defaultIndex">default index</param>
        public static void PopulateRadioGroupWithList(Activity context, RadioGroup radioGroup, Dictionary <String, EnergyScanView.ScanMode> list, int defaultIndex)
        {
            //if list is empty, remove the radio group
            if (list == null)
            {
                context.FindViewById <RelativeLayout>(Resource.Id.root).RemoveView(radioGroup);
                return;
            }

            foreach (var pair in list)
            {
                var radioButton = new RadioButton(context)
                {
                    Text = pair.Key
                };
                radioGroup.AddView(radioButton, radioGroup.ChildCount, radioGroup.LayoutParameters);
            }

            radioGroup.Check(radioGroup.GetChildAt(defaultIndex).Id);
        }
Example #13
0
        /// <summary>
        /// Init this instance.
        /// </summary>
        private void Init()
        {
            // Init toolbar
            toolbar = FindViewById <Android.Support.V7.Widget.Toolbar>(Resource.Id.app_bar);
            SetSupportActionBar(toolbar);

            // Set toolbar title Add or Edit according to condition
            SetToolbarTitle();
            // Set font for title
            ApplyFontForToolbarTitle();

            SupportActionBar.SetDisplayHomeAsUpEnabled(true);

            spin_current_entity  = FindViewById <Spinner>(Resource.Id.spin_current_entity);
            spin_account_code    = FindViewById <Spinner>(Resource.Id.spin_account_code);
            txt_notes_val        = FindViewById <EditText>(Resource.Id.txt_notes_val);
            txt_notes_header_val = FindViewById <EditText>(Resource.Id.edt_notes_header_val);


            Button btn_save = FindViewById <Button>(Resource.Id.btn_save);

            btn_save.Click += Btn_save_Click;

            Button btn_cancel = FindViewById <Button>(Resource.Id.btn_cancel);

            btn_cancel.Click += Btn_cancel_Click;

            txt_calendar_type = FindViewById <TextView>(Resource.Id.txt_calendar_type);

            radio_group = FindViewById <RadioGroup>(Resource.Id.radio_group);
            ((RadioButton)radio_group.GetChildAt(0)).Checked = true;
            radio_group.CheckedChange += Radio_group_CheckedChange;
            privacyId = "1";
            // Set Current Entity in Spinner
            InitEntitySpinnerValues();

            // Initialize listener for spinner
            InitializeListeners();
        }
Example #14
0
        public void init()
        {
            RadioGroup radiogroup = (RadioGroup)root.FindViewById(Resource.Id.bottombar);

            radiogroup.CheckedChange += changeChecked;
            int countBtns = radiogroup.ChildCount;

            if (countBtns == 0)
            {
                return;
            }
            LinearLayout linearLayoutE = (LinearLayout)root.FindViewById(Resource.Id.example);

            param = linearLayoutE.LayoutParameters;
            DisplayMetrics dm = Resources.DisplayMetrics;
            int            id = radiogroup.GetChildAt(0).Id;

            ((RadioButton)root.FindViewById(id)).Checked = true;
            param.Width = dm.WidthPixels / countBtns;
            for (int i = 0; i < countBtns; i++)
            {
                root.FindViewById(id++).LayoutParameters = param;
            }
        }
Example #15
0
        protected override void OnCreate(Bundle savedInstanceState)
        {
            base.OnCreate(savedInstanceState);
            Xamarin.Essentials.Platform.Init(this, savedInstanceState);
            // Set our view from the "main" layout resource
            SetContentView(Resource.Layout.activity_saveload);

            //When the NumberPlayers radio group is changed
            RadioGroup NumberPlayers = FindViewById <RadioGroup>(Resource.Id.NumberPlayers);

            NumberPlayers.CheckedChange += (sender, e) =>
            {
                //Make those radio buttons invisible
                NumberPlayers.Visibility = ViewStates.Gone;

                //Display the chosen option
                TextView NumberPlayersText = FindViewById <TextView>(Resource.Id.NumberPlayersText);
                for (int i = 0; i < NumberPlayers.ChildCount; i++)
                {
                    RadioButton currentRadioButton = (RadioButton)NumberPlayers.GetChildAt(i);
                    if (currentRadioButton.Checked)
                    {
                        int n = i + 3;
                        NumberPlayersText.Text = "Number of Players: " + n;
                    }
                }

                //Show the next prompt
                TextView GameTypeText = FindViewById <TextView>(Resource.Id.GameTypeText);
                GameTypeText.Visibility = ViewStates.Visible;

                RadioGroup GameType = FindViewById <RadioGroup>(Resource.Id.GameType);
                GameType.Visibility = ViewStates.Visible;
            };


            //When the GameType radio group is changed
            RadioGroup GameType = FindViewById <RadioGroup>(Resource.Id.GameType);

            GameType.CheckedChange += (sender, e) =>
            {
                //Make those radio buttons invisible
                GameType.Visibility = ViewStates.Gone;

                //Display the chosen option
                TextView GameTypeText = FindViewById <TextView>(Resource.Id.GameTypeText);
                for (int i = 0; i < GameType.ChildCount; i++)
                {
                    RadioButton currentRadioButton = (RadioButton)GameType.GetChildAt(i);
                    if (currentRadioButton.Checked && i == 0)
                    {
                        GameTypeText.Text = "Game Type: Base";

                        //Display the confirm board config button
                        Button LoadConfig = FindViewById <Button>(Resource.Id.LoadConfig);
                        LoadConfig.Visibility = ViewStates.Visible;
                    }
                    else if (currentRadioButton.Checked && i == 1)
                    {
                        GameTypeText.Text = "Game Type: Seafarers";

                        //Get the radio group with the scenario radio buttons in it
                        RadioGroup Scenario     = FindViewById <RadioGroup>(Resource.Id.Scenario);
                        TextView   ScenarioText = FindViewById <TextView>(Resource.Id.ScenarioText);

                        //Set the scenario text and radio buttons to be visible
                        ScenarioText.Visibility = ViewStates.Visible;
                        Scenario.Visibility     = ViewStates.Visible;

                        //Set the specific scenario radio buttons to be clickable
                        for (int j = 0; j < Scenario.ChildCount; j++)
                        {
                            View v = Scenario.GetChildAt(j);
                            v.Clickable = true;
                        }
                    }
                }
            };



            //When the Scenario radio group is changed
            RadioGroup Scenario = FindViewById <RadioGroup>(Resource.Id.Scenario);

            Scenario.CheckedChange += (sender, e) =>
            {
                //Make those radio buttons invisible
                Scenario.Visibility = ViewStates.Gone;

                //Display the chosen option
                TextView ScenarioText = FindViewById <TextView>(Resource.Id.ScenarioText);
                for (int i = 0; i < Scenario.ChildCount; i++)
                {
                    RadioButton currentRadioButton = (RadioButton)Scenario.GetChildAt(i);
                    if (currentRadioButton.Checked)
                    {
                        switch (i)
                        {
                        case (0):
                            ScenarioText.Text = "Scenario 1: Heading to New Shores";
                            break;

                        case (1):
                            ScenarioText.Text = "Scenario 2: The Four Islands";
                            break;

                        case (2):
                            ScenarioText.Text = "Scenario 3: The Fog Islands";
                            break;

                        case (3):
                            ScenarioText.Text = "Scenario 4: Through the Desert";
                            break;

                        case (4):
                            ScenarioText.Text = "Scenario 5: The Forgotten Tribe";
                            break;

                        case (5):
                            ScenarioText.Text = "Scenario 6: Cloth for Catan";
                            break;

                        case (6):
                            ScenarioText.Text = "Scenario 7: The Pirate Islands";
                            break;

                        case (7):
                            ScenarioText.Text = "Scenario 8: The Wonders of Catan";
                            break;

                        case (8):
                            ScenarioText.Text = "Scenario 9: New World";
                            break;
                        }
                    }
                }

                //Display the confirm board config button
                Button LoadConfig = FindViewById <Button>(Resource.Id.LoadConfig);
                LoadConfig.Visibility = ViewStates.Visible;
            };



            //Do reset button things
            ImageButton resetButton = FindViewById <ImageButton>(Resource.Id.resetButton);

            resetButton.SetImageResource(Resource.Drawable.ResetButton);
            resetButton.Click += (sender, e) =>
            {
                Finish();
                OverridePendingTransition(0, 0);
                StartActivity(Intent);
                OverridePendingTransition(0, 0);
            };


            //Get the LoadConfig button
            Button LoadConfig = FindViewById <Button>(Resource.Id.LoadConfig);

            //When we click this button
            LoadConfig.Click += (sender, e) =>
            {
                if (!loading)
                {
                    //Make sure we don't load the config and start the generator activity twice
                    loading = true;

                    //Create an intent to launch the Generator Activity
                    Intent generatorIntent = new Intent(this, typeof(GeneratorActivity));

                    //Add the necessary data to the intent
                    generatorIntent.PutExtra("BoardConfig", createBoardConfig());

                    //Start the activity
                    StartActivity(generatorIntent);

                    //close this activity
                    Finish();
                }
            };
        }
Example #16
0
        public override void OnBindViewHolder(RecyclerView.ViewHolder holder, int position)
        {
            TaskViewHolder vh;

            Type thisType = holder.GetType();

            OnBind = true;

            if (Curator)
            {
                if (position == 0)
                {
                    return;
                }
            }

            if (position == 0 || (Curator && position == 1))
            {
                // Activity description + entered names (if required)
                vh = holder as TaskViewHolderName;
                if (vh == null)
                {
                    return;
                }

                vh.Title.Text       = description;
                vh.Description.Text = context.Resources.GetString(Resource.String.TasksTitle);

                ((TaskViewHolderName)vh).NameSection.Visibility =
                    (reqName) ? ViewStates.Visible : ViewStates.Gone;
                ((TaskViewHolderName)vh).EnteredNames.Text = names;

                return;
            }

            if (position == Items.Count - 1)
            {
                // Finish button
                if (holder is ButtonViewHolder bvh)
                {
                    bvh.Button.Enabled = true;
                }

                return;
            }

            string taskType = Items[position].TaskType.IdName;

            if (thisType == typeof(TaskViewHolderInfo))
            {
                AdditionalInfoData taskInfo = JsonConvert.DeserializeObject <AdditionalInfoData>(Items[position].JsonData);
                vh = holder as TaskViewHolderInfo;
                Items[position].IsCompleted = true;

                if (!string.IsNullOrWhiteSpace(taskInfo.ImageUrl))
                {
                    Items[position].ImageUrl = taskInfo.ImageUrl;
                }

                TaskViewHolderInfo taskViewHolderInfo = (TaskViewHolderInfo)vh;
                if (taskViewHolderInfo != null)
                {
                    taskViewHolderInfo.Button.Visibility =
                        (string.IsNullOrWhiteSpace(taskInfo.ExternalUrl)) ? ViewStates.Gone : ViewStates.Visible;
                }
            }
            else if (thisType == typeof(TaskViewHolderRecordAudio))
            {
                vh = holder as TaskViewHolderRecordAudio;
                if (vh != null)
                {
                    ((TaskViewHolderRecordAudio)vh).StartTaskButton.Text =
                        context.Resources.GetString(Resource.String.StartBtn);

                    if (!string.IsNullOrWhiteSpace(Items[position].CompletionData.JsonData))
                    {
                        List <string> audioPaths =
                            JsonConvert.DeserializeObject <List <string> >(Items[position].CompletionData.JsonData);

                        ((TaskViewHolderRecordAudio)vh).ShowResults(audioPaths, context);
                        Items[position].IsCompleted = true;
                    }
                    else
                    {
                        Items[position].IsCompleted = false;
                        ((TaskViewHolderRecordAudio)vh).ClearResults();
                    }
                }
            }
            else if (thisType == typeof(TaskViewHolderRecordVideo))
            {
                vh = holder as TaskViewHolderRecordVideo;
                if (vh != null)
                {
                    ((TaskViewHolderRecordVideo)vh).StartTaskButton.Text =
                        context.Resources.GetString(Resource.String.RecBtn);

                    if (!string.IsNullOrWhiteSpace(Items[position].CompletionData.JsonData))
                    {
                        List <string> videoPaths =
                            JsonConvert.DeserializeObject <List <string> >(Items[position].CompletionData.JsonData);

                        ((TaskViewHolderRecordVideo)vh).ShowResults(videoPaths, context);
                        Items[position].IsCompleted = true;
                    }
                    else
                    {
                        Items[position].IsCompleted = false;
                        ((TaskViewHolderRecordVideo)vh).ClearResults();
                    }
                }
            }
            else if (thisType == typeof(TaskViewHolderResultList))
            {
                vh = holder as TaskViewHolderResultList;

                bool   btnEnabled = true;
                string btnText;

                if (taskType == "DRAW" || taskType == "DRAW_PHOTO")
                {
                    btnText = context.Resources.GetString(Resource.String.StartDrawBtn);

                    if (taskType == "DRAW_PHOTO")
                    {
                        btnEnabled = !int.TryParse(Items[position].JsonData, out var idResult) || GetTaskWithId(idResult).IsCompleted;

                        if (!btnEnabled)
                        {
                            btnText = context.Resources.GetString(Resource.String.TaskBtnNotReady);
                        }
                    }
                }
                else
                {
                    btnText = context.Resources.GetString(Resource.String.TakePhotoBtn);
                }

                if (vh != null)
                {
                    ((TaskViewHolderResultList)vh).StartTaskButton.Text    = btnText;
                    ((TaskViewHolderResultList)vh).StartTaskButton.Enabled = btnEnabled;

                    if (!string.IsNullOrWhiteSpace(Items[position].CompletionData.JsonData))
                    {
                        List <string> photoPaths =
                            JsonConvert.DeserializeObject <List <string> >(Items[position].CompletionData.JsonData);

                        ((TaskViewHolderResultList)vh).ShowResults(photoPaths, context);
                        Items[position].IsCompleted = true;
                    }
                    else
                    {
                        Items[position].IsCompleted = false;
                        ((TaskViewHolderResultList)vh).ClearResults();
                    }
                }
            }
            else if (thisType == typeof(TaskViewHolderBtn))
            {
                vh = holder as TaskViewHolderBtn;
                string btnText = context.Resources.GetString(Resource.String.TaskBtn);

                if (taskType == "LISTEN_AUDIO")
                {
                    btnText = context.Resources.GetString(Resource.String.ListenBtn);
                }

                TaskViewHolderBtn viewHolderBtn = (TaskViewHolderBtn)vh;
                if (viewHolderBtn != null)
                {
                    viewHolderBtn.Button.Text = btnText;
                }
            }
            else if (thisType == typeof(TaskViewHolderTextEntry))
            {
                vh = holder as TaskViewHolderTextEntry;
                if (vh != null)
                {
                    ((TaskViewHolderTextEntry)vh).TextField.Text = Items[position].CompletionData.JsonData;
                    Items[position].IsCompleted =
                        !string.IsNullOrWhiteSpace(((TaskViewHolderTextEntry)vh).TextField.Text);
                }
            }
            else
            {
                if (thisType == typeof(TaskViewHolderMultipleChoice))
                {
                    vh = holder as TaskViewHolderMultipleChoice;
                    RadioGroup radios = ((TaskViewHolderMultipleChoice)vh)?.RadioGroup;

                    string[] choices = JsonConvert.DeserializeObject <string[]>(Items[position].JsonData);
                    int.TryParse(Items[position].CompletionData.JsonData, out var answeredInd);

                    if (radios != null && radios.ChildCount == 0)
                    {
                        int index = 0;
                        foreach (string option in choices)
                        {
                            RadioButton rad = new RadioButton(context)
                            {
                                Text = option
                            };
                            rad.SetPadding(0, 0, 0, 5);
                            rad.TextSize = 16;
                            radios.AddView(rad);

                            if (Items[position].IsCompleted && answeredInd == index)
                            {
                                ((RadioButton)radios.GetChildAt(answeredInd)).Checked = true;
                            }
                            index++;
                        }
                    }

                    if (answeredInd == -1)
                    {
                        Items[position].IsCompleted = false;
                    }

                    if (radios != null)
                    {
                        radios.CheckedChange += (sender, e) =>
                        {
                            Items[position].IsCompleted = true;
                            int  radioButtonId = radios.CheckedRadioButtonId;
                            View radioButton   = radios.FindViewById(radioButtonId);
                            int  idx           = radios.IndexOfChild(radioButton);
                            Items[position].CompletionData.JsonData = idx.ToString();
                            NotifyItemChanged(Items.Count - 1);
                        };
                    }
                }
                else if (thisType == typeof(TaskViewHolderMap))
                {
                    vh = holder as TaskViewHolderMap;
                    TaskViewHolderMap mapHolder = ((TaskViewHolderMap)vh);

                    if (taskType == "MAP_MARK")
                    {
                        List <Map_Location> points = JsonConvert.DeserializeObject <List <Map_Location> >(Items[position].CompletionData.JsonData);

                        if (points != null && points.Count > 0)
                        {
                            if (mapHolder != null)
                            {
                                mapHolder.EnteredLocationsView.Visibility = ViewStates.Visible;
                                mapHolder.EnteredLocationsView.Text       = string.Format(
                                    context.Resources.GetString(Resource.String.ChosenLocations),
                                    points.Count,
                                    (points.Count > 1) ? "s" : "");
                            }

                            Items[position].IsCompleted = true;
                        }
                        else
                        {
                            if (mapHolder != null)
                            {
                                mapHolder.EnteredLocationsView.Visibility = ViewStates.Gone;
                            }

                            Items[position].IsCompleted = false;
                        }
                    }
                }
                else
                {
                    vh = holder as TaskViewHolder;
                }
            }

            // These apply to all task types:
            AndroidUtils.LoadTaskTypeIcon(Items[position].TaskType, ((TaskViewHolder)holder).TaskTypeIcon);

            if (!string.IsNullOrWhiteSpace(Items[position].ImageUrl))
            {
                AndroidUtils.LoadActivityImageIntoView(vh.TaskImage, Items[position].ImageUrl, activityId, 350);
            }
            else
            {
                if (vh != null)
                {
                    vh.TaskImage.Visibility = ViewStates.Gone;
                }
            }

            vh.Description.Text = Items[position].Description;
            vh.Title.Text       = Items[position].TaskType.DisplayName;

            bool hasChildren = Items[position].ChildTasks != null && Items[position].ChildTasks.Any();

            if (Items[position].TaskType.IdName == "ENTER_TEXT")
            {
                vh.LockedChildrenTease.Visibility = ViewStates.Gone;
            }
            else if (hasChildren && !Items[position].IsCompleted)
            {
                vh.LockedChildrenTease.Visibility = ViewStates.Visible;
                int childCount = Items[position].ChildTasks.Count();
                vh.LockedChildrenTease.Text = string.Format(
                    context.GetString(Resource.String.taskLockedParent),
                    childCount,
                    (childCount > 1) ? "s" : "");
            }
            else if (hasChildren && Items[position].IsCompleted)
            {
                vh.LockedChildrenTease.Visibility = ViewStates.Visible;
                vh.LockedChildrenTease.Text       = context.GetString(Resource.String.taskUnlockedParent);
            }
            else
            {
                vh.LockedChildrenTease.Visibility = ViewStates.Gone;
            }

            OnBind = false;
        }
Example #17
0
        protected override async void OnCreate(Bundle savedInstanceState)
        {
            base.OnCreate(savedInstanceState);

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

            dbConfig.ServiceURL           = "https://026821060357.signin.aws.amazon.com/console/dynamobdb/";
            dbConfig.AuthenticationRegion = "dynamodb.us-east-1.amazonaws.com";
            dbConfig.RegionEndpoint       = RegionEndpoint.USEast1;

            AmazonDynamoDBClient dynDBClient = new AmazonDynamoDBClient("AKIAIMDIMZSEHYRAI6CQ", "6B2FRtd4JZiwq2iqiQJOmJPytboQ7EDOb08xovN3", dbConfig.RegionEndpoint);


            //dynDBClient.Config.ServiceURL= "https://console.aws.amazon.com/dynamodb/";
            dynDBClient.Config.ServiceURL     = "https://026821060357.signin.aws.amazon.com/console/dynamodb/";
            dynDBClient.Config.RegionEndpoint = RegionEndpoint.USEast1;
            DynamoDBContext dynContext = new DynamoDBContext(dynDBClient);

            AsyncSearch <ShoppingCart> listDataCartItems = dynContext.FromScanAsync <ShoppingCart>(new ScanOperationConfig()
            {
                ConsistentRead = true
            });


            List <ShoppingCart> dataCartItems = await listDataCartItems.GetRemainingAsync();

            Button     btnCheckout        = FindViewById <Button>(Resource.Id.btnCheckout);
            Button     btnBack            = FindViewById <Button>(Resource.Id.btnBack);
            Button     btnEnterOrder      = FindViewById <Button>(Resource.Id.btnEnterOrder);
            GridLayout grdOrderEntry      = FindViewById <GridLayout>(Resource.Id.grdOrderEntry);
            TextView   tvCustName         = FindViewById <TextView>(Resource.Id.tvCustName);
            EditText   edtItemDescription = FindViewById <EditText>(Resource.Id.edtItemDescription);
            EditText   edtPrice           = FindViewById <EditText>(Resource.Id.edtPrice);
            EditText   edtQuant           = FindViewById <EditText>(Resource.Id.edtQuant);
            DateTime   dtOrderDate        = DateTime.Today;

            strOrderDate  = dtOrderDate.ToString("MM/dd/yyyy");
            strCustFName  = this.Intent.GetStringExtra("CustomerFName");
            strCustLName  = this.Intent.GetStringExtra("CustomerLName");
            strStoreName  = this.Intent.GetStringExtra("SelectedStore");
            strZipCode    = this.Intent.GetStringExtra("UserZipCode");
            strSelectItem = this.Intent.GetStringExtra("ProductType");
            var        dlgCustomerName = new AlertDialog.Builder(this);
            GridLayout grdShoppingCart = FindViewById <GridLayout>(Resource.Id.grdShoppingCart);
            GridLayout grdCustName     = new GridLayout(this);

            grdCustName.RowCount    = 2;
            grdCustName.ColumnCount = 2;
            TextView tvFName = new TextView(this);

            tvFName.Text = "First Name:";
            grdCustName.AddView(tvFName);
            EditText edtFName = new EditText(this);

            grdCustName.AddView(edtFName);
            TextView tvLName = new TextView(this);

            tvLName.Text = "Last Name";
            grdCustName.AddView(tvLName);
            EditText edtLName = new EditText(this);

            grdCustName.AddView(edtLName);
            dlgCustomerName.SetTitle("PLEASE ENTER YOUR NAME");
            dlgCustomerName.SetView(grdCustName);
            dlgCustomerName.SetPositiveButton("OK", delegate {
                strCustFName    = edtFName.Text;
                strCustLName    = edtLName.Text;
                tvCustName.Text = string.Concat(strCustFName, " ", strCustLName);
                listCartItems(dataCartItems, grdShoppingCart);
            });
            dlgCustomerName.SetNegativeButton("CANCEL", delegate { });
            dlgCustomerName.Show();



            var theCart = from aCartItem in dataCartItems
                          where aCartItem.CustomerFname == strCustFName && aCartItem.CustomerLname == strCustLName && aCartItem.CheckedOut == false
                          select aCartItem;

            TextView tvCustStore = FindViewById <TextView>(Resource.Id.tvCustStore);

            tvCustStore.Text = strStoreName;

            listCartItems(dataCartItems, grdShoppingCart);

            btnCheckout.Click += (sender, e) =>
            {
                var dlgCheckout = new AlertDialog.Builder(this);
                dlgCheckout.SetMessage("Are you sure you want to check out your order?");

                GridLayout grdPurchase = new GridLayout(this);
                grdPurchase.ColumnCount = 1;
                grdPurchase.RowCount    = 10;
                RadioGroup  rgCreditCards = new RadioGroup(this);
                RadioButton rbVisa        = new RadioButton(this);
                rbVisa.Text = "VISA";
                rgCreditCards.AddView(rbVisa);
                RadioButton rbMasterCard = new RadioButton(this);
                rbMasterCard.Text = "MASTER CARD";
                rgCreditCards.AddView(rbMasterCard);
                RadioButton rbDiscover = new RadioButton(this);
                rbDiscover.Text = "DISCOVER";
                rgCreditCards.AddView(rbDiscover);
                RadioButton rbAmEx = new RadioButton(this);
                rbAmEx.Text = "AMERICAN EXPRESS";
                rgCreditCards.AddView(rbAmEx);
                grdPurchase.AddView(rgCreditCards);
                TextView tvCCPrompt = new TextView(this);
                tvCCPrompt.Text = "YOUR CREDIT CARD NUMBER:";
                grdPurchase.AddView(tvCCPrompt);
                EditText edtCCNum = new EditText(this);
                grdPurchase.AddView(edtCCNum);
                TextView tvExpDate = new TextView(this);
                tvExpDate.Text = "EXPIRATION DATE (mmyy):";
                EditText edtExpDate = new EditText(this);
                grdPurchase.AddView(tvExpDate);
                grdPurchase.AddView(edtExpDate);

                TextView tvVerifyCode = new TextView(this);
                tvVerifyCode.Text = "YOUR THREE-DIGIT VERIFICATION CODE:";
                EditText edtVerifyCode = new EditText(this);
                grdPurchase.AddView(tvVerifyCode);
                grdPurchase.AddView(edtVerifyCode);
                dlgCheckout.SetView(grdPurchase);


                string strCCName      = "";
                bool   boolCCSelected = false;
                //Toast.MakeText(this, grdPurchase.ChildCount.ToString(), ToastLength.Long).Show();
                dlgCheckout.SetPositiveButton("OK", async delegate
                {
                    // EditText edtTheNumber = (EditText)grdPurchase.GetChildAt(2);
                    string strCCNum      = edtCCNum.Text;
                    string strExpDate    = edtExpDate.Text;
                    string strVerifyCode = edtVerifyCode.Text;

                    string strExpDatePattern = @"^(0[1-9]|1[012])\d{2}$";
                    for (int iCCN = 0; iCCN < rgCreditCards.ChildCount; iCCN++)
                    {
                        RadioButton rbCC = (RadioButton)rgCreditCards.GetChildAt(iCCN);
                        if (rbCC.Checked)
                        {
                            boolCCSelected = true;
                            strCCName      = rbCC.Text;
                            break;
                        }
                    }
                    if (!boolCCSelected)
                    {
                        Toast.MakeText(this, "PLEASE SELECT A CREDIT CARD", ToastLength.Long).Show();
                    }
                    else if (strCCNum.Trim() == "")
                    {
                        Toast.MakeText(this, "PLEASE ENTER YOUR CREDIT INFORMATION", ToastLength.Long).Show();
                    }
                    else if (Regex.IsMatch(strExpDate, strExpDatePattern) == false)
                    {
                        Toast.MakeText(this, "PLEASE ENTER YOUR EXPIRATION DATE IN FORM mmyy", ToastLength.Long).Show();
                    }
                    else
                    {
                        AsyncSearch <CreditCard> listPurchases = dynContext.FromScanAsync <CreditCard>(new ScanOperationConfig()
                        {
                            ConsistentRead = true
                        });
                        List <CreditCard> listDataPurchases = await listPurchases.GetRemainingAsync();

                        int iCountAllPurchases = listDataPurchases.Count;
                        listDataCartItems      = dynContext.FromScanAsync <ShoppingCart>(new ScanOperationConfig()
                        {
                            ConsistentRead = true
                        });


                        dataCartItems = await listDataCartItems.GetRemainingAsync();


                        theCart = from aCartItem in dataCartItems
                                  where aCartItem.CustomerFname == strCustFName && aCartItem.CustomerLname == strCustLName && aCartItem.CheckedOut == false && aCartItem.OrderID != "0"
                                  select aCartItem;

                        Table tblShoppingCart = Table.LoadTable(dynDBClient, "ShoppingCart");
                        Table tblCreditCard   = Table.LoadTable(dynDBClient, "CreditCard");
                        foreach (ShoppingCart aCartItem in theCart)
                        {
                            Document docCartItem           = new Document();
                            Document docPurchase           = new Document();
                            docCartItem["OrderID"]         = aCartItem.OrderID;
                            docCartItem["CheckedOut"]      = 1;
                            docPurchase["ChargeID"]        = (iCountAllPurchases++).ToString();
                            docPurchase["CardNumber"]      = strCCNum;
                            docPurchase["Amount"]          = aCartItem.TotalCost;
                            docPurchase["CardName"]        = strCCName;
                            docPurchase["CustomerName"]    = string.Concat(strCustFName, " ", strCustLName);
                            docPurchase["Expiration"]      = strExpDate;
                            docPurchase["ItemDescription"] = aCartItem.ProductDescription;
                            docPurchase["Verification"]    = strVerifyCode;
                            docPurchase["Merchant"]        = aCartItem.StoreName;
                            docPurchase["PurchaseDate"]    = strOrderDate;
                            docPurchase["NewCharge"]       = 1;
                            await tblCreditCard.PutItemAsync(docPurchase);
                            //  await tblShoppingCart.UpdateItemAsync(docCartItem);
                            await tblShoppingCart.DeleteItemAsync(docCartItem);
                        }


                        Intent intentDeliveryPickup = new Intent(this, typeof(DeliveryPickupActivity));

                        StartActivity(intentDeliveryPickup);
                    }
                });
                dlgCheckout.SetNegativeButton("NO", delegate { });
                dlgCheckout.Show();
            };
            btnEnterOrder.Click += async(sender, e) =>
            {
                AsyncSearch <ShoppingCart> listUpdateDataCartItems = dynContext.FromScanAsync <ShoppingCart>(new ScanOperationConfig()
                {
                    ConsistentRead = true
                });

                List <ShoppingCart> dataUpdateCartItems = await listUpdateDataCartItems.GetRemainingAsync();

                int    iOrderCount    = dataUpdateCartItems.Count;
                string strDescription = edtItemDescription.Text.Trim();
                string strPrice       = edtPrice.Text.Trim();
                string strQuant       = edtQuant.Text.Trim();
                if (strDescription == "")
                {
                    Toast.MakeText(this, "PLEASE ENTER A PRODUCT DESCRIPTION", ToastLength.Long).Show();
                    return;
                }
                Double dblNum = 0.00;
                if (Double.TryParse(strPrice, out dblNum) == false)
                {
                    Toast.MakeText(this, "PLEASE ENTER PRICE AS A REAL NUMBER", ToastLength.Long).Show();
                    return;
                }
                int iNum = 0;
                if (int.TryParse(strQuant, out iNum) == false)
                {
                    Toast.MakeText(this, "PLEASE ENTER QUANTITY AS AN INTEGER NUMBER", ToastLength.Long).Show();
                    return;
                }
                else if (Convert.ToInt32(strQuant) <= 0)
                {
                    Toast.MakeText(this, "PLEASE ENTER A POSITIVE NUMBER (>=1)", ToastLength.Long).Show();
                    return;
                }
                Table    tblCart        = Table.LoadTable(dynDBClient, "ShoppingCart");
                Document docMerchandise = new Document();
                double   dblUnitPrice   = Convert.ToDouble(strPrice);

                int    iQuant       = Convert.ToInt32(strQuant);
                double dblTotalCost = Convert.ToDouble(iQuant) * dblUnitPrice;
                docMerchandise["OrderID"]            = iOrderCount.ToString();
                docMerchandise["ProductDescription"] = strDescription;
                docMerchandise["CustomerFname"]      = strCustFName;
                docMerchandise["CustomerLname"]      = strCustLName;
                docMerchandise["StoreName"]          = strStoreName;
                docMerchandise["UnitPrice"]          = dblUnitPrice;
                docMerchandise["Quantity"]           = iQuant;
                docMerchandise["TotalCost"]          = dblTotalCost;
                docMerchandise["OrderDate"]          = strOrderDate;
                docMerchandise["CheckedOut"]         = 0;
                await tblCart.PutItemAsync(docMerchandise);

                listCartItems(dataCartItems, grdShoppingCart);
                //  double dblRunningTotal += dblTotalCost;
                edtItemDescription.Text = "";
                edtPrice.Text           = "";
                edtQuant.Text           = "";
                //  dblTotalPurchase = dblRunningTotal;
            };
            btnBack.Click += (sender, e) =>
            {
                Intent intentItems = new Intent(this, typeof(ItemsActivity));
                intentItems.PutExtra("CustomerFname", strCustFName);
                intentItems.PutExtra("CustomerLname", strCustLName);
                intentItems.PutExtra("SelectedStore", strStoreName);
                intentItems.PutExtra("UserZipCode", strZipCode);
                intentItems.PutExtra("OrderDate", strOrderDate);
                intentItems.PutExtra("ProductType", strSelectItem);
                StartActivity(intentItems);
            };
        }
Example #18
0
        public override View OnCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState)
        {
            var view = inflater.Inflate(Resource.Layout.fragment_dictlist, container, false);
            //EditText etDictName = view.FindViewById<EditText>(Resource.Id.etDictListDictName);
            TextView tvHint = view.FindViewById <TextView>(Resource.Id.tvHint);

            Button btDelete   = view.FindViewById <Button>(Resource.Id.btDelete);
            Button btOpenDict = view.FindViewById <Button>(Resource.Id.btOpenDict);
            Button btRefresh  = view.FindViewById <Button>(Resource.Id.btRefresh);
            Button btRecreate = view.FindViewById <Button>(Resource.Id.btRecreate);
            //btDelete.Enabled = false;

            RadioGroup rgDictList = view.FindViewById <RadioGroup>(Resource.Id.rgDictList);

            int iSelectedID = 0;

            DatabaseManager dm        = new DatabaseManager();
            string          sDictName = dm.GetDefaultValueByKey("DictName");


            List <string> dictList = dm.GetDictNameList();

            for (int i = 0; i < dictList.Count; i++)
            {
                RadioButton rbNew = new RadioButton(view.Context);
                rbNew.Id = View.GenerateViewId();//start from 1.
                //set attributes "wrap_content" dynamically.(but it has been set default.
                //LinearLayout.LayoutParams parmsWrapContent = new LinearLayout.LayoutParams(LinearLayout.LayoutParams.WrapContent, LinearLayout.LayoutParams.WrapContent);
                //rbNew.LayoutParameters = parmsWrapContent;

                rbNew.Text = dictList[i];
                if (rbNew.Text.Equals(sDictName))
                {
                    iSelectedID = rbNew.Id;
                }
                rgDictList.AddView(rbNew);
            }


            rgDictList.CheckedChange += (sender, e) => {
                btDelete.Enabled = true;
                iSelectedID      = e.CheckedId;

                RadioButton rbNew = view.FindViewById <RadioButton>(e.CheckedId);
                if (rbNew is null)
                {
                    return;
                }
                sDictName = rbNew.Text;
                dm.SetDefaultValue("DictName", sDictName);
                tvHint.Text = "Dictionary: " + sDictName + " is selected! " + dm.GetTotalWordsNumberByDictName(sDictName) + " words.";
            };
            //must be executed after listener "CheckedChange" definited.
            rgDictList.Check(iSelectedID);

            /*
             * for (int i = 0; i < rgDictList.ChildCount; i++)
             * {
             *  RadioButton rbNew = view.FindViewById<RadioButton>(rgDictList.GetChildAt(i).Id);
             *  if(rbNew.Text.Equals(sDictName))
             *  {
             *      iSelectedID = rgDictList.GetChildAt(i).Id;
             *      rgDictList.Check(iSelectedID);
             *      break;
             *  }
             * }
             */



            btOpenDict.Click += delegate
            {
                Fragment fragment = new OpenDict();
                FragmentManager.BeginTransaction().Replace(Resource.Id.flContent, fragment).Commit();
            };

            //remove words which is in "Trash" or "PassDict" from selected dictionary.
            btRefresh.Click += delegate
            {
                if (sDictName.Equals("Trash") || sDictName.Equals("PassDict"))
                {
                    return;
                }

                List <string> lSelectedDict = dm.GetWordListByDictName(sDictName);
                List <string> lTrash        = dm.GetWordListByDictName("Trash");
                List <string> lPassDict     = dm.GetWordListByDictName("PassDict");

                foreach (string sWord in lSelectedDict)
                {
                    if (lTrash.Contains(sWord))
                    {
                        dm.RemoveWordFromDict(sDictName, sWord);
                    }
                    if (lPassDict.Contains(sWord))
                    {
                        dm.RemoveWordFromDict(sDictName, sWord);
                    }
                }

                tvHint.Text = "Dictionary: " + sDictName + " is refreshed! " + dm.GetTotalWordsNumberByDictName(sDictName) + " words.";
            };

            btRecreate.Click += delegate
            {
                if (sDictName.Equals("Trash") || sDictName.Equals("PassDict") || sDictName.Equals("NewWord"))
                {
                    return;
                }

                DictDataModel ddm = dm.GetDictFromDBByName(sDictName);
                if (ddm is null)
                {
                    ddm           = new DictDataModel();
                    ddm.sDictName = sDictName;
                }

                ddm.UpdateDictWord();
                dm.StoreDictToDB(ddm);

                tvHint.Text = "Dictionary: " + sDictName + " is recreated! " + dm.GetTotalWordsNumberByDictName(sDictName) + " words.";
            };

            //delete dictionary. name can be set manually
            btDelete.Click += delegate
            {
                for (int i = 0; i < rgDictList.ChildCount; i++)
                {
                    if (rgDictList.GetChildAt(i).Id == iSelectedID)
                    {
                        if (!sDictName.Equals(""))
                        {
                            dm.RemoveDictByName(sDictName);
                            dm.SetDefaultValue("DictName", "");
                        }
                        rgDictList.RemoveViewAt(i);
                        break;
                    }
                }
                btDelete.Enabled = false;
                dm.RemoveDictByName(sDictName);
                DictDataModel ddm = dm.GetDictFromDBByName(sDictName);
            };


            return(view);

            //return base.OnCreateView(inflater, container, savedInstanceState);
        }
Example #19
0
        protected override void OnCreate(Bundle savedInstanceState)
        {
            base.OnCreate(savedInstanceState);
            SetContentView(Resource.Layout.Scout_Form_Edit);
            //get controls from layout and assign event handlers
            textTitle              = FindViewById <TextView>(Resource.Id.textEventTitle);
            vMatchNumber           = FindViewById <EditText>(Resource.Id.vMatchNumber);
            vTeamNumber            = FindViewById <EditText>(Resource.Id.vTeamNumber);
            position               = FindViewById <Spinner>(Resource.Id.vPosition);
            position.ItemSelected += SpinnerClick;
            table      = FindViewById <CheckBox>(Resource.Id.table);
            radioLevel = FindViewById <RadioGroup>(Resource.Id.radioLevel);
            radioLevel.CheckedChange     += RadioClicked;
            radioSandstorm                = FindViewById <RadioGroup>(Resource.Id.radioSandstorm);
            radioSandstorm.CheckedChange += RadioClicked;
            sandCargo                     = FindViewById <CheckBox>(Resource.Id.sandCargo);
            sandHatch                     = FindViewById <CheckBox>(Resource.Id.sandHatch);
            sandHab                       = FindViewById <CheckBox>(Resource.Id.sandHab);
            cargo                         = FindViewById <CheckBox>(Resource.Id.cargo);
            cargo.CheckedChange          += CheckboxClicked;
            cargoWell                     = FindViewById <CheckBox>(Resource.Id.cargoWell);
            cargoWell.CheckedChange      += CheckboxClicked;
            cargoBarely                   = FindViewById <CheckBox>(Resource.Id.cargoBarely);
            cargoBarely.CheckedChange    += CheckboxClicked;
            hatch                         = FindViewById <CheckBox>(Resource.Id.hatch);
            hatch.CheckedChange          += CheckboxClicked;
            hatchWell                     = FindViewById <CheckBox>(Resource.Id.hatchWell);
            hatchWell.CheckedChange      += CheckboxClicked;
            hatchBarely                   = FindViewById <CheckBox>(Resource.Id.hatchBarely);
            hatchBarely.CheckedChange    += CheckboxClicked;
            radioClimb                    = FindViewById <RadioGroup>(Resource.Id.radioClimb);
            radioClimb.CheckedChange     += RadioClicked;
            radioDrivers                  = FindViewById <RadioGroup>(Resource.Id.radioDrivers);
            radioDrivers.CheckedChange   += RadioClicked;
            radioRecommend                = FindViewById <RadioGroup>(Resource.Id.radioRecommend);
            radioRecommend.CheckedChange += RadioClicked;
            radioResult                   = FindViewById <RadioGroup>(Resource.Id.radioResult);
            radioResult.CheckedChange    += RadioClicked;
            comments                      = FindViewById <MultiAutoCompleteTextView>(Resource.Id.comments);
            bFinish                       = FindViewById <Button>(Resource.Id.bFinish);
            bFinish.Click                += ButtonClicked;
            //put positions into dropdown
            string[]     positions = new string[] { "Red 1", "Red 2", "Red 3", "Blue 1", "Blue 2", "Blue 3" };
            ArrayAdapter posAdapt  = new ArrayAdapter <string>(this, Android.Resource.Layout.SimpleListItem1, positions);

            position.Adapter = posAdapt;
            //get current event and set title text
            currentEvent    = eData.GetCurrentEvent();
            currentMatch    = eData.GetCurrentMatch();
            textTitle.Text += currentMatch.matchNumber.ToString() + "'";
            //set options to match properties
            vMatchNumber.Text = currentMatch.matchNumber.ToString();
            vTeamNumber.Text  = currentMatch.teamNumber.ToString();
            position.SetSelection(currentMatch.position);
            table.Checked = currentMatch.isTable;
            ((RadioButton)radioLevel.GetChildAt(currentMatch.sandstormStartLevel - 1)).Checked = true;
            ((RadioButton)radioSandstorm.GetChildAt(currentMatch.sandstormMode)).Checked       = true;
            sandCargo.Checked   = currentMatch.sandstormCargo;
            sandHatch.Checked   = currentMatch.sandstormHatch;
            sandHab.Checked     = currentMatch.sandstormLine;
            cargo.Checked       = currentMatch.cargo;
            cargoWell.Checked   = currentMatch.cargoWell;
            cargoBarely.Checked = currentMatch.cargoBarely;
            hatch.Checked       = currentMatch.hatch;
            hatchWell.Checked   = currentMatch.hatchWell;
            hatchBarely.Checked = currentMatch.hatchBarely;
            try
            {
                ((RadioButton)radioClimb.GetChildAt(currentMatch.climb - 2)).Checked = true;
            }
            catch
            {
                ((RadioButton)radioClimb.GetChildAt(2)).Checked = true;
            }
            ((RadioButton)radioDrivers.GetChildAt(Convert.ToInt16(!currentMatch.goodDrivers))).Checked = true;
            ((RadioButton)radioRecommend.GetChildAt(currentMatch.wouldRecommend)).Checked = true;
            ((RadioButton)radioResult.GetChildAt(currentMatch.result)).Checked            = true;
            comments.Text = currentMatch.additionalComments;
        }