Example #1
0
        private void ToggleContainerVisibility(FrameworkElement container, TokenInfo tokenInfo)
        {
            if (container == null || tokenInfo == null)
            {
                return;
            }

            var searchFields = container.ChildrenOfType<TextBlock>();
            if (searchFields == null || searchFields.Count <= 0)
            {
                tokenInfo.Visibility = Visibility.Collapsed;
                return;
            }

            var isFilterContained = false;
            var highlightingForeground = HighlightingForeground;
            var highlightingBackground = this.HighlightingBackground;

            foreach (var field in searchFields)
            {
                if (TokenEditExtensions.GetIsExcludedFromSearch(field))
                {
                    continue;
                }

                // clear any previously applied formatting
                var contentRange = new TextRange(field.ContentStart, field.ContentEnd);
                contentRange.ClearAllProperties();

                var matches = Regex.Matches(field.Text, Filter, RegexOptions.IgnoreCase);
                if (matches.Count == 0)
                {
                    continue;
                }

                isFilterContained = true;
                foreach (Match match in matches)
                {
                    var textRange = field.GetTextRangeFromCharOffset(match.Index, match.Length);
                    textRange.ApplyPropertyValue(TextElement.BackgroundProperty, highlightingBackground);

                    if (highlightingForeground != null)
                    {
                        textRange.ApplyPropertyValue(TextElement.ForegroundProperty, highlightingForeground);
                    }
                }
            }

            tokenInfo.Visibility = isFilterContained ? Visibility.Visible : Visibility.Collapsed;
        }
 internal static FrameworkElement GetChildByName(this FrameworkElement element, string name)
 {
     return((FrameworkElement)element.FindName(name) ?? element.ChildrenOfType <FrameworkElement>().FirstOrDefault(c => c.Name == name));
 }
 public ConfigurationPanelBehavior(FrameworkElement layoutRoot, FrameworkElement panel)
 {
     this.layoutRoot = layoutRoot;
     this.controlPanel = panel;
     this.gridView = (from i in layoutRoot.ChildrenOfType<RadGridView>() where i.Name == "radGridView" select i).FirstOrDefault();
     this.externalDetailsBorder = (from i in layoutRoot.ChildrenOfType<Border>() where i.Name == "externalDetailsBorder" select i).FirstOrDefault();
     
     this.CurrentDetailsTemplate = DetailsTemplateChoices.FirstOrDefault();
     this.CurrentInlineDetails = InlineDetailsChoices.FirstOrDefault();
     this.CurrentExternalDetailsPresenter = ExternalDetailsPresenterChoices.FirstOrDefault();
     this.CurrentHorizontalScrollingchoices = HorizontalScrollingChoices.FirstOrDefault();
     
     this.controlPanel.LayoutUpdated += controlPanel_LayoutUpdated;
 }