void AutosarTreeViewControl_SelectedItemChanged(object sender, RoutedPropertyChangedEventArgs <object> e)
 {
     if (e.NewValue is TreeViewItem)
     {
         TreeViewItem item = (e.NewValue as TreeViewItem);
         if (item.Tag is ComponentInstance)
         {
             autosarApp.UnselectComponents();
             (item.Tag as ComponentInstance).Select();
         }
         if (item.Tag is PortPainter)
         {
             autosarApp.UnselectComponents();
             (item.Tag as PortPainter).Selected = true;
         }
         if (item.Tag is PortConnection)
         {
             autosarApp.UnselectComponents();
             (item.Tag as PortConnection).Select();
         }
     }
 }
Example #2
0
        private void Viewport_MouseLeftButtonDown(object sender, MouseButtonEventArgs e)
        {
            if (e.ClickCount == 1)
            {
                //Scale image with cursor pointer stayed on last plase
                Point currentPoint = e.GetPosition(ViewPortImage);

                //get pointed scene coordinates
                Point sceneCoordinates = scene.MouseToXY(currentPoint);

                autosarApp.UnselectComponents();

                moveObjectsController.Viewport_MouseLeftButtonDown(sceneCoordinates);
                if (moveObjectsController.SelectedObject != null)
                {
                    if (!(moveObjectsController.SelectedObject is CompositionInstance))
                    {
                        AutosarTree.UpdateAutosarTreeView(moveObjectsController.SelectedObject);
                        AutosarTree.Focus();
                    }
                }

                /* Check for creating connection line */
                connectionLineController.Viewport_MouseDown(e, sceneCoordinates);
            }
            else if (e.ClickCount == 2)
            {
                //Scale image with cursor pointer stayed on last plase
                Point currentPoint = e.GetPosition(ViewPortImage);

                //get pointed scene coordinates
                Point sceneCoordinates = scene.MouseToXY(currentPoint);

                autosarApp.UnselectComponents();

                moveObjectsController.Viewport_MouseLeftButtonDown(sceneCoordinates);
                if (moveObjectsController.SelectedObject != null)
                {
                    if (moveObjectsController.SelectedObject is CompositionInstance)
                    {
                        autosarApp.ActiveComposition = moveObjectsController.SelectedObject as CompositionInstance;

                        compositionInstanceController.Composition = autosarApp.ActiveComposition;
                        CompositionProperties_TabItem.IsEnabled   = true;
                        SelectElement(autosarApp.ActiveComposition);

                        AutosarTree.UpdateAutosarTreeView(moveObjectsController.SelectedObject);
                        AutosarTree.Focus();

                        moveObjectsController.SelectedObject = null;
                    }
                    else if (moveObjectsController.SelectedObject is ComponentInstance)
                    {
                        ComponentInstance inst = (moveObjectsController.SelectedObject as ComponentInstance);
                        componentDefenitionViewController.ComponentDefenition = inst.ComponentDefenition;
                        ComponentDefenitionTab.IsEnabled = true;
                        tabHideHelper.ProcessTabs();
                        tabHideHelper.SelectTab(ComponentDefenitionTab);
                    }
                }
            }
            Render(null, null);
        }