/// <summary> /// Sets shapeposition enum and resets position. /// </summary> private void SetFromEnum(ShapePosition shapePosition) { if (!IsValid(shapePosition)) throw new ArgumentException(DomSR.InvalidEnumForLeftPosition); _shapePosition = shapePosition; _position = Unit.NullValue; }
/// <summary> /// Initializes a new instance of the LeftPosition class from ShapePosition. /// </summary> private LeftPosition(ShapePosition value) { if (!(value == ShapePosition.Undefined || IsValid(value))) throw new ArgumentException(DomSR.InvalidEnumForLeftPosition); this.shapePosition = value; this.position = Unit.NullValue; this.notNull = (value != ShapePosition.Undefined); }
/// <summary> /// Initializes a new instance of TopPosition from ShapePosition. /// </summary> private TopPosition(ShapePosition value) { if (!(IsValid(value) || value == ShapePosition.Undefined)) throw new ArgumentException(DomSR.InvalidEnumForTopPosition); _shapePosition = value; _position = Unit.NullValue; _notNull = (value != ShapePosition.Undefined); }
/// <summary> /// Initializes a new instance of the LeftPosition class from ShapePosition. /// </summary> private LeftPosition(ShapePosition value) { if (!(value == ShapePosition.Undefined || IsValid(value))) { throw new ArgumentException(DomSR.InvalidEnumForLeftPosition); } _shapePosition = value; _position = Unit.NullValue; _notNull = (value != ShapePosition.Undefined); }
/// <inheritdoc /> public override int GetHashCode() { unchecked // Overflow is fine, just wrap { var hashCode = 41; if (AnnotationPosition != null) { hashCode = hashCode * 59 + AnnotationPosition.GetHashCode(); } if (AnnotationTail != null) { hashCode = hashCode * 59 + AnnotationTail.GetHashCode(); } if (AnnotationText != null) { hashCode = hashCode * 59 + AnnotationText.GetHashCode(); } if (AxisTitleText != null) { hashCode = hashCode * 59 + AxisTitleText.GetHashCode(); } if (ColorbarPosition != null) { hashCode = hashCode * 59 + ColorbarPosition.GetHashCode(); } if (ColorbarTitleText != null) { hashCode = hashCode * 59 + ColorbarTitleText.GetHashCode(); } if (LegendPosition != null) { hashCode = hashCode * 59 + LegendPosition.GetHashCode(); } if (LegendText != null) { hashCode = hashCode * 59 + LegendText.GetHashCode(); } if (ShapePosition != null) { hashCode = hashCode * 59 + ShapePosition.GetHashCode(); } if (TitleText != null) { hashCode = hashCode * 59 + TitleText.GetHashCode(); } return(hashCode); } }
public static IEnumerable <string> CollectTabs(this EditorResult editorResult) { var set = new HashSet <ShapePosition>(); foreach (var editor in editorResult.Editors) { var positionText = editor.Metadata.Position; if (!String.IsNullOrWhiteSpace(positionText)) { var position = ShapePosition.Parse(positionText); set.Add(position); } } return(set.Distinct(new ShapePositionDistinctComparer()).OrderBy(x => x.Position).Select(x => x.Name)); }
/// <summary> /// Renders the shape's Left attribute by setting the \posh, \shpleft and \shpright RTF controls. /// </summary> protected void RenderLeftPosition() { RenderLeftRight(); ShapePosition leftShapePosition = _shape.Left.ShapePosition; string leftValue = ""; switch (leftShapePosition) { case ShapePosition.Left: //WrapFormat.DistanceBottom is used slightly different in the rendering module than in word. //It must be taken into account for the left value. object wrapLeft = GetValueAsIntended("WrapFormat.DistanceLeft"); if (wrapLeft == null || ((Unit)wrapLeft).Point == 0) { leftValue = "1"; } break; case ShapePosition.Center: leftValue = "2"; break; case ShapePosition.Right: //WrapFormat.DistanceBottom is used slightly different in the rendering module than in word. //It must be taken into account for the right value. object wrapRight = GetValueAsIntended("WrapFormat.DistanceRight"); if (wrapRight == null || ((Unit)wrapRight).Point == 0) { leftValue = "3"; } break; } if (leftValue != "" && !RenderInParagraph()) { RenderNameValuePair("posh", leftValue); } }
/// <summary> /// Renders the shape's Left attribute by setting the \posv, \shptop and \shpbottom RTF controls. /// </summary> protected void RenderTopPosition() { RenderTopBottom(); string topValue = ""; ShapePosition topShapePosition = _shape.Top.ShapePosition; switch (topShapePosition) { case ShapePosition.Top: //WrapFormat.DistanceTop is used slightly different in the rendering module than in word. //It must be taken into account for the top value. object wrapTop = GetValueAsIntended("WrapFormat.DistanceTop"); if (wrapTop == null || ((Unit)wrapTop).Point == 0) { topValue = "1"; } break; case ShapePosition.Center: topValue = "2"; break; case ShapePosition.Bottom: //WrapFormat.DistanceBottom is used slightly different in the rendering module than in word. //It must be taken into account for the bottom value. object wrapBottom = GetValueAsIntended("WrapFormat.DistanceBottom"); if (wrapBottom == null || ((Unit)wrapBottom).Point == 0) { topValue = "3"; } break; } if (topValue != "" && !RenderInParagraph()) { RenderNameValuePair("posv", topValue); } }
/// <summary> /// Indicates the given shapePosition is valid for TopPosition. /// </summary> private static bool IsValid(ShapePosition shapePosition) { return(shapePosition == ShapePosition.Bottom || shapePosition == ShapePosition.Top || shapePosition == ShapePosition.Center); }
public MezImage Top(ShapePosition top) { Image.Top = top; return(this); }
/// <summary> /// Indicates the given shapePosition is valid for LeftPosition. /// </summary> private static bool IsValid(ShapePosition shapePosition) { return shapePosition == ShapePosition.Left || shapePosition == ShapePosition.Center || shapePosition == ShapePosition.Right || shapePosition == ShapePosition.Inside || shapePosition == ShapePosition.Outside; }
/// <summary> /// Indicates the given shapePosition is valid for TopPosition. /// </summary> private static bool IsValid(ShapePosition shapePosition) { return shapePosition == ShapePosition.Bottom || shapePosition == ShapePosition.Top || shapePosition == ShapePosition.Center; }
public void Render() { if (!isRunning) { return; } Device device = this.Host.Device; if (device == null) { return; } device.InputAssembler.InputLayout = this.ParticleLayout; device.InputAssembler.PrimitiveTopology = SharpDX.Direct3D.PrimitiveTopology.TriangleStrip; ParticlePass.Apply(); device.InputAssembler.SetVertexBuffers(0, new VertexBufferBinding(this.Particles, 32, 0)); ParticleProjection.Set(new Vector2(Host.Width, Host.Height)); ParticleCamera.Set(new Vector2(0, -PlayerShip.Instance.Position.Y)); device.Draw(ParticleManager.particleList.Count, 0); device.InputAssembler.InputLayout = this.ShapeLayout; device.InputAssembler.PrimitiveTopology = SharpDX.Direct3D.PrimitiveTopology.TriangleStrip; ShapeCamera.Set(new Vector2(0, -PlayerShip.Instance.Position.Y)); ShapeProjection.Set(new Vector2(Host.Width, Host.Height)); foreach (Entity entity in EntityManager.Entities) { device.InputAssembler.SetVertexBuffers(0, entity.Shape.Buffer); ShapeColor.Set(entity.Color); ShapePosition.Set(new Vector3(entity.Position, entity.Orientation)); ShapePass.Apply(); device.Draw(entity.Shape.Vertices.Length * 2 + 2, 0); } if (Math.Abs(Profiles.Current.State.LinesPosition - PlayerShip.Instance.Position.Y) < Height) { device.InputAssembler.InputLayout = this.LineLayout; device.InputAssembler.PrimitiveTopology = SharpDX.Direct3D.PrimitiveTopology.PointList; device.InputAssembler.SetVertexBuffers(0, new VertexBufferBinding(LineBuffer, 8, 0)); LineEffect.GetVariableByName("Step").AsScalar().Set(0.1f); LineEffect.GetVariableByName("Width").AsScalar().Set(2.0f / Width); LineEffect.GetVariableByName("Height").AsScalar().Set(1.0f - Math.Abs(Profiles.Current.State.LinesPosition - PlayerShip.Instance.Position.Y) / Height); LineEffect.GetVariableByName("Color").AsVector().Set(Color.Yellow); Vector4[] disturb = new Vector4[16]; float maxX = 0.05f, maxY = 0.02f; for (int i = 0; i < linesCount; i++) { for (int k = 0; k < 16; k++) { disturb[k] = new Vector4(Rand.NextFloat(-maxX, maxX), Rand.NextFloat(-maxY, maxY), Rand.NextFloat(-maxX, maxX), Rand.NextFloat(-maxY, maxY)); } LineEffect.GetVariableByName("Disturb").AsVector().Set(disturb); LineEffect.GetTechniqueByIndex(0).GetPassByIndex(0).Apply(); device.Draw(1, i); } } }
/// <summary> /// Sets the Position from a Unit. /// </summary> private void SetFromUnit(Unit unit) { this.shapePosition = ShapePosition.Undefined; this.position = unit; }
public static void DefineImage(Section section, string strPath, Unit strWidth, ShapePosition shapePosition, WrapStyle wrapStyle) { Image image = section.AddImage(strPath); image.Width = strWidth; image.Left = shapePosition; image.WrapFormat.Style = wrapStyle; }
/// <summary> /// Aligns the given left and right position so that ShapePosition.Left results in left position = 0. /// </summary> private void AlignHorizontally(ShapePosition shpPos, Unit distanceLeftRight, out Unit leftValue, out Unit rightValue) { double width = GetShapeWidth().Point; leftValue = 0; rightValue = width; Unit leftWrap = (Unit)GetValueOrDefault("WrapFormat.DistanceLeft", (Unit)0); Unit rightWrap = (Unit)GetValueOrDefault("WrapFormat.DistanceRight", (Unit)0); switch (shpPos) { case ShapePosition.Right: //Positioning the shape Outside seems impossible=>Do the best that's possible. case ShapePosition.Outside: leftValue = distanceLeftRight.Point - width - rightWrap; rightValue = distanceLeftRight - rightWrap; break; case ShapePosition.Center: { double centerPos = distanceLeftRight.Point / 2; leftValue = centerPos - width / 2.0; rightValue = centerPos + width / 2.0; } break; case ShapePosition.Left: //Positioning the shape inside seems impossible=>Do the best that's possible. case ShapePosition.Inside: leftValue = leftWrap; rightValue = leftWrap + width; break; } }
/// <summary> /// Initializes a new instance of TopPosition from Unit. /// </summary> private TopPosition(Unit value) { this.shapePosition = ShapePosition.Undefined; this.position = value; this.notNull = !value.IsNull; }
/// <summary> /// Aligns the given top and bottom position so that ShapePosition.Top results in top position = 0. /// </summary> private void AlignVertically(ShapePosition shpPos, Unit distanceTopBottom, out Unit topValue, out Unit bottomValue) { double height = GetShapeHeight().Point; topValue = 0; bottomValue = height; Unit topWrap = (Unit)GetValueOrDefault("WrapFormat.DistanceTop", (Unit)0); Unit bottomWrap = (Unit)GetValueOrDefault("WrapFormat.DistanceBottom", (Unit)0); switch (shpPos) { case ShapePosition.Bottom: topValue = distanceTopBottom - height - bottomWrap; bottomValue = distanceTopBottom - bottomWrap; break; case ShapePosition.Center: { Unit centerPos = distanceTopBottom / 2.0; topValue = centerPos - height / 2.0; bottomValue = centerPos + height / 2.0; } break; case ShapePosition.Top: topValue = topWrap; bottomValue = topWrap + height; break; } }
public MezImage Left(ShapePosition left) { Image.Left = left; return(this); }
/// <inheritdoc /> public bool Equals([AllowNull] Edits other) { if (other == null) { return(false); } if (ReferenceEquals(this, other)) { return(true); } return (( AnnotationPosition == other.AnnotationPosition || AnnotationPosition != null && AnnotationPosition.Equals(other.AnnotationPosition) ) && ( AnnotationTail == other.AnnotationTail || AnnotationTail != null && AnnotationTail.Equals(other.AnnotationTail) ) && ( AnnotationText == other.AnnotationText || AnnotationText != null && AnnotationText.Equals(other.AnnotationText) ) && ( AxisTitleText == other.AxisTitleText || AxisTitleText != null && AxisTitleText.Equals(other.AxisTitleText) ) && ( ColorbarPosition == other.ColorbarPosition || ColorbarPosition != null && ColorbarPosition.Equals(other.ColorbarPosition) ) && ( ColorbarTitleText == other.ColorbarTitleText || ColorbarTitleText != null && ColorbarTitleText.Equals(other.ColorbarTitleText) ) && ( LegendPosition == other.LegendPosition || LegendPosition != null && LegendPosition.Equals(other.LegendPosition) ) && ( LegendText == other.LegendText || LegendText != null && LegendText.Equals(other.LegendText) ) && ( ShapePosition == other.ShapePosition || ShapePosition != null && ShapePosition.Equals(other.ShapePosition) ) && ( TitleText == other.TitleText || TitleText != null && TitleText.Equals(other.TitleText) )); }
public static void DefineImage(Section section, string strPath, Unit strWidth, ShapePosition shapePosition) { Image image = section.AddImage(strPath); image.Width = strWidth; image.Left = shapePosition; }