Free cookie consent management tool by TermsFeed Policy Generator

source: trunk/sources/HeuristicLab.ExtLibs/HeuristicLab.Netron/3.0.2672.12446/HeuristicLab.Netron-3.0.2672.12446/NetronVisualization.cs @ 2801

Last change on this file since 2801 was 2801, checked in by mkommend, 14 years ago

added first version of OperatorGraphVisualization (ticket #867)

File size: 3.6 KB
Line 
1#region License Information
2/* HeuristicLab
3 * Copyright (C) 2002-2010 Heuristic and Evolutionary Algorithms Laboratory (HEAL)
4 *
5 * This file is part of HeuristicLab.
6 *
7 * HeuristicLab is free software: you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License as published by
9 * the Free Software Foundation, either version 3 of the License, or
10 * (at your option) any later version.
11 *
12 * HeuristicLab is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
15 * GNU General Public License for more details.
16 *
17 * You should have received a copy of the GNU General Public License
18 * along with HeuristicLab. If not, see <http://www.gnu.org/licenses/>.
19 */
20#endregion
21
22using System;
23using System.Collections.Generic;
24using System.ComponentModel;
25using System.Drawing;
26using System.Data;
27using System.Linq;
28using System.Text;
29using System.Windows.Forms;
30
31using Netron.Diagramming.Core;
32
33namespace HeuristicLab.Netron {
34  [ToolboxItem(true)]
35  public partial class NetronVisualization : DiagramControlBase {
36    private static Size INVALID_SIZE = new Size(-1, -1);
37    private Size oldSize;
38    public NetronVisualization()
39      : base() {
40      InitializeComponent();
41      this.oldSize = INVALID_SIZE;
42
43      SetStyle(ControlStyles.AllPaintingInWmPaint, true);
44      SetStyle(ControlStyles.DoubleBuffer, true);
45      SetStyle(ControlStyles.UserPaint, true);
46      SetStyle(ControlStyles.ResizeRedraw, true);
47
48      if (!DesignMode) {
49        this.Controller = new Controller(this);
50        this.View = new View(this);
51
52        this.Document = new Document();
53        this.AttachToDocument(Document);
54        this.Controller.View = View;
55        TextEditor.Init(this);
56
57        View.OnCursorChange += new EventHandler<CursorEventArgs>(mView_OnCursorChange);
58        View.OnBackColorChange += new EventHandler<ColorEventArgs>(View_OnBackColorChange);
59
60        this.SizeChanged += new EventHandler(NetronVisualization_SizeChanged);
61        this.AllowDrop = true;
62      }
63    }
64
65    private void NetronVisualization_SizeChanged(object sender, EventArgs e) {
66      //if (this.oldSize == INVALID_SIZE) {
67        this.View.PageSize = new Size((int)(this.Size.Width * this.Magnification.Width), (int)(this.Size.Height * this.Magnification.Height));
68      //  if (!this.DesignMode)
69      //    oldSize = this.Size;
70      //  return;
71      //}
72
73      //SizeF magnificationChanges = new SizeF();
74      //magnificationChanges.Width = ((float)this.Size.Width) / oldSize.Width;
75      //magnificationChanges.Height = ((float)this.Size.Height) / oldSize.Height;
76
77      //SizeF newMagnification = new SizeF();
78      //newMagnification.Width = this.View.Magnification.Width * magnificationChanges.Width;
79      //newMagnification.Height = this.View.Magnification.Height * magnificationChanges.Height;
80
81      //this.Magnification = newMagnification;
82      //this.oldSize = this.Size;
83    }
84
85    protected override void OnScroll(ScrollEventArgs se) {
86      //base.OnScroll(se);
87      if (se.ScrollOrientation == ScrollOrientation.HorizontalScroll) {
88        Origin = new Point(se.NewValue, Origin.Y);
89        //System.Diagnostics.Trace.WriteLine(se.NewValue);
90      } else {
91        Origin = new Point(Origin.X, se.NewValue);
92        //System.Diagnostics.Trace.WriteLine(se.NewValue);
93      }
94    }
95
96    private void mView_OnCursorChange(object sender, CursorEventArgs e) {
97      this.Cursor = e.Cursor;
98    }
99  }
100}
Note: See TracBrowser for help on using the repository browser.