コード例 #1
0
        public static Engine.Data.Setting GetNewSetting(UserController device, Engine.Data.Game game, MapTo mapTo)
        {
            // Create new setting for game/device.
            var newSetting = new Engine.Data.Setting();

            newSetting.InstanceGuid    = device.InstanceGuid;
            newSetting.InstanceName    = device.InstanceName;
            newSetting.ProductGuid     = device.ProductGuid;
            newSetting.ProductName     = device.ProductName;
            newSetting.DeviceType      = (int)device.CapType;
            newSetting.FileName        = game.FileName;
            newSetting.FileProductName = game.FileProductName;
            newSetting.DateCreated     = DateTime.Now;
            newSetting.IsEnabled       = true;
            newSetting.MapTo           = (int)mapTo;
            return(newSetting);
        }
コード例 #2
0
ファイル: GamesControl.cs プロジェクト: jeppeter/x360ce
        void ScanFunction()
        {
            string[] paths = null;
            Invoke((MethodInvoker)delegate()
            {
            ScanButton.Enabled = false;
            paths = MainForm.Current.OptionsPanel.GameScanLocationsListBox.Items.Cast<string>().ToArray();
            ScanProgressLabel.Text = "Scanning...";
            });
            var skipped = 0;
            var added = 0;
            var updated = 0;
            for (int i = 0; i < paths.Length; i++)
            {
                var path = (string)paths[i];
                // Don't allow to scan windows folder.
                var winFolder = System.Environment.GetFolderPath(Environment.SpecialFolder.Windows);
                if (path.StartsWith(winFolder)) continue;
                var di = new System.IO.DirectoryInfo(path);
                // Skip folders if don't exists.
                if (!di.Exists) continue;
                var exes = di.GetFiles("*.exe", System.IO.SearchOption.AllDirectories);
                for (int f = 0; f < exes.Length; f++)
                {

                    var exe = exes[f];
                    var program = SettingsFile.Current.Programs.FirstOrDefault(x => x.FileName == exe.Name);
                    // If file doesn't exist in the game list then continue.
                    if (program == null)
                    {
                        skipped++;
                    }
                    else
                    {
                        var game = SettingsFile.Current.Games.FirstOrDefault(x => x.FileName == exe.Name);
                        // If file doesn't exist in the game list then continue.
                        if (game == null)
                        {
                            game = new Engine.Data.Game();
                            game.LoadDefault(program);
                            SettingsFile.Current.Games.Add(game);
                            added++;
                        }
                        else
                        {
                            game.FullPath = exe.FullName;
                            updated++;
                        }
                    }
                    Invoke((MethodInvoker)delegate()
                        {
                            ScanProgressLabel.Text = string.Format("Scanning Path ({0}/{1}): {2}\r\nSkipped = {3}, Added = {4}, Updated = {5}", i + 1, paths.Length, path, skipped, added, updated);
                        });
                }
                SettingsFile.Current.Save();
            }
            Invoke((MethodInvoker)delegate()
            {
                //ScanProgressLabel.Text = "Scan Completed";
                ScanButton.Enabled = true;
            });
        }