示例#1
0
        public IEnumerable <IFileDataSource> HandleNewSaveGames(ISourcePortDataSource sourcePort, IGameFileDataSource gameFile, string[] files)
        {
            List <IFileDataSource> list = new List <IFileDataSource>();

            if ((gameFile != null) && gameFile.GameFileID.HasValue)
            {
                foreach (string str in files)
                {
                    try
                    {
                        FileInfo info = new FileInfo(str);
                        string   str2 = Guid.NewGuid().ToString() + info.Extension;
                        info.CopyTo(Path.Combine(this.SaveGameDirectory.GetFullPath(), str2));
                        FileDataSource ds = new FileDataSource {
                            Description      = info.Name,
                            OriginalFileName = info.Name,
                            FileName         = str2,
                            GameFileID       = gameFile.GameFileID.Value,
                            SourcePortID     = sourcePort.SourcePortID,
                            FileTypeID       = 3
                        };
                        this.DataSourceAdapter.InsertFile(ds);
                        list.Add(ds);
                    }
                    catch
                    {
                    }
                }
            }
            return(list);
        }
示例#2
0
        public bool New()
        {
            OpenFileDialog dialog = new OpenFileDialog();

            if (dialog.ShowDialog(this) != DialogResult.OK)
            {
                return(false);
            }
            FileDetailsEditForm detailsForm = new FileDetailsEditForm();

            detailsForm.Initialize(this.DataSourceAdapter);
            detailsForm.StartPosition = FormStartPosition.CenterParent;
            if ((detailsForm.ShowDialog(this) == DialogResult.OK) && (detailsForm.SourcePort != null))
            {
                this.GameFile = this.DataSourceAdapter.GetGameFile(this.GameFile.FileName);
                string[] fileNames = dialog.FileNames;
                for (int i = 0; i < fileNames.Length; i++)
                {
                    FileInfo       fi = new FileInfo(fileNames[i]);
                    FileDataSource ds = this.CreateNewFileDataSource(detailsForm, fi);
                    fi.CopyTo(Path.Combine(this.DataDirectory.GetFullPath(), ds.FileName));
                    this.DataSourceAdapter.InsertFile(ds);
                }
            }
            else if (detailsForm.SourcePort == null)
            {
                this.ShowSourcePortError();
            }
            return(true);
        }
示例#3
0
        public IEnumerable <IFileDataSource> HandleNewDemo(ISourcePortDataSource sourcePort, IGameFileDataSource gameFile, string demoFile, string descriptionText)
        {
            FileInfo info = new FileInfo(demoFile);

            if (gameFile.GameFileID.HasValue && info.Exists)
            {
                info.CopyTo(Path.Combine(this.DemoDirectory.GetFullPath(), info.Name));
                FileDataSource ds = new FileDataSource {
                    FileName     = info.Name,
                    GameFileID   = gameFile.GameFileID.Value,
                    SourcePortID = sourcePort.SourcePortID,
                    FileTypeID   = 2,
                    Description  = descriptionText
                };
                this.DataAdapter.InsertFile(ds);
            }
            return(new List <IFileDataSource>());
        }