예제 #1
0
        public static DevicesViewModel GetInstance()
        {
            if (instance == null)
            {
                instance = new DevicesViewModel();
            }

            return(instance);
        }
예제 #2
0
        /// <summary>
        /// listview 아이템 클릭 시 장치의 블루투스와 연결
        /// </summary>
        /// <param name="deviceName">장치 이름</param>
        private async void ItemClickBluetoothMethod(object deviceName)
        {
            isRun = true;

            if (string.IsNullOrEmpty(connectionInfo))
            {
                MessageService.Show(ErrorMessage.empty);
                isRun = false;

                return;
            }

            foreach (var i in DevicesViewModel.GetInstance().deviceCollection)
            {
                if (i.name == connectionInfo)
                {
                    MessageService.Show(ErrorMessage.Bluetooth.alreadyExist);
                    isRun = false;

                    return;
                }
            }

            if (!await DependencyService.Get <DIBluetooth>().ConnectDevice(deviceName.ToString()))
            {
                MessageService.Show(ErrorMessage.Bluetooth.ConnectionFailed);
                isRun = false;

                return;
            }

            deviceNickName = connectionInfo;
            wirelessCollection.Clear();
            isRun = false;

            placeHolder    = wifiPlaceHolder;
            statusText     = wifiStatus;
            connectionInfo = string.Empty;

            DependencyService.Get <DIWifi>().StartScanWiFi();
        }