---
# System prepended metadata

title: Exam 2 review sheet
tags: [Exam 2]

---

# Exam 2 review sheet

###### tags: `Exam 2`

## Windows Forms programming
   form = window
   Widget/Control = Software component that a user manipulates to interact with an application.
  ## Windows Forms Application
  
Program.cs - Application.Run() This file is rarely edited.
  
**Form1.cs – inherits Form**
All forms are inherited from Form1 class. File is partial since it is defined in another file (Form1.Desginer.cs). The apps main logic goes here.
      
**Form1.Designer.cs – InitializeComponent()**
The compiler declares it automatically and there is where we intanciate componenet that make up our window.

**Event-driven programming**
Callback and event handler are functions which are called whenever user clicks a button
*          +=/-= to register/deregister event handlers
That's in order to register for an event.
-= is in case I don't want you to call a function (not commonly used)
+= it's by default in event handlers to call functions when clicking 

*          Event handler parameters: sender and EventArgs
**Sender** is an object where the event occurs, like ToString, hash value, equals
it has properties.. it gets info of the click, by creating a variable to store the object (button, textbox..etc) we can modify it. **Event Args** is event data.



   **Controls**
      MenuStrip:  ![](https://i.imgur.com/r0gvv54.png)
      

Label: ![](https://i.imgur.com/yjFGiwB.png)

Button: ![](https://i.imgur.com/f8kFdy6.png)

TextBox: ![](https://i.imgur.com/qrQPh99.png)
Open text 

RadioButton: ![](https://i.imgur.com/sGozFzb.png)
You can choose only one.

CheckBox: ![](https://i.imgur.com/s5Bi3fI.png)
You can choose more than one.


ComboBox: ![](https://i.imgur.com/8XtlD58.png)
Options but you can choose one

      
   **Icon file .ico**
   It has a bitmap
   
   **Paint event and Invalidate()**
  **Paint event** is  where we draw the squares based on a grid, bollean values, when we modify the array by clicking on we are calling the **invalidate** function. We allow Windows to call it.
   
   **Separating GUI logic from business logic**
   Separating from different classes
   

**Dialog boxes**
   **Modal vs. modeless** When a modal dialog is open you cannot interact with anything else than this modal dialog inside your program, as long as the modal dialog is open. Most dialogs are modal, for example the File-Save As dialogs are modal.

On the other hand a modeless dialog behaves just like a normal window, you can do anything you want while it is open. The spell checker dialog in Microsoft Word is an example of such a dialog.

   **MessageBox class**
   Displays a message window, also known as a dialog box, which presents a message to the user. It is a modal window, blocking other actions in the application until the user closes it.
   
   ```C#
string message = "You did not enter a server name. Cancel this operation?";
string caption = "Error Detected in Input";
MessageBoxButtons buttons = MessageBoxButtons.YesNo;
        
MessageBox.Show(message, caption, buttons);
```
   
   **Form methods ShowDialog() vs. Show()**
   *Show* displays the form in a non-modal way.
   *ShowDialog* displays the form in a modal way.

   **DialogResult enum**
   DialogResult is returned by dialogs after dismissal.
It indicates which button was clicked on the dialog by the user. It is used with the MessageBox.Show method. It is a value. It can be switched upon and tested in an if-statement.

Example. This is a Windows Forms program that uses a Form1_Load event handler. We show a MessageBox with the OK and Cancel buttons (seen in the screenshot). We use the MessageBox.Show method for this.

   
   **Usability principles**
   - Unless the dialog box should be resizable (which is rare), remove the ability to resize the dialog box and remove the maximize button
- FormBorderStyle = FixedDialog
- MaximizeBox = False
- Always have OK and Cancel buttons available, and make the Cancel button reset the dialog box back to its original configuration
- Closing the dialog box via the close button (X) on the title bar should have the same effect as pressing Cancel
- In Windows, OK is always on the left, Cancel on the right
- Don't use scrollable dialog boxes, menu bars, or status bars
- Modal & Nonmodal Dialogs: When (& When Not) to Use Them
- Confirmation Dialogs Can Prevent User Errors — If Not Overused
- Windows User Experience Interation Guidelines for Dialog Boxes


   
  **Observer design pattern**
      **Observer (main form) vs. Subject (dialog box)
      Registration, notification, deregistration**
      
      Registration is in the observer what you want to be notified.
      notification tells the observer that something occured.
      deregistration, we don't need it because we are interested in registrarion.
      
    **Creating events, delegates, and triggering events**
      
   **Common dialog boxes**
      Color, font, folder, open, save, print
      
```c#
    ColorDialog dlg = new ColorDialog();
    dlg.ShowDialog();
    
    //or also
    FontDialog();
    OpenFileDialog();
    PrintDialog();
    
    OpenFileDialog theDialog = new OpenFileDialog();
    theDialog.ShowDialog();
    

    SaveFileDialog SaveFileDialog1 = new SaveFileDialog(); 
    theDialog.ShowDialog();
    
    
```
      
      GUI BLOOPERS!!!
      Like the thumbs down
      
      Look for more!
      
#   Chapter 2 – Our Vision is Optimized to See Structure
  
**Gestalt principles:**
* Proximity
    * Principle of Proximity is that the relative distance between objects in a display affects our perception of whether and how the objects are organized into subgroups.
    * It showed that group boxes and separators were not necessary because the related controls were visually spaced closer together.
    
* Similarity
    * Where objects that look similar appear grouped.
* Continuity
    * The principle of Continuity, states that our visual perception is biased to perceive continuous forms rather than disconnected segments.
   
    * ![](https://i.imgur.com/3l9tGB9.png)

* Closure
    *  Closure, which states that our visual system automatically tries to close open figures so that they are perceived as whole objects rather than separate pieces
* Symmetry
    * Symmetry, It states that we tend to parse complex scenes in a way that reduces the complexity. 
    * ![](https://i.imgur.com/05XEWh5.png)
* Figure/ground
    * How our visual system structures the data it receives.
    * This principle states that our mind separates the visual field into the figure (the foreground) and ground (the background).
    * ![](https://i.imgur.com/uBMnzfJ.png)
  
* Common fate
    * Common Fate—concerns moving objects.
    *  The Common Fate principle states that objects that move together are perceived as grouped or related.


---
*  (Quiz question chapter 2)
    * When a website displays content on top of the page content, they are making use of what Gestalt principle? :
        * Click for Answer
    * What Gestalt principle states that objects that move together are perceived as grouped or related? : 
        * Click for Answer
    * T/F The Gestalt Similarity principle states that objects that look similar appear grouped (all other things being equal): 
        * Click for Answer
    * The slider control that depicts a single range controlled by a handle is a prime example of what Gestalt principle? : 
        * Click for Answer 
    * T/F Typically Gestalt principles work in isolation.
        * Click for Answer
    * According to the text, what Gestalt principle did Escher often exploit in his drawings?
        * Click for Answer
    * What Gestalt principle states that we tend to parse complex scenes in a way that reduces the complexity?
        * Click for Answer
    * What Gestalt principle is used by GUIs to represent collections of objects like documents or messages as stacks so that showing one whole object and the edges of others "behind" it is enough to make users perceive a whole stack of objects?
        * Click for Answer
    * The Gestalt principles were theories developed by a group of German psychologists lead by Dr. Gestalt.
        * Click for Answer  
    * (T/F) For information displays to be easy to scan, all that is necessary is to make them terse, structured, and non-repetitious.
        * Click for Answer
---

             
# Chapter 3 – We Seek and Use Visual Structure
*     Seeking and seeing structure:
    * Users seek organization and structure when they are quickly searching for information.
    * Bad designs
        * Compare Bad design:![](https://i.imgur.com/oSF3usk.png)
        * and good design: ![](https://i.imgur.com/5wzkrvx.png)
        * The second design factors out needless repetition and marks as links only the words that represent options. It consumes less screen space and is easy
    * Scanning long numbers
        * Long numbers can be broken up in two ways. Either the user interface breaks it up explicitly by providing a separate field for each part of the number, or the interface provides a single number field but lets users break the number into parts with spaces or punctuation.
        * Not breaking up long numbers makes it difficult for the user to scan or verify they typed it correctly. CONSIDERED USER INTERFACE DESIGN BLOOPER.
        * ![](https://i.imgur.com/R2At3IO.png)
    *   Segmented data fields
        *   Segmented data fields can provide useful visual structure even **when the data to be entered is not a number**. Dates are example
        *   ![](https://i.imgur.com/IHU5FDj.png)
    *   Data-specific controls: Instead of using simple text fields, desingers can use controls that are designed specfically to display a value of a specific type. For example dates can be presented in the form of menus combined with pop up calendear controls.
    *   Visual hierarchy does the following:
        *   Breaks the information into distinct sections, and breaks large sections into subsections
        *   Labels each section and sbusection prominently and in such a way as to clearly identify its content
        *   Presents the sections and subsections as a hierarchy, with higher-level sections presented more strongly than lower-level ones.
    *   Visual hierarchy allows people, when scanning information, to instantly separate what is relevant to their goals from what is irrelevant.
---
* (Quiz questions chapter 3)
    * (T/F) Jeff Johnson suggests that credit card entry fields should not allow the user to enter spaces or dashes along with the numbers.
        * Click for Answer
    * (T/F) Data-specific controls should not be mixed with text field controls.
        * Click for Answer
    * (T/F) When scanning information, a visual hierarchy allows readers to instantly separate what is relevant to their goals from what is irrelevant.
        * Click for Answer

# Chapter 4 – Our Color Vision is Limited
* THe retina has two type of light receptors:
    * Rods detect light levels but not colors
    * Cones detect colors
        * Low Frequency: These cones are sensitive to light over almost the entire range of visible light, but are most sensitive to the middle (yellow) and low (red) frequencies
        * Medium Frequency: These cones respond to light ranging from the high-frequency blues through the lower middle-frequency yellows and oranges. Overall, they are less sensitive than the low-frequency cones.
        * High Frequency: These cones are most sensitive to light at the upper end of the visible light spectrum—violets and blues—but they also respond weakly to middle frequencies, such as green. These cones are much less sensitive overall than the other two types of cones, and also less numerous. One result is that our eyes are much less sensitive to blues and violets than to other colors.

Contrast vs. Brightness: VIsion is optimized for contrsting colors not brightness. 

* Discriminating between colors
    * Paleness: The paler (less saturated) two colos are, the harder it is to tell them apart
    * Color patch size:  The smaller or thinner objects are, the harder it is to distinguish their colors.
    * Separation: The more separated color patches are, the more difficult it is to distinguish their colors, especially if the separation is great enough to require eye motion between patches 
    * Color-blindness: Wheter colors can be distinguished by people who have common types of color-blindness.
        *  The most common type of color-blindness is red–green; other types are much rarer
    *  External factors:
        *  Variation among color displays
        *  Grayscale displays
        *  Display angle
        *  Ambient illumination
  *  Guidelines for using colors:
      *  Distinguish colors by saturation and brightness as well as hue
          *  avoid subtle color differences
      *  Use distinctive colors
          *  Use red, gree, yellow, blue, black and white
      *  Avoid color pairs that color blind people cannot distinguish
      *  Use color redundantly with other cues.
          *  Maybe use a symbol as well with color
      *  Separate strong opponent colors
          *  Placing opponent colors right next to or on top of each other casues a disturbing shimmering sensation, and so it shoulb be avoided