Example #1
0
        public int AddNewClasses(BackgroundWorker worker, int classificationProgress, int classificationTotal, MOG_Project project, TreeNodeCollection nodes)
        {
            foreach (AssetTreeNode atn in nodes)
            {
                if (atn.IsAClassification && !atn.InDB)
                {
                    string classFullName = atn.FullPath.Replace(atn.TreeView.PathSeparator, "~");

                    worker.ReportProgress(classificationProgress++ *100 / classificationTotal, "Creating " + classFullName);

                    project.ClassificationAdd(classFullName);
                    MOG_Properties properties = project.GetClassificationProperties(classFullName);
                    properties.SetImmeadiateMode(true);

                    //If all the kids have the same sync target, we're setting the classification sync target to the same one
                    string commonSyncTarget = FindCommonSyncTarget(atn);
                    if (commonSyncTarget != "")
                    {
                        // Set the classification's sync target to the common sync target of all the assets
                        atn.FileFullPath = commonSyncTarget;
                    }

                    atn.InDB = true;
                }

                // recurse
                classificationProgress = AddNewClasses(worker, classificationProgress, classificationTotal, project, atn.Nodes);
            }

            return(classificationProgress);
        }
Example #2
0
        private void LoadClassTreeConfigs_old(TreeNodeCollection nodes, MOG_Project proj)
        {
            if (nodes == null || proj == null)
            {
                return;
            }

            foreach (classTreeNode tn in nodes)
            {
                MOG_Properties props = proj.GetClassificationProperties(tn.FullPath);
                props.SetImmeadiateMode(true);
                tn.props = props;

                // set icon
                string iconFilename = proj.GetProjectToolsPath() + "\\" + tn.props.ClassIcon;
                if (File.Exists(iconFilename))
                {
                    if (!this.imageArrayList.Contains(iconFilename.ToLower()))
                    {
                        // this image hasn't been loaded before
                        Image img = Image.FromFile(iconFilename);
                        this.imageList.Images.Add(img);
                        this.imageArrayList.Add(iconFilename.ToLower());
                        //tn.ImageIndex = this.imageArrayList.Count - 1;
                        //tn.SelectedImageIndex = this.imageArrayList.Count - 1;
                    }
                    else
                    {
                        // this image has already been loaded
                        //tn.ImageIndex = this.imageArrayList.IndexOf(iconFilename.ToLower());
                        //tn.SelectedImageIndex = this.imageArrayList.IndexOf(iconFilename.ToLower());
                    }
                }

                LoadClassTreeConfigs(tn.Nodes);
            }
        }
Example #3
0
        private void CreateProject_Worker(object sender, DoWorkEventArgs e)
        {
            BackgroundWorker worker = sender as BackgroundWorker;

            MOG_Project project = new MOG_Project();

            try
            {
                MOG_System sys = MOG_ControllerSystem.GetSystem();
                if (sys != null)
                {
                    project = sys.ProjectCreate(this.projectInfoControl.ProjectName);
                    if (project != null)
                    {
                        worker.ReportProgress(0, "Setting project info...");

                        // project info
                        project.SetProjectPath(this.projectInfoControl.ProjectPath);
                        project.SetProjectToolsPath(this.projectInfoControl.ProjectPath + "\\Tools");
                        project.SetProjectUsersPath(this.projectInfoControl.ProjectPath + "\\Users");

                        worker.ReportProgress(0, "Copying tools...");

                        worker.ReportProgress(0, "Saving and logging in...");

                        // create project and login
                        project.Save();

                        MOG_ControllerProject.LoginProject(this.projectInfoControl.ProjectName, "");

                        worker.ReportProgress(0, "Creating current branch...");

                        // create default branch
                        MOG_ControllerProject.BranchCreate("", "Current");

                        worker.ReportProgress(0, "Creating classification tree...");

                        // platforms
                        MOG_Platform pcPlatform = new MOG_Platform();
                        pcPlatform.mPlatformName = "PC";
                        project.PlatformAdd(pcPlatform);

                        // create classifications
                        MogUtil_ClassificationLoader classLoader = new MogUtil_ClassificationLoader();
                        classLoader.ProjectName = this.projectInfoControl.ProjectName;
                        foreach (MOG_Properties props in classLoader.GetClassPropertiesListFromFiles())
                        {
                            if (props.Classification.ToLower() == project.GetProjectName().ToLower())
                            {
                                // create only project name root class node
                                project.ClassificationAdd(props.Classification);
                                MOG_Properties properties = project.GetClassificationProperties(props.Classification);
                                properties.SetImmeadiateMode(true);
                                properties.SetProperties(props.GetPropertyList());
                                break;
                            }
                        }

                        project.Save();
                    }
                    else
                    {
                        throw new Exception("Failed to create the project.");
                    }
                }
                else
                {
                    throw new Exception("System not initialized.");
                }
            }
            catch (Exception ex)
            {
                MOG_Report.ReportMessage("Project Creation Failed", ex.Message, ex.StackTrace, MOG_ALERT_LEVEL.CRITICAL);
            }

            e.Result = project;
        }