protected virtual void ScrollIntoView(Rectangle rect) { if (!ContentRectangle.Contains(rect)) { int x = -ScrollPosition.X, y = -ScrollPosition.Y; if (ContentRectangle.Bottom < rect.Bottom) { y += rect.Bottom - ContentRectangle.Bottom; } if (ContentRectangle.Top > rect.Top) { y -= ContentRectangle.Top - rect.Top; } if (ContentRectangle.Right < rect.Right) { x += rect.Right - ContentRectangle.Right; } if (ContentRectangle.Left > rect.Left) { x -= ContentRectangle.Left - rect.Left; } ScrollPosition = new Point(x, y); } }
/// <summary> /// Logic for adding an event that is used both in AddEmptyEvent and AddFinishedEvent. /// If addToManager is true, adds the event to the AuthoredEventManager.W /// </summary> private void AddEvent(EventStub currentEvent, bool addToManager) { if (addToManager) { AuthoredEventManager.Instance.AddAuthoredEvent(currentEvent); } for (int i = 0; i < currentEvent.NrOfNeededRoles; i++) { currentEvent.GetSelectorForIndex(i).OnObjectChanged += ((SmartObject o, SmartObject n) => UpdateEventParticipants(currentEvent, o, n)); } connectors.Add(currentEvent, new HashSet<ParticipantConnector>()); rectangleForEvent[currentEvent] = new ContentRectangle<EventStub>(currentEvent, false, new Rect(0, 0, 0, 0), true, EventStubContent); rectangleForEvent[currentEvent].Style = rectangleForEvent[currentEvent].GetContent().image == null ? GUI.skin.button : GUI.skin.GetStyle("ImageBackground"); rectangleForEvent[currentEvent].onRightClick = this.onEventRightClick; rectangleForEvent[currentEvent].onLeftClick = this.onEventLeftClick; rectangleForEvent[currentEvent].onMouseOver = this.onEventMouseOver; rectangleForEvent[currentEvent].onMouseOut = this.onEventMouseOut; rectangleForEvent[currentEvent].RegisterLeftClickAction(StartDragEvent); for (int i = 0; i < currentEvent.NrOfNeededRoles; i++) { connectors[currentEvent].Add(new ParticipantConnector(i, currentEvent, this)); } CalculateEventAndObjectPositions(); }
/// <summary> /// Finish dragging the participant rectangle when the mouse is released. /// </summary> private void OnEndParticipantDrag() { foreach (ContentRectangle<EventStub> rect in rectangleForEvent.Values) { for (int i = 0; i < rect.containedObject.NrOfNeededRoles; i++) { IEnumerable<Texturizer> available = texturizers. Where((Texturizer t) => t.Event == rect.containedObject); if (rect.GetContent().image == null || available.Count() == 0) { continue; } Rect connector = available.First(). GetRectForIndex(zoomLevel * WIDTH_EVENT_RECT, zoomLevel * HEIGHT_EVENT_RECT, i); connector.xMin = connector.xMin + rect.Position.xMin; connector.yMin = connector.yMin + rect.Position.yMin; connector.xMax = connector.xMax + rect.Position.xMin; connector.yMax = connector.yMax + rect.Position.yMin; if (participantDragRect.Position.Contains(connector.center)) { if (rect.containedObject.GetSelectorForIndex(i). TrySet(participantDragRect.containedObject)) { participantDragRect = null; return; } } } } }
/// <summary> /// Gets the start position for drawing/dragging based on the rectangle's position /// and whether the start position should be at the top of the rect or not. /// </summary> private Vector3 GetStartDrawPosition(ContentRectangle rect, bool top) { return new Vector3( rect.Position.xMin + rect.Position.width / 2, rect.Position.yMin + (top ? 0 : rect.Position.height), 0); }
/// <summary> /// Start dragging an event to position it within a new beat. /// </summary> private void StartDragEvent(EventStub current) { eventDragRect = rectangleForEvent[current]; draggingEvent = true; }
/// <summary> /// Start drawing a participant line or start dragging a participant, depending on whether /// ShowLines is true and the participant has an image associated to it. /// </summary> private void StartDrawParticipantLine(SmartObject obj) { if (rectangleForObject[obj].GetContent().image != null && !ShowLines) { ContentRectangle rect = rectangleForObject[obj]; participantDragRect = new ContentRectangle<SmartObject>( obj, false, new Rect(currentMousePosition.x, currentMousePosition.y, rect.Position.width / 2, rect.Position.height / 2), true, ObjectContent); participantDragRect.Style = GUI.skin.GetStyle("ImageBackground"); draggingParticipant = true; } else { ShowLines = true; startDrawRectangle = rectangleForObject[obj]; participant = obj; drawingParticipantConnection = true; } }
/// <summary> /// Creates the daigram /// </summary> /// <param name="businessType">Type of the List to be added</param> private void CreateDiagram(string businessType) { RectangleF rect = new RectangleF(10, 10, 1400, 60); TextNode nodeRectHeader = new TextNode("Safety", rect); nodeRectHeader.BackgroundStyle.Color = Color.FromArgb(84, 167, 167); nodeRectHeader.LineStyle.LineWidth = 1; nodeRectHeader.FontStyle.Size = 32; nodeRectHeader.FontStyle.Bold = true; nodeRectHeader.FontStyle.Italic = true; nodeRectHeader.FontColorStyle.Color = Color.White; nodeRectHeader.ReadOnly = true; nodeRectHeader.HorizontalAlignment = StringAlignment.Near; nodeRectHeader.VerticalAlignment = StringAlignment.Center; nodeRectHeader.EditStyle.AllowSelect = false; //FY10 goal is to provide a safe working environment for our employees.Achieve this through improvement in the key categorie of severity and frequency rates. EllipseRectGroup erg = new EllipseRectGroup(1, "Vision", "Vision-1", Color.Red, Color.Black, Color.LightBlue, Color.White); GridGroup gg = new GridGroup(); HeaderandEllipse he1 = new HeaderandEllipse(2, "Goals", Color.Red, Color.LightBlue, 13); HeaderandEllipse he2 = new HeaderandEllipse(3, "Objectives", Color.Red, Color.LightBlue, 13); HeaderandEllipse he3 = new HeaderandEllipse(4, "Key Tasks", Color.Red, Color.LightBlue, 12); SplitContent spc = new SplitContent("Who \n(leader)", "Resources Investor", Color.LightBlue, true, 12, true); GridGroupShapesandNumber ggsn = new GridGroupShapesandNumber("Schedule(Month)", Color.LightBlue); SplitContent spc2 = new SplitContent("Comments", "Cost Savings", Color.LightBlue, true, 12, true); int nameIndex = 0; List <HoshinKanriListItem> hoshinList = GenerateList(businessType); float contentPinPointY = 400, splitContentPinpointY = 400, gridSymbolPinpointY = 390, subContentPinPointY = 400; for (int i = 0; i < hoshinList.Count; i++) { ContentRectangle content = new ContentRectangle(hoshinList[i].Content, Color.Black, Color.LightGreen, false, 13, true); content.PinPoint = new PointF(10 + content.BoundingRectangle.Width / 2, contentPinPointY + content.BoundingRectangle.Height / 2); diagram1.Model.AppendChild(content); ContentRectangle content1 = new ContentRectangle(hoshinList[i].Content1, Color.Black, Color.LightGreen, false, 10, true); content1.PinPoint = new PointF(230 + content1.BoundingRectangle.Width / 2, contentPinPointY + content1.BoundingRectangle.Height / 2); diagram1.Model.AppendChild(content1); lineconnector = getLineConnectorOrdinary(content.PinPoint, content1.PinPoint); content.CentralPort.TryConnect(lineconnector.HeadEndPoint); content1.CentralPort.TryConnect(lineconnector.TailEndPoint); this.diagram1.Model.AppendChild(lineconnector); for (int j = 0; j < hoshinList[i].Leader.Count; j++) { SplitContent splitContent = new SplitContent(hoshinList[i].Leader[j], hoshinList[i].Resources[j], Color.Gray, false, 10, false); splitContent.Name = "splitContent" + (nameIndex + 1); splitContent.PinPoint = new PointF(690 + splitContent.BoundingRectangle.Width / 2, splitContentPinpointY + splitContent.BoundingRectangle.Height / 2); diagram1.Model.AppendChild(splitContent); GridSymbols gridSymbol = new GridSymbols(hoshinList[i].Plan[j], hoshinList[i].Actual[j], hoshinList[i].ToolTip[j]); gridSymbol.Name = "gridSymbol" + (nameIndex + 1); gridSymbol.PinPoint = new PointF(920 + gridSymbol.BoundingRectangle.Width / 2, 2 + gridSymbolPinpointY + gridSymbol.BoundingRectangle.Height / 2); diagram1.Model.AppendChild(gridSymbol); SplitContent splitContent1 = new SplitContent(hoshinList[i].Comments[j], hoshinList[i].CostSavings[j], Color.LightGray, false, 10, false); splitContent1.Name = "splitContent1" + (nameIndex + 1); splitContent1.PinPoint = new PointF(1160 + splitContent1.BoundingRectangle.Width / 2, splitContentPinpointY + splitContent1.BoundingRectangle.Height / 2); diagram1.Model.AppendChild(splitContent1); if (!hoshinList[i].IsOuterRectangle[j]) { ContentRectangle subContent = new ContentRectangle(hoshinList[i].SubContent[j], Color.Black, Color.LightGreen, false, 10, true); subContent.PinPoint = new PointF(460 + subContent.BoundingRectangle.Width / 2, subContentPinPointY + subContent.BoundingRectangle.Height / 2); diagram1.Model.AppendChild(subContent); lineconnector = getLineConnectorOrdinary(content1.PinPoint, subContent.PinPoint); content1.CentralPort.TryConnect(lineconnector.TailEndPoint); subContent.CentralPort.TryConnect(lineconnector.HeadEndPoint); this.diagram1.Model.AppendChild(lineconnector); lineconnector = getLineConnectorOrdinary(subContent.PinPoint, splitContent.PinPoint); splitContent.CentralPort.TryConnect(lineconnector.TailEndPoint); subContent.CentralPort.TryConnect(lineconnector.HeadEndPoint); this.diagram1.Model.AppendChild(lineconnector); } else { ContentWithOuterRectangle subContent1 = new ContentWithOuterRectangle(hoshinList[i].SubContent[j], "A3", Color.LightGreen, Color.Pink); subContent1.PinPoint = new PointF(460 + subContent1.BoundingRectangle.Width / 2, subContentPinPointY + subContent1.BoundingRectangle.Height / 2 - 20); diagram1.Model.AppendChild(subContent1); orthogoanlConnector = getOrthogonalConnector(content1.PinPoint, subContent1.PinPoint); content1.CentralPort.TryConnect(orthogoanlConnector.TailEndPoint); subContent1.CentralPort.TryConnect(orthogoanlConnector.HeadEndPoint); this.diagram1.Model.AppendChild(orthogoanlConnector); lineconnector = getLineConnectorOrdinary(subContent1.PinPoint, splitContent.PinPoint); splitContent.CentralPort.TryConnect(lineconnector.TailEndPoint); subContent1.CentralPort.TryConnect(lineconnector.HeadEndPoint); this.diagram1.Model.AppendChild(lineconnector); } nameIndex++; //if (!hoshinList[i].IsOuterRectangle[j]) //{ // contentPinPointY += 65; // splitContentPinpointY += 65; gridSymbolPinpointY += 65; subContentPinPointY += 65; //} //else //{ //} contentPinPointY += 85; splitContentPinpointY += 85; gridSymbolPinpointY += 85; subContentPinPointY += 85; //if (j < hoshinList[i].Leader.Count) //{ // if (hoshinList[i].IsOuterRectangle[j]) // { // contentPinPointY += (120-85); // splitContentPinpointY += (130 - 85); gridSymbolPinpointY += (130 - 85); subContentPinPointY += (120 - 85); // } //} } } HeaderRectangleActual actualrect = new HeaderRectangleActual(); HeaderRectanglePlan planrect = new HeaderRectanglePlan(); erg.PinPoint = new PointF(10 + erg.BoundingRectangle.Width / 2, erg.BoundingRectangle.Height / 2 + 120); erg.CentralPort.OffsetX = he1.PinPoint.X; he1.PinPoint = new PointF(10 + he1.BoundingRectangle.Width / 2, 330 + he1.BoundingRectangle.Height / 2); he2.PinPoint = new PointF(230 + he2.BoundingRectangle.Width / 2, 330 + he2.BoundingRectangle.Height / 2); he3.PinPoint = new PointF(460 + he3.BoundingRectangle.Width / 2, 330 + he3.BoundingRectangle.Height / 2); spc.PinPoint = new PointF(690 + spc.BoundingRectangle.Width / 2, 330 + spc.BoundingRectangle.Height / 2); ggsn.PinPoint = new PointF(920 + ggsn.BoundingRectangle.Width / 2, 330 + ggsn.BoundingRectangle.Height / 2); spc2.PinPoint = new PointF(1160 + spc2.BoundingRectangle.Width / 2, 330 + spc2.BoundingRectangle.Height / 2); actualrect.PinPoint = new PointF(630 + actualrect.BoundingRectangle.Width / 2, actualrect.BoundingRectangle.Height / 2 + 103); planrect.PinPoint = new PointF(400 + planrect.BoundingRectangle.Width / 2, planrect.BoundingRectangle.Height / 2 + 103); gg.PinPoint = new PointF(900 + gg.BoundingRectangle.Width / 2, gg.BoundingRectangle.Height / 2 + 143); this.diagram1.Model.AppendChild(erg); this.diagram1.Model.AppendChild(gg); this.diagram1.Model.AppendChild(ggsn); this.diagram1.Model.AppendChild(he1); this.diagram1.Model.AppendChild(he2); this.diagram1.Model.AppendChild(he3); this.diagram1.Model.AppendChild(spc); this.diagram1.Model.AppendChild(spc2); this.diagram1.Model.AppendChild(planrect); this.diagram1.Model.AppendChild(actualrect); this.diagram1.Model.AppendChild(nodeRectHeader); lineconnector = getLineConnector(erg.PinPoint, he1.PinPoint); erg.CentralPort.TryConnect(lineconnector.TailEndPoint); he1.CentralPort.TryConnect(lineconnector.HeadEndPoint); this.diagram1.Model.AppendChild(lineconnector); lineconnector = getLineConnector(he1.PinPoint, he2.PinPoint); he1.CentralPort.TryConnect(lineconnector.TailEndPoint); he2.CentralPort.TryConnect(lineconnector.HeadEndPoint); this.diagram1.Model.AppendChild(lineconnector); lineconnector = getLineConnector(he2.PinPoint, he3.PinPoint); he2.CentralPort.TryConnect(lineconnector.TailEndPoint); he3.CentralPort.TryConnect(lineconnector.HeadEndPoint); this.diagram1.Model.AppendChild(lineconnector); lineconnector = getLineConnector(he3.PinPoint, spc.PinPoint); he3.CentralPort.TryConnect(lineconnector.TailEndPoint); spc.CentralPort.TryConnect(lineconnector.HeadEndPoint); this.diagram1.Model.AppendChild(lineconnector); }
/// <summary> /// Executed when the mouse is released after dragging of an Event started. /// </summary> private void OnEventDragEnd() { if (eventDragRectangle.Position.Overlaps(new Rect(0, HEIGHT_BARS, width - 2 * WIDTH_SIDEBAR, height - HEIGHT_BARS))) { EventStub toAdd = new EventStub(eventDragRectangle.containedObject); mainWindow.AddEmptyEvent(toAdd); for (int i = 0; i < toAdd.NrOfNeededRoles; i++) { toAdd.GetSelectorForIndex(i).OnObjectChanged += (SmartObject o, SmartObject n) => CheckForWaypoint(o); } } eventDragRectangle = null; draggingEvent = false; }
/// <summary> /// Executed when the mouse is released after dragging of a SmartObject started. /// </summary> private void OnParticipantDragEnd() { //check if the rectangle is in the eventstub details window, if yes, add it if (participantDragRectangle.Position.Overlaps(new Rect(0, HEIGHT_BARS, width - 2 * WIDTH_SIDEBAR, height - HEIGHT_BARS))) { mainWindow.AddSmartObject(participantDragRectangle.containedObject); } participantDragRectangle = null; draggingParticipant = false; }
/// <summary> /// Executed when dragging an Event from the sidebar is started. /// </summary> private void OnEventDragStart(EventStub evnt) { dragRectangle = eventDragRectangle = new ContentRectangle<EventStub>(evnt, false, new Rect(Event.current.mousePosition.x + width - 2 * WIDTH_SIDEBAR, Event.current.mousePosition.y + HEIGHT_BARS, 120, 60), true, (EventStub e) => new GUIContent(e.Name)); draggingEvent = true; }
/// <summary> /// Executed when dragging a SmartObject from the sidebar is started. /// </summary> private void OnParticipantDragStart(SmartObject obj) { dragRectangle = participantDragRectangle = new ContentRectangle<SmartObject>(obj, false, new Rect(Event.current.mousePosition.x + width - WIDTH_SIDEBAR, Event.current.mousePosition.y + HEIGHT_BARS, 120, 60), true, ObjectContentString); draggingParticipant = true; }