示例#1
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;
        }
示例#2
0
        private void BUT_setup_Click(object sender, EventArgs e)
        {
            Form temp = new Setup.Setup();

            MainV2.fixtheme(temp);
            temp.ShowDialog();
        }
示例#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;
            }
        }
        public void Activate()
        {
            startup = true;

            SuspendLayout();

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

            processToScreen();

            ResumeLayout();

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

            CMB_paramfiles.Enabled    = false;
            BUT_paramfileload.Enabled = false;

            ThreadPool.QueueUserWorkItem(updatedefaultlist);

            startup = false;

            txt_search.Focus();
        }
        private void BUT_compare_Click(object sender, EventArgs e)
        {
            Hashtable param2 = new Hashtable();

            OpenFileDialog ofd = new OpenFileDialog();

            ofd.AddExtension     = true;
            ofd.DefaultExt       = ".param";
            ofd.RestoreDirectory = true;
            ofd.Filter           = "Param List|*.param;*.parm";
            DialogResult dr = ofd.ShowDialog();

            if (dr == DialogResult.OK)
            {
                StreamReader sr = new StreamReader(ofd.OpenFile());
                while (!sr.EndOfStream)
                {
                    string line = sr.ReadLine();

                    if (line.Contains("NOTE:"))
                    {
                        MessageBox.Show(line, "Saved Note");
                    }

                    int index = line.IndexOf(',');

                    if (index == -1)
                    {
                        continue;
                    }

                    string name  = line.Substring(0, index);
                    float  value = float.Parse(line.Substring(index + 1), new System.Globalization.CultureInfo("en-US"));

                    MAVLink.modifyParamForDisplay(true, name, ref value);

                    if (name == "SYSID_SW_MREV")
                    {
                        continue;
                    }
                    if (name == "WP_TOTAL")
                    {
                        continue;
                    }
                    if (name == "CMD_TOTAL")
                    {
                        continue;
                    }

                    param2[name] = value;
                }
                sr.Close();

                ParamCompare temp = new ParamCompare(this, param, param2);
                MainV2.fixtheme(temp);
                temp.ShowDialog();
            }
        }
示例#6
0
        private void Logs_Click(object sender, EventArgs e)
        {
            Form Log = new Log();

            MainV2.fixtheme(Log);
            inlogview = true;
            Log.ShowDialog();
            inlogview = false;
        }
示例#7
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;
            }
        }
示例#8
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); }
            }
        }
示例#9
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
            }
        }
        private void Configuration_Load(object sender, EventArgs e)
        {
            startup = true;

            // enable disable relevbant hardware tabs
            if (MainV2.APMFirmware == MainV2.Firmwares.ArduPlane)
            {
                ConfigTabs.SelectedIndex = 0;
                TabAPM2.Enabled          = true;
                TabAC2.Enabled           = false;
            }
            else
            {
                ConfigTabs.SelectedIndex = 1;
                TabAPM2.Enabled          = false;
                TabAC2.Enabled           = true;
            }

            // read tooltips
            if (tooltips.Count == 0)
            {
                readToolTips();
            }

            // prefill all fields
            param = MainV2.comPort.param;
            processToScreen();



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

            // setup speech states
            if (MainV2.config["speechenable"] != null)
            {
                CHK_enablespeech.Checked = bool.Parse(MainV2.config["speechenable"].ToString());
            }
            if (MainV2.config["speechwaypointenabled"] != null)
            {
                CHK_speechwaypoint.Checked = bool.Parse(MainV2.config["speechwaypointenabled"].ToString());
            }
            if (MainV2.config["speechmodeenabled"] != null)
            {
                CHK_speechmode.Checked = bool.Parse(MainV2.config["speechmodeenabled"].ToString());
            }
            if (MainV2.config["speechcustomenabled"] != null)
            {
                CHK_speechcustom.Checked = bool.Parse(MainV2.config["speechcustomenabled"].ToString());
            }
            if (MainV2.config["speechbatteryenabled"] != null)
            {
                CHK_speechbattery.Checked = bool.Parse(MainV2.config["speechbatteryenabled"].ToString());
            }
            if (MainV2.config["speechaltenabled"] != null)
            {
                CHK_speechaltwarning.Checked = bool.Parse(MainV2.config["speechaltenabled"].ToString());
            }

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

            // get wps on connect
            if (MainV2.config["loadwpsonconnect"] != null)
            {
                CHK_loadwponconnect.Checked = bool.Parse(MainV2.config["loadwpsonconnect"].ToString());
            }

            // setup other config state
            if (MainV2.config["CHK_resetapmonconnect"] != null)
            {
                CHK_resetapmonconnect.Checked = bool.Parse(MainV2.config["CHK_resetapmonconnect"].ToString());
            }

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


            if (MainV2.config["CHK_GDIPlus"] != null)
            {
                CHK_GDIPlus.Checked = bool.Parse(MainV2.config["CHK_GDIPlus"].ToString());
            }

            //set hud color state
            string hudcolor = (string)MainV2.config["hudcolor"];

            CMB_osdcolor.DataSource = Enum.GetNames(typeof(KnownColor));
            if (hudcolor != null)
            {
                int index = CMB_osdcolor.Items.IndexOf(hudcolor);
                CMB_osdcolor.SelectedIndex = index;
            }
            else
            {
                int index = CMB_osdcolor.Items.IndexOf("White");
                CMB_osdcolor.SelectedIndex = index;
            }

            // set distance/speed unit states
            CMB_distunits.DataSource  = Enum.GetNames(typeof(Common.distances));
            CMB_speedunits.DataSource = Enum.GetNames(typeof(Common.speeds));
            if (MainV2.config["distunits"] != null)
            {
                CMB_distunits.Text = MainV2.config["distunits"].ToString();
            }
            if (MainV2.config["speedunits"] != null)
            {
                CMB_speedunits.Text = MainV2.config["speedunits"].ToString();
            }

            // setup language selection
            CultureInfo ci = null;

            foreach (string name in new string[] { "en-US", "zh-Hans", "zh-TW", "ru-RU", "Fr" })
            {
                ci = MainV2.getcultureinfo(name);
                if (ci != null)
                {
                    languages.Add(ci);
                }
            }

            CMB_language.DisplayMember = "DisplayName";
            CMB_language.DataSource    = languages;
            bool match = false;

            for (int i = 0; i < languages.Count && !match; i++)
            {
                ci = Thread.CurrentThread.CurrentUICulture;
                while (!ci.Equals(CultureInfo.InvariantCulture))
                {
                    if (ci.Equals(languages[i]))
                    {
                        CMB_language.SelectedIndex = i;
                        match = true;
                        break;
                    }
                    ci = ci.Parent;
                }
            }
            CMB_language.SelectedIndexChanged += CMB_language_SelectedIndexChanged;

            startup = false;
        }
示例#11
0
 public MainV2()
 {
     CurrentForm = this;
     InitializeComponent();
 }
示例#12
0
 public void BUT_updatecheck_Click(object sender, EventArgs e)
 {
     MainV2.DoUpdate();
 }
示例#13
0
        private void BUT_updatecheck_Click(object sender, EventArgs e)
        {
            Form loading = new Form();

            loading.Width         = 400;
            loading.Height        = 150;
            loading.StartPosition = FormStartPosition.CenterScreen;
            System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(MainV2));
            loading.Icon = ((System.Drawing.Icon)(resources.GetObject("$this.Icon")));

            Label loadinglabel = new Label();

            loadinglabel.Location = new System.Drawing.Point(50, 40);
            loadinglabel.Name     = "load";
            loadinglabel.AutoSize = true;
            loadinglabel.Text     = "Checking...";
            loadinglabel.Size     = new System.Drawing.Size(100, 20);

            loading.Controls.Add(loadinglabel);
            loading.Show();

            System.Threading.Thread t12 = new System.Threading.Thread(delegate() { try { MainV2.updatecheck(loadinglabel); } catch (Exception ex) { Console.WriteLine(ex.ToString()); } }); // wait for tcp connections
            t12.Name = "Update check thread";
            t12.Start();
            MainV2.threads.Add(t12);
        }
示例#14
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;
        }
示例#15
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);
                }
            }
        }