public CircleImage()
 {
     WidthRequest         = 60;
     HeightRequest        = 60;
     DownsampleToViewSize = true;
     Transformations.Add(new CircleTransformation());
 }
        /// <summary>Executes the specified action on the transformation.</summary>
        /// <param name="action">An action to execute.</param>
        public TransformationBuilder<TSource, TDestination> Do(Func<TSource, TDestination, TransformationContext, TDestination> action)
        {
            ArgGuard.NotNull(action, nameof(action));

            Transformations.Add(new ActionTransformer<TSource, TDestination>(action));
            return this;
        }
Example #3
0
        internal void FadeOut(int duration, EasingTypes easing = EasingTypes.None, int delay = 0)
        {
            int count = Transformations.Count;

            if (count == 0 && Alpha == 0)
            {
                return;
            }

            lock (SpriteManager.SpriteLock)
                Transformations.RemoveAll(t => t.Type == TransformationType.Fade);

            if (Alpha < float.Epsilon)
            {
                return;
            }

            if (duration == 0)
            {
                Alpha = 0;
                return;
            }

            int startTime = GameBase.GetTime(Clock) + delay;

            Transformation tr =
                new Transformation(TransformationType.Fade, (float)Alpha, 0,
                                   startTime - (int)GameBase.ElapsedMilliseconds,
                                   startTime + duration, easing);

            Transformations.Add(tr);
        }
Example #4
0
        public void FadeTo(float final, int duration, EasingTypes easing = EasingTypes.None)
        {
            if (Transformations.Count == 1)
            {
                Transformation t = Transformations[0];
                if (t.Type == TransformationType.Fade && t.EndFloat == final && t.Time2 - t.Time1 == duration)
                {
                    return;
                }
            }

            lock (SpriteManager.SpriteLock)
                Transformations.RemoveAll(t => t.Type == TransformationType.Fade);

            if (Alpha == final)
            {
                return;
            }

            Transformation tr =
                new Transformation(TransformationType.Fade, (float)Alpha,
                                   (InitialColour.A != 0 ? (float)InitialColour.A / 255 * final : final),
                                   GameBase.GetTime(Clock) - (int)GameBase.ElapsedMilliseconds,
                                   GameBase.GetTime(Clock) + duration);

            tr.Easing = easing;
            Transformations.Add(tr);
        }
Example #5
0
        public void RotateTo(float final, int duration, EasingTypes easing = EasingTypes.None)
        {
            if (Transformations.Count == 1)
            {
                Transformation t = Transformations[0];
                if (t.Type == TransformationType.Rotation && t.EndFloat == final && t.Time2 - t.Time1 == duration)
                {
                    return;
                }
            }

            lock (SpriteManager.SpriteLock)
                Transformations.RemoveAll(t => t.Type == TransformationType.Rotation);

            if (Rotation == final)
            {
                return;
            }

            Transformation tr =
                new Transformation(TransformationType.Rotation, (float)Rotation, final,
                                   GameBase.GetTime(Clock) - (int)GameBase.ElapsedMilliseconds,
                                   GameBase.GetTime(Clock) + duration);

            tr.Easing = easing;
            Transformations.Add(tr);
        }
 /// <summary>Add the transformation step to the transformation chain.</summary>
 public TransformationBuilder<TSource, TDestination> Apply(AbstractTransformation<TSource, TDestination> transformation)
 {
     ArgGuard.NotNull(transformation, nameof(transformation));
    
     Transformations.Add(transformation);
     return this;
 }
        private void MethodAddButton_Click(object sender, EventArgs e)
        {
            var transform = new AdditionalMethods.StringTransformation();

            if (DescriptionUpdateOptions.SelectedItem.ToString().Equals("Append"))
            {
                transform.Method       = AdditionalMethods.StringTransformation.TransformationMethod.Append;
                transform.PrimaryValue = PrimaryValueBox.Text;
            }
            else if (DescriptionUpdateOptions.SelectedItem.ToString().Equals("Prepend"))
            {
                transform.Method       = AdditionalMethods.StringTransformation.TransformationMethod.Prepend;
                transform.PrimaryValue = PrimaryValueBox.Text;
            }
            else if (DescriptionUpdateOptions.SelectedItem.ToString().Equals("Replace"))
            {
                transform.Method         = AdditionalMethods.StringTransformation.TransformationMethod.Replace;
                transform.IgnoreCase     = IgnoreCaseCheck.Checked;
                transform.PrimaryValue   = PrimaryValueBox.Text;
                transform.SecondaryValue = SecondaryValueBox.Text;
            }
            else if (DescriptionUpdateOptions.SelectedItem.ToString().Equals("Remove"))
            {
                transform.Method       = AdditionalMethods.StringTransformation.TransformationMethod.Remove;
                transform.IgnoreCase   = IgnoreCaseCheck.Checked;
                transform.PrimaryValue = PrimaryValueBox.Text;
            }
            Transformations.Add(transform);
            File.WriteAllText(TransformationPath, JsonConvert.SerializeObject(Transformations, Formatting.Indented));
            LogMessage($"Added new {DescriptionUpdateOptions.SelectedItem} Transformation");
            UpdateTransformationsInfo();
        }
Example #8
0
        internal Transformation MoveTo(Vector2 destination, int duration, EasingTypes easing)
        {
            lock (SpriteManager.SpriteLock)
                Transformations.RemoveAll(t => (t.Type & TransformationType.Movement) > 0);

            if (destination == Position)
            {
                return(null);
            }

            if (duration == 0)
            {
                Position = destination;
                return(null);
            }

            Transformation tr =
                new Transformation(Position, destination,
                                   GameBase.GetTime(Clock) - (int)Math.Max(1, GameBase.ElapsedMilliseconds),
                                   GameBase.GetTime(Clock) + duration);

            tr.Easing = easing;
            Transformations.Add(tr);

            return(tr);
        }
        private void OnAddTransformer(object obj)
        {
            if (SelectedTransfomer == null)
            {
                MessageBox.Show(Application.Current.MainWindow, "Please choose a transformer", "Error");
                return;
            }

            var exists = Transformations.FirstOrDefault(t => t.ColumnName == ColumnName && t.TransformerId == SelectedTransfomer.Id);

            if (exists != null)
            {
                return;
            }

            var newTransformation = new TransformationItemViewModel();

            SelectedTransfomer.SetOptions(Options.Select(o => new OptionItem {
                Name = o.Name, Value = o.Value
            }));
            newTransformation.SetTransformation(new ColumnTransformationModel {
                ColumnName       = ColumnName,
                TargetEntityId   = _entityId,
                TargetEntityType = _entityType,
                TransformerId    = SelectedTransfomer.Id
            });
            newTransformation.TransformerName = SelectedTransfomer.Name;
            newTransformation.SetOptions(SelectedTransfomer.Options);
            Transformations.Add(newTransformation);
        }
        /// <summary>Add the specified isolated transformation step to the transformation chain if the specified condition returns true.</summary>
        /// <param name="condition">The condition function that defines whether to apply the specified transformation. It's evaluated in run-time when the
        /// transformation is going.</param>
        /// <param name="transformation">The transformation to apply.</param>
        public TransformationBuilder<TSource, TDestination> IfApplyIsolated(Func<TSource, TDestination, TransformationContext, bool> condition,
            AbstractTransformation<TSource, TDestination> transformation)
        {
            ArgGuard.NotNull(condition, nameof(condition));
            ArgGuard.NotNull(transformation, nameof(transformation));

            Transformations.Add(new ConditionalTransformer<TSource, TDestination>(condition, transformation.Transform, true));
            return this;
        }
 /// <summary>Add the isolated transformation step to the transformation chain.</summary>
 public TransformationBuilder<TSource, TDestination> ApplyIsolated(AbstractTransformation<TSource, TDestination> transformation, bool? keepInitialDestination = null)
 {
     ArgGuard.NotNull(transformation, nameof(transformation));
   
     transformation.IsIsolatedResult = true;
     transformation.KeepInitialDestination = keepInitialDestination ?? !Configuration.IsolateInitialDestination;
     Transformations.Add(transformation);
     return this;
 }
 /// <summary>Applies the transformation <paramref name="action"/> only when <paramref name="condition"/> returns true.</summary>
 /// <param name="condition">The condition to evaluate.</param>
 /// <param name="action">The action to execute when condition is true.</param>
 public TransformationBuilder<TSource, TDestination> IfDo(Func<TSource, TDestination, TransformationContext, bool> condition,
     Func<TSource, TDestination, TransformationContext, TDestination> action)
 {
     ArgGuard.NotNull(condition, nameof(condition));
     ArgGuard.NotNull(action, nameof(action));
   
     Transformations.Add(new ConditionalTransformer<TSource, TDestination>(condition, action));
     return this;
 }
Example #13
0
        public TaskParameter Transform(ITransformation transformation)
        {
            if (transformation == null)
            {
                throw new NullReferenceException("The transformation argument was null.");
            }

            Transformations.Add(transformation);
            return(this);
        }
Example #14
0
        /// <summary>
        /// Sets transformation for image loading task
        /// </summary>
        /// <returns>The TaskParameter instance for chaining the call.</returns>
        /// <param name="transformation">Transformation.</param>
        public TaskParameter Transform(ITransformation transformation)
        {
            if (transformation == null)
            {
                throw new ArgumentNullException(nameof(transformation));
            }

            Transformations.Add(transformation);
            return(this);
        }
Example #15
0
 private void ScanTransformations()
 {
     foreach (var path in Directory.GetFiles(FilesystemPath, "*." + KettleItem.TransformationFileExtension))
     {
         if (!path.EndsWith("#"))
         {
             var name           = Path.GetFileName(path);
             var transformation = new Transformation(this, path);
             Transformations.Add(transformation);
             Repository.AllTransformations.Add(transformation.Key, transformation);
         }
     }
 }
        public Drawable FlashColour(Color4 flashColour, int duration)
        {
            Debug.Assert(transformationDelay == 0, @"FlashColour doesn't support Delay() currently");

            Color4 startValue = Transformations.FindLast(t => t.Type == TransformationType.Colour)?.EndColour ?? Colour;

            Transformations.RemoveAll(t => t.Type == TransformationType.Colour);

            double startTime = Time + transformationDelay;

            Transformations.Add(new Transformation(flashColour, startValue, startTime, startTime + duration));

            return(this);
        }
Example #17
0
        internal Transformation FadeInFromZero(int duration)
        {
            Alpha = 0;

            lock (SpriteManager.SpriteLock)
                Transformations.RemoveAll(t => t.Type == TransformationType.Fade);

            Transformation tr =
                new Transformation(TransformationType.Fade, 0, 1,
                                   GameBase.GetTime(Clock) - (int)GameBase.ElapsedMilliseconds,
                                   GameBase.GetTime(Clock) + duration);

            Transformations.Add(tr);
            return(tr);
        }
        public Transformation FadeInFromZero(double duration)
        {
            if (transformationDelay == 0)
            {
                Alpha = 0;
                Transformations.RemoveAll(t => t.Type == TransformationType.Fade);
            }

            double startTime = Time + transformationDelay;

            Transformation tr = new Transformation(TransformationType.Fade, 0, 1, startTime, startTime + duration);

            Transformations.Add(tr);
            return(tr);
        }
Example #19
0
        internal void MoveToRelative(Vector2 destination, int duration, EasingTypes easing = EasingTypes.None)
        {
            Transformation lastRelative = Transformations.Find(t => t.TagNumeric == 125);

            if (lastRelative != null)
            {
                Position = lastRelative.EndVector;
            }

            lock (SpriteManager.SpriteLock)
                Transformations.RemoveAll(t => (t.Type & TransformationType.Movement) > 0);

            Transformation tr = new Transformation(Position, Position + destination, GameBase.GetTime(Clock), GameBase.GetTime(Clock) + duration)
            {
                Easing     = easing,
                TagNumeric = 125
            };

            Transformations.Add(tr);
        }
        private Drawable transformVectorTo(Vector2 startValue, Vector2 newValue, double duration, EasingTypes easing, TransformationType transform)
        {
            if (transformationDelay == 0)
            {
                Transformations.RemoveAll(t => t.Type == transform);
                if (startValue == newValue)
                {
                    return(this);
                }
            }
            else
            {
                startValue = Transformations.FindLast(t => t.Type == transform)?.EndVector ?? startValue;
            }

            double startTime = Time + transformationDelay;

            Transformations.Add(new Transformation(transform, startValue, newValue, startTime, startTime + duration, easing));

            return(this);
        }
Example #21
0
        internal void BlurTo(int radius, int duration, EasingTypes easing = EasingTypes.None)
        {
            lock (SpriteManager.SpriteLock)
                Transformations.RemoveAll(t => (t.Type & TransformationType.Blur) > 0);

            if (radius == BlurRadius)
            {
                return;
            }

            if (duration == 0)
            {
                BlurRadius = radius;
                return;
            }

            Transformation tr =
                new Transformation(TransformationType.Blur, BlurRadius, radius,
                                   GameBase.GetTime(Clock) - (int)Math.Max(1, GameBase.ElapsedMilliseconds),
                                   GameBase.GetTime(Clock) + duration, easing);

            Transformations.Add(tr);
        }
        public Drawable FadeColour(Color4 newColour, int duration, EasingTypes easing = EasingTypes.None)
        {
            Color4 startValue = Colour;

            if (transformationDelay == 0)
            {
                Transformations.RemoveAll(t => t.Type == TransformationType.Colour);
                if (startValue == newColour)
                {
                    return(this);
                }
            }
            else
            {
                startValue = Transformations.FindLast(t => t.Type == TransformationType.Colour)?.EndColour ?? startValue;
            }

            double startTime = Time + transformationDelay;

            Transformations.Add(new Transformation(startValue, newColour, startTime, startTime + duration, easing));

            return(this);
        }
Example #23
0
        internal void MoveToY(float destination, int duration, EasingTypes easing = EasingTypes.None)
        {
            lock (SpriteManager.SpriteLock)
                Transformations.RemoveAll(t => (t.Type & TransformationType.MovementY) > 0);

            if (destination == Position.Y)
            {
                return;
            }

            if (duration == 0)
            {
                Position.Y = destination;
                return;
            }

            Transformation tr =
                new Transformation(TransformationType.MovementY, Position.Y, destination,
                                   GameBase.GetTime(Clock) - (int)Math.Max(1, GameBase.ElapsedMilliseconds),
                                   GameBase.GetTime(Clock) + duration);

            tr.Easing = easing;
            Transformations.Add(tr);
        }
Example #24
0
        private void HoverStart()
        {
            int time = SpriteManager.GetSpriteTime(this);

            if (HoverEffect != null)
            {
                Transformations.RemoveAll(t => t.NumericalTag == 1);

                Transformation h = HoverEffect.Clone();
                h.StartVector = CurrentPosition;
                switch (HoverEffect.Type)
                {
                case TransformationType.Fade:
                    h.StartFloat = (float)CurrentColour.A / 255;
                    break;

                case TransformationType.Scale:
                    h.StartFloat = CurrentScale;
                    break;

                case TransformationType.Rotation:
                    h.StartFloat = CurrentRotation;
                    break;
                }
                h.StartColour = StartColour;


                int duration = HoverEffect.Duration;
                h.Time1 = time;
                h.Time2 = time + duration;

                h.NumericalTag = 1;

                Transformations.Add(h);
            }
            if (HoverEffects != null)
            {
                Transformations.RemoveAll(t => t.NumericalTag == 1);
                bool first = true;
                foreach (Transformation t in HoverEffects)
                {
                    Transformation h = t.Clone();
                    if (first)
                    {
                        h.StartVector = CurrentPosition;
                        switch (h.Type)
                        {
                        case TransformationType.Fade:
                            h.StartFloat = (float)CurrentColour.A / 255;
                            break;

                        case TransformationType.Scale:
                            h.StartFloat = CurrentScale;
                            break;

                        case TransformationType.Rotation:
                            h.StartFloat = CurrentRotation;
                            break;
                        }
                        h.StartColour = StartColour;
                        first         = false;
                    }
                    h.Time1 += time;
                    h.Time2 += time;

                    h.NumericalTag = 1;

                    Transformations.Add(h);
                }
            }
        }
Example #25
0
 public CircleCachedImage()
 {
     Transformations.Add(new CircleTransformation());
     WidthRequest  = 50;
     HeightRequest = 50;
 }
Example #26
0
        /// <summary>
        /// Save a piece of information to the appropriate package element
        /// </summary>
        /// <typeparam name="T">The type of data to be saved</typeparam>
        /// <param name="dataToSave">The data to be saved</param>
        /// <returns>The saved data</returns>
        public T Save <T>(T dataToSave) where T : CommonObject
        {
            // Get the type of data to be saved
            String typeOfData = typeof(T).ToShortName();

            // Based on the type of data, save it to the correct repository element
            switch (typeOfData)
            {
            case "apidefinition":

                // Get the actual value from the object wrapper
                ApiDefinition apiDefinition = (ApiDefinition)Convert.ChangeType(dataToSave, typeof(ApiDefinition));

                // If the type is not null
                if (apiDefinition != null)
                {
                    // Does this api definition already exist?
                    ApiDefinition existingApiDefinition =
                        (apiDefinition.Id == Guid.Empty) ? null : this.Api(apiDefinition.Id);

                    // No API Definition found?
                    if (existingApiDefinition == null)
                    {
                        // Doesn't exist currently so create a new Id
                        // and assign the object as the "existing" api definition
                        existingApiDefinition    = apiDefinition;
                        existingApiDefinition.Id = Guid.NewGuid();

                        // Add this new api definition to the repository
                        ApiDefinitions.Add(existingApiDefinition);
                    }
                    else
                    {
                        // Assign the values from the item to save
                        existingApiDefinition.Description = apiDefinition.Description;
                        existingApiDefinition.Name        = apiDefinition.Name;
                        existingApiDefinition.LastUpdated = DateTime.Now;

                        // Assign the foreign keys
                        existingApiDefinition.DataConnection   = apiDefinition.DataConnection;
                        existingApiDefinition.DataDefinition   = apiDefinition.DataDefinition;
                        existingApiDefinition.CredentialsLinks = apiDefinition.CredentialsLinks;
                    }

                    // Convert the data back to the return data type (which is actually the same)
                    dataToSave = (T)Convert.ChangeType(existingApiDefinition, typeof(T));
                }

                break;

            case "dataitemdefinition":

                // Get the actual value from the object wrapper
                DataItemDefinition dataItemDefinition = (DataItemDefinition)Convert.ChangeType(dataToSave, typeof(DataItemDefinition));

                // If the type is not null
                if (dataItemDefinition != null)
                {
                    // Does this data definition already exist?
                    DataItemDefinition existingDataItemDefinition =
                        (dataItemDefinition.Id == Guid.Empty) ? null : this.DataDefinition(dataItemDefinition.Id);

                    // No data definition found?
                    if (existingDataItemDefinition == null)
                    {
                        // Doesn't exist currently so create a new Id
                        // and assign the object as the "existing" data definition
                        existingDataItemDefinition    = dataItemDefinition;
                        existingDataItemDefinition.Id = Guid.NewGuid();

                        // Add this new data definition to the repository
                        DataDefinitions.Add(existingDataItemDefinition);
                    }
                    else
                    {
                        // Assign the values from the item to save
                        existingDataItemDefinition.Description    = dataItemDefinition.Description;
                        existingDataItemDefinition.Name           = dataItemDefinition.Name;
                        existingDataItemDefinition.Culture        = dataItemDefinition.Culture;
                        existingDataItemDefinition.EncodingFormat = dataItemDefinition.EncodingFormat;
                        existingDataItemDefinition.LastUpdated    = DateTime.Now;

                        // Assign the lists
                        existingDataItemDefinition.ItemProperties = dataItemDefinition.ItemProperties;
                        existingDataItemDefinition.PropertyBag    = dataItemDefinition.PropertyBag;
                    }

                    // Convert the data back to the return data type (which is actually the same)
                    dataToSave = (T)Convert.ChangeType(existingDataItemDefinition, typeof(T));
                }

                break;

            case "dataconnection":

                // Get the actual value from the object wrapper
                DataConnection connection = (DataConnection)Convert.ChangeType(dataToSave, typeof(DataConnection));

                // If the type is not null
                if (connection != null)
                {
                    // Does this connection already exist?
                    DataConnection existingConnection =
                        (connection.Id == Guid.Empty) ? null : DataConnection(connection.Id);

                    // No connection found?
                    if (existingConnection == null)
                    {
                        // Doesn't exist currently so create a new Id
                        // and assign the object as the "existing" connection
                        existingConnection    = connection;
                        existingConnection.Id = Guid.NewGuid();

                        // Add this new connection to the repository
                        DataConnections.Add(existingConnection);
                    }
                    else
                    {
                        // Assign the values from the item to save
                        existingConnection.ConnectionString = connection.ConnectionString;
                        existingConnection.Description      = connection.Description;
                        existingConnection.Name             = connection.Name;
                        existingConnection.ProviderType     = connection.ProviderType;
                        existingConnection.Credentials      = connection.Credentials;
                        existingConnection.LastUpdated      = DateTime.Now;
                        existingConnection.PropertyBag      = connection.PropertyBag;
                        existingConnection.ObjectName       = connection.ObjectName;
                    }

                    // Convert the data back to the return data type (which is actually the same)
                    dataToSave = (T)Convert.ChangeType(existingConnection, typeof(T));
                }

                break;

            case "transformation":

                // Get the actual value from the object wrapper
                Transformation transformation = (Transformation)Convert.ChangeType(dataToSave, typeof(Transformation));

                // If the type is not null
                if (transformation != null)
                {
                    // Does this transformation already exist?
                    Transformation existingTransformation =
                        (transformation.Id == Guid.Empty) ? null : Transformation(transformation.Id);

                    // No transformation found?
                    if (existingTransformation == null)
                    {
                        // Doesn't exist currently so create a new Id
                        // and assign the object as the "existing" transformation
                        existingTransformation    = transformation;
                        existingTransformation.Id = Guid.NewGuid();

                        // Add this new transformation to the repository
                        Transformations.Add(existingTransformation);
                    }
                    else
                    {
                        // Assign the values from the item to save
                        existingTransformation.Description = transformation.Description;
                        existingTransformation.Name        = transformation.Name;
                        existingTransformation.LastUpdated = DateTime.Now;
                    }

                    // Convert the data back to the return data type (which is actually the same)
                    dataToSave = (T)Convert.ChangeType(existingTransformation, typeof(T));
                }

                break;

            case "credentials":

                // Get the actual value from the object wrapper
                Credentials credentials = (Credentials)Convert.ChangeType(dataToSave, typeof(Credentials));

                // If the type is not null
                if (credentials != null)
                {
                    // Does this set of credentials already exist?
                    Credentials existingCredentials =
                        (credentials.Id == Guid.Empty) ? null : this.Credentials(credentials.Id);

                    // Loop the properties and see if any have not been saved before. If not give them an Id
                    credentials.Properties.ForEach(credential =>
                    {
                        if (credential.Id == null)
                        {
                            credential.Id = Guid.NewGuid();
                        }
                    });

                    // No credentials found?
                    if (existingCredentials == null)
                    {
                        // Doesn't exist currently so create a new Id
                        // and assign the object as the "existing" credentials
                        existingCredentials    = credentials;
                        existingCredentials.Id = Guid.NewGuid();

                        // Add this new credentials to the repository
                        CredentialsStore.Add(existingCredentials);
                    }
                    else
                    {
                        // Assign the values from the item to save
                        existingCredentials.Description = credentials.Description;
                        existingCredentials.Name        = credentials.Name;
                        existingCredentials.LastUpdated = DateTime.Now;

                        // Assign the lists
                        existingCredentials.Properties = credentials.Properties;
                    }

                    // Convert the data back to the return data type (which is actually the same)
                    dataToSave = (T)Convert.ChangeType(existingCredentials, typeof(T));
                }

                break;
            }

            // Make sure as the item is saved to this package that the
            // reference to it is inside the object
            dataToSave.ParentPackage = this;

            // Return the data that was saved
            return(dataToSave);
        }
 public virtual IHateoasLinksBuilder <TResource, TEntity> AddLink(string reference, string routeName, Func <TResource, TEntity, object> routeParametersDelegate)
 {
     Transformations.Add(reference, (resource, entity) => new HateoasLink(UriBuilder.CreateUri(routeName, routeParametersDelegate.Invoke(resource, entity))));
     return(this);
 }