/// <summary>
        /// Generate content for cell by column binding
        /// </summary>
        /// <returns>Image element</returns>
        internal override FrameworkElement GetGeneratedContent()
        {
            Image result = new Image();

            if (this.Binding != null)
            {
                result.SetBinding(Image.SourceProperty, this.Binding);
            }

            result.SetBinding(Image.WidthProperty, new Binding("ImageWidth") { Source = this });
            result.SetBinding(Image.HeightProperty, new Binding("ImageHeight") { Source = this });

            return result;
        }
Example #2
0
        /// <summary>
        /// Initializes a new instance of the <see cref="ImageButton"/> class.
        /// </summary>
        public ImageButton()
        {
            SetResourceReference(HeightProperty, "DefaultControlHeight");

            var panel = new StackPanel {Orientation = Orientation.Horizontal};

            _icon = new Image {Margin = new Thickness(0, 0, 6, 0)};
            var imageBinding = new Binding("Icon")
                               	{
                               		Source = this,
                               		UpdateSourceTrigger = UpdateSourceTrigger.PropertyChanged
                               	};
            _icon.SetBinding(Image.SourceProperty, imageBinding);

            panel.Children.Add(_icon);

            _textBlock = new TextBlock();
            var textBinding = new Binding("Content")
                              	{
                              		Source = this,
                              		UpdateSourceTrigger = UpdateSourceTrigger.PropertyChanged
                              	};
            _textBlock.SetBinding(TextBlock.TextProperty, textBinding);
            panel.Children.Add(_textBlock);

            base.Content = panel;

            SetResourceReference(StyleProperty, typeof (Button));
        }
Example #3
0
        private void BindMenuIcon(MenuItem menuItem, DependencyProperty property)
        {
            var image = new Image {
                Width = 16, Height = 16
            };
            var binding = new Binding {
                Source = this, Path = new PropertyPath(property)
            };

            image.SetBinding(Image.SourceProperty, binding);
            menuItem.Icon = image;
        }
Example #4
0
        public static void BindParameterToImageSourceWithConverter(int i, string prop, System.Windows.Controls.Image img, string definition, IValueConverter conv)
        {
            var b = new Binding
            {
                Source = TeraLogic.CharList[i],
                Path   = new PropertyPath(prop),
                UpdateSourceTrigger = UpdateSourceTrigger.PropertyChanged,
                Converter           = conv,
                ConverterParameter  = definition
            };

            img.SetBinding(System.Windows.Controls.Image.SourceProperty, b);
        }
Example #5
0
        private void prepButtons(int x)
        {
            _panelImages.Children.Clear();
            for (int i = 0; i < x; i++)
            {
                System.Windows.Controls.Image img = new System.Windows.Controls.Image();
                Button b = new Button();

                b.Command          = EnterIPCommand;
                b.CommandParameter = i + 1;
                b.BorderThickness  = new Thickness(1.0);
                b.Width            = 100;
                b.Height           = 100;

                Binding myBinding = new Binding("Cameras[" + i + "].Image");
                img.SetBinding(System.Windows.Controls.Image.SourceProperty, myBinding);

                b.Content = img;

                _panelImages.Children.Add(b);
            }
        }
Example #6
0
 private void BindMenuIcon(MenuItem menuItem, DependencyProperty property)
 {
     var image = new Image { Width = 16, Height = 16 };
     var binding = new Binding { Source = this, Path = new PropertyPath(property) };
     image.SetBinding(Image.SourceProperty, binding);
     menuItem.Icon = image;
 }
Example #7
0
        private static void ProcessInlines(InlineCollection inlines, Size size, out int numFound)
        {
            numFound = 0;

            try
            {
                for (int inlineIndex = 0; inlineIndex < inlines.Count; inlineIndex++)
                {
                    Inline i = inlines.ElementAt(inlineIndex);
                    if (i is Run)
                    {
                        Run    r    = i as Run;
                        string text = r.Text;

                        foreach (Match m in Regex.Matches(text, HyperlinkUtility.UrlRegex2))
                        {
                            TextPointer tp = i.ContentStart;
                            while (!tp.GetTextInRun(LogicalDirection.Forward).StartsWith(m.Value))
                            {
                                tp = tp.GetNextInsertionPosition(LogicalDirection.Forward);
                            }
                            TextPointer end = tp;
                            for (int j = 0; j < m.Value.Length; j++)
                            {
                                end = end.GetNextInsertionPosition(LogicalDirection.Forward);
                            }
                            TextRange tr = new TextRange(tp, end);
                            tr.Text = string.Empty;
                            UIElement         element    = CreateHyperlink(m.Value);
                            InlineUIContainer iContainer = new InlineUIContainer(element, tp);
                            iContainer.BaselineAlignment = BaselineAlignment.Bottom;
                            continue;
                        }

                        foreach (Match m in Regex.Matches(text, HyperlinkUtility.UncRegex))
                        {
                            TextPointer tp = i.ContentStart;
                            while (!tp.GetTextInRun(LogicalDirection.Forward).StartsWith(m.Value))
                            {
                                tp = tp.GetNextInsertionPosition(LogicalDirection.Forward);
                            }
                            TextPointer end = tp;
                            for (int j = 0; j < m.Value.Length; j++)
                            {
                                end = end.GetNextInsertionPosition(LogicalDirection.Forward);
                            }
                            TextRange tr = new TextRange(tp, end);
                            tr.Text = string.Empty;
                            UIElement         element    = CreateHyperlink(m.Value);
                            InlineUIContainer iContainer = new InlineUIContainer(element, tp);
                            iContainer.BaselineAlignment = BaselineAlignment.Bottom;
                            continue;
                        }

                        text = r.Text;
                        foreach (Match m in Regex.Matches(text, HyperlinkUtility.UrlRegex))
                        {
                            TextPointer tp = i.ContentStart;
                            while (!tp.GetTextInRun(LogicalDirection.Forward).StartsWith(m.Value))
                            {
                                tp = tp.GetNextInsertionPosition(LogicalDirection.Forward);
                            }
                            TextPointer end = tp;
                            for (int j = 0; j < m.Value.Length; j++)
                            {
                                end = end.GetNextInsertionPosition(LogicalDirection.Forward);
                            }
                            TextRange tr = new TextRange(tp, end);
                            tr.Text = string.Empty;
                            UIElement         element    = CreateHyperlink(m.Value);
                            InlineUIContainer iContainer = new InlineUIContainer(element, tp);
                            iContainer.BaselineAlignment = BaselineAlignment.Bottom;
                            continue;
                        }



                        string emoticonFound = string.Empty;
                        int    index         = GetNextEmoticon(text, 0, out emoticonFound);
                        if (index >= 0)
                        {
                            TextPointer tp = i.ContentStart;
                            while (!tp.GetTextInRun(LogicalDirection.Forward).StartsWith(emoticonFound))
                            {
                                tp = tp.GetNextInsertionPosition(LogicalDirection.Forward);
                            }
                            TextPointer end = tp;
                            for (int j = 0; j < emoticonFound.Length; j++)
                            {
                                end = end.GetNextInsertionPosition(LogicalDirection.Forward);
                            }
                            TextRange tr = new TextRange(tp, end);
                            tr.Text = string.Empty;


                            //string uri = ApplicationViewModel.Current.SmiliesView.OfType<EmoticonMapping>().Where( d => d.KeyList.Contains( emoticonFound ) ).FirstOrDefault().Path;
                            ImageSource imageSource = EmoticonLibrary.Current.Where(e => e.Keys.Contains(emoticonFound)).Select(e => e.ImageSource).FirstOrDefault();

                            System.Windows.Controls.Image emoticon = new System.Windows.Controls.Image();
                            emoticon.Style = Application.Current.Resources["AnimatedImageStyle"] as Style;

                            if (size == Size.Empty)
                            {
                                emoticon.Stretch = Stretch.Fill;
                                Binding heightBinding = new Binding("Source.PixelHeight")
                                {
                                    RelativeSource = RelativeSource.Self
                                };
                                Binding widthBinding = new Binding("Source.PixelWidth")
                                {
                                    RelativeSource = RelativeSource.Self
                                };

                                emoticon.SetBinding(Image.HeightProperty, heightBinding);
                                emoticon.SetBinding(Image.WidthProperty, widthBinding);
                            }
                            else
                            {
                                BitmapSource bitmapSource = imageSource as BitmapSource;
                                if (bitmapSource != null)
                                {
                                    if (bitmapSource.PixelHeight < size.Height)
                                    {
                                        emoticon.Stretch = Stretch.Fill;
                                        Binding heightBinding = new Binding("Source.PixelHeight")
                                        {
                                            RelativeSource = RelativeSource.Self
                                        };
                                        Binding widthBinding = new Binding("Source.PixelWidth")
                                        {
                                            RelativeSource = RelativeSource.Self
                                        };

                                        emoticon.SetBinding(Image.HeightProperty, heightBinding);
                                        emoticon.SetBinding(Image.WidthProperty, widthBinding);
                                    }
                                    else
                                    {
                                        RenderOptions.SetBitmapScalingMode(emoticon, BitmapScalingMode.HighQuality);
                                        emoticon.MaxHeight = size.Height;
                                        //emoticon.MaxWidth = size.Width;
                                        emoticon.Stretch = Stretch.Uniform;
                                    }
                                }
                                emoticon.MaxHeight = size.Height;
                                //emoticon.MaxWidth = size.Width;
                                emoticon.Stretch = Stretch.Uniform;
                            }

                            //ImageSource imageSource = new ImageSourceConverter().ConvertFromString( uri ) as ImageSource;

                            WpfAnimatedGif.ImageBehavior.SetAnimatedSource(emoticon, imageSource);

                            numFound++;
                            Grid grid = new Grid();
                            grid.ToolTip = emoticonFound;
                            grid.Children.Add(emoticon);
                            InlineUIContainer iui = new InlineUIContainer(grid, tp);
                            iui.BaselineAlignment = BaselineAlignment.TextBottom;
                        }

                        emoticonFound = string.Empty;
                        ChatUser user;
                        index = GetNextUser(text, 0, out emoticonFound, out user);
                        if (index >= 0)
                        {
                            TextPointer tp = i.ContentStart;
                            while (!tp.GetTextInRun(LogicalDirection.Forward).StartsWith(emoticonFound))
                            {
                                tp = tp.GetNextInsertionPosition(LogicalDirection.Forward);
                            }
                            TextPointer end = tp;
                            for (int j = 0; j < emoticonFound.Length; j++)
                            {
                                end = end.GetNextInsertionPosition(LogicalDirection.Forward);
                            }
                            TextRange tr = new TextRange(tp, end);
                            tr.Text = string.Empty;

                            ChatUserImage userImage = new ChatUserImage {
                                User = user
                            };


                            if (size != Size.Empty)
                            {
                                userImage.Height = size.Height;
                                userImage.Width  = size.Width;
                            }

                            Grid grid = new Grid();
                            grid.ToolTip = emoticonFound;
                            grid.Children.Add(userImage);
                            InlineUIContainer iui = new InlineUIContainer(grid, tp);
                            iui.BaselineAlignment = BaselineAlignment.TextBottom;
                        }
                    }
                }
            }
            catch (Exception)
            {
                // Do nothing, error processing emoticons
            }
        }
        public void LoadNewDataSet(DataSource ds)
        {
            bool bo = false; //These two lines for testing refresh on new row addition. Remove them later.
            if(bo) closeTab();

            if (!DataSourceExists(ds))
            {

                ///DocumentPanel panel = new DocumentPanel();
                //C1DockControlPanel c1panel = new C1DockControlPanel();//Anil
                StackPanel sp = new StackPanel(); //sp.Background = Brushes.Red;
                sp.Orientation = Orientation.Horizontal;
                sp.HorizontalAlignment = HorizontalAlignment.Center;
                sp.VerticalAlignment = VerticalAlignment.Center;
                //sp.Margin = new Thickness(1, 1, 1, 1);

                string sheetname=string.Empty;//29Apr2015
                if (ds.SheetName != null && ds.SheetName.Trim().Length > 0)
                    sheetname = "{" + ds.SheetName + "}";
                Label lb = new Label(); lb.FontWeight = FontWeights.DemiBold; 
                var tabtextcolor = new SolidColorBrush(Color.FromArgb(255, (byte)48, (byte)88, (byte)144));//Foreground="#FF1579DA"
                lb.Foreground = tabtextcolor;
                lb.Content = Path.GetFileName(ds.FileName) + sheetname + " (" + ds.Name + ")";//06Aug2012
                lb.ToolTip = ds.FileName+sheetname; 
                lb.Margin = new Thickness(1, 1, 1, 1);
                //Button b = new Button(); b.Content="x";
                Image b = new Image(); b.MouseLeftButtonUp += new System.Windows.Input.MouseButtonEventHandler(b_MouseLeftButtonUp);
                b.ToolTip = "Close this dataset"; b.Height = 16.0; b.Width = 22.0; 

                string packUri = "pack://application:,,,/BlueSky;component/Images/closetab.png";
                b.Source = new ImageSourceConverter().ConvertFromString(packUri) as ImageSource;
                sp.Children.Add(lb);
                sp.Children.Add(b); //sp.Children.Add(b); 

                TabItem panel = new TabItem(); 
                //panel.Margin = new Thickness(1, 1, 1, 1);
                b.Tag = panel;//for remove 
                ///////triggers///08Feb2013
                Binding bind = new Binding();//for close image to hide for inactive tabs
                bind.Source = panel;
                bind.Path = new PropertyPath("IsSelected");
                bind.Converter = new BooleanToVisibilityConverter();
                b.SetBinding(Image.VisibilityProperty, bind);

                Style st = new Style(typeof(TabItem));
                var brush1 = new SolidColorBrush(Color.FromArgb(255, (byte)212, (byte)227, (byte)242));//#FFD4E3F2
                st.Setters.Add(new Setter() { Property = TabItem.BackgroundProperty, Value = brush1 });

                Trigger tg = new Trigger { Property = TabItem.IsSelectedProperty, Value = true };
                var brush2 = new SolidColorBrush(Color.FromArgb(255, (byte)234, (byte)239, (byte)245));//#FFEAEFF5
                tg.Setters.Add(new Setter() { Property = TabItem.BackgroundProperty, Value = brush2 });

                st.Triggers.Add(tg);

                panel.Style = st;
                ///triggers///

                DataPanel datapanel = new DataPanel();
                datapanel.sortcolnames = sortcolnames;//11Apr2014
                datapanel.sortorder = sortorder; //14Apr2014

                 VirtualListDynamic vld = new VirtualListDynamic(_analyticsService, ds);
                 vld.DataF = _analyticsService.GetDataFrame(ds);
                 if (vld.DataF == null) return; //03Aug2015 When SaveAs fails and tries to load the dataset closing the current one.
                 IList list = vld;
                panel.Tag = ds; //panel.Tag = ds;
                datapanel.DS = ds; //sending reference
                datapanel.Data = list;

                datapanel.Variables = ds.Variables;

                datapanel.statusbar.Text = "";// "No Split";//03Dec2013 Status bar

                panel.Header =  sp;///Path.GetFileName(ds.FileName);
                
                panel.Content = datapanel;
                docGroup.Items.Add(panel);//panel
                //panel.IsSelected = true;
                docGroup.SelectedItem = panel; 
                //docGroup.SelectedIndex = docGroup.Items.Count - 1;
                //docGroup.Background = Brushes.Red; /color around open dataset
                ///layoutManager.Activate(panel);
            }
        }