public GraphicHelper(CachedRepository repository, Project project, Diagram tableDiagram, Display tableDisplay) { Project = project; Repository = repository; TableDiagram = tableDiagram; TableDisplay = tableDisplay; }
private void AdjustZoomToDiagram(Display dsp, Diagram dispDiagram) { int minX = int.MaxValue, maxX = int.MinValue, minY = int.MaxValue, maxY = int.MinValue; var shapes = dispDiagram.Shapes.ToList(); foreach (Shape shape in shapes) { var shapeRect = shape.GetBoundingRectangle(true); if (shapeRect.X < minX) minX = shapeRect.X; if (shapeRect.Y < minY) minY = shapeRect.Y; if (shapeRect.X + shapeRect.Width > maxX) maxX = shapeRect.X + shapeRect.Width; if (shapeRect.Y + shapeRect.Height > maxY) maxY = shapeRect.Y + shapeRect.Height; } var viewRect = new Rectangle(minX, minY, maxX - minX, maxY - minY); dsp.ZoomLevel = 400; dsp.EnsureVisible(dispDiagram.Shapes.ElementAt(0)); dsp.EnsureVisible(viewRect); dsp.ZoomLevel -= (dsp.ZoomLevel/5)*2; }
private void CreateDisplayForDiagram(Diagram diagram) { if (FindDisplayTabPage(diagram) == null) { // Create a new ownerDisplay Display display = new Display(); display.Name = string.Format("Display{0}", displayTabControl.TabCount + 1); display.BackColor = Color.DarkGray; display.HighQualityRendering = HighQuality; display.HighQualityBackground = HighQuality; display.ShowGrid = ShowGrid; display.GridSize = GridSize; display.SnapToGrid = SnapToGrid; display.SnapDistance = SnapDistance; display.GripSize = ControlPointSize; display.ResizeGripShape = ResizePointShape; display.ConnectionPointShape = ConnectionPointShape; display.ZoomLevel = Zoom; #if DEBUG_UI display.ShowCellOccupation = ShowCellOccupation; display.ShowInvalidatedAreas = ShowInvalidatedAreas; #endif display.Dock = DockStyle.Fill; // // Assign DiagramSetController and diagram display.PropertyController = propertyController; display.DiagramSetController = diagramSetController; display.Diagram = diagram; display.CurrentTool = toolSetController.SelectedTool; //display.UserMessage += display_UserMessage; // // Create and add a new tabPage for the display TabPage tabPage = new TabPage(diagram.Title); tabPage.Controls.Add(display); displayTabControl.TabPages.Add(tabPage); displayTabControl.SelectedTab = tabPage; displaysTabControl_SelectedIndexChanged(displayTabControl, EventArgs.Empty); } UpdateAllMenuItems(); }
private void CreateDiagramTab(Diagram diagram) { // Create tab items and add them to the tab control TabItem tabItem = new TabItem(); tabItem.Header = diagram.Title; tabControl.Items.Add(tabItem); // Create a new grid to host other controls Grid grid = new Grid(); // Create WindowsFormsHost and add it to grid System.Windows.Forms.Integration.WindowsFormsHost displayHost = new System.Windows.Forms.Integration.WindowsFormsHost(); grid.Children.Add(displayHost); // Create display and assign it to the WinFormsHost // Display display = new Display(); // Connect with other NSHape components display.DiagramSetController = diagramSetController; display.PropertyController = propertyController; display.Diagram = diagram; // Setup display properties display.BackColor = System.Drawing.Color.FromKnownColor(System.Drawing.KnownColor.ControlDark); display.BackColorGradient = System.Drawing.Color.FromKnownColor(System.Drawing.KnownColor.ControlLight); display.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle; displayHost.Child = display; // Set the grid as the content of a tab item tabItem.Content = grid; }
private void UnregisterDisplayEvents(Display display) { if (display != null) { display.Scroll -= display_Scroll; display.Resize -= display_Resize; display.MouseMove -= display_MouseMove; display.ShapesSelected -= display_ShapesSelected; display.ShapesInserted -= display_ShapesInserted; display.ShapesRemoved -= display_ShapesRemoved; display.ZoomChanged -= display_ZoomChanged; } }