internal List <FrameworkElement> GetToolbarButtons(ModifiableEntity entity, EntityButtonContext ctx) { List <FrameworkElement> elements = new List <FrameworkElement>(); if (GetButtonBarElementGlobal != null) { elements.AddRange(GetButtonBarElementGlobal.GetInvocationListTyped() .Select(d => d(entity, ctx)) .NotNull().SelectMany(d => d).NotNull().ToList()); } var getButtons = GetButtonBarElementByType.TryGetC(entity.GetType()); if (getButtons != null) { elements.AddRange(getButtons.GetInvocationListTyped() .Select(d => d(entity, ctx)) .NotNull().ToList()); } if (ctx.MainControl is IHaveToolBarElements) { elements.AddRange(((IHaveToolBarElements)ctx.MainControl).GetToolBarElements(entity, ctx)); } return(elements.OrderBy(Common.GetOrder).ToList()); }
public List<FrameworkElement> GetToolBarElements(object dataContext, EntityButtonContext ctx) { ToolBarButton button = new ToolBarButton() { Content = FileMessage.Open.NiceToString(), Image = ExtensionsImageLoader.GetImageSortName("document_view.png"), }; button.Click += new RoutedEventHandler(buttonOpen_Click); return new List<FrameworkElement>() { button }; }
public List <EmbeddedWidget> GetEmbeddedWigets(ModifiableEntity entity, EntityButtonContext ctx) { List <EmbeddedWidget> elements = new List <EmbeddedWidget>(); if (OnGetEmbeddedWigets != null) { elements.AddRange(OnGetEmbeddedWigets.GetInvocationListTyped() .Select(d => d(entity, ctx)) .NotNull().ToList()); } return(elements.ToList()); }
void NormalWindow_DataContextChanged(object sender, DependencyPropertyChangedEventArgs e) { RefreshEnabled(); var entity = (ModifiableEntity)e.NewValue; if (entity == null) { return; } EntityButtonContext ctx = new EntityButtonContext { MainControl = MainControl, ViewButtons = ViewMode, SaveProtected = SaveProtected, ShowOperations = ShowOperations, }; List <FrameworkElement> elements = Navigator.Manager.GetToolbarButtons(entity, ctx); ButtonBar.SetButtons(elements); var widgets = Navigator.Manager.GetEmbeddedWigets(entity, ctx); spTop.Children.Clear(); foreach (var w in widgets.Where(w => w.Position == EmbeddedWidgetPostion.Top).OrderBy(a => a.Order)) { spTop.Children.Add(w.Control); } spBottom.Children.Clear(); foreach (var w in widgets.Where(w => w.Position == EmbeddedWidgetPostion.Bottom).OrderBy(a => a.Order)) { spBottom.Children.Add(w.Control); } }
void NormalWindow_DataContextChanged(object sender, DependencyPropertyChangedEventArgs e) { RefreshEnabled(); var entity = (ModifiableEntity)e.NewValue; if(entity == null) return; EntityButtonContext ctx = new EntityButtonContext { MainControl = MainControl, ViewButtons = ViewMode, SaveProtected = SaveProtected, ShowOperations = ShowOperations, }; List<FrameworkElement> elements = Navigator.Manager.GetToolbarButtons(entity, ctx); ButtonBar.SetButtons(elements); var widgets = Navigator.Manager.GetEmbeddedWigets(entity, ctx); spTop.Children.Clear(); foreach (var w in widgets.Where(w=>w.Position == EmbeddedWidgetPostion.Top).OrderBy(a=>a.Order)) spTop.Children.Add(w.Control); spBottom.Children.Clear(); foreach (var w in widgets.Where(w => w.Position == EmbeddedWidgetPostion.Bottom).OrderBy(a => a.Order)) spBottom.Children.Add(w.Control); }