コード例 #1
0
        public void loadData()
        {
            settingsVal = readSettings();

            if (!File.Exists(FILENAME))
            {
                if (!createXmlFile())
                {
                    MessageBox.Show("Error creating XML file.", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                }
                else
                {
                    var result = MessageBox.Show("Seems this is your first time :), please add device first.", "No devices listed", MessageBoxButtons.YesNo, MessageBoxIcon.Warning);
                    switch (result)
                    {
                    case DialogResult.Yes:
                        var frmAdd = new frmAddDevices(null, null);
                        frmAdd.Show();
                        frmAdd.TopMost = true;
                        break;

                    case DialogResult.No:
                        break;

                    default:
                        MessageBox.Show("What did you press?", "Error", MessageBoxButtons.YesNo, MessageBoxIcon.Error);
                        break;
                    }
                }
            }
            else
            {
                readXmlFile();
                var bindingList = new BindingList <Drone>(droneList);
                var source      = new BindingSource(bindingList, null);
                cmbConnect.DataSource    = source;
                cmbConnect.DisplayMember = "profileName";
            }
        }
コード例 #2
0
        public frmSettings(AppSettingsVal settingsValParam)
        {
            InitializeComponent();
            settingsVal = settingsValParam;

            aspectRatio.Add("4:3");
            aspectRatio.Add("16:9");
            aspectRatio.Add("16:10");

            var aviFormat = new VideoFormat();
            var mkvFormat = new VideoFormat();
            var mp4Format = new VideoFormat();
            var tsForamt  = new VideoFormat();

            aviFormat.formatIdentifier = "AVI";
            aviFormat.fileExt          = ".avi";
            mkvFormat.formatIdentifier = "MKV";
            mkvFormat.fileExt          = ".mkv";
            tsForamt.formatIdentifier  = "TS";
            tsForamt.fileExt           = ".ts";

            videoFormats.Add(aviFormat);
            videoFormats.Add(mkvFormat);
            videoFormats.Add(tsForamt);

            toggleSaveVideo.VisualStyle = ToggleButtonStyle.Office2016Colorful;
            cmbAspectRatio.DataSource   = aspectRatio;

            var bindingList = new BindingList <VideoFormat>(videoFormats);
            var source      = new BindingSource(bindingList, null);

            cmbVIdeoFormat.DataSource    = source;
            cmbVIdeoFormat.DisplayMember = "formatIdentifier";

            mapsMode.Add("Offline");
            mapsMode.Add("Online");
            mapsMode.Add("Dowload");
            cmbMapMode.DataSource = mapsMode;
        }
コード例 #3
0
        public AppSettingsVal readSettings()
        {
            var buff = new AppSettingsVal();

            try
            {
                var settingsFile  = ConfigurationManager.AppSettings;
                var buffSaveState = settingsFile["save-video-state"];
                buff.aspectRatio   = settingsFile["aspect-ratio"];
                buff.cacheLocation = settingsFile["cache-location"];
                buff.videoFormat   = settingsFile["video-format"];
                buff.savePath      = settingsFile["save-path"];
                buff.mapsMode      = settingsFile["maps-mode"];
                buff.mapLocation   = settingsFile["maps-location"];
                if (buffSaveState == "true")
                {
                    buff.saveVideoState = true;
                }
                else
                {
                    buff.saveVideoState = false;
                }
            }
            catch (ConfigurationErrorsException)
            {
                var result = MessageBox.Show("Error reading application settings", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                switch (result)
                {
                case DialogResult.OK:
                    Application.ExitThread();
                    Process.GetCurrentProcess().Kill();
                    break;
                }
            }
            return(buff);
        }