public ColorPickerWindow(Color color)
 {
     InitializeComponent();
     ColorPickerControl.SetColor(color);
     Transfer.SelectedColor = color;
     OKButton.Focus();
 }
        protected override void OnVisualChildrenChanged(DependencyObject visualAdded, DependencyObject visualRemoved)
        {
            base.OnVisualChildrenChanged(visualAdded, visualRemoved);
            int index = InternalChildren.IndexOf((UIElement)visualAdded);

            Grid.SetRow((UIElement)visualAdded, index / ColorPickerControl.GetColumnCount(this));
            Grid.SetColumn((UIElement)visualAdded, index % ColorPickerControl.GetColumnCount(this));
        }
        /// <summary>
        /// raised when the selection change occurs in the source control
        /// </summary>
        /// <param name="sender">the source control</param>
        /// <param name="e">the event args</param>
        private void lstColorPicker_SelectionChanged(object sender, SelectionChangedEventArgs e)
        {
            //get a reference to the source object and cast it to the correct type
            ColorPickerControl lstSrc = (e.Source as ColorPickerControl);

            //set the background to the sources selected value, remember the SelectedValue
            //was set as Fill, which in fact returns a Brush. See the ColorPickerControl.cs class
            this.Background = (Brush)lstSrc.SelectedValue;
        }
        /// <summary>
        /// A user defined RoutedEvent within the  <see cref="ColorPickerControl">
        /// ColorPickerControl</see> that simply uses the standard RoutedEventArgs event args
        /// </summary>
        /// <param name="sender">the ColorPickerControl</param>
        /// <param name="e">standard RoutedEventArgs event args</param>
        private void lstColorPicker_NewColor(object sender, RoutedEventArgs e)
        {
            //get a reference to the source object and cast it to the correct type
            ColorPickerControl lstSrc = (sender as ColorPickerControl);
            //get the tooltip and show it as MessageBox
            ToolTip t = (ToolTip)(lstSrc.SelectedItem as Rectangle).ToolTip;

            this.LblColor.Content = t.Content;
        }
Exemplo n.º 5
0
 public void OpenColorPicker()
 {
     if (colPickerOpen)
     {
         colorPicker.transform.SetAsLastSibling();
     }
     else
     {
         colPickerOpen = true;
         colorPicker   = Instantiate(UIManager.instance.colorPickerPrefab, UIManager.instance.gameWindowContainer);
         colorPicker.Open(myColor, SetMarkerColor, CloseColorPicker);
     }
 }
Exemplo n.º 6
0
    // Colouring Walls
    public void BeginPaintingWalls()
    {
        if (paintingWalls)
        {
            return;
        }

        if (isMouseOccupied)
        {
            FreeMouse();
        }

        paintingWalls   = true;
        isMouseOccupied = true;
        wallColorPicker = Instantiate(UIManager.instance.colorPickerPrefab, UIManager.instance.gameWindowContainer);
        wallColorPicker.Open(paintColor, SetPaintColor, CancelPaintingWalls);
    }
Exemplo n.º 7
0
            public void Init(Color color, string name)
            {
                RedSlider   = new Slider("Red", color.R, 0, 255);
                GreenSlider = new Slider("Green", color.B, 0, 255);
                BlueSlider  = new Slider("Blue", color.G, 0, 255);
                ColorPicker = new ColorPickerControl(Id + "ColorDisplay", color);

                _menu.AddGroupLabel(name);

                _menu.Add(Id + "ColorDisplay", ColorPicker);
                _menu.Add(Id + "Red", RedSlider);
                _menu.Add(Id + "Green", GreenSlider);
                _menu.Add(Id + "Blue", BlueSlider);

                RedSlider.OnValueChange   += OnValueChange;
                GreenSlider.OnValueChange += OnValueChange;
                BlueSlider.OnValueChange  += OnValueChange;

                ColorPicker.SetColor(Color.FromArgb(GetValue(ColorBytes.Red), GetValue(ColorBytes.Green), GetValue(ColorBytes.Blue)));
            }
        /// <summary>
        /// Apply templates
        /// </summary>
        protected override void OnApplyTemplate()
        {
            base.OnApplyTemplate();

            this.FontColorType         = this.GetTemplateChild("FontColorType") as ComboBox;
            this.BackgroundColorType   = this.GetTemplateChild("BackgroundColorType") as ComboBox;
            this.WindowColorType       = this.GetTemplateChild("WindowColorType") as ComboBox;
            this.CaptionFontStyle      = this.GetTemplateChild("CaptionFontStyle") as ComboBox;
            this.FontColorButton       = this.GetTemplateChild("FontColorButton") as Button;
            this.BackgroundColorButton = this.GetTemplateChild("BackgroundColorButton") as Button;
            this.WindowColorButton     = this.GetTemplateChild("WindowColorButton") as Button;

            this.FontColorPicker       = this.GetColorPicker("FontColorPicker", this.OnFontColorSelected);
            this.BackgroundColorPicker = this.GetColorPicker("BackgroundColorPicker", this.OnBackgroundColorSelected);
            this.WindowColorPicker     = this.GetColorPicker("WindowColorPicker", this.OnWindowColorSelected);

            this.Preview = this.GetTemplateChild("Preview") as PreviewControl;

            this.Initialize();
        }
Exemplo n.º 9
0
        public void Init(Color color, string name)
        {
            AlphaSlider = new Slider("Alpha", color.A, 0, 255);
            RedSlider   = new Slider("Kirmisi", color.R, 0, 255);
            GreenSlider = new Slider("Yesil", color.B, 0, 255);
            BlueSlider  = new Slider("Mavi", color.G, 0, 255);
            Picker      = new ColorPickerControl(Id + "ColorDisplay", color);

            _menu.AddLabel(name);

            _menu.Add(Id + "ColorDisplay", Picker);
            _menu.Add(Id + "Alpha", AlphaSlider);
            _menu.Add(Id + "Red", RedSlider);
            _menu.Add(Id + "Green", GreenSlider);
            _menu.Add(Id + "Blue", BlueSlider);

            AlphaSlider.OnValueChange += OnValueChange;
            RedSlider.OnValueChange   += OnValueChange;
            GreenSlider.OnValueChange += OnValueChange;
            BlueSlider.OnValueChange  += OnValueChange;

            Picker.SetColor(Color.FromArgb(GetValue(ColorBytes.Alpha), GetValue(ColorBytes.Red),
                                           GetValue(ColorBytes.Green), GetValue(ColorBytes.Blue)));
        }
Exemplo n.º 10
0
        public Control GetWebControl(System.Web.HttpServerUtility server, XmlNode renderingDocument)
        {
            PlaceHolder ph = new PlaceHolder();

            Label lbl = new Label();

            if (renderingDocument.Attributes["renderedLabel"] != null)
            {
                lbl.Text = renderingDocument.Attributes["renderedLabel"].Value.FromXmlValue2Render(server);
            }
            else
            {
                lbl.Text = this.Name.FromXmlName2Render(server);
            }
            lbl.CssClass = "label";
            ph.Controls.Add(lbl);

            ColorPickerControl colp = new ColorPickerControl(this);

            colp.CausesValidation = false;

            if (renderingDocument.Attributes["class"] != null)
            {
                colp.CssClass = renderingDocument.Attributes["class"].Value.FromXmlValue2Render(server);
            }
            if (renderingDocument.Attributes["rel"] != null)
            {
                colp.Attributes.Add("rel", renderingDocument.Attributes["rel"].Value.FromXmlValue2Render(server));
            }
            if (renderingDocument.Attributes["description"] != null)
            {
                colp.ToolTip = renderingDocument.Attributes["description"].Value.FromXmlValue2Render(server);
            }
            colp.Style.Add("z-index", "1800");
            ph.Controls.Add(colp);

            /*** Validators ***/

            // Base validator
            RegularExpressionValidator rev = new RegularExpressionValidator();

            rev.ControlToValidate    = colp.ID;
            rev.Display              = ValidatorDisplay.Dynamic;
            rev.ErrorMessage         = "Color code not in the required format";
            rev.ValidationExpression = @"^\#([a-fA-F0-9]{6}|[a-fA-F0-9]{3})$";             // if empty the validator is not checked, that's fine
            rev.ValidationGroup      = "1";
            ph.Controls.Add(rev);

            // Required validator
            if (!Common.getElementFromSchema(baseSchema).IsNillable)
            {
                RequiredFieldValidator rqfv = new RequiredFieldValidator();
                rqfv.ErrorMessage      = "Required fields shouldn't be empty";
                rqfv.ControlToValidate = colp.ID;
                rqfv.ValidationGroup   = "1";
                rqfv.Display           = ValidatorDisplay.Dynamic;
                ph.Controls.Add(rqfv);
            }

            if (((XmlSchemaSimpleType)Common.getElementFromSchema(baseSchema).SchemaType) == null)
            {
                return(ph);
            }

            XmlSchemaObjectCollection constrColl =
                ((XmlSchemaSimpleTypeRestriction)
                 (
                     (XmlSchemaSimpleType)
                     Common.getElementFromSchema(baseSchema).SchemaType
                 ).Content
                ).Facets;

            foreach (XmlSchemaFacet facet in constrColl)
            {
                //TODO: No validators by now
            }

            return(ph);
        }
Exemplo n.º 11
0
 private void Awake()
 {
     colorPicker = GetComponent <ColorPickerControl>();
     vent        = LocatorProvider.Get().Get(MaruKeys.Vent) as IMessageBus;
     colorPicker.onValueChanged.AddListener(ColorPickerChanged);
 }