Esempio n. 1
0
        private static void BindSource(FImage img)
        {
            var value = img.Source;

            if (value.IsInvalid())
            {
                return;
            }
            if (value.Length == 1)
            {
                img.FIcon.Text = value;
                return;
            }

            img.Dispatcher.BeginInvoke(new Action(() =>
            {
                try
                {
                    var path = value.TrimStart(' ', '/', '\\');
                    //如果是相对路径则转换为绝对路径
                    if (!Path.IsPathRooted(path))
                    {
                        path = File.GetPhysicalPath(path);
                    }
                    BitmapImage bitmapImage = new BitmapImage();
                    bitmapImage.BeginInit();
                    bitmapImage.UriSource   = new Uri(path);
                    bitmapImage.CacheOption = BitmapCacheOption.OnLoad;
                    bitmapImage.EndInit();
                    img.Image.Source = bitmapImage;
                }
                catch { }
            }), DispatcherPriority.ApplicationIdle);
        }
Esempio n. 2
0
        /// <summary>
        /// 属性更改处理事件
        /// </summary>
        private static void OnSourcePropertyChanged(DependencyObject sender, DependencyPropertyChangedEventArgs args)
        {
            FImage img = sender as FImage;

            if (img == null)
            {
                return;
            }
            if (!img.IsLoaded)
            {
                return;
            }
            BindSource(img);
        }
Esempio n. 3
0
        void System.Windows.Markup.IComponentConnector.Connect(int connectionId, object target)
        {
            switch (connectionId)
            {
            case 1:
                this.uc = ((XLY.Framework.Controls.FImage)(target));
                return;

            case 2:
                this.Icon = ((System.Windows.Controls.TextBlock)(target));
                return;

            case 3:
                this.img = ((System.Windows.Controls.Image)(target));
                return;
            }
            this._contentLoaded = true;
        }