The Dynamo model.
Inheritance: Dynamo.Models.ModelBase
コード例 #1
0
        private static string DoPackageFileOperationsAndZip(DynamoModel dynamoModel, Package pkg, List<string> files, PackageUploadHandle uploadHandle)
        {
            uploadHandle.UploadState = PackageUploadHandle.State.Copying;

            DirectoryInfo rootDir, dyfDir, binDir, extraDir;
            FormPackageDirectory(dynamoModel.Loader.PackageLoader.RootPackagesDirectory, pkg.Name, out rootDir, out  dyfDir, out binDir, out extraDir); // shouldn't do anything for pkg versions
            pkg.RootDirectory = rootDir.FullName;
            WritePackageHeader(pkg.Header, rootDir);
            CopyFilesIntoPackageDirectory(files, dyfDir, binDir, extraDir);
            RemoveDyfFiles(files, dyfDir); 
            RemapCustomNodeFilePaths(dynamoModel.CustomNodeManager, files, dyfDir.FullName);

            uploadHandle.UploadState = PackageUploadHandle.State.Compressing;

            string zipPath;
            FileInfo info;

            try
            {
                zipPath = Greg.Utility.FileUtilities.Zip(rootDir.FullName);
                info = new FileInfo(zipPath);
            }
            catch
            {
                // give nicer error
                throw new Exception("Could not compress file.  Is the file in use?");
            }
            
            if (info.Length > 15 * 1000000) throw new Exception("The package is too large!  The package must be less than 15 MB!");

            return zipPath;
        }
コード例 #2
0
ファイル: EngineController.cs プロジェクト: whztt07/Dynamo
        public EngineController(DynamoModel dynamoModel, string geometryFactoryFileName)
        {
            this.dynamoModel = dynamoModel;

            // Create a core which is used for parsing code and loading libraries
            libraryCore = new ProtoCore.Core(new Options()
            {
                RootCustomPropertyFilterPathName = string.Empty
            });
            libraryCore.Executives.Add(Language.kAssociative,new ProtoAssociative.Executive(libraryCore));
            libraryCore.Executives.Add(Language.kImperative, new ProtoImperative.Executive(libraryCore));
            libraryCore.ParsingMode = ParseMode.AllowNonAssignment;

            libraryServices = new LibraryServices(libraryCore);
            libraryServices.LibraryLoading += this.LibraryLoading;
            libraryServices.LibraryLoadFailed += this.LibraryLoadFailed;
            libraryServices.LibraryLoaded += this.LibraryLoaded;

            liveRunnerServices = new LiveRunnerServices(dynamoModel, this, geometryFactoryFileName);
            liveRunnerServices.ReloadAllLibraries(libraryServices.ImportedLibraries);

            codeCompletionServices = new CodeCompletionServices(LiveRunnerCore);

            astBuilder = new AstBuilder(dynamoModel, this);
            syncDataManager = new SyncDataManager();

            dynamoModel.NodeDeleted += NodeDeleted;
        }
コード例 #3
0
ファイル: Logger.cs プロジェクト: whztt07/Dynamo
        //Service start
        public static void Start(DynamoModel dynamoModel)
        {
            string appVersion = Process.GetCurrentProcess().ProcessName + "-"
                                + UpdateManager.UpdateManager.Instance.ProductVersion.ToString();


            CSharpAnalytics.MeasurementConfiguration mc = new MeasurementConfiguration(ANALYTICS_PROPERTY,
                "Dynamo", appVersion);

            sessionID = Guid.NewGuid().ToString();
            loggerImpl = new Log("Dynamo", userID, sessionID);

            
            CSharpAnalytics.AutoMeasurement.Start(mc);
            client = AutoMeasurement.Client;

            if (IS_VERBOSE_DIAGNOSTICS)
            {
                AutoMeasurement.DebugWriter = d => Debug.WriteLine(d);
            }

            started = true;

            // The following starts the heartbeat, do not remove this 
            // because of the unreferenced "heartbeat" variable.

// ReSharper disable UnusedVariable
            var heartbeat = Heartbeat.GetInstance(dynamoModel);
// ReSharper restore UnusedVariable

        }
コード例 #4
0
ファイル: AbstractMutator.cs プロジェクト: heegwon/Dynamo
 protected AbstractMutator(Random rand)
 {
     this.Rand = rand;
     this.Controller = dynSettings.Controller;
     this.DynamoViewModel = Controller.DynamoViewModel;
     this.DynamoModel = Controller.DynamoModel;
 }
コード例 #5
0
ファイル: Logger.cs プロジェクト: ankushraizada/Dynamo
        //Service start
        public static void Start(DynamoModel dynamoModel)
        {
            InstrumentationLogger.dynamoModel = dynamoModel;

            if (IsAnalyticsEnabled)
            {
                string appVersion = dynamoModel.AppVersion;

                var mc = new MeasurementConfiguration(ANALYTICS_PROPERTY,
                    "Dynamo", appVersion);
                mc.AnonymizeIp = true;

                sessionID = Guid.NewGuid().ToString();
                loggerImpl = new Log("Dynamo", userID, sessionID);
            
                AutoMeasurement.Start(mc);
                client = AutoMeasurement.Client;

                if (IS_VERBOSE_DIAGNOSTICS)
                    AutoMeasurement.DebugWriter = d => Debug.WriteLine(d);

                started = true;
            }


            // The following starts the heartbeat, do not remove this 
            // because of the unreferenced "heartbeat" variable.

// ReSharper disable UnusedVariable
            var heartbeat = Heartbeat.GetInstance(dynamoModel);
// ReSharper restore UnusedVariable

        }
コード例 #6
0
        public bool Extract(DynamoModel dynamoModel, string installDirectory, out Package pkg)
        {
            this.DownloadState = State.Installing;

            // unzip, place files
            var unzipPath = Greg.Utility.FileUtilities.UnZip(DownloadPath);
            if (!Directory.Exists(unzipPath))
            {
                throw new Exception(Properties.Resources.PackageEmpty);
            }

            if (String.IsNullOrEmpty(installDirectory))
                installDirectory = dynamoModel.PathManager.DefaultPackagesDirectory;

            var installedPath = BuildInstallDirectoryString(installDirectory);
            Directory.CreateDirectory(installedPath);

            // Now create all of the directories
            foreach (string dirPath in Directory.GetDirectories(unzipPath, "*", SearchOption.AllDirectories))
                Directory.CreateDirectory(dirPath.Replace(unzipPath, installedPath));

            // Copy all the files
            foreach (string newPath in Directory.GetFiles(unzipPath, "*.*", SearchOption.AllDirectories))
                File.Copy(newPath, newPath.Replace(unzipPath, installedPath));

            // provide handle to installed package 
            pkg = new Package(installedPath, Header.name, VersionName, Header.license);

            return true;
        }
コード例 #7
0
ファイル: CefCommands.cs プロジェクト: DynamoDS/Dynamo
 public CefCommands(PackageLoader loader, DynamoModel model)
 {
     this.ProductName = !string.IsNullOrEmpty(model.HostName) ? model.HostName : "Dynamo"; 
     this.Loader = loader;
     this.Model = model;
     this.Client = new DynamoPackagesUIClient();
 }
コード例 #8
0
ファイル: CustomNodeManager.cs プロジェクト: RobertiF/Dynamo
 /// <summary>
 ///     Class Constructor
 /// </summary>
 /// <param name="dynamoModel"></param>
 /// <param name="searchPath">The path to search for definitions</param>
 public CustomNodeManager(DynamoModel dynamoModel, string searchPath)
 {
     this.dynamoModel = dynamoModel;
     SearchPath = new ObservableCollection<string> { searchPath };
     NodeInfos = new ObservableDictionary<Guid, CustomNodeInfo>();
     AddDirectoryToSearchPath(DynamoPathManager.Instance.CommonDefinitions);
 }
コード例 #9
0
        public void ExecuteCommand(DynamoModel.RecordableCommand command, string uniqueId, string extensionName)
        {
            // log that the command is being executed
            if (dynamoModel.DebugSettings.VerboseLogging)
            {
                dynamoModel.Logger.Log("Command: " + command);
            }
            
            var extnDetails = string.Format(
                "ExtensionCommandExecutive ( UniqueId: {0}, Name: {1}, commandTypeName: {2} )",
                uniqueId, extensionName, command.GetType().Name);
            
            Log(LogMessage.Info(extnDetails));

            try
            {
                // run the command
                dynamoModel.ExecuteCommand(command);
            }
            catch (Exception e)
            {
                // clean up or show failure messages
                Log(LogMessage.Error(string.Format("{0}, from {1}", e.Message, extnDetails)));
            }
            
        }
コード例 #10
0
 public Watch3DViewModelStartupParams(DynamoModel model)
 {
     Model = model;
     Scheduler = model.Scheduler;
     Logger = model.Logger;
     Preferences = model.PreferenceSettings;
     EngineControllerManager = model;
 }
コード例 #11
0
ファイル: NodeToCode.cs プロジェクト: jbenoit44/Dynamo
        public static string ConvertNodesToCode(DynamoModel dynamoModel, IEnumerable<NodeModel> nodeList)
        {
            var astBuilder = new AstBuilder(dynamoModel, null);
            var astNodes = astBuilder.CompileToAstNodes(nodeList, false);

            string code = GraphToDSCompiler.GraphUtilities.ASTListToCode(astNodes);
            return code;
        }
コード例 #12
0
ファイル: NodeToCode.cs プロジェクト: whztt07/Dynamo
        public static string ConvertNodesToCode(DynamoModel dynamoModel, IEnumerable<NodeModel> nodeList)
        {
            var astBuilder = new AstBuilder(dynamoModel, null);
            var astNodes = astBuilder.CompileToAstNodes(nodeList, false);

            var codeGen = new ProtoCore.CodeGenDS(astNodes);
            return codeGen.GenerateCode();
        }
コード例 #13
0
        /// <summary>
        /// Constructor
        /// </summary>
        /// <param name="dynamoViewModel"></param>
        /// <param name="model"></param>
        /// <param name="address"></param>
        public PackageManagerViewModel(PackageLoader loader, DynamoModel model, string address)
        {
            PkgMgrCommands = new PackageManagerCommands(loader, model);

            var path = this.GetType().Assembly.Location;
            var config = ConfigurationManager.OpenExeConfiguration(path);
            this.Address = PACKAGE_MANAGER_URL + "/#/" + address;
        }
コード例 #14
0
ファイル: DynamoCommands.cs プロジェクト: whztt07/Dynamo
        void OnModelCommandCompleted(DynamoModel.RecordableCommand command)
        {
            var name = command.GetType().Name;
            switch (name)
            {
                case "OpenFileCommand":
                    this.AddToRecentFiles((command as DynamoModel.OpenFileCommand).XmlFilePath);
                    this.VisualizationManager.UnPause();
                    break;

                case "MutateTestCommand":
                    var mutatorDriver = new Dynamo.TestInfrastructure.MutatorDriver(this);
                    mutatorDriver.RunMutationTests();
                    break;

                case "SelectInRegionCommand":
                    var selectC = command as DynamoModel.SelectInRegionCommand;
                    CurrentSpaceViewModel.SelectInRegion(selectC.Region, selectC.IsCrossSelection);
                    break;

                case "DragSelectionCommand":
                    var dragC = command as DynamoModel.DragSelectionCommand;

                    if (DynamoModel.DragSelectionCommand.Operation.BeginDrag == dragC.DragOperation)
                        CurrentSpaceViewModel.BeginDragSelection(dragC.MouseCursor);
                    else
                        CurrentSpaceViewModel.EndDragSelection(dragC.MouseCursor);
                    break;

                case "DeleteModelCommand":
                case "CreateNodeCommand":
                case "CreateNoteCommand":
                case "UndoRedoCommand":
                case "ModelEventCommand":
                case "UpdateModelValueCommand":
                case "ConvertNodesToCodeCommand":
                    UndoCommand.RaiseCanExecuteChanged();
                    RedoCommand.RaiseCanExecuteChanged();
                    break;

                case "SwitchTabCommand":
                    if (command.IsInPlaybackMode)
                        RaisePropertyChanged("CurrentWorkspaceIndex");
                    break;

                case "RunCancelCommand":
                case "ForceRunCancelCommand":
                case "SelectModelCommand":
                case "MakeConnectionCommand":
                case "CreateCustomNodeCommand":
                    // for this commands there is no need
                    // to do anything after execution
                    break;

                default:
                    throw new InvalidOperationException("Unhandled command name");
            }
        }
コード例 #15
0
ファイル: PublishCommands.cs プロジェクト: Benglin/Dynamo
 public PublishCommands(PackageLoader loader, DynamoModel model) 
 {
     fileCompressor = new MutatingFileCompressor();
     //customNodeDefinitions = new List<CustomNodeDefinition>();
     //Dependencies = new List<PackageDependency>();
     //Assemblies = new List<PackageAssembly>();
     //PackageAssemblyNodes = new List<TypeLoadData>();
     //FilesToUpload = new List<string>();
 }
コード例 #16
0
ファイル: ExecutionSession.cs プロジェクト: sh4nnongoh/Dynamo
 /// <summary>
 /// Constructs a new execution session.
 /// </summary>
 public ExecutionSession(Scheduler.UpdateGraphAsyncTask updateTask, DynamoModel model, string geometryFactoryPath)
 {
     CurrentWorkspacePath = updateTask.TargetedWorkspace.FileName;
     pathManager = model.PathManager;
     parameters[ParameterKeys.GeometryFactory] = geometryFactoryPath;
     parameters[ParameterKeys.MajorVersion] = pathManager.MajorFileVersion;
     parameters[ParameterKeys.MinorVersion] = pathManager.MinorFileVersion;
     parameters[ParameterKeys.NumberFormat] = model.PreferenceSettings.NumberFormat;
 }
コード例 #17
0
ファイル: Heartbeat.cs プロジェクト: whztt07/Dynamo
        public static Heartbeat GetInstance(DynamoModel dynModel)
        {
            lock (typeof(Heartbeat))
            {
                if (instance == null)
                    instance = new Heartbeat(dynModel);
            }

            return instance;
        }
コード例 #18
0
ファイル: PackageLoader.cs プロジェクト: RobertiF/Dynamo
        public PackageLoader(DynamoModel dynamoModel, string overridePackageDirectory)
        {
            this.dynamoModel = dynamoModel;

            this.RootPackagesDirectory = overridePackageDirectory;
            if (!Directory.Exists(this.RootPackagesDirectory))
            {
                Directory.CreateDirectory(this.RootPackagesDirectory);
            }
        }
コード例 #19
0
ファイル: DynamoCommands.cs プロジェクト: whztt07/Dynamo
        public void ExecuteCommand(DynamoModel.RecordableCommand command)
        {
            if (null != this.automationSettings)
                this.automationSettings.RecordCommand(command);

            if (Model.DebugSettings.VerboseLogging)
                model.Logger.Log("Command: " + command);

            this.model.ExecuteCommand(command);
        }
コード例 #20
0
        public CustomNodeWorkspaceModel(DynamoModel dynamoModel, 
            String name, String category, string description, IEnumerable<NodeModel> e, IEnumerable<ConnectorModel> c, double x, double y)
            : base(dynamoModel, name, e, c, x, y)
        {
            WatchChanges = true;
            HasUnsavedChanges = false;
            Category = category;
            Description = description;

            PropertyChanged += OnPropertyChanged;
        }
コード例 #21
0
ファイル: Package.cs プロジェクト: jbenoit44/Dynamo
 public Package(DynamoModel dynamoModel, string directory, string name, string versionName)
 {
     this.dynamoModel = dynamoModel;
     this.Loaded = false;
     this.RootDirectory = directory;
     this.Name = name;
     this.VersionName = versionName;
     this.LoadedTypes = new ObservableCollection<Type>();
     this.Dependencies = new ObservableCollection<PackageDependency>();
     this.LoadedCustomNodes = new ObservableCollection<CustomNodeInfo>();
 }
コード例 #22
0
        public void Start(DynamoModel model)
        {
            //Whether enabled or not, we still record the startup.
            Service.Instance.Register(new GATrackerFactory(ANALYTICS_PROPERTY));

            StabilityCookie.Startup();

            heartbeat = Heartbeat.GetInstance(model);

            logger = new UsageLog("Dynamo", UserId, SessionId);
        }
コード例 #23
0
ファイル: Heartbeat.cs プロジェクト: sm6srw/Dynamo
        private Heartbeat(DynamoModel dynamoModel)
        {
            // KILLDYNSETTINGS - this is provisional - but we need to enforce that Hearbeat is 
            // not referencing multiple DynamoModels
            this.dynamoModel = dynamoModel;

            startTime = DateTime.Now;
            heartbeatThread = new Thread(this.ExecThread);
            heartbeatThread.IsBackground = true;
            heartbeatThread.Start();
        }
コード例 #24
0
ファイル: ExtensionTests.cs プロジェクト: rafatahmed/Dynamo
        public void Init()
        {
            extensionsPath = Path.Combine(Directory.GetCurrentDirectory(), "extensions");
            extMock = new Mock<IExtension>();

            model = DynamoModel.Start(
                new DynamoModel.DefaultStartConfiguration()
                {
                    StartInTestMode = true,
                    Extensions = new List<IExtension> { extMock.Object }
                });
        }
コード例 #25
0
 public Watch3DViewModelStartupParams(DynamoModel model, DynamoViewModel viewModel, string name)
 {
     Model = model;
     Scheduler = model.Scheduler;
     Logger = model.Logger;
     Preferences = model.PreferenceSettings;
     EngineControllerManager = model;
     RenderPackageFactory = viewModel.RenderPackageFactoryViewModel.Factory;
     ViewModel = viewModel;
     RenderPackageFactoryViewModel = viewModel.RenderPackageFactoryViewModel;
     Name = name;
 }
コード例 #26
0
        public void Init()
        {
            extensionsPath = Path.Combine(Directory.GetCurrentDirectory(), "extensions");
            extMock = new Mock<IExtension>();

            model = DynamoModel.Start(
                new DynamoModel.DefaultStartConfiguration()
                {
                    StartInTestMode = true,
                    Extensions = new List<IExtension> { extMock.Object },
                    ProcessMode = Core.Threading.TaskProcessMode.Synchronous
                });
        }
コード例 #27
0
        public void Start(DynamoModel model)
        {
            //Whether enabled or not, we still record the startup.
            var service = Service.Instance;
            
            //Some clients such as Revit may allow start/close Dynamo multiple times
            //in the same session so register only if the factory is not registered.
            if(service.GetTrackerFactory(GATrackerFactory.Name) == null)
                service.Register(new GATrackerFactory(ANALYTICS_PROPERTY));

            StabilityCookie.Startup();

            heartbeat = Heartbeat.GetInstance(model);

            logger = new UsageLog("Dynamo", UserId, SessionId);
        }
コード例 #28
0
        public void TestOnRequestMigrationStatusDialog()
        {
            //Arrange
            //This will subscribe our local method to the RequestMigrationStatusDialog event
            DynCmd.RequestMigrationStatusDialog += DynamoModel_RequestMigrationStatusDialog;

            //Act
            //This will execute the OnRequestMigrationStatusDialog() in the DynamoModelEvents class
            DynCmd.OnRequestMigrationStatusDialog(new SettingsMigrationEventArgs(
                                                      SettingsMigrationEventArgs.EventStatusType.Begin));

            //Assert
            DynCmd.RequestMigrationStatusDialog -= DynamoModel_RequestMigrationStatusDialog;
            //This will validate that the local handler was executed and set the flag in true
            Assert.IsTrue(migrationStatusDialog);
        }
コード例 #29
0
ファイル: EngineController.cs プロジェクト: RobertiF/Dynamo
        public EngineController(DynamoModel dynamoModel, string geometryFactoryFileName)
        {
            this.dynamoModel = dynamoModel;

            libraryServices = LibraryServices.GetInstance();
            libraryServices.LibraryLoading += this.LibraryLoading;
            libraryServices.LibraryLoadFailed += this.LibraryLoadFailed;
            libraryServices.LibraryLoaded += this.LibraryLoaded;

            liveRunnerServices = new LiveRunnerServices(dynamoModel, this, geometryFactoryFileName);
            liveRunnerServices.ReloadAllLibraries(libraryServices.Libraries.ToList());

            astBuilder = new AstBuilder(dynamoModel, this);
            syncDataManager = new SyncDataManager();

            dynamoModel.NodeDeleted += NodeDeleted;
        }
コード例 #30
0
ファイル: ExtensionTests.cs プロジェクト: sh4nnongoh/Dynamo
        public void Init()
        {
            extensionsPath = Path.Combine(Directory.GetCurrentDirectory(), "extensions");
            extMock = new Mock<IExtension>();
            extMock.Setup(ext => ext.Ready(It.IsAny<ReadyParams>())).Callback((ReadyParams r) => ExtensionReadyCallback(r));
            cmdExecutionState = -1;

            model = DynamoModel.Start(
                new DynamoModel.DefaultStartConfiguration()
                {
                    StartInTestMode = true,
                    Extensions = new List<IExtension> { extMock.Object },
                    ProcessMode = TaskProcessMode.Synchronous
                });
            model.ExtensionManager.ExtensionAdded += OnExtensionAdded;
            model.ExtensionManager.ExtensionRemoved += OnExtensionRemoved;
        }
コード例 #31
0
        private static string DoPackageFileOperationsAndZip(DynamoModel dynamoModel, Package pkg, List<string> files, PackageUploadHandle uploadHandle)
        {
            uploadHandle.UploadState = PackageUploadHandle.State.Copying;

            DirectoryInfo rootDir, dyfDir, binDir, extraDir;
            FormPackageDirectory(dynamoModel.Loader.PackageLoader.RootPackagesDirectory, pkg.Name, out rootDir, out  dyfDir, out binDir, out extraDir); // shouldn't do anything for pkg versions
            pkg.RootDirectory = rootDir.FullName;
            WritePackageHeader(pkg.Header, rootDir);
            CopyFilesIntoPackageDirectory(files, dyfDir, binDir, extraDir);
            RemoveDyfFiles(files, dyfDir); 
            RemapCustomNodeFilePaths(dynamoModel.CustomNodeManager, files, dyfDir.FullName);

            uploadHandle.UploadState = PackageUploadHandle.State.Compressing;

            var zipPath = Greg.Utility.FileUtilities.Zip(rootDir.FullName);

            return zipPath;
        }
コード例 #32
0
        public void CreateModel(XmlElement modelData)
        {
            XmlElementHelper helper   = new XmlElementHelper(modelData);
            string           typeName = helper.ReadString("type", String.Empty);

            if (string.IsNullOrEmpty(typeName))
            {
                // If there wasn't a "type" attribute, then we fall-back onto
                // the name of the XmlElement itself, which is usually the type
                // name.
                typeName = modelData.Name;
                if (string.IsNullOrEmpty(typeName))
                {
                    string guid = helper.ReadString("guid");
                    throw new InvalidOperationException(
                              string.Format("No type information: {0}", guid));
                }
            }

            if (typeName.StartsWith("Dynamo.Nodes"))
            {
                NodeModel nodeModel = DynamoModel.CreateNodeInstance(typeName);
                nodeModel.WorkSpace = this;
                nodeModel.Deserialize(modelData, SaveContext.Undo);
                Nodes.Add(nodeModel);
            }
            else if (typeName.StartsWith("Dynamo.Models.ConnectorModel"))
            {
                ConnectorModel connector = ConnectorModel.Make();
                connector.Deserialize(modelData, SaveContext.Undo);
                Connectors.Add(connector);
            }
            else if (typeName.StartsWith("Dynamo.Models.NoteModel"))
            {
                NoteModel noteModel = new NoteModel(0.0, 0.0);
                noteModel.Deserialize(modelData, SaveContext.Undo);
                Notes.Add(noteModel);
            }
        }
コード例 #33
0
 public HomeWorkspaceModel(DynamoModel dynamoModel)
     : this(dynamoModel, new List <NodeModel>(), new List <ConnectorModel>(), 0, 0)
 {
 }
コード例 #34
0
ファイル: HomeWorkspaceModel.cs プロジェクト: hipigod/Dynamo
 public HomeWorkspaceModel(DynamoModel dynamoModel, IEnumerable <NodeModel> e, IEnumerable <ConnectorModel> c, double x, double y)
     : base(dynamoModel, "Home", e, c, x, y)
 {
 }
コード例 #35
0
 internal NodeFactory(WorkspaceModel workspaceModel, DynamoModel dynamoModel)
 {
     this.dynamoModel    = dynamoModel;
     this.workspaceModel = workspaceModel;
 }
コード例 #36
0
 public CustomNodeWorkspaceModel(DynamoModel dynamoModel)
     : this(dynamoModel, "", "", "", new List <NodeModel>(), new List <ConnectorModel>(), 0, 0)
 {
 }
コード例 #37
0
ファイル: WorkspaceHeader.cs プロジェクト: vic-kailiu/Dynamo
        public static WorkspaceHeader FromPath(DynamoModel dynamoModel, string path)
        {
            try
            {
                var xmlDoc = new XmlDocument();
                xmlDoc.Load(path);

                string funName = null;
                double cx      = 0;
                double cy      = 0;
                double zoom    = 1.0;
                string id      = "";

                var topNode = xmlDoc.GetElementsByTagName("Workspace");

                // legacy support
                if (topNode.Count == 0)
                {
                    topNode = xmlDoc.GetElementsByTagName("dynWorkspace");
                }

                // load the header
                foreach (XmlNode node in topNode)
                {
                    foreach (XmlAttribute att in node.Attributes)
                    {
                        if (att.Name.Equals("X"))
                        {
                            cx = double.Parse(att.Value, CultureInfo.InvariantCulture);
                        }
                        else if (att.Name.Equals("Y"))
                        {
                            cy = double.Parse(att.Value, CultureInfo.InvariantCulture);
                        }
                        else if (att.Name.Equals("zoom"))
                        {
                            zoom = double.Parse(att.Value, CultureInfo.InvariantCulture);
                        }
                        else if (att.Name.Equals("Name"))
                        {
                            funName = att.Value;
                        }
                        else if (att.Name.Equals("ID"))
                        {
                            id = att.Value;
                        }
                    }
                }

                // we have a dyf and it lacks an ID field, we need to assign it
                // a deterministic guid based on its name.  By doing it deterministically,
                // files remain compatible
                if (string.IsNullOrEmpty(id) && !string.IsNullOrEmpty(funName) && funName != "Home")
                {
                    id = GuidUtility.Create(GuidUtility.UrlNamespace, funName).ToString();
                }

                return(new WorkspaceHeader()
                {
                    ID = id, Name = funName, X = cx, Y = cy, Zoom = zoom, FileName = path
                });
            }
            catch (Exception ex)
            {
                dynamoModel.Logger.Log("There was an error opening the workbench.");
                dynamoModel.Logger.Log(ex);
                Debug.WriteLine(ex.Message + ":" + ex.StackTrace);

                if (DynamoModel.IsTestMode)
                {
                    throw ex; // Rethrow for NUnit.
                }
                return(null);
            }
        }
コード例 #38
0
ファイル: RecordableCommands.cs プロジェクト: Steell/Dynamo
 protected override void ExecuteCore(DynamoModel dynamoModel)
 {
     // A PausePlaybackCommand should never be executed.
     throw new NotImplementedException();
 }
コード例 #39
0
ファイル: RecordableCommands.cs プロジェクト: Steell/Dynamo
 protected override void ExecuteCore(DynamoModel dynamoModel)
 {
     dynamoModel.SwitchTabImpl(this);
 }
コード例 #40
0
ファイル: RecordableCommands.cs プロジェクト: Steell/Dynamo
 protected override void ExecuteCore(DynamoModel dynamoModel)
 {
     dynamoModel.SendModelEventImpl(this);
 }
コード例 #41
0
ファイル: RecordableCommands.cs プロジェクト: Steell/Dynamo
 protected override void ExecuteCore(DynamoModel dynamoModel)
 {
     dynamoModel.CreateNoteImpl(this);
 }
コード例 #42
0
ファイル: RecordableCommands.cs プロジェクト: Steell/Dynamo
 protected override void ExecuteCore(DynamoModel dynamoModel)
 {
 }
コード例 #43
0
ファイル: RecordableCommands.cs プロジェクト: Steell/Dynamo
 /// <summary>
 /// Call this method to execute a RecordableCommand. A RecordableCommand
 /// must be executed in the context of an existing DynamoViewModel.
 /// </summary>
 /// <param name="dynamoModel">The DynamoModel object this
 /// RecordableCommand is targeting.</param>
 ///
 internal void Execute(DynamoModel dynamoModel)
 {
     ExecuteCore(dynamoModel);
 }
コード例 #44
0
ファイル: RecordableCommands.cs プロジェクト: Steell/Dynamo
 protected override void ExecuteCore(DynamoModel dynamoModel)
 {
     dynamoModel.ForceRunCancelImpl(this);
 }
コード例 #45
0
ファイル: RecordableCommands.cs プロジェクト: Steell/Dynamo
 protected override void ExecuteCore(DynamoModel dynamoModel)
 {
     dynamoModel.OpenFileImpl(this);
 }
コード例 #46
0
ファイル: RecordableCommands.cs プロジェクト: Steell/Dynamo
 protected override void ExecuteCore(DynamoModel dynamoModel)
 {
     dynamoModel.ConvertNodesToCodeImpl(this);
 }
コード例 #47
0
ファイル: RecordableCommands.cs プロジェクト: Steell/Dynamo
 protected override void ExecuteCore(DynamoModel dynamoModel)
 {
     dynamoModel.UndoRedoImpl(this);
 }
コード例 #48
0
ファイル: RecordableCommands.cs プロジェクト: Steell/Dynamo
 protected override void ExecuteCore(DynamoModel dynamoModel)
 {
     dynamoModel.UpdateModelValueImpl(this);
 }
コード例 #49
0
 public CustomNodeWorkspaceModel(DynamoModel dynamoModel, String name, String category)
     : this(dynamoModel, name, category, "", new List <NodeModel>(), new List <ConnectorModel>(), 0, 0)
 {
 }
コード例 #50
0
ファイル: RecordableCommands.cs プロジェクト: Steell/Dynamo
 protected override void ExecuteCore(DynamoModel dynamoModel)
 {
     dynamoModel.MakeConnectionImpl(this);
 }
コード例 #51
0
ファイル: RecordableCommands.cs プロジェクト: Steell/Dynamo
 /// <summary>
 /// Derived classes must implement this method to perform the actual
 /// command execution. A typical implementation of this method involves
 /// calling a corresponding method on DynamoModel by passing itself as
 /// the only argument.
 /// </summary>
 /// <param name="dynamoModel">The DynamoModel object on which
 /// this command should be executed.</param>
 ///
 protected abstract void ExecuteCore(DynamoModel dynamoModel);
コード例 #52
0
ファイル: RecordableCommands.cs プロジェクト: Steell/Dynamo
 protected override void ExecuteCore(DynamoModel dynamoModel)
 {
     dynamoModel.DeleteModelImpl(this);
 }
コード例 #53
0
 public CustomNodeWorkspaceModel(DynamoModel dynamoModel, String name, String category, string description, double x, double y)
     : this(dynamoModel, name, category, description, new List <NodeModel>(), new List <ConnectorModel>(), x, y)
 {
 }