Example #1
0
        void stopRecorder_Click(object sender, EventArgs e)
        {
            try
            {
                _stopRecorder.Enabled = !(_startRecorder.Enabled = true);
                BluetoothHidWriter.RecorderList data = _hidWriter.StopRecorder();

                string fileName = string.Empty;

                if (Platform.IsWindowsMobileStandard)
                {
                    // TODO: allow for other macros
                    using (StringInput stringInput = new StringInput("Enter Name", "Enter Recorded File Name:"))
                    {
                        if (DialogResult.OK == stringInput.ShowDialog(this) && !string.IsNullOrEmpty(stringInput.Value))
                        {
                            fileName = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.Personal), string.Format("{0}.mrm", stringInput.Value));
                        }
                        else
                        {
                            return;
                        }
                    }
                }
                else
                {
                    using (SaveFileDialog sfd = new SaveFileDialog())
                    {
                        sfd.Filter = "MobileRemote Macro|.mrm";

                        if (DialogResult.OK == sfd.ShowDialog())
                        {
                            fileName = sfd.FileName;
                        }
                    }
                }

                if (!string.IsNullOrEmpty(fileName))
                {
                    using (FileStream fs = File.Create(fileName))
                    {
                        using (BinaryWriter bw = new BinaryWriter(fs))
                        {
                            byte[] binaryData = data.Serialize();
                            bw.Write(binaryData);
                            bw.Flush();
                        }
                    }
                }
            }
            catch
            {
                MessageBox.Show("There was an error saving your recording", "Error Saving Recording", MessageBoxButtons.OK, MessageBoxIcon.Exclamation, MessageBoxDefaultButton.Button1);
            }
        }
Example #2
0
        public static void AddNewAddress(UInt64 address, bool legacyMode)
        {
            if (!Utils.CheckRegistration())
            {
                return;
            }
            List <BluetoothDevice> devices = GetPreviousDevices();

            string szName = string.Empty;// address.ToString("C");

            try
            {
                int    num;
                byte[] szString = new byte[0x1f0];
                if (0 == L2CAPAPI.BthRemoteNameQuery(ref address, 0xf8, out num, szString) || num == 0)
                {
                    szName = Encoding.Unicode.GetString(szString, 0, (num - 1) * 2);;
                }
            }
            catch
            {
            }

            if (string.IsNullOrEmpty(szName))
            {
                using (StringInput si = new StringInput("Enter Name", "Enter the name of this connection..."))
                {
                    si.ShowDialog(MobileRemoteUI.Instance);
                    szName = si.Value;
                }
            }

            StringBuilder sbAddresses = new StringBuilder();

            sbAddresses.Append(String.Format("{0}={1}={2}", szName, address, legacyMode));

            List <string> names    = new List <string>();
            List <ulong>  addrs    = new List <ulong>();
            List <bool>   legModes = new List <bool>();

            for (int i = 0; i < devices.Count; ++i)
            {
                if (names.Contains(devices[i].Name) || addrs.Contains(devices[i].Address))
                {
                    devices.RemoveAt(i);
                    i--;
                }
                else
                {
                    names.Add(devices[i].Name);
                    addrs.Add(devices[i].Address);
                    legModes.Add(devices[i].LegacyMode);
                }
            }

            for (int i = 0; i < devices.Count; ++i)
            {
                if (devices[i].Address != address)
                {
                    sbAddresses.Append(",");
                    sbAddresses.Append(String.Format("{0}={1}={2}", devices[i].Name, devices[i].Address, devices[i].LegacyMode));
                }
            }

            using (RegistryKey key = Registry.CurrentUser.CreateSubKey(@"Software\MobileSrc\MobileRemote"))
            {
                key.SetValue("PreviousAddresses", sbAddresses.ToString(), RegistryValueKind.String);
            }
        }
Example #3
0
        void stopRecorder_Click(object sender, EventArgs e)
        {
            try
            {
                _stopRecorder.Enabled = !(_startRecorder.Enabled = true);
                BluetoothHidWriter.RecorderList data = _hidWriter.StopRecorder();

                string fileName = string.Empty;

                if (Platform.IsWindowsMobileStandard)
                {
                    // TODO: allow for other macros
                    using (StringInput stringInput = new StringInput("Enter Name", "Enter Recorded File Name:"))
                    {
                        if (DialogResult.OK == stringInput.ShowDialog(this) && !string.IsNullOrEmpty(stringInput.Value))
                        {
                            fileName = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.Personal), string.Format("{0}.mrm", stringInput.Value));
                        }
                        else
                        {
                            return;
                        }
                    }
                }
                else
                {
                    using (SaveFileDialog sfd = new SaveFileDialog())
                    {
                        sfd.Filter = "MobileRemote Macro|.mrm";

                        if (DialogResult.OK == sfd.ShowDialog())
                        {
                            fileName = sfd.FileName;
                        }
                    }
                }

                if (!string.IsNullOrEmpty(fileName))
                {
                    using (FileStream fs = File.Create(fileName))
                    {
                        using (BinaryWriter bw = new BinaryWriter(fs))
                        {
                            byte[] binaryData = data.Serialize();
                            bw.Write(binaryData);
                            bw.Flush();
                        }
                    }
                }
            }
            catch
            {
                MessageBox.Show("There was an error saving your recording", "Error Saving Recording", MessageBoxButtons.OK, MessageBoxIcon.Exclamation, MessageBoxDefaultButton.Button1);
            }
        }
Example #4
0
        public static void AddNewAddress(UInt64 address, bool legacyMode)
        {
            if (!Utils.CheckRegistration())
            {
                return;
            }
            List<BluetoothDevice> devices = GetPreviousDevices();

            string szName = string.Empty;// address.ToString("C");

            try
            {
                int num;
                byte[] szString = new byte[0x1f0];
                if (0 == L2CAPAPI.BthRemoteNameQuery(ref address, 0xf8, out num, szString) || num == 0)
                {
                    szName = Encoding.Unicode.GetString(szString, 0, (num - 1) * 2); ;
                }
            }
            catch
            {
            }

            if (string.IsNullOrEmpty(szName))
            {
                using (StringInput si = new StringInput("Enter Name", "Enter the name of this connection..."))
                {
                    si.ShowDialog(MobileRemoteUI.Instance);
                    szName = si.Value;
                }
            }

            StringBuilder sbAddresses = new StringBuilder();
            sbAddresses.Append(String.Format("{0}={1}={2}", szName, address, legacyMode));

            List<string> names = new List<string>();
            List<ulong> addrs = new List<ulong>();
            List<bool> legModes = new List<bool>();

            for (int i = 0; i < devices.Count; ++i)
            {
                if (names.Contains(devices[i].Name) || addrs.Contains(devices[i].Address))
                {
                    devices.RemoveAt(i);
                    i--;
                }
                else
                {
                    names.Add(devices[i].Name);
                    addrs.Add(devices[i].Address);
                    legModes.Add(devices[i].LegacyMode);
                }
            }

            for (int i = 0; i < devices.Count; ++i)
            {
                if (devices[i].Address != address)
                {
                    sbAddresses.Append(",");
                    sbAddresses.Append(String.Format("{0}={1}={2}", devices[i].Name, devices[i].Address, devices[i].LegacyMode));
                }
            }

            using (RegistryKey key = Registry.CurrentUser.CreateSubKey(@"Software\MobileSrc\MobileRemote"))
            {
                key.SetValue("PreviousAddresses", sbAddresses.ToString(), RegistryValueKind.String);
            }
        }