Exemplo n.º 1
0
        //private bool createPdfFilesToFirtsSheetDirectory;
        //public bool CreatePdfFilesToFirtsSheetDirectory
        //{
        //    get { return createPdfFilesToFirtsSheetDirectory; }
        //    set { SetProperty(ref createPdfFilesToFirtsSheetDirectory, value); }
        //}

        //private string directoryPathForPdfs;
        //public string DirectoryPathForPdfs
        //{
        //    get { return directoryPathForPdfs; }
        //    set { SetProperty(ref directoryPathForPdfs, value); }
        //}

        //private bool createCombinationFile;
        //public bool CreateCombinationFile
        //{
        //    get { return createCombinationFile; }
        //    set { SetProperty(ref createCombinationFile, value); }
        //}

        //private string combinationFilePath;
        //public string CombinationFilePath
        //{
        //    get { return combinationFilePath; }
        //    set { SetProperty(ref combinationFilePath, value); }
        //}

        //private string sheetSeparator;
        //public string SheetSeparator
        //{
        //    get { return sheetSeparator; }
        //    set { SetProperty(ref sheetSeparator, value); }
        //}

        //private bool opendAfterMerging;
        //public bool OpendAfterMerging
        //{
        //    get { return opendAfterMerging; }
        //    set { SetProperty(ref opendAfterMerging, value); }
        //}
        #endregion

        #region methods
        //private void ReadSettings()
        //{
        //    CreatePdfFilesToFirtsSheetDirectory = Properties.Settings.Default.SaveToSameDirectoryAsFirstSheet;
        //    DirectoryPathForPdfs = Properties.Settings.Default.SaveDirectoryPath;
        //    CreateCombinationFile = Properties.Settings.Default.CreateCombinationFile;
        //    CombinationFilePath = Properties.Settings.Default.CombinationFilePath;
        //    SheetSeparator = Properties.Settings.Default.SheetSeparator;
        //    OpendAfterMerging = Properties.Settings.Default.OpenAfterMerge;
        //}

        //public void SaveSettings()
        //{
        //    Properties.Settings.Default.SaveToSameDirectoryAsFirstSheet = CreatePdfFilesToFirtsSheetDirectory;
        //    Properties.Settings.Default.SaveDirectoryPath = DirectoryPathForPdfs;
        //    Properties.Settings.Default.CreateCombinationFile = CreateCombinationFile;
        //    Properties.Settings.Default.CombinationFilePath = CombinationFilePath;
        //    Properties.Settings.Default.SheetSeparator = SheetSeparator;
        //    Properties.Settings.Default.OpenAfterMerge = OpendAfterMerging;
        //    Properties.Settings.Default.Save();
        //}

        public void AddSheet(string filepath)
        {
            if (!filepath.EndsWith(".pdf"))
            {
                string msg = $"File '{filepath}' discarded (not pdf).";
                logger.Log(LogFactory.CreateWarningMessage(msg));
                return;
            }

            foreach (Sheet item in Sheets.GetAllTargetItems())
            {
                if (item.FullPath.Equals(filepath))
                {
                    string msg = $"File '{filepath}' was already in the list.";
                    logger.Log(LogFactory.CreateWarningMessage(msg));
                    return;
                }
            }

            if (!CheckSheetSeparator())
            {
                return;
            }

            string fileName = System.IO.Path.GetFileName(filepath);

            if (!fileName.Contains(Settings.SheetSeparator))
            {
                string msg = $"File name '{fileName}' does not contain sheet separator '{Settings.SheetSeparator}', file discarded.";
                logger.Log(LogFactory.CreateWarningMessage(msg));
                return;
            }

            Sheet sheet = new Sheet(filepath, Settings.SheetSeparator);

            Sheets.AddItem(sheet);
        }