Example #1
0
        public MainForm()
        {
            InitializeComponent();

            connectBtn.Text = connectText;

            fontLoading();

            Font = new Font(fontCollection.Families[0], 8.25f);

            coloringComponents();

            tip.SetToolTip(barsCheckBox, "Передвигать ползунки одновременно на уровень передвигаемого");
            tip.SetToolTip(fadeCheckBox, "Включение плавной смены цвета после 5 секунд отсутствия звука");
            tip.SetToolTip(lightCheckBox, "Переключение между режимами цветомузыки и постоянного свечения");

            tip.SetToolTip(scanBtn, "Поиск доступных устройств TheSoundLights");
            tip.SetToolTip(deviceCombo, "Список доступных устройств TheSoundLights для подключения");

            myBt = new MyBluetooth(connectBtn, connectBtn_Click);

            if (myBt.getRadio() == null)
            {
                MessageForm.Show(MessageForm.ping_sad, "На Вашем устройстве отключен или отсутствует Bluetooth!", "Проверьте состояние Bluetooth");

                Environment.Exit(0);
            }
            else
            {
                lightShow = new LightShow(myBt, spectrumChart, trackInit(), fadeCheckBox, barsCheckBox, lightCheckBox);
            }
        }
        protected override void OnCreate(Bundle bundle)
        {
            #region Android stuff

            base.OnCreate(bundle);
            SetContentView(Resource.Layout.Main);
            Title          = "SVB Console";
            Monitor        = FindViewById <TextView>(Resource.Id.MonitorView);
            ButtonRun      = FindViewById <Button>(Resource.Id.MyButton);
            MainAct        = this;
            ConfFile       = new FileHelper();
            ConfigEntity   = Helper.Parse(ConfFile.Read());
            MainDictionary = new Dictionary <string, string>
            {
                { "phone", ConfigEntity.SosPhone1 }, { "phone2", ConfigEntity.SosPhone2 },
                { "sender", "0552395895" },
                { "longitude", "0.000000" },
                { "latitude", "0.000000" },
                { "password", ConfigEntity.Password },
                { "address", "NULL Address ! GPS ma rahch ykhdem" }
            };

            #endregion


            #region Bluetooth stuff

            Bluetooth = new MyBluetooth("HC-05", 100);
            Bluetooth.PropertyChanged += DoOnBluetoothPropChanged;
            if (Bluetooth.Socket.IsConnected)
            {
                Monitor.Text += "\r\n Bluetooth HC-05 Connected !!! \r\n";
            }
            else
            {
                Monitor.Text += "\r\n Ooops Bluetooth not Connected !!! \r\n";
            }

            #endregion

            Monitor.MovementMethod = new Android.Text.Method.ScrollingMovementMethod();
            Monitor.TextChanged   += ClearMonitor;



            ButtonRun.Click += delegate
            {
                GetAdress();
            };

            InitializeLocationManager();
            _smsManager = SmsManager.Default;
        }
Example #3
0
            public LightShow(MyBluetooth myBt, Chart spectrumChart, TrackBar[] bars, CheckBox fadeCheckBox, CheckBox barsCheckBox, CheckBox lightCheckBox)
            {
                rnd      = new Random();
                rgbTimer = new Timer();
                time     = new Stopwatch();

                this.spectrumChart = spectrumChart;

                this.myBt = myBt;
                this.bars = bars;

                ToolTip tip = new ToolTip();

                tip.SetToolTip(bars[0], "Уровень красного канала");
                tip.SetToolTip(bars[1], "Уровень оранжевого канала");
                tip.SetToolTip(bars[2], "Уровень зелёного канала");
                tip.SetToolTip(bars[3], "Уровень синего канала");

                this.fadeCheckBox  = fadeCheckBox;
                this.barsCheckBox  = barsCheckBox;
                this.lightCheckBox = lightCheckBox;

                for (int i = 0; i < numBands; i++)
                {
                    outScales[i] = 1200f;
                }

                spectrumChart.BorderlineWidth = 1;
                spectrumChart.Visible         = false;

                spectrumChart.ChartAreas[0].AxisY.Enabled            = AxisEnabled.False;
                spectrumChart.ChartAreas[0].AxisY.LabelStyle.Enabled = false;
                spectrumChart.ChartAreas[0].AxisY.MajorGrid.Enabled  = false;
                spectrumChart.ChartAreas[0].AxisY.MinorGrid.Enabled  = false;

                spectrumChart.ChartAreas[0].AxisX.Enabled            = AxisEnabled.False;
                spectrumChart.ChartAreas[0].AxisX.Maximum            = spectrumBands - 0.5;
                spectrumChart.ChartAreas[0].AxisX.Minimum            = -0.5;
                spectrumChart.ChartAreas[0].AxisX.LabelStyle.Enabled = false;
                spectrumChart.ChartAreas[0].AxisX.MajorGrid.Enabled  = false;
                spectrumChart.ChartAreas[0].AxisX.MinorGrid.Enabled  = false;

                spectrumChart.Series["FFT"].ChartType = SeriesChartType.Column;

                spectrumChart.Resize += spectrumChartResize;

                rgbTimer.Interval = 10;
                rgbTimer.Tick    += RgbTimer_Tick;
                rgbTimer.Start();
            }
Example #4
0
        static void Main(string[] args)
        {
            MyBluetooth mb = new MyBluetooth();

            Console.WriteLine("本机设备名称:" + mb.BuleRadio.Name + ",地址:" + mb.BuleRadio.LocalAddress);
            while (true)
            {
                var x = Console.ReadLine();
                if (x == "d")
                {
                    mb.DiscoverDevices();
                    int i = 0;
                    foreach (var o in mb.Devices)
                    {
                        Console.WriteLine("序号:" + i + ",设备名:" + o.DeviceName + ",地址:" + o.DeviceAddress);
                        i++;
                    }
                }
                else if (x.StartsWith("c"))
                {
                    var para = x.Split(' ')[1];
                    mb.Connect(mb.Devices[int.Parse(para)]);
                    Console.WriteLine("连接成功! 设备名:" + mb.CurrentDevices.DeviceName + ",地址:" + mb.CurrentDevices.DeviceAddress);
                }
                else if (x.StartsWith("r"))
                {
                    Console.WriteLine(mb.Read());
                }
                else if (x.StartsWith("w"))
                {
                    string str = "Hello World ! ";
                    mb.Write(str);
                    Console.WriteLine("写入数据:" + str);
                }
                else if (x.StartsWith("q"))
                {
                    MyBluetoothService ms = new MyBluetoothService();
                }
                else if (x.StartsWith("s"))
                {
                    //MyBluetoothService ms = new MyBluetoothService();
                    Console.WriteLine("启动服务------------------------");
                    mb.StartService();
                    Console.WriteLine("启动服务++++++++++++++");
                }
            }
        }