예제 #1
2
파일: MyThumb.cs 프로젝트: shader/QuickArch
 public MyThumb(ControlTemplate template, string title, Point position)
     : this()
 {
     this.Template = template;
     this.Title = (title != null) ? title : string.Empty;
     this.SetPosition(position);
 }
예제 #2
1
 public SymbolControl(ControlTemplate template)
 {
     Template = template;
     _dataContext = new SymbolControlContext();
     DataContext = _dataContext;
     HorizontalContentAlignment = HorizontalAlignment.Center;
 }
 internal static Adorner Create(UIElement element, ControlTemplate template)
 {
     var adorner = (Adorner)Constructor.Invoke(new object[] { element, template });
     adorner.Bind(FrameworkElement.DataContextProperty)
            .OneWayTo(element, FrameworkElement.DataContextProperty);
     return adorner;
 }
예제 #4
1
        public static ControlTemplate GetBuildDoneImage(BuildInfo buildInfo, IEnumerable<ProjectItem> allProjects, out ControlTemplate stateImage)
        {
            if (buildInfo == null || buildInfo.BuildAction == null || buildInfo.BuildScope == null)
            {
                stateImage = null;
                return VectorResources.TryGet(BuildActionResourcesUri, "StandBy");
            }

            if (allProjects == null)
                throw new InvalidOperationException();

            int errorProjectsCount = allProjects.Count(item => item.State.IsErrorState());
            bool buildedProjectsSuccess = buildInfo.BuildedProjects.BuildWithoutErrors;

            string stateKey;
            if (buildInfo.BuildIsCancelled)
                stateKey = "BuildCancelled";
            else if (!buildedProjectsSuccess)
                stateKey = "BuildError";
            else if (buildedProjectsSuccess && errorProjectsCount == 0)
                stateKey = "BuildDone";
            else if (buildedProjectsSuccess && errorProjectsCount != 0)
                stateKey = "BuildErrorDone";
            else
                throw new InvalidOperationException();

            stateImage = VectorResources.TryGet(BuildStateResourcesUri, stateKey);

            string actionKey = GetBuildActionResourceKey(buildInfo.BuildAction.Value);
            return VectorResources.TryGet(BuildActionResourcesUri, actionKey);
        }
 /// <summary>
 /// Provides derived classes an opportunity to handle changes to the Template property.
 /// </summary>
 protected virtual void OnTemplateChanged(ControlTemplate oldTemplate, ControlTemplate newTemplate)
 {
     _mask = (FrameworkElement)newTemplate.LoadContent();
     _canvas.Children.Clear();
     _canvas.Children.Add(_mask);
     SetBindings();
 }
예제 #6
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]);

            }
        }
예제 #7
0
        //private static readonly DataTemplate DefaultTemplate;
        static ComboBoxBackend()
        {
            if (System.Windows.Application.Current.Resources.MergedDictionaries.Count == 0 ||
                !System.Windows.Application.Current.Resources.MergedDictionaries.Any(x => x.Contains(typeof(ExComboBox))))
            {
                var factory = new FrameworkElementFactory(typeof(WindowsSeparator));
                factory.SetValue(FrameworkElement.HorizontalAlignmentProperty, HorizontalAlignment.Stretch);

                var sepTemplate = new ControlTemplate(typeof(ComboBoxItem));
                sepTemplate.VisualTree = factory;

                DataTrigger trigger = new DataTrigger();
                trigger.Binding = new Binding(".[1]") { Converter = new TypeToStringConverter() };
                trigger.Value = typeof(ItemSeparator).Name;
                trigger.Setters.Add(new Setter(Control.TemplateProperty, sepTemplate));
                trigger.Setters.Add(new Setter(UIElement.IsEnabledProperty, false));

                ContainerStyle = new Style(typeof(ComboBoxItem));
                ContainerStyle.Triggers.Add(trigger);
            }
            else
            {
                ContainerStyle = null;
            }
        }
예제 #8
0
 /// <summary>
 /// Initializes a new instance of the <see cref="TemplatedAdorner"/> class.
 /// </summary>
 /// <param name="adornedElement">The adorned element.</param>
 /// <param name="dataContext">The data context.</param>
 /// <param name="adornerTemplate">The adorner template.</param>
 public TemplatedAdorner(UIElement adornedElement, object dataContext, ControlTemplate adornerTemplate)
     : base(adornedElement)
 {
     _child = new Control {Template = adornerTemplate};
     DataContext = dataContext;
     AddVisualChild(_child);
 }
 public PinButton(ControlTemplate template, string title, string imageSource, Point position)
     : this()
 {
     this.Template = template;
     this.ImageSource = (imageSource != null) ? imageSource : string.Empty;
     this.SetPosition(position);
 }
예제 #10
0
 public WinRegister(WinLogin login)
 {
     this.InitializeComponent();
     this.login = login;
     passwordDefaultTemplate = TxtPassword.Template;
     confirmPasswordDefaultTemplate = TxtConfirmPassword.Template;
 }
 static MapDrawingExtensionMethods()
 {
     var sri = Application.GetResourceStream(new Uri("Vishcious.ArcGIS.SLContrib;component/resources/simplesymbols.xaml", UriKind.Relative));
     StreamReader sr = new StreamReader(sri.Stream);
     resources = XamlReader.Load(sr.ReadToEnd()) as ResourceDictionary;
     drawingPointTemplate = resources["SimpleMarkerSymbol_Circle"] as ControlTemplate;
     drawingLineTemplate = resources["LineSymbol"] as ControlTemplate;
     drawingPolygonTemplate = resources["FillSymbol"] as ControlTemplate;
 }
예제 #12
0
        private static ControlTemplate CreateTemplate()
        {
            ControlTemplate result = new ControlTemplate(typeof(UiImageButton));

            FrameworkElementFactory contentPresenter = new FrameworkElementFactory(typeof(ContentPresenter));

            result.VisualTree = contentPresenter;
            return result;
        }
        static MenuSeparatorStyleSelector()
        {
            var rTemplate = new ControlTemplate(typeof(MenuItem));
            rTemplate.VisualTree = new FrameworkElementFactory(typeof(Separator));
            rTemplate.VisualTree.SetValue(Separator.HorizontalAlignmentProperty, HorizontalAlignment.Stretch);

            r_SeparatorStyle = new Style(typeof(MenuItem));
            r_SeparatorStyle.Setters.Add(new Setter(MenuItem.TemplateProperty, rTemplate));
        }
        private ControlTemplate CreateTemplate()
        {
            var template = new ControlTemplate();

            var label = new FrameworkElementFactory(typeof(Label));
            label.SetBinding(Label.ContentProperty, new Binding("Description"));
            template.VisualTree = label;

            return template;
        }
예제 #15
0
파일: f_main.xaml.cs 프로젝트: ufasoft/coin
        public FormMain()
        {
            InitializeComponent();
            menuTemplate = (ControlTemplate)FindResource("currencyMenu");

            I = this;
            CultureInfo.NumberFormat = (NumberFormatInfo)CultureInfo.NumberFormat.Clone();
            CultureInfo.NumberFormat.CurrencySymbol = "";
            Thread.CurrentThread.CurrentCulture = CultureInfo;
        }
        /// <summary>
        /// Initializes a new instance of the <see cref="DataTemplateElement"/> class.
        /// </summary>
        /// <param name="controlTemplate">The data template.</param>
        /// <param name="boundType">Type of the bound.</param>
        /// <param name="baseName">Name of the base.</param>
        internal ControlTemplateElement(ControlTemplate controlTemplate, BoundType boundType, string baseName)
            : base(controlTemplate.LoadContent(), boundType)
        {
            _controlTemplate = controlTemplate;

            if(_controlTemplate.TargetType != null)
                BaseName = baseName + " [ControlTemplate " + _controlTemplate.TargetType.Name + "] ";

            else BaseName = baseName + " [ControlTemplate] ";
        }
예제 #17
0
        /// <summary>
        /// Initializes a new instance of the <see cref="ResizeThumb"/> class.
        /// </summary>
        /// <remarks>
        ///     Actually it will create a <see cref="Border"/> element and not <see cref="Thumb"/> element
        /// </remarks>
        public ResizeThumb()
            : base()
        {
            FrameworkElementFactory borderFactory = new FrameworkElementFactory(typeof(Border));
            borderFactory.SetValue(Border.BackgroundProperty, Brushes.Transparent);

            ControlTemplate template = new ControlTemplate(typeof(ResizeThumb));
            template.VisualTree = borderFactory;

            this.Template = template;
        }
예제 #18
0
		public void setBackgroundImage(string normal_image_uri, string pressed_image_uri)
		{
			Style style = new Style();

			style.Setters.Add(new Setter(ForegroundProperty, MetrialColor.getBrush(MetrialColor.Name.White)));

			// Normal
			ControlTemplate normal_button_template = new ControlTemplate(typeof(Button));

			FrameworkElementFactory normal_button_shape = new FrameworkElementFactory(typeof(Rectangle));
			normal_button_shape.SetValue(Shape.FillProperty, makeImageBrush(normal_image_uri));
			//normal_button_shape.SetValue(Shape.StrokeProperty, Brushes.White);
			//normal_button_shape.SetValue(Shape.StrokeThicknessProperty, 2.0);

			FrameworkElementFactory normal_button_content_presenter = new FrameworkElementFactory(typeof(ContentPresenter));
			normal_button_content_presenter.SetValue(ContentProperty, new TemplateBindingExtension(ContentProperty));
			normal_button_content_presenter.SetValue(HorizontalAlignmentProperty, HorizontalAlignment.Center);
			normal_button_content_presenter.SetValue(VerticalAlignmentProperty, VerticalAlignment.Center);

			FrameworkElementFactory normal_button_merged_element = new FrameworkElementFactory(typeof(Grid));
			normal_button_merged_element.AppendChild(normal_button_shape);
			normal_button_merged_element.AppendChild(normal_button_content_presenter);

			normal_button_template.VisualTree = normal_button_merged_element;
			style.Setters.Add(new Setter(TemplateProperty, normal_button_template));

			// For Pressed
			Trigger button_pressed_trigger = new Trigger();
			button_pressed_trigger.Property = Button.IsPressedProperty;
			button_pressed_trigger.Value = true;

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

			FrameworkElementFactory pressed_button_shape = new FrameworkElementFactory(typeof(Rectangle));
			pressed_button_shape.SetValue(Shape.FillProperty, makeImageBrush(pressed_image_uri));
			//pressed_button_shape.SetValue(Shape.StrokeProperty, Brushes.White);
			//pressed_button_shape.SetValue(Shape.StrokeThicknessProperty, 2.0);

			FrameworkElementFactory pressed_button_button_content_presenter = new FrameworkElementFactory(typeof(ContentPresenter));
			pressed_button_button_content_presenter.SetValue(ContentProperty, new TemplateBindingExtension(ContentProperty));
			pressed_button_button_content_presenter.SetValue(HorizontalAlignmentProperty, HorizontalAlignment.Center);
			pressed_button_button_content_presenter.SetValue(VerticalAlignmentProperty, VerticalAlignment.Center);

			FrameworkElementFactory pressed_button_mreged_element = new FrameworkElementFactory(typeof(Grid));
			pressed_button_mreged_element.AppendChild(pressed_button_shape);
			pressed_button_mreged_element.AppendChild(pressed_button_button_content_presenter);

			pressed_button_template.VisualTree = pressed_button_mreged_element;
			button_pressed_trigger.Setters.Add(new Setter(TemplateProperty, pressed_button_template));

			style.Triggers.Add(button_pressed_trigger);

			button.Style = style;
		}
예제 #19
0
        /// <summary>
        /// Instantiates new instance of <c>SymbolControl</c> class.
        /// </summary>
        /// <param name="template">Control template.</param>
        public SymbolControl(ControlTemplate template)
        {
            Template = template;

            _dataContext = new SymbologyContext();
            _dataContext.Attributes[SymbologyContext.SIZE_ATTRIBUTE_NAME] = SymbologyManager.DEFAULT_SIZE;
            _dataContext.Attributes[SymbologyContext.FULLSIZE_ATTRIBUTE_NAME] = SymbologyManager.DEFAULT_SIZE + SymbologyManager.DEFAULT_INDENT;
            DataContext = _dataContext;

            HorizontalContentAlignment = HorizontalAlignment.Center;
        }
예제 #20
0
 public void InitializeComponent() {
     if (_contentLoaded) {
         return;
     }
     _contentLoaded = true;
     System.Windows.Application.LoadComponent(this, new System.Uri("/MegaStarzWP7;component/Views/KaraokePage.xaml", System.UriKind.Relative));
     this.buttonTemplate = ((System.Windows.Controls.ControlTemplate)(this.FindName("buttonTemplate")));
     this.LayoutRoot = ((System.Windows.Controls.Grid)(this.FindName("LayoutRoot")));
     this.videoPlayer = ((System.Windows.Controls.MediaElement)(this.FindName("videoPlayer")));
     this.CameraPreview = ((System.Windows.Shapes.Rectangle)(this.FindName("CameraPreview")));
     this.button = ((System.Windows.Controls.Button)(this.FindName("button")));
 }
예제 #21
0
        public static void Register(ResourceDictionary resources)
        {
            var buttonTemplate = new FrameworkElementFactory(typeof(ButtonTemplate));

            var controlTemplate = new ControlTemplate(typeof(ToggleButton));
            controlTemplate.VisualTree = buttonTemplate;

            var style = new Style(typeof(ToggleButton));
            style.Setters.Add(new Setter(Control.TemplateProperty, controlTemplate));

            resources.Add(typeof(ToggleButton), style);
        }
예제 #22
0
        private static void UpdateAdroner(UIElement adorned, bool isVisible, ControlTemplate controlTemplate)
        {
            var layer = AdornerLayer.GetAdornerLayer(adorned);

            if (layer == null)
            {
                // if we don't have an adorner layer it's probably
                // because it's too early in the window's construction
                // Let's re-run at a slightly later time
                Dispatcher.CurrentDispatcher.BeginInvoke(
                    DispatcherPriority.Background,
                    new Action<UIElement>(o =>
                    {
                        if(AdornerLayer.GetAdornerLayer(o) == null)
                        {
                            System.Diagnostics.Debug.WriteLine("AdornerLib.Adorrners: Error - no adorner layer");
                            return;
                        }
                        UpdateAdroner(o);
                    }), adorned);
                return;
            }

            var existingAdorner = GetInteranlAdorner(adorned);

            if (existingAdorner == null)
            {
                if (controlTemplate != null && isVisible)
                {
                    // show
                    var newAdorner = new ControlAdorner(adorned);
                    newAdorner.Child = new Control() { Template = controlTemplate, Focusable = false, };
                    layer.Add(newAdorner);
                    SetInternalAdorner(adorned, newAdorner);
                }
            }
            else
            {
                if (controlTemplate != null && isVisible)
                {
                    // switch template
                    Control ctrl = existingAdorner.Child;
                    ctrl.Template = controlTemplate;
                }
                else
                {
                    // hide
                    existingAdorner.Child = null;
                    layer.Remove(existingAdorner);
                    SetInternalAdorner(adorned, null);
                }
            }
        }
예제 #23
0
        public static void Register(ResourceDictionary resources)
        {
            var textBoxTemplate = new FrameworkElementFactory(typeof(TextBoxTemplate));
            textBoxTemplate.AppendChild(new FrameworkElementFactory(typeof(ScrollViewer), "PART_ContentHost"));

            var controlTemplate = new ControlTemplate(typeof(TextBox));
            controlTemplate.VisualTree = textBoxTemplate;

            var style = new Style(typeof(TextBox));
            style.Setters.Add(new Setter(Control.TemplateProperty, controlTemplate));

            resources.Add(typeof(TextBox), style);
        }
        public TemplatedAdorner(UIElement adornedElement, ControlTemplate adornerTemplate) : base(adornedElement)
        {
            Debug.Assert(adornedElement != null, "adornedElement should not be null");
            Debug.Assert(adornerTemplate != null, "adornerTemplate should not be null");

            Control control = new Control();

            control.DataContext = Validation.GetErrors(adornedElement);
            //control.IsEnabled = false; // Hittest should not work on visual subtree
            control.IsTabStop = false;      // Tab should not get into adorner layer
            control.Template = adornerTemplate;
            _child = control;
            this.AddVisualChild(_child);
        }
예제 #25
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;
        }
        static ViewElement()
        {
            var self = typeof(ViewElement);

            var template = new ControlTemplate(self);

            var contentPresenter = new FrameworkElementFactory(typeof(ContentPresenter));
            contentPresenter.SetValue(ContentPresenter.ContentSourceProperty, "View");

            template.VisualTree = contentPresenter;

            template.Seal();

            TemplateProperty.OverrideMetadata(self, new FrameworkPropertyMetadata(template));
        }
        public static ControlTemplate GetTemplate()
        {
            if (m_TemplateCache == null)
            {
                //m_TemplateCache = new ControlTemplate();

                //m_TemplateCache.VisualTree = new System.Windows.FrameworkElementFactory(typeof(TextErrorTemplateVisualtree));
                MemoryStream sr = new MemoryStream(Encoding.ASCII.GetBytes(c_TemplateXaml));
                ParserContext pc = new ParserContext();
                pc.XmlnsDictionary.Add("", "http://schemas.microsoft.com/winfx/2006/xaml/presentation");
                pc.XmlnsDictionary.Add("x", "http://schemas.microsoft.com/winfx/2006/xaml");
                m_TemplateCache = (ControlTemplate)XamlReader.Load(sr, pc);
            }
            return m_TemplateCache;
        }
예제 #28
0
        /// <summary>
        /// Loads control template from resource.
        /// </summary>
        /// <param name="name">Name of manifest resource being requested.</param>
        /// <returns>Loaded control template</returns>
        private SysControls.ControlTemplate _LoadTemplateFromResource(string name)
        {
            Debug.Assert(!string.IsNullOrEmpty(name));

            SysControls.ControlTemplate controlTemplate = null;

            Assembly assembly = Assembly.GetExecutingAssembly();

            using (Stream stream = assembly.GetManifestResourceStream(name))
            {
                using (XmlTextReader xmlReader = new XmlTextReader(stream))
                    controlTemplate = XamlReader.Load(xmlReader) as SysControls.ControlTemplate;
            }

            return(controlTemplate);
        }
예제 #29
0
 /// <summary>
 /// Constructor.
 /// </summary>
 public SymbolDisplay()
 {
     if (_template == null)
     {
         string temp = "<ControlTemplate xmlns=\"http://schemas.microsoft.com/winfx/2006/xaml/presentation\" xmlns:x=\"http://schemas.microsoft.com/winfx/2006/xaml\"><ContentPresenter x:Name=\"Child\" HorizontalAlignment=\"{TemplateBinding HorizontalAlignment}\" VerticalAlignment=\"{TemplateBinding VerticalAlignment}\"/></ControlTemplate>";
     #if SILVERLIGHT
         _template = System.Windows.Markup.XamlReader.Load(temp) as ControlTemplate;
     #else
         System.IO.MemoryStream templateStream = new System.IO.MemoryStream(System.Text.UTF8Encoding.Default.GetBytes(temp));
         _template = System.Windows.Markup.XamlReader.Load(templateStream) as ControlTemplate;
     #endif
     }
     Template = _template;
     ApplyTemplate();
     base.IsTabStop = false;
 }
        public ColorEllipseScatterViewItem()
        {
            ControlTemplate ct = new ControlTemplate();

            ContentPresenter cp = new ContentPresenter();
            cp.VerticalAlignment = VerticalAlignment.Center;
            cp.HorizontalAlignment = HorizontalAlignment.Center;
            cp.Content = MyElip;
            ct.RegisterName("ContentPresenter", cp);
            this.Template = ct;

            InitializeComponent();

            this.AddHandler(IdentifiedEvents.PreviewIdentifiedHoverOutEvent, new IdentifiedEvents.RoutedIdentifiedHoverEventHandler(MyEllipseScatterViewItemHover));
            this.AddHandler(IdentifiedEvents.PreviewIdentifiedHoverOverEvent, new IdentifiedEvents.RoutedIdentifiedHoverEventHandler(MyEllipseScatterViewItemHover));
        }
예제 #31
0
        public override void OnApplyTemplate()
        {
            base.OnApplyTemplate();

            if (this.RootElement != null) {
                this.RootElement.SizeChanged -= new SizeChangedEventHandler(RootElement_SizeChanged);
            }

            RootElement = (StackPanel)Template.FindName("RootElement", this);
            StarTemplate = RootElement.TryFindResource(new ComponentResourceKey(typeof(RatingControl), "StarTemplate")) as ControlTemplate;
            UpdateStarList();

            if (this.RootElement != null) {
                this.RootElement.SizeChanged += new SizeChangedEventHandler(RootElement_SizeChanged);
            }
        }
예제 #32
0
 protected override void OnTemplateChanged(ControlTemplate oldTemplate, ControlTemplate newTemplate)
 {
 }
예제 #33
0
        protected override void OnTemplateChanged(ControlTemplate oldTemplate, ControlTemplate newTemplate)
        {
            base.OnTemplateChanged(oldTemplate, newTemplate);

            Dispatcher.BeginInvoke(DispatcherPriority.DataBind, new Action(CreateMenu));
        }
예제 #34
0
 protected virtual void OnTemplateChanged(ControlTemplate oldTemplate, ControlTemplate newTemplate)
 {
 }
예제 #35
0
        static ResourceDictionary CreateButtonResources()
        {
            // Toggle button template/style
            var menuDropDownTemplate = new SWC.ControlTemplate(typeof(SWC.Primitives.ToggleButton));

            menuDropDownTemplate.VisualTree = CreateButtonChromeFactory();
            var trigger = new Trigger {
                Property = SWC.Primitives.ToggleButton.IsKeyboardFocusedProperty, Value = true
            };

            trigger.Setters.Add(new Setter(Microsoft.Windows.Themes.ButtonChrome.RenderDefaultedProperty, true, "Chrome"));
            menuDropDownTemplate.Triggers.Add(trigger);
            trigger = new Trigger {
                Property = SWC.Primitives.ToggleButton.IsCheckedProperty, Value = true
            };
            trigger.Setters.Add(new Setter(Microsoft.Windows.Themes.ButtonChrome.RenderDefaultedProperty, true, "Chrome"));
            menuDropDownTemplate.Triggers.Add(trigger);
            trigger = new Trigger {
                Property = SWC.Primitives.ToggleButton.IsEnabledProperty, Value = false
            };
            trigger.Setters.Add(new Setter(SWC.Primitives.ToggleButton.ForegroundProperty, new System.Windows.Media.SolidColorBrush(System.Windows.Media.Color.FromArgb(0xFF, 0xAD, 0xAD, 0xAD))));
            menuDropDownTemplate.Triggers.Add(trigger);
            var menuDropDownStyle = new Style(typeof(SWC.Primitives.ToggleButton));

            menuDropDownStyle.Setters.Add(new Setter()
            {
                Property = SWC.Control.TemplateProperty,
                Value    = menuDropDownTemplate
            });

            // Button template/style
            var normalDropDownTemplate = new SWC.ControlTemplate(typeof(SWC.Button));

            normalDropDownTemplate.VisualTree = CreateButtonChromeFactory();
            trigger = new Trigger {
                Property = SWC.Button.IsKeyboardFocusedProperty, Value = true
            };
            trigger.Setters.Add(new Setter(Microsoft.Windows.Themes.ButtonChrome.RenderDefaultedProperty, true, "Chrome"));
            normalDropDownTemplate.Triggers.Add(trigger);
            trigger = new Trigger {
                Property = SWC.Button.IsEnabledProperty, Value = false
            };
            trigger.Setters.Add(new Setter(SWC.Button.ForegroundProperty, new System.Windows.Media.SolidColorBrush(System.Windows.Media.Color.FromArgb(0xFF, 0xAD, 0xAD, 0xAD))));
            normalDropDownTemplate.Triggers.Add(trigger);
            var normalDropDownStyle = new Style(typeof(SWC.Button));

            normalDropDownStyle.Setters.Add(new Setter()
            {
                Property = SWC.Control.TemplateProperty,
                Value    = normalDropDownTemplate
            });

            menuDropDownStyle.Seal();
            normalDropDownStyle.Seal();

            var resourceDic = new ResourceDictionary();

            resourceDic.Add("MenuDropDown", menuDropDownStyle);
            resourceDic.Add("NormalDropDown", normalDropDownStyle);

            return(resourceDic);
        }
예제 #36
0
 protected override void OnTemplateChanged(SWC.ControlTemplate oldTemplate, SWC.ControlTemplate newTemplate)
 {
     base.OnTemplateChanged(oldTemplate, newTemplate);
     UpdateTextBox();
 }