示例#1
0
        /// <summary>
        /// Gets the file collection as a dictionary of file containers
        /// </summary>
        /// <param name="postedData">The HTTP posted data</param>
        /// <returns>The file container dictionary</returns>
        public static Dictionary <string, FileContainer> AsFileContainerDictionary
        (
            this HttpPostedData postedData
        )
        {
            Validate.IsNotNull(postedData);

            var dictionary = new Dictionary <string, FileContainer>();

            foreach (var item in postedData.Files)
            {
                var file = item.Value;

                if (file.FileContents.Length > 0)
                {
                    var container = new FileContainer
                                    (
                        file.FileContents,
                        file.ContentType,
                        file.Filename
                                    );

                    dictionary.Add
                    (
                        item.Key,
                        container
                    );
                }
            }

            return(dictionary);
        }
        private JsonResult GetResult(FileContainer fileContainer)
        {
            switch (fileContainer.TypeContainer)
            {
            case TypeContainer.Video:
                return(Json(new
                {
                    ipfsAddSourceVideo = IpfsResultJson(fileContainer.SourceFileItem),
                    sprite = fileContainer.SpriteVideoFileItem == null ? null : (new
                    {
                        spriteCreation = SpriteResultJson(fileContainer.SpriteVideoFileItem),
                        ipfsAddSprite = IpfsResultJson(fileContainer.SpriteVideoFileItem)
                    }),
                    encodedVideos = fileContainer.EncodedFileItems
                                    .Select(e =>
                                            new
                    {
                        encode = EncodeResultJson(e),
                        ipfsAddEncodeVideo = IpfsResultJson(e)
                    })
                                    .ToArray()
                }));

            case TypeContainer.Overlay:
                return(Json(new
                {
                    ipfsAddSource = IpfsResultJson(fileContainer.SourceFileItem),
                    ipfsAddOverlay = IpfsResultJson(fileContainer.OverlayFileItem)
                }));
            }

            Debug.WriteLine("Type container non géré " + fileContainer.TypeContainer);
            throw new InvalidOperationException("type container non géré");
        }
示例#3
0
        private IFileContainer ProcessFileInfo(string name, FileInfo fileInfo, DataReader reader)
        {
            var fileContainer = new FileContainer {
                Name = name, FileType = fileInfo.FileType
            };

            if (fileInfo.SingleFile)
            {
                fileContainer.Files.Add(1, DecodeFile(reader, fileInfo.FileType, 1));
            }
            else
            {
                reader.Position = 6;                       // here the file sizes follow (dword each)
                int offset = 6 + (fileInfo.NumFiles << 2); // 4 bytes per size entry

                for (int i = 1; i <= fileInfo.NumFiles; ++i)
                {
                    int size = (int)reader.ReadDword();

                    if (size > 0)
                    {
                        fileContainer.Files.Add(i, DecodeFile(new DataReader(reader, offset, size), fileInfo.FileType, i));
                        offset += size;
                    }
                }
            }

            return(fileContainer);
        }
示例#4
0
        //test meth
        //private void uploadResultonDisc(JobDocument[] jds)
        //{
        //    foreach (JobDocument jd in jds)
        //    {
        //        OutputDocument od = jd.OutputDocuments[0];
        //        FileContainer file = od.Files[0];

        //        String filename= jd.CustomText + ".tiff";
        //        byte[] content = file.FileContents;
        //        Utils.saveToFileSystem(content, filename);
        //    }
        //}

        protected override List <InputFile[]> getInputFilesFromJobDocuments(JobDocument[] jds)
        {
            var vs = jds.Select(jd => jd.CustomText.Substring(0, 7)).Distinct();
            List <JobDocument[]> jdaList = new List <JobDocument[]>(vs.Count());

            foreach (var v in vs)
            {
                IEnumerable <JobDocument> x = jds.Where(j => j.CustomText.StartsWith(v));
                jdaList.Add(x.ToArray());
            }

            List <InputFile[]> list = new List <InputFile[]>(jdaList.Count());

            foreach (JobDocument[] jda in jdaList)
            {
                List <InputFile> inputFiles = new List <InputFile>();
                foreach (JobDocument jd in jda)
                {
                    OutputDocument od        = jd.OutputDocuments[0];
                    FileContainer  file      = od.Files[0];
                    InputFile      inputFile = new InputFile();
                    inputFile.OutputDocuments = jd.OutputDocuments;
                    inputFile.Id       = jd.CustomText;
                    inputFile.FileData = file;
                    inputFiles.Add(inputFile);
                }
                list.Add(inputFiles.ToArray());
            }
            return(list);
        }
示例#5
0
        public static async Task <Guid> ComputeSubtitle(string text)
        {
            FileContainer fileContainer = FileContainer.NewSubtitleContainer();

            if (!IsValidVTT(text))
            {
                fileContainer.SubtitleFileItem.IpfsProcess.SetErrorMessage("Not a valid WEBVTT file", "Not a valid WEBVTT file");
                return(fileContainer.ProgressToken);
            }

            try
            {
                await File.WriteAllTextAsync(fileContainer.SubtitleFileItem.TempFilePath, text);

                fileContainer.SubtitleFileItem.ReplaceOutputPathWithTempPath();
                IpfsDaemon.Instance.Queue(fileContainer.SubtitleFileItem);
            }
            catch (Exception ex)
            {
                LogManager.AddSubtitleMessage(LogLevel.Critical, "Exception non gérée", "Exception", ex);
                fileContainer.CancelAll("Exception non gérée");
                fileContainer.CleanFilesIfEnd();
                return(fileContainer.ProgressToken);
            }

            return(fileContainer.ProgressToken);
        }
示例#6
0
        private void AddFileToContainer(string fileName)
        {
            FileContainer fc         = new FileContainer();
            string        fileNoPath = System.IO.Path.GetFileName(fileName);

            // Check if file with this name exists in container
            FileContainer result = null;

            result = (from fn in _fileContainerCollection
                      where fn.file_name == fileNoPath
                      select fn).FirstOrDefault();

            if (result == null || result.Visible == Visibility.Collapsed)
            {
                fc.File           = new PropertyMgmt.Model.File();
                fc.File.file_data = System.IO.File.ReadAllBytes(fileName);

                fc.file_size     = fc.File.file_data.Length;
                fc.date_modified = System.IO.File.GetLastWriteTime(fileName);
                fc.file_name     = fileNoPath;

                _fileContainerCollection.Add(fc);
                ViewModel.AddAuditEntry(ViewModel.WorkingContainer, "Added file '" + fc.file_name + "'");

                UpdateGrid();
            }
            else
            {
                MessageBox.Show("The file " + fileNoPath + " is already in the list. Please rename the file before adding", "Error - Unable to add item", MessageBoxButton.OK, MessageBoxImage.Error);
            }
        }
示例#7
0
        public static async Task <Guid> ComputeSubtitle(string text)
        {
            FileContainer fileContainer  = FileContainer.NewSubtitleContainer();
            string        outputfilePath = Path.ChangeExtension(TempFileManager.GetNewTempFilePath(), ".vtt");

            if (!IsValidVTT(text))
            {
                fileContainer.SubtitleFileItem.IpfsProcess.SetErrorMessage("Not a valid WEBVTT file", "Not a valid WEBVTT file");
                return(fileContainer.ProgressToken);
            }

            try
            {
                await File.WriteAllTextAsync(outputfilePath, text);

                fileContainer.SubtitleFileItem.SetOutputFilePath(outputfilePath);
                IpfsDaemon.Instance.Queue(fileContainer.SubtitleFileItem);
            }
            catch (Exception ex)
            {
                TempFileManager.SafeDeleteTempFile(outputfilePath);
                LogManager.AddSubtitleMessage(LogLevel.Critical, "Exception non gérée", "Exception", ex);
                return(fileContainer.ProgressToken);
            }

            return(fileContainer.ProgressToken);
        }
示例#8
0
        /// <summary>
        /// Streams a file container to the response as a HTTP response message
        /// </summary>
        /// <param name="controller">The controller reference</param>
        /// <param name="fileContainer">The file container</param>
        /// <param name="dispositionType">The content disposition type (optional)</param>
        /// <returns>An action result with the streamed file data</returns>
        public static HttpResponseMessage StreamFile
        (
            this ApiController controller,
            FileContainer fileContainer,
            string dispositionType = "inline"
        )
        {
            if (fileContainer == null)
            {
                throw new ArgumentNullException
                      (
                          "fileContainer"
                      );
            }
            else
            {
                var fileContents = fileContainer.FileContents;
                var contentType  = fileContainer.ContentType;
                var fileName     = fileContainer.FileName;

                return(StreamFile
                       (
                           controller,
                           fileContents,
                           contentType,
                           fileName,
                           dispositionType
                       ));
            }
        }
示例#9
0
        protected override void OnStartup(StartupEventArgs e)
        {
            //var culture = new System.Globalization.CultureInfo("es-ES");
            //System.Globalization.CultureInfo.CurrentCulture = culture;
            //System.Globalization.CultureInfo.CurrentUICulture = culture;

            // Initialize the console view model first thing so we can see any problems that may occur
            var consoleViewModel = ConsoleViewModel.Instance;

            Log.WriteLine($"Started {Assembly.GetExecutingAssembly().GetName().Version}");
            //Log.WriteLine($"Culture: {System.Globalization.CultureInfo.CurrentCulture.Name}");

            SetPerMonitorDpiAwareness();

            ConfigHelper.EnsureConfigs();
            ConfigHelper.Main.Loaded += Config_Loaded;

            m_SkinFile          = new FileContainer(ConfigHelper.Main.Values.SkinFileName);
            m_SkinFile.Changed += (s1, e1) => { LoadSkin(); };
            LoadSkin();

            m_Overlay = new MhwOverlay(new ConsoleWindow(), new TeamWidgetWindow(), new MonsterWidgetWindow(), new PlayerWidgetWindow());

            ConfigHelper.Main.Loaded += StatLog.StatLogger.OnConfigChanged;
            if (ConfigHelper.Main.Values.StatLogging.LogStats)
            {
                StatLog.StatLogger.InitLogger();
            }

            base.OnStartup(e);
        }
示例#10
0
        private FileContainer GetResponseStream(Uri baseAddress)
        {
            using (var handler = new HttpClientHandler {
                CookieContainer = SetupCookie(baseAddress)
            })
                using (var client = new HttpClient(handler)
                {
                    BaseAddress = baseAddress
                })
                {
                    var response = client.GetAsync(baseAddress);

                    try
                    {
                        response.Result.EnsureSuccessStatusCode();

                        var file = new FileContainer
                        {
                            ContentType = response.Result.Content.Headers.ContentType.ToString(),
                            Size        = response.Result.Content.Headers.ContentLength,
                            Data        = response.Result.Content.ReadAsByteArrayAsync().Result
                        };
                        return(file);
                    }
                    catch (HttpRequestException)
                    {
                        if (response.Result.StatusCode == HttpStatusCode.NotFound)
                        {
                            return(new FileContainer());
                        }
                        throw;
                    }
                }
        }
示例#11
0
        public void WillCreateIfMissing()
        {
            string test_file_name = ".\\FileContainerTests_15.txt";

            if (File.Exists(test_file_name))
            {
                File.Delete(test_file_name);
            }

            var file_container = new FileContainer(test_file_name, true);

            var result = file_container.ReadAllLines();

            Assert.That(result.Count, Is.EqualTo(0));

            file_container.WriteAllLines(new List <string>()
            {
                "Hello", "World"
            });

            Assert.That(File.Exists(test_file_name));

            if (File.Exists(test_file_name))
            {
                File.Delete(test_file_name);
            }
        }
示例#12
0
        public static async Task <Guid> ComputeSubtitle(string text)
        {
            FileContainer fileContainer  = FileContainer.NewSubtitleContainer();
            string        outputfilePath = Path.ChangeExtension(TempFileManager.GetNewTempFilePath(), ".vtt");

            if (!IsValidVTT(text))
            {
                return(fileContainer.ProgressToken);
            }

            try
            {
                await System.IO.File.WriteAllTextAsync(outputfilePath, text);

                fileContainer.SubtitleFileItem.SetOutputFilePath(outputfilePath);
                IpfsDaemon.Instance.Queue(fileContainer.SubtitleFileItem);
            }
            catch (Exception ex)
            {
                TempFileManager.SafeDeleteTempFile(outputfilePath);
                LogManager.AddSubtitleMessage(ex.ToString(), "Exception");
                return(fileContainer.ProgressToken);
            }

            return(fileContainer.ProgressToken);
        }
示例#13
0
        public void CanWriteAllLines()
        {
            string test_file_name = ".\\FileContainerTests_12.txt";

            if (File.Exists(test_file_name))
            {
                File.Delete(test_file_name);
            }

            File.WriteAllLines(test_file_name, new List <string>()
            {
                "Old", "Stuff"
            });

            var file_container = new FileContainer(test_file_name);

            file_container.WriteAllLines(new List <string>()
            {
                "Hello", "World"
            });

            var result = File.ReadAllLines(test_file_name);

            Assert.That(result.Count, Is.EqualTo(2));
            Assert.That(result[0], Is.EqualTo("Hello"));
            Assert.That(result[1], Is.EqualTo("World"));

            if (File.Exists(test_file_name))
            {
                File.Delete(test_file_name);
            }
        }
        private TreeListNode AddFileNode(TreeListNode treenode, OutputFile fileTheirs, OutputFile fileMine)
        {
            TreeListNode fileNode         = null;
            bool         differenceExists = false;

            if (fileTheirs != null && fileMine != null)
            {
                FileContainer fileContainer = new FileContainer(fileMine, fileTheirs, fileTheirs.Name);
                fileNode = AddNodeBoth(Images.IMG_FILE, "", fileTheirs.Name, fileMine.Name, treenode, fileContainer, false);

                if (fileTheirs.FileType != fileMine.FileType)
                {
                    differenceExists = true;
                    AddNodeBoth(Images.IMG_DOT, "File Type", fileTheirs.FileType, fileMine.FileType, fileNode, null, true);
                }
                if (fileTheirs.Name != fileMine.Name)
                {
                    differenceExists = true;
                    AddNodeBoth(Images.IMG_DOT, "Name", fileTheirs.Name, fileMine.Name, fileNode, null, true);
                }
                if (fileTheirs.ScriptName != fileMine.ScriptName)
                {
                    differenceExists = true;
                    AddNodeBoth(Images.IMG_DOT, "Script Name", fileTheirs.ScriptName, fileMine.ScriptName, fileNode, null, true);
                }
                if (fileTheirs.StaticFileIterator != fileMine.StaticFileIterator)
                {
                    differenceExists = true;
                    AddNodeBoth(Images.IMG_DOT, "Static File Iterator", fileTheirs.StaticFileIterator, fileMine.StaticFileIterator, fileNode, null, true);
                }
                if (fileTheirs.StaticFileName != fileMine.StaticFileName)
                {
                    differenceExists = true;
                    AddNodeBoth(Images.IMG_DOT, "Static File Name", fileTheirs.StaticFileName, fileMine.StaticFileName, fileNode, null, true);
                }

                if (fileNode.Nodes.Count == 0 && !differenceExists)
                {
                    fileNode.ParentNode.Nodes.Remove(fileNode);
                }
                else if (!FilesAreDifferent(fileTheirs, fileMine))
                {
                    fileNode.SetValue(0, fileMine.Name);
                    fileNode.SetValue(1, "");
                    fileNode.SetValue(3, "");
                }
            }
            else if (fileTheirs != null)
            {
                FileContainer fileContainer = new FileContainer(null, fileTheirs, fileTheirs.Name);
                fileNode = AddNodeTheirs(Images.IMG_FILE, "", fileTheirs.Name, "", treenode, fileContainer, true);
            }
            else if (fileMine != null)
            {
                FileContainer fileContainer = new FileContainer(fileMine, null, fileMine.Name);
                fileNode = AddNodeMine(Images.IMG_FILE, "", "", fileMine.Name, treenode, fileContainer, true);
            }
            return(fileNode);
        }
示例#15
0
        public static Guid ComputeOverlay(string sourceFilePath)
        {
            FileContainer fileContainer = FileContainer.NewOverlayContainer(sourceFilePath);

            var processStartInfo = new ProcessStartInfo();

            processStartInfo.WorkingDirectory = TempFileManager.GetTempDirectory();
            processStartInfo.UseShellExecute  = false;
            processStartInfo.ErrorDialog      = false;
            processStartInfo.CreateNoWindow   = true;
            processStartInfo.WindowStyle      = ProcessWindowStyle.Hidden;

            string oldFilePath    = fileContainer.SourceFileItem.FilePath;
            string outputFilePath = null;

            try
            {
                LogManager.AddOverlayMessage("SourceFileName " + Path.GetFileName(oldFilePath), "Start Crop");
                // resize + crop source image
                outputFilePath             = Path.ChangeExtension(TempFileManager.GetNewTempFilePath(), ".png");
                processStartInfo.FileName  = Path.Combine(FrontSettings.ImageMagickPath, "convert");
                processStartInfo.Arguments = $"{Path.GetFileName(fileContainer.SourceFileItem.FilePath)} -resize \"{_finalWidth}x{_finalHeight}^\" -gravity Center -crop {_finalWidth}x{_finalHeight}+0+0 {Path.GetFileName(outputFilePath)}";
                StartProcess(processStartInfo, 5000);
                fileContainer.SourceFileItem.FilePath = outputFilePath;
                LogManager.AddOverlayMessage("OutputFileName " + Path.GetFileName(outputFilePath), "End Crop");
                IpfsDaemon.Queue(fileContainer.SourceFileItem);
            }
            catch (Exception ex)
            {
                TempFileManager.SafeDeleteTempFile(outputFilePath);
                LogManager.AddOverlayMessage(ex.ToString(), "Exception");
                return(fileContainer.ProgressToken);
            }
            finally
            {
                TempFileManager.SafeDeleteTempFile(oldFilePath);
            }

            try
            {
                LogManager.AddOverlayMessage("SourceFileName " + Path.GetFileName(fileContainer.SourceFileItem.FilePath), "Start Overlay");
                // watermark source image
                outputFilePath             = Path.ChangeExtension(TempFileManager.GetNewTempFilePath(), ".png");
                processStartInfo.FileName  = Path.Combine(FrontSettings.ImageMagickPath, "composite");
                processStartInfo.Arguments = $"-gravity NorthEast {_overlayImagePath} {Path.GetFileName(fileContainer.SourceFileItem.FilePath)} {Path.GetFileName(outputFilePath)}";
                StartProcess(processStartInfo, 5000);
                fileContainer.OverlayFileItem.FilePath = outputFilePath;
                LogManager.AddOverlayMessage("OutputFileName " + Path.GetFileName(outputFilePath), "End Overlay");
                IpfsDaemon.Queue(fileContainer.OverlayFileItem);
            }
            catch (Exception ex)
            {
                TempFileManager.SafeDeleteTempFile(outputFilePath);
                LogManager.AddOverlayMessage(ex.ToString(), "Exception");
                return(fileContainer.ProgressToken);
            }

            return(fileContainer.ProgressToken);
        }
示例#16
0
 private DocumentController SetupControllerWithServiceReturningFileResponse(FileContainer file)
 {
     fakeAsbestosService = new Mock <IAsbestosService>();
     fakeAsbestosService.Setup(m => m.GetFile(It.IsAny <string>(), It.IsAny <string>()))
     .Returns(Task.FromResult(file));
     return(new DocumentController(fakeAsbestosService.Object,
                                   fakeControllerLogger.Object,
                                   fakeActionsLogger.Object));
 }
示例#17
0
        private void KeyboardNavigationUp(FileContainer fc)
        {
            fc.IsSelected = false;
            FileContainer fcPrev = null;

            if (fc.Index == 0)
            {
                if (fc.Parent != null)
                {
                    fcPrev = fc.Parent;
                }
                else
                {
                    fcPrev = fc;
                }
            }
            else
            {
                if (fc.Parent != null)
                {
                    fcPrev = FileSearchUpVisible(fc.Parent.SubFiles, fc.Index - 1);
                }
                else
                {
                    fcPrev = FileSearchUpVisible(fileContainerCollection, fc.Index - 1);
                }
                if (fcPrev != null)
                {
                    if (fcPrev.IsExpanded)
                    {
                        FileContainer fcLastChild = fcPrev;
                        do
                        {
                            fcLastChild = FileSearchDownVisible(fcLastChild.SubFiles, fcLastChild.SubFiles.Count - 1);
                        }while (fcLastChild != null && (fcLastChild.FullPath == "dummy" || (fcLastChild.IsExpanded && fcLastChild.SubFiles.Count > 0)));

                        //FileContainer fcPrevLastChild = FileSearchUpVisible(fcPrev.SubFiles, fcPrev.SubFiles.Count - 1);
                        if (fcLastChild != null)
                        {
                            fcLastChild.IsSelected = true;
                            return;
                        }
                    }
                }
                else
                {
                    if (fc.Parent != null)
                    {
                        fcPrev = fc.Parent;
                    }
                }
            }
            if (fcPrev != null)
            {
                fcPrev.IsSelected = true;
            }
        }
示例#18
0
        public void NopbaiThi()
        {
            if (string.IsNullOrWhiteSpace(this.noiluu))
            {
                return;
            }

            if (!Directory.Exists(this.noiluu))
            {
                Message("Chưa có nơi lưu bài thi ");
                return;
            }

            List <string> sucessfile = new List <string>()
            {
                ".zip",
                ".7z",
                ".rar"
            };

            DirectoryInfo direc = new DirectoryInfo(this.noiluu);

            FileInfo[] files  = direc.GetFiles("*.*");
            string     baithi = null;

            foreach (FileInfo item in files)
            {
                string filenames  = item.Name;
                string phanmorong = Path.GetExtension(filenames);
                if (sucessfile.Contains(phanmorong))
                {
                    baithi = item.FullName;
                    break;
                }
            }

            if (string.IsNullOrWhiteSpace(baithi))
            {
                MessageBox.Show("Không tìm thấy file rar");
                return;
            }
            FileContainer  noiluubai = new FileContainer(baithi, null);
            ServerResponse repor     = new ServerResponse(ServerResponseType.FinishExam, noiluubai);

            try
            {
                if (repor == null)
                {
                    MessageBox.Show("Data Available!!!");//dữ liệu rỗng
                }
                socket.Send(repor.Serialize());
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
        }
示例#19
0
 public ContainerTreeNode(FileContainerHttpClient service, FileContainer container)
     : base(service, container.Name, "Resources/Container.ico", true)
 {
     this.Container        = container;
     this.Description      = container.Description;
     this.DateCreated      = container.DateCreated;
     this.DateLastModified = this.DateCreated;
     this.Size             = container.Size;
 }
示例#20
0
        public async Task return_404_for_valid_request_but_no_results()
        {
            var emptyFileResponse = new FileContainer();

            controller = SetupControllerWithServiceReturningFileResponse(emptyFileResponse);
            var response = (JsonResult) await PickDocumentControllerEndpoint(randomPick, fakeId.ToString());

            Assert.Equal((int)HttpStatusCode.NotFound, response.StatusCode);
        }
示例#21
0
        private void ProcessTrack(FileInfo file)
        {
            TagLib.File   af        = Banshee.IO.DemuxVfs.OpenFile(file.FullName);
            FileContainer container = new FileContainer();

            container.File = af;
            container.Path = file.FullName;
            files.Add(container);
        }
示例#22
0
        public Worker(XDocument xmlGame, XDocument xmlEdit, FileContainer root)
        {
            Configuration.Initialize(xmlEdit);
            this.config = Configuration.GetInstance();
            FileManager.Initialize(root, FileInfoCollection.FromXml(xmlGame));
            this.fileManager = FileManager.GetInstance();

            this.edit = xmlEdit;
            this.updateQueue = new List<string>();
        }
示例#23
0
        void LoadSkin()
        {
            if (ConfigHelper.Main.Values.Debug.UseInternalSkin)
            {
                return;
            }

            var skinFileName = ConfigHelper.Main.Values.SkinFileName;

            if (!File.Exists(FileContainer.GetFullPathFileName(skinFileName)))
            {
                Log.WriteLine($"Failed to load skin file '{skinFileName}'");
                return;
            }

            m_SkinFile.TryChangeFileName(skinFileName);

            try
            {
                ResourceDictionary resourceDictionary = null;

                using (var streamReader = new StreamReader(m_SkinFile.FullPathFileName, Encoding.UTF8))
                {
                    LoadExternalAssemblies();
                    var xmlReaderSettings = new XamlXmlReaderSettings
                    {
                        LocalAssembly = Assembly.GetExecutingAssembly()
                    };

                    using (var xamlReader = new XamlXmlReader(streamReader.BaseStream, XamlReader.GetWpfSchemaContext(), xmlReaderSettings))
                    {
                        resourceDictionary = XamlReader.Load(xamlReader) as ResourceDictionary;
                    }
                }

                if (resourceDictionary != null)
                {
                    Resources.MergedDictionaries.Clear();
                    Resources.MergedDictionaries.Add(resourceDictionary);

                    if (m_Overlay != null)
                    {
                        m_Overlay.RefreshWidgetsLayout();
                    }

                    Log.WriteLine($"{m_SkinFile.FileName} loaded");
                }
            }
            catch (Exception ex)
            {
                Log.WriteException(ex);
            }

            m_LastSkinFileName = skinFileName;
        }
示例#24
0
文件: Worker.cs 项目: pleonex/modime
        public Worker(XDocument xmlGame, XDocument xmlEdit, FileContainer root)
        {
            Configuration.Initialize(xmlEdit);
            this.config = Configuration.GetInstance();

            this.edit = xmlEdit;
            this.updateQueue = new List<string>();

            InitializeFileTypes(root, xmlGame);
            this.fileManager = FileManager.GetInstance();
        }
示例#25
0
        public static Guid ComputeVideo(string originFilePath, string videoEncodingFormats, bool?sprite)
        {
            VideoSize[] formats = new VideoSize[0];

            if (!string.IsNullOrWhiteSpace(videoEncodingFormats))
            {
                formats = videoEncodingFormats
                          .Split(',')
                          .Select(v =>
                {
                    switch (v)
                    {
                    case "360p":
                        return(VideoSize.F360p);

                    case "480p":
                        return(VideoSize.F480p);

                    case "720p":
                        return(VideoSize.F720p);

                    case "1080p":
                        return(VideoSize.F1080p);

                    default:
                        throw new InvalidOperationException("Format non reconnu.");
                    }
                })
                          .ToArray();
            }

            FileContainer fileContainer = FileContainer.NewVideoContainer(originFilePath, sprite ?? false, formats);

            if (IpfsSettings.AddVideoSource)
            {
                IpfsDaemon.Instance.Queue(fileContainer.SourceFileItem);
            }

            if (VideoSettings.GpuEncodeMode)
            {
                // encoding audio de la source puis ça sera encoding videos Gpu
                AudioCpuEncodeDaemon.Instance.Queue(fileContainer.SourceFileItem, "waiting audio encoding...");
            }
            else
            {
                // si encoding est demandé, et gpuMode -> encodingAudio
                foreach (FileItem file in fileContainer.EncodedFileItems)
                {
                    AudioVideoCpuEncodeDaemon.Instance.Queue(file, "Waiting encode...");
                }
            }

            return(fileContainer.ProgressToken);
        }
示例#26
0
 private static void SetDateTaken(FileContainer fileContainer)
 {
     if (_pictureFileTypes.Contains(fileContainer.FileSource.Extension))
     {
         fileContainer.FileSource.DateTaken = GetDateTakenFromImage(fileContainer.FileSource);
     }
     else if (_movieFileTypes.Contains(fileContainer.FileSource.Extension))
     {
         fileContainer.FileSource.DateTaken = GetDateTakenFromFileInfo(fileContainer.FileSource.GetFileInfo());
     }
 }
示例#27
0
        public ActionResult GetProgressByToken(Guid token)
        {
            FileContainer fileContainer = ProgressManager.GetFileContainerByToken(token);

            if (fileContainer == null)
            {
                return(BadRequest(new { errorMessage = "token not exist" }));
            }

            return(GetResult(fileContainer));
        }
        private void ListView_MouseDoubleClick(object sender, System.Windows.Input.MouseButtonEventArgs e)
        {
            FileContainer p   = null;
            var           itm = (sender as ListView).SelectedItem as Core.IMapRecordFull;

            if (itm != null && itm.Data != null && itm.Data.Count > 0)
            {
                p = itm.Data[0] as FileContainer;
            }
            MainVM.Instance.Selected = p;
        }
示例#29
0
        private void lbTranslatesConflicts_MouseDoubleClick(object sender, System.Windows.Input.MouseButtonEventArgs e)
        {
            FileContainer p   = null;
            var           itm = ((KeyValuePair <IMapRecordFull, SortedItems <string> >)lbTranslatesConflicts.SelectedItem).Key;

            if (itm != null && itm.Data != null && itm.Data.Count > 0)
            {
                p = itm.Data[0] as FileContainer;
            }
            MainVM.Instance.Selected = p;
        }
示例#30
0
文件: Worker.cs 项目: pleonex/modime
        public Worker(XDocument xmlGame, XDocument xmlEdit, FileContainer root)
        {
            Configuration.Initialize(xmlEdit);
            this.config = Configuration.GetInstance();

            this.edit        = xmlEdit;
            this.updateQueue = new List <string>();

            InitializeFileTypes(root, xmlGame);
            this.fileManager = FileManager.GetInstance();
        }
示例#31
0
        public static void RegisterProgress(FileContainer fileContainer)
        {
            progresses.TryAdd(fileContainer.ProgressToken, fileContainer);

            // Supprimer le suivi progress après 1j
            Task taskClean = Task.Run(() =>
            {
                Thread.Sleep(24 * 60 * 60 * 1000); // 1j
                FileContainer thisFileContainer;
                progresses.TryRemove(fileContainer.ProgressToken, out thisFileContainer);
            });
        }
示例#32
0
 private void FireMouseDoubleClick(object sender, MouseButtonEventArgs args)
 {
     if (sender is TreeViewItem)
     {
         FileContainer fc = (sender as TreeViewItem).DataContext as FileContainer;
         if (fc != null && (fc.FileType & FileType.IsFileMask) == FileType.IsFileMask)
         {
             args.Handled = true;
             TviMouseDoubleClickEvent?.Invoke(sender, args);
         }
     }
 }
示例#33
0
 // Отправить исходный текст
 private void sendSource()
 {
     bool isFileSelected = _sourceFilePathEdit.Enabled && _sourceFilePathEdit.TextLength > 0;
     FileContainer source = new FileContainer();
     // Прочтем файл, либо возьмем содержимое edit-бокса
     source.Extension = isFileSelected ? Path.GetExtension(_sourceFilePathEdit.Text) : ".txt";
     if (isFileSelected)
         source.Contents = File.ReadAllBytes(_sourceFilePathEdit.Text);
     else
     {
         List<byte> bytes = new List<byte>(System.Text.Encoding.Unicode.GetPreamble());
         bytes.AddRange(System.Text.Encoding.Unicode.GetBytes(_sourceTextEdit.Text));
         source.Contents = bytes.ToArray();
     }
     ComprenoErrorInfo errorInfo = _client.SetTaskSource(_currentTaskId, source);
     if (errorInfo.Code != ComprenoErrorCode.Success)
         throw new ApplicationException("Error in SetTastSource method: " + errorInfo.Message);
 }
示例#34
0
 public GameFolder(string name, FileContainer parent)
     : base(name)
 {
     parent.AddFolder(this);
 }
示例#35
0
 public static void Initialize(FileContainer rootDir, FileInfoCollection infoCollection)
 {
     Instance = new FileManager(rootDir, infoCollection);
 }
示例#36
0
 private FileManager(FileContainer root, FileInfoCollection infoCollection)
 {
     this.Root = root;
     this.InfoCollection = infoCollection;
     InitializeAddins();
 }
示例#37
0
文件: Worker.cs 项目: pleonex/modime
        private void InitializeFileTypes(FileContainer root, XDocument xmlGame)
        {
            FileInfoCollection fileInfo = FileInfoCollection.FromXml(xmlGame);

            // Add the parameters to each file format.
            // They can be used to add specific properties of the project to the formats parsers.
            // E.g.: to pass the key of the GoogleSpreadsheets to parse.
            foreach (XElement fileEdit in edit.Root.Element("Files").Elements("File")) {
                // In order to set parameters the type must be defined in the XML. Otherwise it will defined in run-time
                string filePath = fileEdit.Element("Path").Value;
                if (!fileInfo.Contains(filePath))
                    continue;

                FileInfo info = fileInfo[filePath];
                if (info.Parameters == null)
                    info.Parameters = fileEdit.Element("Parameters");
                else
                    info.Parameters.Add(fileEdit.Element("Parameters")?.Elements());
            }

            FileManager.Initialize(root, fileInfo);
        }
示例#38
0
 public Worker(string xmlGame, string xmlEdit, FileContainer root)
     : this(XDocument.Load(xmlGame), XDocument.Load(xmlEdit), root)
 {
 }