/// <summary> /// Updates the currently targeted object and cursor modifier upon getting /// an event indicating that the focused object has changed. /// </summary> /// <param name="pointer">The pointer associated with this focus change.</param> /// <param name="oldFocusedObject">Object that was previously being focused.</param> /// <param name="newFocusedObject">New object being focused.</param> protected virtual void OnPointerSpecificFocusChanged(IPointingSource pointer, GameObject oldFocusedObject, GameObject newFocusedObject) { if (pointer == Pointer) { TargetedObject = newFocusedObject; CursorModifier newModifier = (newFocusedObject == null) ? null : newFocusedObject.GetComponent <CursorModifier>(); OnActiveModifier(newModifier); } }
/// <summary> /// Override to set the cursor anim trigger /// </summary> /// <param name="modifier"></param> protected override void OnActiveModifier(CursorModifier modifier) { base.OnActiveModifier(modifier); if (modifier != null) { if ((modifier.CursorParameters != null) && (modifier.CursorParameters.Length > 0)) { OnCursorStateChange(CursorStateEnum.Contextual); foreach (var param in modifier.CursorParameters) { SetAnimatorParameter(param); } } } else { OnCursorStateChange(CursorStateEnum.None); } }
/// <summary> /// Override function when a new modifier is found or no modifier is valid /// </summary> /// <param name="modifier"></param> protected virtual void OnActiveModifier(CursorModifier modifier) { TargetedCursorModifier = modifier; }
protected virtual void OnCreateModifiers(SciChartInteractionToolbar toolbar, ISciChartSurface scs) { var listMod = new List <ToolbarItem>(); var surface = scs as SciChartSurface; var isPolar = surface != null && (surface.IsPolarChart || surface.XAxes.Any(x => x.IsPolarAxis) || surface.YAxes.Any(x => x.IsPolarAxis)); // RubberBandXyZoomModifier var rbzm = new RubberBandXyZoomModifier { IsXAxisOnly = IsZoomXAxisOnly }; _modifiersInAllMode.ChildModifiers.Add(rbzm); _modifiersInDevMode.ChildModifiers.Add(rbzm); if (!isPolar) { // ZoomPanModifier var zpm = new ZoomPanModifier { ClipModeX = ClipMode.None, IsEnabled = false }; _modifiersInAllMode.ChildModifiers.Add(zpm); _modifiersInDevMode.ChildModifiers.Add(zpm); } // ZoomExtentsModifier var zoomExtents = new ZoomExtentsModifier { ExecuteOn = ExecuteOn.MouseDoubleClick }; _modifiersInAllMode.ChildModifiers.Add(zoomExtents); _modifiersInDevMode.ChildModifiers.Add(zoomExtents); // SeriesSelectionModifier var selStyle = new Style(typeof(BaseRenderableSeries)); selStyle.Setters.Add(new Setter(BaseRenderableSeries.StrokeProperty, Colors.Red)); selStyle.Setters.Add(new Setter(BaseRenderableSeries.StrokeThicknessProperty, 2)); selStyle.Seal(); var seriesSelection = new SeriesSelectionModifier { SelectedSeriesStyle = selStyle, ReceiveHandledEvents = true, IsEnabled = false }; _modifiersInDevMode.ChildModifiers.Add(seriesSelection); // AnnotationCreationModifier var annotationMod = new CustomAnnotationCreationModifier(); annotationMod.AnnotationCreated += (sender, args) => { var modifier = (CustomAnnotationCreationModifier)sender; if (modifier != null) { foreach (var annotation in scs.Annotations) { var newAnnotation = (annotation as AnnotationBase); if (newAnnotation != null) { newAnnotation.IsEditable = true; newAnnotation.CanEditText = true; } } modifier.IsEnabled = false; } }; annotationMod.IsEnabled = false; _modifiersInDevMode.ChildModifiers.Add(annotationMod); // CustomRotateChartModifier var rotate = new CustomRotateChartModifier(); var propertyPath = new PropertyPath(CustomRotateChartModifier.IsRotationEnabledProperty); var binding = new Binding() { Source = this, Path = propertyPath }; rotate.SetBinding(ChartModifierBase.IsEnabledProperty, binding); _modifiersInDevMode.ChildModifiers.Add(rotate); // Custom Export Modifier var export = new CustomExportModifier(); _modifiersInDevMode.ChildModifiers.Add(export); // CustomThemeChangeModifier var theme = new CustomThemeChangeModifier(); _modifiersInDevMode.ChildModifiers.Add(theme); // LegendModifier var legend = new LegendModifier { UseInterpolation = true, ShowLegend = false, ShowVisibilityCheckboxes = true, ShowSeriesMarkers = true }; _modifiersInDevMode.ChildModifiers.Add(legend); // MouseWheelZoomModifier var mouseWheel = new MouseWheelZoomModifier(); _modifiersInAllMode.ChildModifiers.Add(mouseWheel); _modifiersInDevMode.ChildModifiers.Add(mouseWheel); // CustomFlipModifier var flip = new CustomFlipModifier(); _modifiersInDevMode.ChildModifiers.Add(flip); // RolloverModifier var rollover = new RolloverModifier { IsEnabled = false, UseInterpolation = true, DrawVerticalLine = true, ReceiveHandledEvents = true, ShowAxisLabels = true, ShowTooltipOn = ShowTooltipOptions.Always }; _modifiersInDevMode.ChildModifiers.Add(rollover); // CursorModifier var cursorMod = new CursorModifier { IsEnabled = false, ShowTooltipOn = ShowTooltipOptions.MouseOver, ReceiveHandledEvents = true, ShowAxisLabels = false, ShowTooltip = true }; _modifiersInDevMode.ChildModifiers.Add(cursorMod); // TooltipModifier var toolTipMod = new TooltipModifier { ReceiveHandledEvents = true, IsEnabled = false, UseInterpolation = true }; _modifiersInDevMode.ChildModifiers.Add(toolTipMod); if (!isPolar) { // YAxisDragModifier var yAxisDrag = new YAxisDragModifier(); _modifiersInDevMode.ChildModifiers.Add(yAxisDrag); // XAxisDragModifier var xAxisDrag = new XAxisDragModifier(); _modifiersInDevMode.ChildModifiers.Add(xAxisDrag); } var exampleModifiers = (scs.ChartModifier as ModifierGroup); if (exampleModifiers == null) { exampleModifiers = new ModifierGroup(); if (scs.ChartModifier != null) { exampleModifiers.ChildModifiers.Add(scs.ChartModifier); } } var devMods = new ModifierGroup(); var userMods = new ModifierGroup(); foreach (var devMod in _modifiersInDevMode.ChildModifiers) { var devModName = devMod.ModifierName; if (devMod is CustomAnnotationCreationModifier) { devModName = "AnnotationCreationModifier"; } if (!(exampleModifiers.ChildModifiers.Any(x => x.ModifierName == devModName))) { devMods.ChildModifiers.Add(devMod); } else { if (exampleModifiers.ChildModifiers.Count(x => x.ModifierName == devModName) == 1) { var exampleMod = exampleModifiers.ChildModifiers.Single(x => x.ModifierName == devModName); if (!GetAppearceInToolbar((ChartModifierBase)exampleMod)) { continue; } devMods.ChildModifiers.Add(exampleMod); } else { foreach (var exampleMod in exampleModifiers.ChildModifiers.Where(x => x.ModifierName == devModName && GetAppearceInToolbar((ChartModifierBase)x))) { devMods.ChildModifiers.Add(exampleMod); } } } } foreach (var inAllMod in _modifiersInAllMode.ChildModifiers) { var modName = inAllMod.ModifierName; if (!(exampleModifiers.ChildModifiers.Any(x => x.ModifierName == modName))) { userMods.ChildModifiers.Add(inAllMod); } else { if (exampleModifiers.ChildModifiers.Count(x => x.ModifierName == modName) == 1) { var exampleMod = exampleModifiers.ChildModifiers.Single(x => x.ModifierName == modName); if (!GetAppearceInToolbar((ChartModifierBase)exampleMod)) { continue; } userMods.ChildModifiers.Add(exampleMod); } else { foreach (var exampleMod in exampleModifiers.ChildModifiers.Where(x => x.ModifierName == modName && GetAppearceInToolbar((ChartModifierBase)x))) { userMods.ChildModifiers.Add(exampleMod); } } } } foreach (var exampleMod in exampleModifiers.ChildModifiers.Where(x => GetAppearceInToolbar((ChartModifierBase)x))) { if (!devMods.ChildModifiers.Any(x => x.ModifierName == exampleMod.ModifierName)) { devMods.ChildModifiers.Add(exampleMod); } if (!userMods.ChildModifiers.Any(x => x.ModifierName == exampleMod.ModifierName)) { userMods.ChildModifiers.Add(exampleMod); } } _modifiersInDevMode = devMods; _modifiersInUserMode = userMods; // Set modifiers to the chart scs.ChartModifier = IsDeveloperMode ? _modifiersInDevMode : _modifiersInUserMode; var wrappers = WrapModifiers(toolbar.IsDeveloperMode ? toolbar._modifiersInDevMode.ChildModifiers : toolbar._modifiersInUserMode.ChildModifiers); // Set modifiers to the ItemSource for ItemsControl listMod.AddRange(wrappers); if (listMod.Any(x => x.Modifier.ModifierName == "AnnotationCreationModifier" || x.Modifier is VerticalSliceModifier)) { listMod.Remove(listMod.FirstOrDefault(x => x.Modifier.ModifierName == "AnnotationCreationModifier")); listMod.Remove(listMod.FirstOrDefault(x => x.Modifier is VerticalSliceModifier)); } ModifiersSource = listMod; }