public WorkspaceComparisonData(WorkspaceModel workspace, EngineController controller) { Guid = workspace.Guid; NodeCount = workspace.Nodes.Count(); ConnectorCount = workspace.Connectors.Count(); GroupCount = workspace.Annotations.Count(); NoteCount = workspace.Notes.Count(); NodeTypeMap = new Dictionary<Guid, Type>(); NodeDataMap = new Dictionary<Guid, List<object>>(); InportCountMap = new Dictionary<Guid, int>(); OutportCountMap = new Dictionary<Guid, int>(); foreach (var n in workspace.Nodes) { NodeTypeMap.Add(n.GUID, n.GetType()); var portvalues = new List<object>(); foreach (var p in n.OutPorts) { var value = n.GetValue(p.Index, controller); if (value.IsCollection) { portvalues.Add(GetStringRepOfCollection(value)); } else { portvalues.Add(value.StringData); } } NodeDataMap.Add(n.GUID, portvalues); InportCountMap.Add(n.GUID, n.InPorts.Count); OutportCountMap.Add(n.GUID, n.OutPorts.Count); } }
public virtual void OnWorkspaceCleared(WorkspaceModel workspace) { if (WorkspaceCleared != null) WorkspaceCleared(workspace); WorkspaceEvents.OnWorkspaceCleared(); }
public NewTagViewController (WorkspaceModel workspace) { this.model = new TagModel () { Workspace = workspace, }; Title = "NewTagTitle".Tr (); }
protected virtual void OnWorkspaceAdded(WorkspaceModel obj) { var handler = WorkspaceAdded; if (handler != null) handler(obj); WorkspaceEvents.OnWorkspaceAdded(obj.Guid, obj.Name, obj.GetType()); }
CreateClientViewModel (WorkspaceModel workspaceModel) { model = new ClientModel { Workspace = workspaceModel }; ServiceContainer.Resolve<ITracker> ().CurrentScreen = "New Client Screen"; }
static void OnWorkspaceAdded(WorkspaceModel obj) { if (obj is CustomNodeWorkspaceModel) Analytics.TrackScreenView("CustomWorkspace"); else Analytics.TrackScreenView("Workspace"); }
public NewClientViewController (WorkspaceModel workspace) { this.model = new ClientModel () { Workspace = workspace, Name = "", }; Title = "NewClientTitle".Tr (); }
public NewProjectViewController (WorkspaceModel workspace, int color) { this.model = Model.Update (new ProjectModel () { Workspace = workspace, Color = color, IsActive = true, }); Title = "NewProjectTitle".Tr (); }
public NewProjectViewController (WorkspaceModel workspace, int color) { model = new ProjectModel { Workspace = workspace, Color = color, IsActive = true, IsPrivate = true }; Title = "NewProjectTitle".Tr (); }
public override void OnCreate (Bundle state) { base.OnCreate (state); timeEntry = Model.ById<TimeEntryModel> (TimeEntryId); workspace = Model.ById<WorkspaceModel> (WorkspaceId); if (workspace == null) { Dismiss (); } }
public static async Task<NewProjectViewModel> Init (Guid workspaceId) { var workspaceModel = new WorkspaceModel (workspaceId); await workspaceModel.LoadAsync (); return new NewProjectViewModel (new ProjectModel { Workspace = workspaceModel, IsActive = true, IsPrivate = true }); }
private void InitializeWorkspaceModel() { var workspaceView = WpfUtilities.FindUpVisualTree<WorkspaceView>(this); if (workspaceView == null) { throw new InvalidOperationException( "InfiniteGridView should be a nested element of WorkspaceView"); } workspaceModel = workspaceView.ViewModel.Model; }
public CreateProjectDialogFragment (TimeEntryModel timeEntry, WorkspaceModel workspace, int color) { var args = new Bundle (); if (timeEntry != null) { args.PutString (TimeEntryIdArgument, timeEntry.Id.ToString ()); } args.PutString (WorkspaceIdArgument, workspace.Id.ToString ()); args.PutInt (ProjectColorArgument, color); Arguments = args; }
/// <summary> /// This method is called by task creator to associate the trace data with /// the current instance of virtual machine. The given WorkspaceModel can /// optionally contain saved trace data in a previous execution session. As /// a side-effect, this method resets "WorkspaceModel.PreloadedTraceData" /// data member to ensure the correctness of the execution flow. /// </summary> /// <param name="controller">Reference to the EngineController on which the /// loaded trace data should be set.</param> /// <param name="workspace">The workspace from which the trace data should /// be retrieved.</param> /// <returns>If the given WorkspaceModel contains saved trace data, this /// method returns true, in which case the task needs to be scheduled. /// Otherwise, the method returns false.</returns> /// internal bool Initialize(EngineController controller, WorkspaceModel workspace) { if (controller == null || (controller.LiveRunnerCore == null)) return false; engineController = controller; traceData = workspace.PreloadedTraceData; TargetedWorkspace = workspace; workspace.PreloadedTraceData = null; return ((traceData != null) && traceData.Any()); }
private void CreateTestData () { workspace = Model.Update (new WorkspaceModel () { RemoteId = 1, Name = "Unit Testing", IsDirty = true, IsPersisted = true, }); user = Model.Update (new UserModel () { RemoteId = 1, Name = "Tester", DefaultWorkspace = workspace, IsDirty = true, IsPersisted = true, }); var project = Model.Update (new ProjectModel () { RemoteId = 1, Name = "Ad design", Workspace = workspace, IsDirty = true, IsPersisted = true, }); Model.Update (new TimeEntryModel () { RemoteId = 1, Description = "Initial concept", State = TimeEntryState.Finished, StartTime = new DateTime (2013, 01, 01, 09, 12, 0, DateTimeKind.Utc), StopTime = new DateTime (2013, 01, 01, 10, 1, 0, DateTimeKind.Utc), Project = project, Workspace = workspace, User = user, IsDirty = true, IsPersisted = true, }); Model.Update (new TimeEntryModel () { RemoteId = 2, Description = "Breakfast", State = TimeEntryState.Finished, StartTime = new DateTime (2013, 01, 01, 10, 12, 0, DateTimeKind.Utc), StopTime = new DateTime (2013, 01, 01, 10, 52, 0, DateTimeKind.Utc), Workspace = workspace, User = user, IsDirty = true, IsPersisted = true, }); }
/// <summary> /// This method is called by codes that intent to start a graph update. /// This method is called on the main thread where node collection in a /// WorkspaceModel can be safely accessed. /// </summary> /// <param name="controller">Reference to an instance of EngineController /// to assist in generating GraphSyncData object for the given set of nodes. /// </param> /// <param name="workspace">Reference to the WorkspaceModel from which a /// set of updated nodes is computed. The EngineController generates the /// resulting GraphSyncData from this list of updated nodes.</param> /// <param name="dynamoLogger"> Logs the error message</param> /// <returns>Returns the list of node id's that will be executed in the next run /// for execution).</returns> internal List<Guid> Initialize(EngineController controller, WorkspaceModel workspace) { try { engineController = controller; TargetedWorkspace = workspace; modifiedNodes = ComputeModifiedNodes(workspace); previewGraphData = engineController.PreviewGraphSyncData(modifiedNodes,verboseLogging); return previewGraphData; } catch (Exception e) { return null; } }
/// <summary> /// This method is called by codes that intent to start a graph update. /// This method is called on the main thread where node collection in a /// WorkspaceModel can be safely accessed. /// </summary> /// <param name="controller">Reference to an instance of EngineController /// to assist in generating GraphSyncData object for the given set of nodes. /// </param> /// <param name="workspace">Reference to the WorkspaceModel from which a /// set of updated nodes is computed. The EngineController generates the /// resulting GraphSyncData from this list of updated nodes.</param> /// <returns>Returns true if there is any GraphSyncData, or false otherwise /// (in which case there will be no need to schedule UpdateGraphAsyncTask /// for execution).</returns> /// internal bool Initialize(EngineController controller, WorkspaceModel workspace) { try { engineController = controller; TargetedWorkspace = workspace; modifiedNodes = ComputeModifiedNodes(workspace); graphSyncData = engineController.ComputeSyncData(modifiedNodes); return graphSyncData != null; } catch (Exception) { return false; } }
public WorkspaceComparisonData(WorkspaceModel workspace) { Guid = workspace.Guid; NodeCount = workspace.Nodes.Count(); ConnectorCount = workspace.Connectors.Count(); GroupCount = workspace.Annotations.Count(); NoteCount = workspace.Notes.Count(); NodeTypeMap = new Dictionary<Guid, Type>(); NodeDataMap = new Dictionary<Guid, object>(); InportCountMap = new Dictionary<Guid, int>(); OutportCountMap = new Dictionary<Guid, int>(); foreach (var n in workspace.Nodes) { NodeTypeMap.Add(n.GUID, n.GetType()); NodeDataMap.Add(n.GUID, n.CachedValue == null? null:n.CachedValue.Data); InportCountMap.Add(n.GUID, n.InPorts.Count); OutportCountMap.Add(n.GUID, n.OutPorts.Count); } }
private static IEnumerable <NodeModel> ComputeModifiedNodes(WorkspaceModel workspace) { return(workspace.Nodes); // TODO(Ben): Implement dirty node subsetting. }
public void Update(string id, WorkspaceModel workspaceModel) => mWorkspaces.ReplaceOne(workspace => workspace.Id == id, workspaceModel);
public WorkspaceSaveEventArgs(WorkspaceModel ws, bool allowCancel) { Workspace = ws; AllowCancel = allowCancel; Success = false; }
public TomDickHarryList(WorkspaceModel workspace) : base(workspace) { }
public static void LoadChartSample(WorkspaceModel workspaceModel) { BusinessApplication.Instance.OpenModel(() => new ChartingForm()); }
/// <summary> /// Get a FunctionDefinition from a workspace. Assumes the FunctionDefinition is already loaded. /// Use IsInitialized to figure out if the FunctionDef is loaded. /// </summary> /// <param name="workspace">The workspace which you'd like to find the Definition for</param> /// <returns>A valid function definition if the FunctionDefinition is already loaded, otherwise null. </returns> public FunctionDefinition GetDefinitionFromWorkspace(WorkspaceModel workspace) { return(this.LoadedCustomNodes.Values.FirstOrDefault((def) => def.WorkspaceModel == workspace)); }
public static void SimpleMap(WorkspaceModel workspaceModel) { BusinessApplication.Instance.OpenModel(() => new SimpleMapRiport()); }
private void ModelWorkspaceCleared(WorkspaceModel workspace) { RaiseCanExecuteUndoRedo(); // Reset workspace state CurrentSpaceViewModel.CancelActiveState(); }
public static T FirstNodeFromWorkspace <T>(this WorkspaceModel model) where T : NodeModel { return(model.Nodes.OfType <T>().FirstOrDefault()); }
/// <summary> /// Returns the file-save dialog with customized file types of Dynamo. /// </summary> /// <param name="workspace"></param> /// <returns>A customized file-save dialog</returns> public FileDialog GetSaveDialog(WorkspaceModel workspace) { FileDialog fileDialog = new SaveFileDialog { AddExtension = true, }; string ext, fltr; if (workspace == HomeSpace) { ext = ".dyn"; fltr = string.Format(Resources.FileDialogDynamoWorkspace,BrandingResourceProvider.ProductName,"*.dyn"); } else { ext = ".dyf"; fltr = string.Format(Resources.FileDialogDynamoCustomNode,BrandingResourceProvider.ProductName,"*.dyf"); } fltr += "|" + string.Format(Resources.FileDialogAllFiles, "*.*"); fileDialog.FileName = workspace.Name + ext; fileDialog.AddExtension = true; fileDialog.DefaultExt = ext; fileDialog.Filter = fltr; return fileDialog; }
/// <summary> /// Requests a message box asking the user to save the workspace and allows saving. /// </summary> /// <param name="workspace">The workspace for which to show the dialog</param> /// <returns>False if the user cancels, otherwise true</returns> public bool AskUserToSaveWorkspaceOrCancel(WorkspaceModel workspace, bool allowCancel = true) { var args = new WorkspaceSaveEventArgs(workspace, allowCancel); OnRequestUserSaveWorkflow(this, args); if (!args.Success) return false; return true; }
private DomainValue EvaluateReference(SharedDomainReferenceNode theExpressionNode, WorkspaceModel theWorkspace) { var sharedDomainName = theExpressionNode.DomainName; var sharedDomainModel = theWorkspace.Model.GetSharedDomainByName(sharedDomainName.Name); var evaluatorContext = new SharedDomainExpressionEvaluatorContext(sharedDomainModel.Expression.Node, theWorkspace); return(SharedDomainExpressionEvaluator.Evaluate(evaluatorContext)); }
/// <summary> /// Evaluate a shared domain reference. /// </summary> /// <param name="theExpressionNode">Shared domain reference node.</param> /// <param name="theWorkspace">The model.</param> /// <returns>Domain value.</returns> internal static DomainValue Evaluate(SharedDomainReferenceNode theExpressionNode, WorkspaceModel theWorkspace) { var evaluator = new DomainExpressionEvaluator(); return(evaluator.EvaluateReference(theExpressionNode, theWorkspace)); }
public Task <bool> UpdateWorkspace(UnitOfWork unitOfWork, WorkspaceModel workspace) { throw new NotImplementedException(); }
protected ReferenceSelection( WorkspaceModel workspaceModel, SelectionType selectionType, SelectionObjectType selectionObjectType, string message, string prefix) : base(workspaceModel, selectionType, selectionObjectType, message, prefix) { }
private bool OpenHomeWorkspace( XmlDocument xmlDoc, WorkspaceInfo workspaceInfo, out WorkspaceModel workspace) { var nodeGraph = NodeGraph.LoadGraphFromXml(xmlDoc, NodeFactory); var newWorkspace = new HomeWorkspaceModel( EngineController, Scheduler, NodeFactory, Utils.LoadTraceDataFromXmlDocument(xmlDoc), nodeGraph.Nodes, nodeGraph.Notes, nodeGraph.Annotations, nodeGraph.Presets, nodeGraph.ElementResolver, workspaceInfo, DebugSettings.VerboseLogging, IsTestMode ); RegisterHomeWorkspace(newWorkspace); workspace = newWorkspace; return true; }
/// <summary> /// Compiles this custom node definition, updating all UI instances to match /// inputs and outputs and registering new definition with the EngineController. /// </summary> /// <param name="controller"></param> public void Compile(EngineController controller) { // If we are loading dyf file, dont compile it until all nodes are loaded // otherwise some intermediate function defintions will be created. // TODO: This is a hack, in reality we should be preventing this from being called at the Workspace.Modified() level --SJE if (IsBeingLoaded) { return; } #region Outputs and Inputs and UI updating #region Find outputs // Find output elements for the node List <Output> outputs = WorkspaceModel.Nodes.OfType <Output>().ToList(); var topMost = new List <Tuple <int, NodeModel> >(); List <string> outNames; // if we found output nodes, add select their inputs // these will serve as the function output if (outputs.Any()) { topMost.AddRange( outputs.Where(x => x.HasInput(0)).Select(x => Tuple.Create(0, x as NodeModel))); outNames = outputs.Select(x => x.Symbol).ToList(); } else { outNames = new List <string>(); // if there are no explicitly defined output nodes // get the top most nodes and set THEM as the output IEnumerable <NodeModel> topMostNodes = WorkspaceModel.GetTopMostNodes(); var rtnPorts = //Grab multiple returns from each node topMostNodes.SelectMany( topNode => //If the node is a recursive instance... topNode is Function && (topNode as Function).Definition == this // infinity output ? new[] { new { portIndex = 0, node = topNode, name = "∞" } } // otherwise, grab all ports with connected outputs and package necessary info : topNode.OutPortData .Select( (port, i) => new { portIndex = i, node = topNode, name = port.NickName }) .Where(x => !topNode.HasOutput(x.portIndex))); foreach (var rtnAndIndex in rtnPorts.Select((rtn, i) => new { rtn, idx = i })) { topMost.Add(Tuple.Create(rtnAndIndex.rtn.portIndex, rtnAndIndex.rtn.node)); outNames.Add(rtnAndIndex.rtn.name ?? rtnAndIndex.idx.ToString()); } } var nameDict = new Dictionary <string, int>(); foreach (var name in outNames) { if (nameDict.ContainsKey(name)) { nameDict[name]++; } else { nameDict[name] = 0; } } nameDict = nameDict.Where(x => x.Value != 0).ToDictionary(x => x.Key, x => x.Value); outNames.Reverse(); var keys = new List <string>(); foreach (var name in outNames) { int amt; if (nameDict.TryGetValue(name, out amt)) { nameDict[name] = amt - 1; keys.Add(name == "" ? amt + ">" : name + amt); } else { keys.Add(name); } } keys.Reverse(); ReturnKeys = keys; #endregion //Find function entry point, and then compile var inputNodes = WorkspaceModel.Nodes.OfType <Symbol>().ToList(); var parameters = inputNodes.Select(x => string.IsNullOrEmpty(x.InputSymbol) ? x.AstIdentifierForPreview.Value: x.InputSymbol); Parameters = inputNodes.Select(x => x.InputSymbol); //Update existing function nodes which point to this function to match its changes var customNodeInstances = dynSettings.Controller.DynamoModel.AllNodes .OfType <Function>() .Where(el => el.Definition != null && el.Definition == this); foreach (var node in customNodeInstances) { node.ResyncWithDefinition(); } //Call OnSave for all saved elements foreach (var node in WorkspaceModel.Nodes) { node.OnSave(); } #endregion controller.GenerateGraphSyncDataForCustomNode( this, WorkspaceModel.Nodes.Where(x => !(x is Symbol)), topMost.Select(x => x.Item2.GetAstIdentifierForOutputIndex(x.Item1) as AssociativeNode).ToList(), parameters); // Not update graph until Run // if (success) // controller.UpdateGraph(); }
/// <summary> /// Adds a workspace to the dynamo model. /// </summary> /// <param name="workspace"></param> private void AddWorkspace(WorkspaceModel workspace) { if (workspace == null) return; Action savedHandler = () => OnWorkspaceSaved(workspace); workspace.WorkspaceSaved += savedHandler; workspace.MessageLogged += LogMessage; workspace.PropertyChanged += OnWorkspacePropertyChanged; workspace.Disposed += () => { workspace.WorkspaceSaved -= savedHandler; workspace.MessageLogged -= LogMessage; workspace.PropertyChanged -= OnWorkspacePropertyChanged; }; _workspaces.Add(workspace); OnWorkspaceAdded(workspace); }
public void AlignSelected(object parameter) { string alignType = parameter.ToString(); if (DynamoSelection.Instance.Selection.Count <= 1) { return; } // All the models in the selection will be modified, // record their current states before anything gets changed. SmartCollection <ISelectable> selection = DynamoSelection.Instance.Selection; IEnumerable <ModelBase> models = selection.OfType <ModelBase>(); WorkspaceModel.RecordModelsForModification(models.ToList(), Model.UndoRecorder); var toAlign = DynamoSelection.Instance.Selection.OfType <ILocatable>().ToList(); switch (alignType) { case "HorizontalCenter": { var xAll = GetSelectionAverageX(); toAlign.ForEach((x) => { x.CenterX = xAll; }); } break; case "HorizontalLeft": { var xAll = GetSelectionMinX(); toAlign.ForEach((x) => { x.X = xAll; }); } break; case "HorizontalRight": { var xAll = GetSelectionMaxX(); toAlign.ForEach((x) => { x.X = xAll - x.Width; }); } break; case "VerticalCenter": { var yAll = GetSelectionAverageY(); toAlign.ForEach((x) => { x.CenterY = yAll; }); } break; case "VerticalTop": { var yAll = GetSelectionMinY(); toAlign.ForEach((x) => { x.Y = yAll; }); } break; case "VerticalBottom": { var yAll = GetSelectionMaxY(); toAlign.ForEach((x) => { x.Y = yAll - x.Height; }); } break; case "VerticalDistribute": { if (DynamoSelection.Instance.Selection.Count <= 2) { return; } var yMin = GetSelectionMinY(); var yMax = GetSelectionMaxY(); var spacing = 0.0; var span = yMax - yMin; var nodeHeightSum = DynamoSelection.Instance.Selection.Where(y => y is ILocatable) .Cast <ILocatable>() .Sum((y) => y.Height); if (span > nodeHeightSum) { spacing = (span - nodeHeightSum) / (DynamoSelection.Instance.Selection.Count - 1); } var cursor = yMin; foreach (var node in toAlign.OrderBy(y => y.Y)) { node.Y = cursor; cursor += node.Height + spacing; } } break; case "HorizontalDistribute": { if (DynamoSelection.Instance.Selection.Count <= 2) { return; } var xMin = GetSelectionMinX(); var xMax = GetSelectionMaxX(); var spacing = 0.0; var span = xMax - xMin; var nodeWidthSum = DynamoSelection.Instance.Selection.Where((x) => x is ILocatable) .Cast <ILocatable>() .Sum((x) => x.Width); // If there is more span than total node width, // distribute the nodes with a gap. If not, leave // the spacing at 0 and the nodes will distribute // up against each other. if (span > nodeWidthSum) { spacing = (span - nodeWidthSum) / (DynamoSelection.Instance.Selection.Count - 1); } var cursor = xMin; foreach (var node in toAlign.OrderBy(x => x.X)) { node.X = cursor; cursor += node.Width + spacing; } } break; } toAlign.ForEach(x => x.ReportPosition()); }
protected virtual void OnWorkspaceCleared(WorkspaceModel workspace) { OnClear(); }
public void CanZoom() { WorkspaceModel workspaceModel = ViewModel.CurrentSpaceViewModel.Model; WorkspaceViewModel workspaceVM = ViewModel.CurrentSpaceViewModel; double zoom; // Test Zoom in zoom = workspaceVM.Zoom; if (ViewModel.ZoomInCommand.CanExecute(null)) { ViewModel.ZoomInCommand.Execute(null); } Assert.Greater(workspaceVM.Zoom, zoom); // Test Zoom out zoom = workspaceVM.Zoom; if (ViewModel.ZoomOutCommand.CanExecute(null)) { ViewModel.ZoomOutCommand.Execute(null); } Assert.Greater(zoom, workspaceVM.Zoom); // Test can set zoom (at random zoom for 10 times) int testLoop = 10; for (int i = 0; i < testLoop; i++) { // Get random number for the zoom double upperBound = WorkspaceViewModel.ZOOM_MAXIMUM; double lowerBound = WorkspaceViewModel.ZOOM_MINIMUM; Random random = new Random(); double randomNumber = random.NextDouble() * (upperBound - lowerBound) + lowerBound; if (ViewModel.CurrentSpaceViewModel.SetZoomCommand.CanExecute(randomNumber)) { ViewModel.CurrentSpaceViewModel.SetZoomCommand.Execute(randomNumber); } // Check Zoom is correct Assert.AreEqual(randomNumber, workspaceVM.Zoom); } // Border Test for Set Zoom // Min zoom zoom = WorkspaceViewModel.ZOOM_MINIMUM; if (workspaceVM.SetZoomCommand.CanExecute(zoom)) { workspaceVM.SetZoomCommand.Execute(zoom); } Assert.AreEqual(zoom, workspaceVM.Zoom); // Zoom out over limit (check that it does not zoom out) if (ViewModel.ZoomOutCommand.CanExecute(null)) { ViewModel.ZoomOutCommand.Execute(null); } Assert.AreEqual(zoom, workspaceVM.Zoom); // Max zoom zoom = WorkspaceViewModel.ZOOM_MAXIMUM; if (workspaceVM.SetZoomCommand.CanExecute(zoom)) { workspaceVM.SetZoomCommand.Execute(zoom); } Assert.AreEqual(zoom, workspaceVM.Zoom); // Zoom in over limit (check that it does not zoom in) if (ViewModel.ZoomInCommand.CanExecute(null)) { ViewModel.ZoomInCommand.Execute(null); } Assert.AreEqual(zoom, workspaceVM.Zoom); // Above Max Limit Test zoom = WorkspaceViewModel.ZOOM_MAXIMUM + 0.1; if (workspaceVM.SetZoomCommand.CanExecute(zoom)) { workspaceVM.SetZoomCommand.Execute(zoom); } Assert.AreNotEqual(zoom, workspaceVM.Zoom); // Below Min Limit Test zoom = WorkspaceViewModel.ZOOM_MINIMUM - 0.1; if (workspaceVM.SetZoomCommand.CanExecute(zoom)) { workspaceVM.SetZoomCommand.Execute(zoom); } Assert.AreNotEqual(zoom, workspaceVM.Zoom); // Stress Test // Zoom in and out repeatly for (int i = 0; i < 20; i++) { for (int stepIn = 0; stepIn < 20; stepIn++) { if (ViewModel.ZoomInCommand.CanExecute(null)) { ViewModel.ZoomInCommand.Execute(null); } } for (int stepOut = 0; stepOut < 20; stepOut++) { if (ViewModel.ZoomOutCommand.CanExecute(null)) { ViewModel.ZoomOutCommand.Execute(null); } } } // Doesn't crash the system Assert.True(true); }
public string Create(WorkspaceModel workspace) { mWorkspaces.InsertOne(workspace); return(workspace.Id); }
public void Initialize() { Subject = CreateWorkspace(); }
public static NodeModel NodeFromWorkspace(this WorkspaceModel ws, Guid guid) { return(ws.Nodes.FirstOrDefault(node => node.GUID == guid)); }
protected DSFunctionBase(WorkspaceModel workspaceModel, ZeroTouchNodeController controller) : base(workspaceModel, controller) { ArgumentLacing = LacingStrategy.Shortest; }
private void Slider_OnDragStarted(object sender, DragStartedEventArgs e) { var undoRecorder = ui.ViewModel.WorkspaceViewModel.Model.UndoRecorder; WorkspaceModel.RecordModelForModification(nodeModel, undoRecorder); }
public DoubleSlider(WorkspaceModel workspace) : base(workspace) { Value = 0; Min = 0; Max = 100; }
public static NodeModel GetDSFunctionNodeFromWorkspace(this WorkspaceModel model, string nodeName) { return(model.Nodes.FirstOrDefault(node => node is DSFunction && node.Name == nodeName)); }
/// <summary> /// Attempts to save a given workspace. Shows a save as dialog if the /// workspace does not already have a path associated with it /// </summary> /// <param name="workspace">The workspace for which to show the dialog</param> /// <returns>true if save was successful, false otherwise</returns> internal bool ShowSaveDialogIfNeededAndSave(WorkspaceModel workspace) { // crash sould always allow save as if (!String.IsNullOrEmpty(workspace.FileName) && !DynamoModel.IsCrashing) { workspace.Save(EngineController.LiveRunnerRuntimeCore); return true; } else { //TODO(ben): We still add a cancel button to the save dialog if we're crashing // sadly it's not usually possible to cancel a crash var fd = this.GetSaveDialog(workspace); if (fd.ShowDialog() == DialogResult.OK) { workspace.SaveAs(fd.FileName, EngineController.LiveRunnerRuntimeCore); return true; } } return false; }
public static void LoadSimpleWorkflowForm(WorkspaceModel workspaceModel) { BusinessApplication.Instance.OpenModel(() => new SimpleWorkflowForm()); }
private void ModelWorkspaceSaved(WorkspaceModel model) { this.AddToRecentFiles(model.FileName); }
public static void OpenLibrary(Application anApp, string aName, string aLang) { PdOOM.BaseObject modelObject; WorkspaceModel model = RetrieveModelByFile(anApp, aName); if (model == null) { Workspace activeWorkspace = (Workspace)anApp.ActiveWorkspace; if (activeWorkspace == null) { throw new Exception("Unable to reach the Workspace"); } modelObject = (PdOOM.BaseObject)activeWorkspace.AddDocument(aName, -1); if (modelObject == null) { return; } model = (WorkspaceModel)modelObject; } Model aModel = null; if (model.ModelKind == 0x18112060) { modelObject = (PdOOM.BaseObject)model.ModelObject; if (modelObject == null) { long interactiveMode = (long)anApp.InteractiveMode; anApp.InteractiveMode = InteractiveModeValue.im_Batch; try { modelObject = (PdOOM.BaseObject)model.Open(); } catch (Exception exception) { if (LZ.Reverse.Info._bDebug) { LZ.Reverse.Info.Write(new string[] { exception.StackTrace }); } } finally { anApp.InteractiveMode = (InteractiveModeValue)((int)interactiveMode); } } if (modelObject != null) { aModel = (Model)modelObject; ObjectLanguage objectLanguage = (ObjectLanguage)aModel.ObjectLanguage; if (objectLanguage.Name == aLang) { string name; if (aModel.Name != aModel.Code) { name = aModel.Name + " (" + aModel.Code + ")"; } else { name = aModel.Name; } LZ.Reverse.Info.Write(new string[] { "... indexation of the library \"{0}\"", name }); IndexModelClassifiers(aModel); } } } }
/// <summary> /// Uses the init function to evaluate this rule and return a collection of evaluation results /// </summary> /// <param name="workspaceModel"></param> /// <returns></returns> private protected abstract List <IRuleEvaluationResult> InitializeRule(WorkspaceModel workspaceModel);
private bool OpenFile(WorkspaceInfo workspaceInfo, XmlDocument xmlDoc, out WorkspaceModel workspace) { CustomNodeManager.AddUninitializedCustomNodesInPath( Path.GetDirectoryName(workspaceInfo.FileName), IsTestMode); var result = workspaceInfo.IsCustomNodeWorkspace ? CustomNodeManager.OpenCustomNodeWorkspace(xmlDoc, workspaceInfo, IsTestMode, out workspace) : OpenHomeWorkspace(xmlDoc, workspaceInfo, out workspace); workspace.OnCurrentOffsetChanged( this, new PointEventArgs(new Point2D(workspaceInfo.X, workspaceInfo.Y))); return result; }
/// <summary> /// Uses the cleanup function to allow a rule to get rid of any transient data /// it might have stored before the workspace model is disposed /// </summary> /// <param name="muribundWorkspaceModel"></param> /// <returns></returns> internal protected virtual void CleanupRule(WorkspaceModel muribundWorkspaceModel) { }
/// <summary> /// Remove a workspace from the dynamo model. /// </summary> /// <param name="workspace">Workspace to remove</param> public void RemoveWorkspace(WorkspaceModel workspace) { OnWorkspaceRemoveStarted(workspace); if (_workspaces.Remove(workspace)) { if (workspace is HomeWorkspaceModel) { workspace.Dispose(); } OnWorkspaceRemoved(workspace); } }
private void DoGraphAutoLayout(object o) { if (Model.Nodes.Count() == 0) { return; } var graph = new GraphLayout.Graph(); var models = new Dictionary <ModelBase, UndoRedoRecorder.UserAction>(); foreach (AnnotationModel n in Model.Annotations) { // Treat a group as a graph layout node/vertex graph.AddNode(n.GUID, n.Width, n.Height, n.Y); models.Add(n, UndoRedoRecorder.UserAction.Modification); } foreach (NodeModel n in Model.Nodes) { AnnotationModel group = Model.Annotations.Where( s => s.SelectedModels.Contains(n)).ToList().FirstOrDefault(); // Do not process nodes within groups if (group == null) { graph.AddNode(n.GUID, n.Width, n.Height, n.Y, n.InPorts.Count); models.Add(n, UndoRedoRecorder.UserAction.Modification); } } foreach (ConnectorModel x in Model.Connectors) { AnnotationModel startGroup = null, endGroup = null; startGroup = Model.Annotations.Where( s => s.SelectedModels.Contains(x.Start.Owner)).ToList().FirstOrDefault(); endGroup = Model.Annotations.Where( s => s.SelectedModels.Contains(x.End.Owner)).ToList().FirstOrDefault(); // Connector does not belong to any group if ((startGroup == null) && (endGroup == null)) { graph.AddEdge(x.Start.Owner.GUID, x.End.Owner.GUID, x.Start.Center.Y, x.End.Center.Y); } // Connector starts from a node within a group else if ((startGroup != null) && (endGroup == null)) { graph.AddEdge(startGroup.GUID, x.End.Owner.GUID, x.Start.Center.Y, x.End.Center.Y); } // Connector ends at a node within a group else if ((startGroup == null) && (endGroup != null)) { graph.AddEdge(x.Start.Owner.GUID, endGroup.GUID, x.Start.Center.Y, x.End.Center.Y); } models.Add(x, UndoRedoRecorder.UserAction.Modification); } // Support undo for graph layout command WorkspaceModel.RecordModelsForModification(new List <ModelBase>(Model.Nodes), Model.UndoRecorder); // Sugiyama algorithm steps graph.RemoveCycles(); graph.AssignLayers(); graph.OrderNodes(); graph.NormalizeGraphPosition(); // Assign coordinates to nodes inside groups foreach (var x in Model.Annotations) { var id = x.GUID; double deltaX = graph.FindNode(id).X - x.X; double deltaY = graph.FindNode(id).Y - x.Y; foreach (var n in x.SelectedModels) { n.X += deltaX; n.Y += deltaY; n.ReportPosition(); } } // Assign coordinates to nodes outside groups foreach (var x in Model.Nodes) { var n = graph.FindNode(x.GUID); if (n != null) { x.X = n.X; x.Y = n.Y; x.ReportPosition(); } } // Fit view to the new graph layout DynamoSelection.Instance.ClearSelection(); ResetFitViewToggle(null); FitViewInternal(); }
internal void OnWorkspaceSaved(WorkspaceModel model) { if (WorkspaceSaved != null) WorkspaceSaved(model); }
public WorkspaceViewModel(WorkspaceModel model, DynamoViewModel dynamoViewModel) { this.DynamoViewModel = dynamoViewModel; this.DynamoViewModel.PropertyChanged += DynamoViewModel_PropertyChanged; Model = model; stateMachine = new StateMachine(this); var nodesColl = new CollectionContainer { Collection = Nodes }; _workspaceElements.Add(nodesColl); var connColl = new CollectionContainer { Collection = Connectors }; _workspaceElements.Add(connColl); var notesColl = new CollectionContainer { Collection = Notes }; _workspaceElements.Add(notesColl); var errorsColl = new CollectionContainer { Collection = Errors }; _workspaceElements.Add(errorsColl); var annotationsColl = new CollectionContainer { Collection = Annotations }; _workspaceElements.Add(annotationsColl); //respond to collection changes on the model by creating new view models //currently, view models are added for notes and nodes //connector view models are added during connection Model.NodeAdded += Model_NodeAdded; Model.NodeRemoved += Model_NodeRemoved; Model.NodesCleared += Model_NodesCleared; Model.NoteAdded += Model_NoteAdded; Model.NoteRemoved += Model_NoteRemoved; Model.NotesCleared += Model_NotesCleared; Model.AnnotationAdded += Model_AnnotationAdded; Model.AnnotationRemoved += Model_AnnotationRemoved; Model.AnnotationsCleared += Model_AnnotationsCleared; Model.ConnectorAdded += Connectors_ConnectorAdded; Model.ConnectorDeleted += Connectors_ConnectorDeleted; Model.PropertyChanged += ModelPropertyChanged; DynamoSelection.Instance.Selection.CollectionChanged += (sender, e) => RefreshViewOnSelectionChange(); // sync collections foreach (NodeModel node in Model.Nodes) { Model_NodeAdded(node); } foreach (NoteModel note in Model.Notes) { Model_NoteAdded(note); } foreach (AnnotationModel annotation in Model.Annotations) { Model_AnnotationAdded(annotation); } foreach (ConnectorModel connector in Model.Connectors) { Connectors_ConnectorAdded(connector); } InCanvasSearchViewModel = new SearchViewModel(DynamoViewModel); InCanvasSearchViewModel.Visible = true; }
private void OnWorkspaceRemoved(WorkspaceModel workspace) { workspace.Saving -= OnWorkspaceSaving; workspace.NodeAdded -= OnNodeAddedToWorkspace; workspace.NodeRemoved -= OnNodeRemovedFromWorkspace; foreach (var node in workspace.Nodes) { UnregisterNodeEventHandlers(node); } OnClear(); }
public static void OpenBrowser(WorkspaceModel workspaceModel) { BusinessApplication.Instance.OpenModel(() => new BrowserModel()); }