Ejemplo n.º 1
0
        public void Activate()
        {
            startup = true;

            CMB_paramfiles.Enabled    = false;
            BUT_paramfileload.Enabled = false;
            ThreadPool.QueueUserWorkItem(updatedefaultlist);

            SuspendLayout();

            foreach (DataGridViewColumn col in Params.Columns)
            {
                if (!String.IsNullOrEmpty(MainV2.getConfig("rawparam_" + col.Name + "_width")))
                {
                    col.Width = int.Parse(MainV2.config["rawparam_" + col.Name + "_width"].ToString());
                }
            }

            processToScreen();

            ResumeLayout();

            Common.MessageShowAgain(Strings.RawParamWarning, Strings.RawParamWarningi);

            startup = false;

            txt_search.Focus();
        }
Ejemplo n.º 2
0
        public static void doUserAndPassword()
        {
            string droneshareusername = MainV2.getConfig("droneshareusername");

            InputBox.Show("Username", "Username", ref droneshareusername);

            MainV2.config["droneshareusername"] = droneshareusername;

            string dronesharepassword = MainV2.getConfig("dronesharepassword");

            if (dronesharepassword != "")
            {
                try
                {
                    // fail on bad entry
                    var crypto = new Crypto();
                    dronesharepassword = crypto.DecryptString(dronesharepassword);
                }
                catch { }
            }

            InputBox.Show("Password", "Password", ref dronesharepassword, true);

            var crypto2 = new Crypto();

            string encryptedpw = crypto2.EncryptString(dronesharepassword);

            MainV2.config["dronesharepassword"] = encryptedpw;
        }
Ejemplo n.º 3
0
        void loadSettings()
        {
            string desc = MainV2.getConfig("Servo" + thisservo + "_desc");
            string low  = MainV2.getConfig("Servo" + thisservo + "_low");
            string high = MainV2.getConfig("Servo" + thisservo + "_high");

            string highdesc = MainV2.getConfig("Servo" + thisservo + "_highdesc");
            string lowdesc  = MainV2.getConfig("Servo" + thisservo + "_lowdesc");

            if (low != "")
            {
                TXT_pwm_low.Text = low;
            }

            if (high != "")
            {
                TXT_pwm_high.Text = high;
            }

            if (desc != "")
            {
                TXT_rcchannel.Text = desc;
            }

            if (highdesc != "")
            {
                BUT_High.Text = highdesc;
            }

            if (lowdesc != "")
            {
                BUT_Low.Text = lowdesc;
            }
        }
Ejemplo n.º 4
0
        void loadSettings()
        {
            string low  = MainV2.getConfig("Servo" + thisservo + "_low");
            string high = MainV2.getConfig("Servo" + thisservo + "_high");

            if (low != "")
            {
                TXT_pwm_low.Text = low;
            }

            if (high != "")
            {
                TXT_pwm_high.Text = high;
            }
        }
Ejemplo n.º 5
0
        public static void doUpload(string file)
        {
            if (!validcred)
            {
                doUserAndPassword();
            }

            string droneshareusername = MainV2.getConfig("droneshareusername");

            string dronesharepassword = MainV2.getConfig("dronesharepassword");

            if (dronesharepassword != "")
            {
                try
                {
                    // fail on bad entry
                    var crypto = new Crypto();
                    dronesharepassword = crypto.DecryptString(dronesharepassword);
                }
                catch { }
            }

            MAVLinkInterface mav = new MAVLinkInterface();

            mav.BaseStream          = new Comms.CommsFile();
            mav.BaseStream.PortName = file;
            mav.BaseStream.Open();
            if (mav.getHeartBeat().Length == 0)
            {
                CustomMessageBox.Show("Invalid log");
                return;
            }
            mav.Close();

            string viewurl = Utilities.DroneApi.droneshare.doUpload(file, droneshareusername, dronesharepassword, mav.MAV.Guid, Utilities.DroneApi.APIConstants.apiKey);

            if (viewurl != "")
            {
                try
                {
                    validcred = true;
                    System.Diagnostics.Process.Start(viewurl);
                }
                catch (Exception ex) { log.Error(ex); CustomMessageBox.Show("Failed to open url " + viewurl); }
            }
        }
Ejemplo n.º 6
0
        private void CMB_videosources_SelectedIndexChanged(object sender, EventArgs e)
        {
            if (MainV2.MONO)
            {
                return;
            }

            int                   hr;
            int                   count;
            int                   size;
            object                o;
            IBaseFilter           capFilter = null;
            ICaptureGraphBuilder2 capGraph  = null;
            AMMediaType           media     = null;
            VideoInfoHeader       v;
            VideoStreamConfigCaps c;
            List <GCSBitmapInfo>  modes = new List <GCSBitmapInfo>();

            // Get the ICaptureGraphBuilder2
            capGraph = (ICaptureGraphBuilder2) new CaptureGraphBuilder2();
            IFilterGraph2 m_FilterGraph = (IFilterGraph2) new FilterGraph();

            DsDevice[] capDevices;
            capDevices = DsDevice.GetDevicesOfCat(FilterCategory.VideoInputDevice);

            // Add the video device
            hr = m_FilterGraph.AddSourceFilterForMoniker(capDevices[CMB_videosources.SelectedIndex].Mon, null, "Video input", out capFilter);
            try
            {
                DsError.ThrowExceptionForHR(hr);
            }
            catch (Exception ex)
            {
                CustomMessageBox.Show("Can not add video source\n" + ex.ToString());
                return;
            }

            // Find the stream config interface
            hr = capGraph.FindInterface(PinCategory.Capture, MediaType.Video, capFilter, typeof(IAMStreamConfig).GUID, out o);
            DsError.ThrowExceptionForHR(hr);

            IAMStreamConfig videoStreamConfig = o as IAMStreamConfig;

            if (videoStreamConfig == null)
            {
                throw new Exception("Failed to get IAMStreamConfig");
            }

            hr = videoStreamConfig.GetNumberOfCapabilities(out count, out size);
            DsError.ThrowExceptionForHR(hr);
            IntPtr TaskMemPointer = Marshal.AllocCoTaskMem(size);

            for (int i = 0; i < count; i++)
            {
                IntPtr ptr = IntPtr.Zero;

                hr = videoStreamConfig.GetStreamCaps(i, out media, TaskMemPointer);
                v  = (VideoInfoHeader)Marshal.PtrToStructure(media.formatPtr, typeof(VideoInfoHeader));
                c  = (VideoStreamConfigCaps)Marshal.PtrToStructure(TaskMemPointer, typeof(VideoStreamConfigCaps));
                modes.Add(new GCSBitmapInfo(v.BmiHeader.Width, v.BmiHeader.Height, c.MaxFrameInterval, c.VideoStandard.ToString(), media));
            }
            Marshal.FreeCoTaskMem(TaskMemPointer);
            DsUtils.FreeAMMediaType(media);

            CMB_videoresolutions.DataSource = modes;

            if (MainV2.getConfig("video_options") != "" && CMB_videosources.Text != "")
            {
                try
                {
                    CMB_videoresolutions.SelectedIndex = int.Parse(MainV2.getConfig("video_options"));
                }
                catch { } // ignore bad entries
            }
        }
Ejemplo n.º 7
0
        // Called every time that this control is made current in the backstage view
        public void Activate()
        {
            startup = true; // flag to ignore changes while we programatically populate controls


            CMB_osdcolor.DataSource = Enum.GetNames(typeof(KnownColor));

            // set distance/speed unit states
            CMB_distunits.DataSource  = Enum.GetNames(typeof(Common.distances));
            CMB_speedunits.DataSource = Enum.GetNames(typeof(Common.speeds));

            CMB_theme.DataSource = Enum.GetNames(typeof(ThemeManager.Themes));

            CMB_theme.Text = ThemeManager.CurrentTheme.ToString();

            // setup language selection
            var cultureCodes = new[]
            { "en-US", "zh-Hans", "zh-TW", "ru-RU", "Fr", "Pl", "it-IT", "es-ES", "de-DE", "ja-JP", "id-ID" };

            _languages = cultureCodes
                         .Select(CultureInfoEx.GetCultureInfo)
                         .Where(c => c != null)
                         .ToList();

            CMB_language.DisplayMember = "DisplayName";
            CMB_language.DataSource    = _languages;
            var currentUiCulture = Thread.CurrentThread.CurrentUICulture;

            for (var i = 0; i < _languages.Count; i++)
            {
                if (currentUiCulture.IsChildOf(_languages[i]))
                {
                    try
                    {
                        CMB_language.SelectedIndex = i;
                    }
                    catch
                    {
                    }
                    break;
                }
            }

            // setup up camera button states
            if (MainV2.cam != null)
            {
                BUT_videostart.Enabled = false;
                CHK_hudshow.Checked    = FlightData.myhud.hudon;
            }
            else
            {
                BUT_videostart.Enabled = true;
            }

            // setup speech states
            SetCheckboxFromConfig("speechenable", CHK_enablespeech);
            SetCheckboxFromConfig("speechwaypointenabled", CHK_speechwaypoint);
            SetCheckboxFromConfig("speechmodeenabled", CHK_speechmode);
            SetCheckboxFromConfig("speechcustomenabled", CHK_speechcustom);
            SetCheckboxFromConfig("speechbatteryenabled", CHK_speechbattery);
            SetCheckboxFromConfig("speechaltenabled", CHK_speechaltwarning);
            SetCheckboxFromConfig("speecharmenabled", CHK_speecharmdisarm);
            SetCheckboxFromConfig("speechlowspeedenabled", CHK_speechlowspeed);
            SetCheckboxFromConfig("beta_updates", CHK_beta);
            SetCheckboxFromConfig("password_protect", CHK_Password);
            SetCheckboxFromConfig("advancedview", CHK_advancedview);
            SetCheckboxFromConfig("showairports", CHK_showairports);
            SetCheckboxFromConfig("enableadsb", chk_ADSB);

            // this can't fail because it set at startup
            NUM_tracklength.Value = int.Parse(MainV2.config["NUM_tracklength"].ToString());

            // get wps on connect
            SetCheckboxFromConfig("loadwpsonconnect", CHK_loadwponconnect);

            // setup other config state
            SetCheckboxFromConfig("CHK_resetapmonconnect", CHK_resetapmonconnect);

            CMB_rateattitude.Text = MainV2.comPort.MAV.cs.rateattitude.ToString();
            CMB_rateposition.Text = MainV2.comPort.MAV.cs.rateposition.ToString();
            CMB_raterc.Text       = MainV2.comPort.MAV.cs.raterc.ToString();
            CMB_ratestatus.Text   = MainV2.comPort.MAV.cs.ratestatus.ToString();
            CMB_ratesensors.Text  = MainV2.comPort.MAV.cs.ratesensors.ToString();

            SetCheckboxFromConfig("analyticsoptout", chk_analytics);

            SetCheckboxFromConfig("CHK_GDIPlus", CHK_GDIPlus);
            SetCheckboxFromConfig("CHK_maprotation", CHK_maprotation);

            SetCheckboxFromConfig("CHK_disttohomeflightdata", CHK_disttohomeflightdata);

            //set hud color state
            var hudcolor = (string)MainV2.config["hudcolor"];
            var index    = CMB_osdcolor.Items.IndexOf(hudcolor ?? "White");

            try
            {
                CMB_osdcolor.SelectedIndex = index;
            }
            catch
            {
            }


            if (MainV2.config["distunits"] != null)
            {
                CMB_distunits.Text = MainV2.config["distunits"].ToString();
            }
            if (MainV2.config["speedunits"] != null)
            {
                CMB_speedunits.Text = MainV2.config["speedunits"].ToString();
            }

            try
            {
                if (MainV2.config["video_device"] != null)
                {
                    CMB_videosources_Click(this, null);
                    CMB_videosources.SelectedIndex = int.Parse(MainV2.config["video_device"].ToString());

                    if (MainV2.getConfig("video_options") != "" && CMB_videosources.Text != "")
                    {
                        CMB_videoresolutions.SelectedIndex = int.Parse(MainV2.getConfig("video_options"));
                    }
                }
            }
            catch
            {
            }


            txt_log_dir.Text = MainV2.LogDir;

            startup = false;
        }
Ejemplo n.º 8
0
        public static void doUpload(string file)
        {
            if (file == null)
            {
                return;
            }

            if (!validcred)
            {
                doUserAndPassword();
            }

            string droneshareusername = MainV2.getConfig("droneshareusername");

            string dronesharepassword = MainV2.getConfig("dronesharepassword");

            if (dronesharepassword != "")
            {
                try
                {
                    // fail on bad entry
                    var crypto = new Crypto();
                    dronesharepassword = crypto.DecryptString(dronesharepassword);
                }
                catch
                {
                }
            }


            String tempguid = null;

            if (!doLogin(droneshareusername, dronesharepassword))
            {
                CustomMessageBox.Show("Bad Credentials", Strings.ERROR);
                return;
            }

            validcred = true;

            if (uuidcached == "")
            {
                UI.VehicleSelection veh = new VehicleSelection(accountuuids);
                veh.ShowDialog();

                tempguid   = veh.uuid;
                uuidcached = veh.uuid;
            }
            else
            {
                tempguid = uuidcached;
            }

            string viewurl = Utilities.DroneApi.droneshare.doUpload(file, droneshareusername, dronesharepassword,
                                                                    tempguid);

            if (viewurl != "")
            {
                try
                {
                    System.Diagnostics.Process.Start(viewurl);
                }
                catch (Exception ex)
                {
                    log.Error(ex);
                    CustomMessageBox.Show("Failed to open url " + viewurl);
                }
            }
        }