/// <summary> /// Initialize a new instance of the ButtonSpecView class. /// </summary> /// <param name="redirector">Palette redirector.</param> /// <param name="paletteMetric">Source for metric values.</param> /// <param name="metricPadding">Padding metric for border padding.</param> /// <param name="manager">Reference to owning manager.</param> /// <param name="buttonSpec">Access</param> public ButtonSpecView(PaletteRedirect redirector, IPaletteMetric paletteMetric, PaletteMetricPadding metricPadding, ButtonSpecManagerBase manager, ButtonSpec buttonSpec) { Debug.Assert(redirector != null); Debug.Assert(manager != null); Debug.Assert(buttonSpec != null); // Remember references _redirector = redirector; _manager = manager; _buttonSpec = buttonSpec; _finishDelegate = new EventHandler(OnFinishDelegate); // Create delegate for paint notifications NeedPaintHandler needPaint = new NeedPaintHandler(OnNeedPaint); // Intercept calls from the button for color remapping and instead use // the button spec defined map and the container foreground color _remapPalette = _manager.CreateButtonSpecRemap(redirector, buttonSpec); // Use a redirector to get button values directly from palette _palette = new PaletteTripleRedirect(_remapPalette, PaletteBackStyle.ButtonButtonSpec, PaletteBorderStyle.ButtonButtonSpec, PaletteContentStyle.ButtonButtonSpec, needPaint); // Create the view for displaying a button _viewButton = new ViewDrawButton(_palette, _palette, _palette, _palette, paletteMetric, this, VisualOrientation.Top, false); // Associate the view with the source component (for design time support) if (buttonSpec.AllowComponent) _viewButton.Component = buttonSpec; // Use a view center to place button in centre of given space _viewCenter = new ViewLayoutCenter(paletteMetric, metricPadding, VisualOrientation.Top); _viewCenter.Add(_viewButton); // Create a controller for managing button behavior ButtonSpecViewControllers controllers = CreateController(_viewButton, needPaint, new MouseEventHandler(OnClick)); _viewButton.MouseController = controllers.MouseController; _viewButton.SourceController = controllers.SourceController; _viewButton.KeyController = controllers.KeyController; // We need notifying whenever a button specification property changes _buttonSpec.ButtonSpecPropertyChanged += new PropertyChangedEventHandler(OnPropertyChanged); // Associate the button spec with the view that is drawing it _buttonSpec.SetView(_viewButton); // Finally update view with current button spec settings UpdateButtonStyle(); UpdateVisible(); UpdateEnabled(); UpdateChecked(); }
/// <summary> /// Initialize a new instance of the ButtonSpecViewAppButton class. /// </summary> /// <param name="redirector">Palette redirector.</param> /// <param name="paletteMetric">Source for metric values.</param> /// <param name="metricPadding">Padding metric for border padding.</param> /// <param name="manager">Reference to owning manager.</param> /// <param name="buttonSpec">Access</param> public ButtonSpecViewAppButton(PaletteRedirect redirector, IPaletteMetric paletteMetric, PaletteMetricPadding metricPadding, ButtonSpecManagerBase manager, ButtonSpec buttonSpec) : base(redirector, paletteMetric, metricPadding, manager, buttonSpec) { }
/// <summary> /// Create the button spec view appropriate for the button spec. /// </summary> /// <param name="redirector">Redirector for acquiring palette values.</param> /// <param name="viewPaletteMetric">Target metric providers.</param> /// <param name="viewMetricPadding">Target metric padding.</param> /// <param name="buttonSpec">ButtonSpec instance.</param> /// <returns>ButtonSpecView derived class.</returns> protected override ButtonSpecView CreateButtonSpecView(PaletteRedirect redirector, IPaletteMetric viewPaletteMetric, PaletteMetricPadding viewMetricPadding, ButtonSpec buttonSpec) { return new ButtonSpecViewRibbon(redirector, viewPaletteMetric, viewMetricPadding, this, buttonSpec); }
/// <summary> /// Initialize a new instance of the PageToTooltipMapping class. /// </summary> /// <param name="palette">Palette for sourcing information.</param> /// <param name="buttonSpec">Source button spec instance.</param> public ButtonSpecToContent(IPalette palette, ButtonSpec buttonSpec) { Debug.Assert(palette != null); Debug.Assert(buttonSpec != null); _palette = palette; _buttonSpec = buttonSpec; }
/// <summary> /// Initialize a new instance of the ButtonSpecEventArgs class. /// </summary> /// <param name="spec">Button spec effected by event.</param> /// <param name="index">Index of page in the owning collection.</param> public ButtonSpecEventArgs(ButtonSpec spec, int index) { Debug.Assert(spec != null); Debug.Assert(index >= 0); // Remember parameter details _spec = spec; _index = index; }
/// <summary> /// Initialize a new instance of the ButtonSpecNavRemapDisabled class. /// </summary> /// <param name="target">Initial palette target for redirection.</param> /// <param name="buttonSpec">Reference to button specification.</param> /// <param name="remapTarget">Target for remapping the color onto.</param> public ButtonSpecNavRemap(IPalette target, ButtonSpec buttonSpec, ButtonSpecRemapTarget remapTarget) : base(target) { Debug.Assert(buttonSpec != null); _buttonSpec = buttonSpec; _remapTarget = remapTarget; }
/// <summary> /// Create the button spec view appropriate for the button spec. /// </summary> /// <param name="redirector">Redirector for acquiring palette values.</param> /// <param name="viewPaletteMetric">Target metric providers.</param> /// <param name="viewMetricPadding">Target metric padding.</param> /// <param name="buttonSpec">ButtonSpec instance.</param> /// <returns>ButtonSpecView derived class.</returns> protected virtual ButtonSpecView CreateButtonSpecView(PaletteRedirect redirector, IPaletteMetric viewPaletteMetric, PaletteMetricPadding viewMetricPadding, ButtonSpec buttonSpec) { return(new ButtonSpecView(redirector, viewPaletteMetric, viewMetricPadding, this, buttonSpec)); }
/// <summary> /// Get the display rectangle of the provided button. /// </summary> /// <param name="buttonSpec">Button specification.</param> /// <returns>Display rectangle.</returns> public Rectangle GetButtonRectangle(ButtonSpec buttonSpec) { // Find all the buttons on this view docker foreach (ButtonSpecView buttonView in _specLookup.Values) { if (buttonView.ButtonSpec == buttonSpec) { return(buttonView.ViewButton.ClientRectangle); } } return(Rectangle.Empty); }
/// <summary> /// Value copy from the provided source to ourself. /// </summary> /// <param name="source">Source instance.</param> public virtual void CopyFrom(ButtonSpec source) { // Copy class specific values Image = source.Image; ImageTransparentColor = source.ImageTransparentColor; ImageStates.CopyFrom(source.ImageStates); Text = source.Text; ExtraText = source.ExtraText; AllowInheritImage = source.AllowInheritImage; AllowInheritText = source.AllowInheritText; AllowInheritExtraText = source.AllowInheritExtraText; ColorMap = source.ColorMap; Style = source.Style; Orientation = source.Orientation; Edge = source.Edge; ProtectedType = source.ProtectedType; }
private ButtonSpecView AddButtonSpec(ButtonSpec buttonSpec) { // Find the docker index that is the target for the button spec int viewDockerIndex = GetTargetDockerIndex(buttonSpec.GetLocation(_redirector)); IPaletteMetric viewPaletteMetric = null; PaletteMetricPadding viewMetricPadding = PaletteMetricPadding.None; // Are we applying metrics if ((_viewMetrics != null) && (_viewMetrics.Length > viewDockerIndex) && (_viewMetricPaddings.Length > viewDockerIndex)) { viewPaletteMetric = _viewMetrics[viewDockerIndex]; viewMetricPadding = _viewMetricPaddings[viewDockerIndex]; // Create an instance to manage the individual button spec ButtonSpecView buttonView = CreateButtonSpecView(_redirector, viewPaletteMetric, viewMetricPadding, buttonSpec); // Add a lookup from the button spec to the button spec view _specLookup.Add(buttonSpec, buttonView); // Update the button with the same orientation as the view header buttonView.ViewButton.Orientation = CalculateOrientation(DockerOrientation(viewDockerIndex), buttonSpec.GetOrientation(_redirector)); buttonView.ViewCenter.Orientation = DockerOrientation(viewDockerIndex); // Insert the button view into the docker AddViewToDocker(viewDockerIndex, GetDockStyle(buttonSpec), buttonView.ViewCenter, (_viewMetrics != null)); // Perform any last construction steps for button spec ButtonSpecCreated(buttonSpec, buttonView, viewDockerIndex); // Hook in to the button spec change event buttonSpec.ButtonSpecPropertyChanged += new PropertyChangedEventHandler(OnPropertyChanged); return(buttonView); } return(null); }
private void RemoveButtonSpec(ButtonSpec buttonSpec) { // Unhook from button spec events buttonSpec.ButtonSpecPropertyChanged -= new PropertyChangedEventHandler(OnPropertyChanged); // Get the button view from the button spec ButtonSpecView buttonView = _specLookup[buttonSpec]; if (buttonView != null) { // Remove the view that was created for the button from its header if ((buttonView.ViewCenter.Parent != null) && buttonView.ViewCenter.Parent.Contains(buttonView.ViewCenter)) { buttonView.ViewCenter.Parent.Remove(buttonView.ViewCenter); } // Pull down the view for the button buttonView.Destruct(); } }
/// <summary> /// Initialize a new instance of the ButtonSpecRemapByContentView class. /// </summary> /// <param name="target">Initial palette target for redirection.</param> /// <param name="buttonSpec">Reference to button specification.</param> public ButtonSpecRemapByContentView(IPalette target, ButtonSpec buttonSpec) : base(target, buttonSpec) { }
/// <summary> /// Create a palette redirector for remapping button spec colors. /// </summary> /// <param name="redirector">Base palette class.</param> /// <param name="buttonSpec">ButtonSpec instance.</param> /// <returns>Palette redirector for the button spec instance.</returns> public override PaletteRedirect CreateButtonSpecRemap(PaletteRedirect redirector, ButtonSpec buttonSpec) { return new ButtonSpecNavRemap(redirector, buttonSpec, RemapTarget); }
/// <summary> /// Create a palette redirector for remapping button spec colors. /// </summary> /// <param name="redirector">Base palette class.</param> /// <param name="buttonSpec">ButtonSpec instance.</param> /// <returns>Palette redirector for the button spec instance.</returns> public virtual PaletteRedirect CreateButtonSpecRemap(PaletteRedirect redirector, ButtonSpec buttonSpec) { return(new ButtonSpecRemapByContentView(redirector, buttonSpec)); }
/// <summary> /// Create a palette redirector for remapping button spec colors. /// </summary> /// <param name="redirector">Base palette class.</param> /// <param name="buttonSpec">ButtonSpec instance.</param> /// <returns>Palette redirector for the button spec instance.</returns> public override PaletteRedirect CreateButtonSpecRemap(PaletteRedirect redirector, ButtonSpec buttonSpec) { return new ButtonSpecRemapByContentCache(redirector, buttonSpec); }
/// <summary> /// Perform final steps now that the button spec has been created. /// </summary> /// <param name="buttonSpec">ButtonSpec instance.</param> /// <param name="buttonView">Associated ButtonSpecView instance.</param> /// <param name="viewDockerIndex">Index of view docker button is placed onto.</param> protected override void ButtonSpecCreated(ButtonSpec buttonSpec, ButtonSpecView buttonView, int viewDockerIndex) { // Cast the remapping palette to the correct type ButtonSpecRemapByContentCache remapPalette = (ButtonSpecRemapByContentCache)buttonView.RemapPalette; // Update button with the foreground used for color mapping remapPalette.SetPaletteContent(_paletteContent); remapPalette.SetPaletteState(_paletteState); }
private ViewDockStyle GetDockStyle(ButtonSpec spec) { return(spec.GetEdge(_redirector) == RelativeEdgeAlign.Near ? ViewDockStyle.Left : ViewDockStyle.Right); }
/// <summary> /// Initialize a new instance of the ButtonSpecView class. /// </summary> /// <param name="redirector">Palette redirector.</param> /// <param name="paletteMetric">Source for metric values.</param> /// <param name="metricPadding">Padding metric for border padding.</param> /// <param name="manager">Reference to owning manager.</param> /// <param name="buttonSpec">Access</param> public ButtonSpecView(PaletteRedirect redirector, IPaletteMetric paletteMetric, PaletteMetricPadding metricPadding, ButtonSpecManagerBase manager, ButtonSpec buttonSpec) { Debug.Assert(redirector != null); Debug.Assert(manager != null); Debug.Assert(buttonSpec != null); // Remember references _redirector = redirector; Manager = manager; ButtonSpec = buttonSpec; _finishDelegate = OnFinishDelegate; // Create delegate for paint notifications NeedPaintHandler needPaint = OnNeedPaint; // Intercept calls from the button for color remapping and instead use // the button spec defined map and the container foreground color RemapPalette = Manager.CreateButtonSpecRemap(redirector, buttonSpec); // Use a redirector to get button values directly from palette _palette = new PaletteTripleRedirect(RemapPalette, PaletteBackStyle.ButtonButtonSpec, PaletteBorderStyle.ButtonButtonSpec, PaletteContentStyle.ButtonButtonSpec, needPaint); // Create the view for displaying a button ViewButton = new ViewDrawButton(_palette, _palette, _palette, _palette, paletteMetric, this, VisualOrientation.Top, false); // Associate the view with the source component (for design time support) if (buttonSpec.AllowComponent) { ViewButton.Component = buttonSpec; } // Use a view center to place button in centre of given space ViewCenter = new ViewLayoutCenter(paletteMetric, metricPadding, VisualOrientation.Top) { ViewButton }; // Create a controller for managing button behavior ButtonSpecViewControllers controllers = CreateController(ViewButton, needPaint, OnClick); ViewButton.MouseController = controllers.MouseController; ViewButton.SourceController = controllers.SourceController; ViewButton.KeyController = controllers.KeyController; // We need notifying whenever a button specification property changes ButtonSpec.ButtonSpecPropertyChanged += OnPropertyChanged; // Associate the button spec with the view that is drawing it ButtonSpec.SetView(ViewButton); // Finally update view with current button spec settings UpdateButtonStyle(); UpdateVisible(); UpdateEnabled(); UpdateChecked(); }
/// <summary> /// Perform final steps now that the button spec has been created. /// </summary> /// <param name="buttonSpec">ButtonSpec instance.</param> /// <param name="buttonView">Associated ButtonSpecView instance.</param> /// <param name="viewDockerIndex">Index of view docker button is placed onto.</param> protected override void ButtonSpecCreated(ButtonSpec buttonSpec, ButtonSpecView buttonView, int viewDockerIndex) { // Nothing extra to do }
private void OnShowToolTip(object sender, ToolTipEventArgs e) { if (!IsDisposed) { // Do not show tooltips when the form we are in does not have focus Form topForm = FindForm(); if ((topForm != null) && !topForm.ContainsFocus) { return; } // Never show tooltips are design time if (!DesignMode) { IContentValues sourceContent = null; LabelStyle toolTipStyle = LabelStyle.ToolTip; // Find the button spec associated with the tooltip request ButtonSpec buttonSpec = _buttonManager.ButtonSpecFromView(e.Target); // If the tooltip is for a button spec if (buttonSpec != null) { // Are we allowed to show page related tooltips if (AllowButtonSpecToolTips) { // Create a helper object to provide tooltip values ButtonSpecToContent buttonSpecMapping = new ButtonSpecToContent(Redirector, buttonSpec); // Is there actually anything to show for the tooltip if (buttonSpecMapping.HasContent) { sourceContent = buttonSpecMapping; toolTipStyle = buttonSpec.ToolTipStyle; } } } if (sourceContent != null) { // Remove any currently showing tooltip if (_visualPopupToolTip != null) { _visualPopupToolTip.Dispose(); } // Create the actual tooltip popup object _visualPopupToolTip = new VisualPopupToolTip(Redirector, sourceContent, Renderer, PaletteBackStyle.ControlToolTip, PaletteBorderStyle.ControlToolTip, CommonHelper.ContentStyleFromLabelStyle(toolTipStyle)); _visualPopupToolTip.Disposed += new EventHandler(OnVisualPopupToolTipDisposed); // Show relative to the provided screen rectangle _visualPopupToolTip.ShowCalculatingSize(RectangleToScreen(e.Target.ClientRectangle)); } } } }