1 | using System;
|
---|
2 | using System.Collections.Generic;
|
---|
3 | using System.ComponentModel;
|
---|
4 | using System.Drawing;
|
---|
5 | using System.Data;
|
---|
6 | using System.Linq;
|
---|
7 | using System.Text;
|
---|
8 | using System.Windows.Forms;
|
---|
9 |
|
---|
10 | using Netron.Diagramming.Core;
|
---|
11 |
|
---|
12 | namespace HeuristicLab.Netron {
|
---|
13 | [ToolboxItem(true)]
|
---|
14 | public partial class NetronVisualization : DiagramControlBase {
|
---|
15 | public NetronVisualization()
|
---|
16 | : base() {
|
---|
17 | InitializeComponent();
|
---|
18 |
|
---|
19 | SetStyle(ControlStyles.AllPaintingInWmPaint, true);
|
---|
20 | SetStyle(ControlStyles.DoubleBuffer, true);
|
---|
21 | SetStyle(ControlStyles.UserPaint, true);
|
---|
22 | SetStyle(ControlStyles.ResizeRedraw, true);
|
---|
23 |
|
---|
24 | if (!DesignMode) {
|
---|
25 | this.Controller = new Controller(this);
|
---|
26 | this.View = new View(this);
|
---|
27 |
|
---|
28 | this.Document = new Document();
|
---|
29 | this.AttachToDocument(Document);
|
---|
30 | this.Controller.View = View;
|
---|
31 | TextEditor.Init(this);
|
---|
32 |
|
---|
33 | View.OnCursorChange += new EventHandler<CursorEventArgs>(mView_OnCursorChange);
|
---|
34 | View.OnBackColorChange += new EventHandler<ColorEventArgs>(View_OnBackColorChange);
|
---|
35 |
|
---|
36 | this.SizeChanged += new EventHandler(AlgorithmVisualization_SizeChanged);
|
---|
37 | this.AllowDrop = true;
|
---|
38 | }
|
---|
39 | }
|
---|
40 |
|
---|
41 | void AlgorithmVisualization_SizeChanged(object sender, EventArgs e) {
|
---|
42 | Size newSize = new Size((int) (this.Size.Width * this.View.Magnification.Width),
|
---|
43 | (int) (this.Size.Height * this.View.Magnification.Height));
|
---|
44 | this.View.PageSize = newSize;
|
---|
45 | }
|
---|
46 |
|
---|
47 | protected override void OnScroll(ScrollEventArgs se) {
|
---|
48 | //base.OnScroll(se);
|
---|
49 | if (se.ScrollOrientation == ScrollOrientation.HorizontalScroll) {
|
---|
50 | Origin = new Point(se.NewValue, Origin.Y);
|
---|
51 | //System.Diagnostics.Trace.WriteLine(se.NewValue);
|
---|
52 | } else {
|
---|
53 | Origin = new Point(Origin.X, se.NewValue);
|
---|
54 | //System.Diagnostics.Trace.WriteLine(se.NewValue);
|
---|
55 | }
|
---|
56 | }
|
---|
57 |
|
---|
58 | private void mView_OnCursorChange(object sender, CursorEventArgs e) {
|
---|
59 | this.Cursor = e.Cursor;
|
---|
60 | }
|
---|
61 | }
|
---|
62 | }
|
---|