private void AddDeviceUI()
        {
            for (int i = 0; i < App.Devices.Count; i++)
            {
                Device d = App.Devices[i];

                if (!d.IsInstalled && d.IsInInstallQue)
                {
                    Border brdr = new Border();
                    brdr.Width = 150;
                    brdr.SnapsToDevicePixels = true;
                    brdr.Margin          = new Thickness(0, 0, 0, 10);
                    brdr.BorderBrush     = (Brush)FindResource("StandardBorderColor");
                    brdr.BorderThickness = new Thickness(0, 0, 0, 1);
                    brdr.Padding         = new Thickness(0, 10, 0, 10);

                    DockPanel dp = new DockPanel();

                    brdr.Child = dp;

                    PixelSnappedImage pi = new PixelSnappedImage();
                    pi.Width  = 65;
                    pi.Height = 33;
                    pi.Source = d.ManufacturerImage;
                    pi.HorizontalAlignment = HorizontalAlignment.Left;

                    Button btn = new Button();
                    btn.Uid = d.ID.ToString();
                    btn.HorizontalAlignment = HorizontalAlignment.Right;
                    btn.Style     = (Style)FindResource("ButtonAction");
                    btn.Margin    = new Thickness(0, 0, 0, 0);
                    btn.MinWidth  = 0;
                    btn.MinHeight = 0;
                    btn.Width     = 50;
                    btn.Height    = 30;
                    btn.Content   = "Add";
                    btn.Click    += new RoutedEventHandler(btn_Click);

                    DockPanel.SetDock(btn, Dock.Right);
                    DockPanel.SetDock(pi, Dock.Left);

                    dp.Children.Add(pi);
                    dp.Children.Add(btn);

                    DeviceList.Children.Add(brdr);
                }
            }
        }
Example #2
0
        private static void OnSourceChanged(DependencyObject d, DependencyPropertyChangedEventArgs e)
        {
            PixelSnappedImage bitmap   = (PixelSnappedImage)d;
            BitmapSource      oldValue = (BitmapSource)e.OldValue;
            BitmapSource      newValue = (BitmapSource)e.NewValue;

            if (((oldValue != null) && (bitmap._sourceDownloaded != null)) && (!oldValue.IsFrozen && (oldValue is BitmapSource)))
            {
                ((BitmapSource)oldValue).DownloadCompleted -= bitmap._sourceDownloaded;
                ((BitmapSource)oldValue).DownloadFailed    -= bitmap._sourceFailed;
            }
            if (((newValue != null) && (newValue is BitmapSource)) && !newValue.IsFrozen)
            {
                ((BitmapSource)newValue).DownloadCompleted += bitmap._sourceDownloaded;
                ((BitmapSource)newValue).DownloadFailed    += bitmap._sourceFailed;
            }
        }