private static Arr <OxyColorData> GetOxyColorDatas() => typeof(OxyColors) .GetFields(BindingFlags.Public | BindingFlags.Static) .Skip(1) .Select(cd => new { cd.Name, OxyColor = RequireInstanceOf <OxyColor>(cd.GetValue(null)) }) .Select(cd => new OxyColorData(cd.Name, ConverterExtensions.ToBrush(cd.OxyColor), cd.OxyColor)) .ToArr();
public void DrawArea( string title, IEnumerable x1, IEnumerable y1, IEnumerable x2, IEnumerable y2, Models.Graph.Axis.AxisType xAxisType, Models.Graph.Axis.AxisType yAxisType, Color colour, bool showOnLegend) { AreaSeries series = new AreaSeries(); series.Color = ConverterExtensions.ToOxyColor(colour); series.Fill = ConverterExtensions.ToOxyColor(colour); List <DataPoint> points = this.PopulateDataPointSeries(x1, y1, xAxisType, yAxisType); List <DataPoint> points2 = this.PopulateDataPointSeries(x2, y2, xAxisType, yAxisType); if (points != null && points2 != null) { foreach (DataPoint point in points) { series.Points.Add(point); } foreach (DataPoint point in points2) { series.Points2.Add(point); } } series.CanTrackerInterpolatePoints = false; this.plot1.Model.Series.Add(series); }
/// <summary> /// Raises the <see cref="E:System.Windows.Forms.Control.MouseWheel"/> event. /// </summary> /// <param name="e"> /// A <see cref="T:System.Windows.Forms.MouseEventArgs"/> that contains the event data. /// </param> protected override void OnMouseWheel(MouseEventArgs e) { base.OnMouseWheel(e); bool isControlDown = ModifierKeys == Keys.Control; var m = new ZoomStepManipulator(this, e.Delta * 0.001, isControlDown); m.Started(new ManipulationEventArgs(ConverterExtensions.ToScreenPoint(e.Location))); }
public void DrawLineAndMarkers( string title, IEnumerable x, IEnumerable y, Models.Graph.Axis.AxisType xAxisType, Models.Graph.Axis.AxisType yAxisType, Color colour, Models.Graph.Series.LineType lineType, Models.Graph.Series.MarkerType markerType, bool showOnLegend) { if (x != null && y != null) { Utility.LineSeriesWithTracker series = new Utility.LineSeriesWithTracker(); series.OnHoverOverPoint += OnHoverOverPoint; if (showOnLegend) { series.Title = title; } series.Color = ConverterExtensions.ToOxyColor(colour); series.ItemsSource = this.PopulateDataPointSeries(x, y, xAxisType, yAxisType); series.XAxisKey = xAxisType.ToString(); series.YAxisKey = yAxisType.ToString(); series.CanTrackerInterpolatePoints = false; bool filled = false; string oxyMarkerName = markerType.ToString(); if (oxyMarkerName.StartsWith("Filled")) { oxyMarkerName = oxyMarkerName.Remove(0, 6); filled = true; } // Line type. LineStyle oxyLineType; if (Enum.TryParse <LineStyle>(lineType.ToString(), out oxyLineType)) { series.LineStyle = oxyLineType; } // Marker type. MarkerType type; if (Enum.TryParse <MarkerType>(oxyMarkerName, out type)) { series.MarkerType = type; } series.MarkerSize = 7.0; series.MarkerStroke = ConverterExtensions.ToOxyColor(colour); if (filled) { series.MarkerFill = ConverterExtensions.ToOxyColor(colour); series.MarkerStroke = OxyColors.White; } this.plot1.Model.Series.Add(series); } }
/// <summary> /// Creates the mouse wheel event arguments. /// </summary> /// <param name="e">The scroll event args.</param> /// <returns>Mouse event arguments.</returns> private static OxyMouseWheelEventArgs GetMouseWheelEventArgs(Gdk.EventScroll e) { return(new OxyMouseWheelEventArgs { Delta = e.Direction == Gdk.ScrollDirection.Down ? -120 : 120, Position = new ScreenPoint(e.X, e.Y), ModifierKeys = ConverterExtensions.GetModifiers(e.State) }); }
public void DrawText( string text, object x, object y, bool leftAlign, double textRotation, Models.Graph.Axis.AxisType xAxisType, Models.Graph.Axis.AxisType yAxisType, Color colour) { OxyPlot.Annotations.TextAnnotation annotation = new OxyPlot.Annotations.TextAnnotation(); annotation.Text = text; if (leftAlign) { annotation.TextHorizontalAlignment = OxyPlot.HorizontalAlignment.Left; } else { annotation.TextHorizontalAlignment = OxyPlot.HorizontalAlignment.Center; } annotation.TextVerticalAlignment = VerticalAlignment.Top; annotation.Stroke = OxyColors.White; annotation.Font = Font; annotation.TextRotation = textRotation; double xPosition = 0.0; if (x is DateTime) { xPosition = DateTimeAxis.ToDouble(x); } else { xPosition = Convert.ToDouble(x); } double yPosition = 0.0; if ((double)y == double.MinValue) { yPosition = AxisMinimum(yAxisType); annotation.TextVerticalAlignment = VerticalAlignment.Bottom; } else if ((double)y == double.MaxValue) { yPosition = AxisMaximum(yAxisType); } else { yPosition = (double)y; } annotation.TextPosition = new DataPoint(xPosition, yPosition); annotation.TextColor = ConverterExtensions.ToOxyColor(colour); annotation.Text += "\r\n\r\n"; this.plot1.Model.Annotations.Add(annotation); }
/// <summary> /// Creates the mouse wheel event arguments. /// </summary> /// <param name="e">The scroll event args.</param> /// <returns>Mouse event arguments.</returns> private static OxyMouseWheelEventArgs GetMouseWheelEventArgs(Gdk.EventScroll e) { int delta; #if NETSTANDARD2_0 if (e.Direction == Gdk.ScrollDirection.Smooth) { delta = e.DeltaY < 0 ? 120 : -120; } else #endif delta = e.Direction == Gdk.ScrollDirection.Down ? -120 : 120; return(new OxyMouseWheelEventArgs { Delta = delta, Position = new ScreenPoint(e.X, e.Y), ModifierKeys = ConverterExtensions.GetModifiers(e.State) }); }
public void DrawText( string text, double x, double y, Models.Graph.Axis.AxisType xAxisType, Models.Graph.Axis.AxisType yAxisType, Color colour) { TextAnnotation annotation = new TextAnnotation(); annotation.Text = text; annotation.TextHorizontalAlignment = OxyPlot.HorizontalAlignment.Left; annotation.TextVerticalAlignment = VerticalAlignment.Top; annotation.Stroke = OxyColors.White; annotation.TextPosition = new DataPoint(x, y); //annotation.XAxis = this.GetAxis(xAxisType); //annotation.YAxis = this.GetAxis(yAxisType); annotation.TextColor = ConverterExtensions.ToOxyColor(colour); annotation.FontSize = FontSize - 1; this.plot1.Model.Annotations.Add(annotation); }
public void DrawBar( string title, IEnumerable x, IEnumerable y, Models.Graph.Axis.AxisType xAxisType, Models.Graph.Axis.AxisType yAxisType, Color colour, bool showOnLegend) { ColumnXYSeries series = new ColumnXYSeries(); if (showOnLegend) { series.Title = title; } series.FillColor = ConverterExtensions.ToOxyColor(colour); series.StrokeColor = ConverterExtensions.ToOxyColor(colour); series.ItemsSource = this.PopulateDataPointSeries(x, y, xAxisType, yAxisType); series.XAxisKey = xAxisType.ToString(); series.YAxisKey = yAxisType.ToString(); this.plot1.Model.Series.Add(series); }
public void DrawLine( object x1, object y1, object x2, object y2, Models.Graph.LineType type, Models.Graph.LineThicknessType thickness, Color colour) { OxyPlot.Annotations.LineAnnotation annotation = new OxyPlot.Annotations.LineAnnotation(); double x1Position = 0.0; if (x1 is DateTime) { x1Position = DateTimeAxis.ToDouble(x1); } else { x1Position = Convert.ToDouble(x1); } double y1Position = 0.0; if ((double)y1 == double.MinValue) { y1Position = AxisMinimum(Models.Graph.Axis.AxisType.Left); } else if ((double)y1 == double.MaxValue) { y1Position = AxisMaximum(Models.Graph.Axis.AxisType.Left); } else { y1Position = (double)y1; } double x2Position = 0.0; if (x2 is DateTime) { x2Position = DateTimeAxis.ToDouble(x2); } else { x2Position = Convert.ToDouble(x2); } double y2Position = 0.0; if ((double)y2 == double.MinValue) { y2Position = AxisMinimum(Models.Graph.Axis.AxisType.Left); } else if ((double)y2 == double.MaxValue) { y2Position = AxisMaximum(Models.Graph.Axis.AxisType.Left); } else { y2Position = (double)y2; } annotation.X = x1Position; annotation.Y = y1Position; annotation.MinimumX = x1Position; annotation.MinimumY = y1Position; annotation.MaximumX = x2Position; annotation.MaximumY = y2Position; annotation.Type = LineAnnotationType.Vertical; annotation.Color = ConverterExtensions.ToOxyColor(colour); // Line type. //LineStyle oxyLineType; //if (Enum.TryParse<LineStyle>(type.ToString(), out oxyLineType)) // annotation.LineStyle = oxyLineType; // Line thickness if (thickness == LineThicknessType.Thin) { annotation.StrokeThickness = 0.5; } this.plot1.Model.Annotations.Add(annotation); }
/// <summary> /// Creates the manipulation event args. /// </summary> /// <param name="e"> /// The MouseEventArgs instance containing the event data. /// </param> /// <returns> /// A manipulation event args object. /// </returns> ManipulationEventArgs CreateManipulationEventArgs(MouseEventArgs e) { return(new ManipulationEventArgs(ConverterExtensions.ToScreenPoint(e.Location))); }
/// <summary> /// Server only - Tries to remove a body part /// </summary> public void TryRemoveFromBody(bool beingGibbed = false) { bool alreadyBleeding = false; SetRemovedColor(); foreach (var bodyPart in HealthMaster.BodyPartList) { if (bodyPart.BodyPartType == BodyPartType.Chest && alreadyBleeding == false) { bodyPart.IsBleeding = true; alreadyBleeding = true; HealthMaster.ChangeBleedStacks(limbLossBleedingValue); } } DropItemsOnDismemberment(this); var bodyPartUISlot = GetComponent <BodyPartUISlots>(); var dynamicItemStorage = HealthMaster.GetComponent <DynamicItemStorage>(); dynamicItemStorage.Remove(bodyPartUISlot); //Fixes an error where externally bleeding body parts would continue to try bleeding even after their removal. if (IsBleedingExternally) { StopExternalBleeding(); } //this kills the crab if (DeathOnRemoval) { HealthMaster.Death(); } if (gibsEntireBodyOnRemoval && beingGibbed == false) { HealthMaster.Gib(); } if (ContainedIn != null) { if (beingGibbed) { ContainedIn.OrganStorage.ServerTryRemove(gameObject, DroppedAtWorldPositionOrThrowVector: ConverterExtensions.GetRandomRotatedVector2(-0.5f, 0.5f), Throw: true); } else { ContainedIn.OrganStorage.ServerTryRemove(gameObject); } } else { if (beingGibbed) { HealthMaster.OrNull()?.BodyPartStorage.OrNull()?.ServerTryRemove(gameObject, DroppedAtWorldPositionOrThrowVector: ConverterExtensions.GetRandomRotatedVector2(-0.5f, 0.5f), Throw: true); } else { HealthMaster.OrNull()?.BodyPartStorage.OrNull()?.ServerTryRemove(gameObject); } } }