示例#1
0
        private void fileSelectListBox_DrawItem(object sender, DrawItemEventArgs e)
        {
            if (this.fileSelectListBox.Items.Count != DiscContents.getInstance().MaskedFileInfoList.Count)
            {
                return;
            }

            e.DrawBackground();
            if (ViewModel.getInstance().ExpectedThesisFile != null &&
                ViewModel.getInstance().ExpectedThesisFile.Equals(((MaskedFileInfo)this.fileSelectListBox.Items[e.Index])) &&
                !ViewModel.getInstance().ExpectedThesisFile.Equals(((MaskedFileInfo)this.fileSelectListBox.SelectedItem))
                )
            {
                e.Graphics.FillRectangle(new SolidBrush(Color.Gold), e.Bounds);
            }
            else
            {
                e.DrawFocusRectangle();
            }

            Brush textBrush = Brushes.Black;

            if (!this.fileSelectListBox.Enabled)
            {
                textBrush = Brushes.Silver;
            }
            e.Graphics.DrawString(((MaskedFileInfo)this.fileSelectListBox.Items[e.Index]).MaskedFileName, e.Font, textBrush, e.Bounds, StringFormat.GenericDefault);
        }
        public static void CopyContentToStaging()
        {
            CleanUpStaging();
            long   totalFileSize   = DiscContents.getInstance().TotalFileSize;
            long   copiedFileSize  = 0;
            string sourceDirectory = ReaderConfig.getInstance().ContentPath;

            if (!sourceDirectory.EndsWith(@"\"))
            {
                sourceDirectory += @"\";
            }

            foreach (FileInfo fileInfo in DiscContents.getInstance().FileInfoList)
            {
                string fileName            = fileInfo.Name;
                string targetFileDirectory = DEFAULT_STAGING_DIRECTORY + fileInfo.FullName.Substring(sourceDirectory.Length);
                targetFileDirectory = targetFileDirectory.Substring(0, targetFileDirectory.Length - fileName.Length);
                if (!targetFileDirectory.EndsWith(@"\"))
                {
                    targetFileDirectory += @"\";
                }
                if (!Directory.Exists(targetFileDirectory))
                {
                    Directory.CreateDirectory(targetFileDirectory);
                }

                File.Copy(fileInfo.FullName, targetFileDirectory + fileName);
                copiedFileSize += fileInfo.Length;
                ViewModel.getInstance().ProgressPercentage = copiedFileSize * 100 / totalFileSize;
            }
        }
示例#3
0
        public MainForm()
        {
            InitializeComponent();
            this.thesisRecordBindingSource.Add(MainThread.getInstance().ThesisRecord);
            this.viewModelBindingSource.Add(ViewModel.getInstance());
            this.readerConfigBindingSource.Add(ReaderConfig.getInstance());
            this.inventoryRecordBindingSource.Add(InventoryStore.getInstance().SelectedInventoryRecord);

            this.fileSelectListBox.DataSource           = DiscContents.getInstance().MaskedFileInfoList;
            this.fileSelectListBox.DisplayMember        = "MaskedFileName";
            this.allFileListBox.DataSource              = DiscContents.getInstance().DisplayFileInfoList;
            this.allFileListBox.DisplayMember           = "DisplayFileName";
            this.inventoryMatchesComboBox.DataSource    = MainThread.getInstance().MatchingInventoryList;
            this.inventoryMatchesComboBox.DisplayMember = "DisplayString";

            ViewModel.getInstance().ProgressBar          = this.progressBar;
            PdfReaderHelper.getInstance().ContainerPanel = this.pdfReaderPanel;

            Version version = Assembly.GetExecutingAssembly().GetName().Version;

            this.Text = Text + " - v" + version.Major + "." + version.Minor + "." + version.Build;

            this.chineseAbstractTextBox.KeepLineBreaks = true;
            this.englishAbstractTextBox.KeepLineBreaks = true;

            this.menuPanel.DataBindings.Add(new Binding("Visible", this.viewModelBindingSource, "ShowMenu", true, DataSourceUpdateMode.OnPropertyChanged));
            this.pdfTextsTextArea.DataBindings.Add(new Binding("Visible", this.viewModelBindingSource, "ShowPdfTexts", true, DataSourceUpdateMode.OnPropertyChanged));
        }
示例#4
0
        protected void loadExpectedThesisFile()
        {
            MaskedFileInfo expectedFileInfo = expectedFileLookup(DiscContents.getInstance());
            ViewModel      viewModel        = ViewModel.getInstance();

            if (expectedFileInfo != null)
            {
                viewModel.ExpectedThesisFile = expectedFileInfo;
                viewModel.SelectedThesisFile = expectedFileInfo;
            }
            loadSelectedThesisFile();
        }
示例#5
0
        protected MaskedFileInfo expectedFileLookup(DiscContents contents)
        {
            List <MaskedFileInfo> potentialFileList = new List <MaskedFileInfo>();
            MaskedFileInfo        largestPdfFile    = null;

            foreach (MaskedFileInfo maskedFileInfo in contents.MaskedFileInfoList)
            {
                if (maskedFileInfo == null)
                {
                    continue;
                }
                FileInfo fileInfo      = maskedFileInfo.FileInfo;
                string   filePathLower = fileInfo.FullName.ToLower();

                if (EXPECTED_FILE_PATTERN_REGEX.IsMatch(filePathLower))
                {
                    potentialFileList.Add(maskedFileInfo);
                }

                if (filePathLower.EndsWith("pdf") && fileInfo.Length > (largestPdfFile == null ? 0 : largestPdfFile.FileInfo.Length))
                {
                    largestPdfFile = maskedFileInfo;
                }
            }
            if (potentialFileList.Count > 0)
            {
                MaskedFileInfo largerPdfFile = null;
                foreach (MaskedFileInfo potentialFileInfo in potentialFileList)
                {
                    if (potentialFileInfo.FileInfo.Length > (largerPdfFile == null ? 0 : largerPdfFile.FileInfo.Length))
                    {
                        largerPdfFile = potentialFileInfo;
                    }
                }
                return(largerPdfFile);
            }

            if (largestPdfFile != null)
            {
                return(largestPdfFile);
            }

            return(null);
        }
        protected bool readDiscContent(string contentPath)
        {
            if (!_reader.read(contentPath))
            {
                return(false);
            }

            if (DiscContents.getInstance().FileInfoList != null)
            {
                foreach (FileInfo fileInfo in DiscContents.getInstance().FileInfoList)
                {
                    if (fileInfo != null && fileInfo.FullName != null && fileInfo.FullName.ToLower().EndsWith(".pdf"))
                    {
                        return(true);
                    }
                }
            }
            return(false);
        }
示例#7
0
        public bool read(string path)
        {
            DiscContents discContents = DiscContents.getInstance();

            this._filePathList.Clear();
            this._filePathList.AddRange(FileUtils.ListFilesInDirectory(path));

            List <FileInfo> fileInfoList  = new List <FileInfo>();
            long            totalFileSize = 0;

            foreach (string filePath in this._filePathList)
            {
                FileInfo fileInfo = new FileInfo(filePath);
                fileInfoList.Add(fileInfo);
                totalFileSize += fileInfo.Length;
            }
            discContents.TotalFileSize = totalFileSize;
            bool isNewDisc = discContents.updateFileInfoList(fileInfoList);

            this._filePathList.Clear();
            return(isNewDisc);
        }