Changeset 140

Show
Ignore:
Timestamp:
03/08/07 22:07:04 (2 years ago)
Author:
dmoy2
Message:

Added start buttons

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • TeachingSoftware/GUI/BodyOfCode_Canvas.xaml.cs

    r93 r140  
    2525 
    2626        // Form Controls 
     27        public List<ButtonControl> myStartButtons    = new List<ButtonControl>(); 
    2728        public List<ButtonControl> myCanvasButtons   = new List<ButtonControl>(); 
    2829        public List<Arrow>         myCanvasArrows    = new List<Arrow>(); 
     
    3738        private List<Line>      selectionBox          = new List<Line>(); 
    3839        private List<ButtonControl> mySelectedButtons = new List<ButtonControl>(); 
     40         
    3941 
    4042        // ------------------------------------------------------------------------- 
     
    8284            this.Children.Add(element); 
    8385            this.myCanvasButtons.Add(element); 
     86        } 
     87 
     88        public void AddStartButton(ButtonControl start) 
     89        { 
     90            this.myStartButtons.Add(start); 
     91            this.Children.Add(start); 
    8492        } 
    8593 
     
    161169                } 
    162170            } 
     171            foreach(ButtonControl button in this.myStartButtons) { 
     172                if((button.Visibility == Visibility.Visible) && (!button.HasOutgoing() && ((button.GetIncoming() != arrow) || (arrow == null))) || ((button.GetOutgoing() == arrow) && (arrow != null))) { 
     173                    this.CreateEllipsesForArrows(button, this.myLineSources); 
     174                } 
     175            } 
    163176        } 
    164177 
  • TeachingSoftware/GUI/ButtonControl.xaml

    r135 r140  
    4141                        </EventTrigger> 
    4242                </Canvas.Triggers> 
     43                <Image x:Name="startImage" Source="../Art/start.png" Visibility="Hidden" Width="84.09" Height="83.446"/> 
     44                <Image x:Name="startImageGlow" Source="../Art/start_glow.png" Visibility="Hidden" Width="84.09" Height="83.446"/> 
    4345                <Image x:Name="ifImage" Source="../Art/triangle.png" Visibility="Hidden" Width="84.09" Height="83.446"/> 
    4446                <Image x:Name="otherImage" Source="../Art/square.png" Visibility="Hidden" Width="84.09" Height="83.446"/> 
  • TeachingSoftware/GUI/ButtonControl.xaml.cs

    r135 r140  
    1515    public enum AnchorSide { Top = 0, Bottom = 1, Left = 2, Right = 3 }; 
    1616    public enum ButtonLocation { Sidebar, Normal }; 
    17     public enum ButtonType { Other, If, Variable, Method, Loop }; 
     17    public enum ButtonType { Other, If, Variable, Method, Loop, Start }; 
    1818 
    1919        public partial class ButtonControl 
     
    7474                } 
    7575 
     76        // ------------------------------------------ 
     77        // ButtonControl() 
     78        // Copy Constructor 
     79        // Params: 
     80        //    sourceButton - Button to Copy data from 
     81        // ------------------------------------------ 
     82        public ButtonControl(ButtonControl sourceButton, ButtonControl newParent) 
     83        { 
     84            // Initialize Stuff 
     85                        this.InitializeComponent(); 
     86 
     87            SetLocation(sourceButton.myLocation); 
     88            this.myParentWindow  = sourceButton.myParentWindow; 
     89            this.myParent        = newParent; 
     90            this.Background      = Brushes.White; 
     91            this.Foreground      = Brushes.Black; 
     92            this.myType          = sourceButton.myType; 
     93            this.myShape.Content = sourceButton.myShape.Content; 
     94            this.myBackendComponent = sourceButton.myBackendComponent; 
     95            this.RenderTransform = sourceButton.RenderTransform; 
     96            this.myOutgoingArrow = null; 
     97            this.myIncomingArrow = null; 
     98 
     99            // Event 
     100            this.MouseDoubleClick += new MouseButtonEventHandler(ButtonControl_MouseDoubleClick); 
     101            this.MouseLeftButtonDown += new MouseButtonEventHandler(this.myParentWindow.ButtonControl_MouseLeftButtonDown); 
     102            SetupType(); 
     103        } 
     104 
    76105        public ButtonControl GetParentView() 
    77106        { 
     
    104133        public void ButtonControl_MouseDoubleClick(object sender, MouseButtonEventArgs e) 
    105134        { 
    106             if(this.myType == ButtonType.If || this.myType == ButtonType.Method || this.myType == ButtonType.Loop) { 
     135            if(this.myType == ButtonType.If || this.myType == ButtonType.Loop || this.myType == ButtonType.Method) { 
     136                if(!this.myParentWindow.HasStartButtonFor(this)) { 
     137                    this.myParentWindow.AddStartButton(this); 
     138                } 
     139                 
    107140                this.myParentWindow.ChangeViewLevel(this); 
    108141                DoubleAnimation expandAnimation = new DoubleAnimation(50, new Duration( new TimeSpan(0, 0, 0, 0, 500))); 
     
    131164        } 
    132165 
    133         // ------------------------------------------ 
    134         // ButtonControl() 
    135         // Copy Constructor 
    136         // Params: 
    137         //    sourceButton - Button to Copy data from 
    138         // ------------------------------------------ 
    139         public ButtonControl(ButtonControl sourceButton) 
    140         { 
    141             this.InitializeComponent(); 
    142             this.myParentWindow        = sourceButton.myParentWindow; 
    143             this.Background      = sourceButton.Background; 
    144             this.Foreground      = sourceButton.Foreground; 
    145             this.myChildren      = sourceButton.myChildren; 
    146             this.myType          = sourceButton.myType; 
    147             this.myIncomingArrow = sourceButton.myIncomingArrow; 
    148             this.myOutgoingArrow = sourceButton.myOutgoingArrow; 
    149  
    150             SetLocation(sourceButton.myLocation); 
    151  
    152             // Event 
    153             this.MouseLeftButtonDown += new MouseButtonEventHandler(this.myParentWindow.ButtonControl_MouseLeftButtonDown); 
    154  
    155             SetupType(); 
    156         } 
    157166 
    158167        public void Delete() 
     
    426435                    break; 
    427436 
     437                case ButtonType.Start: 
     438                    this.myImage = this.startImage; 
     439                    this.startImage.Visibility = Visibility.Visible; 
     440                    this.myOutputAnchors.Insert((int)AnchorSide.Top, new Point(GetWidth() / 2 - 5, 0)); 
     441                    this.myOutputAnchors.Insert((int)AnchorSide.Bottom, new Point(GetWidth() / 2 - 5, GetHeight())); 
     442                    this.myOutputAnchors.Insert((int)AnchorSide.Left, new Point(0, GetHeight() / 2 - 5)); 
     443                    this.myOutputAnchors.Insert((int)AnchorSide.Right, new Point(GetWidth(), GetHeight() / 2 - 5)); 
     444                    this.myInputAnchors.Insert((int)AnchorSide.Top, new Point(GetWidth() / 2 + 5, 0)); 
     445                    this.myInputAnchors.Insert((int)AnchorSide.Bottom, new Point(GetWidth() / 2 + 5, GetHeight())); 
     446                    this.myInputAnchors.Insert((int)AnchorSide.Left, new Point(0, GetHeight() / 2 + 5)); 
     447                    this.myInputAnchors.Insert((int)AnchorSide.Right, new Point(GetWidth(), GetHeight() / 2 + 5)); 
     448                    break; 
     449 
    428450                case ButtonType.Method: 
    429451                    this.myImage = this.methodImage; 
  • TeachingSoftware/GUI/Scene1.xaml.cs

    r136 r140  
    3838                        this.InitializeComponent(); 
    3939                 
     40            ButtonControl myStartButton = new ButtonControl(this, ButtonType.Start, ButtonLocation.Normal, null, null); 
     41            myStartButton.RenderTransform = new TranslateTransform(70, 30); 
     42            this.Canvas_Main.AddStartButton(myStartButton); 
     43 
    4044            this.ListBox_Variable.DataContext = Project.getInScopeVariables(); 
    4145            this.ListBox_Class.DataContext = Project.getProgramClasses(); 
     
    5458            this.ListBox_Variable.MouseLeftButtonDown += new MouseButtonEventHandler(ListBox_Variable_MouseDown); 
    5559            this.ListBox_Variable.SelectionChanged += new SelectionChangedEventHandler(ListBox_Variable_SelectionChanged); 
     60        } 
     61 
     62        public bool HasStartButtonFor(ButtonControl button) 
     63        { 
     64            foreach(ButtonControl startButton in this.Canvas_Main.myStartButtons) { 
     65                if(startButton.GetParentView() == button) { 
     66                    return true; 
     67                } 
     68            } 
     69            return false; 
     70        } 
     71 
     72        public void AddStartButton(ButtonControl parentView) 
     73        { 
     74            ButtonControl newStart = new ButtonControl(this.Canvas_Main.myStartButtons[0], parentView); 
     75            this.Canvas_Main.AddStartButton(newStart); 
     76        } 
     77 
     78        public ButtonControl GetStartButtonForParent(ButtonControl button) 
     79        { 
     80            foreach(ButtonControl startButton in this.Canvas_Main.myStartButtons) { 
     81                if(startButton.GetParentView() == button) { 
     82                    return startButton; 
     83                } 
     84            } 
     85            return null; 
    5686        } 
    5787 
     
    6797                } 
    6898            } 
     99            foreach(ButtonControl button in this.Canvas_Main.myStartButtons) { 
     100                if(button.GetParentView() == this.myCurrentViewRoot) { 
     101                    button.Show(); 
     102                } 
     103                else if(button != newViewRoot) { 
     104                    button.Hide(); 
     105                } 
     106            } 
    69107 
    70108            if(this.myCurrentViewRoot == null) { 
     
    74112                this.UpLevelButton.IsEnabled = true; 
    75113            } 
    76         } 
    77  
    78         void showAnim_Completed(object sender, EventArgs e) 
    79         { 
    80              
    81114        } 
    82115 
     
    194227            } 
    195228            else { 
    196                                
    197                 // Set the offset position (inside the button) 
    198                 this.myMouseOffsetForDrag = e.GetPosition(owner as IInputElement); 
    199                  
    200                 this.draggedButton = owner; 
    201                 this.Canvas_Main.BringElementToFront(this.draggedButton); 
    202                 this.Canvas_Main.BringElementToFront(this.draggedButton.GetIncoming()); 
    203                 this.Canvas_Main.BringElementToFront(this.draggedButton.GetOutgoing()); 
    204  
    205               
    206                 // Add the appropriate event for moving/releasing 
    207                 this.Canvas_Main.MouseMove += new MouseEventHandler(this.MainWindow_MouseMove); 
    208                 this.Canvas_Main.MouseLeftButtonUp += new MouseButtonEventHandler(this.MainWindow_MouseLeftButtonUp); 
     229                if(!this.Canvas_Main.myStartButtons.Contains(owner)) { 
     230                    // Set the offset position (inside the button) 
     231                    this.myMouseOffsetForDrag = e.GetPosition(owner as IInputElement); 
     232                     
     233                    this.draggedButton = owner; 
     234                    this.Canvas_Main.BringElementToFront(this.draggedButton); 
     235                    this.Canvas_Main.BringElementToFront(this.draggedButton.GetIncoming()); 
     236                    this.Canvas_Main.BringElementToFront(this.draggedButton.GetOutgoing()); 
     237 
     238                  
     239                    // Add the appropriate event for moving/releasing 
     240                    this.Canvas_Main.MouseMove += new MouseEventHandler(this.MainWindow_MouseMove); 
     241                    this.Canvas_Main.MouseLeftButtonUp += new MouseButtonEventHandler(this.MainWindow_MouseLeftButtonUp); 
     242                } 
    209243            } 
    210244            // Set to handled 
  • TeachingSoftware/TeachingSoftware.csproj

    r139 r140  
    144144    <None Include="ClassDiagram1.cd" /> 
    145145  </ItemGroup> 
     146  <ItemGroup> 
     147    <Resource Include="Art\start.png" /> 
     148    <Resource Include="Art\start_glow.png" /> 
     149  </ItemGroup> 
    146150</Project>