source: trunk/CrypPlugins/WorkspaceManager/View/Container/ConnectorView.xaml.cs @ 1680

Last change on this file since 1680 was 1680, checked in by kopal, 12 years ago
  • Execution now is always triggered when one input changed and provides also old inputs
  • Added support for dynamic Connectors
  • some small bug fixing
File size: 3.6 KB
Line 
1using System;
2using System.Collections.Generic;
3using System.Linq;
4using System.Text;
5using System.Windows;
6using System.Windows.Controls;
7using System.Windows.Data;
8using System.Windows.Documents;
9using System.Windows.Input;
10using System.Windows.Media;
11using System.Windows.Media.Imaging;
12using System.Windows.Navigation;
13using System.Windows.Shapes;
14using WorkspaceManager.View.Interface;
15using System.ComponentModel;
16using WorkspaceManager.Model;
17
18namespace WorkspaceManager.View.Container
19{
20    /// <summary>
21    /// Interaction logic for ConnectorView.xaml
22    /// </summary>
23    public partial class ConnectorView : UserControl, IConnectable, IUpdateableView
24    {
25        public static readonly DependencyProperty PositionOnWorkSpaceXProperty = DependencyProperty.Register("PositionOnWorkSpaceX", typeof(double), typeof(ConnectorView), new FrameworkPropertyMetadata(0.0, FrameworkPropertyMetadataOptions.AffectsRender | FrameworkPropertyMetadataOptions.AffectsMeasure));
26        public static readonly DependencyProperty PositionOnWorkSpaceYProperty = DependencyProperty.Register("PositionOnWorkSpaceY", typeof(double), typeof(ConnectorView), new FrameworkPropertyMetadata(0.0, FrameworkPropertyMetadataOptions.AffectsRender | FrameworkPropertyMetadataOptions.AffectsMeasure));
27
28        public event EventHandler<ConnectorViewEventArgs> OnConnectorMouseLeftButtonDown;
29        public ConnectorModel model;
30        public ConnectorModel Model
31        {
32            get { return model; }
33            private set { model = value; }
34        }
35
36        [TypeConverter(typeof(LengthConverter))]
37        public double PositionOnWorkSpaceX
38        {
39            get { return (double)base.GetValue(PositionOnWorkSpaceXProperty); }
40            set
41            {
42                base.SetValue(PositionOnWorkSpaceXProperty, value);
43            }
44        }
45
46        [TypeConverter(typeof(LengthConverter))]
47        public double PositionOnWorkSpaceY
48        {
49            get { return (double)base.GetValue(PositionOnWorkSpaceYProperty); }
50            set
51            {
52                base.SetValue(PositionOnWorkSpaceYProperty, value);
53            }
54        }
55
56        public ConnectorView()
57        {
58            this.MouseLeftButtonDown += new MouseButtonEventHandler(ConnectorView_MouseLeftButtonDown);
59            InitializeComponent();
60        }
61
62        public ConnectorView(Model.ConnectorModel cModel)
63        {                       
64            this.MouseLeftButtonDown += new MouseButtonEventHandler(ConnectorView_MouseLeftButtonDown);
65            this.Model = cModel;
66            this.Model.UpdateableView = this;
67            InitializeComponent();
68            Color color = ColorHelper.GetColor(cModel.ConnectorType);
69            this.Ellipse.Fill = new SolidColorBrush(Color.FromArgb(color.A, color.R, color.G, color.B));
70            this.Ellipse.ToolTip = cModel.ToolTip;
71        }
72
73        void ConnectorView_MouseLeftButtonDown(object sender, MouseButtonEventArgs e)
74        {
75            if (this.OnConnectorMouseLeftButtonDown != null)
76            {
77                this.OnConnectorMouseLeftButtonDown.Invoke(this, new ConnectorViewEventArgs { connector = this });
78            }
79        }
80
81        public bool CanConnect
82        {
83            get { throw new NotImplementedException(); }
84        }
85
86        public void update()
87        {
88            if (model.HasData)
89            {
90                ToolTip = model.Data;
91            }
92        }
93    }
94
95    public class ConnectorViewEventArgs : EventArgs
96    {
97        public ConnectorView connector;
98    }
99}
Note: See TracBrowser for help on using the repository browser.