Exemplo n.º 1
0
        public SortForm(SortProject project, MainForm mainForm, bool randomSort)
        {
            InitializeComponent();
            _randomSort = randomSort;
            _mainForm   = mainForm;
            _project    = project;

            // vlc control used for webms
            _vlcControl = new VlcControl();
            _vlcControl.VlcMediaplayerOptions  = new string[] { "--loop" };
            _vlcControl.VlcLibDirectoryNeeded += VlcLibDirectoryNeeded;
            _vlcControl.EndReached            += EndReached;
            _vlcControl.Dock            = DockStyle.Fill;
            _vlcControl.BackColor       = SystemColors.Control;
            _vlcControl.VlcLibDirectory = new DirectoryInfo(".");
            _vlcControl.EndInit();
            _vlcControl.Visible = false;

            // picture box used for everything else - the vlc control can show images, but it's a lot slower than the picture box
            // we disable both and choose which one to display based on the filetype of the current image
            _pictureBox          = new PictureBox();
            _pictureBox.Dock     = DockStyle.Fill;
            _pictureBox.Visible  = false;
            _pictureBox.SizeMode = PictureBoxSizeMode.Zoom;

            splitter.Panel1.Controls.Add(_vlcControl);
            splitter.Panel1.Controls.Add(_pictureBox);

            // load the first image
            LoadImage(FindNextImage());
        }
Exemplo n.º 2
0
        /// <summary>
        /// Save the history - image history is saved in a seperate file, to make appending to both formats easier.
        /// </summary>
        private static void SaveHistory(SortProject project)
        {
            var appDataFolder = Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData);

            CreateDataDirectory(appDataFolder);

            var filePath   = Path.Combine(appDataFolder, "imagetool", project.Id + ".hist");
            var fileExists = File.Exists(filePath);
            var outputFile = File.Open(
                filePath,
                project.HistoryCount < 0 ? FileMode.Create : FileMode.Append
                );

            var outputWriter = new StreamWriter(outputFile);

            if (!fileExists || project.HistoryCount < 0)
            {
                outputWriter.WriteLine("--history--");
                foreach (string file in project.History)
                {
                    outputWriter.WriteLine(file);
                }
            }
            else
            {
                foreach (string file in project.GetHistoryBuffer())
                {
                    outputWriter.WriteLine(file);
                }
            }
            project.ClearHistoryBuffer();
            outputWriter.Close();
            outputFile.Close();
        }
Exemplo n.º 3
0
 public ComicListForm(SortProject project, MainForm form)
 {
     InitializeComponent();
     _project  = project;
     _mainForm = form;
     RefreshComics();
     yesButton.Enabled = false;
     noButton.Enabled  = false;
 }
Exemplo n.º 4
0
        /// <summary>
        /// Delete the sort project.
        /// </summary>
        public static void DeleteProject(SortProject project)
        {
            var appDataFolder = Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData);
            var projectPath   = Path.Combine(appDataFolder, "imagetool", project.Id);

            if (File.Exists(projectPath + ".dat"))
            {
                File.Delete(projectPath + ".dat");
            }
            if (File.Exists(projectPath + ".hist"))
            {
                File.Delete(projectPath + ".hist");
            }
        }
Exemplo n.º 5
0
 private void createButton_Click(object sender, EventArgs e)
 {
     if (string.IsNullOrWhiteSpace(projectNameBox.Text) ||
         string.IsNullOrWhiteSpace(directoryBox.Text))
     {
         return;
     }
     DialogResult = DialogResult.OK;
     this.Hide();
     Project = new SortProject(projectNameBox.Text, directoryBox.Text)
     {
         Type = (SortProject.ProjectType)
                Enum.Parse(typeof(SortProject.ProjectType), (string)projectType.SelectedItem)
     };
 }
Exemplo n.º 6
0
        /// <summary>
        /// Saves a single project.
        /// </summary>
        public static void SaveProject(SortProject project)
        {
            // find the app folder and ensure it's created.
            var appDataFolder = Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData);

            CreateDataDirectory(appDataFolder);

            var filePath   = Path.Combine(appDataFolder, "imagetool", project.Id + ".dat");
            var fileExists = File.Exists(filePath);
            var outputFile = File.Open(
                filePath,
                FileMode.Append
                );

            var outputWriter = new StreamWriter(outputFile);

            // if the file doesn't exist, write the header
            if (!fileExists)
            {
                outputWriter.WriteLine("--project2--");
                outputWriter.WriteLine(project.Id);
                outputWriter.WriteLine(project.Name);
                outputWriter.WriteLine(project.Directory);
                outputWriter.WriteLine(project.Type);
                foreach (string file in project.FinishedFiles)
                {
                    outputWriter.WriteLine(file);
                }
            }
            else // if the file exists, just write the files that have changed since last save
            {
                foreach (string file in project.GetBuffer())
                {
                    outputWriter.WriteLine(file);
                }
                project.ClearBuffer();
            }
            outputWriter.Close();
            outputFile.Close();

            SaveHistory(project);
        }