コード例 #1
0
        public static string ToString(this Color color)
        {
            string NewColor;

            if (StringColor.TryGetValue(color, out NewColor))
            {
                return(NewColor);
            }
            else
            {
                return("White");
            }
        }
コード例 #2
0
ファイル: GraphicsHelper.cs プロジェクト: unkei/unCal
        public static void drawString(WriteableBitmap wb, int x, int y, string str, StringColor sc, int fontsize = 14, HAlign halign = HAlign.LEFT, string fnt = "Segoe WP Light")
        {
            TextBlock tb = new TextBlock();
            tb.Text = str;
            tb.FontFamily = new FontFamily(fnt);
            tb.FontSize = fontsize;
            if (sc == StringColor.HIGHLIGHT)
            {
                //tb.FontFamily = new FontFamily("Segoe WP");
                //tb.FontSize = fontsize + 1.0;
                //y--;
                tb.Foreground = new SolidColorBrush(foregroundColor);
                //tb.Foreground = new SolidColorBrush(getColor("PhoneContrastForegroundColor"));
                tb.FontWeight = System.Windows.FontWeights.Bold;
                //tb.TextDecorations = TextDecorations.Underline;
            }
            else
            {
                tb.Foreground = new SolidColorBrush(foregroundColor);
                if (sc == StringColor.DIMMED)
                {
                    tb.Opacity = 0.5;
                }
            }

            switch (halign)
            {
                case HAlign.CENTER:
                    x -= (int)tb.ActualWidth / 2;
                    break;
                case HAlign.RIGHT:
                    x -= (int)tb.ActualWidth;
                    break;
                case HAlign.LEFT:
                    break;
            }
            wb.Render(tb, new TranslateTransform() { X = x, Y = y });

            if (sc == StringColor.HIGHLIGHT)
            {
                // TODO : FIXME, line is not drawn at all ( and even not sure if this is right UI element)
                Line ln = new Line();
                ln.X1 = x;
                ln.Y1 = y + tb.ActualHeight + 2;
                ln.X2 = x + tb.ActualWidth;
                ln.Y2 = y + tb.ActualHeight + 2;
                wb.Render(ln, new TranslateTransform() { X = x, Y = y });
            }
        }
コード例 #3
0
    void OnStringReachCore(StringColor color)
    {
        var t = targetString.Find(m => m.stringColor == color);

        if (t != null)
        {
            t.gameObject.SetActive(false);
            foreach (var c in colorLayers)
            {
                if (c.color == color && !c.inlayFinished)
                {
                    StartCoroutine(FillColorRoutine(c));
                }
            }
        }
    }
コード例 #4
0
ファイル: CUGradientTextBox.cs プロジェクト: mcu8/CUFramework
        protected void OnPaint(object sender, PaintEventArgs e)
        {
            Font         drawFont   = new Font(this.Font.FontFamily, this.Font.Size, this.Font.Style, this.Font.Unit);//this.Font;
            SolidBrush   drawBrush  = new SolidBrush(this.ForeColor);
            StringFormat drawFormat = new StringFormat();

            drawFormat.Alignment = TextAlign == ETextAlign.Center ? StringAlignment.Center : StringAlignment.Near;

            int fontH   = (int)drawFont.GetHeight();
            int spacing = 4;

            Debug.WriteLine("FontH: " + fontH);
            int limit = ((this.Height - spacing) / (spacing + fontH));

            Debug.WriteLine("Limit: " + limit);

            int index = 0;
            int x     = TextAlign == ETextAlign.Center ? this.Width / 2 : 0;

            int   y = (this.Height - spacing / 2) - fontH - spacing / 2;
            float off;
            float r, g, b;

            StringColor[] lines = new StringColor[this.Lines.Count];
            this.Lines.CopyTo(lines); // prevent concurrent exception here
            foreach (var ln in lines)
            {
                off             = 1f - ((float)index / (float)limit);
                r               = Math.Max(ln.Color.R * off, this.BackColor.R);
                g               = Math.Max(ln.Color.G * off, this.BackColor.G);
                b               = Math.Max(ln.Color.B * off, this.BackColor.B);
                drawBrush.Color = Color.FromArgb((int)r, (int)g, (int)b);
                e.Graphics.DrawString(ln.Text, drawFont, drawBrush, x, y, drawFormat);
                y -= fontH + spacing;
                index++;
                if (index == limit)
                {
                    break;
                }
                Debug.WriteLine(off);
            }

            drawFont.Dispose();
        }
コード例 #5
0
        bool CardRotationCheck(int level, Card testedResult, Card[] results, int b1, int b2, int f1, int f2)    //  Balra és Fel irányba melyik madzagokat kell vizsgáljuk: b1, b2, f1, f2
        {
            bool stillGood = true;
            //  Vizsgálat a balra szomszédra:
            int testedResultSide = testedResult.WhichSide ? 1 : 0;  //  A tesztelt kártya aktív oldalát intben elmentem az indexelés miatt
            int sqrtCardCount    = (int)Math.Sqrt(Game.cardCount);

            if (level % sqrtCardCount != 0)                            //  Ezeknél az eseteknél nem kell vizsgálnunk a balra oldalt, mert nincs ott kártya (0-ás, 3-as, 6-os indexű kártyák)
            {
                Card        cardTemp     = results[level - 1];         //  A hivatkozások egyszerűsítése miatt
                int         cardTempSide = cardTemp.WhichSide ? 1 : 0; //  A vizsgált szomszéd aktív oldalát intben elmentem
                StringColor bxColor      = testedResult.Colors[testedResultSide, b1];
                StringColor byColor      = testedResult.Colors[testedResultSide, b2];
                switch (cardTemp.Rotation)          //  Megnézzük a vizsgált szomszéd jelenlegi állását
                {
                case 0: if (bxColor != cardTemp.Colors[cardTempSide, 3] || byColor != cardTemp.Colors[cardTempSide, 0])
                    {
                        stillGood = false;
                    }                           //  Ha valamelyik madzag nem jól kapcsolódik, akkor már nem jó a kártya
                    break;

                case 1: if (bxColor != cardTemp.Colors[cardTempSide, 2] || byColor != cardTemp.Colors[cardTempSide, 1])
                    {
                        stillGood = false;
                    }
                    break;

                case 2: if (bxColor != cardTemp.Colors[cardTempSide, 1] || byColor != cardTemp.Colors[cardTempSide, 3])
                    {
                        stillGood = false;
                    }
                    break;

                case 3: if (bxColor != cardTemp.Colors[cardTempSide, 2] || byColor != cardTemp.Colors[cardTempSide, 0])
                    {
                        stillGood = false;
                    }
                    break;

                default:
                    throw new MyException("Nem megfelelő a forgatási szám: " + cardTemp.Rotation);            //  Ha ezektől különböző érték, akkor nem jó a forgatási szám
                }
            }

            //  Vizsgálat a felső szomszédra, ha balra szomszéd vizsgálat sikerült:
            if (stillGood && level > sqrtCardCount - 1)                //  Ha a szint kisebb kettőnél, akkor nem kell vizsgálnunk a felszomszédot, mivel az az első sor
            {
                Card        cardTemp = results[level - sqrtCardCount]; //  A hivatkozások egyszerűsítése miatt
                int         oldal    = cardTemp.WhichSide ? 1 : 0;
                StringColor fxColor  = testedResult.Colors[testedResultSide, f1];
                StringColor fyColor  = testedResult.Colors[testedResultSide, f2];
                switch (cardTemp.Rotation)
                {
                case 0: if (fxColor != cardTemp.Colors[oldal, 2] || fyColor != cardTemp.Colors[oldal, 0])
                    {
                        stillGood = false;
                    }
                    break;

                case 1: if (fxColor != cardTemp.Colors[oldal, 3] || fyColor != cardTemp.Colors[oldal, 0])
                    {
                        stillGood = false;
                    }
                    break;

                case 2: if (fxColor != cardTemp.Colors[oldal, 2] || fyColor != cardTemp.Colors[oldal, 1])
                    {
                        stillGood = false;
                    }
                    break;

                case 3: if (fxColor != cardTemp.Colors[oldal, 1] || fyColor != cardTemp.Colors[oldal, 3])
                    {
                        stillGood = false;
                    }
                    break;

                default:
                    throw new MyException("Nem megfelelő a forgatási szám: + " + cardTemp.Rotation);            //  Ha ezektől különböző érték, akkor nem jó a forgatási szám
                }
            }
            return(stillGood);
        }
コード例 #6
0
 public StringColorPosition(StringColor stringColor, Vector3 position)
 {
     StringColor = stringColor;
     Position    = position;
 }
コード例 #7
0
ファイル: Colors.cs プロジェクト: fritzmark/Imagin.NET
 protected virtual void OnSelected(StringColor input) => Selected?.Invoke(this, new EventArgs <StringColor>(input));