Ejemplo n.º 1
0
        private void GetT_ControlByTypeQueryCallback(LoadOperation<t_Control> result)
        {
            LoadingBusyIndicator.IsBusy = false;
            if (!result.HasError)
            {
                //this.GalleryListBox.ItemsSource = result.Entities;
                this.GalleryListBox.Items.Clear();

                var pointer = new Pointer();
                pointer.Height = 93d;
                pointer.Width = 93d;
                this.GalleryListBox.Items.Add(new ListBoxItem() { Content= pointer, Height = 100d, Width= 100d });

                foreach (var t in result.Entities)
                {
                    var item = new ListBoxItem();
                    item.DataContext = t;
                    try
                    {
                        if (!string.IsNullOrEmpty(t.ImageURL) && t.ImageURL == "MonitorSystem.Other.RealTimeT")
                        {
                            ImageBrush imageBrush = new ImageBrush();
                            imageBrush.ImageSource = new BitmapImage(new Uri("../Images/RealtimeBG.jpg", UriKind.Relative));
                            imageBrush.Stretch = Stretch.Uniform;
                            Canvas instance = new Canvas();
                            instance.Background = imageBrush;
                          var  control = instance as FrameworkElement;
                            if (null != control)
                            {
                                control.Height = 93d;
                                control.Width = 93d;
                                item.Content = control;
                            }
                        }
                        else if (!string.IsNullOrEmpty(t.ImageURL))
                        {
                            var instance = Activator.CreateInstance(Type.GetType(t.ImageURL));
                            var control = instance as FrameworkElement;
                            if (null != control)
                            {
                                control.Height = 93d;
                                control.Width = 93d;
                                item.Content = control;
                            }
                            else
                            {
                                item.Content = new TextBlock() { Text = t.ControlName, TextTrimming = TextTrimming.WordEllipsis };
                            }
                        }
                        else
                        {
                            item.Content = new TextBlock() { Text = t.ControlName, TextTrimming = TextTrimming.WordEllipsis };
                        }
                    }
                    catch
                    {
                        item.Content = new TextBlock() { Text = t.ControlName, TextTrimming = TextTrimming.WordEllipsis };
                    }
                    item.Height = 100d;
                    item.Width = 100d;
                    this.GalleryListBox.Items.Add(item);
                }
            }
        }
Ejemplo n.º 2
0
        private void GetT_ControlByTypeQueryCallback(List<t_Control> result)
        {
            //this.GalleryListBox.ItemsSource = result.Entities;
            try
            {
                this.GalleryListBox.Items.Clear();

                var pointer = new Pointer();
                pointer.Height = 93d;
                pointer.Width = 93d;
                this.GalleryListBox.Items.Add(new ListBoxItem() { Content = pointer, Height = 100d, Width = 100d });

                foreach (var t in result)
                {
                    var item = new ListBoxItem();
                    item.DataContext = t;
                    try
                    {
                        if (!string.IsNullOrEmpty(t.ImageURL) && t.ImageURL == "MonitorSystem.Other.RealTimeT")
                        {
                            string url = "/WPFMonitor;component/Resources/Images/RealtimeBG.jpg";
                            BitmapImage bitmap = new BitmapImage(new Uri(url, UriKind.Relative));
                            ImageSource mm = bitmap;
                            Image _img = new Image();

                            _img.Source = mm;

                            var control = _img as FrameworkElement;
                            if (null != control)
                            {
                                control.Height = 93d;
                                control.Width = 93d;
                                item.Content = control;
                            }
                        }
                        else
                        if (!string.IsNullOrEmpty(t.ImageURL))
                        {
                            var instance = Activator.CreateInstance(MonitorControl.GetType(t.ImageURL));
                            var control = instance as FrameworkElement;
                            if (null != control)
                            {
                                control.Height = 93d;
                                control.Width = 93d;
                                item.Content = control;
                            }
                            else
                            {
                                item.Content = new TextBlock() { Text = t.ControlName, TextTrimming = TextTrimming.WordEllipsis };
                            }
                        }
                        else
                        {
                            item.Content = new TextBlock() { Text = t.ControlName, TextTrimming = TextTrimming.WordEllipsis };
                        }
                    }
                    catch
                    {
                        item.Content = new TextBlock() { Text = t.ControlName, TextTrimming = TextTrimming.WordEllipsis };
                    }
                    item.Height = 100d;
                    item.Width = 100d;
                    this.GalleryListBox.Items.Add(item);
                }
            }
            catch (Exception ex)
            {

            }
            LoadingBusyIndicator.IsBusy = false;
        }