Inheritance: IDependencyPropertyChangedEventArgs
        private static void EffectChanged(DependencyObject d, DependencyPropertyChangedEventArgs e)
        {
            var uiSender = d as UIElement;
            var effect = e.NewValue as IComposition;

            effect.Initialize(uiSender);
        }
Ejemplo n.º 2
0
 private static void OnMessageChanged(DependencyObject d, DependencyPropertyChangedEventArgs e)
 {
     var notifybar = d as NotificationBar;
     var message = e.NewValue as string;
     if (message == string.Empty) return;
     notifybar?.ShowMessage(message);
 }
Ejemplo n.º 3
0
        private static async void SizeChanged(DependencyObject d, DependencyPropertyChangedEventArgs e) {
            if ((int)e.NewValue <= 0)
                throw new ArgumentException("ThumbImageSource width/height 必须大于0");

            var thumb = (ThumbImageSource)d;
            //await thumb.Deal();
        }
 // 依存関係プロパティに値がセットされたときに呼び出されるメソッド
 private static void OnSourceChanged(DependencyObject d, DependencyPropertyChangedEventArgs e)
 {
     var i = d as TwitterSuggestTextBox;
     i.textBoxTweet.Text = (string)e.NewValue;
    // i.model.Text = (string)e.NewValue;
     
 }
 private static void OnMaskChanged(DependencyObject sender, DependencyPropertyChangedEventArgs e)
 {
     var target = (TextBoxMaskBehavior)sender;
     var oldMask = (TextMask)e.OldValue;
     var newMask = (TextMask)e.NewValue;
     target.OnMaskChanged(oldMask, newMask);
 }
Ejemplo n.º 6
0
 private static void OnHeaderTemplatePropertyChanged(DependencyObject d, DependencyPropertyChangedEventArgs e)
 {
     var source = d as HeaderedItemsControl;
     var oldHeaderTemplate = e.OldValue as DataTemplate;
     var newHeaderTemplate = e.NewValue as DataTemplate;
     if (source != null) source.OnHeaderTemplateChanged(oldHeaderTemplate, newHeaderTemplate);
 }
Ejemplo n.º 7
0
 static void PositionChanged(DependencyObject dp, DependencyPropertyChangedEventArgs args)
 {
     var p = ((FrameworkElement)dp)?.Parent;
     if (p == null)
         return;
     ((UIElement)p)?.InvalidateArrange();
 }
Ejemplo n.º 8
0
        private static void OnBaterryPercentagePropertyChanged(DependencyObject d, DependencyPropertyChangedEventArgs e)
        {
            var obj = (BatteryPercentageTrigger)d;
            var val = (BaterryPercentageState)e.NewValue;

            obj.SetActive(val == _batteryPercentageState);
        }
Ejemplo n.º 9
0
 /// <summary>
 /// RatioVisibleProperty property changed handler.
 /// </summary>
 /// <param name="d">PartialView that changed its RatioVisible.</param>
 /// <param name="e">Event arguments.</param>
 private static void OnRatioVisibleChanged(DependencyObject d, DependencyPropertyChangedEventArgs e)
 {
     Clipper source = (Clipper)d;
     double oldValue = (double)e.OldValue;
     double newValue = (double)e.NewValue;
     source.OnRatioVisibleChanged(oldValue, newValue);
 }
Ejemplo n.º 10
0
 /// <summary>
 /// ExpandDirectionProperty property changed handler.
 /// </summary>
 /// <param name="d">ExpandDirectionView that changed its ExpandDirection.</param>
 /// <param name="e">Event arguments.</param>
 private static void OnExpandDirectionChanged(DependencyObject d, DependencyPropertyChangedEventArgs e)
 {
     LinearClipper source = (LinearClipper)d;
     ExpandDirection oldValue = (ExpandDirection)e.OldValue;
     ExpandDirection newValue = (ExpandDirection)e.NewValue;
     source.OnExpandDirectionChanged(oldValue, newValue);
 }
        private static void OnSearchTermChanged(DependencyObject d, DependencyPropertyChangedEventArgs args) {
            var textBlock = (TextBlock)d;
            if (textBlock == null) return;

            var searchTerm = GetSearchTerm(textBlock);
            var originalText = GetSearchText(textBlock);
            if (string.IsNullOrEmpty(originalText) || (searchTerm == null)) return;
            if (searchTerm.Length == 0) {
                textBlock.Text = originalText;
                return;
            }

            textBlock.Inlines.Clear();
            var currentIndex = 0;
            var searchTermLength = searchTerm.Length;
            int index = originalText.IndexOf(searchTerm, 0, StringComparison.CurrentCultureIgnoreCase);
            while (index > -1) {
                textBlock.Inlines.Add(new Run() { Text = originalText.Substring(currentIndex, index - currentIndex) });
                currentIndex = index + searchTermLength;
                textBlock.Inlines.Add(new Run() { Text = originalText.Substring(index, searchTermLength), Foreground = GetHighlightBrush(textBlock) });
                index = originalText.IndexOf(searchTerm, currentIndex, 0, StringComparison.CurrentCultureIgnoreCase);
            }

            textBlock.Inlines.Add(new Run() { Text = originalText.Substring(currentIndex) });
        }
 private static void OnSecondsChanged(DependencyObject sender, DependencyPropertyChangedEventArgs e)
 {
     var target = (CountdownControl)sender;
     var oldSeconds = (int)e.OldValue;
     var newSeconds = (int)e.NewValue;
     target.OnSecondsChanged(oldSeconds, newSeconds);
 }
Ejemplo n.º 13
0
 private static void OnButtonForegroundColorPropertyChanged(DependencyObject d,
     DependencyPropertyChangedEventArgs e)
 {
     var color = (Color)e.NewValue;
     var titleBar = ApplicationView.GetForCurrentView().TitleBar;
     titleBar.ButtonForegroundColor = color;
 }
Ejemplo n.º 14
0
        /// <summary>
        /// Handles the HTML has changed, converts it and attach to the attached RichTextBlock.
        /// </summary>
        /// <param name="d">The RichTextBlock.</param>
        /// <param name="e">The <see cref="DependencyPropertyChangedEventArgs"/> instance containing the event data.</param>
        private static async void HtmlChanged(DependencyObject d, DependencyPropertyChangedEventArgs e)
        {
            RichTextBlock richText = d as RichTextBlock;
            string html = e.NewValue as string;

            if (richText != null && !string.IsNullOrEmpty(html))
            {
                try
                {
                    if (!ContainsHtmlTags(html))
                    {
                        html = html.Replace("\r\n", "<br/>");
                        html = html.Replace("\n\r", "<br/>");
                        html = html.Replace("\n", "<br/>");
                    }

                    string xaml = await Html2XamlProcessor.ConvertToXaml(html);
                    ChangeRichTextBlockContents(richText, xaml);
                }
                catch (Exception ex)
                {
                    Debug.WriteLine(ex);
                    try
                    {
                        ChangeRichTextBlockContents(richText, GetErrorXaml(ex, html));
                    }
                    catch
                    {
                        Debug.WriteLine(ex);
                    }
                }
            }
        }
Ejemplo n.º 15
0
        private static void OnPathChanged( DependencyObject obj, DependencyPropertyChangedEventArgs args )
        {
            var icon = (Icon) obj;
            var data = (string) args.NewValue;

            if ( data == null )
            {
                return;
            }

            // Copy it since sharing it isn't permitted
            var path = (Path) XamlReader.Load( "<Path xmlns=\"http://schemas.microsoft.com/winfx/2006/xaml/presentation\" Data=\"" + data + "\" />" );

            path.Stretch = Stretch.Uniform;
            path.HorizontalAlignment = HorizontalAlignment.Center;
            path.VerticalAlignment = VerticalAlignment.Center;
            path.SetBinding( Path.FillProperty, new Binding { Source = icon, Path = new PropertyPath( "Foreground" ) } );
            path.SetBinding( Path.MarginProperty, new Binding { Source = icon, Path = new PropertyPath( "Padding" ) } );

            var container = new Border
            {
                Child = path
            };
            container.SetBinding( Border.WidthProperty, new Binding { Source = icon, Path = new PropertyPath( "IconWidth" ) } );
            container.SetBinding( Border.HeightProperty, new Binding { Source = icon, Path = new PropertyPath( "IconHeight" ) } );
            container.SetBinding( Border.BackgroundProperty, new Binding { Source = icon, Path = new PropertyPath( "Background" ) } );

            icon.HorizontalAlignment = HorizontalAlignment.Center;
            icon.VerticalAlignment = VerticalAlignment.Center;
            icon.Content = new Viewbox
            {
                Child = container
            };
        }
Ejemplo n.º 16
0
 private static void VisualStateNarrowMinWidthChanged(DependencyObject d, DependencyPropertyChangedEventArgs e)
 {
     //if (!Equals(e.NewValue, -1) && XamlUtils.Ancestor<HamburgerMenu>(d as Control) == null)
     //{
     //    (d as PageHeader).VisualStateNarrowMinWidth = -1;
     //}
 }
		private static void OnSelectedIndexPropertyChanged(DependencyObject d, DependencyPropertyChangedEventArgs e)
		{
			var item = (int)(e.NewValue);
			var ctrl = (SidePanel)d;
			if (item < ctrl.Items.Count)
				ctrl.SelectedItem = ctrl.Items[item];
		}
Ejemplo n.º 18
0
 private static void OnPropertyChanged(DependencyObject d, DependencyPropertyChangedEventArgs e)
 {
     if (e.NewValue != null)
         (d as ExtendedTextBox).TextChanged += ExtendedTextBox_TextChanged;
     else
         (d as ExtendedTextBox).TextChanged -= ExtendedTextBox_TextChanged;
 }
Ejemplo n.º 19
0
 private static void OnEndAngleChanged(DependencyObject sender, DependencyPropertyChangedEventArgs e)
 {
     var target = (PieSlice)sender;
     var oldEndAngle = (double)e.OldValue;
     var newEndAngle = (double)e.NewValue;
     target.OnEndAngleChanged(oldEndAngle, newEndAngle);
 }
Ejemplo n.º 20
0
        /// <summary>
        /// Handles changes to the Cursor property.
        /// </summary>
        /// <param name="d">
        /// The <see cref="DependencyObject"/> on which
        /// the property has changed value.
        /// </param>
        /// <param name="e">
        /// Event data that is issued by any event that
        /// tracks changes to the effective value of this property.
        /// </param>
        private static void OnCursorChanged(
            DependencyObject d, DependencyPropertyChangedEventArgs e)
        {
            CoreCursor oldCursor = (CoreCursor)e.OldValue;
            CoreCursor newCursor = (CoreCursor)d.GetValue(CursorProperty);

            if (oldCursor == null)
            {
                var handler = new CursorDisplayHandler();
                handler.Attach((Control)d);
                SetCursorDisplayHandler(d, handler);
            }
            else
            {
                var handler = GetCursorDisplayHandler(d);

                if (newCursor == null)
                {
                    handler.Detach();
                    SetCursorDisplayHandler(d, null);
                }
                else
                {
                    handler.UpdateCursor();
                }
            }
        }
Ejemplo n.º 21
0
        private static void OnNetworkStatusPropertyChanged(DependencyObject d, DependencyPropertyChangedEventArgs e)
        {
            var obj = (NetworkStatusTrigger)d;
            var val = (NetworkStatus)e.NewValue;

            obj.SetActive(val == _status);
        }
Ejemplo n.º 22
0
        private static void MessageTextForegroundColorPropertyChanged(DependencyObject obj, DependencyPropertyChangedEventArgs args)
        {
            NotificationView ctl = (NotificationView)obj;

            ctl.lblMessage.Foreground = (Brush)args.NewValue;

        }
Ejemplo n.º 23
0
 private static void SearchBoxChanged(DependencyObject d, DependencyPropertyChangedEventArgs e)
 {
     var textBox = d as TextBox;
     if (textBox == null)
         throw new InvalidCastException("This extension is for TextBox only");
     var searchBox = e.NewValue as SearchBox;
     if (searchBox == null)
         return;
     searchBox.QuerySubmitted += (s, args) =>
     {
         var text = args.QueryText;
         if (string.IsNullOrEmpty(text))
         {
             textBox.SelectionLength = 0;
             return;
         }
         var index = textBox.Text.IndexOf(text);
         if (index < 0)
         {
             textBox.SelectionLength = 0;
             return;
         }
         textBox.SelectionStart = index;
         textBox.SelectionLength = text.Length;
         if (textBox.FocusState == FocusState.Unfocused)
             textBox.Focus(FocusState.Programmatic);
     };
 }
        private static void OnLocomotiveChanged(DependencyObject d, DependencyPropertyChangedEventArgs e)
        {
            ucLocomotiveEditor uc = d as ucLocomotiveEditor;

            if ((e.NewValue as Locomotive) != null)
                uc.InitProtocolList();
        }
Ejemplo n.º 25
0
 private static void OnTextChanged(DependencyObject sender, DependencyPropertyChangedEventArgs e)
 {
     var target = (TextBoxMaskBehavior)sender;
     var oldText = (string)e.OldValue;
     var newText = (string)e.NewValue;
     target.OnTextChanged(oldText, newText);
 }
Ejemplo n.º 26
0
        private static async void OnCacheUriChanged(DependencyObject d, DependencyPropertyChangedEventArgs e)
        {
            
            //Uri oldCacheUri = (Uri)e.OldValue;
            Uri newCacheUri = (Uri)d.GetValue(CacheUriProperty);
            var image = (Image)d;

            if (newCacheUri != null)
            {
                try
                {
                    //Get image from cache (download and set in cache if needed)
                    var cacheUri = await WebDataCache.GetLocalUriAsync(newCacheUri);

                    //Set cache uri as source for the image
                    image.Source = new BitmapImage(cacheUri);
                }
                catch (Exception ex)
                {
                    Debug.WriteLine(ex);

                    //Revert to using passed URI
                    image.Source = new BitmapImage(newCacheUri);
                }
            }
            else
                image.Source = null;

        }
 private static void OnCommandPropertyChanged(DependencyObject d,
     DependencyPropertyChangedEventArgs e)
 {
     var control = d as FrameworkElement;
     if (control != null)
         control.Tapped += OnTapped;
 }
Ejemplo n.º 28
0
 private static void OnCommandPropertyChanged(DependencyObject d,
     DependencyPropertyChangedEventArgs e)
 {
     var control = d as ListViewBase;
     if (control != null)
         control.ItemClick += OnItemClick;
 }
Ejemplo n.º 29
0
 private static void OnMaximumChanged(DependencyObject sender, DependencyPropertyChangedEventArgs e)
 {
     var target = (PercentRingSlice)sender;
     var oldMaximum = (double)e.OldValue;
     var newMaximum = (double)e.NewValue;
     target.OnMaximumChanged(oldMaximum, newMaximum);
 }
Ejemplo n.º 30
-1
        private async static  void UriSourcePropertyChangedCallback(DependencyObject d, DependencyPropertyChangedEventArgs e)
        {
                Debug.WriteLine("我被触发了");
                StorageCachedImage image = d as StorageCachedImage;
                string i = e.NewValue as string;
                int k = i.IndexOf("image");
                string imagePath = i.Substring(k + 7);
                string uri = App.Uri + "public/images/" + imagePath;
                Debug.WriteLine(uri);
              
             
                Uri imageUri = new Uri(uri);

                HttpClient client = new HttpClient();
                var response = await client.GetAsync(imageUri);
                var buffer = await response.Content.ReadAsBufferAsync();
                var memoryStream = new InMemoryRandomAccessStream();
                await memoryStream.WriteAsync(buffer);
                await memoryStream.FlushAsync();
             
                await image.SetSourceAsync(memoryStream);
              
            

        }