Exemplo n.º 1
0
        private void BindToSearchElements()
        {
            // Bind search
            HighlightToggleButton.SetBinding(ToggleButton.IsCheckedProperty, CreateBinding("Enabled", Search));
            FilterToggleButton.SetBinding(ToggleButton.IsCheckedProperty, CreateBinding("Enabled", SearchFilter));
            ExtractToggleButton.SetBinding(ToggleButton.IsCheckedProperty, CreateBinding("Enabled", SearchExtractor));

            if (Search.Enabled)
            {
                BindSearchToSearchHighlighter();
            }
            else if (SearchFilter.Enabled)
            {
                BindSearchToSearchFilter();
            }
            else if (SearchExtractor.Enabled)
            {
                BindSearchToSearchExtractor();
            }
        }
Exemplo n.º 2
0
        private void BindViewToViewModel()
        {
            // Append version number to caption (to save effort of producing an about screen)
            Title = string.Format("{0} ({1}) {2}", Assembly.GetExecutingAssembly().GetName().Name, Assembly.GetExecutingAssembly().GetName().Version, ServiceLocator.Instance.Get <ISessionManager>().Name);

            Preferences = ServiceLocator.Instance.Get <IUserPreferences>();
            ViewManager = ServiceLocator.Instance.Get <IViewManager>();

            // Maintaining column widths is proving difficult in Xaml alone, so
            // add an observer here and deal with it in code.
            if (Preferences is INotifyPropertyChanged)
            {
                (Preferences as INotifyPropertyChanged).PropertyChanged += PreferencesChanged;
            }

            DataContext = this;

            // When a new item is added, select the newest one.
            ViewManager.Viewers.CollectionChanged += ViewManagerChanged;

            //View-specific bindings
            var collapseIfZero = new CollapseIfZeroConverter();

            var standardHighlighters = new CollectionViewSource()
            {
                Source = Highlighters.Highlighters
            };

            standardHighlighters.View.Filter = c =>
            {
                if (c is IStandardDebuggingHighlighter)
                {
                    return(true);
                }
                return(false);
            };

            var customHighlighters = new CollectionViewSource()
            {
                Source = Highlighters.Highlighters
            };

            customHighlighters.View.Filter = c =>
            {
                if (c is IStandardDebuggingHighlighter)
                {
                    return(false);
                }
                return(true);
            };

            StandardHighlightersRibbonGroup.SetBinding(RibbonGroup.ItemsSourceProperty, new Binding()
            {
                Source = standardHighlighters
            });

            StandardHighlighterRibbonGroupOnTab.SetBinding(RibbonGroup.ItemsSourceProperty, new Binding()
            {
                Source = standardHighlighters
            });
            StandardHighlighterRibbonGroupOnTab.SetBinding(VisibilityProperty, new Binding()
            {
                Source    = standardHighlighters,
                Path      = new PropertyPath("Count"),
                Converter = collapseIfZero
            });
            CustomHighlighterRibbonGroupOnTab.SetBinding(RibbonGroup.ItemsSourceProperty, new Binding()
            {
                Source = customHighlighters
            });
            CustomHighlighterRibbonGroupOnTab.SetBinding(VisibilityProperty, new Binding()
            {
                Source    = customHighlighters,
                Path      = new PropertyPath("Count"),
                Converter = collapseIfZero
            });

            var standardFilters = new CollectionViewSource()
            {
                Source = Filters.Filters
            };

            standardFilters.View.Filter = c =>
            {
                if (c is IStandardDebuggingFilter)
                {
                    return(true);
                }
                return(false);
            };
            var customFilters = new CollectionViewSource()
            {
                Source = Filters.Filters
            };

            customFilters.View.Filter = c =>
            {
                if (c is IStandardDebuggingFilter)
                {
                    return(false);
                }
                return(true);
            };

            StandardFiltersRibbonGroup.SetBinding(RibbonGroup.ItemsSourceProperty, new Binding()
            {
                Source = standardFilters
            });

            StandardFiltersRibbonGroupOnTab.SetBinding(RibbonGroup.ItemsSourceProperty, new Binding()
            {
                Source = standardFilters
            });

            StandardFiltersRibbonGroupOnTab.SetBinding(VisibilityProperty, new Binding()
            {
                Source    = standardFilters,
                Path      = new PropertyPath("Count"),
                Converter = collapseIfZero
            });
            CustomFiltersRibbonGroupOnTab.SetBinding(RibbonGroup.ItemsSourceProperty, new Binding()
            {
                Source = customFilters
            });
            CustomFiltersRibbonGroupOnTab.SetBinding(VisibilityProperty, new Binding()
            {
                Source    = customFilters,
                Path      = new PropertyPath("Count"),
                Converter = collapseIfZero
            });

            var customExtractors = Extractors.Extractors;

            CustomExtractorsRibbonGroupOnTab.SetBinding(RibbonGroup.ItemsSourceProperty, new Binding()
            {
                Source = customExtractors
            });

            var customClassifyiers = ClassifyingService.Classifiers;

            CustomClassifiersRibbonGroupOnTab.SetBinding(RibbonGroup.ItemsSourceProperty, new Binding()
            {
                Source = customClassifyiers
            });

            //Bind search
            HighlightToggleButton.SetBinding(RibbonToggleButton.IsCheckedProperty, new Binding()
            {
                Source = Search,
                Path   = new PropertyPath("Enabled"),
                UpdateSourceTrigger = UpdateSourceTrigger.PropertyChanged
            });
            FilterToggleButton.SetBinding(RibbonToggleButton.IsCheckedProperty, new Binding()
            {
                Source = SearchFilter,
                Path   = new PropertyPath("Enabled"),
                UpdateSourceTrigger = UpdateSourceTrigger.PropertyChanged
            });
            ExtractToggleButton.SetBinding(RibbonToggleButton.IsCheckedProperty, new Binding()
            {
                Source = SearchExtractor,
                Path   = new PropertyPath("Enabled"),
                UpdateSourceTrigger = UpdateSourceTrigger.PropertyChanged
            });

            if (Search.Enabled)
            {
                BindSearchToSearchHighlighter();
            }
            else if (SearchFilter.Enabled)
            {
                BindSearchToSearchFilter();
            }
            else if (SearchExtractor.Enabled)
            {
                BindSearchToSearchExtractor();
            }

            //Column view buttons
            ExceptionRibbonToggleButton.SetBinding(RibbonToggleButton.IsCheckedProperty, new Binding()
            {
                Source = Preferences,
                Path   = new PropertyPath("ShowExceptionColumn")
            });
            ThreadRibbonToggleButton.SetBinding(RibbonToggleButton.IsCheckedProperty, new Binding()
            {
                Source = Preferences,
                Path   = new PropertyPath("ShowThreadColumn")
            });
        }