コード例 #1
0
        public override void onItemClick <T1>(AdapterView <T1> parent, View view, int position, long id)
        {
            string device = ((TextView)view).Text.ToString();

            logicalName = device.Substring(0, device.IndexOf(DEVICE_ADDRESS_START, StringComparison.Ordinal));

            string address = StringHelperClass.SubstringSpecial(device, device.IndexOf(DEVICE_ADDRESS_START, StringComparison.Ordinal) + DEVICE_ADDRESS_START.Length, device.IndexOf(DEVICE_ADDRESS_END, StringComparison.Ordinal));

            try
            {
                foreach (object entry in bxlConfigLoader.Entries)
                {
                    JposEntry jposEntry = (JposEntry)entry;
                    bxlConfigLoader.removeEntry(jposEntry.LogicalName);
                }
            }
            catch (Exception e)
            {
                Console.WriteLine(e.ToString());
                Console.Write(e.StackTrace);
            }

            try
            {
                bxlConfigLoader.addEntry(logicalName, BXLConfigLoader.DEVICE_CATEGORY_POS_PRINTER, logicalName, BXLConfigLoader.DEVICE_BUS_BLUETOOTH, address);

                bxlConfigLoader.saveFile();
            }
            catch (Exception e)
            {
                Console.WriteLine(e.ToString());
                Console.Write(e.StackTrace);
            }
        }
コード例 #2
0
        public override bool onContextItemSelected(MenuItem item)
        {
            AdapterContextMenuInfo info = (AdapterContextMenuInfo)item.MenuInfo;
            string logicalName          = ((TextView)info.targetView).Text.ToString();

            switch (item.ItemId)
            {
            case R.id.context_modify_entry:
                int    deviceCategory = bxlConfigLoader.getDeviceCategory(logicalName);
                string dc             = null;
                switch (deviceCategory)
                {
                case BXLConfigLoader.DEVICE_CATEGORY_CASH_DRAWER:
                    dc = Resources.getStringArray(R.array.device_categories)[0];
                    break;

                case BXLConfigLoader.DEVICE_CATEGORY_MSR:
                    dc = Resources.getStringArray(R.array.device_categories)[1];
                    break;

                case BXLConfigLoader.DEVICE_CATEGORY_POS_PRINTER:
                    dc = Resources.getStringArray(R.array.device_categories)[2];
                    break;

                case BXLConfigLoader.DEVICE_CATEGORY_SMART_CARD_RW:
                    dc = Resources.getStringArray(R.array.device_categories)[3];
                    break;
                }

                int    deviceBus = bxlConfigLoader.getDeviceBus(logicalName);
                string db        = null;
                switch (deviceBus)
                {
                case BXLConfigLoader.DEVICE_BUS_BLUETOOTH:
                    db = Resources.getStringArray(R.array.device_bus)[0];
                    break;

                case BXLConfigLoader.DEVICE_BUS_ETHERNET:
                    db = Resources.getStringArray(R.array.device_bus)[1];
                    break;

                case BXLConfigLoader.DEVICE_BUS_USB:
                    db = Resources.getStringArray(R.array.device_bus)[2];
                    break;

                case BXLConfigLoader.DEVICE_BUS_WIFI:
                    db = Resources.getStringArray(R.array.device_bus)[3];
                    break;

                case BXLConfigLoader.DEVICE_BUS_WIFI_DIRECT:
                    db = Resources.getStringArray(R.array.device_bus)[4];
                    break;
                }

                EntryInfo entryInfo = new EntryInfo(logicalName, dc, bxlConfigLoader.getProductName(logicalName), db, bxlConfigLoader.getAddress(logicalName));
                EntryDialogFragment.showDialog(SupportFragmentManager, "Modify entry", entryInfo);
                return(true);

            case R.id.context_remove_entry:
                if (bxlConfigLoader.removeEntry(logicalName))
                {
                    arrayAdapter.remove(logicalName);
                }
                else
                {
                    Toast.makeText(this, "Remove failed", Toast.LENGTH_SHORT).show();
                }
                return(true);

            default:
                return(base.onContextItemSelected(item));
            }
        }