Beispiel #1
0
        private static bool RichTextBoxState(RichTextBox t, ControlStateVisuals v)
        {
            //variable
            bool Filled = false;
            ControlStateStatus state;
            string             richText = new TextRange(t.Document.ContentStart, t.Document.ContentEnd).Text;

            //Check what the current state is
            if (richText == string.Empty)
            {
                state = ControlStateStatus.empty;
            }
            else if (richText == "error")
            {
                state = ControlStateStatus.error;
            }
            else
            {
                state = ControlStateStatus.filled; Filled = true;
            }

            //Check what the methode is and make the action that belongs to it
            VisualAction(t, state, v);

            //check if a field was not filled
            return(Filled);
        }
Beispiel #2
0
        private static bool LabelState(Label t, ControlStateVisuals methode)
        {
            //variable
            bool Filled = false;
            ControlStateStatus state;

            switch (t.Content)
            {
            case "":
                state = ControlStateStatus.empty;
                break;

            case "error":
                state = ControlStateStatus.error;
                break;

            default:
                state = ControlStateStatus.filled; Filled = true;
                break;
            }

            //Check what the methode is and make the action that belongs to it
            VisualAction(t, state, methode);

            //check if a field was not filled
            return(Filled);
        }
Beispiel #3
0
        private static bool TextBoxState(TextBox t, ControlStateVisuals v)
        {
            //variable
            bool filled = false;
            ControlStateStatus state;

            //Check what the current state is
            if (t.Text == string.Empty)
            {
                state = ControlStateStatus.empty;
            }
            else if (t.Text == "error")
            {
                state = ControlStateStatus.error;
            }
            else
            {
                state = ControlStateStatus.filled; filled = true;
            }

            //Check what the methode is and make the action that belongs to it
            VisualAction(t, state, v);

            //check if a field was not filled
            return(filled);
        }
Beispiel #4
0
 private static void VisualAction(Control t, ControlStateStatus state, ControlStateVisuals v)
 {
     if (v == ControlStateVisuals.Colored)
     {
         SetState_color(t, state);
     }
     else if (v == ControlStateVisuals.Background)
     {
         t.BorderBrush = System.Windows.Media.Brushes.White;
     }
 }
Beispiel #5
0
 public static bool Execute(object controls, ControlStateVisuals visual)
 {
     //Determ object = list or array
     if (controls is List <ControlStateConfiger> )
     {
         return(List(controls as List <ControlStateConfiger>));
     }
     else
     if (controls is Control[])
     {
         return(Array(controls as Control[], visual));
     }
     else
     {
         return(false);
     }
 }
Beispiel #6
0
        private static bool ComboBoxState(ComboBox t, ControlStateVisuals v)
        {
            //variable
            bool Filled = false;
            ControlStateStatus state;

            //Check what the current state is
            if (t.SelectedIndex == 0)
            {
                state = ControlStateStatus.empty;
            }
            else
            {
                state = ControlStateStatus.filled; Filled = true;
            }

            //Check what the methode is and make the action that belongs to it
            VisualAction(t, state, v);

            //check if a field was not filled
            return(Filled);
        }
Beispiel #7
0
 internal ControlStateConfiger(Control control, ControlStateVisuals visual)
 {
     Control = control;
     Visuals = visual;
 }
Beispiel #8
0
        private static bool Array(Control[] con, ControlStateVisuals methode)
        {
            //notfilled is that not everything has been filled yet
            bool NotFilled = false;

            //strart loop foreach control
            foreach (Control c in con)
            {
                c.KeyUp += Enter_;
                //determ what type of control it is
                if (c.IsEnabled)
                {
                    switch (c.GetType().Name)
                    {
                    case "TextBox":
                        if (!TextBoxState(c as TextBox, methode))
                        {
                            NotFilled = true;
                        }
                        break;

                    case "RichTextBox":
                        if (!RichTextBoxState(c as RichTextBox, methode))
                        {
                            NotFilled = true;
                        }
                        break;

                    case "ComboBox":
                        if (!ComboBoxState(c as ComboBox, methode))
                        {
                            NotFilled = true;
                        }
                        break;

                    case "Label":
                        if (!LabelState(c as Label, methode))
                        {
                            NotFilled = true;
                        }
                        break;


                    default:
                        break;
                    }
                }
                else
                {
                    //if control is diabled set color state to white
                    c.BorderBrush = System.Windows.Media.Brushes.White;
                }
            }

            //check if a field was not filled
            if (NotFilled)
            {
                return(false);
            }
            else
            {
                return(true);
            }
        }
Beispiel #9
0
 public ControlStateConfiger(Control control, ControlStateVisuals visual)
 {
     Control = control;
     Visuals = visual;
 }