Esempio n. 1
0
        public WinForms()
        {
            InitializeComponent();

            size = Device.Info.ScaledScreenSize;
            size = Device.Info.PixelScreenSize;

            size = new Forms.Size(900, 540); // 1.66 - remove back and home pane

            Instance            = this;
            MainV2.speechEngine = new Speech();
        }
Esempio n. 2
0
        private void StartThreads()
        {
            size = Device.Info.ScaledScreenSize;
            size = Device.Info.PixelScreenSize;

            size  = new Forms.Size(900, 540); // 1.66 - remove back and home pane
            scale = new Forms.Size((Device.Info.PixelScreenSize.Width / size.Width),
                                   (Device.Info.PixelScreenSize.Height / size.Height));

            XplatUIMine.GetInstance()._virtualScreen = new Rectangle(0, 0, (int)size.Width, (int)size.Height);
            XplatUIMine.GetInstance()._workingArea   = new Rectangle(0, 0, (int)size.Width, (int)size.Height);

            winforms = new Thread(() =>
            {
                AppDomain.CurrentDomain.UnhandledException += CurrentDomain_UnhandledException;

                Application.Idle += (sender, args) => Thread.Sleep(0);

                MissionPlanner.Program.Main(new string[0]);
            });
            winforms.Start();

            Forms.Device.StartTimer(TimeSpan.FromMilliseconds(1000 / 30), () =>
            {
                Monitor.Enter(XplatUIMine.paintlock);
                if (XplatUIMine.PaintPending)
                {
                    if (SkCanvasView != null)
                    {
                        scale = new Forms.Size((Instance.SkCanvasView.CanvasSize.Width / size.Width),
                                               (Instance.SkCanvasView.CanvasSize.Height / size.Height));

                        XplatUIMine.GetInstance()._virtualScreen =
                            new Rectangle(0, 0, (int)size.Width, (int)size.Height);
                        XplatUIMine.GetInstance()._workingArea =
                            new Rectangle(0, 0, (int)size.Width, (int)size.Height);

                        Device.BeginInvokeOnMainThread(() => { Instance.SkCanvasView.InvalidateSurface(); });
                        XplatUIMine.PaintPending = false;
                    }
                }
                Monitor.Exit(XplatUIMine.paintlock);

                return(true);
            });
        }
Esempio n. 3
0
        public WinForms()
        {
            InitializeComponent();

            size = Device.Info.ScaledScreenSize;
            size = Device.Info.PixelScreenSize;

            var scale = size.Width / size.Height; // 1.77 1.6  1.33


            size = new Forms.Size(540 * scale, 540);
            if (size.Width < 960)
            {
                size = new Forms.Size(960, 960 / scale);
            }

            Instance            = this;
            MainV2.speechEngine = new Speech();

            // init seril port type
            SerialPort.DefaultType = (self, s, i) =>
            {
                return(Task.Run(async() =>
                {
                    Log.Info(TAG, "SerialPort.DefaultType in " + s + " " + i);

                    // no valid portname to start
                    if (String.IsNullOrEmpty(s))
                    {
                        Log.Info(TAG, "SerialPort.DefaultType passthrough s = null");
                        return self._baseport;
                    }
                    else
                    {
                        var dil = await Test.UsbDevices.GetDeviceInfoList();

                        var di = dil.Where(a => a.board == s);

                        if (di.Count() > 0)
                        {
                            Log.Info(TAG, "SerialPort.DefaultType found device " + di.First().board + " search " + s);
                            return await Test.UsbDevices.GetUSB(di.First());
                        }
                    }

                    Log.Info(TAG, "SerialPort.DefaultType passthrough no board match");
                    return self._baseport;
                }).Result);
            };

            // report back device list
            SerialPort.GetCustomPorts = () =>
            {
                var list1 = Task.Run(async() =>
                {
                    var list = await Test.BlueToothDevice.GetDeviceInfoList();
                    return(list.Select(a => a.board).ToList());
                }).Result;

                var list2 = Task.Run(async() =>
                {
                    var list = await Test.UsbDevices.GetDeviceInfoList();
                    return(list.Select(a => a.board).ToList());
                }).Result;

                list1.AddRange(list2);
                return(list1);
            };

            // support for fw upload
            MissionPlanner.GCSViews.ConfigurationView.ConfigFirmwareManifest.ExtraDeviceInfo += () =>
            {
                return(Task.Run(async() => { return await Test.UsbDevices.GetDeviceInfoList(); }).Result);
            };

            MissionPlanner.GCSViews.ConfigurationView.ConfigFirmware.ExtraDeviceInfo += () =>
            {
                return(Task.Run(async() => { return await Test.UsbDevices.GetDeviceInfoList(); }).Result);
            };
        }
Esempio n. 4
0
        public WinForms()
        {
            InitializeComponent();

            size = Device.Info.ScaledScreenSize;
            size = Device.Info.PixelScreenSize;

            Xamarin.Forms.Platform.WinForms.Forms.UIThread = Thread.CurrentThread.ManagedThreadId;

            var scale = size.Width / size.Height; // 1.77 1.6  1.33

            if (scale < 1)
            {
                size = new Forms.Size(960, 960 * scale);
            }
            else
            {
                size = new Forms.Size(540 * scale, 540);
                if (size.Width < 960)
                {
                    size = new Forms.Size(960, 960 / scale);
                }
            }

            if (Device.RuntimePlatform == Device.macOS || Device.RuntimePlatform == Device.UWP)
            {
                size = Device.Info.PixelScreenSize;
                // scale if higher than full hd
                if (size.Width > 1920)
                {
                    size.Width  /= 2;
                    size.Height /= 2;
                }
            }

            Instance = this;
            try
            {
                MainV2.speechEngine = new Speech();
            } catch {}

            RestoreFiles();

            // init seril port type
            SerialPort.DefaultType = (self, s, i) =>
            {
                if (Device.RuntimePlatform == Device.macOS)
                {
                    Log.Info(TAG, "SerialPort.DefaultType in " + s + " " + i + " for " + Device.RuntimePlatform);
                    return(new MonoSerialPort());
                }

                return(Task.Run(async() =>
                {
                    Log.Info(TAG, "SerialPort.DefaultType in " + s + " " + i);

                    // no valid portname to start
                    if (String.IsNullOrEmpty(s))
                    {
                        Log.Info(TAG, "SerialPort.DefaultType passthrough s = null");
                        return self._baseport;
                    }
                    else
                    {
                        if (s.StartsWith("BT_"))
                        {
                            var bt = await Test.BlueToothDevice.GetDeviceInfoList();

                            var di = bt.Where(a => a.board == s);

                            if (di.Count() > 0)
                            {
                                Log.Info(TAG, "SerialPort.DefaultType found device " + di.First().board + " search " + s);
                                return await Test.BlueToothDevice.GetBT(di.First());
                            }
                        }

                        if (s.StartsWith("GPS"))
                        {
                            var com = new CommsInjection();
                            Task.Run(async() => {
                                while (true)
                                {
                                    var(lat, lng, alt) = await Test.GPS.GetPosition();
                                    var latdms = (int)lat + (lat - (int)lat) * .6f;
                                    var lngdms = (int)lng + (lng - (int)lng) * .6f;

                                    var line = string.Format(CultureInfo.InvariantCulture,
                                                             "$GP{0},{1:HHmmss.ff},{2},{3},{4},{5},{6},{7},{8},{9},{10},{11},{12},{13},{14}", "GGA",
                                                             DateTime.Now.ToUniversalTime(),
                                                             Math.Abs(latdms * 100).ToString("0000.00", CultureInfo.InvariantCulture), lat < 0 ? "S" : "N",
                                                             Math.Abs(lngdms * 100).ToString("00000.00", CultureInfo.InvariantCulture), lng < 0 ? "W" : "E",
                                                             1, 10,
                                                             1, alt.ToString("0.00", CultureInfo.InvariantCulture), "M", 0, "M", "0.0", "0");

                                    var checksum = GetChecksum(line);
                                    com.AppendBuffer(ASCIIEncoding.ASCII.GetBytes(line + "*" + checksum + "\r\n"));

                                    await Task.Delay(200);
                                }
                            });

                            return com;
                        }

                        {
                            var dil = await Test.UsbDevices.GetDeviceInfoList();

                            var di = dil.Where(a => a.board == s);

                            if (di.Count() > 0)
                            {
                                Log.Info(TAG,
                                         "SerialPort.DefaultType found device " + di.First().board + " search " + s);
                                return await Test.UsbDevices.GetUSB(di.First());
                            }
                        }
                    }

                    Log.Info(TAG, "SerialPort.DefaultType passthrough no board match");
                    return self._baseport;
                }).Result);
            };

            // report back device list
            SerialPort.GetCustomPorts = () =>
            {
                var list1 = Task.Run(async() =>
                {
                    var list = await Test.BlueToothDevice.GetDeviceInfoList();
                    return(list.Select(a => a.board).ToList());
                }).Result;

                var list2 = Task.Run(async() =>
                {
                    var list = await Test.UsbDevices.GetDeviceInfoList();
                    return(list.Select(a => a.board).ToList());
                }).Result;

                list1.AddRange(list2);
                if (Device.RuntimePlatform == Device.Android)
                {
                    list1.Add("GPS");
                }

                return(list1);
            };

            /*
             * // support for fw upload
             * MissionPlanner.GCSViews.ConfigurationView.ConfigFirmwareManifest.ExtraDeviceInfo += () =>
             * {
             * return Task.Run(async () => { return await Test.UsbDevices.GetDeviceInfoList(); }).Result;
             * };
             *
             * MissionPlanner.GCSViews.ConfigurationView.ConfigFirmware.ExtraDeviceInfo += () =>
             * {
             * return Task.Run(async () => { return await Test.UsbDevices.GetDeviceInfoList(); }).Result;
             * };*/
        }
Esempio n. 5
0
 public static IPlatformElementConfiguration <Windows, FormsElement> SetHeaderIconsSize(
     this IPlatformElementConfiguration <Windows, FormsElement> config, Forms.Size value)
 {
     SetHeaderIconsSize(config.Element, value);
     return(config);
 }
Esempio n. 6
0
 public static void SetHeaderIconsSize(BindableObject element, Forms.Size value)
 {
     element.SetValue(HeaderIconsSizeProperty, value);
 }
Esempio n. 7
0
        public WinForms()
        {
            InitializeComponent();

            size = Device.Info.ScaledScreenSize;
            size = Device.Info.PixelScreenSize;

            Xamarin.Forms.Platform.WinForms.Forms.UIThread = Thread.CurrentThread.ManagedThreadId;

            var scale = size.Width / size.Height; // 1.77 1.6  1.33

            if (scale < 1)
            {
                size = new Forms.Size(960, 960 * scale);
            }
            else
            {
                size = new Forms.Size(540 * scale, 540);
                if (size.Width < 960)
                {
                    size = new Forms.Size(960, 960 / scale);
                }
            }

            if (Device.RuntimePlatform == Device.macOS || Device.RuntimePlatform == Device.UWP)
            {
                size = Device.Info.PixelScreenSize;
                // scale if higher than full hd
                if (size.Width > 1920)
                {
                    size.Width  /= 2;
                    size.Height /= 2;
                }
            }

            Instance = this;
            try
            {
                MainV2.speechEngine = new Speech();
            } catch {}

            RestoreFiles();

            // init seril port type
            SerialPort.DefaultType = (self, s, i) =>
            {
                if (Device.RuntimePlatform == Device.macOS)
                {
                    Log.Info(TAG, "SerialPort.DefaultType in " + s + " " + i + " for " + Device.RuntimePlatform);
                    return(new MonoSerialPort());
                }

                return(Task.Run(async() =>
                {
                    Log.Info(TAG, "SerialPort.DefaultType in " + s + " " + i);

                    // no valid portname to start
                    if (String.IsNullOrEmpty(s))
                    {
                        Log.Info(TAG, "SerialPort.DefaultType passthrough s = null");
                        return self._baseport;
                    }
                    else
                    {
                        if (s.StartsWith("BT_"))
                        {
                            var bt = await Test.BlueToothDevice.GetDeviceInfoList();

                            var di = bt.Where(a => a.board == s);

                            if (di.Count() > 0)
                            {
                                Log.Info(TAG, "SerialPort.DefaultType found device " + di.First().board + " search " + s);
                                return await Test.BlueToothDevice.GetBT(di.First());
                            }
                        }

                        {
                            var dil = await Test.UsbDevices.GetDeviceInfoList();

                            var di = dil.Where(a => a.board == s);

                            if (di.Count() > 0)
                            {
                                Log.Info(TAG,
                                         "SerialPort.DefaultType found device " + di.First().board + " search " + s);
                                return await Test.UsbDevices.GetUSB(di.First());
                            }
                        }
                    }

                    Log.Info(TAG, "SerialPort.DefaultType passthrough no board match");
                    return self._baseport;
                }).Result);
            };

            // report back device list
            SerialPort.GetCustomPorts = () =>
            {
                var list1 = Task.Run(async() =>
                {
                    var list = await Test.BlueToothDevice.GetDeviceInfoList();
                    return(list.Select(a => a.board).ToList());
                }).Result;

                var list2 = Task.Run(async() =>
                {
                    var list = await Test.UsbDevices.GetDeviceInfoList();
                    return(list.Select(a => a.board).ToList());
                }).Result;

                list1.AddRange(list2);
                return(list1);
            };

            /*
             * // support for fw upload
             * MissionPlanner.GCSViews.ConfigurationView.ConfigFirmwareManifest.ExtraDeviceInfo += () =>
             * {
             * return Task.Run(async () => { return await Test.UsbDevices.GetDeviceInfoList(); }).Result;
             * };
             *
             * MissionPlanner.GCSViews.ConfigurationView.ConfigFirmware.ExtraDeviceInfo += () =>
             * {
             * return Task.Run(async () => { return await Test.UsbDevices.GetDeviceInfoList(); }).Result;
             * };*/
        }