Exemplo n.º 1
0
        private string GetFullPath(int index)
        {
            string returnPath = currentPath;

            // parent path
            if (index == 2)
            {
                if (returnPath != testproject)
                {
                    returnPath = returnPath.Remove(returnPath.Length - 1);
                    int pos = returnPath.LastIndexOf(Path.DirectorySeparatorChar);
                    returnPath = returnPath.Substring(0, pos + 1);
                }
            }
            // specified path
            else if (index > 2)
            {
                string[] fileList = Directory.GetFileSystemEntries(returnPath);
                int      i        = 2;
                foreach (string file in fileList)
                {
                    FileCategory belongToCategory = proj.GetFileCategory(file);
                    bool         isViewed         = false;
                    if (belongToCategory != FileCategory.Unknown)
                    {
                        isViewed = true;
                        if (!Directory.Exists(file))
                        {
                            ProjectFile     projFile     = proj.GetFile(file);
                            ProjectFileName projFileName = new ProjectFileName(file);
                            if (projFile == null || !projFile.DwgExists || projFileName.Extension.ToLower() != ".xml")
                            {
                                isViewed = false;
                            }
                        }
                    }

                    if (isViewed)
                    {
                        ++i;
                    }

                    if (i == index)
                    {
                        returnPath = file;
                        break;
                    }
                }
            }
            // else: current path

            if (Directory.Exists(returnPath) &&
                returnPath[returnPath.Length - 1] != Path.DirectorySeparatorChar)
            {
                returnPath += Path.DirectorySeparatorChar;
            }

            return(returnPath);
        }
Exemplo n.º 2
0
        public static PackageID GetDefaultPackageID(ProjectFileName projectFileName)
        {
            var projectFileNameWithoutExtension = PathUtilities.GetFileNameWithoutExtension(projectFileName);

            var packageID = Utilities.GetDefaultPackageID(projectFileNameWithoutExtension);

            return(packageID);
        }
Exemplo n.º 3
0
        private void ListAll( )
        {
            string[]     fileList   = Directory.GetFileSystemEntries(currentPath);
            FileCategory category   = proj.GetCategory(currentPath);
            bool         isCategory = (category != FileCategory.Unknown);

            Print("1. <CATEGORY>       .");
            Print("2. <CATEGORY>       ..");

            int i = 2;

            foreach (string file in fileList)
            {
                //find category or file in category
                FileCategory belongToCategory = proj.GetFileCategory(file);
                bool         isViewed         = false;
                string       tag = null;

                // in category directory
                if (belongToCategory != FileCategory.Unknown)
                {
                    isViewed = true;
                    if (!Directory.Exists(file))
                    {
                        tag = ". <DWGFILE>        ";
                        ProjectFile     projFile     = proj.GetFile(file);
                        ProjectFileName projFileName = new ProjectFileName(file);
                        if (projFile == null || !projFile.DwgExists || projFileName.Extension.ToLower() != ".xml")
                        {
                            isViewed = false;
                        }
                    }
                    else
                    {
                        tag = ". <CATEGORY>       ";
                    }
                }

                if (isViewed)
                {
                    ++i;
                    string fileName = file.Substring(currentPath.Length);

                    if (fileName.ToLower().Contains(".xml"))
                    {
                        fileName = fileName.Substring(0, fileName.Length - 4);
                    }

                    Print(i + tag + fileName);
                }
            }
        }
Exemplo n.º 4
0
        public MainWindow(UpdateMonitor InUpdateMonitor, string InSqlConnectionString, string InDataFolder, EventWaitHandle ActivateEvent, bool bInRestoreStateOnLoad, string InOriginalExecutableFileName, string InProjectFileName, bool bInUnstable, BoundedLogWriter InLog, UserSettings InSettings)
        {
            InitializeComponent();

            NotifyMenu_OpenUnrealGameSync.Font = new Font(NotifyMenu_OpenUnrealGameSync.Font, FontStyle.Bold);

            UpdateMonitor              = InUpdateMonitor;
            SqlConnectionString        = InSqlConnectionString;
            DataFolder                 = InDataFolder;
            ActivationListener         = new ActivationListener(ActivateEvent);
            bRestoreStateOnLoad        = bInRestoreStateOnLoad;
            OriginalExecutableFileName = InOriginalExecutableFileName;
            bUnstable = bInUnstable;
            Log       = InLog;
            Settings  = InSettings;

            TabControl.OnTabChanged  += TabControl_OnTabChanged;
            TabControl.OnNewTabClick += TabControl_OnNewTabClick;
            TabControl.OnTabClicked  += TabControl_OnTabClicked;
            TabControl.OnTabClosing  += TabControl_OnTabClosing;
            TabControl.OnTabClosed   += TabControl_OnTabClosed;
            TabControl.OnTabReorder  += TabControl_OnTabReorder;
            TabControl.OnButtonClick += TabControl_OnButtonClick;

            SetupDefaultControl();

            int SelectTabIdx = -1;

            foreach (string ProjectFileName in Settings.OpenProjectFileNames)
            {
                if (!String.IsNullOrEmpty(ProjectFileName))
                {
                    int TabIdx = TryOpenProject(ProjectFileName);
                    if (TabIdx != -1 && Settings.LastProjectFileName != null && ProjectFileName.Equals(Settings.LastProjectFileName, StringComparison.InvariantCultureIgnoreCase))
                    {
                        SelectTabIdx = TabIdx;
                    }
                }
            }

            if (SelectTabIdx != -1)
            {
                TabControl.SelectTab(SelectTabIdx);
            }
            else if (TabControl.GetTabCount() > 0)
            {
                TabControl.SelectTab(0);
            }
        }
Exemplo n.º 5
0
        public static ProjectName GetProjectName(ProjectFileName projectFileName)
        {
            var projectName = PathUtilities.GetFileNameWithoutExtension(projectFileName).Value.AsProjectName();

            return(projectName);
        }
        public static ProjectFileName AsProjectFileName(this string value)
        {
            var projectFileName = new ProjectFileName(value);

            return(projectFileName);
        }
Exemplo n.º 7
0
        private void NewProjectViewModel_PropertyChanged(object sender, PropertyChangedEventArgs e)
        {
            // Project
            if (e.PropertyName == nameof(ProjectFileName))
            {
                if (!string.IsNullOrWhiteSpace(ProjectFileName))
                {
                    if (!ProjectFileName.EndsWith(".ytcfg"))
                    {
                        ProjectFileName += ".ytcfg";
                    }
                }
            }

            if (e.PropertyName == nameof(HeightWidth) && HeightWidth != null)
            {
                HeightWidth = FindClosestInt(HeightWidth.Value, 32);
            }

            if ((e.PropertyName == nameof(ProjectFileName) || e.PropertyName == nameof(DarknetExecutable)) &&
                !string.IsNullOrWhiteSpace(ProjectFileName) &&
                !string.IsNullOrWhiteSpace(DarknetExecutable))
            {
                var darknetDirectory = Path.GetDirectoryName(DarknetExecutable);
                var projectName      = Path.GetFileNameWithoutExtension(ProjectFileName);
                if (!projectName.EndsWith("-yolov3"))
                {
                    projectName += "-yolov3";
                }

                if (string.IsNullOrWhiteSpace(YoloConfigFile))
                {
                    YoloConfigFile = Path.Combine(darknetDirectory, projectName + ".cfg");
                }

                if (string.IsNullOrWhiteSpace(ObjDataFile))
                {
                    ObjDataFile = Path.Combine(darknetDirectory, projectName + "-data", "obj.data");
                }
            }

            if (e.PropertyName == nameof(YoloConfigFile) && !string.IsNullOrWhiteSpace(YoloConfigFile))
            {
                // TODO (judwhite): load if exists

                BatchSize       = 64;
                Subdivisions    = 32;
                HeightWidth     = 608;
                IsRandomChecked = true;
                MaxObjects      = 150;
            }

            if (e.PropertyName == nameof(ObjDataFile) && !string.IsNullOrWhiteSpace(ObjDataFile))
            {
                // TODO (judwhite): load if exists

                var dataDirectory   = Path.GetFileName(Path.GetDirectoryName(ObjDataFile));
                var backupDirectory = (dataDirectory + "-backup").Replace("-data-backup", "-backup");

                TrainFileName      = dataDirectory + "/train.txt";
                ValidFileName      = dataDirectory + "/valid.txt";
                ClassNamesFileName = dataDirectory + "/obj.names";
                BackupFolder       = backupDirectory + "/";

                if (string.IsNullOrWhiteSpace(ImagesDirectory))
                {
                    ImagesDirectory = dataDirectory + "/img";
                }
            }
        }