Ejemplo n.º 1
0
        private void CopyFiles()
        {
            string remoteDir = Path.GetDirectoryName(Globals.RemoteProjectFile);

            IOSupport.CopyFile(Globals.RemoteProjectFile, Globals.ProjectFile, true);
            IOSupport.CopyFile(remoteDir + @"\Settings\categories.xml", Globals.SettingsDir + "categories.xml", true);
        }
Ejemplo n.º 2
0
        private void btnAdd_Click(object sender, EventArgs e)
        {
            OpenFileDialog dlg = new OpenFileDialog();

            if (dlg.ShowDialog() == DialogResult.OK)
            {
                if (String.IsNullOrEmpty(Globals.ProjectFile) == false)
                {
                    string destFile = Globals.MapsDir + Path.GetFileName(dlg.FileName);
                    IOSupport.CopyFile(dlg.FileName, destFile);

                    int index = dgrMaps.Rows.Add();
                    dgrMaps[0, index].Value = Path.GetFileName(dlg.FileName);
                    dgrMaps[1, index].Value = "";
                }
            }
        }
Ejemplo n.º 3
0
        private void SetImage(int index, string filepath)
        {
            string fileName    = navigatorPoint.Id + "-" + Path.GetFileName(filepath);
            string curFileName = string.Empty;

            // Set point image and picture box image
            switch (index)
            {
            case 0:
                pbStraight.Image    = ImageLoader.GetImageFromFile(filepath, pbStraight.Width, pbStraight.Height);
                curFileName         = navigatorPoint.Img1;
                navigatorPoint.Img1 = fileName;
                break;

            case 1:
                pbLeft.Image        = ImageLoader.GetImageFromFile(filepath, pbLeft.Width, pbLeft.Height);;
                curFileName         = navigatorPoint.Img2;
                navigatorPoint.Img2 = fileName;
                break;

            case 2:
                pbBehind.Image      = ImageLoader.GetImageFromFile(filepath, pbBehind.Width, pbBehind.Height);;
                curFileName         = navigatorPoint.Img3;
                navigatorPoint.Img3 = fileName;
                break;

            case 3:
                pbRight.Image       = ImageLoader.GetImageFromFile(filepath, pbRight.Width, pbRight.Height);;
                curFileName         = navigatorPoint.Img4;
                navigatorPoint.Img4 = fileName;
                break;
            }


            string destinationDir = Globals.ImagesDir + navigatorPath.Id + "\\";

            IOSupport.CopyFile(filepath, destinationDir + fileName);

            // Rename old file name (filename to _filename)
            if (String.IsNullOrEmpty(curFileName) == false && File.Exists(destinationDir + curFileName))
            {
                IOSupport.RenameFile(destinationDir + curFileName, destinationDir + "_" + curFileName);
            }
        }
Ejemplo n.º 4
0
        private void lnkSelectNewImage_LinkClicked(object sender, LinkLabelLinkClickedEventArgs e)
        {
            OpenFileDialog dlg = new OpenFileDialog();

            dlg.Filter      = "Image files (.jpg, .jpeg, .bmp, .gif, .png)|*.jpg;*.jpeg;*.bmp;*.gif;*.png";
            dlg.Multiselect = false;
            if (dlg.ShowDialog() == DialogResult.OK)
            {
                // rename current image (name#dd-MMM-yyyy seconds.extension)
                string curFile = navigationViewerCtrl1.CurrentImagePath;
                IOSupport.RenameFile(curFile, GetHistFilename(curFile));
                // rename selected image to be used for Navigator point
                IOSupport.CopyFile(dlg.FileName, curFile);

                ShowCurrentImage();
                ShowPastImages();

                navigationViewerCtrl1.RefreshCurrentImage();
            }
        }
Ejemplo n.º 5
0
        private void SyncFolder(string srcFolder, string destFolder)
        {
            IOSupport.CreateDirectory(destFolder);
            // 1. FILES
            // copy all files if does not exists or changed
            List <string> existingFiles = new List <string>();

            foreach (string srcFile in Directory.GetFiles(srcFolder))
            {
                string name     = Path.GetFileName(srcFile);
                string destFile = destFolder + "\\" + name;
                if (File.Exists(destFile))
                {
                    // copy only if modified
                    FileInfo srcFileInfo  = new FileInfo(srcFile);
                    FileInfo destFileInfo = new FileInfo(destFile);
                    if (srcFileInfo.LastWriteTime != destFileInfo.LastWriteTime)
                    {
                        IOSupport.CopyFile(srcFile, destFile, true);
                    }
                }
                else
                {
                    // new file
                    IOSupport.CopyFile(srcFile, destFile, true);
                }

                existingFiles.Add(name);
            }
            // Delete unused files
            foreach (string destFile in Directory.GetFiles(destFolder))
            {
                string name = Path.GetFileName(destFile);
                if (existingFiles.Contains(name) == false)
                {
                    IOSupport.DeleteFile(destFile);
                }
            }

            // 2. FOLDERS
            List <string> existingFolders = new List <string>();

            // recursively process all sub directories
            foreach (string subfolder in Directory.GetDirectories(srcFolder))
            {
                string foldername = new DirectoryInfo(subfolder).Name;
                // recursive call
                SyncFolder(subfolder, destFolder + "\\" + foldername);

                existingFolders.Add(foldername);
            }
            // delete all unused folders
            foreach (string destDir in Directory.GetDirectories(destFolder))
            {
                string name = new DirectoryInfo(destDir).Name;
                if (existingFolders.Contains(name) == false)
                {
                    IOSupport.DeleteDirectory(destDir, true);
                }
            }
        }