如何在Windows Phone 8银灯应用程序中使用蓝牙打印机打印阿拉伯语文本?

时间:2015-11-03 07:02:12

标签: windows-phone-8 printing bluetooth arabic

我们需要在Windows Phone 8银灯应用程序中使用蓝牙打印机打印阿拉伯语文本。打印工作正常英语当我们尝试打印阿拉伯文本时,它不能按预期打印?示例代码如下:

Public async void PrintTest(string text)
{
var isConnected= await RefreshPairedDevicesList()  

if  (isConnected)
{
 try
            {
                if (_socket != null)
                {
                    DataWriter writer = new DataWriter(_socket.OutputStream);

                    writer.WriteString(text);
                    writer.WriteBytes(Cmd_ESC_JN);  // byte[] Cmd_ESC_JN = new byte[] { 27, 74, 230 };
                    writer.StoreAsync();
                }
            }
            catch { }
}
}
 public async Task<bool> RefreshPairedDevicesList()  
        {
            try
            {
                PeerFinder.AlternateIdentities["Bluetooth:Paired"] = "";

                var peers = await PeerFinder.FindAllPeersAsync();

                if (peers == null && peers.Count == 0)
                {
                    MessageBox.Show("NoPairedDevices");
                    return false;
                }
                else
                {
                    // Found paired devices.
                    foreach (var peer in peers)
                    {
                        _pairedDevices.Add(new PairedDeviceInfo(peer));
                    }

                    PairedDeviceInfo connectedDeive = _pairedDevices.FirstOrDefault();
                    var issuccess = await ConnectToDevice(connectedDeive.PeerInfo);
                    return issuccess;
                }
            }
            catch (Exception ex)
            {
                if ((uint)ex.HResult == 0x8007048F || (int)ex.HResult == -2147467259)
                {
                    var result = MessageBox.Show(MyStoreWP8AppConstants.Msg_BluetoothOff, "Bluetooth Off",          MessageBoxButton.OKCancel);
                    if (result == MessageBoxResult.OK)
                    {
                        ShowBluetoothcControlPanel();
                    }
                    return false;
                }
                else if ((uint)ex.HResult == 0x80070005)
                {
                    MessageBox.Show(MyStoreWP8AppConstants.Msg_MissingCaps);
                    return false;
                }
                else
                {
                    MessageBox.Show(ex.Message);
                    return false;
                }
            }
        }

        private async Task<bool> ConnectToDevice(PeerInformation peer)
        {
            if (_socket != null)
            {
                _socket.Dispose();
                _socket = null;
            }
            try
            {
                _socket = new StreamSocket();
                string serviceName = peer.ServiceName;
                serviceName = String.IsNullOrWhiteSpace(serviceName) ? "1" : serviceName;
                 await _socket.ConnectAsync(peer.HostName, serviceName);
                return true;
            }
            catch (TaskCanceledException taskEx)
            {
                return false;
            }
            catch (Exception ex)
            {
                              MessageBox.Show(ex.Message);

                              if (_socket != null)
                                  _socket.Dispose();
                              _socket = null;
                return false;
            }
}

有人可以帮助我们。

谢谢和问候, WinitWindowsTeam。

0 个答案:

没有答案