Ignore:
Timestamp:
Jun 8, 2010, 6:02:50 AM (12 years ago)
Author:
matkovic
Message:

-added Animations
-added Arrow Image
-Some style changes

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/CrypPlugins/WorkspaceManager/View/Container/WorkSpaceEditorView.xaml.cs

    r1595 r1600  
    3232            BUSY
    3333        };
    34 
    3534        private Point previousDragPoint = new Point();
    3635        private ConnectorView selectedConnector;
     
    4140        public EditorState State;
    4241        public EditorState ConnectorState;
    43         public List<CryptoLineView> LineList = new List<CryptoLineView>();
     42        public List<CryptoLineView> ConnectionList = new List<CryptoLineView>();
    4443        public List<PluginContainerView> PluginContainerList = new List<PluginContainerView>();
    45         private WorkspaceModel WorkspaceModel;
     44        private WorkspaceModel model;
     45        public WorkspaceModel Model
     46        {
     47            get { return model; }
     48            private set { model = value; }
     49        }
    4650
    4751        public WorkSpaceEditorView()
     
    5256        public WorkSpaceEditorView(WorkspaceModel WorkspaceModel)
    5357        {
     58            this.MouseLeave += new MouseEventHandler(WorkSpaceEditorView_MouseLeave);
    5459            this.Loaded += new RoutedEventHandler(WorkSpaceEditorView_Loaded);
    5560            this.DragEnter += new DragEventHandler(WorkSpaceEditorView_DragEnter);
     
    5762            this.MouseMove += new MouseEventHandler(WorkSpaceEditorView_MouseMove);
    5863            this.PreviewMouseRightButtonDown += new MouseButtonEventHandler(WorkSpaceEditorView_PreviewMouseRightButtonDown);
    59             this.WorkspaceModel = WorkspaceModel;
     64            this.Model = WorkspaceModel;
    6065            this.State = EditorState.READY;
    6166            InitializeComponent();
    6267        }
    6368
     69        void PluginDelete(object sender, PluginContainerViewDeleteViewEventArgs e)
     70        {
     71            for(int i = 0; i< e.container.ConnectorViewList.Count; i++)
     72            {
     73                for(int j = 0; j< e.container.ConnectorViewList[i].Model.OutputConnections.Count; j++)
     74                {
     75                    Model.deleteConnectionModel(e.container.ConnectorViewList[i].Model.OutputConnections[j]);
     76                    for (int n = 0; n < ConnectionList.Count; n++)
     77                    {
     78                        if (ConnectionList[n].Model == e.container.ConnectorViewList[i].Model.OutputConnections[j] ||
     79                            ConnectionList[n].Model == e.container.ConnectorViewList[i].Model.InputConnection)
     80                            root.Children.Remove(ConnectionList[n]);
     81                    }
     82                }
     83                Model.deleteConnectionModel(e.container.ConnectorViewList[i].Model.InputConnection);
     84            }
     85            root.Children.Remove(e.container);
     86        }
     87
    6488        void WorkSpaceEditorView_Loaded(object sender, RoutedEventArgs e)
    6589        {
     
    7094        {
    7195            PluginContainerView shape = new PluginContainerView(model);
    72             shape.MouseLeave += new MouseEventHandler(shape_MouseLeave);
     96            shape.Delete += new EventHandler<PluginContainerViewDeleteViewEventArgs>(PluginDelete);
     97            shape.ShowSettings += new EventHandler<PluginContainerViewSettingsViewEventArgs>(shape_ShowSettings);
    7398            shape.OnConnectorMouseLeftButtonDown += new EventHandler<ConnectorViewEventArgs>(shape_OnConnectorMouseLeftButtonDown);
    7499            shape.MouseLeftButtonDown += new MouseButtonEventHandler(shape_MouseLeftButtonDown);
     
    79104        }
    80105
     106        void shape_ShowSettings(object sender, PluginContainerViewSettingsViewEventArgs e)
     107        {
     108            this.InformationPanel.Visibility = Visibility.Visible;
     109        }
     110
    81111        public void AddConnection(IConnectable source, IConnectable target)
    82112        {
    83             ConnectionModel connectionModel = this.WorkspaceModel.newConnectionModel(((ConnectorView)source).cModel, ((ConnectorView)target).cModel, ((ConnectorView)source).cModel.ConnectorType);
     113            ConnectionModel connectionModel = this.Model.newConnectionModel(((ConnectorView)source).Model, ((ConnectorView)target).Model, ((ConnectorView)source).Model.ConnectorType);
    84114            CryptoLineView conn = new CryptoLineView(connectionModel);
    85115            conn.SetBinding(CryptoLineView.StartPointProperty, CreateConnectorBinding(source));
    86116            conn.SetBinding(CryptoLineView.EndPointProperty, CreateConnectorBinding(target));
    87117            root.Children.Add(conn);
     118            ConnectionList.Add(conn);
    88119            Canvas.SetZIndex(conn, 0);           
    89120        }
     
    91122        private void AddConnectionSource(IConnectable source, CryptoLineView conn)
    92123        {
    93             Color color = ColorHelper.getColor((source as ConnectorView).cModel.ConnectorType);
     124            Color color = ColorHelper.getColor((source as ConnectorView).Model.ConnectorType);
    94125            conn.Stroke = new SolidColorBrush(color);
    95126            conn.SetBinding(CryptoLineView.StartPointProperty, CreateConnectorBinding(source));
     
    129160        void shape_OnConnectorMouseLeftButtonDown(object sender, ConnectorViewEventArgs e)
    130161        {
    131             if (selectedConnector != null && e.connector.cModel.ConnectorType.Name == selectedConnector.cModel.ConnectorType.Name)
     162            if (selectedConnector != null && e.connector.Model.ConnectorType.Name == selectedConnector.Model.ConnectorType.Name)
    132163            {
    133164                this.root.Children.Remove(dummyLine);
     
    155186        }
    156187
     188        void WorkSpaceEditorView_MouseLeave(object sender, MouseEventArgs e)
     189        {
     190            this.selectedPluginContainer = null;
     191            this.State = EditorState.READY;
     192        }
     193
    157194        void WorkSpaceEditorView_MouseMove(object sender, MouseEventArgs e)
    158195        {
     
    168205            }
    169206            this.previousDragPoint = Mouse.GetPosition(root);
    170         }
    171 
    172         void shape_MouseLeave(object sender, MouseEventArgs e)
    173         {
    174             this.selectedPluginContainer = null;
    175             this.State = EditorState.READY;
    176207        }
    177208
     
    194225            DragDropDataObject obj = e.Data.GetData("Cryptool.PluginBase.Editor.DragDropDataObject") as DragDropDataObject;
    195226            if(obj != null)
    196                 this.AddPluginContainerView(e.GetPosition(root), WorkspaceModel.newPluginModel(DragDropDataObjectToPluginConverter.CreatePluginInstance(obj.AssemblyFullName, obj.TypeFullName)));
     227                this.AddPluginContainerView(e.GetPosition(root), Model.newPluginModel(DragDropDataObjectToPluginConverter.CreatePluginInstance(obj.AssemblyFullName, obj.TypeFullName)));
    197228        }
    198229
     
    203234
    204235        #endregion
     236
     237        private void CloseSettingsButton_Click(object sender, RoutedEventArgs e)
     238        {
     239            this.InformationPanel.Visibility = Visibility.Hidden;
     240        }
    205241    }
    206242}
Note: See TracChangeset for help on using the changeset viewer.