コード例 #1
0
 protected void rgFont_ItemDataBound(object sender, Telerik.Web.UI.GridItemEventArgs e)
 {
     if (e.Item.ItemType == GridItemType.EditItem)
     {
         RadColorPicker picker = (RadColorPicker)e.Item.FindControl("rcpColor");
         if (picker != null)
         {
             DayCarePL.FontProperties objFont = e.Item.DataItem as DayCarePL.FontProperties;
             if (objFont != null)
             {
                 picker.SelectedColor = ColorTranslator.FromHtml((DataBinder.Eval(objFont, "Color").ToString()));
             }
         }
     }
     if (e.Item.ItemType == GridItemType.Item || e.Item.ItemType == GridItemType.AlternatingItem)
     {
         DayCarePL.FontProperties item = e.Item.DataItem as DayCarePL.FontProperties;
         Label lblColor = e.Item.FindControl("lblColor") as Label;
         lblColor.Height    = 25;
         lblColor.Width     = 25;
         lblColor.BackColor = System.Drawing.ColorTranslator.FromHtml(item.Color);
     }
     if (e.Item.ItemIndex == -1)
     {
         if (e.Item.Edit == true)
         {
             GridEditableItem dataItem  = e.Item as Telerik.Web.UI.GridEditableItem;
             CheckBox         chkActive = dataItem["Active"].Controls[0] as CheckBox;
             chkActive.Checked = true;
         }
     }
 }
コード例 #2
0
ファイル: FormWizard.ascx.cs プロジェクト: VijayMVC/LeadForce
        /// <summary>
        /// Encodes the CSS.
        /// </summary>
        /// <returns></returns>
        protected string EncodeBackgroundCss(RadColorPicker rcpBackgroundColor)
        {
            var css = new StringBuilder();

            if (!rcpBackgroundColor.SelectedColor.IsEmpty)
            {
                css.AppendFormat("background-color:{0};", ColorTranslator.ToHtml(rcpBackgroundColor.SelectedColor));
            }

            if (css.ToString() == "")
            {
                return(null);
            }

            return(css.ToString());
        }
コード例 #3
0
        private FrameworkElement GetCellContent(GridViewCell cell, object dataItem)
        {
            Type myType = dataItem.GetType();
            IList <PropertyInfo> props = new List <PropertyInfo>(myType.GetProperties());
            var colorProp = props.FirstOrDefault(x => x.Name == this.DataMemberBinding.Path.Path);

            if (colorProp != null)
            {
                var            valueColor  = colorProp.GetValue(dataItem);
                RadColorPicker colorPicker = new RadColorPicker();
                if (valueColor != null && valueColor.ToString() != "")
                {
                    colorPicker.SelectedColor = (Color)System.Windows.Media.ColorConverter.ConvertFromString(valueColor.ToString());
                }
                colorPicker.SelectedColorChanged += (sender1, e1) => ColorPicker_SelectedColorChanged(sender1, e1, colorProp, dataItem);
                return(colorPicker);
                // Grid grid = new Grid();
                // grid.HorizontalAlignment = HorizontalAlignment.Stretch;
                // grid.ColumnDefinitions.Add(new ColumnDefinition() { Width = new GridLength(30) });
                // grid.ColumnDefinitions.Add(new ColumnDefinition() { Width = new GridLength() });
                // var button = new Button();
                // button.Content = "...";
                // var textBlock = new TextBlock();
                //textBlock.Width = 50;
                // textBlock.HorizontalAlignment = HorizontalAlignment.Stretch;

                // if (valueColor != null && valueColor.ToString() != "")
                // {
                //     System.Windows.Media.Color color = (Color)System.Windows.Media.ColorConverter.ConvertFromString(valueColor.ToString());
                //     var colorBrush = new SolidColorBrush(color);
                //     textBlock.Background = colorBrush;
                // }
                // button.Click += (sender, e) => Button_Click(sender, e, textBlock, colorProp, dataItem, textBlock.Background as SolidColorBrush);
                // grid.Children.Add(button);
                // Grid.SetColumn(textBlock, 1);
                // grid.Children.Add(textBlock);
                // return grid;
            }



            return(null);
        }
コード例 #4
0
        protected override Control GetControl()
        {
            var colorPicker = new RadColorPicker();

            if (this.DataMemberBinding != null)
            {
                colorPicker.SetBinding(this.GetControlBindingProperty(), this.DataMemberBinding);
            }

            colorPicker.SetBinding(
                RadColorPicker.SelectedColorProperty,
                new Binding("Color")
            {
                Source          = this.Item,
                Mode            = BindingMode.TwoWay,
                TargetNullValue = Colors.Transparent
            });

            return(colorPicker);
        }