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

Last change on this file since 1640 was 1640, checked in by matkovic, 12 years ago

-ProgresBar added
-few updates added
-Orthogonal PolyLines added(experimental)

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            InitializeComponent();
67            Color color = ColorHelper.GetColor(cModel.ConnectorType);
68            this.Ellipse.Fill = new SolidColorBrush(Color.FromArgb(color.A, color.R, color.G, color.B));
69            this.Ellipse.ToolTip = cModel.ToolTip;
70        }
71
72        void ConnectorView_MouseLeftButtonDown(object sender, MouseButtonEventArgs e)
73        {
74            if (this.OnConnectorMouseLeftButtonDown != null)
75            {
76                this.OnConnectorMouseLeftButtonDown.Invoke(this, new ConnectorViewEventArgs { connector = this });
77            }
78        }
79
80        public bool CanConnect
81        {
82            get { throw new NotImplementedException(); }
83        }
84
85        public void update()
86        {
87            if (model.HasLastData)
88            {
89                ToolTip = model.LastData;
90            }
91        }
92    }
93
94    public class ConnectorViewEventArgs : EventArgs
95    {
96        public ConnectorView connector;
97    }
98}
Note: See TracBrowser for help on using the repository browser.