cst238 week 4 questions / concerns? announcements – start thinking about project ideas – test#1...
TRANSCRIPT
![Page 1: CST238 Week 4 Questions / Concerns? Announcements – Start thinking about project ideas – Test#1 next Monday, 4/28/14 Recap Check-off Take Home Lab#3 New](https://reader035.vdocument.in/reader035/viewer/2022072014/56649eaa5503460f94baf9be/html5/thumbnails/1.jpg)
CST238 Week 4• Questions / Concerns?• Announcements
– Start thinking about project ideas– Test#1 next Monday, 4/28/14
• Recap• Check-off Take Home Lab#3• New topics
– Dialogs (user-defined dialogs)– Timer control– DateTime object– Richtextbox– MDI (Multiple Document Interface)
• Parent/child form relationship• Richtextbox – open, save, cut, copy, paste
• In-Class Exercise #4• Take Home Lab#4
![Page 2: CST238 Week 4 Questions / Concerns? Announcements – Start thinking about project ideas – Test#1 next Monday, 4/28/14 Recap Check-off Take Home Lab#3 New](https://reader035.vdocument.in/reader035/viewer/2022072014/56649eaa5503460f94baf9be/html5/thumbnails/2.jpg)
Recap• Picturebox– Image property– Load method
• Layout controls– Table– Flow layout
• Menu• Toolbar• Status bar• Working with C# arrays
![Page 3: CST238 Week 4 Questions / Concerns? Announcements – Start thinking about project ideas – Test#1 next Monday, 4/28/14 Recap Check-off Take Home Lab#3 New](https://reader035.vdocument.in/reader035/viewer/2022072014/56649eaa5503460f94baf9be/html5/thumbnails/3.jpg)
Dialog• Forms that:– Provide information to the user, or– Request information from the user
• Generally modal– Cannot switch forms until dialog is closed.
• Several dialogs included with Windows Forms– MessageBox, Color, OpenFile, SaveFile, Print, etc.
• You can create your own custom dialog
![Page 4: CST238 Week 4 Questions / Concerns? Announcements – Start thinking about project ideas – Test#1 next Monday, 4/28/14 Recap Check-off Take Home Lab#3 New](https://reader035.vdocument.in/reader035/viewer/2022072014/56649eaa5503460f94baf9be/html5/thumbnails/4.jpg)
Working with Dialogs• Simple Dialogs– Just a function call• MessageBox.Show()
• Common/Custom Dialog– Create instance of dialog – Set properites– Show dialog using ShowDialog method• Returns a meber of the DialogResult enumeration
– Take action based on dialog result
![Page 5: CST238 Week 4 Questions / Concerns? Announcements – Start thinking about project ideas – Test#1 next Monday, 4/28/14 Recap Check-off Take Home Lab#3 New](https://reader035.vdocument.in/reader035/viewer/2022072014/56649eaa5503460f94baf9be/html5/thumbnails/5.jpg)
Working with DialogOpenFieDialog openFile1 = new OpenFileDialog();
openFile1.Filter = “JPEG Files (*.jpg)|*.jpg|PNG Files (*.png)|*.png|BMP Files (*.bmp)|*.bmp|All files (*.*)|*.*”;
if (openFile1.ShowDialog() == DialogResults.OK){ //Do something with OpenFile1.FileName //which is the filename selected by the user if (openFile1.ShowDialog() == DialogResult.OK) { pictureBox1.Load(openFile1.FileName); }
}
![Page 6: CST238 Week 4 Questions / Concerns? Announcements – Start thinking about project ideas – Test#1 next Monday, 4/28/14 Recap Check-off Take Home Lab#3 New](https://reader035.vdocument.in/reader035/viewer/2022072014/56649eaa5503460f94baf9be/html5/thumbnails/6.jpg)
Working with Color DialogColorDialog colorDialog1 = new ColorDialog();
if (colorDialog1.ShowDialog() == DialogResult.OK) pictureBox1.BackColor = colorDialog1.Color; //selected color
![Page 7: CST238 Week 4 Questions / Concerns? Announcements – Start thinking about project ideas – Test#1 next Monday, 4/28/14 Recap Check-off Take Home Lab#3 New](https://reader035.vdocument.in/reader035/viewer/2022072014/56649eaa5503460f94baf9be/html5/thumbnails/7.jpg)
Custom Dialog• Create form as you would any other• Set form properties to add dialog look, feel and behavior
– Set FormBorderStyle to FixedDialog• Disables resizing of dialog
– Set ControlBox property to false• Removes minimize, maximize and close buttons from title bar
– Set AcceptButton and CancelButton properties• AcceptButton - pressing Enter is the same as clicking the
button• CancelButton – pressing Escape is the same as clicking the
button
• Set dialog return value on button clicks– In event handler, or– Using the DialogResult property of the button
![Page 8: CST238 Week 4 Questions / Concerns? Announcements – Start thinking about project ideas – Test#1 next Monday, 4/28/14 Recap Check-off Take Home Lab#3 New](https://reader035.vdocument.in/reader035/viewer/2022072014/56649eaa5503460f94baf9be/html5/thumbnails/8.jpg)
Timer Control• Add a timer control to the form• Set its interval – 1000 ms = 1 second• Set its Tick event handler to handle the timer
event at every interval
![Page 9: CST238 Week 4 Questions / Concerns? Announcements – Start thinking about project ideas – Test#1 next Monday, 4/28/14 Recap Check-off Take Home Lab#3 New](https://reader035.vdocument.in/reader035/viewer/2022072014/56649eaa5503460f94baf9be/html5/thumbnails/9.jpg)
DateTime• DateTime object in C# returns the current date and
time. • Custom Date and Time Format Strings:
http://msdn.microsoft.com/en-us/library/8kb3ddd4(v=vs.110).aspx
• Example:private DateTime timeOfDay;Private string timeString;private string hour;private string minute;timeOfDay = DateTime.Now;timeString = timeOfDay.ToString("hh:mm:ss");hour = timeOfDay.Hour.ToString("00");minute = timeOfDay.Minute.ToString("00");
![Page 10: CST238 Week 4 Questions / Concerns? Announcements – Start thinking about project ideas – Test#1 next Monday, 4/28/14 Recap Check-off Take Home Lab#3 New](https://reader035.vdocument.in/reader035/viewer/2022072014/56649eaa5503460f94baf9be/html5/thumbnails/10.jpg)
Richtextbox• Supports– Cut– Copy– Paste– SelectAll– SaveFile(filename)– LoadFile(filename)– SelectionColor– SelectionFont
![Page 11: CST238 Week 4 Questions / Concerns? Announcements – Start thinking about project ideas – Test#1 next Monday, 4/28/14 Recap Check-off Take Home Lab#3 New](https://reader035.vdocument.in/reader035/viewer/2022072014/56649eaa5503460f94baf9be/html5/thumbnails/11.jpg)
MDI
![Page 12: CST238 Week 4 Questions / Concerns? Announcements – Start thinking about project ideas – Test#1 next Monday, 4/28/14 Recap Check-off Take Home Lab#3 New](https://reader035.vdocument.in/reader035/viewer/2022072014/56649eaa5503460f94baf9be/html5/thumbnails/12.jpg)
Multiple Document Interface (MDI)
![Page 13: CST238 Week 4 Questions / Concerns? Announcements – Start thinking about project ideas – Test#1 next Monday, 4/28/14 Recap Check-off Take Home Lab#3 New](https://reader035.vdocument.in/reader035/viewer/2022072014/56649eaa5503460f94baf9be/html5/thumbnails/13.jpg)
MDI Apps• Main Form– Set IsMdiContainer to true– Use ActiveMdiChild to get reference to active child
form– Use MdiChildren to get collection of child forms– Use LayoutMdi to arrange child forms
• Child forms– Set MdiParent to main form on creation– Use MdiParent to get reference back to main form
![Page 14: CST238 Week 4 Questions / Concerns? Announcements – Start thinking about project ideas – Test#1 next Monday, 4/28/14 Recap Check-off Take Home Lab#3 New](https://reader035.vdocument.in/reader035/viewer/2022072014/56649eaa5503460f94baf9be/html5/thumbnails/14.jpg)
MDI• Windows menu– Arrange the windows in Cascade– Arrange the windows in Tile Horizontally– Arrange the windows in Tile Vertically
• Menustrip Control– Set MdiWindowList • This will show a list of active child windows
![Page 15: CST238 Week 4 Questions / Concerns? Announcements – Start thinking about project ideas – Test#1 next Monday, 4/28/14 Recap Check-off Take Home Lab#3 New](https://reader035.vdocument.in/reader035/viewer/2022072014/56649eaa5503460f94baf9be/html5/thumbnails/15.jpg)
Access the Active Child form if (this.ActiveMdiChild != null){ //cast the ActiveMdiChild to the right form type ChildForm child=(ChildForm)this.ActiveMdiChild;
//do something with childform’s control child.documentTextbox.Undo(); }
documentTextbox is private. It needs to be internal. Change its modifier in the Properties window.
![Page 16: CST238 Week 4 Questions / Concerns? Announcements – Start thinking about project ideas – Test#1 next Monday, 4/28/14 Recap Check-off Take Home Lab#3 New](https://reader035.vdocument.in/reader035/viewer/2022072014/56649eaa5503460f94baf9be/html5/thumbnails/16.jpg)
private vs. internal• All controls on a form are default to private
modifier. – Only available to the containing form
• In order for the Main Form to access the Childform’s control, the control’s modifier would have to be changed.– internal means that they are in the same assembly
(.exe or .dll)
![Page 17: CST238 Week 4 Questions / Concerns? Announcements – Start thinking about project ideas – Test#1 next Monday, 4/28/14 Recap Check-off Take Home Lab#3 New](https://reader035.vdocument.in/reader035/viewer/2022072014/56649eaa5503460f94baf9be/html5/thumbnails/17.jpg)
Modifiers
![Page 18: CST238 Week 4 Questions / Concerns? Announcements – Start thinking about project ideas – Test#1 next Monday, 4/28/14 Recap Check-off Take Home Lab#3 New](https://reader035.vdocument.in/reader035/viewer/2022072014/56649eaa5503460f94baf9be/html5/thumbnails/18.jpg)
In-Class Lab#4• Finish the MDI application by finishing the
Open, Save, Cut, Copy,Paste, Change Font and Change Color menu options.
• When open a new childForm window, set its title appropriately.
• Be sure to change the childForm window title to the saved/opened filename.
![Page 19: CST238 Week 4 Questions / Concerns? Announcements – Start thinking about project ideas – Test#1 next Monday, 4/28/14 Recap Check-off Take Home Lab#3 New](https://reader035.vdocument.in/reader035/viewer/2022072014/56649eaa5503460f94baf9be/html5/thumbnails/19.jpg)
Take-Home Exercise #4• Build a Tix Clock
• This is a Tix Clock showing 15:43.
![Page 20: CST238 Week 4 Questions / Concerns? Announcements – Start thinking about project ideas – Test#1 next Monday, 4/28/14 Recap Check-off Take Home Lab#3 New](https://reader035.vdocument.in/reader035/viewer/2022072014/56649eaa5503460f94baf9be/html5/thumbnails/20.jpg)
Tix Clock• Use pictureboxes to simulate color LEDs.• Use random number to randomly color
squares.• Tix clocks are updated every 4 seconds.• Use DateTime to get the current time. Be sure
to grab 2 digits for hour and 2 digits for minute.