Esempio n. 1
0
        /// <summary>
        /// Add a control and anchor it according to AnchorPreference.  If no suitable anchor can
        /// be found, the control is anchored to this panels inside-top-left.
        /// </summary>
        /// <param name="control"><see cref="Control"/> to add.</param>
        /// <param name="pref">Method used to anchor the control to this panel.</param>
        /// <param name="offset">Offset from this panel.</param>
        public Control Add(Control control, AnchorPreference pref,
                           AnchorAlignment alignment, PositionOffset offset)
        {
            switch (pref)
            {
            case AnchorPreference.Panel:
                control.AnchorTo(this, alignment, offset);
                break;

            case AnchorPreference.Top:
                var t = Children.FindTopControl();
                if (t != null)
                {
                    control.AnchorTo(t, alignment, offset);
                }
                break;

            case AnchorPreference.Bottom:
                var b = Children.FindBottomControl();
                if (b != null)
                {
                    control.AnchorTo(b, alignment, offset);
                }
                break;

            case AnchorPreference.Right:
                var r = Children.FindBottomControl();
                if (r != null)
                {
                    control.AnchorTo(r, alignment, offset);
                }
                break;

            case AnchorPreference.Left:
                var l = Children.FindBottomControl();
                if (l != null)
                {
                    control.AnchorTo(l, alignment, offset);
                }
                break;

            case AnchorPreference.First:
                control.AnchorTo(Children[0], alignment, offset);
                break;

            case AnchorPreference.Last:
                control.AnchorTo(Children[Children.Count - 1], alignment, offset);
                break;

            default:
                break;
            }
            // Fallback: If no control found, anchor to this panel.
            if (control.Anchored == false)
            {
                // TODO: Log Message
                control.AnchorTo(this, AnchorAlignment.Inside_Top_Left, offset);
            }
            return(Add(control));
        }
Esempio n. 2
0
        internal void Show(ref CustomCamera OldCamera, CameraSwitchType cameraSwitchType = CameraSwitchType.Instant)
        {
            if (Camera == null || Camera.Exists() == false)
            {
                Camera = World.CreateCamera(Entity.Position, Entity.Rotation, FieldOfView);

                if (!isVehicle)
                {
                    Camera.AttachTo(Entity, PositionOffset);
                    Camera.PointAt(Entity, PointAtOffset);
                }
                else
                {
                    Camera.AttachToVehicle((Vehicle)Entity, "", PositionOffset, PointAtOffset);
                }
            }

            if (OldCamera == null || OldCamera.Camera == null || OldCamera.Camera.Exists() == false)
            {
                World.RenderingCamera = Camera;
            }
            else
            {
                Camera.IsActive           = true;
                OldCamera.Camera.IsActive = false;

                if (cameraSwitchType == CameraSwitchType.Animated)
                {
                    OldCamera.Camera.InterpTo(Camera, 900, 1, 1);
                }
                else
                {
                    World.RenderingCamera = Camera;
                }
            }

            if (Duration > -1)
            {
                gameTime = Game.GameTime + Duration;
            }
            else
            {
                gameTime = -1;
            }

            if (!Moving)
            {
                return;
            }

            CurrentPositionOffset = PositionOffset;
            CurrentPointAtOffset  = PointAtOffset;
            CurrentFieldOfView    = FieldOfView;

            positionSpeed = 1000 * PositionOffset.DistanceTo(PositionEndOffset) / SwitchDuration;
            pointAtSpeed  = 1000 * PointAtOffset.DistanceTo(PointAtEndOffset) / SwitchDuration;
            fovSpeed      = 1000 * (FieldOfViewEnd - FieldOfView) / SwitchDuration;

            waitTime = Game.GameTime + Wait;
        }
Esempio n. 3
0
        protected DesignRequest CreateDesignFromRandomImageAsync()
        {
            var rand  = new Random();
            var files = Directory.GetFiles("C:\\BFU\\350years\\pngs", "*.png");
            var randomImageFileName = files[rand.Next(files.Length)];

            var design = new DesignRequest
            {
                name  = $"Design created on {DateTime.Now}",
                type  = DesignTypes.dtg,
                sides = new DesignSides
                {
                    front = new DesignSide
                    {
                        artwork    = randomImageFileName,
                        aspect     = 1,
                        resize     = true,
                        dimensions = Dimension.Width(11),
                        position   = new Position
                        {
                            horizontal = "C",
                            offset     = PositionOffset.FromTop(2.5f)
                        }
                    }
                }
            };

            return(design);
        }
Esempio n. 4
0
 public MovementFormationOrder(BaseUnit unitToFollow, PositionOffset offset)
     : this()
 {
     UnitToFollow   = unitToFollow;
     PositionOffset = offset;
     GetActiveWaypoint();
 }
Esempio n. 5
0
 /// <summary>
 /// Anchor this control to another.
 /// </summary>
 /// <param name="target">anchor to</param>
 /// <param name="owner">this object</param>
 /// <param name="alignment">alignment type</param>
 /// <param name="offset">position offset</param>
 public AnchorComponent(IAnchorable target, IAnchorable owner, AnchorAlignment alignment, PositionOffset offset)
 {
     _target   = target;
     _owner    = owner;
     Alignment = alignment;
     Offset    = offset;
     _target.PositionChanged += OnAnchorMoved;
 }
Esempio n. 6
0
 public void setAntennaOffset(PositionOffset offset)
 {
     msclPINVOKE.InertialNode_setAntennaOffset(swigCPtr, PositionOffset.getCPtr(offset));
     if (msclPINVOKE.SWIGPendingException.Pending)
     {
         throw msclPINVOKE.SWIGPendingException.Retrieve();
     }
 }
Esempio n. 7
0
        public MovementFormationOrder(BaseUnit unitToFollow, double rightM, double forwardM, double upM)
            : this()
        {
            UnitToFollow   = unitToFollow;
            PositionOffset = new PositionOffset(rightM, forwardM, upM);

            GetActiveWaypoint();
        }
Esempio n. 8
0
        public void ToString_one_base_duplication()
        {
            var startPosOff = new PositionOffset(7, 0, "7", false);
            var endPosOff   = new PositionOffset(7, 0, "7", false);

            var hgvsc = new HgvscNotation("T", "T", "NM_012232.1", GenomicChange.Duplication, startPosOff, endPosOff, true);

            Assert.Equal("NM_012232.1:c.7dupT", hgvsc.ToString());
        }
Esempio n. 9
0
 void onori(float o)
 {
     transform.localEulerAngles = new Vector3(transform.localEulerAngles.x, transform.localEulerAngles.y, o + OriOffset);
     if (OriPositionOffset)
     {
         transform.localPosition = Position + PositionOffset.RotateZCCW(OriOffset + o);
     }
     Ori = o;
 }
Esempio n. 10
0
 public virtual void OnOriOffset(float ooffset)
 {
     transform.localEulerAngles = new Vector3(0, 0, ooffset + Ori);
     if (OriPositionOffset)
     {
         transform.localPosition = Position + PositionOffset.RotateZCCW(Ori + ooffset);
     }
     OriOffset = ooffset;
 }
Esempio n. 11
0
 public virtual void OnOri(float o)
 {
     transform.localEulerAngles = new Vector3(0, 0, o + OriOffset);
     if (OriPositionOffset)
     {
         transform.localPosition = Position + PositionOffset.RotateZCCW(OriOffset + o);
     }
     Ori = o;
 }
Esempio n. 12
0
 public override void OnOriOffset(float ooffset)
 {
     renderer.material.SetFloat("orioffset", ooffset);
     if (OriPositionOffset)
     {
         transform.localPosition = Position + PositionOffset.RotateZCCW(Ori + ooffset);
     }
     OriOffset = ooffset;
 }
Esempio n. 13
0
 public override void OnOri(float o)
 {
     renderer.material.SetFloat("ori", o);
     if (OriPositionOffset)
     {
         transform.localPosition = Position + PositionOffset.RotateZCCW(OriOffset + o);
     }
     Ori = o;
 }
Esempio n. 14
0
 void onorioffset(float ooffset)
 {
     transform.localEulerAngles = new Vector3(transform.localEulerAngles.x, transform.localEulerAngles.y, ooffset + Ori);
     if (OriPositionOffset)
     {
         transform.localPosition = Position + PositionOffset.RotateZCCW(Ori + ooffset);
     }
     OriOffset = ooffset;
 }
Esempio n. 15
0
        public void ToString_deletion_multiple_base()
        {
            var startPosOff = new PositionOffset(19, 0, "19", false);
            var endPosOff   = new PositionOffset(21, 0, "21", false);

            var hgvsc = new HgvscNotation("TGC", "", "NM_012232.1", GenomicChange.Deletion, startPosOff, endPosOff, true);

            Assert.Equal("NM_012232.1:c.19_21del", hgvsc.ToString());
        }
Esempio n. 16
0
        public void ToString_substitution()
        {
            var startPosOff = new PositionOffset(93, 0, "93", false);
            var endPosOff   = new PositionOffset(93, 0, "93", false);

            var hgvsc = new HgvscNotation("G", "T", "NM_004006.1", GenomicChange.Substitution, startPosOff, endPosOff, true);

            Assert.Equal("NM_004006.1:c.93G>T", hgvsc.ToString());
        }
Esempio n. 17
0
        public void ToString_multi_base_duplication()
        {
            var startPosOff = new PositionOffset(6, 0, "6", false);
            var endPosOff   = new PositionOffset(8, 0, "8", false);

            var hgvsc = new HgvscNotation("TGC", "TGC", "NM_012232.1", GenomicChange.Duplication, startPosOff, endPosOff, true);

            Assert.Equal("NM_012232.1:c.6_8dupTGC", hgvsc.ToString());
        }
Esempio n. 18
0
        public void ToString_insertion()
        {
            var startPosOff = new PositionOffset(5756, 0, "5756", false);
            var endPosOff   = new PositionOffset(5757, 0, "5757", false);

            var hgvsc = new HgvscNotation("", "AGG", "NM_012232.1", GenomicChange.Insertion, startPosOff, endPosOff, true);

            Assert.Equal("NM_012232.1:c.5756_5757insAGG", hgvsc.ToString());
        }
Esempio n. 19
0
        public PositionOffset getAntennaOffset()
        {
            PositionOffset ret = new PositionOffset(msclPINVOKE.InertialNode_getAntennaOffset(swigCPtr), true);

            if (msclPINVOKE.SWIGPendingException.Pending)
            {
                throw msclPINVOKE.SWIGPendingException.Retrieve();
            }
            return(ret);
        }
Esempio n. 20
0
        private void Update(EvaluationContext context)
        {
            Reference.DirtyFlag.Clear();
            LastObjectToWorld = context.ObjectToWorld;

            var fov         = MathUtil.DegreesToRadians(Fov.GetValue(context));
            var aspectRatio = AspectRatio.GetValue(context);

            if (aspectRatio < 0.0001f)
            {
                aspectRatio = (float)context.RequestedResolution.Width / context.RequestedResolution.Height;
            }
            System.Numerics.Vector2 clip = NearFarClip.GetValue(context);
            CameraToClipSpace = Matrix.PerspectiveFovRH(fov, aspectRatio, clip.X, clip.Y);

            var positionValue     = Position.GetValue(context);
            var eye               = new Vector3(positionValue.X, positionValue.Y, positionValue.Z);
            var targetValue       = Target.GetValue(context);
            var target            = new Vector3(targetValue.X, targetValue.Y, targetValue.Z);
            var upValue           = Up.GetValue(context);
            var up                = new Vector3(upValue.X, upValue.Y, upValue.Z);
            var worldToCameraRoot = Matrix.LookAtRH(eye, target, up);

            var rollRotation = Matrix.RotationAxis(new Vector3(0, 0, 1), -(float)Roll.GetValue(context));

            var pOffset = PositionOffset.GetValue(context);
            var additionalTranslation = Matrix.Translation(pOffset.X, pOffset.Y, pOffset.Z);

            var rOffset            = RotationOffset.GetValue(context);
            var additionalRotation = Matrix.RotationYawPitchRoll(MathUtil.DegreesToRadians(rOffset.Y),
                                                                 MathUtil.DegreesToRadians(rOffset.X),
                                                                 MathUtil.DegreesToRadians(rOffset.Z));

            WorldToCamera = worldToCameraRoot * rollRotation * additionalTranslation * additionalRotation;


            if (context.BypassCameras)
            {
                Command.GetValue(context);
                Log.Debug($"Bypassing {SymbolChildId}", SymbolChildId);
                return;
            }

            // Set properties and evaluate sub tree
            var prevWorldToCamera     = context.WorldToCamera;
            var prevCameraToClipSpace = context.CameraToClipSpace;

            context.WorldToCamera     = WorldToCamera;
            context.CameraToClipSpace = CameraToClipSpace;

            Command.GetValue(context);

            context.CameraToClipSpace = prevCameraToClipSpace;
            context.WorldToCamera     = prevWorldToCamera;
        }
Esempio n. 21
0
        void onorioffset(float ooffset)
        {
            var theta = ooffset + Ori;

            renderer.material.SetFloat("_ori", Mathf.Deg2Rad * theta);
            if (OriPositionOffset)
            {
                transform.localPosition = Position + PositionOffset.RotateZCCW(theta);
            }
            OriOffset = ooffset;
        }
Esempio n. 22
0
 public virtual void OnOriPositionOffset(bool opo)
 {
     if (opo)
     {
         transform.localPosition = Position + PositionOffset.RotateZCCW(Ori + OriOffset);
     }
     else
     {
         transform.localPosition = Position + PositionOffset;
     }
     OriPositionOffset = opo;
 }
Esempio n. 23
0
 public void AnchorTo(IAnchorable target, AnchorAlignment alignment, PositionOffset offset)
 {
     if (target.GetHashCode() != GetHashCode())
     {
         RemoveAnchor();
         Anchor   = new AnchorComponent(target, this, alignment, offset);
         Position = Anchor.AnchoredPosition;
         Anchored = true;
         return;
     }
     throw new NotSupportedException("Cannot anchor an object to itself.");
 }
Esempio n. 24
0
 protected override void OnPosition(Vector3 p)
 {
     if (OriPositionOffset)
     {
         transform.localPosition = p + PositionOffset.RotateZCCW(Ori + OriOffset);
         Position = p;
     }
     else
     {
         base.OnPosition(p);
     }
 }
Esempio n. 25
0
 void onoripositionoffset(bool opo)
 {
     if (opo)
     {
         transform.localPosition = Position + PositionOffset.RotateZCCW(Ori + OriOffset);
     }
     else
     {
         transform.localPosition = Position + PositionOffset;
     }
     OriPositionOffset = opo;
 }
Esempio n. 26
0
            /// <summary>
            /// constructor
            /// </summary>
            public HgvsNotation(string referenceBases, string alternateBases, string transcriptId, int start, int end,
                                bool isCoding)
            {
                TranscriptId = transcriptId;

                Start = new PositionOffset(start);
                End   = new PositionOffset(end);

                ReferenceBases = referenceBases ?? "";
                AlternateBases = alternateBases ?? "";

                TranscriptType = isCoding ? CodingType : NonCodingType;
            }
Esempio n. 27
0
        /// <summary>
        /// HGVS aligns changes 3'
        /// e.g. given a ATG/- deletion in C[ATG]ATGT, we want to move to: CATG[ATG]T
        ///      given a   A/- deletion in  TA[A]AAAA, we want to move to:  TAAAAA[A]
        ///      given a  AA/- deletion in  TA[AA]AAA, we want to move to:  TAAAA[AA]
        /// </summary>
        private void SwapEndpoints()
        {
            if (_start.Position <= _end.Position &&
                (_start.Position != _end.Position || _start.Offset <= _end.Offset))
            {
                return;
            }

            var temp = _start;

            _start = _end;
            _end   = temp;
        }
Esempio n. 28
0
        public HgvscNotation(string referenceBases, string alternateBases, string transcriptId, GenomicChange changeType, PositionOffset start, PositionOffset end, bool isCoding)
        {
            _transcriptId = transcriptId;
            _start        = start;
            _end          = end;
            _type         = changeType;

            SwapEndpoints();

            _referenceBases = referenceBases ?? "";
            _alternateBases = alternateBases ?? "";

            _transcriptType = isCoding ? CodingType : NonCodingType;
        }
        /// <summary>
        /// Stops the creature from being able to walk until it has finished moving.
        /// </summary>
        /// <param name="moveOffset"></param>
        public void WalkWait(PositionOffset moveOffset)
        {
            // old:
            // var x = Speed < 1 ? 1000 : (tileSpeed * 1000) / Speed;
            // var y = (GameClient.BeatDuration - 1 + x) / GameClient.BeatDuration;
            // y *= GameClient.BeatDuration;
            // EarliestWalkTime = DateTimeOffset.UtcNow.ToUnixTimeMilliseconds() + y;

            // new:

            // if (!floorChange)
            // {
            //     tileSpeed *= 3;
            // }
            // var currentTileSpeed = IoC.Game.Map[Position].Speed;
            // Position += moveOffset;
            // var destinationTileSpeed = IoC.Game.Map[Position].Speed;
            // //var speed = GetSpeed();
            // var x = currentTileSpeed < 1 ? 1000 : (destinationTileSpeed * 1000) / currentTileSpeed;
            // //var x = speed < 1 ? 1000 : (tileSpeed * 1000) / speed;
            // var y = (GameClient.Beat- 1 + x) / GameClient.Beat;
            // y *= GameClient.Beat;
            // EarliestWalkTime = DateTimeOffset.UtcNow.ToUnixTimeMilliseconds() + y;

            // EarliestWalkTime =
            //     ((GameClient.Beat - 1 + (tileSpeed * 1000) / speed) / GameClient.Beat) * GameClient.Beat +
            //     DateTimeOffset.UtcNow.ToUnixTimeMilliseconds();
            // EarliestWalkTime =
            //     ((GameClient.Beat - 1 + (tileSpeed * 1000) / speed) / GameClient.Beat) * GameClient.Beat +
            //     DateTimeOffset.UtcNow.ToUnixTimeMilliseconds();

            var tileSpeed = IoC.Game.Map[Position].Speed;

            Position += moveOffset;
            ZIndex    = IoC.Game.GetCreatureZIndex(this, Position);

            var speed = GetSpeed();

            EarliestWalkTime =
                ((GameClient.Beat - 1 + (tileSpeed * 1000) / speed) / GameClient.Beat) * GameClient.Beat +
                DateTimeOffset.UtcNow.ToUnixTimeMilliseconds();


            _canWalk = false;
        }
Esempio n. 30
0
        private void Update(EvaluationContext context)
        {
            float fov         = MathUtil.DegreesToRadians(Fov.GetValue(context));
            float aspectRatio = AspectRatio.GetValue(context);

            if (aspectRatio < 0.0001f)
            {
                aspectRatio = (float)context.RequestedResolution.Width / context.RequestedResolution.Height;
            }
            System.Numerics.Vector2 clip = NearFarClip.GetValue(context);
            Matrix cameraToClipSpace     = Matrix.PerspectiveFovRH(fov, aspectRatio, clip.X, clip.Y);

            var     positionValue = Position.GetValue(context);
            Vector3 eye           = new Vector3(positionValue.X, positionValue.Y, positionValue.Z);
            var     targetValue   = Target.GetValue(context);
            Vector3 target        = new Vector3(targetValue.X, targetValue.Y, targetValue.Z);
            var     upValue       = Up.GetValue(context);
            Vector3 up            = new Vector3(upValue.X, upValue.Y, upValue.Z);
            Matrix  worldToCamera = Matrix.LookAtRH(eye, target, up);

            //var worldToCamera = Matrix.LookAtLH(position, target, new Vector3(0, 1, 0));
            var rollRotation = Matrix.RotationAxis(new Vector3(0, 0, 1), -(float)Roll.GetValue(context));

            var pOffset = PositionOffset.GetValue(context);
            var additionalTranslation = Matrix.Translation(pOffset.X, pOffset.Y, pOffset.Z);

            var rOffset            = RotationOffset.GetValue(context);
            var additionalRotation = Matrix.RotationYawPitchRoll(MathUtil.DegreesToRadians(rOffset.Y),
                                                                 MathUtil.DegreesToRadians(rOffset.X),
                                                                 MathUtil.DegreesToRadians(rOffset.Z));


            var worldToCamera2 = worldToCamera * rollRotation * additionalTranslation * additionalRotation;

            var prevWorldToCamera     = context.WorldToCamera;
            var prevCameraToClipSpace = context.CameraToClipSpace;

            context.WorldToCamera     = worldToCamera2;
            context.CameraToClipSpace = cameraToClipSpace;

            Command.GetValue(context);

            context.CameraToClipSpace = prevCameraToClipSpace;
            context.WorldToCamera     = prevWorldToCamera;
        }
Esempio n. 31
0
        /// <summary>
        /// Contains all options to run a portrait command.
        /// </summary>
        /// <param name="useDefaultSettings">Will use stage default times for animation and fade</param>
        public PortraitOptions(bool useDefaultSettings = true)
        {
            character = null;
            replacedCharacter = null;
            portrait = null;
            display = DisplayType.None;
            offset = PositionOffset.None;
            fromPosition = null;
            toPosition = null;
            facing = FacingDirection.None;
            shiftOffset = new Vector2(0, 0);
            move = false;
            shiftIntoPlace = false;
            waitUntilFinished = false;
            onComplete = null;

            // Special values that can be overridden
            fadeDuration = 0.5f;
            moveDuration = 1f;
            this.useDefaultSettings = useDefaultSettings;
        }