コード例 #1
0
        public bool PerformActions(IMenuItem item)
        {
            var adapter = (ArrayAdapter <string>) this.ListAdapter;
            SparseBooleanArray pchecked = this.ListView.CheckedItemPositions;

            switch (item.ItemId)
            {
            case Resource.Id.cap:
                for (var i = 0; i < pchecked.Size(); i++)
                {
                    if (pchecked.ValueAt(i))
                    {
                        var position = pchecked.KeyAt(i);
                        var word     = this.words[position];

                        word = word.ToUpper();

                        adapter.Remove(this.words[position]);
                        adapter.Insert(word, position);
                    }
                }

                return(true);

            case Resource.Id.remove:
                var positions = new List <int>();

                for (var i = 0; i < pchecked.Size(); i++)
                {
                    if (pchecked.ValueAt(i))
                    {
                        positions.Add(pchecked.KeyAt(i));
                    }
                }

                positions.Reverse();

                foreach (var position in positions)
                {
                    adapter.Remove(this.words[position]);
                }

                this.ListView.ClearChoices();

                return(true);
            }

            return(false);
        }
コード例 #2
0
        // Handle the dismiss event on the dialog to raise a custom event that passes the updated order fields back
        public override void OnDismiss(IDialogInterface dialog)
        {
            base.OnDismiss(dialog);

            // Verify the event has listeners
            if (OrderFieldDialogClosed != null)
            {
                // Get an array of checked list item positions (indices)
                SparseBooleanArray checkedItemsArray = _orderFieldsListView.CheckedItemPositions;

                // Loop through all the available order fields
                for (int i = 0; i < _potentialOrderByFields.Count; i++)
                {
                    // Initially set each order option to false
                    OrderFieldOption orderOption = _potentialOrderByFields[i];
                    orderOption.OrderWith = false;

                    // If the item was checked in the list view, set the order option to true
                    if (checkedItemsArray.KeyAt(i) == i && checkedItemsArray.ValueAt(i))
                    {
                        orderOption.OrderWith = true;
                    }
                }

                // Raise the event and pass back the updated list of order field options
                OrderFieldDialogClosed(this, _potentialOrderByFields);
            }
        }
コード例 #3
0
        // Handle the dialog dismiss event to raise a custom event that passes back the updated fields dictionary
        public override void OnDismiss(IDialogInterface dialog)
        {
            base.OnDismiss(dialog);

            // If the event has listeners
            if (GroupFieldDialogClosed != null)
            {
                // Get an array of all checked row positions in the list
                SparseBooleanArray checkedItemsArray = _groupFieldsListView.CheckedItemPositions;

                // Loop through all fields in the dictionary
                for (int i = 0; i < _potentialGroupByFields.Count; i++)
                {
                    // Set the corresponding value for the field to false (will not be used for grouping results)
                    string key = _potentialGroupByFields.Keys.ElementAt(i);
                    _potentialGroupByFields[key] = false;

                    // If the corresponding row in the list view is checked, set the field's value in the dictionary to true
                    if (checkedItemsArray.KeyAt(i) == i && checkedItemsArray.ValueAt(i))
                    {
                        _potentialGroupByFields[key] = true;
                    }
                }

                // Raise the GroupFieldDialogClosed event to pass back the updated dictionary
                GroupFieldDialogClosed(this, _potentialGroupByFields);
            }
        }
 public SparseBooleanArrayParcelable(SparseBooleanArray sparseBooleanArray)
 {
     for (int i = 0; i < sparseBooleanArray.Size(); i++)
     {
         this.Put(sparseBooleanArray.KeyAt(i), sparseBooleanArray.ValueAt(i));
     }
 }
コード例 #5
0
        //private Color GetArgb(int argb)
        //{
        //	return Color.Argb(Color.GetAlphaComponent(argb), Color.GetRedComponent(argb), Color.GetGreenComponent(argb), Color.GetBlueComponent(argb));
        //}

        public void CheckListItem(bool checkValue = false)
        {
            try {
                SparseBooleanArray checkedList = listView.CheckedItemPositions;
                for (int i = 0; i < checkedList.Size(); i++)
                {
                    if (checkedList.ValueAt(i))
                    {
                        var pos = checkedList.KeyAt(i);
                        listView.SetItemChecked(pos, checkValue);
                        wcdListAdapter[pos].ItemChecked = checkValue;
                    }
                }
                if (wcdListAdapter.Count == 0)
                {
                    fabWcd.SetImageResource(Resource.Drawable.ic_refresh_white);
                }
                else if (listView.CheckedItemCount == 0)
                {
                    fabWcd.SetImageResource(Resource.Drawable.ic_subject_white);
                }
                else
                {
                    fabWcd.SetImageResource(Resource.Drawable.ic_edit_white);
                }
                wcdListAdapter.NotifyDataSetChanged();
            } catch { }

            if (snackbar != null)
            {
                snackbar.Dismiss();
                snackbar = null;
            }
        }
コード例 #6
0
            public bool OnActionItemClicked(ActionMode mode, IMenuItem item)
            {
                switch (item.ItemId)
                {
                //ifuserclickmenu print_me
                case Resource.Id.print_me:
                    //createanalert dialog
                    AlertDialog.Builder builder = new AlertDialog.Builder(parent);
                    string msg = "Are you sure you want to print items?";
                    builder.SetMessage(msg)
                    .SetCancelable(false)
                    .SetPositiveButton("Yes", (or, er) =>
                    {
                        SparseBooleanArray selected = parent.myAdapter.getSelectedIds();
                        List <string> list_item     = new List <string>();
                        for (int i = (selected.Size() - 1); i >= 0; i--)
                        {
                            //checkisvaluecheckedby user
                            if (selected.ValueAt(i))
                            {
                                int selectedItem = (int)parent.myAdapter.GetItem(selected.KeyAt(i));
                                list_item.Add(selectedItem.ToString());
                            }
                        }
                        //print message
                        Toast.MakeText(parent, "YouSelect" + parent.myAdapter.getSelectedCount() + "Item:[" + string.Join(",", list_item) + "]", ToastLength.Long).Show();
                        mode.Finish();

                        parent.below_layout.Visibility = ViewStates.Gone;      // Gone
                    })
                    .SetNegativeButton("No", (or, er) =>
                    {
                        parent.below_layout.Visibility = ViewStates.Gone;      // Gone

                        ((Dialog)or).Cancel();
                    });

                    AlertDialog alert = builder.Create();
                    alert.Show();

                    return(true);

                default:
                    return(false);
                }
            }
コード例 #7
0
        private void ListView_ItemClick(object sender, AdapterView.ItemClickEventArgs e)
        {
            SparseBooleanArray checkeds = listView.CheckedItemPositions;
            int num_selected            = 0;

            for (int i = 0; i < checkeds.Size(); i++)
            {
                if (checkeds.ValueAt(i))
                {
                    num_selected++;
                    int  key   = checkeds.KeyAt(i);
                    bool value = checkeds.Get(key);
                    if (value)
                    {
                        //
                    }
                }
            }
        }
コード例 #8
0
		private void SetToAddress(object sender, EventArgs e)
		{
			
			List<string> PBT_selected = new List<string>();
			List<string> ID_PBT_selected = new List<string>();
			sparseArray = FindViewById<ListView> (Resource.Id.lvMSCMLPBTLpbt).CheckedItemPositions;

			string Pbt_Name_selected;
			string Pbt_ID_selected;

			for (var i = 0; i < sparseArray.Size (); i++) {

				string selectedValue = string.Empty;
				string ID_selected = string.Empty;

				int position = sparseArray.KeyAt(i);

				if (sparseArray.ValueAt (i) == true) 
				{
					selectedValue = listView.GetItemAtPosition (position).ToString ();
					ID_selected = pbtListIDArray[position];
					//groups.Remove (groups [position]);
					//Android.Widget.Toast.MakeText(this,"Subscribed for "+selectedValue, Android.Widget.ToastLength.Short).Show();
					//searchGroupAdapter.NotifyDataSetChanged ();

					PBT_selected.Add(selectedValue);
					ID_PBT_selected.Add(ID_selected);
				}

			}

			Pbt_Name_selected = String.Join(" , ", PBT_selected);
			Pbt_ID_selected = String.Join(" , ", ID_PBT_selected);

			Intent intentToSend = new Intent();
			intentToSend.PutExtra("PBT_Name",Pbt_Name_selected.ToString());
			intentToSend.PutExtra("PBT_ID",Pbt_ID_selected.ToString());
			SetResult(Result.Ok,intentToSend);

			this.Finish ();
			this.OverridePendingTransition (0, 0);
		}
コード例 #9
0
        private void FabWcd_Click(object sender, EventArgs e)
        {
            if (snackbar != null)
            {
                snackbar.Dismiss();
                snackbar = null;
            }

            if (wcdListAdapter.Count == 0)
            {
                Refresh();
                if (wcdListAdapter.Count == 0)
                {
                    Show("항목이 없습니다");
                }
                return;
            }

            List <int> positions = new List <int>();

            try {
                SparseBooleanArray checkedList = listView.CheckedItemPositions;
                for (int i = 0; i < checkedList.Size(); i++)
                {
                    if (checkedList.ValueAt(i))
                    {
                        positions.Add(checkedList.KeyAt(i));
                    }
                }
                if (positions.Count == 0)
                {
                    lastPosition = 0;
                }
            } catch {
                return;
            }

            View dialogView = LayoutInflater.From(Context).Inflate(Resource.Layout.weld_condition_editor, null);

            AlertDialog.Builder dialog = new AlertDialog.Builder(Context);
            dialog.SetView(dialogView);

            // 에디트텍스트
            IList <EditText> etList = new List <EditText>();

            etList.Add(dialogView.FindViewById <EditText>(Resource.Id.etOutputData));
            etList.Add(dialogView.FindViewById <EditText>(Resource.Id.etOutputType));
            etList.Add(dialogView.FindViewById <EditText>(Resource.Id.etSqueezeForce));
            etList.Add(dialogView.FindViewById <EditText>(Resource.Id.etMoveTipClearance));
            etList.Add(dialogView.FindViewById <EditText>(Resource.Id.etFixedTipClearance));
            etList.Add(dialogView.FindViewById <EditText>(Resource.Id.etPannelThickness));
            etList.Add(dialogView.FindViewById <EditText>(Resource.Id.etCommandOffset));

            int[] etMax = { 2000, 100, 350, 500, 500, 500, 500, 1000, 1000 };               // 임계치

            InputMethodManager imm = (InputMethodManager)Context.GetSystemService(Context.InputMethodService);

            for (int i = 0; i < etList.Count; i++)
            {
                EditText et = etList[i];

                if (i == 0)                                                                 // outputData
                {
                    et.Text = wcdListAdapter[lastPosition][i];                              // 기본선택된 자료값 가져오기
                }
                int maxValue = etMax[i];                                                    // 임계치 설정
                et.FocusChange += (object sender1, View.FocusChangeEventArgs e1) =>
                {
                    int n;
                    if (Int32.TryParse(et.Text, out n))
                    {
                        if (n > maxValue)
                        {
                            n       = maxValue;
                            et.Text = n.ToString();
                        }
                    }
                };
                et.KeyPress += (object sender1, View.KeyEventArgs e1) =>
                {
                    // KeyEventArgs.Handled
                    // 라우트된 이벤트를 처리된 것으로 표시하려면 true이고,
                    // 라우트된 이벤트를 처리되지 않은 것으로 두어 이벤트가 추가로 라우트되도록 허용하려면 false입니다.
                    // 기본값은 false입니다.
                    e1.Handled = false;
                    if (e1.KeyCode == Keycode.Enter || e1.KeyCode == Keycode.Back || e1.KeyCode == Keycode.Escape)
                    {
                        imm.HideSoftInputFromWindow(et.WindowToken, 0);
                        et.ClearFocus();
                        e1.Handled = true;
                    }
                };
            }

            var statusText = dialogView.FindViewById <TextView>(Resource.Id.statusText);

            statusText.Text = wcdListAdapter[lastPosition][0];
            if (positions.Count > 0)
            {
                StringBuilder sb = new StringBuilder();
                foreach (int pos in positions)
                {
                    sb.Append(pos + 1);
                    sb.Append(" ");
                }
                statusText.Text = "수정 항목: " + sb.ToString().TrimEnd();
            }
            else
            {
                statusText.Text = "수정 항목: " + (lastPosition + 1).ToString();
            }

            var sampleSeekBar = dialogView.FindViewById <SeekBar>(Resource.Id.sampleSeekBar);

            sampleSeekBar.Max              = wcdListAdapter.Count - 1;
            sampleSeekBar.Progress         = Convert.ToInt32(wcdListAdapter[lastPosition][0]) - 1;
            sampleSeekBar.ProgressChanged += (object sender1, SeekBar.ProgressChangedEventArgs e1) =>
            {
                for (int i = 0; i < wcdListAdapter[sampleSeekBar.Progress].Count; i++)
                {
                    if (etList[i].Text != "")
                    {
                        etList[i].Text = wcdListAdapter[sampleSeekBar.Progress][i];
                    }
                }
                if (positions.Count == 0)
                {
                    lastPosition    = sampleSeekBar.Progress;
                    statusText.Text = "수정 항목: " + (lastPosition + 1).ToString();
                }
            };

            // 선택 시작
            var beginSeekBar = dialogView.FindViewById <SeekBar>(Resource.Id.sbBegin);

            beginSeekBar.Max      = wcdListAdapter.Count - 1;
            beginSeekBar.Progress = 0;

            // 선택 끝
            var endSeekBar = dialogView.FindViewById <SeekBar>(Resource.Id.sbEnd);

            endSeekBar.Max      = wcdListAdapter.Count - 1;
            endSeekBar.Progress = endSeekBar.Max;

            beginSeekBar.ProgressChanged += (object sender1, SeekBar.ProgressChangedEventArgs e1) =>
            {
                if (e1.FromUser)
                {
                    int sb1Progress = beginSeekBar.Progress;
                    int sb2Progress = endSeekBar.Max - endSeekBar.Progress;
                    if (sb1Progress > sb2Progress)
                    {
                        sb2Progress         = sb1Progress;
                        endSeekBar.Progress = endSeekBar.Max - sb1Progress;
                    }
                    if (sb1Progress == 0 && sb2Progress == 0 || sb1Progress == beginSeekBar.Max && sb2Progress == endSeekBar.Max)
                    {
                        if (positions.Count > 0)
                        {
                            StringBuilder sb = new StringBuilder();
                            foreach (int pos in positions)
                            {
                                sb.Append(pos + 1);
                                sb.Append(" ");
                            }
                            statusText.Text = "수정 항목: " + sb.ToString().TrimEnd();
                        }
                        else
                        {
                            statusText.Text = "수정 항목: " + (lastPosition + 1).ToString();
                        }
                    }
                    else
                    {
                        statusText.Text = "수정 범위: " + string.Format("{0}", sb1Progress + 1) + " ~ " + string.Format("{0}", sb2Progress + 1);
                    }
                }
            };
            endSeekBar.ProgressChanged += (object sender2, SeekBar.ProgressChangedEventArgs e2) =>
            {
                if (e2.FromUser)
                {
                    int sb1Progress = beginSeekBar.Progress;
                    int sb2Progress = endSeekBar.Max - endSeekBar.Progress;
                    if (sb2Progress < sb1Progress)
                    {
                        sb1Progress           = sb2Progress;
                        beginSeekBar.Progress = sb2Progress;
                    }
                    if (sb1Progress == 0 && sb2Progress == 0 || sb1Progress == beginSeekBar.Max && sb2Progress == endSeekBar.Max)
                    {
                        if (positions.Count > 0)
                        {
                            StringBuilder sb = new StringBuilder();
                            foreach (int pos in positions)
                            {
                                sb.Append(pos + 1);
                                sb.Append(" ");
                            }
                            statusText.Text = "수정 항목: " + sb.ToString().TrimEnd();
                        }
                        else
                        {
                            statusText.Text = "수정 항목: " + (lastPosition + 1).ToString();
                        }
                    }
                    else
                    {
                        statusText.Text = "수정 범위: " + string.Format("{0}", sb1Progress + 1) + " ~ " + string.Format("{0}", sb2Progress + 1);
                    }
                }
            };

            dialog.SetNegativeButton("취소", delegate
            {
                CheckListItem(false);
            });

            dialog.SetPositiveButton("저장", async delegate
            {
                int seekBegin = beginSeekBar.Progress + 1;
                int seekEnd   = endSeekBar.Max - endSeekBar.Progress + 1;
                bool isSeek   = !((seekBegin == 1 && seekEnd == 1) || (seekBegin == beginSeekBar.Max + 1 && seekEnd == endSeekBar.Max + 1));
                bool isUpdate = false;

                if (positions.Count == 0)
                {
                    positions.Add(lastPosition);
                }
                if (isSeek)
                {
                    positions.Clear();
                    for (int rowNum = seekBegin - 1; rowNum < seekEnd; rowNum++)
                    {
                        positions.Add(rowNum);
                    }
                }
                foreach (int rowNum in positions)
                {
                    for (int colNum = 1; colNum < wcdListAdapter[rowNum].Count; colNum++)
                    {
                        if (etList[colNum].Text != "")
                        {
                            wcdListAdapter[rowNum][colNum] = etList[colNum].Text;
                            isUpdate = true;
                        }
                    }
                    listView.SetItemChecked(rowNum, false);
                    wcdListAdapter[rowNum].ItemChecked = false;
                }
                if (isUpdate)
                {
                    wcdListAdapter.NotifyDataSetChanged();
                    await UpdateFileAsync(robotPath, wcdListAdapter);
                }
                else
                {
                    CheckListItem(false);
                }
                try {
                    if (wcdListAdapter.Count == 0)
                    {
                        fabWcd.SetImageResource(Resource.Drawable.ic_refresh_white);
                    }
                    else if (listView.CheckedItemCount == 0)
                    {
                        fabWcd.SetImageResource(Resource.Drawable.ic_subject_white);
                    }
                    else
                    {
                        fabWcd.SetImageResource(Resource.Drawable.ic_edit_white);
                    }
                } catch { }
            });

            dialog.Show();
        }