Exemplo n.º 1
0
        //-------------------------------------------------------------------------EVENT FOR RADIOBUTTON---------------------------------------------------------------------------
        private void RadioButtonDown(object sender, RoutedEventArgs e)
        {
            //Checking the IsChecked property....
            CustomPanel stackPanel         = sender as CustomPanel;
            Border      radioButtonEnable  = stackPanel.FindName("EnableButton") as Border;
            Border      radioButtonDisable = stackPanel.FindName("DisableButton") as Border;
            Border      radioButton;
            Boolean     EnabledFlag = true;

            try
            {
                ContentPresenter myContent = e.Source as ContentPresenter;
                Console.WriteLine(myContent.Content);
                if ((String)myContent.Tag == "Disable")
                {
                    EnabledFlag = false;
                }
                else
                {
                    EnabledFlag = true;
                }
            }
            catch (Exception)
            {
                Border myBorder = e.Source as Border;
                if ((String)myBorder.Tag == "Disable")
                {
                    EnabledFlag = false;
                }
                else
                {
                    EnabledFlag = true;
                }
            }
            if (EnabledFlag)
            {
                radioButton = radioButtonEnable;
                Colorpicker colorPicker = new Colorpicker(radioButton.Background);
                radioButton.Background = colorPicker.darker();
            }
            else
            {
                radioButton = radioButtonDisable;
                Colorpicker colorPicker = new Colorpicker(radioButton.Background);
                radioButton.Background = colorPicker.darker();
            }
        }
Exemplo n.º 2
0
        private void RadioButtonUp(object sender, RoutedEventArgs e)
        {
            Console.WriteLine("In button up property");
            //Checking the IsChecked property....
            CustomPanel stackPanel         = sender as CustomPanel;
            Border      radioButtonEnable  = stackPanel.FindName("EnableButton") as Border;
            Border      radioButtonDisable = stackPanel.FindName("DisableButton") as Border;
            Border      radioButton;

            Boolean EnabledFlag = true;

            try
            {
                ContentPresenter myContent = e.Source as ContentPresenter;
                Console.WriteLine(myContent.Content);
                if ((String)myContent.Tag == "Disable")
                {
                    EnabledFlag = false;
                }
                else
                {
                    EnabledFlag = true;
                }
            }
            catch (Exception)
            {
                Border myBorder = e.Source as Border;
                if ((String)myBorder.Tag == "Disable")
                {
                    EnabledFlag = false;
                }
                else
                {
                    EnabledFlag = true;
                }
            }
            if (EnabledFlag)
            {
                radioButton = radioButtonEnable;
                Colorpicker colorPicker = new Colorpicker(radioButton.Background);
                radioButton.Background = colorPicker.lighter();
            }
            else
            {
                radioButton = radioButtonDisable;
                Colorpicker colorPicker = new Colorpicker(radioButton.Background);
                radioButton.Background = colorPicker.lighter();
            }
            Console.WriteLine("PrevCheck value is " + stackPanel.PrevCheck);
            if (stackPanel.PrevCheck)
            {
                if (EnabledFlag)
                {
                    Console.WriteLine("I am inside enabled flag background");
                    Colorpicker colorPicker = new Colorpicker(radioButtonDisable.Background);
                    radioButtonEnable.Background  = colorPicker.dark();
                    radioButtonDisable.Background = new SolidColorBrush(Color.FromRgb(219, 219, 224));
                    stackPanel.PrevCheck          = false;
                }
            }

            if (stackPanel.PrevCheck == false)
            {
                if (EnabledFlag == false)
                {
                    Console.WriteLine("I am inside disabled flag background");
                    Colorpicker colorPicker = new Colorpicker(radioButtonEnable.Background);
                    radioButtonDisable.Background = colorPicker.dark();
                    radioButtonEnable.Background  = new SolidColorBrush(Color.FromRgb(219, 219, 224));
                    stackPanel.PrevCheck          = true;
                }
            }
        }