private void MoveHighlight(IEasingFunctionDefinition targetFunction, int buttonNumber) { if (targetFunction == null) { return; } ComboBoxItem comboBoxItem = (ComboBoxItem)this.ItemContainerGenerator.ContainerFromItem((object)targetFunction); if (comboBoxItem == null) { return; } ContentPresenter contentPresenter = Enumerable.FirstOrDefault <ContentPresenter>(Enumerable.OfType <ContentPresenter>(ElementUtilities.GetVisualTree((Visual)comboBoxItem))); DataTemplate contentTemplate = contentPresenter.ContentTemplate; if (buttonNumber < 0 || buttonNumber >= this.buttonOrder.Count) { return; } EasingFunctionSelectionButton functionSelectionButton = contentTemplate.FindName(this.buttonOrder[buttonNumber].ToString() + "Button", (FrameworkElement)contentPresenter) as EasingFunctionSelectionButton; if (functionSelectionButton == null) { return; } this.LastHighlightedButton = functionSelectionButton; }
protected override void OnRender(DrawingContext drawingContext) { base.OnRender(drawingContext); IEasingFunctionDefinition easingFunction = this.EasingFunction; EasingMode easing = this.Easing; Size size = new Size(this.ActualWidth, this.ActualHeight); Pen pen = new Pen(this.Brush, 1.0); Point point = new Point(5.0, 5.0); if (easingFunction != null) { EasingMode easingMode = EasingMode.None; if (easing != EasingMode.None) { easingMode = easingFunction.EasingMode; easingFunction.EasingMode = easing; } int capacity = (int)Math.Floor(size.Width); List <double> list = new List <double>(capacity); double val2_1 = 0.0; double val2_2 = 1.0; for (int index = 0; index < capacity; ++index) { try { double val1 = (size.Height - 1.0) * (1.0 - easingFunction.Ease(1.0 * (double)index / ((double)capacity - 1.0))); list.Add(val1); val2_1 = Math.Min(val1, val2_1); val2_2 = Math.Max(val1, val2_2); } catch (Exception ex) { return; } } if (val2_2 > this.ActualHeight - 1.0 + EasingFunctionPreviewIcon.MaxExtraRange || val2_1 < 0.0 - EasingFunctionPreviewIcon.MaxExtraRange) { double num1 = val2_2 - val2_1; double num2 = (size.Height + EasingFunctionPreviewIcon.MaxExtraRange) / num1; double num3 = val2_1 + point.Y / 2.0; for (int index = 0; index < capacity; ++index) { list[index] = (list[index] - num3) * num2; } } Point point0 = new Point(point.X, point.Y + list[0]); for (int index = 1; index < capacity; ++index) { Point point1 = new Point(point.X + (double)index, point.Y + list[index]); drawingContext.DrawLine(pen, point0, point1); point0 = point1; } easingFunction.EasingMode = easingMode; } else { drawingContext.DrawLine(pen, new Point(point.X, point.Y + size.Height - 1.0), new Point(point.X + size.Width - 1.0, point.Y)); } }
private static void OnSelectedEasingFunctionChanged(DependencyObject d, DependencyPropertyChangedEventArgs e) { EasingFunctionSelectionButton functionSelectionButton = d as EasingFunctionSelectionButton; IEasingFunctionDefinition selectedEasingFunction = functionSelectionButton.SelectedEasingFunction; IEasingFunctionDefinition ownEasingFunction = functionSelectionButton.OwnEasingFunction; bool flag = functionSelectionButton.CanBeEnabled && (selectedEasingFunction == null || ownEasingFunction == null ? selectedEasingFunction == null && ownEasingFunction == null : ownEasingFunction.PlatformSpecificObject.GetType() == selectedEasingFunction.PlatformSpecificObject.GetType() && functionSelectionButton.Easing == selectedEasingFunction.EasingMode); functionSelectionButton.MatchesSelection = flag; }
public static string GetEasingFunctionGroupName(IEasingFunctionDefinition easingFunctionDefinition) { Type type = easingFunctionDefinition.PlatformSpecificObject.GetType(); if (type.Namespace.IndexOf(".", StringComparison.Ordinal) <= 0) { return(type.Namespace); } return(type.Namespace.Substring(0, type.Namespace.IndexOf(".", StringComparison.Ordinal))); }
public void Reset() { this.lastEvaluatedTime = -1.0; this.keyFrameEnumerator.Reset(); this.curSegmentStartTime = -1.0; this.curSegmentEndTime = -1.0; this.curSegmentStartValue = new double?(); this.curSegmentEndValue = new double?(); this.keySpline = (KeySpline)null; this.easingFunction = (IEasingFunctionDefinition)null; }
private static bool CompareEasingFunctions(object firstEasingFunction, object secondEasingFunction, SceneView sceneView) { if (sceneView == null) { return(false); } IEasingFunctionDefinition functionDefinition1 = sceneView.ProjectContext.Platform.ViewObjectFactory.Instantiate(firstEasingFunction) as IEasingFunctionDefinition; IEasingFunctionDefinition functionDefinition2 = sceneView.ProjectContext.Platform.ViewObjectFactory.Instantiate(secondEasingFunction) as IEasingFunctionDefinition; if (functionDefinition1 == null || functionDefinition2 == null) { return(false); } if (functionDefinition1.EasingMode == EasingMode.None || functionDefinition2.EasingMode == EasingMode.None) { return(firstEasingFunction.GetType() == secondEasingFunction.GetType()); } if (firstEasingFunction.GetType() == secondEasingFunction.GetType()) { return(functionDefinition1.EasingMode == functionDefinition2.EasingMode); } return(false); }
private void OnEasingFunctionSelected(object sender, RoutedEventArgs args) { this.EasingFunctionSelectionComboBox.IsDropDownOpen = false; EasingFunctionSelectionButton functionSelectionButton = sender as EasingFunctionSelectionButton; if (functionSelectionButton == null || this.easingFunctionProperty == null) { return; } IEasingFunctionDefinition ownEasingFunction = functionSelectionButton.OwnEasingFunction; SceneViewModel viewModel = this.easingFunctionProperty.SceneNodeObjectSet.ViewModel; if (viewModel == null) { return; } foreach (SceneNode sceneNode in this.easingFunctionProperty.SceneNodeObjectSet.Objects) { if (!sceneNode.IsAttached) { return; } } using (SceneEditTransaction editTransaction = viewModel.CreateEditTransaction(StringTable.ChangeEasingFunctionUndoUnit, false)) { if (ownEasingFunction != null) { ownEasingFunction.EasingMode = functionSelectionButton.Easing; this.easingFunctionProperty.PropertyValue.Value = ownEasingFunction.PlatformSpecificObject; } else { this.easingFunctionProperty.PropertyValue.ClearValue(); } editTransaction.Commit(); } }
private void AddFoundEasingFunctionBaseTypes(IAssembly assembly, IPlatform platform) { if (assembly == null || !assembly.IsLoaded || platform == null) { return; } bool flag = false; Dictionary <string, List <IEasingFunctionDefinition> > orCreateCache = DesignSurfacePlatformCaches.GetOrCreateCache <Dictionary <string, List <IEasingFunctionDefinition> > >(platform.Metadata, DesignSurfacePlatformCaches.EasingFunctionsCache); IAssembly usingAssemblyName = platform.Metadata.GetPlatformAssemblyUsingAssemblyName(assembly); if (usingAssemblyName != null && AssemblyHelper.IsPlatformAssembly(usingAssemblyName)) { if (orCreateCache.ContainsKey(assembly.FullName)) { this.knownEasingFunctions.AddRange((IEnumerable <IEasingFunctionDefinition>)orCreateCache[assembly.FullName]); return; } flag = true; } bool supportInternal = this.ActiveProjectContext.ProjectAssembly.CompareTo(assembly); IType type1 = platform.Metadata.ResolveType(PlatformTypes.EasingFunctionBase); if (platform.Metadata.IsNullType((ITypeId)type1)) { return; } Type runtimeType = type1.RuntimeType; Type[] types; try { types = AssemblyHelper.GetTypes(assembly); } catch (Exception ex) { return; } foreach (Type type2 in types) { if (runtimeType.IsAssignableFrom(type2)) { ConstructorAccessibility accessibility; ConstructorInfo defaultConstructor = PlatformTypeHelper.GetDefaultConstructor(type2, supportInternal, out accessibility); if (defaultConstructor != (ConstructorInfo)null) { IEasingFunctionDefinition functionDefinition = platform.ViewObjectFactory.Instantiate(defaultConstructor.Invoke((object[])null)) as IEasingFunctionDefinition; if (functionDefinition != null) { this.knownEasingFunctions.Add(functionDefinition); if (flag) { if (!orCreateCache.ContainsKey(assembly.FullName)) { orCreateCache.Add(assembly.FullName, new List <IEasingFunctionDefinition>()); } orCreateCache[assembly.FullName].Add(functionDefinition); } } } } } }
private void KeyDownEventHandler(object sender, KeyEventArgs args) { if (!this.IsDropDownOpen) { return; } if (args.Key == Key.Left || args.Key == Key.Right || (args.Key == Key.Down || args.Key == Key.Up)) { if (this.lastHighlightedButton == null) { IEasingFunctionDefinition functionDefinition = this.Tag as IEasingFunctionDefinition; if (functionDefinition == null) { this.LastHighlightedButton = this.nullButton; } else { foreach (object obj in (IEnumerable)this.Items) { IEasingFunctionDefinition targetFunction = obj as IEasingFunctionDefinition; if (targetFunction != null && targetFunction.PlatformSpecificObject.GetType() == functionDefinition.PlatformSpecificObject.GetType()) { this.MoveHighlight(targetFunction, this.buttonOrder.IndexOf((object)functionDefinition.EasingMode)); break; } } } } if (this.LastHighlightedButton == this.nullButton) { if (args.Key != Key.Down) { return; } this.MoveHighlight(this.Items[0] as IEasingFunctionDefinition, this.buttonOrder.IndexOf((object)EasingMode.In)); } else if (args.Key == Key.Left || args.Key == Key.Right) { this.MoveHighlight(this.LastHighlightedButton.DataContext as IEasingFunctionDefinition, this.buttonOrder.IndexOf((object)this.LastHighlightedButton.Easing) + (args.Key == Key.Left ? -1 : 1)); } else { int index = this.Items.IndexOf(this.LastHighlightedButton.DataContext) + (args.Key == Key.Down ? 1 : -1); if (index < 0) { this.LastHighlightedButton = this.nullButton; } else { if (index == this.Items.Count) { index = this.Items.Count - 1; } this.MoveHighlight(this.Items[index] as IEasingFunctionDefinition, this.buttonOrder.IndexOf((object)this.LastHighlightedButton.Easing)); } } } else { if (args.Key != Key.Return && args.Key != Key.Space) { return; } if (this.LastHighlightedButton == null) { this.nullButton.FireButtonPressed(); } else { this.LastHighlightedButton.FireButtonPressed(); } } }
public static string GetEasingFunctionName(IEasingFunctionDefinition easingFunctionDefinition) { return(EasingFunctionDefinitionHelper.GetEasingFunctionName(easingFunctionDefinition.PlatformSpecificObject.GetType())); }
public void MoveToTime(double time) { if (time < 0.0) { throw new ArgumentException("negative times are not valid"); } if (Tolerances.LessThan(time, this.lastEvaluatedTime)) { throw new ArgumentException("Evaluating backward in time is not supported. Call Reset() first"); } this.lastEvaluatedTime = time; if (time >= this.curSegmentStartTime && time < this.curSegmentEndTime) { return; } while (time > this.curSegmentEndTime) { this.curSegmentStartTime = this.curSegmentStartTime == -1.0 ? 0.0 : this.curSegmentEndTime; this.curSegmentStartValue = this.curSegmentEndValue; if (this.keyFrameEnumerator.MoveNext()) { this.easingFunction = (IEasingFunctionDefinition)null; this.keySpline = (KeySpline)null; switch (this.keyFrameEnumerator.Current.InterpolationType) { case KeyFrameInterpolationType.Discrete: this.keySpline = (KeySpline)null; break; case KeyFrameInterpolationType.Spline: this.keySpline = this.keyFrameEnumerator.Current.KeySpline; if (this.keySpline == null) { this.keySpline = ForwardAnimationEvaluator.linearKeySpline; break; } break; case KeyFrameInterpolationType.Linear: this.keySpline = ForwardAnimationEvaluator.linearKeySpline; break; case KeyFrameInterpolationType.Easing: this.easingFunction = this.keyFrameEnumerator.Current.EasingFunction; if (this.easingFunction == null) { this.keySpline = ForwardAnimationEvaluator.linearKeySpline; break; } break; default: this.keySpline = (KeySpline)null; break; } this.curSegmentEndTime = this.keyFrameEnumerator.Current.Time; this.curSegmentEndValue = new double?(MotionPath.GetKeyframeValue(this.keyFrameEnumerator.Current)); } else { this.keySpline = (KeySpline)null; this.curSegmentEndTime = double.PositiveInfinity; this.curSegmentEndValue = new double?(); } } if (this.curSegmentStartValue.HasValue && this.curSegmentEndValue.HasValue) { this.valueInterpolator = (DoubleInterpolator) new LinearDoubleInterpolator(this.curSegmentStartValue.Value, this.curSegmentEndValue.Value); } else { this.valueInterpolator = (DoubleInterpolator)null; } }