Changeset 140
- Timestamp:
- 03/08/07 22:07:04 (2 years ago)
- Files:
-
- TeachingSoftware/GUI/BodyOfCode_Canvas.xaml.cs (modified) (4 diffs)
- TeachingSoftware/GUI/ButtonControl.xaml (modified) (1 diff)
- TeachingSoftware/GUI/ButtonControl.xaml.cs (modified) (5 diffs)
- TeachingSoftware/GUI/Scene1.xaml.cs (modified) (5 diffs)
- TeachingSoftware/TeachingSoftware.csproj (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
TeachingSoftware/GUI/BodyOfCode_Canvas.xaml.cs
r93 r140 25 25 26 26 // Form Controls 27 public List<ButtonControl> myStartButtons = new List<ButtonControl>(); 27 28 public List<ButtonControl> myCanvasButtons = new List<ButtonControl>(); 28 29 public List<Arrow> myCanvasArrows = new List<Arrow>(); … … 37 38 private List<Line> selectionBox = new List<Line>(); 38 39 private List<ButtonControl> mySelectedButtons = new List<ButtonControl>(); 40 39 41 40 42 // ------------------------------------------------------------------------- … … 82 84 this.Children.Add(element); 83 85 this.myCanvasButtons.Add(element); 86 } 87 88 public void AddStartButton(ButtonControl start) 89 { 90 this.myStartButtons.Add(start); 91 this.Children.Add(start); 84 92 } 85 93 … … 161 169 } 162 170 } 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 } 163 176 } 164 177 TeachingSoftware/GUI/ButtonControl.xaml
r135 r140 41 41 </EventTrigger> 42 42 </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"/> 43 45 <Image x:Name="ifImage" Source="../Art/triangle.png" Visibility="Hidden" Width="84.09" Height="83.446"/> 44 46 <Image x:Name="otherImage" Source="../Art/square.png" Visibility="Hidden" Width="84.09" Height="83.446"/> TeachingSoftware/GUI/ButtonControl.xaml.cs
r135 r140 15 15 public enum AnchorSide { Top = 0, Bottom = 1, Left = 2, Right = 3 }; 16 16 public enum ButtonLocation { Sidebar, Normal }; 17 public enum ButtonType { Other, If, Variable, Method, Loop };17 public enum ButtonType { Other, If, Variable, Method, Loop, Start }; 18 18 19 19 public partial class ButtonControl … … 74 74 } 75 75 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 76 105 public ButtonControl GetParentView() 77 106 { … … 104 133 public void ButtonControl_MouseDoubleClick(object sender, MouseButtonEventArgs e) 105 134 { 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 107 140 this.myParentWindow.ChangeViewLevel(this); 108 141 DoubleAnimation expandAnimation = new DoubleAnimation(50, new Duration( new TimeSpan(0, 0, 0, 0, 500))); … … 131 164 } 132 165 133 // ------------------------------------------134 // ButtonControl()135 // Copy Constructor136 // Params:137 // sourceButton - Button to Copy data from138 // ------------------------------------------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 // Event153 this.MouseLeftButtonDown += new MouseButtonEventHandler(this.myParentWindow.ButtonControl_MouseLeftButtonDown);154 155 SetupType();156 }157 166 158 167 public void Delete() … … 426 435 break; 427 436 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 428 450 case ButtonType.Method: 429 451 this.myImage = this.methodImage; TeachingSoftware/GUI/Scene1.xaml.cs
r136 r140 38 38 this.InitializeComponent(); 39 39 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 40 44 this.ListBox_Variable.DataContext = Project.getInScopeVariables(); 41 45 this.ListBox_Class.DataContext = Project.getProgramClasses(); … … 54 58 this.ListBox_Variable.MouseLeftButtonDown += new MouseButtonEventHandler(ListBox_Variable_MouseDown); 55 59 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; 56 86 } 57 87 … … 67 97 } 68 98 } 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 } 69 107 70 108 if(this.myCurrentViewRoot == null) { … … 74 112 this.UpLevelButton.IsEnabled = true; 75 113 } 76 }77 78 void showAnim_Completed(object sender, EventArgs e)79 {80 81 114 } 82 115 … … 194 227 } 195 228 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 } 209 243 } 210 244 // Set to handled TeachingSoftware/TeachingSoftware.csproj
r139 r140 144 144 <None Include="ClassDiagram1.cd" /> 145 145 </ItemGroup> 146 <ItemGroup> 147 <Resource Include="Art\start.png" /> 148 <Resource Include="Art\start_glow.png" /> 149 </ItemGroup> 146 150 </Project>
