public void Execute(Shape changedShape, string context) { RationallyModel model = Globals.RationallyAddIn.Model; OpenFileDialog openFileDialog = new OpenFileDialog { CheckFileExists = true, CheckPathExists = true }; if (openFileDialog.ShowDialog() == DialogResult.OK) { VisioShape comp = new VisioShape(Globals.RationallyAddIn.Application.ActivePage) { Shape = changedShape }; int index = comp.Index; //container of all related documents: RelatedDocumentsContainer relatedDocumentsContainer = (RelatedDocumentsContainer)Globals.RationallyAddIn.View.Children.First(c => c is RelatedDocumentsContainer); //find the the RelatedDocumentContainer of the selected file RelatedDocumentContainer documentContainer = (RelatedDocumentContainer)relatedDocumentsContainer.Children.First(f => f.Index == index); RelatedDocument doc = model.Documents[index]; doc.Name = openFileDialog.FileName; doc.Path = openFileDialog.FileName; documentContainer.EditFile(doc, index); RepaintHandler.Repaint(relatedDocumentsContainer); } }
/// <summary> /// Adds a related document to the sheet, with a specified document index /// </summary> /// <param name="document"></param> /// <param name="documentIndex"></param> public void InsertRelatedDocument(RelatedDocument document, int documentIndex) { //create a container that wraps the new document Children.Insert(Math.Min(documentIndex, Globals.RationallyAddIn.Model.Documents.Count - 1), new RelatedDocumentContainer(Globals.RationallyAddIn.Application.ActivePage, documentIndex, document, document.Id)); RepaintHandler.Repaint(this); }
public void Execute(Shape changedShape, string identifier) { RationallyModel model = Globals.RationallyAddIn.Model; ForcesContainer forcesContainer = (ForcesContainer)Globals.RationallyAddIn.View.Children.First(c => c is ForcesContainer); if (forcesContainer.Children.Count == 0) { //insert header, if it is absent if ((forcesContainer.Children.Count == 0) || !forcesContainer.Children.Any(c => c is ForceHeaderRow)) { forcesContainer.Children.Insert(0, new ForceHeaderRow(Globals.RationallyAddIn.Application.ActivePage)); } //insert footer, if it is absent if ((forcesContainer.Children.Count == 0) || !forcesContainer.Children.Any(c => c is ForceTotalsRow)) { forcesContainer.Children.Add(new ForceTotalsRow(Globals.RationallyAddIn.Application.ActivePage)); } else if (forcesContainer.Children.Any(c => c is ForceTotalsRow)) { VisioShape toMove = forcesContainer.Children.First(c => c is ForceTotalsRow); int toMoveIndex = forcesContainer.Children.IndexOf(toMove); VisioShape toSwapWith = forcesContainer.Children.Last(); forcesContainer.Children[forcesContainer.Children.Count - 1] = toMove; forcesContainer.Children[toMoveIndex] = toSwapWith; } } Force newForce = new Force(ForceConcernComponent.DefaultConcern, ForceDescriptionComponent.DefaultDescription); model.Forces.Add(newForce); forcesContainer.Children.Insert(forcesContainer.Children.Count - 1, new ForceContainer(Globals.RationallyAddIn.Application.ActivePage, forcesContainer.Children.Count - 2, newForce.Id)); //update the model as well RepaintHandler.Repaint(forcesContainer); }
public void Execute(Shape changedShape, string identifier) { RationallyModel model = Globals.RationallyAddIn.Model; //locate the stakeholder(component) to move VisioShape toChangeComponent = Globals.RationallyAddIn.View.GetComponentByShape(changedShape); int currentIndex = toChangeComponent.Index; //locate the stakeholder to swap with StakeholdersContainer stakeholdersContainer = (StakeholdersContainer)Globals.RationallyAddIn.View.Children.First(c => c is StakeholdersContainer); StakeholderContainer toChange = (StakeholderContainer)stakeholdersContainer.Children.First(c => (int)c.Shape.CellsU[VisioFormulas.Cell_Index].ResultIU == currentIndex); StakeholderContainer other = (StakeholderContainer)stakeholdersContainer.Children.First(c => (int)c.Shape.CellsU[VisioFormulas.Cell_Index].ResultIU == currentIndex - 1); //swap Stakeholder one = model.Stakeholders[currentIndex]; model.Stakeholders[currentIndex] = model.Stakeholders[currentIndex - 1]; model.Stakeholders[currentIndex - 1] = one; //update the index of the component and his children toChange.SetStakeholderIndex(currentIndex - 1); //same, for the other component other.SetStakeholderIndex(currentIndex); //swap the elements VisioShape temp = stakeholdersContainer.Children[currentIndex]; stakeholdersContainer.Children[currentIndex] = stakeholdersContainer.Children[currentIndex - 1]; stakeholdersContainer.Children[currentIndex - 1] = temp; RepaintHandler.Repaint(); }
public void Execute(Shape changedShape, string identifier) { RationallyModel model = Globals.RationallyAddIn.Model; RelatedDocumentsContainer docsContainer = (RelatedDocumentsContainer)Globals.RationallyAddIn.View.Children.First(c => c is RelatedDocumentsContainer); VisioShape currentComponent = new VisioShape(changedShape.ContainingPage) { Shape = changedShape }; int currentIndex = currentComponent.Index; //swap the forces in the model RelatedDocument currentDoc = model.Documents[currentIndex]; model.Documents[currentIndex] = model.Documents[currentIndex + 1]; model.Documents[currentIndex + 1] = currentDoc; RelatedDocumentContainer toMove = docsContainer.Children.Where(c => c is RelatedDocumentContainer).Cast <RelatedDocumentContainer>().First(c => c.Index == currentIndex); RelatedDocumentContainer toSwapWith = docsContainer.Children.Where(c => c is RelatedDocumentContainer).Cast <RelatedDocumentContainer>().First(c => c.Index == currentIndex + 1); //update the index of the component and his children toMove.SetDocumentIdentifier(currentIndex + 1); //same, for the other component toSwapWith.SetDocumentIdentifier(currentIndex); VisioShape temp = docsContainer.Children[currentIndex]; docsContainer.Children[currentIndex] = docsContainer.Children[currentIndex + 1]; docsContainer.Children[currentIndex + 1] = temp; RepaintHandler.Repaint(docsContainer); }
public void Execute(Shape changedShape, string identifier) { RationallyModel model = Globals.RationallyAddIn.Model; PlanningContainer planningContainer = (PlanningContainer)Globals.RationallyAddIn.View.Children.First(c => c is PlanningContainer); VisioShape toChangeComponent = Globals.RationallyAddIn.View.GetComponentByShape(changedShape); int currentIndex = toChangeComponent.Index; PlanningItemComponent toChange = (PlanningItemComponent)planningContainer.Children.First(c => c.Index == currentIndex); //locate the stakeholder that we are going to swap with PlanningItemComponent other = (PlanningItemComponent)planningContainer.Children.First(c => c.Index == currentIndex + 1); PlanningItem one = model.PlanningItems[currentIndex]; model.PlanningItems[currentIndex] = model.PlanningItems[currentIndex + 1]; model.PlanningItems[currentIndex + 1] = one; //update the index of the component and his children toChange.SetPlanningItemIndex(currentIndex + 1); //same, for the other component other.SetPlanningItemIndex(currentIndex); //swap the elements in the view tree VisioShape temp = planningContainer.Children[currentIndex]; planningContainer.Children[currentIndex] = planningContainer.Children[currentIndex + 1]; planningContainer.Children[currentIndex + 1] = temp; RepaintHandler.Repaint(); }
/// <summary> /// Adds a related document to the sheet. /// </summary> /// <param name="document"></param> public void AddRelatedDocument(RelatedDocument document) { //create a container that wraps the new document Children.Add(new RelatedDocumentContainer(Globals.RationallyAddIn.Application.ActivePage, Globals.RationallyAddIn.Model.Documents.Count - 1, document, document.Id)); RepaintHandler.Repaint(this); }
public static void Execute(int alternativeIndex, string newTitle, string newState) { if (Globals.RationallyAddIn.Model.Alternatives.Count > 0) { Alternative alternative = Globals.RationallyAddIn.Model.Alternatives[alternativeIndex]; alternative.Title = newTitle; alternative.Status = newState; RepaintHandler.Repaint(Globals.RationallyAddIn.View.Children.FirstOrDefault(c => c is AlternativesContainer)); } }
public void Execute(RationallyModel model, Shape changedShape) { Globals.RationallyAddIn.View.Children.RemoveAll(obj => obj.Shape.Equals(changedShape)); Log.Debug("Handler of delete planning container entered."); if (!Globals.RationallyAddIn.View.Children.Any(x => x is PlanningContainer)) { model.PlanningItems.Clear(); Log.Debug("model planning items list emptied."); RepaintHandler.Repaint(); } }
public void Execute(RationallyModel model, Shape changedShape) { Log.Debug("Entered DeleteRelatedDocumentsEventHandler."); Globals.RationallyAddIn.View.Children.RemoveAll(obj => obj.Shape.Equals(changedShape)); if (!Globals.RationallyAddIn.View.Children.Any(x => x is RelatedDocumentsContainer)) { Log.Debug("Deleting documents in document list in model."); model.Documents.Clear(); RepaintHandler.Repaint(); } }
public void Execute(RationallyModel model, Shape forcesContainer) { Log.Debug("Entered DeleteForcesEventHandler."); Globals.RationallyAddIn.View.Children.RemoveAll(obj => obj.Shape.Equals(forcesContainer)); if (!Globals.RationallyAddIn.View.Children.Any(x => x is ForcesContainer)) { model.Forces.Clear(); Log.Debug("Cleared model forces list."); RepaintHandler.Repaint(); } }
public void Execute(RationallyModel model, Shape changedShape) { Globals.RationallyAddIn.View.Children.RemoveAll(obj => obj.Shape.Equals(changedShape)); Log.Debug("Handler of delete stakeholders entered."); if (!Globals.RationallyAddIn.View.Children.Any(x => x is StakeholdersContainer)) { model.Stakeholders.Clear(); Log.Debug("model stakeholders list emptied."); RepaintHandler.Repaint(); } }
public void AddStakeholder(string name, string role) { PleaseWait pleaseWait = new PleaseWait(); pleaseWait.Show(); pleaseWait.Refresh(); Stakeholder stakeholder = new Stakeholder(name, role); Globals.RationallyAddIn.Model.Stakeholders.Add(stakeholder); Children.Add(new StakeholderContainer(Globals.RationallyAddIn.Application.ActivePage, Globals.RationallyAddIn.Model.Stakeholders.Count - 1, stakeholder, stakeholder.Id));//assumes stakeholder is already in the model RepaintHandler.Repaint(this); pleaseWait.Hide(); }
public void AddPlanningItem() { PleaseWait pleaseWait = new PleaseWait(); pleaseWait.Show(); pleaseWait.Refresh(); PlanningItem newItem = new PlanningItem(Constants.DefaultPlanningItemText, false); Globals.RationallyAddIn.Model.PlanningItems.Add(newItem); Children.Add(new PlanningItemComponent(Globals.RationallyAddIn.Application.ActivePage, Globals.RationallyAddIn.Model.PlanningItems.Count - 1, newItem)); RepaintHandler.Repaint(); pleaseWait.Hide(); }
public void Execute(Shape changedShape, string identifier) { RationallyModel model = Globals.RationallyAddIn.Model; AlternativesContainer alternativesContainer = (AlternativesContainer)Globals.RationallyAddIn.View.Children.First(c => c is AlternativesContainer); VisioShape toChangeComponent = Globals.RationallyAddIn.View.GetComponentByShape(changedShape); int currentIndex = toChangeComponent.Index; AlternativeShape toChange = (AlternativeShape)alternativesContainer.Children.First(c => (int)c.Shape.CellsU[VisioFormulas.Cell_Index].ResultIU == currentIndex); //locate the alternative that we are going to swap with AlternativeShape other = (AlternativeShape)alternativesContainer.Children.First(c => (int)c.Shape.CellsU[VisioFormulas.Cell_Index].ResultIU == currentIndex + 1); //swap the items in the model model.Alternatives[currentIndex].GenerateIdentifier(currentIndex + 1); model.Alternatives[currentIndex + 1].GenerateIdentifier(currentIndex); string higherIndex = model.Alternatives[currentIndex].IdentifierString; string oldIndex = model.Alternatives[currentIndex + 1].IdentifierString; Alternative one = model.Alternatives[currentIndex]; model.Alternatives[currentIndex] = model.Alternatives[currentIndex + 1]; model.Alternatives[currentIndex + 1] = one; //update the index of the component and his children toChange.Index = currentIndex + 1; //same, for the other component other.Index = currentIndex; //update the related force column value identifiers ForcesContainer forcesContainer = (ForcesContainer)Globals.RationallyAddIn.View.Children.FirstOrDefault(c => c is ForcesContainer); //set all force value cells with id "higherIndex" to "temp" //set all force value cells with id "oldIndex" to "higherIndex" //set all force value cells with id "temp" to "oldIndex" forcesContainer?.Children.Where(c => c is ForceContainer).Cast <ForceContainer>().ToList().ForEach(fc => fc.Children.Where(fcc => fcc is ForceValueComponent && (((ForceValueComponent)fcc).AlternativeIdentifierString == higherIndex)).Cast <ForceValueComponent>().ToList().ForEach(fvc => fvc.AlternativeIdentifierString = "temp")); forcesContainer?.Children.Where(c => c is ForceContainer).Cast <ForceContainer>().ToList().ForEach(fc => fc.Children.Where(fcc => fcc is ForceValueComponent && (((ForceValueComponent)fcc).AlternativeIdentifierString == oldIndex)).Cast <ForceValueComponent>().ToList().ForEach(fvc => fvc.AlternativeIdentifierString = higherIndex)); forcesContainer?.Children.Where(c => c is ForceContainer).Cast <ForceContainer>().ToList().ForEach(fc => fc.Children.Where(fcc => fcc is ForceValueComponent && (((ForceValueComponent)fcc).AlternativeIdentifierString == "temp")).Cast <ForceValueComponent>().ToList().ForEach(fvc => fvc.AlternativeIdentifierString = oldIndex)); //swap the elements in the view tree VisioShape temp = alternativesContainer.Children[currentIndex]; alternativesContainer.Children[currentIndex] = alternativesContainer.Children[currentIndex + 1]; alternativesContainer.Children[currentIndex + 1] = temp; RepaintHandler.Repaint(); }
public void Execute(RationallyView view, Shape changedShape) { ForcesContainer forcesContainer = (ForcesContainer)view.Children.First(c => c is ForcesContainer); ForceValueComponent forceValue = (ForceValueComponent)view.GetComponentByShape(changedShape); string forceVal = forceValue.Text == string.Empty ? "0" : forceValue.Text; Globals.RationallyAddIn.Model.Forces[forceValue.Index].ForceValueDictionary[forceValue.ForceAlternativeId] = forceVal; RepaintHandler.Repaint(forceValue); //repaint the force value, for coloring ForceTotalsRow forceTotalsRow = forcesContainer.Children.First(c => c is ForceTotalsRow) as ForceTotalsRow; if (forceTotalsRow != null) { RepaintHandler.Repaint(forceTotalsRow.Children.Where(c => c is ForceTotalComponent).FirstOrDefault(c => c.ForceAlternativeId == forceValue.ForceAlternativeId)); } }
public void AddAlternative(string title, string state) { PleaseWait pleaseWait = new PleaseWait(); pleaseWait.Show(); pleaseWait.Refresh(); Log.Debug("About to create Alternative model object"); Alternative newAlternative = new Alternative(title, state); newAlternative.GenerateIdentifier(Globals.RationallyAddIn.Model.Alternatives.Count); Log.Debug("Identifier generated"); Globals.RationallyAddIn.Model.Alternatives.Add(newAlternative); Children.Add(new AlternativeShape(Globals.RationallyAddIn.Application.ActivePage, Globals.RationallyAddIn.Model.Alternatives.Count - 1, newAlternative)); RepaintHandler.Repaint(); pleaseWait.Hide(); }
public void Execute(RationallyModel model, Shape changedShape) { Log.Debug("Entered delete alternative event handler."); //store the rationally type of the last shape, which is responsible for ending the undo scope if (string.IsNullOrEmpty(Globals.RationallyAddIn.LastDelete) && (Globals.RationallyAddIn.StartedUndoState == 0) && !Globals.RationallyAddIn.Application.IsUndoingOrRedoing) { Log.Debug("Starting undo scope."); Globals.RationallyAddIn.LastDelete = changedShape.Name; Globals.RationallyAddIn.StartedUndoState = Globals.RationallyAddIn.Application.BeginUndoScope(DeleteUndoScope); } //trace alternative container in view tree VisioShape alternativeComponent = Globals.RationallyAddIn.View.GetComponentByShape(changedShape); AlternativeShape delete = alternativeComponent as AlternativeShape; if (delete != null) { model.Forces.ForEach(force => force.ForceValueDictionary.Remove(delete.Id)); AlternativeShape containerToDelete = delete; if (!Globals.RationallyAddIn.Application.IsUndoingOrRedoing) { Log.Debug("deleting children of the alternative to delete"); containerToDelete.Children.Where(c => !c.Deleted).ToList().ForEach(c => { c.Deleted = true; c.Shape.DeleteEx((short)VisDeleteFlags.visDeleteNormal); }); //schedule the missing delete events (children not selected during the manual delete) } AlternativesContainer alternativesContainer = (AlternativesContainer)Globals.RationallyAddIn.View.Children.First(c => c is AlternativesContainer); //update model model.Alternatives.RemoveAll(a => a.Id == containerToDelete.Id); Log.Debug("Alternative removed from alternatives container."); //update view tree alternativesContainer.Children.Remove(containerToDelete); model.RegenerateAlternativeIdentifiers(); Log.Debug("Identifiers regenerated of alternatives."); if (!Globals.RationallyAddIn.Application.IsUndoingOrRedoing) { alternativesContainer.MsvSdContainerLocked = true; } RepaintHandler.Repaint(); } }
public void Execute(RationallyModel model, Shape changedShape) { Log.Debug("Entered DeleteRelatedDocumentEventHandler."); //trace documents container in view tree VisioShape documentComponent = Globals.RationallyAddIn.View.GetComponentByShape(changedShape); if (documentComponent is RelatedDocumentContainer) { RelatedDocumentContainer containerToDelete = (RelatedDocumentContainer)documentComponent; if (!Globals.RationallyAddIn.Application.IsUndoingOrRedoing) { Log.Debug("Deleting child shapes of related document..."); containerToDelete.Children.Where(c => !c.Deleted).ToList().ForEach(c => { c.Deleted = true; c.Shape.Delete(); }); //schedule the missing delete events (children not selected during the manual delete) } RelatedDocumentsContainer relatedDocumentsContainer = (RelatedDocumentsContainer)Globals.RationallyAddIn.View.Children.First(c => c is RelatedDocumentsContainer); //update model int docIndex = containerToDelete.Index; /*if (!Globals.RationallyAddIn.Application.IsUndoingOrRedoing) * { * * }*/ Log.Debug("Document being removed from model list..."); model.Documents.RemoveAll(doc => doc.Id == containerToDelete.Id); //update view tree relatedDocumentsContainer.Children.Remove(containerToDelete); Log.Debug("Regenerated identifiers of document list in model."); if (!Globals.RationallyAddIn.Application.IsUndoingOrRedoing) { model.RegenerateDocumentIdentifiers(); relatedDocumentsContainer.MsvSdContainerLocked = true; } RepaintHandler.Repaint(relatedDocumentsContainer); } }
public void Execute(RationallyModel model, Shape changedShape) { Log.Debug("Entered delete planningitem event handler."); //store the rationally type of the last shape, which is responsible for ending the undo scope if (string.IsNullOrEmpty(Globals.RationallyAddIn.LastDelete) && (Globals.RationallyAddIn.StartedUndoState == 0) && !Globals.RationallyAddIn.Application.IsUndoingOrRedoing) { Log.Debug("Starting undo scope."); Globals.RationallyAddIn.LastDelete = changedShape.Name; Globals.RationallyAddIn.StartedUndoState = Globals.RationallyAddIn.Application.BeginUndoScope(DeleteUndoScope); } //trace planning item container in view tree VisioShape planningComponent = Globals.RationallyAddIn.View.GetComponentByShape(changedShape); PlanningItemComponent delete = planningComponent as PlanningItemComponent; if (delete != null) { PlanningItemComponent containerToDelete = delete; if (!Globals.RationallyAddIn.Application.IsUndoingOrRedoing) { Log.Debug("deleting children of the planning item to delete"); containerToDelete.Children.Where(c => !c.Deleted).ToList().ForEach(c => { c.Deleted = true; c.Shape.DeleteEx((short)VisDeleteFlags.visDeleteNormal); }); //schedule the missing delete events (children not selected during the manual delete) } PlanningContainer planningContainer = (PlanningContainer)Globals.RationallyAddIn.View.Children.First(c => c is PlanningContainer); //update model model.PlanningItems.RemoveAll(p => p.Id == containerToDelete.Id); Log.Debug("Planning item removed from planning container."); //update view tree planningContainer.Children.Remove(containerToDelete); model.RegeneratePlanningIdentifiers();//one index no longer exists, so let the view adapt to the new index range if (!Globals.RationallyAddIn.Application.IsUndoingOrRedoing) { planningContainer.MsvSdContainerLocked = true; } RepaintHandler.Repaint(); } }
public void Execute(RationallyModel model, Shape changedShape) { Log.Debug("Entered delete stakeholder event handler."); //store the rationally type of the last shape, which is responsible for ending the undo scope if (string.IsNullOrEmpty(Globals.RationallyAddIn.LastDelete) && (Globals.RationallyAddIn.StartedUndoState == 0) && !Globals.RationallyAddIn.Application.IsUndoingOrRedoing) { Log.Debug("Starting undo scope."); Globals.RationallyAddIn.LastDelete = changedShape.Name; Globals.RationallyAddIn.StartedUndoState = Globals.RationallyAddIn.Application.BeginUndoScope(DeleteUndoScope); } //trace stakeholder container in view tree VisioShape stakeholderComponent = Globals.RationallyAddIn.View.GetComponentByShape(changedShape); StakeholderContainer delete = stakeholderComponent as StakeholderContainer; if (delete != null) { StakeholderContainer containerToDelete = delete; if (!Globals.RationallyAddIn.Application.IsUndoingOrRedoing) { Log.Debug("killing children of the stakeholder to kill"); containerToDelete.Children.Where(c => !c.Deleted).ToList().ForEach(c => { c.Deleted = true; c.Shape.DeleteEx((short)VisDeleteFlags.visDeleteNormal); }); //schedule the missing delete events (children not selected during the manual delete) } StakeholdersContainer stakeholdersContainer = (StakeholdersContainer)Globals.RationallyAddIn.View.Children.First(c => c is StakeholdersContainer); //update model model.Stakeholders.RemoveAll(sth => sth.Id == containerToDelete.Id); Log.Debug("stakeholder removed from stakeholders container."); //update view tree stakeholdersContainer.Children.Remove(containerToDelete); model.RegenerateStakeholderIdentifiers(); if (!Globals.RationallyAddIn.Application.IsUndoingOrRedoing) { stakeholdersContainer.MsvSdContainerLocked = true; } RepaintHandler.Repaint(); } }
private void submit_Click(object sender, EventArgs e) { if (panelList.TrueForAll(panel => panel.IsValid())) { Log.Debug("Everyting is valid."); pleaseWait.Show(); pleaseWait.Refresh(); //wrap all changes that will be triggered by wizard changes in one undo scope int wizardScopeId = Globals.RationallyAddIn.Application.BeginUndoScope("Wizard actions"); CurrentPanel.UpdateModel(); Globals.RationallyAddIn.Model = ModelCopy; Log.Debug("Replaced rationally model by wizard model copy"); Log.Debug($"Check if wizard creates a new document: {DocumentCreation}"); if (DocumentCreation) { Log.Debug($"Create Decision View Header with title {ModelCopy.DecisionName} by {ModelCopy.Author}"); TitleLabel header = new TitleLabel(Globals.RationallyAddIn.Application.ActivePage, ModelCopy.DecisionName); Log.Debug("TitleLabel has been created successfully."); Globals.RationallyAddIn.View.Children.Add(header); Log.Debug("Added title component to the sheet."); //draw the information container InformationContainer informationContainer = new InformationContainer(Globals.RationallyAddIn.Application.ActivePage, ModelCopy.Author, ModelCopy.DateString, ModelCopy.Version); Log.Debug("InformationContainer was created succesfully."); Globals.RationallyAddIn.View.Children.Add(informationContainer); Log.Debug("Added information container to the sheet."); DocumentCreation = false; } Globals.RationallyAddIn.View.Children.FirstOrDefault(c => c is AlternativesContainer)?.Repaint(); //Temporary styling (margin fix) for adding multiple alternatives RepaintHandler.Repaint(); //all changes have been made, close the scope and the wizard Globals.RationallyAddIn.Application.EndUndoScope(wizardScopeId, true); Close(); Log.Debug("Closed wizard"); pleaseWait.Hide(); //TestServerCreateDecision(); } }
public void Execute(RationallyModel model, Shape changedShape) { Log.Debug("Entered DeleteForceEventHandler."); //trace force row in view tree VisioShape forceComponent = Globals.RationallyAddIn.View.GetComponentByShape(changedShape); if (forceComponent is ForceContainer) { ForceContainer containerToDelete = (ForceContainer)forceComponent; if (!Globals.RationallyAddIn.Application.IsUndoingOrRedoing) { Log.Debug("Deleting all child components of the force container..."); containerToDelete.Children.Where(c => !c.Deleted).ToList().ForEach(c => { c.Deleted = true; c.Shape.Delete(); }); //schedule the missing delete events (children not selected during the manual delete) } ForcesContainer forcesContainer = (ForcesContainer)Globals.RationallyAddIn.View.Children.First(c => c is ForcesContainer); //update model if (!Globals.RationallyAddIn.Application.IsUndoingOrRedoing) { model.Forces.RemoveAll(force => force.Id == containerToDelete.Id); Log.Debug("Deleting force from model list of forces."); } //update view tree forcesContainer.Children.Remove(containerToDelete); if (!Globals.RationallyAddIn.Application.IsUndoingOrRedoing) { model.RegenerateForceIdentifiers(); Log.Debug("Regenerated force identifiers in model."); forcesContainer.MsvSdContainerLocked = true; } RepaintHandler.Repaint(forcesContainer); } }
public void Execute(Shape changedShape, string identifier) { RationallyModel model = Globals.RationallyAddIn.Model; ForcesContainer forcesContainer = (ForcesContainer)Globals.RationallyAddIn.View.Children.First(c => c is ForcesContainer); VisioShape currentComponent = new VisioShape(changedShape.ContainingPage) { Shape = changedShape }; int currentForceIndex = currentComponent.Index; int currentChildIndex = currentForceIndex + 1; //swap the forces in the model Force currentForce = model.Forces[currentForceIndex]; model.Forces[currentForceIndex] = model.Forces[currentForceIndex - 1]; model.Forces[currentForceIndex - 1] = currentForce; ForceContainer toMove = forcesContainer.Children.Where(c => c is ForceContainer).Cast <ForceContainer>().First(c => c.Index == currentForceIndex); ForceContainer toSwapWith = forcesContainer.Children.Where(c => c is ForceContainer).Cast <ForceContainer>().First(c => c.Index == currentForceIndex - 1); //update the index of the component and his children toMove.Children.ForEach(c => c.Index = currentForceIndex - 1); toMove.Index = currentForceIndex - 1; //same, for the other component toSwapWith.Children.ForEach(c => c.Index = currentForceIndex); toSwapWith.Index = currentForceIndex; VisioShape temp = forcesContainer.Children[currentChildIndex]; forcesContainer.Children[currentChildIndex] = forcesContainer.Children[currentChildIndex - 1]; forcesContainer.Children[currentChildIndex - 1] = temp; RepaintHandler.Repaint(); }