private void FlipClick(object sender, RoutedEventArgs e)
 {
     if (mainControl.OriginalGrayscaleImage != null)
     {
         mainControl.ProcessedGrayscaleImage = Flip.Flip_Method(mainControl.OriginalGrayscaleImage);
     }
 }
Esempio n. 2
0
        public CarouselPage(Flip flip)
        {
            InitializeComponent();
            DataContext = TabControl;
            _flip       = flip;
            //ConfigurationManager.AppSettings["Culture"] = "en-US";

            CreateTabs();

            TabControl.NumberOfTabs      = 19;
            TabControl.AnimationDuration = 1000;

            String uri = "../../../../../Slides";

            slides = DirSearch(uri);

            //ManipulationStarted += GridMovementStarting;
            //ManipulationDelta += GridMovementDelta;
            TouchDown += TouchMovementStarting;

            //TabControl.ManipulationStarted += GridMovementStarting;
            //TabControl.ManipulationDelta += GridMovementDelta;

            //TouchMove += DetectMovement;
            TouchMove += CheckGesture;
            //TouchUp += CheckGesture;
            Loaded += OnLoad;
            StartTimer();
        }
Esempio n. 3
0
    void FinishFlip(string Name)
    {
        List <Flip> MatchFlip = new List <Flip>();

        foreach (var VARIABLE in Flips)
        {
            if (VARIABLE.FlipName == Name)
            {
                MatchFlip.Add(VARIABLE);
            }
        }

        foreach (var VARIABLE in MatchFlip)
        {
            VARIABLE.OnFinish();
            Flips.Remove(VARIABLE);
        }

        LastFlip    = null;
        NowFlipName = string.Empty;
        if (Flips.Count <= 0)
        {
            OnFlipsFinish?.Invoke();
        }
    }
Esempio n. 4
0
 private void flipToolStripMenuItem_Click(object sender, EventArgs e)
 {
     using (var form = new Flip(_presenter))
     {
         form.ShowDialog(this);
     }
 }
Esempio n. 5
0
 private void TextBoxControl_KeyDown(object sender, KeyRoutedEventArgs e)
 {
     if (e.Key == Windows.System.VirtualKey.Enter)
     {
         Flip.Focus(FocusState.Programmatic);
     }
 }
Esempio n. 6
0
        public Heightmap(byte[] rawData, Flip flip)
        {
            int numElements = rawData.Length;
            int size        = (int)Mathf.Sqrt(numElements);
            int size2       = size * size;

            // Is this an 8-bit raw image?
            if (size2 == numElements)
            {
                Size = new Vector2Int(size, size);
                m_NormalisedHeights = CalculateHeightData(rawData, 1, ConvertRawDataToInt8, Size);
            }
            else
            {
                numElements /= 2;
                size         = (int)Mathf.Sqrt(numElements);
                size2        = size * size;

                // Is this a 16-bit raw image?
                if (size2 == numElements)
                {
                    Size = new Vector2Int(size, size);
                    m_NormalisedHeights = CalculateHeightData(rawData, 2, ConvertRawDataToInt16, Size);
                }
                else
                {
                    throw new InvalidOperationException("Cannot generate a height-map from non-square data.");
                }
            }

            FlipHeightsInPlace(flip);
        }
Esempio n. 7
0
    private void Start()
    {
        flip        = GetComponent <Flip>();
        tileScanner = GetComponent <GroundTileScanner>();

        StartCoroutine("PatrolTimer");
    }
Esempio n. 8
0
        static void Main(string[] args)
        {
            //kdb.ReceiveTimeout = 1000;

            //kdb c = new kdb("localhost", 5000); c.k(".u.sub[`trade;`MSFT.O`IBM.N]");
            //while (true)
            //{
            //    object l = c.k();
            //    O(n(at(l, 2)));
            //}

            kdb c = new kdb("localhost", 5000);

            kdb.e = System.Text.Encoding.UTF8;

            //O("Unicode " + c.k("`$\"c\"$0x52616e627920426ac3b6726b6c756e64204142"));

            //object[] x = new object[4];
            //x[0] = t();
            //x[1] = "xx";
            //x[2] = (double) 93.5;
            //x[3] = 300;
            //tm();
            //for (int i = 0; i < 1000; ++i) c.k("insert", "trade", x);
            //tm();

            Flip r = td(c.k("select sum price by sym from Prices"));

            O("cols: " + n(r.x));
            O("rows: " + n(r.y[0]));

            c.Close();
        }
Esempio n. 9
0
        private async void ImageRotate_Click(object sender, RoutedEventArgs e)
        {
            PhotoDisplaySupport Item = PhotoCollection[Flip.SelectedIndex];

            if (Flip.ContainerFromItem(Item) is DependencyObject Container && Container.FindChildOfType <ScrollViewer>() is ScrollViewer Viewer)
            {
                Storyboard Story = new Storyboard();

                switch (Item.RotateAngle % 360)
                {
                case 0:
                case 180:
                {
                    DoubleAnimation WidthAnimation = new DoubleAnimation
                    {
                        From     = Flip.ActualWidth,
                        To       = Flip.ActualHeight,
                        Duration = TimeSpan.FromMilliseconds(500),
                        EnableDependentAnimation = true,
                        EasingFunction           = new CircleEase {
                            EasingMode = EasingMode.EaseOut
                        }
                    };

                    Storyboard.SetTarget(WidthAnimation, Viewer);
                    Storyboard.SetTargetProperty(WidthAnimation, "Width");

                    Story.Children.Add(WidthAnimation);

                    await Task.WhenAll(Story.BeginAsync(), Viewer.Rotate(Item.RotateAngle += 90).StartAsync()).ConfigureAwait(true);

                    break;
                }

                case 90:
                case 270:
                {
                    DoubleAnimation HeightAnimation = new DoubleAnimation
                    {
                        From     = Flip.ActualHeight,
                        To       = Flip.ActualWidth,
                        Duration = TimeSpan.FromMilliseconds(500),
                        EnableDependentAnimation = true,
                        EasingFunction           = new CircleEase {
                            EasingMode = EasingMode.EaseOut
                        }
                    };

                    Storyboard.SetTarget(HeightAnimation, Viewer);
                    Storyboard.SetTargetProperty(HeightAnimation, "Width");

                    Story.Children.Add(HeightAnimation);

                    await Task.WhenAll(Story.BeginAsync(), Viewer.Rotate(Item.RotateAngle += 90).StartAsync()).ConfigureAwait(true);

                    break;
                }
                }
            }
        }
Esempio n. 10
0
        public override void Use(Player p, string message, CommandData data)
        {
            if (message.Length == 0)
            {
                Help(p); return;
            }
            if (p.CurrentCopy == null)
            {
                p.Message("You haven't copied anything yet"); return;
            }

            CopyState cState = p.CurrentCopy;

            BlockDefinition[] defs = p.level.CustomBlockDefs;

            foreach (string arg in message.SplitSpaces())
            {
                if (arg.CaselessEq("x"))
                {
                    Flip.MirrorX(cState, defs);
                    p.Message("Flipped copy across the X (east/west) axis.");
                }
                else if (arg.CaselessEq("y") || arg.CaselessEq("u"))
                {
                    Flip.MirrorY(cState, defs);
                    p.Message("Flipped copy across the Y (vertical) axis.");
                }
                else if (arg.CaselessEq("z"))
                {
                    Flip.MirrorZ(cState, defs);
                    p.Message("Flipped copy across the Z (north/south) axis.");
                }
            }
        }
Esempio n. 11
0
        /// <inheritdoc />
        public bool Equals([AllowNull] Tiling other)
        {
            if (other == null)
            {
                return(false);
            }
            if (ReferenceEquals(this, other))
            {
                return(true);
            }

            return
                ((
                     Packing == other.Packing ||
                     Packing != null &&
                     Packing.Equals(other.Packing)
                     ) &&
                 (
                     SquarifyRatio == other.SquarifyRatio ||
                     SquarifyRatio != null &&
                     SquarifyRatio.Equals(other.SquarifyRatio)
                 ) &&
                 (
                     Flip == other.Flip ||
                     Flip != null &&
                     Flip.Equals(other.Flip)
                 ) &&
                 (
                     Pad == other.Pad ||
                     Pad != null &&
                     Pad.Equals(other.Pad)
                 ));
        }
        private static Flip createFlipFromLines(Queue <string> lines)
        {
            Flip f = new Flip();

            string tmp = lines.Dequeue();

            // parse the first element, the username and timestamp
            f.userRawTimeStamp = tmp.Substring(0, 20);
            f.user             = tmp.Substring(21);

            // parse the flip request
            tmp = lines.Dequeue();
            f.flipRequestIsHeads = tmp.Contains("heads");
            f.amount             = int.Parse(tmp.Substring(12));

            // parse the bot answer timestamp
            tmp = lines.Dequeue();
            f.botRawTimeStamp = tmp.Substring(0, 20);

            // parse the flip response
            tmp = lines.Dequeue();
            f.flipResponseIsHeads = tmp.Contains("heads");

            return(f);
        }
Esempio n. 13
0
 public PageSend(Flip flip)
 {
     feed = new FeedBackRepository();
     InitializeComponent();
     //DisableWPFTabletSupport();
     _flip = flip;
 }
Esempio n. 14
0
 public Color[] GetPixels(Flip flip)
 {
     if (!Pixels.ContainsKey(flip))
     {
         if (!Pixels.ContainsKey(Flip.None))
         {
             int w = (int)rect.width;
             int h = (int)rect.height;
             int x = (int)rect.x;
             int y = (int)rect.y;
             Pixels[Flip.None] = texture.GetPixels(x, y, w, h);
         }
         if (flip != Flip.None)
         {
             int     w     = (int)rect.width;
             int     h     = (int)rect.height;
             bool    flipX = flip.HasFlag(Flip.Horizontal);
             bool    flipY = flip.HasFlag(Flip.Vertical);
             Color[] pix   = Pixels[Flip.None];
             Color[] tar   = new Color[pix.Length];
             for (int j = 0; j < h; j++)
             {
                 for (int k = 0; k < w; k++)
                 {
                     int tileY = flipY ? (h - 1 - j) : j;
                     int tileX = flipX ? (w - 1 - k) : k;
                     tar[j * w + k] = pix[tileY * w + tileX];
                 }
             }
             Pixels[flip] = tar;
         }
     }
     return(Pixels[flip]);
 }
Esempio n. 15
0
 public void Draw(Rect dstRect, double angle = 0.0, Flip flip = Flip.NONE)
 {
     SDL_SetTextureBlendMode(TexturePtr, (uint)BlendMode);
     SDL_SetTextureAlphaMod(TexturePtr, Color.A);
     SDL_SetTextureColorMod(TexturePtr, Color.R, Color.G, Color.B);
     SDL_RenderCopyEx(Graphics.RendererPtr, TexturePtr, IntPtr.Zero, ref dstRect, angle, IntPtr.Zero, (uint)flip);
 }
Esempio n. 16
0
File: Idle.cs Progetto: eriksk/LD33
        public override void Update()
        {
            if (Input.FirePrimary)
            {
                Set(_attackType);
                return;
            }


            if (Input.Jump)
            {
                Set <Jump>();
                return;
            }

            if (Input.Left)
            {
                Movement.MoveLeft();
                Flip.FlipLeft();
            }
            else if (Input.Right)
            {
                Movement.MoveRight();
                Flip.FlipRight();
            }
            else
            {
                Movement.Stop();
                Set <Idle>();
                return;
            }

            base.Update();
        }
        private List <DataObject> RequestTrade(HistoricalDataRequest request)
        {
            string query_str = string.Format("select from (select datetime, sym, price, size:{{first[x] -': x}} volume, openint from `volume xasc select from `trade where sym = `$\"{0}\") where size >0", request.Instrument.GetSymbol(base.id));

            Log.Info(query_str);
            Flip flip       = (Flip)c.k(query_str);
            int  nRows      = c.n(flip.y[0]); // flip.y is an array of columns. Get the number of rows from the first column.
            int  nColumns   = c.n(flip.x);
            var  y_datetime = (DateTime[])flip.y[0];
            var  y_sym      = (string[])flip.y[1];
            var  y_price    = (double[])flip.y[2];
            var  y_size     = (long[])flip.y[3];
            var  y_openint  = (long[])flip.y[4];


            var ts = new List <DataObject>();

            for (int i = 0; i < nRows; ++i)
            {
                var t = new Trade()
                {
                    ProviderId   = base.id,
                    InstrumentId = request.Instrument.Id,
                    DateTime     = y_datetime[i],
                    Price        = y_price[i],
                    Size         = (int)y_size[i],
                };
                ts.Add(t);
            }

            return(ts);
        }
Esempio n. 18
0
        public override void Use(Player p, string message)
        {
            if (message == "")
            {
                message = "y";
            }
            if (p.CopyBuffer == null)
            {
                Player.Message(p, "You haven't copied anything yet"); return;
            }
            string opt = message.ToLower();

            // Mirroring
            if (opt == "mirrorx" || opt == "mirror x")
            {
                Flip.MirrorX(p.CopyBuffer);
                Player.Message(p, "Flipped copy across the X (east/west) axis.");
            }
            else if (opt == "mirrory" || opt == "mirror y" || opt == "u")
            {
                Flip.MirrorY(p.CopyBuffer);
                Player.Message(p, "Flipped copy across the Y (vertical) axis.");
            }
            else if (opt == "mirrorz" || opt == "mirror z" || opt == "m")
            {
                Flip.MirrorZ(p.CopyBuffer);
                Player.Message(p, "Flipped copy across the Z (north/south) axis.");
            }
            else
            {
                string[] args  = opt.Split(' ');
                char     axis  = 'Y';
                int      angle = 90;
                if (!Handle(ref axis, ref angle, args[0]))
                {
                    Help(p); return;
                }
                if (args.Length > 1 && !Handle(ref axis, ref angle, args[1]))
                {
                    Help(p); return;
                }

                if (angle == 0)
                {
                }
                else if (axis == 'X')
                {
                    p.CopyBuffer = Flip.RotateX(p.CopyBuffer, angle);
                }
                else if (axis == 'Y')
                {
                    p.CopyBuffer = Flip.RotateY(p.CopyBuffer, angle);
                }
                else if (axis == 'Z')
                {
                    p.CopyBuffer = Flip.RotateZ(p.CopyBuffer, angle);
                }
                Player.Message(p, "Rotated copy {0} degrees around the {1} axis", angle, axis);
            }
        }
 protected virtual void Start()
 {
     unit        = GetComponent <Unit>();
     flip        = GetComponent <Flip>();
     tileScanner = GetComponent <GroundTileScanner>();
     player      = FindObjectOfType <PlayerStateController>().gameObject;
 }
Esempio n. 20
0
        public void FlipHeightsInPlace(Flip flip)
        {
            switch (flip)
            {
            case Flip.None:
            {
                break;
            }

            case Flip.Horizontal:
            {
                FlipHeightsInPlaceHorizontally();
                break;
            }

            case Flip.Vertical:
            {
                FlipHeightsInPlaceVertically();
                break;
            }

            default:
            {
                throw new ArgumentOutOfRangeException(nameof(flip), flip, null);
            }
            }             // End of switch.
        }
Esempio n. 21
0
        static void Encode(BinaryWriter writer, Flip o)
        {
            EncodeID(writer, typeof(Flip));

            writer.Write((int)o.Mode);
            writer.Write(o.Bypass);
        }
    public void Move(float move, bool crouch, bool jump)
    {
        // Move the character
        GetComponent <Rigidbody2D>().velocity = new Vector2(move * maxSpeed, GetComponent <Rigidbody2D>().velocity.y);

        // If the input is moving the player right and the player is facing left...
        if (move > 0 && !facingRight)
        {
            // ... flip the player.
            facingRight = Flip.HorizontalFlip(transform, facingRight);
        }
        // Otherwise if the input is moving the player left and the player is facing right...
        else if (move < 0 && facingRight)
        {
            // ... flip the player.
            facingRight = Flip.HorizontalFlip(transform, facingRight);
        }


        // If the player should jump...
        if (jump)
        {
            // Add a vertical force to the player.

            GetComponent <Rigidbody2D>().AddForce(new Vector2(0f, jumpForce));
        }
    }
Esempio n. 23
0
        public override int GetHashCode()
        {
            unchecked // Overflow is fine, just wrap
            {
                int hashCode = 41;

                if (Packing != null)
                {
                    hashCode = hashCode * 59 + Packing.GetHashCode();
                }

                if (SquarifyRatio != null)
                {
                    hashCode = hashCode * 59 + SquarifyRatio.GetHashCode();
                }

                if (Flip != null)
                {
                    hashCode = hashCode * 59 + Flip.GetHashCode();
                }

                if (Pad != null)
                {
                    hashCode = hashCode * 59 + Pad.GetHashCode();
                }

                return(hashCode);
            }
        }
Esempio n. 24
0
        public static void AddTransforms(SvgGroup group, Flip flip)
        {
            if (group.Bounds != default)
            {
                System.Drawing.RectangleF bounds = group.Bounds;

                switch (flip)
                {
                case Flip.PN:     //(1,-1,1) Vertical
                    group.Transforms = new SvgTransformCollection();
                    group.Transforms.Add(new SvgTranslate(0, 2 * bounds.Y + bounds.Height));
                    group.Transforms.Add(new SvgScale(1, -1));
                    break;

                case Flip.NN:     //(-1,-1,1) V and H, same as rotate 180°
                    group.Transforms = new SvgTransformCollection();
                    group.Transforms.Add(new SvgTranslate(2 * bounds.X + bounds.Width, 2 * bounds.Y + bounds.Height));
                    group.Transforms.Add(new SvgScale(-1, -1));
                    break;

                case Flip.NP:     //(-1,1,1) Horizontal
                    group.Transforms = new SvgTransformCollection();
                    group.Transforms.Add(new SvgTranslate(2 * bounds.X + bounds.Width));
                    group.Transforms.Add(new SvgScale(-1, 1));
                    break;

                case Flip.None:
                case Flip.PP:
                default:
                    break;
                }
            }
        }
Esempio n. 25
0
        // Draw a scaled bitmap region
        public void DrawScaledBitmapRegion(Bitmap bmp, int sx, int sy, int sw, int sh,
                                           float dx, float dy, float dw, float dh,
                                           Flip flip = Flip.None)
        {
            baseEffects = SpriteEffects.None;

            // Check flipping
            if (((int)flip & (int)Flip.Horizontal) != 0)
            {
                baseEffects = baseEffects | SpriteEffects.FlipHorizontally;
            }
            if (((int)flip & (int)Flip.Vertical) != 0)
            {
                baseEffects = baseEffects | SpriteEffects.FlipVertically;
            }

            if (autoBeginEnd)
            {
                baseBatch.Begin(SpriteSortMode.Deferred);
            }

            // Draw
            baseBatch.Draw(bmp.GetTexture(),
                           new Rectangle((int)dx, (int)dy, (int)dw, (int)dh),
                           new Rectangle(sx, sy, sw, sh),
                           (new Color(globalColor.X, globalColor.Y, globalColor.Z))
                           * globalColor.W, 0.0f, new Vector2(),
                           baseEffects, 0);

            if (autoBeginEnd)
            {
                baseBatch.End();
            }
        }
Esempio n. 26
0
        public override void Use(Player p, string message, CommandData data)
        {
            if (message.Length == 0)
            {
                message = "y";
            }
            if (p.CurrentCopy == null)
            {
                p.Message("You haven't copied anything yet"); return;
            }

            CopyState cState = p.CurrentCopy;
            string    opt    = message.ToLower();

            BlockDefinition[] defs = p.level.CustomBlockDefs;

            // /Mirror used to be part of spin
            if (opt.CaselessStarts("mirror"))
            {
                p.Message("&T/Spin {0} &Sis deprecated. Use &T/Mirror &Sinstead", opt);
                return;
            }

            string[] args  = opt.SplitSpaces();
            char     axis  = 'Y';
            int      angle = 90;

            if (!Handle(ref axis, ref angle, args[0]))
            {
                Help(p); return;
            }
            if (args.Length > 1 && !Handle(ref axis, ref angle, args[1]))
            {
                Help(p); return;
            }

            CopyState newState = cState;

            if (angle == 0)
            {
            }
            else if (axis == 'X')
            {
                newState = Flip.RotateX(cState, angle, defs);
            }
            else if (axis == 'Y')
            {
                newState = Flip.RotateY(cState, angle, defs);
            }
            else if (axis == 'Z')
            {
                newState = Flip.RotateZ(cState, angle, defs);
            }

            newState.CopySource = cState.CopySource;
            newState.CopyTime   = cState.CopyTime;
            p.CurrentCopy       = newState;
            p.Message("Rotated copy {0} degrees around the {1} axis", angle, axis);
        }
Esempio n. 27
0
 void Awake()
 {
     anime   = GetComponent <Animator>();
     coroute = false;
     fr      = true;
     die     = false;
     flip    = new Flip(emmiter);
 }
Esempio n. 28
0
            public TransformedTile(Tile tile, Flip flip, Rotate rotate)
            {
                Tile   = tile;
                Flip   = flip;
                Rotate = rotate;

                _transformed = BuildTransform(tile.Image, flip, rotate);
            }
    private void Start()
    {
        flip     = GetComponent <Flip>();
        fighter  = GetComponent <Fighter>();
        animator = GetComponent <Animator>();

        StartCoroutine("LifeTimer");
    }
        private async void ImageRotate_Click(object sender, RoutedEventArgs e)
        {
            PhotoDisplaySupport Item   = PhotoCollection[Flip.SelectedIndex];
            ScrollViewer        Viewer = Flip.ContainerFromItem(Item).FindChildOfType <ScrollViewer>();

            Viewer.RenderTransformOrigin = new Point(0.5, 0.5);
            await Viewer.Rotate(Item.RotateAngle += 90).StartAsync().ConfigureAwait(false);
        }
Esempio n. 31
0
 /// <summary>
 /// Generate an ImageGen URL from a Media Item
 /// </summary>
 /// <param name="mediaItem">The media item (iPublishedContent)</param>
 /// <param name="align">The horizontal alignment of the overlay image or text</param>
 /// <param name="allowUpsizing">Allow the image to be upsized</param>
 /// <param name="antiAlias">Boolean to allow the image to be Anti Aliased</param>
 /// <param name="border">Pass in a int to specifiy the border width</param>
 /// <param name="borderColor">The string of the Hexadecimal color value for the border color</param>
 /// <param name="colorMode">The colour mode of the image (colour, greyscale, sepia)</param>
 /// <param name="quality">A percentage scale of the amount of compression to apply to the image</param>
 /// <param name="constrain">A boolean if to constrain the width and height of the image</param>
 /// <param name="flip">Apply x, y or x & y flipping of the image</param>
 /// <param name="fontSize">An int of the size of the font to be applied to the image</param>
 /// <param name="fontStyle">The font style such as bold, italic to be applied to the image</param>
 /// <param name="font">The path or the name of the font installed on the server</param>
 /// <param name="fontColor">The string of the Hexadecimal color value for the font</param>/// 
 /// <param name="format">The output format of the image to be served, such as gif, jpb, png or tiff</param>
 /// <param name="height">The height of the image you want it to be resized to</param>
 /// <param name="lineHeight">An int of the lineheight used in conjuction with text & font params</param>
 /// <param name="maxHeight">An int of the max height of the image</param>
 /// <param name="maxWidth">An int of the max width of the image</param>
 /// <param name="noCache">A boolean to ensure the image is not cached</param>
 /// <param name="overlayMargin">An int to apply a margin to the overlay item, such as text or image</param>
 /// <param name="pad">An int to apply padding to the image</param>
 /// <param name="rotate">The number of degrees to rotate the image by</param>
 /// <param name="transparent">A bool to ensure the image is returned as transparent or not</param>
 /// <param name="vAlign">The vertical alignment of the overlay image or text</param>
 /// <param name="width">The width of the image you want it to be resized to</param>
 /// <param name="altImage">A path to an alternative image if the original image is not found</param>
 /// <param name="bgColor">The string of the Hexadecimal color value for the background of the image</param>
 /// <param name="overlayImage">A path to the image you wish to display over the top of the image, such as PNG watermark</param>
 /// <param name="text">The text you wish to display over the top of the image</param>
 /// <param name="imageCropperAlias">If using a custom crop, the alias of the cropper property</param>
 /// <param name="imageCropperCropId">If using a custom crop, the id of the corp to use</param>
 /// <param name="furtherOptions">If you need some further querystring option pass them here, e.g. &something=true</param>
 /// <param name="slimmage">Output the image for use with Slimmage</param>
 /// <returns>A string to the ImageGen Url with the parameters passed in</returns>
 public static string GetImageGenUrl(
     this IPublishedContent mediaItem,
     int? width = null,
     int? height = null,
     int? quality = null,
     Align? align = null,
     bool? allowUpsizing = null,
     bool? antiAlias = null,
     int? border = null,
     string borderColor = "",
     ColorMode? colorMode = null,
     bool? constrain = null,
     Flip? flip = null,
     int? fontSize = null,
     FontStyle? fontStyle = null,
     string font = null,
     string fontColor = null,
     Format? format = null,
     int? lineHeight = null,
     int? maxHeight = null,
     int? maxWidth = null,
     bool? noCache = null,
     int? overlayMargin = null,
     bool? pad = null,
     int? rotate = null,
     bool? transparent = null,
     VAlign? vAlign = null,
     string altImage = null,
     string bgColor = null,            
     string overlayImage = null,
     string text = null,
     string imageCropperAlias = null,
     string imageCropperCropId = null,
     string furtherOptions = null,
     bool slimmage = false)
 {
     string imageCropperValue = null;
     if (mediaItem.HasPropertyAndValueAndCrop(imageCropperAlias, imageCropperCropId))
     {
         imageCropperValue = mediaItem.GetPropertyValueHack(imageCropperAlias);
     }
     return mediaItem != null ? GetImageGenUrl(mediaItem.Url, width, height, quality, align, allowUpsizing, antiAlias, border, borderColor, colorMode, constrain, flip, fontSize, fontStyle, font, fontColor, format, lineHeight, maxHeight, maxWidth, noCache, overlayMargin, pad, rotate, transparent, vAlign, altImage, bgColor, overlayImage, text, imageCropperValue, imageCropperCropId, furtherOptions, slimmage) : string.Empty;
 }
Esempio n. 32
0
        public static string GetImageGenUrl(
            this string imageUrl,
            int? width = null,
            int? height = null,
            int? quality = null,
            Align? align = null,
            bool? allowUpsizing = null,
            bool? antiAlias = null,
            int? border = null,
            string borderColor = null,
            ColorMode? colorMode = null,
            bool? constrain = null,
            Flip? flip = null,
            int? fontSize = null,
            FontStyle? fontStyle = null,
            string font = "",
            string fontColor = "",
            Format? format = null,
            int? lineHeight = null,
            int? maxHeight = null,
            int? maxWidth = null,
            bool? noCache = null,
            int? overlayMargin = null,
            bool? pad = null,
            int? rotate = null,
            bool? transparent = null,
            VAlign? vAlign = null,
            string altImage = null,
            string bgColor = null,
            string overlayImage = null,
            string text = null,
            string imageCropperValue = null,
            string imageCropperCropId = null,
            string furtherOptions = null,
            bool slimmage = false)
        {
            if (!string.IsNullOrEmpty(imageUrl))
            {
                var imageGenUrl = new StringBuilder();
                imageGenUrl.Append(string.Format("/ImageGen.ashx?Image={0}",imageUrl));

                if (!string.IsNullOrEmpty(imageCropperValue) && imageCropperValue.IsJson())
                {
                    var allTheCrops = imageCropperValue.GetImageCrops();
                    if (allTheCrops != null && allTheCrops.Any())
                    {
                        var crop = imageCropperCropId != null
                            ? allTheCrops.Find(x => x.Id == imageCropperCropId)
                            : allTheCrops.First();
                        if (crop != null)
                        {
                            imageGenUrl.Append(string.Format("&crop={0}",crop.CropCoOrds));
                        }
                    }
                }
                if (width != null)
                {
                    imageGenUrl.Append(string.Format("&width={0}",width));
                }
                if (height != null)
                {
                    imageGenUrl.Append(string.Format("&height={0}", width));
                }
                if (quality != null)
                {
                    imageGenUrl.Append(string.Format("&quality={0}", quality));
                }

                //Align (Left, Center, Right, Near, Far)
                if (align != null)
                {
                    imageGenUrl.Append(string.Format("&Align={0}", align));
                }
                //Allow Upsizing (True False)
                if (allowUpsizing != null)
                {
                    imageGenUrl.Append(string.Format("&AllowUpsizing={0}", allowUpsizing));
                }

                //Alt Image (/photos/waterfall.png)
                if (!string.IsNullOrEmpty(altImage))
                {
                    imageGenUrl.Append(string.Format("&AltImage={0}", altImage));
                }

                //AntiAlias (True of False)
                if (antiAlias != null)
                {
                    imageGenUrl.Append(string.Format("&AntiAlias={0}", antiAlias));
                }

                //BgColor (FFFFFF)
                if (!string.IsNullOrEmpty(bgColor))
                {
                    imageGenUrl.Append(string.Format("&BgColor={0}", bgColor));
                }

                //Color Mode (enum)
                if (colorMode != null)
                {
                    imageGenUrl.Append(string.Format("&ColorMode={0}", colorMode));
                }

                //Border (15)
                if (border != null)
                {
                    imageGenUrl.Append(string.Format("&Border={0}", border));
                }

                //BorderColor (000000)
                if (!string.IsNullOrEmpty(borderColor))
                {
                    imageGenUrl.Append(string.Format("&BorderColor={0}", borderColor));
                }

                //Color Mode (enum)
                if (colorMode != null)
                {
                    imageGenUrl.Append(string.Format("&ColorMode={0}", colorMode));
                }

                //Constrain (true/false)
                if (constrain != null)
                {
                    imageGenUrl.Append(string.Format("&Constrain={0}", constrain));
                }

                //Flip (x,y,xy)
                if (flip != null)
                {
                    imageGenUrl.Append(string.Format("&Flip={0}", flip));
                }

                //fontSize (000033)
                if (fontSize != null)
                {
                    imageGenUrl.Append(string.Format("&FontSize={0}", fontSize));
                }

                //FontStyle (Bold%2BItalic)
                if (fontStyle != null)
                {
                    imageGenUrl.Append(string.Format("&FontStyle={0}", fontStyle));
                }

                //Font (Verdana)
                if (font != null)
                {
                    imageGenUrl.Append(string.Format("&Font={0}", font));
                }

                //FontColor (000033)
                if (fontColor != null)
                {
                    imageGenUrl.Append(string.Format("&FontColor={0}", fontColor));
                }

                //Format (JPEG, JPG, GIF, PNG, BMP, TIFF, TIF)
                if (format != null)
                {
                    imageGenUrl.Append(string.Format("&Format={0}", format));
                }

                //LineHeight (40)
                if (lineHeight != null)
                {
                    imageGenUrl.Append(string.Format("&LineHeight={0}", lineHeight));
                }

                //MaxHeight (40)
                if (maxHeight != null)
                {
                    imageGenUrl.Append(string.Format("&MaxHeight={0}", maxHeight));
                }

                //MaxWidth (40)
                if (maxWidth != null)
                {
                    imageGenUrl.Append(string.Format("&MaxWidth={0}", maxWidth));
                }

                //NoCache (true/false)
                if (noCache != null)
                {
                    imageGenUrl.Append(string.Format("&NoCache={0}", noCache));
                }

                //OverlayMargin (8)
                if (overlayMargin != null)
                {
                    imageGenUrl.Append(string.Format("&OverlayMargin={0}", overlayMargin));
                }

                //Pad (true/false)
                if (pad != null)
                {
                    imageGenUrl.Append(string.Format("&Pad={0}", pad));
                }

                //Rotate (0 - 360) int with validation -360 to 360
                if (rotate != null)
                {
                    //Check values
                    //If larger than 360 set it to 360
                    if (rotate > 360)
                    {
                        rotate = 360;
                    }

                    //If larger than minus 360 set it to minus 360
                    if (rotate < -360)
                    {
                        rotate = -360;
                    }

                    imageGenUrl.Append(string.Format("&Rotate={0}", rotate));
                }

                //Transparent (Bool True of False)
                if (transparent != null)
                {
                    imageGenUrl.Append(string.Format("&Transparent={0}", transparent));
                }

                //VAlign (Enum Top, Middle, Bottom, Near, Far)
                if (vAlign != null)
                {
                    imageGenUrl.Append(string.Format("&VAlign={0}", vAlign));
                }

                //OverlayImage (/images/watermark.png)
                if (overlayImage != null)
                {
                    imageGenUrl.Append(string.Format("&OverlayImage={0}", overlayImage));
                }

                if (text != null)
                {
                    imageGenUrl.Append(string.Format("&Text={0}", HttpUtility.UrlEncode(HttpUtility.HtmlEncode(text))));
                }

                if (slimmage)
                {
                    if (width == null)
                    {
                        imageGenUrl.Append("&width=300");
                    }
                    if (quality == null)
                    {
                        imageGenUrl.Append("&quality=90");
                    }
                    imageGenUrl.Append("&slimmage=true");
                }
                if (furtherOptions != null)
                {
                    imageGenUrl.Append(furtherOptions);
                }

                return imageGenUrl.ToString();
            }
            return string.Empty;
        }
Esempio n. 33
0
 private bool flip_piece(Flip dir)
 {
     switch (dir)
     {
         case Flip.Left :
             switch (current[0].statut)
             {
                 case Direction_piece.Pos1:
                     return (flip_pos4());
                 case Direction_piece.Pos2:
                     return (flip_pos1());
                 case Direction_piece.Pos3:
                     return (flip_pos2());
                 case Direction_piece.Pos4:
                     return (flip_pos3());
             }
             break;
         case Flip.Right:
             switch (current[0].statut)
             {
                 case Direction_piece.Pos1:
                     return (flip_pos2());
                 case Direction_piece.Pos2:
                     return (flip_pos3());
                 case Direction_piece.Pos3:
                     return (flip_pos4());
                 case Direction_piece.Pos4:
                     return (flip_pos1());
             }
             break;
     }
     return (true);
 }