public LayoutDropDown(ActionDispatcher dispatcher, WebDropDownAction action, WebIconSize iconSize) { InitializeComponent(); _iconSize = iconSize; _actionDispatcher = dispatcher; _actionItem = action; _popup = new LayoutPopup(dispatcher, action.DropDownActions).AsSingleton(); dispatcher.Register(_actionItem.Identifier, this); SetIcon(); ToolTipService.SetToolTip(LayoutDropDownButton, _actionItem.ToolTip); ButtonComponent.Click += OnDropClick; LayoutDropDownButton.MouseEnter += ButtonComponent_MouseEnter; LayoutDropDownButton.MouseLeave += ButtonComponent_MouseLeave; Visibility = _actionItem.DesiredVisiblility; ButtonComponent.IsEnabled = _actionItem.Enabled; IndicateChecked(false); //This button doesn't have a checked state. }
public StandardButton(ActionDispatcher dispatcher, WebClickAction icon, WebIconSize iconSize) { InitializeComponent(); _actionItem = icon; _actionDispatcher = dispatcher; _actionDispatcher.Register(_actionItem.Identifier, this); SetIconSize(iconSize); SetIcon(); ToolTipService.SetToolTip(ButtonComponent, _actionItem.ToolTip); ButtonComponent.Click += OnClick; Visibility = _actionItem.DesiredVisiblility; ButtonComponent.IsEnabled = _actionItem.Enabled; ButtonComponent.MouseEnter += ButtonComponentMouseEnter; ButtonComponent.MouseLeave += ButtonComponentMouseLeave; IndicateChecked(_actionItem.IsCheckAction && _actionItem.Checked); OverlayCheckedIndicator.Opacity = _actionItem.IconSet.HasOverlay ? 1 : 0; }
public MenuAdapter(ContextMenu menu, WebActionNode model, ActionDispatcher actionDispatcher) : base(menu) { _menu = menu; if (model is WebDropDownButtonAction) { //TODO (CR May 2010): there's probably a more generic way to do this WebDropDownButtonAction a = model as WebDropDownButtonAction; foreach (WebActionNode node in a.DropDownActions) { MenuItem menuItem = BuildMenuItem(node, actionDispatcher); if (menuItem != null) _menu.Items.Add(menuItem); } } else { foreach (WebActionNode node in model.Children) { MenuItem menuItem = BuildMenuItem(node, actionDispatcher); if (menuItem != null) _menu.Items.Add(menuItem); } } }
public DropDownButton(ActionDispatcher dispatcher, WebDropDownButtonAction action, WebIconSize iconSize) { InitializeComponent(); _iconSize = iconSize; _actionDispatcher = dispatcher; _actionItem = action; dispatcher.Register(_actionItem.Identifier, this); SetIcon(); ToolTipService.SetToolTip(StackPanelVerticalComponent, _actionItem.ToolTip); ButtonComponent.Click += OnClick; DropButtonComponent.Height = ButtonComponent.Height; DropButtonComponent.Click += OnDropClick; _dropMenu = MenuBuilder.BuildContextMenu(action, _actionDispatcher); StackPanelVerticalComponent.MouseEnter += ButtonComponent_MouseEnter; StackPanelVerticalComponent.MouseLeave += ButtonComponent_MouseLeave; Visibility = _actionItem.DesiredVisiblility; ButtonComponent.IsEnabled = _actionItem.Enabled; DropButtonComponent.IsEnabled = _actionItem.Enabled; IndicateChecked(_actionItem.IsCheckAction && _actionItem.Checked); OverlayCheckedIndicator.Opacity = _actionItem.IconSet.HasOverlay ? 1 : 0; }
protected virtual void Dispose(bool disposing) { if (!_disposed) { if (_actionDispatcher != null) { _actionDispatcher.Remove(_actionItem.Identifier); _actionDispatcher = null; } StackPanelVerticalComponent.MouseEnter -= ButtonComponent_MouseEnter; StackPanelVerticalComponent.MouseLeave -= ButtonComponent_MouseLeave; ButtonComponent.Click -= OnClick; DropButtonComponent.Click -= OnDropClick; if (_dropMenu != null) { if (disposing) { _dropMenu.Dispose(); } _dropMenu = null; } _disposed = true; } }
public LayoutPopup(ActionDispatcher dispatcher, IEnumerable <WebActionNode> actions) { InitializeComponent(); Popup.IsOpen = false; IsTabStop = true; // allow focus _actionDispatcher = dispatcher; //because the layout popup is just like a context menu, handle the right mouse explicitly. HostRoot.MouseRightButtonDown += delegate(object sender, MouseButtonEventArgs e) { e.Handled = true; Hide(); }; HostRoot.MouseRightButtonUp += (sender, e) => e.Handled = true; foreach (WebLayoutChangerAction node in actions) { if (node.ActionID.Equals("chooseBoxLayout")) { _imageBoxAction = node; } else if (node.ActionID.Equals("chooseTileLayout")) { _tilesAction = node; } } ImageBoxLayoutText.Text = _imageBoxAction.Label = Labels.MenuImageBoxLayout; TileLayoutText.Text = _tilesAction.Label = Labels.MenuTileLayout; CreateGridElements(); }
protected virtual void Dispose(bool disposing) { if (!_disposed) { _actionDispatcher = null; foreach (Box theBox in _imageBoxList) { theBox.OnClick -= OnClick; } _imageBoxList.Clear(); _disposed = true; } }
public void Dispose() { if (!_disposed) { if (_actionDispatcher != null) { _actionDispatcher.Remove(_actionItem.Identifier); _actionDispatcher = null; } ButtonComponent.MouseEnter -= ButtonComponentMouseEnter; ButtonComponent.MouseLeave -= ButtonComponentMouseLeave; ButtonComponent.Click -= OnClick; _disposed = true; } }
protected virtual void Dispose(bool disposing) { if (!_disposed) { if (_actionDispatcher != null) { _actionDispatcher.Remove(_actionItem.Identifier); _actionDispatcher = null; } LayoutDropDownButton.MouseEnter -= ButtonComponent_MouseEnter; LayoutDropDownButton.MouseLeave -= ButtonComponent_MouseLeave; ButtonComponent.Click -= OnDropClick; _popup.Dispose(); _popup = null; _disposed = true; } }
protected virtual void Dispose(bool disposing) { if (!_disposed) { System.Windows.Application.Current.Host.Content.Resized -= OnApplicationResized; if (disposing) { foreach (var c in LayoutRoot.Children) { var d = c as IDisposable; if (d!= null) d.Dispose(); } } if (_dispatcher != null) { _dispatcher.Dispose(); _dispatcher = null; } if (_eventMediator != null) { _eventMediator.TileHasCaptureChanged -= EventBrokerTileHasCapture; _eventMediator = null; } LayoutRoot.Children.Clear(); _disposed = true; } }
public void Dispose() { if (_actionDispatcher != null) { Item.Click -= OnItemClick; ReleaseDispatcher(); _actionItem = null; Item = null; _actionDispatcher = null; } }
internal static IPopup BuildContextMenu(WebActionNode model, ActionDispatcher actionDispatcher) { ContextMenu menu = new ContextMenu(); return new MenuAdapter(menu, model, actionDispatcher); }
private static MenuItem BuildActionMenuItem(WebActionNode subNode, ActionDispatcher dispatcher) { WebAction actionNode = subNode as WebAction; MenuItem item = new MenuItem { IsEnabled = actionNode.Enabled, IsChecked = (actionNode is WebClickAction) && (actionNode as WebClickAction).Checked, Visibility = actionNode.DesiredVisiblility }; var binding = new MenuItemBinding(actionNode, dispatcher, item); binding.SetLabel(actionNode.Label); binding.SetIcon(); item.Tag = binding; return item; }
public MenuItemBinding(WebAction action, ActionDispatcher dispatcher, MenuItem item) { _actionItem = action; _actionDispatcher = dispatcher; _actionDispatcher.Register(action.Identifier, this); item.Click += OnItemClick; Item = item; }
private static MenuItem BuildMenuItem(WebActionNode node, ActionDispatcher dispatcher) { MenuItem thisMenu = null; try { if (node.Children != null) { thisMenu = new MenuItem { Header = node.LocalizedText }; foreach (WebActionNode subNode in node.Children) { if (subNode.Children == null || subNode.Children.Count == 0) { MenuItem menuItem = BuildActionMenuItem(subNode, dispatcher); if (menuItem != null) { if (menuItem.IsChecked) thisMenu.IsChecked = true; if (menuItem != null) thisMenu.Items.Add(menuItem); } } else { MenuItem menuItem = BuildMenuItem(subNode, dispatcher); if (menuItem != null) { if (menuItem.IsChecked) thisMenu.IsChecked = true; thisMenu.Items.Add(menuItem); } } } // Don't show the menu if it has no children thisMenu.Visibility = node.DesiredVisiblility; } else { WebAction actionNode = node as WebAction; thisMenu = BuildActionMenuItem(actionNode, dispatcher); } return thisMenu; } catch (Exception ex) { // When an error happens here we need as much technical details as possible to diagnose the problem // Also, it's better to capture the error in English var itemName = node.LocalizedText; if (node is WebActionNode) itemName = (node as WebActionNode).LocalizedText; if (node is WebAction) itemName = (node as WebAction).Label; var message = new StringBuilder(); message.AppendFormat("An expected error has occurred when building menu item labelled: {0}", itemName); message.AppendLine(); message.AppendLine(string.Format("Details: {0}", ex.Message)); message.AppendLine("Stack:"); message.AppendLine(ex.StackTrace); var newEx = new Exception(message.ToString(), ex); throw newEx; } }
protected virtual void Dispose(bool disposing) { if (!_disposed) { if (_actionDispatcher != null) { _actionDispatcher.Remove(_actionItem.Identifier); _actionDispatcher = null; } StackPanelVerticalComponent.MouseEnter -= ButtonComponent_MouseEnter; StackPanelVerticalComponent.MouseLeave -= ButtonComponent_MouseLeave; ButtonComponent.Click -= OnClick; DropButtonComponent.Click -= OnDropClick; if (_dropMenu != null) { if (disposing) _dropMenu.Dispose(); _dropMenu = null; } _disposed = true; } }
public LayoutPopup(ActionDispatcher dispatcher, IEnumerable<WebActionNode> actions) { InitializeComponent(); Popup.IsOpen = false; IsTabStop = true; // allow focus _actionDispatcher = dispatcher; //because the layout popup is just like a context menu, handle the right mouse explicitly. HostRoot.MouseRightButtonDown += delegate(object sender, MouseButtonEventArgs e) { e.Handled = true; Hide(); }; HostRoot.MouseRightButtonUp += (sender, e) => e.Handled = true; foreach (WebLayoutChangerAction node in actions) { if (node.ActionID.Equals("chooseBoxLayout")) _imageBoxAction = node; else if (node.ActionID.Equals("chooseTileLayout")) _tilesAction = node; } ImageBoxLayoutText.Text = _imageBoxAction.Label = Labels.MenuImageBoxLayout; TileLayoutText.Text = _tilesAction.Label = Labels.MenuTileLayout; CreateGridElements(); }