Inheritance: System.IComparable
コード例 #1
0
        /// <summary>
        /// Restore all the surfaces, and redraw the sprite surfaces.
        /// </summary>
        void RestoreSurfaces()
        {
            SurfaceDescription description = new SurfaceDescription();

            displayDevice.RestoreAllSurfaces();

            // No need to re-create the surface, just re-draw it.
            text.ColorFill(9);
            text.DrawText(0, 0, textHelp, false);

            // We need to release and re-load, and set the palette again to
            // redraw the bitmap on the surface.  Otherwise, GDI will not
            // draw the bitmap on the surface with the correct palette.
            pal.Dispose();
            pal           = null;
            pal           = new Palette(displayDevice, bitmapFileName);
            front.Palette = pal;

            // Release and re-load the sprite bitmap.
            surfaceLogo.Dispose();
            surfaceLogo = new Surface(bitmapFileName, description, displayDevice);
            ColorKey ck = new ColorKey();

            surfaceLogo.SetColorKey(ColorKeyFlags.SourceDraw, ck);

            return;
        }
コード例 #2
0
    public Color Evaluate(float time)
    {
        ColorKey keyLeft  = _keys[0];
        ColorKey keyRight = _keys[_keys.Count - 1];

        for (int i = 0; i < _keys.Count; i++)
        {
            if (_keys[i].Time <= time)
            {
                keyLeft = _keys[i];
            }
            if (_keys[i].Time >= time)
            {
                keyRight = _keys[i];
                break;
            }
        }

        if (blendMode == BlendMode.Linear)
        {
            float blendTime = Mathf.InverseLerp(keyLeft.Time, keyRight.Time, time);
            return(Color.Lerp(keyLeft.Color, keyRight.Color, blendTime));
        }
        return(keyRight.Color);
    }
コード例 #3
0
 /// <summary>
 /// sets a color
 /// </summary>
 /// <param name="key">the key of the color</param>
 /// <param name="color">the color int</param>
 public void SetColor(ColorKey key, int color)
 {
     if (Colors.ContainsKey(key))
     {
         Colors[key] = IntToColorConvertor(color);
     }
 }
コード例 #4
0
ファイル: fyRibbonTrail.cs プロジェクト: aowchina/HolyTech
    //根据当前时间计算颜色
    public virtual Color GetGradientColor()
    {
        Color gcolor = new Color();

        //计算比例值
        float factor = mColorCurTime / mColorPeriodTime;
        //计算 color值
        int colorLength = colorKey.Length;

        for (int i = 0; i < colorLength - 1; i++)
        {
            ColorKey key1 = colorKey[i % colorLength];
            ColorKey key2 = colorKey[(i + 1) % colorLength];

            //计算距离
            float dist = key2.time - key1.time;

            if (factor >= key1.time && factor <= key2.time)
            {
                //计算当前alpha值
                float ff = (factor - key1.time) / dist;
                gcolor = key1.color * (1 - ff) + key2.color * ff;
                break;
            }
        }

        return(gcolor);
    }
コード例 #5
0
        public async Task <IActionResult> Edit(int id, [Bind("ColorID,ColorName")] ColorKey colorKey)
        {
            if (id != colorKey.ColorID)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(colorKey);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!ColorKeyExists(colorKey.ColorID))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            return(View(colorKey));
        }
コード例 #6
0
    private void Draw()
    {
        gradientPreviewRect = new Rect(BORDER_SIZE, BORDER_SIZE, position.width - BORDER_SIZE * 2, 25);
        GUI.DrawTexture(gradientPreviewRect, gradient.GetTexture((int)gradientPreviewRect.width));

        keyRects = new Rect[gradient.KeyCount];
        for (int i = 0; i < gradient.KeyCount; i++)
        {
            ColorKey key     = gradient.GetKey(i);
            float    keyX    = gradientPreviewRect.x + gradientPreviewRect.width * key.Time - KEY_WIDTH / 2f;
            float    keyY    = gradientPreviewRect.yMax + BORDER_SIZE;
            Rect     keyRect = new Rect(keyX, keyY, KEY_WIDTH, KEY_HEIGHT);

            if (i == selectedKeyIndex)
            {
                EditorGUI.DrawRect(new Rect(keyRect.x - 2, keyRect.y - 2, keyRect.width + 4, keyRect.height + 4), Color.black);
            }
            EditorGUI.DrawRect(keyRect, key.Col);
            keyRects[i] = keyRect;
        }

        Rect settingsRect = new Rect(BORDER_SIZE, keyRects[0].yMax + BORDER_SIZE, position.width - BORDER_SIZE * 2, position.height - BORDER_SIZE * 9);

        GUILayout.BeginArea(settingsRect);
        EditorGUI.BeginChangeCheck();
        Color newCol = EditorGUILayout.ColorField(gradient.GetKey(selectedKeyIndex).Col);

        if (EditorGUI.EndChangeCheck())
        {
            gradient.UpdateKeyColor(selectedKeyIndex, newCol);
        }
        gradient.blendMode      = (BlendMode)EditorGUILayout.EnumPopup("Blend Mode", gradient.blendMode);
        gradient.randomizeColor = EditorGUILayout.Toggle("Randmize Color", gradient.randomizeColor);
        GUILayout.EndArea();
    }
コード例 #7
0
ファイル: DefaultOptionPage.cs プロジェクト: d8q8/VsVim
 internal ColorInfo(ColorKey colorKey, Color color, bool isValid = true)
 {
     ColorKey      = colorKey;
     OriginalColor = color;
     Color         = color;
     IsValid       = isValid;
 }
コード例 #8
0
 /// <summary>
 /// All relevant properties
 /// </summary>
 public OutlookCategory(Guid Id, String DisplayName, ColorKey Color, String User)
 {
     this.Id          = Id;
     this.DisplayName = DisplayName;
     this.Color       = Color;
     this.User        = User;
 }
コード例 #9
0
    public void SwapKeys(int indexOfA, int indexOfB)
    {
        ColorKey temp = _colorKeys[indexOfA];

        _colorKeys[indexOfA] = _colorKeys[indexOfB];
        _colorKeys[indexOfB] = temp;
    }
コード例 #10
0
        void Draw()
        {
            gradientPreveiwRect = new Rect(borderSize, borderSize, position.width - (borderSize * 2), 25);

            GUI.DrawTexture(gradientPreveiwRect, gradient.GetTexture((int)gradientPreveiwRect.width));
            keyRects = new Rect[gradient.NumKeys];
            for (int i = 0; i < gradient.NumKeys; i++)
            {
                ColorKey key = gradient.GetKey(i);

                Rect keyRect = new Rect(gradientPreveiwRect.x + gradientPreveiwRect.width * key.Time - (keyWidth / 2f), gradientPreveiwRect.yMax + borderSize, keyWidth, keyHeight);
                if (i == selectedKeyIndex)
                {
                    EditorGUI.DrawRect(new Rect(keyRect.x - 2, keyRect.y - 2, keyRect.width + 4, keyRect.height + 4), Color.black);
                }

                EditorGUI.DrawRect(keyRect, key.Color);
                keyRects[i] = keyRect;
            }

            Rect settingsRect = new Rect(borderSize, keyRects[0].y + borderSize + keyHeight, position.width - borderSize * 2, position.height - (borderSize + keyHeight * 4));

            GUILayout.BeginArea(settingsRect);
            EditorGUI.BeginChangeCheck();
            Color newcolor = EditorGUILayout.ColorField(gradient.GetKey(selectedKeyIndex).Color);

            if (EditorGUI.EndChangeCheck())
            {
                gradient.UpdateKeyColor(selectedKeyIndex, newcolor);
            }
            // display gradient
            gradient.blendMode      = (MegaGradient.BlendMode)EditorGUILayout.EnumPopup("Blend Mode", gradient.blendMode);
            gradient.randomizeColor = EditorGUILayout.Toggle("Randomize New Color", gradient.randomizeColor);
            GUILayout.EndArea();
        }
コード例 #11
0
    protected void Page_Load(object sender, EventArgs e)
    {
        if (Request.QueryString.Count == 0)
        {
            Response.Redirect(HttpContext.Current.Request.Url.AbsoluteUri + "?ClientName=None&ModelType=CHEMSPILL&OutputType=Dissolved&Location=Wuhan");
        }
        //TO BE REPLACED WITH SOMTHING MORE SECURE
        _ClientName = Request.QueryString["ClientName"];
        _ModelType  = Request.QueryString["ModelType"];
        _OutputType = Request.QueryString["OutputType"];
        _sLocation  = Request.QueryString["Location"];
        _WebPath    = Path.GetDirectoryName(Server.MapPath("ModelRunMapPath.txt"));

        //Set the proper paths for the aggregator based off of the model type
        string keyPath    = "";
        string outputPath = "\\ModelData\\" + _sLocation;

        switch (_ModelType)
        {
        case "OILSPILL":
            switch (_OutputType.ToUpper())
            {
            case "PARTICLES":
                keyPath = _WebPath + outputPath + "\\keys\\oilmaptrj.kew";
                break;

            case "THICKNESS":
                keyPath = _WebPath + outputPath + "\\keys\\oilmaptk.kew";
                break;
            }
            break;

        case "CHEMSPILL":
            switch (_OutputType.ToUpper())
            {
            case "PARTICLES":
                keyPath = _WebPath + outputPath + "\\keys\\chemtraj.kew";
                break;

            case "DISSOLVED":
                keyPath = _WebPath + outputPath + "\\keys\\dissolved.dwt";
                break;

            case "CONCENTRATIONS":
                keyPath = _WebPath + outputPath + "\\keys\\surfaceslick.ssk";
                break;
            }
            break;

        default:
            Response.Write("ERROR: Unrecognized ModelType");
            return;
        }
        ColorKey myKey = new ColorKey(keyPath);

        string myResult = myKey.ToString();

        Response.Write(myResult);
    }
コード例 #12
0
 /// <summary>
 /// All relevant properties including Baseobject
 /// </summary>
 public OutlookCategory(Guid Id, String DisplayName, ColorKey Color, String User, object BaseObject)
 {
     this.Id          = Id;
     this.DisplayName = DisplayName;
     this.Color       = Color;
     this.User        = User;
     this.BaseObject  = BaseObject;
 }
コード例 #13
0
 /// <summary>
 /// get a color
 /// </summary>
 /// <param name="key">the key of the color to get</param>
 /// <returns>the color or a defult color if there's no such key</returns>
 public Color GetColor(ColorKey key)
 {
     if (Colors.ContainsKey(key))
     {
         return((Color)(Colors[key]));
     }
     return(Constants.DEFULT_COLOR);
 }
コード例 #14
0
    void AddColorKey(Vector2 mousePosition)
    {
        float time  = Mathf.InverseLerp(_gradientPreviewTexRect.xMin, _gradientPreviewTexRect.xMax, mousePosition.x);
        Color color = Random.ColorHSV();

        ColorKey newKey = _gradient.ColorKeys.Add(color, time);

        AddColorKeyControl(newKey);
    }
コード例 #15
0
    public ColorKeyControl(float xMin, float xMax, float y, ColorKey key)
    {
        _xMin    = xMin;
        _xMax    = xMax;
        BoundKey = key;
        float positionX = Mathf.Lerp(xMin, xMax, key.Time);
        float offset    = size * 0.5f;

        _rect = new Rect(positionX - offset, y + offset, size, size * 2f);
    }
コード例 #16
0
    void AddColorKeyControl(ColorKey key)
    {
        float           xMin       = _gradientPreviewTexRect.xMin;
        float           xMax       = _gradientPreviewTexRect.xMax;
        float           y          = _gradientPreviewTexRect.yMax;
        ColorKeyControl keyControl = new ColorKeyControl(xMin, xMax, y, key);

        _keyControls.Add(keyControl);
        MarkAsCurrentlySelected(keyControl);
    }
コード例 #17
0
        /// <summary>
        /// Initializes DirectDraw and all the surfaces to be used.
        /// </summary>
        private void InitDirectDraw()
        {
            SurfaceDescription description = new SurfaceDescription();                                                      // Describes a surface.

            draw = new Device();                                                                                            // Create a new DirectDrawDevice.
            draw.SetCooperativeLevel(this, CooperativeLevelFlags.FullscreenExclusive);                                      // Set the cooperative level.
            draw.SetDisplayMode(widthScreen, heightScreen, 16, 0, false);                                                   // Set the display mode width and height, and 16 bit color depth.

            description.SurfaceCaps.PrimarySurface = description.SurfaceCaps.Flip = description.SurfaceCaps.Complex = true; // Capabilities of the surface.
            description.BackBufferCount            = 1;                                                                     // Create 1 backbuffer.

            front = new Surface(description, draw);                                                                         // Create the surface using the description above.

            SurfaceCaps caps = new SurfaceCaps();

            caps.BackBuffer = true;                           // Caps of the surface.
            back            = front.GetAttachedSurface(caps); // Get the attached surface that matches the caps, which will be the backbuffer.
            back.ForeColor  = Color.White;

            description.Clear();                                         // Clear out the SurfaceDescription structure.
            surfaceAnimation = new Surface(nameFile, description, draw); // Create the sprite bitmap surface.

            ColorKey ck = new ColorKey();                                // Create a new colorkey.

            surfaceAnimation.SetColorKey(ColorKeyFlags.SourceDraw, ck);  // Set the colorkey to the bitmap surface. 0 is used for the colorkey, which is what the ColorKey struct is initialized to.

            for (int i = 0; i < numSprites; i++)
            {
                // Set the sprite's position, velocity, frame, rotation direction, and rotation speed.
                sprite[i].posX          = (randomNumber.Next(0, maxRand) % widthScreen);
                sprite[i].posY          = (randomNumber.Next(0, maxRand) % heightScreen);
                sprite[i].velX          = ((500.0f * randomNumber.Next(0, maxRand)) / (float)maxRand) - 250.0f;
                sprite[i].velY          = ((500.0f * randomNumber.Next(0, maxRand)) / (float)maxRand) - 250.0f;
                sprite[i].frame         = randomNumber.Next(0, maxRand) % numFrames;
                sprite[i].tickRotation  = 0;
                sprite[i].speedRotation = (randomNumber.Next(0, maxRand) % 50 + 25) / 1000.0f;
                sprite[i].isClockwise   = (0 == randomNumber.Next(0, maxRand) % 2) ? true : false;
            }

            // Precompute the source rects for frame.  The source rects
            // are used during the blt of the dds to the backbuffer.
            for (int i = 0; i < numFrames; i++)
            {
                System.Drawing.Point p = new System.Drawing.Point((i % 5) * diameterSprite, (i / 5) * diameterSprite);
                frame[i] = new System.Drawing.Rectangle(p, new Size(diameterSprite, diameterSprite));
            }

            // Init an array of random values.  This array is used to create the
            // 'flocking' effect seen in the sample.
            randomIndex = 0;
            for (int randomNext = 0; randomNext < numRandom; randomNext++)
            {
                randomTable[randomNext] = randomNumber.Next(0, maxRand);
            }
        }
コード例 #18
0
ファイル: NiColorData.cs プロジェクト: arycama/MorrowindUnity
        public NiColorData(NiFile niFile) : base(niFile)
        {
            keyCount      = niFile.Reader.ReadInt32();
            interpolation = (KeyType)niFile.Reader.ReadInt32();

            keys = new ColorKey[keyCount];
            for (var i = 0; i < keys.Length; i++)
            {
                keys[i] = new ColorKey(niFile.Reader, interpolation);
            }
        }
コード例 #19
0
ファイル: GradientWrapper.cs プロジェクト: haramako/test02
	public void SetKeys(ColorKey[] colorKeys, AlphaKey[] alphaKeys) {
		GradientColorKey[] actualColorKeys = null;
		GradientAlphaKey[] actualAlphaKeys = null;
		
		if (colorKeys != null)
			actualColorKeys = colorKeys.Select(key => new GradientColorKey(key.color, key.time)).ToArray();
		if (alphaKeys != null)
			actualAlphaKeys = alphaKeys.Select(key => new GradientAlphaKey(key.alpha, key.time)).ToArray();
		
		_gradient.SetKeys(actualColorKeys, actualAlphaKeys);
	}	
コード例 #20
0
        public ColorRandomPanel()
        {
            InitializeComponent();
            colorKeys = Controls.OfType <Panel>().OrderBy(panel => Int32.Parse(Regex.Match(panel.Name, @"\d").Value)).Select(panel =>
            {
                var key       = new ColorKey(panel);
                key.Selected += ColorKey_Selected;

                return(key);
            }).ToArray();
        }
コード例 #21
0
        /// <summary>
        /// saves the colors of the game to the shared preference
        /// </summary>
        /// <param name="sp">the shared preference</param>
        public void SaveColors(ISharedPreferences sp)
        {
            var editor = sp.Edit();

            for (int i = 0; i < length; i++)
            {
                ColorKey key = (ColorKey)i;
                editor.PutInt(key.ToString(), ((Color)Colors[key]).ToArgb());
            }
            editor.Commit();
        }
コード例 #22
0
        public async Task <IActionResult> Create([Bind("ColorID,ColorName")] ColorKey colorKey)
        {
            if (ModelState.IsValid)
            {
                _context.Add(colorKey);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            return(View(colorKey));
        }
コード例 #23
0
        /// <summary>
        /// loads the colors of the game from the shared preference
        /// </summary>
        /// <param name="sp">the shared preference</param>
        public void LoadColors(ISharedPreferences sp)
        {
            int current = 0;

            for (int i = 0; i < length; i++)
            {
                ColorKey key = (ColorKey)i;
                current     = sp.GetInt(key.ToString(), ((Color)Colors[key]).ToArgb());
                Colors[key] = IntToColorConvertor(current);
            }
        }
コード例 #24
0
    public Color GetColorValue(ColorKey colorKey)
    {
        Color temp = Color.black;

        if (_colorsDictionary.TryGetValue(colorKey, out temp))
        {
            return(temp);
        }

        print("Error In Color Manager - GetColorValue Method");
        return(Color.magenta);
    }
コード例 #25
0
        private void TestColorKey()
        {
            int      hr;
            ColorKey j = new ColorKey();
            int      c;

            hr = m_imcPrimary.GetColorKey(j, out c);
            DsError.ThrowExceptionForHR(hr);

            hr = m_imcPrimary.SetColorKey(j);
            DsError.ThrowExceptionForHR(hr);
        }
コード例 #26
0
ファイル: FullScreenDialog.cs プロジェクト: sjk7/DX90SDK
        /// <summary>
        /// Initializes DirectDraw and all the surfaces to be used.
        /// </summary>
        private void InitDirectDraw()
        {
            SurfaceDescription description  = new SurfaceDescription();                         // Describes a surface.
            Random             randomNumber = new Random();                                     // Random number for position and velocity.

            displayDevice = new Device();                                                       // Create a new DirectDrawDevice.
            displayDevice.SetCooperativeLevel(this, CooperativeLevelFlags.FullscreenExclusive); // Set the cooperative level.
            displayDevice.SetDisplayMode(screenWidth, screenHeight, 16, 0, false);              // Set the display mode width and height, and 8 bit color depth.

            description.SurfaceCaps.Flip = description.SurfaceCaps.Complex = description.SurfaceCaps.PrimarySurface = true;
            description.BackBufferCount  = 1;                // Create 1 backbuffer.
            front = new Surface(description, displayDevice); // Create the surface using the description above.

            SurfaceCaps caps = new SurfaceCaps();

            caps.BackBuffer = true;                                          // Caps of the surface.
            back            = front.GetAttachedSurface(caps);                // Get the attached surface that matches the caps, which will be the backbuffer.

            clip          = new Clipper(displayDevice);                      // Create a clipper object.
            clip.Window   = this;                                            // Set the clippers window handle to the window handle of the main window.
            front.Clipper = clip;                                            // Tell the front surface to use the clipper object.

            description.Clear();                                             // Clear out the SurfaceDescription structure.
            surfaceLogo = new Surface(nameFile, description, displayDevice); // Create the sprites bitmap surface.

            description.Clear();

            description.Width  = 400; // Set the width and height of the surface.
            description.Height = 20;
            description.SurfaceCaps.OffScreenPlain = true;

            text = new Surface(description, displayDevice); // Create the surface using the above description.
            text.ColorFill(Color.Black);
            text.ForeColor = Color.White;
            text.DrawText(0, 0, textHelp, true);

            ColorKey ck = new ColorKey();                          // Create a new colorkey.

            surfaceLogo.SetColorKey(ColorKeyFlags.SourceDraw, ck); // Set the colorkey to the bitmap surface. 0 is used for the colorkey, which is what the ColorKey struct is initialized to.

            for (int i = 0; i < numSprites; i++)
            {
                // Set the sprites's position and velocity
                sprites[i].posX = (randomNumber.Next() % screenWidth);
                sprites[i].posY = (randomNumber.Next() % screenHeight);

                sprites[i].velX = 500.0f * randomNumber.Next() / Int32.MaxValue - 250.0f;
                sprites[i].velY = 500.0f * randomNumber.Next() / Int32.MaxValue - 250.0f;
            }
        }
コード例 #27
0
    ///<summary>Add a key to CustomGradient, and returns its index</summary>
    public int AddKey(Color color, float time)
    {
        ColorKey newColorKey = new ColorKey(color, time);

        for (int i = 0; i < _keys.Count; i++)
        {
            if (newColorKey.Time < _keys[i].Time)
            {
                _keys.Insert(i, newColorKey);
                return(i);
            }
        }
        _keys.Add(newColorKey);
        return(_keys.Count - 1);
    }
コード例 #28
0
        /// <summary>
        /// randomize the colors
        /// </summary>
        public void RandomColors()
        {
            Random rand = new Random();

            for (int i = 0; i < length; i++)
            {
                ColorKey key   = (ColorKey)i;
                Color    color = new Color();
                color.A     = Convert.ToByte(255);
                color.R     = Convert.ToByte(rand.Next(255));
                color.G     = Convert.ToByte(rand.Next(255));
                color.B     = Convert.ToByte(rand.Next(255));
                Colors[key] = color;
            }
        }
コード例 #29
0
    public int AddColorKey(Color col, float time)
    {
        ColorKey newKey = new ColorKey(col, time);

        for (int i = 0; i < keys.Count; i++)
        {
            if (newKey.Time < keys[i].Time)
            {
                keys.Insert(i, newKey);
                return(i);
            }
        }
        keys.Add(newKey); // Add key to the end of the list if the key is not return yet
        return(keys.Count - 1);
    }
コード例 #30
0
        /// <summary>
        /// Restore all the surfaces, and redraw the sprite surfaces.
        /// </summary>
        void RestoreSurfaces()
        {
            SurfaceDescription description = new SurfaceDescription();

            draw.RestoreAllSurfaces();

            // Release and re-load the sprite bitmap.
            surfaceAnimation.Dispose();
            surfaceAnimation = null;
            surfaceAnimation = new Surface(nameFile, description, draw);
            ColorKey ck = new ColorKey();

            surfaceAnimation.SetColorKey(ColorKeyFlags.SourceDraw, ck);

            return;
        }
コード例 #31
0
    public int AddKey(Color color, float time)
    {
        ColorKey key = new ColorKey(color, time);

        for (int i = 0; i < keys.Count; i++)
        {
            if (key.Time < keys[i].Time)
            {
                keys.Insert(i, key);
                return(i);
            }
        }

        keys.Add(key);
        return(keys.Count - 1);
    }
コード例 #32
0
 /// <summary>
 /// Adds a color key
 /// </summary>
 /// <param name="t">time</param>
 /// <param name="color">the color to set at time t</param>
 /// <returns>the new Colorkey</returns>
 public ColorKey AddColorKey(float t, Color color)
 {
     ColorKey k = new ColorKey(t, color);
     Colors.Add(k);
     Colors.Sort();
     return k;
 }
コード例 #33
0
ファイル: DefaultOptionPage.cs プロジェクト: kun-liu/VsVim
 internal ColorInfo(ColorKey colorKey, Color color, bool isValid = true)
 {
     ColorKey = colorKey;
     OriginalColor = color;
     Color = color;
     IsValid = isValid;
 }
コード例 #34
0
ファイル: GradientWrapper.cs プロジェクト: kurtdog/DoubleTapp
 public void SetKeys(ColorKey[] colorKeys, AlphaKey[] alphaKeys)
 {
     if (colorKeys != null) {
     Array colorKeyParam = (Array)Activator.CreateInstance(s_tyGradientColorKey.MakeArrayType(), new object[] { colorKeys.Length });
     for (int i = 0; i < colorKeys.Length; ++i)
         colorKeyParam.SetValue(Activator.CreateInstance(s_tyGradientColorKey, colorKeys[i].color, colorKeys[i].time), i);
     s_piColorKeys.SetValue(_gradient, colorKeyParam, null);
     }
     if (alphaKeys != null) {
     Array alphaKeyParam = (Array)Activator.CreateInstance(s_tyGradientAlphaKey.MakeArrayType(), new object[] { alphaKeys.Length });
     for (int i = 0; i < alphaKeys.Length; ++i)
         alphaKeyParam.SetValue(Activator.CreateInstance(s_tyGradientAlphaKey, alphaKeys[i].alpha, alphaKeys[i].time), i);
     s_piAlphaKeys.SetValue(_gradient, alphaKeyParam, null);
     }
 }
コード例 #35
0
    public void DoGradientGUI(MBParticleColorBase P)
    {
        bool lmbd = Event.current.type == EventType.MouseDown && Event.current.button == 0;
        bool lmbu = Event.current.type == EventType.MouseUp && Event.current.button == 0;
        bool drg = Event.current.type==EventType.MouseDrag;
        bool dbl = lmbd && Event.current.clickCount > 1;
        bool rmb = Event.current.type == EventType.MouseDown && Event.current.button == 1;

        Vector2 mp= Event.current.mousePosition;

        EditorGUILayout.BeginHorizontal();
        GUILayout.Box("", new GUILayoutOption[] { GUILayout.MinHeight(24), GUILayout.ExpandWidth(true) });

        Rect r = GUILayoutUtility.GetLastRect();
        r = new Rect(r.x + 2, r.y + 2, r.width - 4, r.height - 4);
        if (!mGradient && Event.current.type == EventType.Repaint){
            mGradient=new Texture2D((int)r.width,(int)r.height, TextureFormat.RGB24, false);
            CreateColorGradient(mGradient, P);
        }

        if (mGradient) {
            EditorGUI.DrawPreviewTexture(r, mGradient);

            for (int k = 0; k < P.Colors.Count; k++) {
                Rect HandleRect = new Rect(r.x + P.Colors[k].t * r.width, r.y, 40, r.height);

                // Delete Key?
                if (rmb && HandleRect.Contains(mp) && P.Colors.Count>2 && k>0 && k<P.Colors.Count-1) {
                    P.Colors.Remove(P.Colors[k]);
                    CreateColorGradient(mGradient, P);
                    Event.current.Use();
                }

                // Begin Drag?
                if (drg && !mDragging && k>0 && k<P.Colors.Count-1 && HandleRect.Contains(mp)) {
                    mDragging = true;
                    mDragKey = P.Colors[k];
                    mDragOffset = mp.x - HandleRect.x;
                    Event.current.Use();
                }

                // Drag?
                if (Event.current.type==EventType.Repaint && mDragging && mDragKey==P.Colors[k]) {
                     mDragKey.t = (mp.x - r.x-mDragOffset) / r.width;
                     HandleRect = new Rect(r.x + mDragKey.t * r.width, r.y, 40, r.height);
                     NeedRepaint = true;
                }

                // Eat Down-Event to allow drag without opening Color Dialog
                if (lmbd && HandleRect.Contains(mp))
                    Event.current.Use();

                // End Drag or turn Up-Event into Down to trigger Color Dialog
                if (lmbu) {
                    if (mDragging && mDragKey==P.Colors[k]) {
                        mDragging = false;
                        mDragKey = null;
                        CreateColorGradient(mGradient, P);
                        Event.current.Use();
                    }
                    else if (HandleRect.Contains(mp)) {
                        Event.current.type = EventType.MouseDown;
                    }
                }

                Color c = P.Colors[k].Color;
                P.Colors[k].Color = EditorGUI.ColorField(HandleRect, P.Colors[k].Color);
                if (c != P.Colors[k].Color)
                    CreateColorGradient(mGradient, P);

            }
            // New Key?
            if (dbl && r.Contains(mp)) {
                P.AddColorKey((mp.x-r.x)/r.width,mGradient.GetPixel((int)(mp.x-r.x), 4));
                CreateColorGradient(mGradient,P);
                NeedRepaint = true;
                Event.current.Use();
            }

        }

        GUILayout.Box("", GUIStyle.none, new GUILayoutOption[] { GUILayout.MinWidth(40), GUILayout.ExpandWidth(false) });
        EditorGUILayout.EndHorizontal();
    }
コード例 #36
0
ファイル: DefaultOptionPage.cs プロジェクト: kun-liu/VsVim
        private static void SaveColor(IVsFontAndColorStorage vsStorage, ColorKey colorKey, Color color)
        {
            var colorableItemInfo = new ColorableItemInfo();
            if (colorKey.IsForeground)
            {
                colorableItemInfo.bForegroundValid = 1;
                colorableItemInfo.crForeground = (uint)ColorTranslator.ToWin32(color);
            }
            else
            {
                colorableItemInfo.bBackgroundValid = 1;
                colorableItemInfo.crBackground = (uint)ColorTranslator.ToWin32(color);
            }

            ErrorHandler.ThrowOnFailure(vsStorage.SetItem(colorKey.Name, new[] { colorableItemInfo }));
        }
コード例 #37
0
        public override void OnEnter()
        {
            PlayState.WorldWidth = Settings.Width;
            PlayState.WorldHeight = Settings.Height;
            PlayState.SeaLevel = Settings.SeaLevel;
            PlayState.Random = new ThreadSafeRandom(Seed);
            PlayState.WorldSize = new Point3(8, 1, 8);

            Overworld.Volcanoes = new List<Vector2>();

            DefaultFont = Game.Content.Load<SpriteFont>(ContentPaths.Fonts.Default);
            GUI = new DwarfGUI(Game, DefaultFont, Game.Content.Load<SpriteFont>(ContentPaths.Fonts.Title), Game.Content.Load<SpriteFont>(ContentPaths.Fonts.Small), Input);
            IsInitialized = true;
            Drawer = new Drawer2D(Game.Content, Game.GraphicsDevice);
            GenerationComplete = false;
            MainWindow = new Panel(GUI, GUI.RootComponent)
            {
                LocalBounds = new Rectangle(EdgePadding, EdgePadding, Game.GraphicsDevice.Viewport.Width - EdgePadding * 2, Game.GraphicsDevice.Viewport.Height - EdgePadding * 2)
            };

            GridLayout layout = new GridLayout(GUI, MainWindow, 7, 4)
            {
                LocalBounds = new Rectangle(0, 0, MainWindow.LocalBounds.Width, MainWindow.LocalBounds.Height)
            };

            Button startButton = new Button(GUI, layout, "Start!", GUI.DefaultFont, Button.ButtonMode.ToolButton, GUI.Skin.GetSpecialFrame(GUISkin.Tile.Check))
            {
                ToolTip = "Start the game with the currently generated world."
            };

            layout.SetComponentPosition(startButton, 2, 6, 1, 1);
            startButton.OnClicked += StartButtonOnClick;

            Button saveButton = new Button(GUI, layout, "Save", GUI.DefaultFont, Button.ButtonMode.ToolButton, GUI.Skin.GetSpecialFrame(GUISkin.Tile.Save))
            {
                ToolTip = "Save the generated world to a file."
            };
            layout.SetComponentPosition(saveButton, 1, 6, 1, 1);
            saveButton.OnClicked += saveButton_OnClicked;

            Button exitButton = new Button(GUI, layout, "Back", GUI.DefaultFont, Button.ButtonMode.ToolButton, GUI.Skin.GetSpecialFrame(GUISkin.Tile.LeftArrow))
            {
                ToolTip = "Back to the main menu."
            };
            layout.SetComponentPosition(exitButton, 0, 6, 1, 1);

            exitButton.OnClicked += ExitButtonOnClick;

            MapPanel = new ImagePanel(GUI, layout, worldMap)
            {
                ToolTip = "Map of the world.\nClick to select a location to embark."
            };

            GridLayout mapLayout = new GridLayout(GUI, MapPanel, 4, 5);

            ColorKeys = new ColorKey(GUI, mapLayout)
            {
                ColorEntries = Overworld.HeightColors
            };

            mapLayout.SetComponentPosition(ColorKeys, 3, 0, 1, 1);

            CloseupPanel = new ImagePanel(GUI, mapLayout, new ImageFrame(worldMap, new Rectangle(0, 0, 128, 128)))
            {
                KeepAspectRatio = true,
                ToolTip = "Closeup of the colony location"
            };

            mapLayout.SetComponentPosition(CloseupPanel, 3, 2, 2, 2);

            layout.SetComponentPosition(MapPanel, 0, 0, 3, 5);

            if(worldMap != null)
            {
                MapPanel.Image = new ImageFrame(worldMap);
            }

            MapPanel.OnClicked += OnMapClick;

            layout.UpdateSizes();

            GroupBox mapProperties = new GroupBox(GUI, layout, "Map Controls");

            GridLayout mapPropertiesLayout = new GridLayout(GUI, mapProperties, 7, 2)
            {
                LocalBounds = new Rectangle(mapProperties.LocalBounds.X, mapProperties.LocalBounds.Y + 32, mapProperties.LocalBounds.Width, mapProperties.LocalBounds.Height)
            };

            ComboBox worldSizeBox = new ComboBox(GUI, mapPropertiesLayout)
            {
                ToolTip = "Size of the colony spawn area."
            };

            worldSizeBox.AddValue("Tiny Colony");
            worldSizeBox.AddValue("Small Colony");
            worldSizeBox.AddValue("Medium Colony");
            worldSizeBox.AddValue("Large Colony");
            worldSizeBox.AddValue("Huge Colony");
            worldSizeBox.CurrentIndex = 1;

            worldSizeBox.OnSelectionModified += worldSizeBox_OnSelectionModified;
            mapPropertiesLayout.SetComponentPosition(worldSizeBox, 0, 0, 2, 1);

            ViewSelectionBox = new ComboBox(GUI, mapPropertiesLayout)
            {
                ToolTip = "Display type for the map."
            };

            ViewSelectionBox.AddValue("Height");
            ViewSelectionBox.AddValue("Factions");
            ViewSelectionBox.AddValue("Biomes");
            ViewSelectionBox.AddValue("Temp.");
            ViewSelectionBox.AddValue("Rain");
            ViewSelectionBox.AddValue("Erosion");
            ViewSelectionBox.AddValue("Faults");
            ViewSelectionBox.CurrentIndex = 0;

            mapPropertiesLayout.SetComponentPosition(ViewSelectionBox, 1, 1, 1, 1);

            Label selectLabel = new Label(GUI, mapPropertiesLayout, "Display", GUI.DefaultFont);
            mapPropertiesLayout.SetComponentPosition(selectLabel, 0, 1, 1, 1);
            selectLabel.Alignment = Drawer2D.Alignment.Right;

            layout.SetComponentPosition(mapProperties, 3, 0, 1, 6);

            Progress = new ProgressBar(GUI, layout, 0.0f);
            layout.SetComponentPosition(Progress, 0, 5, 3, 1);

            ViewSelectionBox.OnSelectionModified += DisplayModeModified;
            base.OnEnter();
        }
コード例 #38
0
ファイル: DefaultOptionPage.cs プロジェクト: kun-liu/VsVim
 private void SetColor(ColorKey colorKey, Color value)
 {
     _colorMap[colorKey].Color = value;
 }
コード例 #39
0
ファイル: DDGraphic.cs プロジェクト: soeminnminn/BattleCity
        /// <summary>
        /// Makes this DDGraphic transparent with the specified color.
        /// </summary>
        /// <param name="transColor">Transparent color in 0x00RRGGBB format.</param>
        public void SetTransparency(int transColor)
        {
            // Make sure a valid color is given.
            if (transColor < 0) {
                return;
            }

            // Get transparent color.
            _transColor = transColor;

            // Set color key.
            ColorKey key = new ColorKey();

            key.ColorSpaceHighValue = _transColor;
            key.ColorSpaceLowValue = _transColor;

            this.SetColorKey(ColorKeyFlags.SourceDraw, key);
        }
コード例 #40
0
ファイル: DefaultOptionPage.cs プロジェクト: kun-liu/VsVim
 private Color GetColor(ColorKey colorKey)
 {
     return _colorMap[colorKey].Color;
 }
コード例 #41
0
ファイル: DefaultOptionPage.cs プロジェクト: kun-liu/VsVim
        private Color LoadColor(IVsFontAndColorStorage vsStorage, ColorKey colorKey)
        {
            var array = new ColorableItemInfo[1];
            ErrorHandler.ThrowOnFailure(vsStorage.GetItem(colorKey.Name, array));

            int isValid = colorKey.IsForeground
                ? array[0].bForegroundValid
                : array[0].bBackgroundValid;
            if (isValid == 0)
            {
                throw new Exception();
            }

            uint colorRef = colorKey.IsForeground
                ? array[0].crForeground
                : array[0].crBackground;
            return FromColorRef(vsStorage, colorRef);
        }