예제 #1
1
        public ButtonBarControl(WebcamControl element)
        {
            InitializeComponent();
            this.parent = element;
            this.Name = "buttonBar";
            int i;

            buttons=new Button[numberOfButtons];
            double buttonSpace = parent.WebcamImage.ActualWidth / numberOfButtons;

            Style style = new Style(typeof(Button));
            style.Setters.Add(new Setter { Property = OverridesDefaultStyleProperty, Value = true });

            Setter templateSetter = new Setter();
            templateSetter.Property = TemplateProperty;

            ControlTemplate controlTemplate = new ControlTemplate(typeof(Button));

            FrameworkElementFactory fact = new FrameworkElementFactory(typeof(Border));

            controlTemplate.VisualTree = fact;

            fact.Name = "Border";
            //fact.SetValue(Border.BorderThicknessProperty, new Thickness(1));
            //fact.SetValue(Border.CornerRadiusProperty, new CornerRadius(2));
            fact.SetValue(Border.BackgroundProperty,new TemplateBindingExtension(Button.BackgroundProperty));
            //fact.SetValue(Border.BorderBrushProperty, Brushes.Aquamarine);

            Trigger triggerIsMouseOver = new Trigger { Property = Border.IsMouseOverProperty, Value = true };

            Binding b = new Binding();
            b.RelativeSource = new RelativeSource(RelativeSourceMode.TemplatedParent);
            b.Path = new PropertyPath(Button.BorderBrushProperty);

            Setter setter = new Setter(Border.BackgroundProperty, b, "Border");

            triggerIsMouseOver.Setters.Add(setter);

            controlTemplate.Triggers.Add(triggerIsMouseOver);
            templateSetter.Value = controlTemplate;

            style.Setters.Add(templateSetter);

            for (i = 0; i < numberOfButtons; i++)
            {
                buttons[i] = new Button();
                //buttons[i].Foreground = new ImageBrush(new BitmapImage(new Uri("test.png", UriKind.Relative)));
                buttons[i].Style = style;
                buttons[i].Background = new ImageBrush(new BitmapImage(new Uri((i+1)+"1.png", UriKind.Relative)));
                buttons[i].BorderBrush = new ImageBrush(new BitmapImage(new Uri((i+1)+"2.png", UriKind.Relative)));
                //buttons[i].Content = "Button" + i;
                buttons[i].Width = (buttonSpace-0.1*buttonSpace);
                buttons[i].Height = 100 - 20;
                buttons[i].Margin = new Thickness(0.05*buttonSpace, 10, 0.05*buttonSpace, 0);
                buttons[i].Click += new RoutedEventHandler(ButtonBar_Click);
                buttonStack.Children.Add(buttons[i]);

            }
        }
        public StyleSelectionMenuItemList()
        {
            ItemsSource = ItemsSource = AvailableStyles.Instance;

            var checkableMenuItemStyle = new Style { TargetType = typeof(MenuItem) };

            var headerBinding = new Binding();
            var headerSetter = new Setter(HeaderProperty, headerBinding);
            checkableMenuItemStyle.Setters.Add(headerSetter);

            var isCheckableSetter = new Setter(IsCheckableProperty, true);
            checkableMenuItemStyle.Setters.Add(isCheckableSetter);

            ICommand command = new RelayCommand(SelectStyle);
            var commandSetter = new Setter(CommandProperty, command);
            checkableMenuItemStyle.Setters.Add(commandSetter);

            var commandParamBinding = new Binding();
            var commandParamSetter = new Setter(CommandParameterProperty, commandParamBinding);
            checkableMenuItemStyle.Setters.Add(commandParamSetter);

            var isCheckedMultiBinding = new MultiBinding { Converter = new MultiValueStringsMatchConverter(), Mode = BindingMode.OneWay };
            isCheckedMultiBinding.Bindings.Add(new Binding { Mode = BindingMode.OneWay });
            isCheckedMultiBinding.Bindings.Add(new Binding("SelectedStyle") { Source = AvailableStyles.Instance, Mode = BindingMode.OneWay });
            var isCheckedSetter = new Setter(IsCheckedProperty, isCheckedMultiBinding);
            checkableMenuItemStyle.Setters.Add(isCheckedSetter);

            Resources.Add(typeof(MenuItem), checkableMenuItemStyle);
        }
예제 #3
0
파일: SetterTest.cs 프로젝트: dfr0/moon
		public void CreateTest ()
		{
			Setter s = new Setter (UIElement.OpacityProperty, 2.0);

			Assert.AreEqual (UIElement.OpacityProperty, s.Property);
			Assert.AreEqual (2.0, s.Value);
		}
 private static SetterBase CreateSetter(EntityFieldInfo fieldInfo, IDataService dataService, GenericDataListState state, bool? isLocked, FrameworkElement element)
 {
     Setter setter = new Setter();
     setter.Property = ContentControl.ContentTemplateProperty;
     setter.Value = DataControlTemplateBuilder.CreateTemplate(fieldInfo, dataService,  state, isLocked,element);
     return setter;
 }
        public override Style SelectStyle(object item, DependencyObject container)
        {
            Style style = new Style {
                TargetType = typeof(ListBoxItem)
            };
            Setter setter = new Setter {
                Property = Control.BackgroundProperty
            };
            ListBox box = ItemsControl.ItemsControlFromItemContainer(container) as ListBox;
            switch (box.ItemContainerGenerator.IndexFromContainer(container))
            {
                case 0:
                    setter.Value = Brushes.LightBlue;
                    break;

                case 1:
                    setter.Value = Brushes.Green;
                    break;

                default:
                    setter.Value = Brushes.SaddleBrown;
                    break;
            }
            style.Setters.Add(setter);
            return style;
        }
예제 #6
0
        public LabelTextBox()
        {
            this.AcceptsReturn = true;
            this.FontWeight = FontWeights.Bold;
            this.BorderThickness = new Thickness(0);

            Setter borderSetter = new Setter();
            borderSetter.Property = TextBox.BorderThicknessProperty;
            borderSetter.Value = new Thickness(0);

            Trigger readOnlyTrigger = new Trigger();
            readOnlyTrigger.Property = TextBox.IsReadOnlyProperty;
            readOnlyTrigger.Value = true;
            readOnlyTrigger.Setters.Add(borderSetter);

            Setter borderFocusSetter = new Setter();
            borderFocusSetter.Property = TextBox.BorderThicknessProperty;
            borderFocusSetter.Value = new Thickness(0);

            Trigger focusTrigger = new Trigger();
            focusTrigger.Property = TextBox.IsFocusedProperty;
            focusTrigger.Value = true;
            focusTrigger.Setters.Add(borderFocusSetter);

            Style style = new Style();
            style.Triggers.Add(readOnlyTrigger);
            style.Triggers.Add(focusTrigger);

            this.Style = style;
            this.SnapsToDevicePixels = true;
        }
예제 #7
0
		public void TestImplicitStyleRectangle_styleInRectangleDictionary ()
		{
			Style rectStyle = new Style { TargetType = typeof (Rectangle) };
			Setter setter = new Setter (FrameworkElement.WidthProperty, 100.0);
			rectStyle.Setters.Add (setter);

			Rectangle r = new Rectangle ();

			Assert.IsTrue (Double.IsNaN (r.Width), "1");

			r.Resources.Add (typeof (Rectangle), rectStyle);

			Assert.AreEqual (100.0, r.Width, "2");

			CreateAsyncTest (r,  () => {
					Assert.AreEqual (100.0, r.Width, "3");

					//setter.Value = 200.0;
					//Assert.AreEqual (200.0, r.Width, "4");

					rectStyle.Setters.Remove (setter);

					Assert.AreEqual (100.0, r.Width, "5");
				});
		}
예제 #8
0
		public void TestImplicitStyleRectangle_multipleImplicitStylesInVisualTree ()
		{
			Style rectStyle1 = new Style { TargetType = typeof (Rectangle) };
			Setter setter = new Setter (FrameworkElement.WidthProperty, 100.0);
			rectStyle1.Setters.Add (setter);

			Style rectStyle2 = new Style { TargetType = typeof (Rectangle) };
			setter = new Setter (FrameworkElement.HeightProperty, 100.0);
			rectStyle2.Setters.Add (setter);

			Rectangle r = new Rectangle ();
			r.Resources.Add (typeof (Rectangle), rectStyle1);

			Canvas c = new Canvas ();
			c.Resources.Add (typeof (Rectangle), rectStyle2);

			c.Children.Add (r);

			Assert.IsTrue (Double.IsNaN (r.Height), "1");

			CreateAsyncTest (c,  () => {
					Assert.AreEqual (100.0, r.Width, "2");
					Assert.IsTrue (Double.IsNaN (r.Height), "3");

					r.Resources.Remove (typeof (Rectangle));

					Assert.AreEqual (100.0, r.Height, "4");
					Assert.IsTrue (Double.IsNaN (r.Width), "5");
				});
		}
예제 #9
0
파일: Theme.cs 프로젝트: dstiert/bloop
        public ResourceDictionary GetResourceDictionary()
        {
            var dict = new ResourceDictionary
            {
                Source = new Uri(GetThemePath(UserSettingStorage.Instance.Theme), UriKind.Absolute)
            };

            Style queryBoxStyle = dict["QueryBoxStyle"] as Style;
            if (queryBoxStyle != null)
            {
                queryBoxStyle.Setters.Add(new Setter(TextBox.FontFamilyProperty, new FontFamily(UserSettingStorage.Instance.QueryBoxFont)));
                queryBoxStyle.Setters.Add(new Setter(TextBox.FontStyleProperty, FontHelper.GetFontStyleFromInvariantStringOrNormal(UserSettingStorage.Instance.QueryBoxFontStyle)));
                queryBoxStyle.Setters.Add(new Setter(TextBox.FontWeightProperty, FontHelper.GetFontWeightFromInvariantStringOrNormal(UserSettingStorage.Instance.QueryBoxFontWeight)));
                queryBoxStyle.Setters.Add(new Setter(TextBox.FontStretchProperty, FontHelper.GetFontStretchFromInvariantStringOrNormal(UserSettingStorage.Instance.QueryBoxFontStretch)));
            }

            Style resultItemStyle = dict["ItemTitleStyle"] as Style;
            Style resultSubItemStyle = dict["ItemSubTitleStyle"] as Style;
            Style resultItemSelectedStyle = dict["ItemTitleSelectedStyle"] as Style;
            Style resultSubItemSelectedStyle = dict["ItemSubTitleSelectedStyle"] as Style;
            if (resultItemStyle != null && resultSubItemStyle != null && resultSubItemSelectedStyle != null && resultItemSelectedStyle != null)
            {
                Setter fontFamily = new Setter(TextBlock.FontFamilyProperty, new FontFamily(UserSettingStorage.Instance.ResultItemFont));
                Setter fontStyle = new Setter(TextBlock.FontStyleProperty, FontHelper.GetFontStyleFromInvariantStringOrNormal(UserSettingStorage.Instance.ResultItemFontStyle));
                Setter fontWeight = new Setter(TextBlock.FontWeightProperty, FontHelper.GetFontWeightFromInvariantStringOrNormal(UserSettingStorage.Instance.ResultItemFontWeight));
                Setter fontStretch = new Setter(TextBlock.FontStretchProperty, FontHelper.GetFontStretchFromInvariantStringOrNormal(UserSettingStorage.Instance.ResultItemFontStretch));

                Setter[] setters = new Setter[] { fontFamily, fontStyle, fontWeight, fontStretch };
                Array.ForEach(new Style[] { resultItemStyle, resultSubItemStyle, resultItemSelectedStyle, resultSubItemSelectedStyle }, o => Array.ForEach(setters, p => o.Setters.Add(p)));
            }

            return dict;
        }
예제 #10
0
        private void Window_Loaded(object sender, RoutedEventArgs e)
        {
            GridView myGridView = new GridView();
            myGridView.AllowsColumnReorder = true;

            //Collapse the header
            Style collapsedHeaderStyle = new Style();
            Setter collapsedHeaderSetter = new Setter();

            collapsedHeaderSetter.Property = VisibilityProperty;
            collapsedHeaderSetter.Value = Visibility.Collapsed;
            collapsedHeaderStyle.Setters.Add(collapsedHeaderSetter);

            myGridView.ColumnHeaderContainerStyle = collapsedHeaderStyle;

            for (int i = 0; i < control.XSize; i++)
            {
                GridViewColumn col = new GridViewColumn();
                col.DisplayMemberBinding = new Binding("Column[" + i.ToString() + "]");
                col.Width = 30;
                myGridView.Columns.Add(col);
            }

            listView.View = myGridView;
            listView.DataContext = control.AgentCollection;
        }
        public ZoomableInlineAdornment(UIElement content, ITextView parent) {
            _parent = parent;
            Debug.Assert(parent is IInputElement);
            Content = new Border { BorderThickness = new Thickness(1), Child = content, Focusable = true };

            _zoom = 1.0;             // config.GetConfig().Repl.InlineMedia.MaximizedZoom
            _zoomStep = 0.25;        // config.GetConfig().Repl.InlineMedia.ZoomStep
            _minimizedZoom = 0.25;   // config.GetConfig().Repl.InlineMedia.MinimizedZoom
            _widthRatio = 0.67;      // config.GetConfig().Repl.InlineMedia.WidthRatio
            _heightRatio = 0.5;      // config.GetConfig().Repl.InlineMedia.HeightRatio

            _isResizing = false;
            UpdateSize();

            GotFocus += OnGotFocus;
            LostFocus += OnLostFocus;

            ContextMenu = MakeContextMenu();

            var trigger = new Trigger { Property = Border.IsFocusedProperty, Value = true };
            var setter = new Setter { Property = Border.BorderBrushProperty, Value = SystemColors.ActiveBorderBrush };
            trigger.Setters.Add(setter);

            var style = new Style();
            style.Triggers.Add(trigger);
            MyContent.Style = style;
        }
예제 #12
0
        public AlternatingListBoxBackground(Color color1, Color color2)
        {
            var setter = new Setter();
            setter.Property = ListBoxItem.BackgroundProperty;
            setter.Value = new SolidColorBrush(color1);

            var trigger = new Trigger();
            trigger.Property = ItemsControl.AlternationIndexProperty;
            trigger.Value = 0;
            trigger.Setters.Add(setter);

            var setter2 = new Setter();
            setter2.Property = ListBoxItem.BackgroundProperty;
            setter2.Value = new SolidColorBrush(color2);

            var trigger2 = new Trigger();
            trigger2.Property = ItemsControl.AlternationIndexProperty;
            trigger2.Value = 1;
            trigger2.Setters.Add(setter2);

            var listBoxStyle = new Style(typeof(ListBoxItem));
            listBoxStyle.Triggers.Add(trigger);
            listBoxStyle.Triggers.Add(trigger2);

            _listBoxStyle = listBoxStyle;
        }
        object FindResource(object resourceKey)
        {
            // NOTE: This code depends on internal implementation details of WPF and 
            // might break in a future release of the platform.  Use at your own risk!

            var resourceReferenceExpression =
                new DynamicResourceExtension(resourceKey).ProvideValue(null)
                as Expression;

            MethodInfo getValue = typeof(Expression).GetMethod(
                "GetValue",
                BindingFlags.Instance | BindingFlags.NonPublic);

            object result = getValue.Invoke(
                resourceReferenceExpression,
                new object[] { this, DummyProperty });

            // Either we do not have an inheritance context or the  
            // requested resource does not exist, so return null.
            if (result == DependencyProperty.UnsetValue)
                return null;

            // The requested resource was found, so we will receive a 
            // DeferredResourceReference object as a result of calling 
            // GetValue.  The only way to resolve that to the actual 
            // resource, without using reflection, is to have a Setter's 
            // Value property unwrap it for us.
            var deferredResourceReference = result;
            Setter setter = new Setter(DummyProperty, deferredResourceReference);
            return setter.Value;
        }
예제 #14
0
파일: SetterTest.cs 프로젝트: dfr0/moon
		public void Defaults ()
		{
			Setter s = new Setter ();
			Assert.IsNull (s.Property, "Property");
			Assert.IsNull (s.Value, "Value");
			// SetterBase (can't be tested indivisually since the type has no visible ctor)
			Assert.IsFalse (s.IsSealed, "IsSealed");
		}
    public void CopyTo(Setter[] array, int arrayIndex)
    {
      if (array == null)
      {
        throw new ArgumentNullException("array");
      }

      List.CopyTo(array, arrayIndex);
    }
예제 #16
0
파일: SetterTest.cs 프로젝트: dfr0/moon
		public void NullProperty ()
		{
			Assert.Throws<NullReferenceException> (delegate { 
				new Setter (null, 2.0); 
			}, "ctor");

			Setter s = new Setter (UIElement.OpacityProperty, 2.0);
			Assert.Throws<NullReferenceException> (delegate {
				s.Property = null;
			}, "Property");
		}
예제 #17
0
 /// <summary>
 /// Initialises a new instance of the MenuIconImage class.
 /// </summary>
 public MenuIconImage()
 {
     Style imgStyle = new Style(typeof(Image));
     Trigger trg = new Trigger();
     trg.Property = Image.IsEnabledProperty;
     trg.Value = false;
     Setter setter = new Setter(Image.OpacityProperty, 0.5);
     trg.Setters.Add(setter);
     imgStyle.Triggers.Add(trg);
     this.Style = imgStyle;
 }
예제 #18
0
        protected override void ApplyToWpfStyle(Style existingStyle, IFigure figure)
        {
            base.ApplyToWpfStyle(existingStyle, figure);
            var brush = Background;
            if (!IsFilled)
            {
                brush = null;
            }

            var fillSetter = new Setter(Canvas.BackgroundProperty, brush);
            existingStyle.Setters.Add(fillSetter);
        }
예제 #19
0
        public override Style SelectStyle(object item, DependencyObject container)
        {
            if (((GridViewRow)container).GridViewDataControl.Items.IndexOf(item) == 0)
            {
                Style style = new Style(typeof(GridViewRow));
                Setter setter = new Setter(GridViewRow.DetailsVisibilityProperty, Visibility.Visible);
                style.Setters.Add(setter);
                return style;
            }

            return new Style(typeof(GridViewRow));
        }
        public override Style SelectStyle(object item, DependencyObject container)
        {
            if (((GridViewRow)container).GridViewDataControl.Items.IndexOf(item) == 0)
            {
				Style style = new Style(typeof(GridViewRow)) { BasedOn = (Style)Application.Current.Resources["GridViewRowStyle"] };
                Setter setter = new Setter(GridViewRow.DetailsVisibilityProperty, Visibility.Visible);
                style.Setters.Add(setter);
                return style;
            }

            return new Style(typeof(GridViewRow)) { BasedOn = (Style)Application.Current.Resources["GridViewRowStyle"] };
        }
예제 #21
0
        void UpdateParagraphStyle()
        {
            if (paragraphStyle != null) {
                Resources.Remove (typeof (Paragraph));
                paragraphStyle = null;
            }

            paragraphStyle = new Style (typeof (Paragraph));
            var lineHeightSetter = new Setter (Block.LineHeightProperty, FontSize + lineSpacing);
            paragraphStyle.Setters.Add (lineHeightSetter);

            Resources.Add (typeof (Paragraph), paragraphStyle);
        }
        public override Style SelectStyle(object item,
                                          DependencyObject container)
        {
            var st = new Style {TargetType = typeof (ListBoxItem)};
            var backGroundSetter = new Setter {Property = Control.BackgroundProperty};
            var listBox = ItemsControl.ItemsControlFromItemContainer(container) as ListBox;
            int index = listBox.ItemContainerGenerator.IndexFromContainer(container);

            backGroundSetter.Value = index%2 == 0 ? Brushes.LightYellow : Brushes.Transparent;
            st.Setters.Add(backGroundSetter);

            return st;
        }
예제 #23
0
        public BuildButtonFactory()
        {
            Title = "Build Button Factory";

            ControlTemplate template = new ControlTemplate(typeof(Button));

            FrameworkElementFactory factoryBorder = new FrameworkElementFactory(typeof(Border));
            factoryBorder.Name = "border";
            factoryBorder.SetValue(Border.BorderBrushProperty, Brushes.Red);
            factoryBorder.SetValue(Border.BorderThicknessProperty, new Thickness(3));
            factoryBorder.SetValue(Border.BackgroundProperty, SystemColors.ControlLightBrush);

            FrameworkElementFactory factoryContent = new FrameworkElementFactory(typeof(ContentPresenter));
            factoryContent.Name = "content";
            factoryContent.SetValue(ContentPresenter.ContentProperty,
                new TemplateBindingExtension(Button.ContentProperty));
            factoryContent.SetValue(ContentPresenter.MarginProperty,
                new TemplateBindingExtension(Button.PaddingProperty));

            factoryBorder.AppendChild(factoryContent);
            template.VisualTree = factoryBorder;

            Trigger trig = new Trigger();
            trig.Property = UIElement.IsMouseOverProperty;
            trig.Value = true;

            Setter set = new Setter();
            set.Property = Border.CornerRadiusProperty;
            set.Value = new CornerRadius(24);
            set.TargetName = "border";
            trig.Setters.Add(set);

            set = new Setter();
            set.Property = Control.FontStyleProperty;
            set.Value = FontStyles.Italic;
            trig.Setters.Add(set);

            template.Triggers.Add(trig);

            Button btn = new Button();
            btn.Template = template;
            btn.Content = "Button with Custom Template";
            btn.Padding = new Thickness(20);
            btn.FontSize = 48;
            btn.HorizontalAlignment = HorizontalAlignment.Center;
            btn.VerticalAlignment = VerticalAlignment.Center;
            btn.Click += ButtonOnClick;

            Content = btn;
        }
예제 #24
0
        public override Style SelectStyle(object item,
            DependencyObject container)
        {
            var foregroundSetter = new Setter
            {
                Property = ListViewItem.ForegroundProperty,
            };
            var style = new Style
            {
                TargetType = typeof(ListViewItem),
            };
            foregroundSetter.Value = Brushes.Gray;
            style.Setters.Add(foregroundSetter);
            var listView = ItemsControl.ItemsControlFromItemContainer(container) as ListView;
            if (listView != null)
            {
                var L_item = item as ViewModels.ConsoleMessage;
                if (L_item != null)
                {
                    switch (L_item.Category.ToUpperInvariant())
                    {
                        case "CRITICAL":
                            foregroundSetter.Value = Brushes.Red;
                            break;

                        case "ERROR":
                            foregroundSetter.Value = Brushes.Orange;
                            break;

                        case "WARNING":
                            foregroundSetter.Value = Brushes.Yellow;
                            break;

                        case "INFORMATION":
                        case "MUBOX":
                            foregroundSetter.Value = Brushes.CornflowerBlue;
                            break;

                        case "VERBOSE":
                            foregroundSetter.Value = Brushes.Gray;
                            break;

                        default:
                            foregroundSetter.Value = Brushes.GhostWhite;
                            break;
                    }
                }
            }
            return style;
        }
예제 #25
0
		private void SealedChildren (bool seal)
		{
			Style style = new Style (typeof (UIElement));
			SetterBaseCollection c = style.Setters;
			Setter s = new Setter (Canvas.LeftProperty, 0);

			c.Add (s);

			if (seal)
				style.Seal ();

			// the setter IsSealed status has nothing to do with sealing the style
			Assert.Throws (delegate { s.Property = Canvas.TopProperty; }, typeof (UnauthorizedAccessException));
			Assert.Throws (delegate { s.Value = 10; }, typeof (UnauthorizedAccessException));
		}
예제 #26
0
        public MainWindow()
        {
            InitializeComponent();

            _drillingChanger = new Setter( ChangeDrillingProgressBarValue );
            _fireingChanger = new Setter(ChangeFireingProgressBarValue);
            _plumbingChanger = new Setter( ChangePlumbingProgressBarValue );
            _pipeRuptureChanger = new Setter( ChangePipeRuptureProgressBarValue );
            _miningChanger = new Setter( ChangeMiningProgressBarValue );

            ResetValues();
            TimerThread = new System.Threading.Thread(Timer);
            TimerThread.IsBackground = true;
            TimerThread.Start();
        }
예제 #27
0
        public object Convert(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
        {
            NetworkEdgeType type = (NetworkEdgeType)value;

            DiagramLink link = parameter as DiagramLink;
            if (link != null)
            {
                Style style = new Style();
                Setter setter = new Setter();
                string str;
                switch (type)
                {
                    case NetworkEdgeType.Agent:
                        str = "Agent";
                        break;
                    case NetworkEdgeType.Recipient:
                        str = "Recipient";
                        break;
                    case NetworkEdgeType.Goal:
                        str = "Goal";
                        break;
                    case NetworkEdgeType.Locative:
                        str = "Locative";
                        break;
                    case NetworkEdgeType.Follow:
                        str = "Follow";
                        break;
                    case NetworkEdgeType.IsInstance:
                        str = "IsInstance";
                        break;
                    default:
                        str = "IsA";
                        break;
                }
                SolidColorBrush brush = App.Current.TryFindResource(str + "Brush") as SolidColorBrush;
                Pen pen = App.Current.FindResource(str + "Pen") as Pen;

                link.HeadPen = pen;
                link.Stroke = brush;
                link.Brush = App.Current.TryFindResource("LinkFillBrush") as SolidColorBrush;
                //link.StrokeThickness = App.StrokeThickness;
                link.TextBrush = brush;
                link.FontWeight = FontWeights.Bold;

            }

            return Utils.ConvertType(type);
        }
    public static void SetListViewContentAlignmentStrech(ListView listView)
    {
        Style style = new Style();
        style.TargetType = typeof(ListViewItem);
        Setter setter = new Setter();
        setter.Property = ListViewItem.HorizontalContentAlignmentProperty;
        setter.Value = HorizontalAlignment.Stretch;
        style.Setters.Add(setter);

        setter = new Setter();
        setter.Property = ListViewItem.VerticalContentAlignmentProperty;
        setter.Value = VerticalAlignment.Stretch;
        style.Setters.Add(setter);

        listView.ItemContainerStyle = style;
    }
예제 #29
0
        public ListBoxHotColor(Color hotColor)
        {
            var setter = new Setter();
            setter.Property = ListBoxItem.BackgroundProperty;
            setter.Value = new SolidColorBrush(hotColor);

            var trigger = new MultiTrigger();
            trigger.Conditions.Add(new Condition(ListBoxItem.IsMouseOverProperty, true));
            trigger.Conditions.Add(new Condition(ListBoxItem.IsSelectedProperty, false));
            trigger.Setters.Add(setter);

            var listBoxStyle = new Style(typeof(ListBoxItem));
            listBoxStyle.Triggers.Add(trigger);

            _listBoxStyle = listBoxStyle;
        }
예제 #30
0
        private void Application_Startup(object sender, StartupEventArgs e)
        {
            _initParams = e.InitParams;

            string defaultColor = "LightBlue";

            if (_initParams.ContainsKey("DefaultColor") && !string.IsNullOrEmpty(_initParams["DefaultColor"]))
                defaultColor = _initParams["DefaultColor"];
         
            
            Setter gridBackgroundColorSetter = new Setter(Grid.BackgroundProperty, defaultColor);
            ((Style)this.Resources["GridStyle"]).Setters.Add(gridBackgroundColorSetter);

            Setter borderBackgroundColorSetter = new Setter(Border.BackgroundProperty, defaultColor);
            ((Style)this.Resources["BorderStyle"]).Setters.Add(borderBackgroundColorSetter);

            this.RootVisual = new Page();
        }
예제 #31
0
        private void handleListFilterType()
        {
            if (FilterCurrentData.Type == FilterType.List)
            {
                ComboBox comboBox             = this.Template.FindName("PART_ComboBoxFilter", this) as ComboBox;
                DataGridComboBoxColumn column = AssignedDataGridColumn as DataGridComboBoxColumn;

                if (comboBox != null && column != null)
                {
                    if (DataGridComboBoxExtensions.GetIsTextFilter(column))
                    {
                        FilterCurrentData.Type = FilterType.Text;
                        initControlType();
                    }
                    else //list filter type
                    {
                        Binding columnItemsSourceBinding = null;
                        columnItemsSourceBinding = BindingOperations.GetBinding(column, DataGridComboBoxColumn.ItemsSourceProperty);

                        if (columnItemsSourceBinding == null)
                        {
                            System.Windows.Setter styleSetter = column.EditingElementStyle.Setters.FirstOrDefault(s => ((System.Windows.Setter)s).Property == DataGridComboBoxColumn.ItemsSourceProperty) as System.Windows.Setter;
                            if (styleSetter != null)
                            {
                                columnItemsSourceBinding = styleSetter.Value as Binding;
                            }
                        }

                        comboBox.DisplayMemberPath = column.DisplayMemberPath;
                        comboBox.SelectedValuePath = column.SelectedValuePath;

                        if (columnItemsSourceBinding != null)
                        {
                            BindingOperations.SetBinding(comboBox, ComboBox.ItemsSourceProperty, columnItemsSourceBinding);
                        }

                        comboBox.RequestBringIntoView
                            += new RequestBringIntoViewEventHandler(setComboBindingAndHanldeUnsetValue);
                    }
                }
            }
        }
예제 #32
0
파일: Style.cs 프로젝트: wawawowowuwu/wpf
        // Iterates through the setters collection and adds the EventSetter information into
        // an EventHandlersStore for easy and fast retrieval during event routing. Also adds
        // an entry in the EventDependents list for EventhandlersStore holding the TargetType's
        // events.
        private void ProcessSetters(Style style)
        {
            // Walk down to bottom of based-on chain
            if (style == null)
            {
                return;
            }

            style.Setters.Seal(); // Does not mark individual setters as sealed, that's up to the loop below.


            // On-demand create the PropertyValues list, so that we can specify the right size.

            if (PropertyValues.Count == 0)
            {
                PropertyValues = new FrugalStructList <System.Windows.PropertyValue>(style.Setters.Count);
            }

            // Add EventSetters to local EventHandlersStore
            for (int i = 0; i < style.Setters.Count; i++)
            {
                SetterBase setterBase = style.Setters[i];
                Debug.Assert(setterBase != null, "Setter collection must contain non-null instances of SetterBase");

                // Setters are folded into the PropertyValues table only for the current style. The
                // processing of BasedOn Style properties will occur in subsequent call to ProcessSelfStyle
                Setter setter = setterBase as Setter;
                if (setter != null)
                {
                    // Style Setters are not allowed to have a child target name - since there are no child nodes in a Style.
                    if (setter.TargetName != null)
                    {
                        throw new InvalidOperationException(SR.Get(SRID.SetterOnStyleNotAllowedToHaveTarget, setter.TargetName));
                    }

                    if (style == this)
                    {
                        DynamicResourceExtension dynamicResource = setter.ValueInternal as DynamicResourceExtension;
                        if (dynamicResource == null)
                        {
                            UpdatePropertyValueList(setter.Property, PropertyValueType.Set, setter.ValueInternal);
                        }
                        else
                        {
                            UpdatePropertyValueList(setter.Property, PropertyValueType.Resource, dynamicResource.ResourceKey);
                        }
                    }
                }
                else
                {
                    Debug.Assert(setterBase is EventSetter,
                                 "Unsupported SetterBase subclass in style triggers ({0})", setterBase.GetType().ToString());

                    // Add this to the _eventHandlersStore

                    EventSetter eventSetter = (EventSetter)setterBase;
                    if (_eventHandlersStore == null)
                    {
                        _eventHandlersStore = new EventHandlersStore();
                    }
                    _eventHandlersStore.AddRoutedEventHandler(eventSetter.Event, eventSetter.Handler, eventSetter.HandledEventsToo);

                    SetModified(HasEventSetter);

                    // If this event setter watches the loaded/unloaded events, set the optimization
                    // flag.

                    if (eventSetter.Event == FrameworkElement.LoadedEvent || eventSetter.Event == FrameworkElement.UnloadedEvent)
                    {
                        _hasLoadedChangeHandler = true;
                    }
                }
            }

            // Process EventSetters on based on style so they get merged
            // into the EventHandlersStore for the current style.
            ProcessSetters(style._basedOn);
        }