Esempio n. 1
0
 internal ScaleAction(ScaleDirection direction, ScaleType type, string value, TimeSpan cooldown)
 {
     Direction = direction;
     Type      = type;
     Value     = value;
     Cooldown  = cooldown;
 }
Esempio n. 2
0
 public CateScale(ScaleDirection scaleDirection)
     : base(scaleDirection)
 {
     Direction = scaleDirection;
     //_scaleType = ScaleType.Categorical;
     SetDefault();
 }
Esempio n. 3
0
        IEnumerator iCycle(float startDelay, float time)
        {
            yield return(new WaitForSeconds(startDelay));

            scaleTo = scaleTo == ScaleDirection.MinScale ? ScaleDirection.MaxScale : ScaleDirection.MinScale;

            while (true)
            {
                switch (scaleTo)
                {
                case ScaleDirection.MinScale:
                    ScaleToMinScale(scaleFrom == ScaleDirection.StartScale ? Time / 2f : Time);
                    scaleFrom = ScaleDirection.MinScale;
                    scaleTo   = ScaleDirection.MaxScale;
                    break;

                case ScaleDirection.MaxScale:
                    ScaleToMaxScale(scaleFrom == ScaleDirection.StartScale ? Time / 2f : Time);
                    scaleFrom = ScaleDirection.MaxScale;
                    scaleTo   = ScaleDirection.MinScale;
                    break;

                case ScaleDirection.StartScale:
                    ScaleToStartScale(Time / 2f);
                    scaleFrom = ScaleDirection.StartScale;
                    scaleTo   = ScaleDirection.MinScale;
                    break;

                default:
                    break;
                }
                yield return(new WaitForSeconds(time));
            }
        }
Esempio n. 4
0
        private void ScaleScaleableItems(ScaleDirection scaleDirection)
        {
            foreach (var item in this.Items)
            {
                var element = this.ItemContainerGenerator.ContainerFromItem(item);

                if (element is null ||
                    (element is UIElement uiElement && uiElement.Visibility != Visibility.Visible))
                {
                    continue;
                }

                var scalableRibbonControl = element as IScalableRibbonControl;

                if (scalableRibbonControl is null)
                {
                    continue;
                }

                switch (scaleDirection)
                {
                case ScaleDirection.Enlarge:
                    scalableRibbonControl.Enlarge();
                    break;

                case ScaleDirection.Reduce:
                    scalableRibbonControl.Reduce();
                    break;
                }
            }
        }
        internal static ScaleAction DeserializeScaleAction(JsonElement element)
        {
            ScaleDirection    direction = default;
            ScaleType         type      = default;
            Optional <string> value     = default;
            TimeSpan          cooldown  = default;

            foreach (var property in element.EnumerateObject())
            {
                if (property.NameEquals("direction"))
                {
                    direction = property.Value.GetString().ToScaleDirection();
                    continue;
                }
                if (property.NameEquals("type"))
                {
                    type = property.Value.GetString().ToScaleType();
                    continue;
                }
                if (property.NameEquals("value"))
                {
                    value = property.Value.GetString();
                    continue;
                }
                if (property.NameEquals("cooldown"))
                {
                    cooldown = property.Value.GetTimeSpan("P");
                    continue;
                }
            }
            return(new ScaleAction(direction, type, value.Value, cooldown));
        }
Esempio n. 6
0
 /// <summary>
 /// Initializes a new instance of the ScaleAction class.
 /// </summary>
 /// <param name="direction">the scale direction. Whether the scaling
 /// action increases or decreases the number of instances. Possible
 /// values include: 'None', 'Increase', 'Decrease'</param>
 /// <param name="type">the type of action that should occur when the
 /// scale rule fires. Possible values include: 'ChangeCount',
 /// 'PercentChangeCount', 'ExactCount'</param>
 /// <param name="cooldown">the amount of time to wait since the last
 /// scaling action before this action occurs. It must be between 1 week
 /// and 1 minute in ISO 8601 format.</param>
 /// <param name="value">the number of instances that are involved in
 /// the scaling action. This value must be 1 or greater. The default
 /// value is 1.</param>
 public ScaleAction(ScaleDirection direction, ScaleType type, System.TimeSpan cooldown, string value = default(string))
 {
     Direction = direction;
     Type      = type;
     Value     = value;
     Cooldown  = cooldown;
 }
    private void UpdateScale(ScaleDirection direction)
    {
        for (int i = 0; i < countOfWaves; i++)
        {
            _actualScales[i] += (Time.deltaTime * speedOfTransition) * (direction == ScaleDirection.FORWARD ? -1 : 1);

            // reset wave position
            switch (direction)
            {
            case ScaleDirection.FORWARD:
                _actualScales[i] = _actualScales[i] < fromScale ? toScale : _actualScales[i];

                break;

            case ScaleDirection.BACKWARD:
                _actualScales[i] = _actualScales[i] > toScale ? fromScale : _actualScales[i];

                break;
            }

            Vector3 scale = _defaultScale * _actualScales[i] * _cameraDistanceScale;

            _scaleObjects[i].transform.localScale  = scale;
            _scaleStencils[i].transform.localScale = scale;
        }
    }
Esempio n. 8
0
        public void BeginScalingEffect(float targetScale, float duration)
        {
            if (targetScale == Scale)
            {
                return;
            }

            _scaleDirection = ScaleDirection.ScaleUp;

            if (targetScale < Scale)
            {
                _scaleDirection = ScaleDirection.ScaleDown;
            }

            float amount = Scale - targetScale;

            if (amount < 0)
            {
                amount *= -1;
            }

            _scaleChangePerSecond = amount / (duration / 1000.0f);

            _targetScale = targetScale;

            IsScaling = true;
        }
Esempio n. 9
0
 void AdjustScale(ScaleDirection scaleDirection, ScaleTransform scale)
 {
     if (scaleDirection == ScaleDirection.Down)
     {
         if (scale.ScaleX < 1.1)
         {
             scale.ScaleX += 0.05; scale.ScaleY += 0.05;
         }
         else
         {
             timer.Stop();
         }
     }
     else
     {
         if (scale.ScaleX > 1.0)
         {
             scale.ScaleX -= 0.05;
             scale.ScaleY -= 0.05;
         }
         else
         {
             timer.Stop();
         }
     }
 }
Esempio n. 10
0
 ///GENMHASH:65BBBF1ED2099A37B0AAE69EEF27057F:4EA1D3F6E50225A49A99B22221964FC1
 public ScaleRuleImpl WithScaleAction(ScaleDirection direction, ScaleType type, int instanceCountChange, TimeSpan cooldown)
 {
     this.Inner.ScaleAction.Direction = direction;
     this.Inner.ScaleAction.Type      = type;
     this.Inner.ScaleAction.Value     = instanceCountChange.ToString();
     this.Inner.ScaleAction.Cooldown  = cooldown;
     return(this);
 }
 /// <summary>
 /// Basiskonstruktor.
 /// </summary>
 public ScalingEffect()
 {
     endImageScale = 0.0f;
     Direction = ScaleDirection.None;
     ActionType = ScaleActionType.OneWay;
     StartImageScale = 0.0f;
     ScalingPerMillisecond = 0.0f;
 }
Esempio n. 12
0
 public ContScale(ScaleDirection scaleDirection)
     : base(scaleDirection)
 {
     Direction = scaleDirection;
     //_scaleType = ScaleType.Continuous;
     //_scalePrimary = scalePrimary;
     SetDefault();
 }
Esempio n. 13
0
 public Refe(ScaleDirection direction)
     : base()
 {
     if (direction == ScaleDirection.None)
     {
         throw new Exception("請指定 Reference 座標軸");
     }
     _scaleDirection = direction;
     SetDefault();
 }
Esempio n. 14
0
 // reset the object to its original state
 public virtual void reset()
 {
     m_position          = new Vector2(m_initialPosition.X, m_initialPosition.Y);
     m_velocity          = new Vector2(m_initialVelocity.X, m_initialVelocity.Y);
     m_acceleration      = m_initialAcceleration;
     m_rotation          = m_initialRotation;
     m_rotationSpeed     = m_initialRotationSpeed;
     m_rotationDirection = m_initialRotationDirection;
     m_scale             = new Vector2(m_initialScale.X, m_initialScale.Y);
     m_scaleSpeed        = m_initialScaleSpeed;
     m_scaleDirection    = m_initialScaleDirection;
 }
Esempio n. 15
0
        public static void ApplyScaleAnimation(ScaleDirection direction, Storyboard storyBoard, FrameworkElement element, Double from, Double to, TimeSpan duration, TimeSpan beginTime, Boolean applyFromValueInitially)
        {
            if (storyBoard == null)
            {
                storyBoard = new Storyboard();
            }

            if (element.RenderTransform == null || !element.RenderTransform.GetType().Equals(typeof(ScaleTransform)))
            {
                element.RenderTransform = new ScaleTransform();
            }

            if (applyFromValueInitially)
            {
                if (direction == ScaleDirection.ScaleX)
                {
                    (element.RenderTransform as ScaleTransform).ScaleX = from;
                }
                else
                {
                    (element.RenderTransform as ScaleTransform).ScaleY = from;
                }
            }

            DoubleAnimation da = new DoubleAnimation()
            {
                From       = from,
                To         = to,
                Duration   = new Duration(duration),
                BeginTime  = beginTime,
                SpeedRatio = 2
            };

            Transform transform = element.RenderTransform;
            String    property  = (direction == ScaleDirection.ScaleX) ? "(ScaleTransform.ScaleX)" : "(ScaleTransform.ScaleY)";

            Storyboard.SetTarget(da, transform);
            Storyboard.SetTargetProperty(da, new PropertyPath(property));
            Storyboard.SetTargetName(da, (String)element.GetValue(FrameworkElement.NameProperty));

#if WPF
            if (direction == ScaleDirection.ScaleX)
            {
                transform.BeginAnimation(ScaleTransform.ScaleXProperty, da);
            }
            else
            {
                transform.BeginAnimation(ScaleTransform.ScaleYProperty, da);
            }
#endif
            storyBoard.Children.Add(da);
        }
Esempio n. 16
0
        public override int GetHashCode()
        {
            int hashCode = 95415488;

            hashCode = hashCode * -1521134295 + ScaleDirection.GetHashCode();
            hashCode = hashCode * -1521134295 + Scale.GetHashCode();
            hashCode = hashCode * -1521134295 + EqualityComparer <Texture2D> .Default.GetHashCode(texture);

            hashCode = hashCode * -1521134295 + speedBounds.GetHashCode();
            hashCode = hashCode * -1521134295 + scaleBounds.GetHashCode();
            hashCode = hashCode * -1521134295 + speed.GetHashCode();
            return(hashCode);
        }
Esempio n. 17
0
 /// <summary>
 /// Initializes a new instance of the ScaleAction class.
 /// </summary>
 /// <param name="scaleAction">The ScaleAction object</param>
 public ScaleAction(Monitor.Models.ScaleAction scaleAction)
     : base()
 {
     if (scaleAction != null)
     {
         base.Cooldown  = scaleAction.Cooldown;
         base.Direction = scaleAction.Direction;
         base.Type      = scaleAction.Type;
         Value          = scaleAction.Value;
         this.Type      = TransitionHelpers.ConvertNamespace(scaleAction.Type);
         this.Direction = TransitionHelpers.ConvertNamespace(scaleAction.Direction);
     }
 }
        internal static string ToSerializedValue(this ScaleDirection value)
        {
            switch (value)
            {
            case ScaleDirection.None:
                return("None");

            case ScaleDirection.Increase:
                return("Increase");

            case ScaleDirection.Decrease:
                return("Decrease");
            }
            return(null);
        }
Esempio n. 19
0
        private async Task <string> ScaleAsync(dynamic Sku, ScaleDirection scaleDirection)
        {
            int current = Sku.capacity;

            if (scaleDirection == ScaleDirection.Out)
            {
                Sku.capacity += this._scaleOutBy;
            }
            else
            {
                Sku.capacity -= this._scaleInBy;
            }

            OnTraceEvent($"setting currect vmss capacity from {current} to {JsonConvert.SerializeObject(Sku.capacity)}");
            return(await SetVMSSCapacityAsync(Sku));
        }
Esempio n. 20
0
        static int Unscale(int v, ScaleDirection direction)
        {
            IntPtr dc = Functions.GetDC(IntPtr.Zero);

            if (dc != IntPtr.Zero)
            {
                int dpi = Functions.GetDeviceCaps(dc,
                                                  direction == ScaleDirection.X ? DeviceCaps.LogPixelsX : DeviceCaps.LogPixelsY);
                if (dpi > 0)
                {
                    float scale = dpi / 96.0f;
                    v = (int)Math.Round(v / scale);
                }
                Functions.ReleaseDC(IntPtr.Zero, dc);
            }
            return(v);
        }
Esempio n. 21
0
    private void SetWaveTransparency(ScaleDirection direction)
    {
        for (int i = 0; i < countOfWaves; i++)
        {
            if (_actualScales[i] < fromScale + scaleDifferenceToFullTransparency)
            {
                _objectsShaderManagers[i].SetTransparency(GetInterpolatedValueFromRange(fromScale, fromScale + scaleDifferenceToFullTransparency, _actualScales[i]));

                //_stencilShaderManagers[i].SetTransparency(1 - GetInterpolatedValueFromRange(fromScale, fromScale + scaleDifferenceToFullTransparency, _actualScales[i]));
            }
            if (_actualScales[i] > toScale - scaleDifferenceToFullTransparency)
            {
                _objectsShaderManagers[i].SetTransparency(GetInterpolatedValueFromRange(toScale, toScale - scaleDifferenceToFullTransparency, _actualScales[i]));

                //_stencilShaderManagers[i].SetTransparency(1 - GetInterpolatedValueFromRange(toScale, toScale - scaleDifferenceToFullTransparency, _actualScales[i]));
            }
        }
    }
Esempio n. 22
0
        public static void ApplyScaleAnimation(ScaleDirection direction, Storyboard storyBoard, FrameworkElement element, Double from, Double to, TimeSpan duration, TimeSpan beginTime, Boolean applyFromValueInitially)
        {
            if (storyBoard == null)
                storyBoard = new Storyboard();

            if (element.RenderTransform == null || !element.RenderTransform.GetType().Equals(typeof(ScaleTransform)))
                element.RenderTransform = new ScaleTransform();

            if (applyFromValueInitially)
            {
                if (direction == ScaleDirection.ScaleX)
                    (element.RenderTransform as ScaleTransform).ScaleX = from;
                else
                    (element.RenderTransform as ScaleTransform).ScaleY = from;
            }

            DoubleAnimation da = new DoubleAnimation()
            {
                From = from,
                To = to,
                Duration = new Duration(duration),
                BeginTime = beginTime,
                SpeedRatio = 2
            };

            Transform transform = element.RenderTransform;
            String property = (direction == ScaleDirection.ScaleX) ? "(ScaleTransform.ScaleX)" : "(ScaleTransform.ScaleY)";

            Storyboard.SetTarget(da, transform);
            Storyboard.SetTargetProperty(da, new PropertyPath(property));
            Storyboard.SetTargetName(da, (String)element.GetValue(FrameworkElement.NameProperty));

#if WPF
            if(direction == ScaleDirection.ScaleX)
                transform.BeginAnimation(ScaleTransform.ScaleXProperty, da);
            else
                transform.BeginAnimation(ScaleTransform.ScaleYProperty, da);
            
#endif
            storyBoard.Children.Add(da);
        }
Esempio n. 23
0
        public async Task <string> SetVMSSInstanceAsync(string[] instanceIds, ScaleDirection scaleDirection)
        {
            try
            {
                AuthenticationResult authenticationResult = await GetAuthorizationHeaderAsync(_tenantId, _clientId, _clientSecret);

                var token = authenticationResult.CreateAuthorizationHeader();

                using (HttpClient client = new HttpClient())
                {
                    client.BaseAddress = new Uri(_azureArmApiBaseUrl);
                    client.DefaultRequestHeaders.Add("Authorization", token);
                    client.DefaultRequestHeaders
                    .Accept
                    .Add(new MediaTypeWithQualityHeaderValue("application/json"));

                    string vmssVerb = (scaleDirection == ScaleDirection.Out ? ScalesetAction.start.ToString("G") : ScalesetAction.deallocate.ToString("G"));

                    var url     = $"subscriptions/{_subscriptionId}/resourceGroups/{_resourceGroup}/providers/Microsoft.Compute/virtualMachineScaleSets/{_vmssName}/{vmssVerb}?api-version={_vmssApiVersion}";
                    var payload = $"{{instanceIds:{JsonConvert.SerializeObject(instanceIds)}}}";
                    HttpRequestMessage message = new HttpRequestMessage();
                    message.Content = new StringContent(payload, Encoding.UTF8, "application/json");

                    using (HttpResponseMessage response = await client.PostAsync(url, message.Content))
                        using (HttpContent content = response.Content)
                        {
                            if (response.StatusCode != System.Net.HttpStatusCode.OK)
                            {
                                OnTraceEvent(response.StatusCode.ToString());
                            }
                            return(await content.ReadAsStringAsync());
                        }
                }
            }
            catch (Exception ex)
            {
                OnTraceEvent(ex.ToString());
                return(await Task.FromResult <string>(ex.ToString()));
            }
        }
Esempio n. 24
0
        private void UpdateScaling(GameTime gameTime)
        {
            if (_scaleDirection == ScaleDirection.None)
            {
                return;
            }

            Scale += (_scaleChangePerSecond * gameTime.DeltaTime()) * (float)_scaleDirection;

            if (_scaleDirection == ScaleDirection.ScaleUp && Scale >= _targetScale)
            {
                _scaleDirection = ScaleDirection.None;
                Scale           = _targetScale;
                IsScaling       = false;
            }
            else if (_scaleDirection == ScaleDirection.ScaleDown && Scale <= _targetScale)
            {
                _scaleDirection = ScaleDirection.None;
                Scale           = _targetScale;
                IsScaling       = false;
            }
        }
Esempio n. 25
0
 void AdjustScale(ScaleDirection scaleDirection, ScaleTransform scale)
 {
     if (scaleDirection == ScaleDirection.Down)
     {
         if (scale.ScaleX < 1.1)
         {
             scale.ScaleX += 0.05; scale.ScaleY += 0.05;
         }
         else
             timer.Stop();
     }
     else
     {
         if (scale.ScaleX > 1.0)
         {
             scale.ScaleX -= 0.05;
             scale.ScaleY -= 0.05;
         }
         else
             timer.Stop();
     }
 }
Esempio n. 26
0
        public GameObject()
        {
            m_sprite = null;

            m_position            = new Vector2(0, 0);
            m_offset              = new Vector2(0, 0);
            m_velocity            = new Vector2(0, 0);
            m_maximumVelocity     = 1;
            m_acceleration        = 0;
            m_maximumAcceleration = 1;

            m_rotation             = 0;
            m_rotationSpeed        = 0;
            m_maximumRotationSpeed = 1;
            m_rotationDirection    = RotationDirection.None;

            m_size           = new Vector2(0, 0);
            m_scale          = new Vector2(1, 1);
            m_scaleSpeed     = 0;
            m_scaleDirection = ScaleDirection.None;

            updateInitialValues();
        }
Esempio n. 27
0
        public GameObject()
        {
            m_sprite = null;

            m_position = new Vector2(0, 0);
            m_offset = new Vector2(0, 0);
            m_velocity = new Vector2(0, 0);
            m_maximumVelocity = 1;
            m_acceleration = 0;
            m_maximumAcceleration = 1;

            m_rotation = 0;
            m_rotationSpeed = 0;
            m_maximumRotationSpeed = 1;
            m_rotationDirection = RotationDirection.None;

            m_size = new Vector2(0, 0);
            m_scale = new Vector2(1, 1);
            m_scaleSpeed = 0;
            m_scaleDirection = ScaleDirection.None;

            updateInitialValues();
        }
Esempio n. 28
0
 private void img_MouseEnter(object sender, MouseEventArgs e)
 {
     scaleDirection = ScaleDirection.Down;
     timer.Start();
 }
Esempio n. 29
0
    private void DoScaleHandle(ref TrackZone.Zone zone, ScaleDirection direction)
    {
        Vector3 axis = Vector3.zero;

        switch (direction)
        {
        case ScaleDirection.Xp:
            axis = Vector3.right;
            break;

        case ScaleDirection.Xn:
            axis = Vector3.left;
            break;

        case ScaleDirection.Yp:
            axis = Vector3.up;
            break;

        case ScaleDirection.Yn:
            axis = Vector3.down;
            break;

        case ScaleDirection.Zp:
            axis = Vector3.forward;
            break;

        case ScaleDirection.Zn:
            axis = Vector3.back;
            break;
        }
        Vector3 globalAxis = zone.rotationMatrix.MultiplyPoint(axis);

        Vector3 handlePosition = zone.transform.MultiplyPoint(axis / 2);
        float   handleSize     = HandleUtility.GetHandleSize(handlePosition);

        Color originalColor = Handles.color;

        if (Vector3.Dot(globalAxis, handlePosition - SceneView.currentDrawingSceneView.camera.transform.position) > 0)
        {
            Handles.color *= new Color(.25f, .25f, .25f);
        }
        Vector3 newPosition = Handles.Slider(handlePosition, globalAxis, handleSize * .05f, Handles.DotHandleCap, 1);

        Handles.color = originalColor;

        if (newPosition != handlePosition)
        {
            EditorUtility.SetDirty(trackZoneData);
            Undo.RecordObject(trackZoneData, "Scale Zone");

            Vector3 otherSide = zone.transform.MultiplyPoint(-axis / 2);
            float   size      = Vector3.Distance(newPosition, otherSide);
            Vector3 scale     = zone.scale;

            zone.position = Vector3.Lerp(newPosition, otherSide, .5f);
            switch (direction)
            {
            case ScaleDirection.Xp:
            case ScaleDirection.Xn:
                scale.x = size;
                break;

            case ScaleDirection.Yp:
            case ScaleDirection.Yn:
                scale.y = size;
                break;

            case ScaleDirection.Zp:
            case ScaleDirection.Zn:
                scale.z = size;
                break;
            }

            zone.scale = scale;
        }
    }
Esempio n. 30
0
 static int Unscale(int v, ScaleDirection direction)
 {
     IntPtr dc = Functions.GetDC(IntPtr.Zero);
     if (dc != IntPtr.Zero)
     {
         int dpi = Functions.GetDeviceCaps(dc,
             direction == ScaleDirection.X ? DeviceCaps.LogPixelsX : DeviceCaps.LogPixelsY);
         if (dpi > 0)
         {
             float scale = dpi / 96.0f;
             v = (int)Math.Round(v / scale);
         }
         Functions.ReleaseDC(IntPtr.Zero, dc);
     }
     return v;
 }
Esempio n. 31
0
 public static string ToSerialString(this ScaleDirection value) => value switch
 {
Esempio n. 32
0
        /// <param name='resourceId'>
        /// Required. The resource ID.
        /// </param>
        /// <param name='cancellationToken'>
        /// Cancellation token.
        /// </param>
        /// <returns>
        /// A standard service response including an HTTP status code and
        /// request ID.
        /// </returns>
        public async System.Threading.Tasks.Task <Microsoft.WindowsAzure.Management.Monitoring.Autoscale.Models.AutoscaleSettingGetResponse> GetAsync(string resourceId, CancellationToken cancellationToken)
        {
            // Validate
            if (resourceId == null)
            {
                throw new ArgumentNullException("resourceId");
            }

            // Tracing
            bool   shouldTrace  = CloudContext.Configuration.Tracing.IsEnabled;
            string invocationId = null;

            if (shouldTrace)
            {
                invocationId = Tracing.NextInvocationId.ToString();
                Dictionary <string, object> tracingParameters = new Dictionary <string, object>();
                tracingParameters.Add("resourceId", resourceId);
                Tracing.Enter(invocationId, this, "GetAsync", tracingParameters);
            }

            // Construct URL
            string url = "/" + (this.Client.Credentials.SubscriptionId != null ? this.Client.Credentials.SubscriptionId.Trim() : "") + "/services/monitoring/autoscalesettings?";

            url = url + "resourceId=" + Uri.EscapeDataString(resourceId.Trim());
            string baseUrl = this.Client.BaseUri.AbsoluteUri;

            // Trim '/' character from the end of baseUrl and beginning of url.
            if (baseUrl[baseUrl.Length - 1] == '/')
            {
                baseUrl = baseUrl.Substring(0, baseUrl.Length - 1);
            }
            if (url[0] == '/')
            {
                url = url.Substring(1);
            }
            url = baseUrl + "/" + url;
            url = url.Replace(" ", "%20");

            // Create HTTP transport objects
            HttpRequestMessage httpRequest = null;

            try
            {
                httpRequest            = new HttpRequestMessage();
                httpRequest.Method     = HttpMethod.Get;
                httpRequest.RequestUri = new Uri(url);

                // Set Headers
                httpRequest.Headers.Add("Accept", "application/json");
                httpRequest.Headers.Add("x-ms-version", "2013-10-01");

                // Set Credentials
                cancellationToken.ThrowIfCancellationRequested();
                await this.Client.Credentials.ProcessHttpRequestAsync(httpRequest, cancellationToken).ConfigureAwait(false);

                // Send Request
                HttpResponseMessage httpResponse = null;
                try
                {
                    if (shouldTrace)
                    {
                        Tracing.SendRequest(invocationId, httpRequest);
                    }
                    cancellationToken.ThrowIfCancellationRequested();
                    httpResponse = await this.Client.HttpClient.SendAsync(httpRequest, cancellationToken).ConfigureAwait(false);

                    if (shouldTrace)
                    {
                        Tracing.ReceiveResponse(invocationId, httpResponse);
                    }
                    HttpStatusCode statusCode = httpResponse.StatusCode;
                    if (statusCode != HttpStatusCode.OK)
                    {
                        cancellationToken.ThrowIfCancellationRequested();
                        CloudException ex = CloudException.Create(httpRequest, null, httpResponse, await httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false));
                        if (shouldTrace)
                        {
                            Tracing.Error(invocationId, ex);
                        }
                        throw ex;
                    }

                    // Create Result
                    AutoscaleSettingGetResponse result = null;
                    // Deserialize Response
                    cancellationToken.ThrowIfCancellationRequested();
                    string responseContent = await httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false);

                    result = new AutoscaleSettingGetResponse();
                    JToken responseDoc = null;
                    if (string.IsNullOrEmpty(responseContent) == false)
                    {
                        responseDoc = JToken.Parse(responseContent);
                    }

                    if (responseDoc != null && responseDoc.Type != JTokenType.Null)
                    {
                        AutoscaleSetting settingInstance = new AutoscaleSetting();
                        result.Setting = settingInstance;

                        JToken profilesArray = responseDoc["Profiles"];
                        if (profilesArray != null && profilesArray.Type != JTokenType.Null)
                        {
                            foreach (JToken profilesValue in ((JArray)profilesArray))
                            {
                                AutoscaleProfile autoscaleProfileInstance = new AutoscaleProfile();
                                settingInstance.Profiles.Add(autoscaleProfileInstance);

                                JToken nameValue = profilesValue["Name"];
                                if (nameValue != null && nameValue.Type != JTokenType.Null)
                                {
                                    string nameInstance = ((string)nameValue);
                                    autoscaleProfileInstance.Name = nameInstance;
                                }

                                JToken capacityValue = profilesValue["Capacity"];
                                if (capacityValue != null && capacityValue.Type != JTokenType.Null)
                                {
                                    ScaleCapacity capacityInstance = new ScaleCapacity();
                                    autoscaleProfileInstance.Capacity = capacityInstance;

                                    JToken minimumValue = capacityValue["Minimum"];
                                    if (minimumValue != null && minimumValue.Type != JTokenType.Null)
                                    {
                                        string minimumInstance = ((string)minimumValue);
                                        capacityInstance.Minimum = minimumInstance;
                                    }

                                    JToken maximumValue = capacityValue["Maximum"];
                                    if (maximumValue != null && maximumValue.Type != JTokenType.Null)
                                    {
                                        string maximumInstance = ((string)maximumValue);
                                        capacityInstance.Maximum = maximumInstance;
                                    }

                                    JToken defaultValue = capacityValue["Default"];
                                    if (defaultValue != null && defaultValue.Type != JTokenType.Null)
                                    {
                                        string defaultInstance = ((string)defaultValue);
                                        capacityInstance.Default = defaultInstance;
                                    }
                                }

                                JToken rulesArray = profilesValue["Rules"];
                                if (rulesArray != null && rulesArray.Type != JTokenType.Null)
                                {
                                    foreach (JToken rulesValue in ((JArray)rulesArray))
                                    {
                                        ScaleRule scaleRuleInstance = new ScaleRule();
                                        autoscaleProfileInstance.Rules.Add(scaleRuleInstance);

                                        JToken metricTriggerValue = rulesValue["MetricTrigger"];
                                        if (metricTriggerValue != null && metricTriggerValue.Type != JTokenType.Null)
                                        {
                                            MetricTrigger metricTriggerInstance = new MetricTrigger();
                                            scaleRuleInstance.MetricTrigger = metricTriggerInstance;

                                            JToken metricNameValue = metricTriggerValue["MetricName"];
                                            if (metricNameValue != null && metricNameValue.Type != JTokenType.Null)
                                            {
                                                string metricNameInstance = ((string)metricNameValue);
                                                metricTriggerInstance.MetricName = metricNameInstance;
                                            }

                                            JToken metricNamespaceValue = metricTriggerValue["MetricNamespace"];
                                            if (metricNamespaceValue != null && metricNamespaceValue.Type != JTokenType.Null)
                                            {
                                                string metricNamespaceInstance = ((string)metricNamespaceValue);
                                                metricTriggerInstance.MetricNamespace = metricNamespaceInstance;
                                            }

                                            JToken metricSourceValue = metricTriggerValue["MetricSource"];
                                            if (metricSourceValue != null && metricSourceValue.Type != JTokenType.Null)
                                            {
                                                string metricSourceInstance = ((string)metricSourceValue);
                                                metricTriggerInstance.MetricSource = metricSourceInstance;
                                            }

                                            JToken timeGrainValue = metricTriggerValue["TimeGrain"];
                                            if (timeGrainValue != null && timeGrainValue.Type != JTokenType.Null)
                                            {
                                                TimeSpan timeGrainInstance = TypeConversion.From8601TimeSpan(((string)timeGrainValue));
                                                metricTriggerInstance.TimeGrain = timeGrainInstance;
                                            }

                                            JToken statisticValue = metricTriggerValue["Statistic"];
                                            if (statisticValue != null && statisticValue.Type != JTokenType.Null)
                                            {
                                                MetricStatisticType statisticInstance = ((MetricStatisticType)Enum.Parse(typeof(MetricStatisticType), ((string)statisticValue), true));
                                                metricTriggerInstance.Statistic = statisticInstance;
                                            }

                                            JToken timeWindowValue = metricTriggerValue["TimeWindow"];
                                            if (timeWindowValue != null && timeWindowValue.Type != JTokenType.Null)
                                            {
                                                TimeSpan timeWindowInstance = TypeConversion.From8601TimeSpan(((string)timeWindowValue));
                                                metricTriggerInstance.TimeWindow = timeWindowInstance;
                                            }

                                            JToken timeAggregationValue = metricTriggerValue["TimeAggregation"];
                                            if (timeAggregationValue != null && timeAggregationValue.Type != JTokenType.Null)
                                            {
                                                TimeAggregationType timeAggregationInstance = ((TimeAggregationType)Enum.Parse(typeof(TimeAggregationType), ((string)timeAggregationValue), true));
                                                metricTriggerInstance.TimeAggregation = timeAggregationInstance;
                                            }

                                            JToken operatorValue = metricTriggerValue["Operator"];
                                            if (operatorValue != null && operatorValue.Type != JTokenType.Null)
                                            {
                                                ComparisonOperationType operatorInstance = ((ComparisonOperationType)Enum.Parse(typeof(ComparisonOperationType), ((string)operatorValue), true));
                                                metricTriggerInstance.Operator = operatorInstance;
                                            }

                                            JToken thresholdValue = metricTriggerValue["Threshold"];
                                            if (thresholdValue != null && thresholdValue.Type != JTokenType.Null)
                                            {
                                                double thresholdInstance = ((double)thresholdValue);
                                                metricTriggerInstance.Threshold = thresholdInstance;
                                            }
                                        }

                                        JToken scaleActionValue = rulesValue["ScaleAction"];
                                        if (scaleActionValue != null && scaleActionValue.Type != JTokenType.Null)
                                        {
                                            ScaleAction scaleActionInstance = new ScaleAction();
                                            scaleRuleInstance.ScaleAction = scaleActionInstance;

                                            JToken directionValue = scaleActionValue["Direction"];
                                            if (directionValue != null && directionValue.Type != JTokenType.Null)
                                            {
                                                ScaleDirection directionInstance = ((ScaleDirection)Enum.Parse(typeof(ScaleDirection), ((string)directionValue), true));
                                                scaleActionInstance.Direction = directionInstance;
                                            }

                                            JToken typeValue = scaleActionValue["Type"];
                                            if (typeValue != null && typeValue.Type != JTokenType.Null)
                                            {
                                                ScaleType typeInstance = ((ScaleType)Enum.Parse(typeof(ScaleType), ((string)typeValue), true));
                                                scaleActionInstance.Type = typeInstance;
                                            }

                                            JToken valueValue = scaleActionValue["Value"];
                                            if (valueValue != null && valueValue.Type != JTokenType.Null)
                                            {
                                                string valueInstance = ((string)valueValue);
                                                scaleActionInstance.Value = valueInstance;
                                            }

                                            JToken cooldownValue = scaleActionValue["Cooldown"];
                                            if (cooldownValue != null && cooldownValue.Type != JTokenType.Null)
                                            {
                                                TimeSpan cooldownInstance = TypeConversion.From8601TimeSpan(((string)cooldownValue));
                                                scaleActionInstance.Cooldown = cooldownInstance;
                                            }
                                        }
                                    }
                                }

                                JToken fixedDateValue = profilesValue["FixedDate"];
                                if (fixedDateValue != null && fixedDateValue.Type != JTokenType.Null)
                                {
                                    TimeWindow fixedDateInstance = new TimeWindow();
                                    autoscaleProfileInstance.FixedDate = fixedDateInstance;

                                    JToken timeZoneValue = fixedDateValue["TimeZone"];
                                    if (timeZoneValue != null && timeZoneValue.Type != JTokenType.Null)
                                    {
                                        string timeZoneInstance = ((string)timeZoneValue);
                                        fixedDateInstance.TimeZone = timeZoneInstance;
                                    }

                                    JToken startValue = fixedDateValue["Start"];
                                    if (startValue != null && startValue.Type != JTokenType.Null)
                                    {
                                        DateTime startInstance = ((DateTime)startValue);
                                        fixedDateInstance.Start = startInstance;
                                    }

                                    JToken endValue = fixedDateValue["End"];
                                    if (endValue != null && endValue.Type != JTokenType.Null)
                                    {
                                        DateTime endInstance = ((DateTime)endValue);
                                        fixedDateInstance.End = endInstance;
                                    }
                                }

                                JToken recurrenceValue = profilesValue["Recurrence"];
                                if (recurrenceValue != null && recurrenceValue.Type != JTokenType.Null)
                                {
                                    Recurrence recurrenceInstance = new Recurrence();
                                    autoscaleProfileInstance.Recurrence = recurrenceInstance;

                                    JToken frequencyValue = recurrenceValue["Frequency"];
                                    if (frequencyValue != null && frequencyValue.Type != JTokenType.Null)
                                    {
                                        RecurrenceFrequency frequencyInstance = ((RecurrenceFrequency)Enum.Parse(typeof(RecurrenceFrequency), ((string)frequencyValue), true));
                                        recurrenceInstance.Frequency = frequencyInstance;
                                    }

                                    JToken scheduleValue = recurrenceValue["Schedule"];
                                    if (scheduleValue != null && scheduleValue.Type != JTokenType.Null)
                                    {
                                        RecurrentSchedule scheduleInstance = new RecurrentSchedule();
                                        recurrenceInstance.Schedule = scheduleInstance;

                                        JToken timeZoneValue2 = scheduleValue["TimeZone"];
                                        if (timeZoneValue2 != null && timeZoneValue2.Type != JTokenType.Null)
                                        {
                                            string timeZoneInstance2 = ((string)timeZoneValue2);
                                            scheduleInstance.TimeZone = timeZoneInstance2;
                                        }

                                        JToken daysArray = scheduleValue["Days"];
                                        if (daysArray != null && daysArray.Type != JTokenType.Null)
                                        {
                                            foreach (JToken daysValue in ((JArray)daysArray))
                                            {
                                                scheduleInstance.Days.Add(((string)daysValue));
                                            }
                                        }

                                        JToken hoursArray = scheduleValue["Hours"];
                                        if (hoursArray != null && hoursArray.Type != JTokenType.Null)
                                        {
                                            foreach (JToken hoursValue in ((JArray)hoursArray))
                                            {
                                                scheduleInstance.Hours.Add(((int)hoursValue));
                                            }
                                        }

                                        JToken minutesArray = scheduleValue["Minutes"];
                                        if (minutesArray != null && minutesArray.Type != JTokenType.Null)
                                        {
                                            foreach (JToken minutesValue in ((JArray)minutesArray))
                                            {
                                                scheduleInstance.Minutes.Add(((int)minutesValue));
                                            }
                                        }
                                    }
                                }
                            }
                        }

                        JToken enabledValue = responseDoc["Enabled"];
                        if (enabledValue != null && enabledValue.Type != JTokenType.Null)
                        {
                            bool enabledInstance = ((bool)enabledValue);
                            settingInstance.Enabled = enabledInstance;
                        }
                    }

                    result.StatusCode = statusCode;
                    if (httpResponse.Headers.Contains("x-ms-request-id"))
                    {
                        result.RequestId = httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault();
                    }

                    if (shouldTrace)
                    {
                        Tracing.Exit(invocationId, result);
                    }
                    return(result);
                }
                finally
                {
                    if (httpResponse != null)
                    {
                        httpResponse.Dispose();
                    }
                }
            }
            finally
            {
                if (httpRequest != null)
                {
                    httpRequest.Dispose();
                }
            }
        }
Esempio n. 33
0
 public ContSecScale(ScaleDirection scaleDirection)
     : base(scaleDirection)
 {
     Direction = scaleDirection;
     SetDefault();
 }
 public override void RevertEffect(bool active)
 {
     if(Direction == ScaleDirection.Up)
     {
         Direction = ScaleDirection.Down;
         StartImageScale = endImageScale;
         endImageScale = startImageScaleOrigin;
     }
     else if(Direction == ScaleDirection.Down)
     {
         Direction = ScaleDirection.Up;
         StartImageScale = endImageScale;
         endImageScale = endImageScaleOrigin;
     }
     IsActive = active;
 }
Esempio n. 35
0
 private void img_MouseLeave(object sender, MouseEventArgs e)
 {
     scaleDirection = ScaleDirection.Up;
     timer.Start();
 }
Esempio n. 36
0
 private IReadOnlyList<Pitch> CalculatePitches(ScaleDirection direction)
 {
     throw new NotImplementedException();
 }
Esempio n. 37
0
 // change what the values are restored to on a reset
 public virtual void updateInitialValues()
 {
     m_initialPosition = new Vector2(m_position.X, m_position.Y);
     m_initialVelocity = new Vector2(m_velocity.X, m_velocity.Y);
     m_initialAcceleration = m_acceleration;
     m_initialRotation = m_rotation;
     m_initialRotationSpeed = m_rotationSpeed;
     m_initialRotationDirection = m_rotationDirection;
     m_initialScale = new Vector2(m_scale.X, m_scale.Y);
     m_initialScaleSpeed = m_scaleSpeed;
     m_initialScaleDirection = m_scaleDirection;
 }
Esempio n. 38
0
 /// <summary>
 /// Sets the action to be performed when the scale rule will be active.
 /// </summary>
 /// <param name="direction">The scale direction. Whether the scaling action increases or decreases the number of instances. Possible values include: 'None', 'Increase', 'Decrease'.</param>
 /// <param name="type">The type of action that should occur when the scale rule fires. Possible values include: 'ChangeCount', 'PercentChangeCount', 'ExactCount'.</param>
 /// <param name="instanceCountChange">The number of instances that are involved in the scaling action.</param>
 /// <param name="cooldown">The amount of time to wait since the last scaling action before this action occurs. It must be between 1 week and 1 minute in ISO 8601 format.</param>
 /// <return>The next stage of the definition.</return>
 ScaleRule.Definition.IWithAttach ScaleRule.Definition.IWithScaleAction.WithScaleAction(ScaleDirection direction, ScaleType type, int instanceCountChange, TimeSpan cooldown)
 {
     return(this.WithScaleAction(direction, type, instanceCountChange, cooldown));
 }
Esempio n. 39
0
 /// <summary>
 /// Updates the action to be performed when the scale rule will be active.
 /// </summary>
 /// <param name="direction">The scale direction. Whether the scaling action increases or decreases the number of instances. Possible values include: 'None', 'Increase', 'Decrease'.</param>
 /// <param name="type">The type of action that should occur when the scale rule fires. Possible values include: 'ChangeCount', 'PercentChangeCount', 'ExactCount'.</param>
 /// <param name="instanceCountChange">The number of instances that are involved in the scaling action.</param>
 /// <param name="cooldown">The amount of time to wait since the last scaling action before this action occurs. It must be between 1 week and 1 minute in ISO 8601 format.</param>
 /// <return>The next stage of the scale rule update.</return>
 ScaleRule.Update.IUpdate ScaleRule.Update.IUpdate.WithScaleAction(ScaleDirection direction, ScaleType type, int instanceCountChange, TimeSpan cooldown)
 {
     return(this.WithScaleAction(direction, type, instanceCountChange, cooldown));
 }
Esempio n. 40
0
        //protected ScaleDirection _scaleDirection;
        //protected ScalePrimary _scalePrimary;
        //protected ScaleType _scaleType;

        public Scale(ScaleDirection scaleDirection)
        {
            Direction = scaleDirection;
            SetDefault();
        }