private void SetHighlighterOpacity(double opacity) { highlighter.Opacity = opacity; if (opacity == 0) { foreach (var label in Children.OfType <ILabel>()) { var textBlock = WpfFactory.GetNativeObject <TextBlock>(label, "child", true); if (textBlock != null) { textBlock.Foreground = label.ForegroundColor.GetBrush(); } } } else { foreach (var label in Children.OfType <ILabel>()) { var textBlock = WpfFactory.GetNativeObject <TextBlock>(label, "child", true); if (textBlock != null) { textBlock.Foreground = (label.HighlightColor.IsDefaultColor ? label.ForegroundColor : label.HighlightColor).GetBrush(); } } } }
public void AddChild(IElement control) { var element = WpfFactory.GetNativeObject <FrameworkElement>(control, "element", false); if (element != null) { if (element.Parent is Panel) { ((Panel)element.Parent).Children.Remove(element); } canvas.Children.Add(element); if (highlighter.Opacity > 0) { var label = element as ILabel; if (label != null) { var textBlock = element as TextBlock; if (textBlock != null) { textBlock.Foreground = (label.HighlightColor.IsDefaultColor ? label.ForegroundColor : label.HighlightColor).GetBrush(); } } } var handler = PropertyChanged; if (handler != null) { handler(this, new PropertyChangedEventArgs("Children")); } } }
public void RemoveChild(IElement control) { var element = WpfFactory.GetNativeObject <FrameworkElement>(control, "element", true); if (element != null) { canvas.Children.Remove(element); var label = element as ILabel; if (label != null) { var textBlock = element as TextBlock; if (textBlock != null) { textBlock.Foreground = label.ForegroundColor.GetBrush(); } } var handler = PropertyChanged; if (handler != null) { handler(this, new PropertyChangedEventArgs("Children")); } } }
public IMXView[] PopToView(IMXView view) { view = (IMXView)WpfFactory.GetNativeObject <UIElement>(view, "view", false); Parameter.CheckObjectExists(ViewStack, "history", view, "view"); List <IMXView> views = null; if (ViewStack.Last() != view) { views = new List <IMXView>(); while (ViewStack.Count > 1 && ViewStack[ViewStack.Count - 1] != view) { var last = ViewStack.Last(); var pair = last as IPairable; if (pair == null) { views.Add(last); } else { views.Add((pair.Pair as IMXView) ?? (IMXView)pair); } ViewStack.RemoveAt(ViewStack.Count - 1); } Content = ViewStack.Last(); } return(views == null ? null : views.ToArray()); }
public void RemoveChild(IElement control) { var element = WpfFactory.GetNativeObject <FrameworkElement>(control, "element", true); if (element != null) { canvas.Children.Remove(element); OnPropertyChanged("Children"); } }
public void InsertView(int index, IMXView view) { Parameter.CheckIndex(ViewStack, "history", index); view = (IMXView)WpfFactory.GetNativeObject <UIElement>(view, "view", false); ViewStack.Insert(index, view); if (index == ViewStack.Count - 1) { Content = view; } }
public void ReplaceView(IMXView currentView, IMXView newView) { currentView = (IMXView)WpfFactory.GetNativeObject <UIElement>(currentView, "currentView", false); int index = Parameter.CheckObjectExists(ViewStack, "history", currentView, "currentView"); ViewStack[index] = (IMXView)WpfFactory.GetNativeObject <UIElement>(newView, "newView", false); if (index == ViewStack.Count - 1) { Content = ViewStack.Last(); } }
public object Convert(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture) { if (value is HeaderFooter) { return(((HeaderFooter)value).Element); } if (value is SectionCell) { SectionCell sc = (SectionCell)value; ICell cell = null; if (sc.SectionCellRequested != null) { cell = sc.SectionCellRequested(sc.CellIndex, null); } else if (sc.CellRequested != null) { cell = sc.CellRequested(sc.SectionIndex, sc.CellIndex, null); } sc.Cell = cell; CustomItemContainer container = cell as CustomItemContainer; if (container != null) { var custom = container.CustomItem as FrameworkElement; System.Windows.Controls.Grid.SetColumn(custom, sc.SectionIndex % 2); return(custom); } var element = WpfFactory.GetNativeObject <FrameworkElement>(cell, "cell", true); if (element != null) { System.Windows.Controls.Grid.SetColumn(element, sc.SectionIndex % 2); element.Unloaded += (o, e) => { var gridCell = o as IGridCell; var view = parameter as ListView; if (view != null && gridCell != null) { view.SetSubmitValue(gridCell); } }; } return(element); } return(value); }
public void AddChild(IElement control) { var element = WpfFactory.GetNativeObject <FrameworkElement>(control, "element", false); if (element != null) { if (element.Parent is Panel) { ((Panel)element.Parent).Children.Remove(element); } canvas.Children.Add(element); OnPropertyChanged("Children"); } }
public void Add(IMenuButton menuButton) { var button = WpfFactory.GetNativeObject <System.Windows.Controls.Button>(menuButton, "menuButton", false); if (button != null) { button.Click -= ClosePopup; button.Click += ClosePopup; button.Background = itemsControl.Background; button.Foreground = itemsControl.Foreground; var buttonBase = button as ButtonBase; if (buttonBase != null) { buttonBase.HighlightColor = HighlightColor; } itemsControl.Items.Add(button); } if (itemsControl.Items.Count != 1) { SetImage(imagePath); } else { if (!string.IsNullOrWhiteSpace(menuButton.ImagePath)) { SetImage(menuButton.ImagePath); } if (!HasImage) { Content = menuButton.Title; FontFamily = new System.Windows.Media.FontFamily("Segoe UI"); FontSize = 12; } } var handler = PropertyChanged; if (handler != null) { handler(this, new PropertyChangedEventArgs("ButtonCount")); } }
public void ReloadSections() { if (!firstColumnItems.IsEnabled) { return; } if (ColumnMode == UI.ColumnMode.TwoColumns) { if (secondColumnItems == null) { secondColumnItems = new ListBox() { HorizontalContentAlignment = System.Windows.HorizontalAlignment.Stretch, ItemContainerStyle = (Style)Resources["ListBoxItemStyle"], ItemTemplateSelector = new CellTemplateSelector(this), BorderThickness = new Thickness(0), Background = firstColumnItems.Background, Padding = new Thickness(8, 0, 10, 0) }; System.Windows.Controls.Grid.SetColumn(secondColumnItems, 1); ScrollViewer.SetHorizontalScrollBarVisibility(secondColumnItems, ScrollBarVisibility.Disabled); ScrollViewer.SetCanContentScroll(secondColumnItems, false); KeyboardNavigation.SetTabNavigation(secondColumnItems, KeyboardNavigationMode.Continue); secondColumnItems.SelectionChanged += (o, e) => { if (e.AddedItems.Count > 0) { firstColumnItems.UnselectAll(); } }; firstColumnItems.SelectionChanged += (o, e) => { if (e.AddedItems.Count > 0 && secondColumnItems != null) { secondColumnItems.UnselectAll(); } }; } if (!container.Children.Contains(secondColumnItems)) { container.ColumnDefinitions.Insert(1, new ColumnDefinition() { Width = new GridLength(1, GridUnitType.Star) }); container.Children.Add(secondColumnItems); ScrollViewer.SetVerticalScrollBarVisibility(firstColumnItems, ScrollBarVisibility.Hidden); ScrollViewer.SetCanContentScroll(firstColumnItems, false); var scroller = firstColumnItems.FindChild <ScrollViewer>(null); if (scroller != null) { scroller.ScrollChanged -= SyncScrollBars; scroller.ScrollChanged += SyncScrollBars; } secondColumnItems.ApplyTemplate(); scroller = secondColumnItems.FindChild <ScrollViewer>(null); if (scroller != null) { scroller.ScrollChanged -= SyncScrollBars; scroller.ScrollChanged += SyncScrollBars; } } List <object> firstItems = new List <object>(); for (int i = 0; i < Sections.Count; i += 2) { Section section = Sections[i]; firstItems.Add(new HeaderFooter() { Element = WpfFactory.GetNativeObject <UIElement>(section.Header, "Header", true) }); for (int j = 0; j < section.ItemCount; j++) { var sc = new SectionCell() { CellIndex = j, SectionIndex = i }; if (section.CellRequested != null) { sc.SectionCellRequested = section.CellRequested; } else { sc.CellRequested = CellRequested; } firstItems.Add(sc); } firstItems.Add(new HeaderFooter() { Element = WpfFactory.GetNativeObject <UIElement>(section.Footer, "Footer", true) }); } firstColumnItems.ItemsSource = firstItems; firstColumnItems.Padding = new Thickness(10, 0, 8 + SystemParameters.ScrollWidth, 0); List <object> secondItems = new List <object>(); for (int i = 1; i < Sections.Count; i += 2) { Section section = Sections[i]; secondItems.Add(new HeaderFooter() { Element = WpfFactory.GetNativeObject <UIElement>(section.Header, "Header", true) }); for (int j = 0; j < section.ItemCount; j++) { var sc = new SectionCell() { CellIndex = j, SectionIndex = i }; if (section.CellRequested != null) { sc.SectionCellRequested = section.CellRequested; } else { sc.CellRequested = CellRequested; } secondItems.Add(sc); } secondItems.Add(new HeaderFooter() { Element = WpfFactory.GetNativeObject <UIElement>(section.Footer, "Footer", true) }); } secondColumnItems.ItemsSource = secondItems; } else { if (secondColumnItems != null && container.Children.Contains(secondColumnItems)) { container.Children.Remove(secondColumnItems); container.ColumnDefinitions.RemoveAt(1); ScrollViewer.SetVerticalScrollBarVisibility(firstColumnItems, ScrollBarVisibility.Auto); ScrollViewer.SetCanContentScroll(firstColumnItems, true); var scroller = firstColumnItems.FindChild <ScrollViewer>(null); if (scroller != null) { scroller.ScrollChanged -= SyncScrollBars; } scroller = secondColumnItems.FindChild <ScrollViewer>(null); if (scroller != null) { scroller.ScrollChanged -= SyncScrollBars; } secondColumnItems = null; } var items = new List <object>(); for (int i = 0; i < Sections.Count; i++) { Section section = Sections[i]; items.Add(new HeaderFooter() { Element = WpfFactory.GetNativeObject <UIElement>(section.Header, "Header", true) }); for (int j = 0; j < section.ItemCount; j++) { var sc = new SectionCell() { CellIndex = j, SectionIndex = i }; if (section.CellRequested != null) { sc.SectionCellRequested = section.CellRequested; } else { sc.CellRequested = CellRequested; } items.Add(sc); } items.Add(new HeaderFooter() { Element = WpfFactory.GetNativeObject <UIElement>(section.Footer, "Footer", true) }); } firstColumnItems.ItemsSource = items; firstColumnItems.Padding = new Thickness(0); } }
public virtual void PushView(IMXView view) { ViewStack.Add((IMXView)WpfFactory.GetNativeObject <UIElement>(view, "view", false)); Content = ViewStack.Last(); }