public ScaleTransition(IScalable obj, float from, float to, bool queue = true, float speed = 0.05f, Action onBegin = null, Action onEnd = null) : base(obj, queue, speed, onBegin, onEnd) { _target = obj; _from = from; _to = to; _d = (_to - _from) * speed; }
public static void Scale(this IScalable src, double volume) { List <Point> points = new List <Point>(src.Points.Count()); foreach (var point in src.Points) { points.Add(new Point(point.X * volume, point.Y * volume)); } src.Points = points; }
/// <summary> /// 胶杯是否超重 /// </summary> /// <returns></returns> public static Result IsScaleCupOverFlow(this IScalable scale, double CumulativeWeight) { Result ret = Result.OK; if (CumulativeWeight >= scale.Prm.MaxCapacity * scale.Prm.WarningStartPercentage * 0.01d) { AlarmServer.Instance.Fire(scale, AlarmInfoScale.ScaleCupOverFlowAlarm); ret = Result.FAILED; } return(ret); }
/// <summary> /// 通过指定次数读取重量 /// </summary> /// <param name="timeout"></param> /// <param name="value"></param> /// <param name="readTimes"></param> /// <returns></returns> private static int ReadValueByTimes(this IScalable scale, TimeSpan timeout, out double value, ushort readTimes = 3) { value = 0; int replyCode = 0; if (readTimes < 3) { replyCode = 4; } replyCode = scale.Print(timeout, readTimes, out value); return(replyCode); }
public void ApplyChangeVariables(PositionedObject objectToResize, float cursorXChange, float cursorYChange, float xChangeCoef, float yChangeCoef) { //IScalable if (objectToResize is IScalable) { IScalable scalable = (IScalable)objectToResize; //Scale if (scalable.ScaleX + cursorXChange < 0) { scalable.ScaleX = 0; xChangeCoef = 0; } else { scalable.ScaleX += cursorXChange; } if (scalable.ScaleY + cursorYChange < 0) { scalable.ScaleY = 0; yChangeCoef = 0; } else { scalable.ScaleY += cursorYChange; } } else if (objectToResize is ElementRuntime && ((ElementRuntime)objectToResize).AssociatedNamedObjectSave != null && ((ElementRuntime)objectToResize).AssociatedNamedObjectSave.GetIsScalableEntity()) { ElementRuntime currentElement = objectToResize as ElementRuntime; float scaleX = (float)currentElement.AssociatedNamedObjectSave.GetEffectiveValue("ScaleX"); float scaleY = (float)currentElement.AssociatedNamedObjectSave.GetEffectiveValue("ScaleY"); IElement entitySave = currentElement.AssociatedIElement; CustomVariable variable = entitySave.GetCustomVariable("ScaleX").Clone(); variable.DefaultValue = scaleX + cursorXChange; currentElement.AssociatedNamedObjectSave.GetCustomVariable("ScaleX").Value = scaleX + cursorXChange; currentElement.SetCustomVariable(variable); variable = entitySave.GetCustomVariable("ScaleY").Clone(); variable.DefaultValue = scaleY + cursorYChange; currentElement.AssociatedNamedObjectSave.GetCustomVariable("ScaleY").Value = variable.DefaultValue; currentElement.SetCustomVariable(variable); } AdjustPositionsAfterScaling(objectToResize, cursorXChange, cursorYChange, xChangeCoef, yChangeCoef); }
private void ApplyScale(float xChange, float yChange, float scaleXMultiplier, float scaleYMultiplier) { IScalable scalable = SelectedObject as IScalable; if (scalable != null) { float newScaleX = scalable.ScaleX + scaleXMultiplier * xChange; float newScaleY = scalable.ScaleY + scaleYMultiplier * yChange; scalable.ScaleX = Math.Max(0, newScaleX); scalable.ScaleY = Math.Max(0, newScaleY); } }
protected override void CreatePolygonForIScalable(object obj) { base.CreatePolygonForIScalable(obj); IScalable scalable = (IScalable)obj; PositionedObject pObj = (PositionedObject)obj; float scaleX = scalable.ScaleX; float scaleY = scalable.ScaleY; CreateHandles(pObj, scaleX, scaleY); }
private void PerformDraggingObjectControl() { Cursor cursor = GuiManager.Cursor; if (mObjectGrabbed == null || cursor.WindowOver != null) { return; } #region Move if (GuiData.ToolsWindow.MoveButton.IsPressed) { PositionedObjectMover.MouseMoveObject(mObjectGrabbed); } #endregion #region Scale else if (GuiData.ToolsWindow.ScaleButton.IsPressed && mObjectGrabbed is IScalable) { cursor.StaticPosition = true; IScalable asIScalable = mObjectGrabbed as IScalable; asIScalable.ScaleX *= 1 + cursor.XVelocity / 100.0f; asIScalable.ScaleY *= 1 + cursor.YVelocity / 100.0f; } #endregion #region Rotate else if (GuiData.ToolsWindow.RotateButton.IsPressed && mObjectGrabbed is IRotatable) { cursor.StaticPosition = true; IRotatable asiRotatable = mObjectGrabbed as IRotatable; asiRotatable.RotationZ += cursor.YVelocity * SpriteManager.Camera.Z / 100.0f; if (mObjectGrabbed.Parent != null) { mObjectGrabbed.SetRelativeFromAbsolute(); } } #endregion }
bool GetIsCursorOverGrabbedObject() { Cursor cursor = GuiManager.Cursor; if (mSelectedObject is IClickable) { return(((IClickable)mSelectedObject).HasCursorOver(GuiManager.Cursor)); } else if (mSelectedObject is Circle) { return(cursor.IsOn3D(mSelectedObject as Circle)); } else if (mSelectedObject is Polygon) { return(cursor.IsOn3D(mSelectedObject as Polygon)); } else if (mSelectedObject is AxisAlignedRectangle) { return(cursor.IsOn3D(mSelectedObject as AxisAlignedRectangle)); } else if (mSelectedObject is Text) { return(cursor.IsOn3D(mSelectedObject as Text)); } else if (mSelectedObject is Sprite) { return(cursor.IsOn3D(mSelectedObject as Sprite)); } else if (mSelectedObject is SpriteFrame) { return(cursor.IsOn3D(mSelectedObject as SpriteFrame)); } else if (mSelectedObject is IScalable && mSelectedObject is IStaticPositionable) { float cursorWorldX = cursor.WorldXAt(0); float cursorWorldY = cursor.WorldYAt(0); IStaticPositionable positionable = SelectedObject as IStaticPositionable; IScalable scalable = SelectedObject as IScalable; return(cursorWorldX > positionable.X - scalable.ScaleX && cursorWorldX < positionable.X + scalable.ScaleX && cursorWorldY > positionable.Y - scalable.ScaleY && cursorWorldY < positionable.Y + scalable.ScaleY); } return(false); }
public Scale LoadSetting(ScaleSetting scaleSetting) { switch (scaleSetting.Vendor) { case Vendor.Sartorius: this.Scalable = new ScalableSartorius(scaleSetting.EasySerialPort); break; case Vendor.Mettler: this.Scalable = new ScalableMettler(scaleSetting.EasySerialPort); break; case Vendor.Disable: this.Scalable = new ScalebleDisable(scaleSetting.EasySerialPort); break; } return(this); }
public Scale SetScalable(Vendor vendor) { SensorMgr.Instance.Scale.Vendor = vendor; switch (vendor) { case Vendor.Sartorius: this.Scalable = new ScalableSartorius(SensorMgr.Instance.Scale.EasySerialPort); break; case Vendor.Mettler: this.Scalable = new ScalableMettler(SensorMgr.Instance.Scale.EasySerialPort); break; case Vendor.Disable: this.Scalable = new ScalebleDisable(SensorMgr.Instance.Scale.EasySerialPort); break; } return(this); }
public void SetScalableProperties(IScalable scalable) { #region Scale and ScaleVelocity scalable.ScaleY = mEmissionSettings.ScaleY + (float)(mRandom.NextDouble() * mEmissionSettings.ScaleYRange); scalable.ScaleYVelocity = mEmissionSettings.ScaleYVelocity + (float)(mRandom.NextDouble() * mEmissionSettings.ScaleYVelocityRange);; if (mEmissionSettings.MatchScaleXToY) { scalable.ScaleX = scalable.ScaleY; scalable.ScaleXVelocity = scalable.ScaleYVelocity; } else { scalable.ScaleX = mEmissionSettings.ScaleX + (float)(mRandom.NextDouble() * mEmissionSettings.ScaleXRange); scalable.ScaleXVelocity = mEmissionSettings.ScaleXVelocity + (float)(mRandom.NextDouble() * mEmissionSettings.ScaleXVelocityRange); } #endregion }
/// <summary> /// 读取重量 /// </summary> /// <param name="weight"></param> /// <returns></returns> public static int ReadWeight(this IScalable scale, out double weight) { weight = 0; int replyCode = 0; //if (scale.Prm.ReadTimes*(scale.Prm.SingleReadTimeOut+ scale.Prm.SingleReadDelay)>= scale.Prm.StabilityTimeOut*0.9) //{ // AlarmServer.Instance.Fire(scale, AlarmInfoScale.ScalePrmSettingAlarm); // return -1; //} Thread.Sleep(scale.Prm.ReadDelay);//读取延时,为了等待天平进入稳定状态 //TimeSpan startTime = new TimeSpan(DateTime.Now.Ticks); //while (true) //{ // replyCode = scale.ReadValueByTimes(new TimeSpan(0, 0, 0, 0,scale.Prm.SingleReadTimeOut), out weight, (ushort)scale.Prm.ReadTimes); // //停止 // if (replyCode==4) // { // break; // } // if (replyCode == 0)//读取成功 // { // break; // } // TimeSpan endTime = new TimeSpan(DateTime.Now.Ticks); // if (endTime.Subtract(startTime).TotalMilliseconds > scale.Prm.StabilityTimeOut) //稳定读数超时 // { // Logger.DEFAULT.Warn(LogCategory.MANUAL | LogCategory.RUNNING, scale.GetType().Name, "weight reading reaches stability time out"); // AlarmServer.Instance.Fire(scale,AlarmInfoScale.StabilityTimeOutAlarm ); // break; // } //} replyCode = scale.ReadValueByTimes(new TimeSpan(0, 0, 0, 0, scale.Prm.SingleReadTimeOut), out weight, (ushort)scale.Prm.ReadTimes); weight = Math.Round(weight, 3); string msg = string.Format("Current value of scale is {0}", weight); Logger.DEFAULT.Info(LogCategory.MANUAL | LogCategory.RUNNING, scale.GetType().Name, msg); //return GetReplyCode(replyCode); return(replyCode); }
public static void Main() { DiagramObject[] dArray = new DiagramObject[100]; dArray[0] = new DiagramObject(); dArray[1] = new TextObject("Text Dude"); dArray[2] = new TextObject("Text Backup"); // array gets initialized here, with classes that // derive from DiagramObject. Some of them implement // IScalable. foreach (DiagramObject d in dArray) { IScalable scalable = d as IScalable; if (scalable != null) { scalable.ScaleX(0.1F); scalable.ScaleY(10.0F); } } }
private void UpdateScale() { float extraScale = 0; if (mPixelsBetweenOutlineAndObject != 0) { float units = 1 / SpriteManager.Camera.PixelsPerUnitAt(this.Z); extraScale = mPixelsBetweenOutlineAndObject * units; } if (mHighlightedObject is IScalable3D) { } else if (mHighlightedObject is IScalable) { IScalable scalable = mHighlightedObject as IScalable; mHighlightRectangle.ScaleX = scalable.ScaleX + extraScale; mHighlightRectangle.ScaleY = scalable.ScaleY + extraScale; } }
/// <summary> /// 保存参数 /// </summary> /// <returns></returns> public static bool SavePrm(this IScalable scale) { string path = SettingsPath.PathMachine + "\\" + typeof(ScalePrm).Name; return(JsonUtil.Serialize <ScalePrm>(path, scale.Prm)); }
public void SetScale(IScalable scaleToSetFrom) { mScaleX = scaleToSetFrom.ScaleX; ScaleY = scaleToSetFrom.ScaleY; }
public CalibrateDialog Setup(IScalable scale) { this.scale = scale; return(this); }