Ejemplo n.º 1
0
 public FrmEditColor(IDataSource ds, ColorClass color, HashSet <string> colorNames = null)
 {
     this.InitializeComponent();
     this._ds = ds;
     this.txtColorName.Enabled = false;
     this._isEdit = true;
     this._color  = color;
     this.Text    = "编辑颜色";
     if (color == null)
     {
         this._colorNames = new HashSet <string>();
     }
     else
     {
         this._colorNames = colorNames;
     }
     if (this._color != null)
     {
         this.txtColorName.Text = this._color.Name;
         if (!string.IsNullOrEmpty(this._color.Code))
         {
             this.colorValue.Color       = System.Drawing.Color.FromArgb(int.Parse(this._color.Code));
             this.traktTansparency.Value = this.colorValue.Color.A;
         }
     }
 }
Ejemplo n.º 2
0
    private List <ColorClass> ShuffleSegmentColor()
    {
        //shuffle color class to generate random sequence
        List <ColorClass> shuffleList = GameManager.Instance.colors;

        for (int i = 0; i < shuffleList.Count; i++)
        {
            int        ran  = Random.Range(i, shuffleList.Count);
            ColorClass temp = shuffleList[i];
            shuffleList[i]   = shuffleList[ran];
            shuffleList[ran] = temp;
        }
        //make sure pass color is in the random sequence
        for (int i = 0; i < shuffleList.Count; i++)
        {
            if (shuffleList[i] == LevelManager.Instance.PassColor)
            {
                if (i < cparams.seg_number)
                {
                    return(shuffleList);
                }
                else
                {
                    int        pass = Random.Range(0, cparams.seg_number - 1);
                    ColorClass temp = shuffleList[i];
                    shuffleList[i]    = shuffleList[pass];
                    shuffleList[pass] = temp;
                    return(shuffleList);
                }
            }
        }
        Debug.LogError("Cannot find the color to pass in the color database");
        return(null);
    }
Ejemplo n.º 3
0
    private void GenerateLevel()
    {
        passColor = GameManager.Instance.GetColorClass(levelParam.pass_color);
        objContainer.gameObject.SetActive(true);

        for (int i = 0; i < levelParam.line_number; i++)
        {
            LineControlParameters data = levelParam.lines[i];
            //Line newLine = Instantiate(levelParam.line_prefab, objContainer) as Line;
            Line newLine = Instantiate(lineAsset, objContainer) as Line;

            if (newLine)
            {
                //NOTE: the cparams field in Line class is a deep copy of the data config, not a reference to it
                //because we use scriptableObject but not modify it
                newLine.cparams                   = new LineControlParameters();
                newLine.cparams.start_point       = data.start_point;
                newLine.cparams.seg_number        = data.seg_number;
                newLine.cparams.color_update_itv  = data.color_update_itv;
                newLine.cparams.length_update_itv = data.length_update_itv;

                newLine.ConfigSelf();
            }
            else
            {
                Debug.LogError("Read line prefab error");
                return;
            }
        }
        levelLines = objContainer.GetComponentsInChildren <Line>();
    }
    void Awake()
    {
        curId = 0;
        scale = 5F;

        ColorClass.Initialize();

        instatiatedObj = new List <BaseObj> ();

        m_savedata = record.load();
        if (m_savedata != null)
        {
            if (m_savedata.m_general != null)
            {
                if (m_savedata.m_general.curId <= 0)
                {
                    m_savedata.m_general.curId = 0;
                }
                if (m_savedata.m_general.scale <= 0)
                {
                    m_savedata.m_general.scale = scale;
                }
            }
            else
            {
                curId = m_savedata.m_general.curId;
                scale = m_savedata.m_general.scale;
            }
        }

        instance = this;
        instanceThisGameObject = this.gameObject;
    }
Ejemplo n.º 5
0
 public void UpdateColor(ColorClass cc)
 {
     currentCC        = cc;
     gameObject.layer = cc.layerFlag;
     m_render.color   = cc.color;
     breakEffect.GetComponent <ParticleSystem>().startColor = cc.color;
 }
Ejemplo n.º 6
0
    private void Start()
    {
#if UNITY_EDITOR
        Debug.Log("Platform: Unity Editor Mode");
#endif

#if UNITY_STANDALONE_WIN
        Debug.Log("Platform: Win Standalone Mode");
#elif UNITY_STANDALONE_OSX
        Debug.Log("Platform: OSX Standalone Mode");
#endif

#if UNITY_IOS
        Debug.Log("Platform: IOS Mode");
#elif UNITY_ANDROID
        Debug.Log("Platform: Android Mode");
#endif

        //TODO test
        List <ColorClass> l = GameManager.Instance.colors;
        targetLayer = 0;
        passColor   = GameManager.Instance.GetColorClass(ColorName.Blue);
        for (int i = 0; i < l.Count; i++)
        {
            targetLayer |= l[i].layerMask;
        }
    }
Ejemplo n.º 7
0
            // @desc 加算色を指定する
            // @decl set_add_color(self, color)
            // @param color カラー
            private static int L_set_add_color(ILuaState lua)
            {
                check_identifier(lua, 1, klassName);
                SpriteObject so  = get_component <SpriteObject>(lua, 1);
                Color        col = ColorClass.ToColor(lua, 2);

                so.player.addColor = col;
                return(0);
            }
Ejemplo n.º 8
0
        public static byte[] ExtractPixelSection(byte[] sourcePixels, int sourceBitsPerPixel, int sourceStride, Int32Rect sectionRect, System.Drawing.Color[] transparentColors)
        {
            int  length = sectionRect.Width * sectionRect.Height * 4;
            int  num1   = sourceBitsPerPixel / 8;
            bool flag   = false;

            if (sourceBitsPerPixel == 32)
            {
                flag = true;
                int num2 = 0;
                while (num2 < sourcePixels.Length)
                {
                    if (sourcePixels[num2 + 3] != 0)
                    {
                        flag = false;
                        break;
                    }
                    num2 += 4;
                }
            }
            byte[] numArray = new byte[length];
            for (int index1 = 0; index1 < sectionRect.Height; ++index1)
            {
                for (int index2 = 0; index2 < sectionRect.Width; ++index2)
                {
                    var  cDisplayClass50 = new ColorClass();
                    int  index3          = (index2 + sectionRect.X) * num1 + (index1 + sectionRect.Y) * sourceStride;
                    int  index4          = index2 * 4 + index1 * (sectionRect.Width * 4);
                    byte num2            = sourcePixels[index3];
                    byte num3            = sourcePixels[index3 + 1];
                    byte num4            = sourcePixels[index3 + 2];
                    byte num5            = sourceBitsPerPixel == 32 ? sourcePixels[index3 + 3] : byte.MaxValue;
                    cDisplayClass50.C = System.Drawing.Color.FromArgb(num4, num3, num2);
                    if (Array.FindIndex(transparentColors, cDisplayClass50.IsEquals) != -1)
                    {
                        num5 = 0;
                    }
                    else if (flag)
                    {
                        num5 = byte.MaxValue;
                    }
                    if (num5 == 0)
                    {
                        num2 = 0;
                        num3 = 0;
                        num4 = 0;
                    }
                    numArray[index4]     = num2;
                    numArray[index4 + 1] = num3;
                    numArray[index4 + 2] = num4;
                    numArray[index4 + 3] = num5;
                }
            }
            return(numArray);
        }
Ejemplo n.º 9
0
 public void SetForegroundColor(ColorClass color)
 {
     byte[] buffer;
     buffer = new byte[5] {
         27, 91, 51, (byte)(48 + color.Color), 109
     };
     if (color.Bright)
     {
         buffer[2] = 57;
     }
     stream.Write(buffer, 0, buffer.Length);
 }
Ejemplo n.º 10
0
 // Methods
 public FrmEditColor(IDataSource ds, string groupId, HashSet <string> colorNames = null)
 {
     this.InitializeComponent();
     this._ds                  = ds;
     this._groupId             = groupId;
     this._isEdit              = false;
     this.Text                 = "添加颜色";
     this.txtColorName.Enabled = true;
     this._color               = new ColorClass();
     this._color.Group         = groupId;
     this._color.ObjectId      = BitConverter.ToString(ObjectIdGenerator.Generate()).Replace("-", string.Empty).ToLowerInvariant();
 }
Ejemplo n.º 11
0
 public void SetBackgroundColor(ColorClass color)
 {
     byte[] buffer;
     if (color.Bright)
     {
         buffer = new byte[6] {
             27, 91, 49, 48, (byte)(48 + color.Color), 109
         }
     }
     ;
     else
     {
         buffer = new byte[5] {
             27, 91, 52, (byte)(48 + color.Color), 109
         }
     };
     stream.Write(buffer, 0, buffer.Length);
 }
    // Use this for initialization
    void Start()
    {
        audioVisualization = GameObject.Find("AudioPlayer").GetComponent <AudioVisualization>();
        colorClass         = GameObject.Find("AudioPlayer").GetComponent <ColorClass>();
        fileControllor     = GetComponent <FileControllor>();

        InitUI();
        InitGlow11();
        InitBarValue();

        if (CheckIndexAndGetMusic(PlayerPrefs.GetString("index")))
        {
            PlayMusic(musicList[UnityEngine.Random.Range(0, musicList.Count)]);
        }
        else
        {
            InitAudioInfo(audioClip);
            nameText.text = audioSource.clip.name;
        }
    }
Ejemplo n.º 13
0
    private unsafe static void TestClassPointer()
    {
        ColorClass color = new ColorClass();
        float      b     = 0.5f;

        color.b = &b;

        fixed(float *pClassGreen = &color.g)
        {
            ModifyFloat(pClassGreen);
        }

        if (Camera.main)
        {
            Camera.main.backgroundColor = new Color(
                r: color.r,
                g: color.g,
                b: *color.b,
                a: 0);
        }
    }
    // Use this for initialization
    void Start()
    {
        colorClass = GetComponent <ColorClass>();
        angle      = 360f / (samples.Length - 14);
        GameObject tempCube;

        audioSource   = GetComponent <AudioSource>();
        cubeTransform = new Transform[samples.Length];
        for (int i = 0; i < samples.Length - 14; i++)
        {
            tempCube                = Instantiate(cube, new Vector3(transform.position.x + i * widthOfCube, transform.position.y, transform.position.z), Quaternion.identity);
            cubeTransform[i]        = tempCube.transform;
            cubeTransform[i].parent = transform;
            angle %= 360;
            float x = transform.position.x + radius * Mathf.Cos(angle * i * 2 * Mathf.PI / 360);
            float z = transform.position.z + radius * Mathf.Sin(angle * i * 2 * Mathf.PI / 360);
            tempCube.transform.position = new Vector3(x, transform.position.y, z);
            tempCube.transform.LookAt(transform);
        }
        cubeMeshrenders = transform.GetComponentsInChildren <MeshRenderer>();
    }
Ejemplo n.º 15
0
 internal Member(ColorClass group, string name) => (Group, Name) = (group, name);
Ejemplo n.º 16
0
#pragma warning disable 1998
        public async Task <IViewComponentResult> InvokeAsync(string text, string uri, ColorClass color = ColorClass.Primary)
#pragma warning restore 1998
        {
            var model = new BadgeControlModel
            {
                Text  = text,
                Uri   = uri,
                Color = color.ToString().ToLower()
            };

            return(View("Default", model));
        }
Ejemplo n.º 17
0
        private void F_資料確認(ref DataTable D_table, ref DataTable D_errortable, ref DataTable DtCula, IRow row, int i, ref List <ColorClass> colorClass)
        {
            int iDDL顏色數量 = 0;

            int.TryParse(匯入筆數DDL.SelectedValue, out iDDL顏色數量);
            int    IRowCount = row.Count();
            string StrError  = "";

            //顏色數量
            if (iDDL顏色數量 > 0)
            {
                if (i > 0)
                {
                    for (int i顏色數量 = 0; i顏色數量 < iDDL顏色數量; i顏色數量++)
                    {
                        ColorClass CC = new ColorClass
                        {
                            ColorX    = i,
                            ColorY    = i顏色數量,
                            ColorName = row.GetCell(i顏色數量).ToString()
                        };
                        colorClass.Add(CC);
                    }
                }
                //增加欄位
                if (i == 0)
                {
                    for (int i欄位數量 = 0; i欄位數量 < IRowCount - 1; i欄位數量++)
                    {
                        if (i欄位數量 < iDDL顏色數量)
                        {
                            D_table.Columns.Add(row.GetCell(i欄位數量).ToString());
                            DtCula.Columns.Add("計算" + row.GetCell(i欄位數量).ToString());
                        }
                        else
                        {
                            DataColumn column;
                            column            = new DataColumn();
                            column.DataType   = System.Type.GetType("System.Int32");
                            column.ColumnName = row.GetCell(i欄位數量).ToString();
                            D_table.Columns.Add(column);
                            DataColumn column2;
                            column2            = new DataColumn();
                            column2.DataType   = System.Type.GetType("System.Int32");
                            column2.ColumnName = "計算" + row.GetCell(i欄位數量).ToString();
                            DtCula.Columns.Add(column2);
                        }
                    }
                }
                else
                {
                    DataRow D_dataRow      = D_table.NewRow();
                    DataRow D_erroraRow    = D_errortable.NewRow();
                    DataRow D_DtCulDataRow = DtCula.NewRow();
                    Boolean BError         = false;
                    #region 基礎資料
                    try
                    {
                        int I公式件數總計  = (int)row.GetCell(IRowCount - 2).NumericCellValue;
                        int I數量增減    = (int)row.GetCell(IRowCount - 1).NumericCellValue;
                        int I件數總計確認  = 0;
                        int I件異動後總件數 = 0;
                        for (int j = 0; j < IRowCount; j++)
                        {
                            if (j < iDDL顏色數量)
                            {
                                D_dataRow[j]      = row.GetCell(j).ToString().Trim();
                                D_DtCulDataRow[j] = row.GetCell(j).ToString().Trim();
                                ListColor.Add(row.GetCell(j).ToString().Trim());
                            }
                            else
                            {
                                int icount = 0;
                                try
                                {
                                    switch (row.GetCell(j).CellType)
                                    {
                                    case CellType.Numeric:
                                    case CellType.Formula:
                                        if (j < IRowCount - 2)
                                        {
                                            I件數總計確認 += (int)row.GetCell(j).NumericCellValue;
                                            if (j == IRowCount - 2 && I件數總計確認 != I公式件數總計)
                                            {
                                                BError   = true;
                                                StrError = "件數不同:件數加總" + I件數總計確認.ToString() + ",公式加總" + I公式件數總計.ToString();
                                            }
                                            icount = (I數量增減 != 0) ? (int)((float)row.GetCell(j).NumericCellValue + ((float)row.GetCell(j).NumericCellValue / I公式件數總計) * I數量增減) : (int)row.GetCell(j).NumericCellValue;
                                            //D_dataRow[j + IRowCount - 2] = icount;
                                            D_DtCulDataRow[j] = icount;
                                            I件異動後總件數         += icount;
                                        }
                                        if (j == IRowCount - 2)
                                        {
                                            D_DtCulDataRow[IRowCount - 2] = I件異動後總件數;
                                        }
                                        D_dataRow[j] = (int)row.GetCell(j).NumericCellValue;
                                        break;

                                    case CellType.Error:
                                    default:
                                        D_dataRow[j] = 0;
                                        break;
                                    }
                                }
                                catch (Exception ex2)
                                {
                                    F_ErrorShow(ex2.ToString());
                                }
                            }
                        }
                        D_table.Rows.Add(D_dataRow);
                        DtCula.Rows.Add(D_DtCulDataRow);
                        if (BError)
                        {
                            D_erroraRow[0] = "Row " + i.ToString() + " " + StrError;
                            D_errortable.Rows.Add(D_erroraRow);
                        }
                    }
                    catch (Exception ex)
                    {
                        F_ErrorShow(ex.ToString());
                    }
                    #endregion
                }
            }
            #region old code
            //string StrError = "";
            //int IRowCount = row.Count();

            //if (i==0)
            //{
            //    for (int x = 0; x < IRowCount*2; x++)
            //    {
            //        if(x< IRowCount)
            //        {
            //            if(x<2)
            //                D_table.Columns.Add(row.GetCell(x).ToString());
            //            else
            //            {
            //                DataColumn column;
            //                column = new DataColumn();
            //                column.DataType = System.Type.GetType("System.Int32");
            //                column.ColumnName =  row.GetCell(x).ToString();
            //                D_table.Columns.Add(column);
            //            }
            //        }
            //        else
            //        {
            //            if ( x<IRowCount * 2-1)
            //                if(x<IRowCount+2)
            //                {
            //                    DtCula.Columns.Add("計算" + row.GetCell(x - IRowCount).ToString());
            //                }
            //                else
            //                {
            //                    DataColumn column;
            //                    column = new DataColumn();
            //                    column.DataType = System.Type.GetType("System.Int32");
            //                    column.ColumnName = "計算" + row.GetCell(x - IRowCount).ToString();
            //                    DtCula.Columns.Add(column);
            //                }


            //        }
            //    }
            //}
            //else
            //{
            //    DataRow D_dataRow = D_table.NewRow();
            //    DataRow D_erroraRow = D_errortable.NewRow();
            //    DataRow D_DtCulDataRow = DtCula.NewRow();
            //    Boolean BError = false;
            //    #region 基礎資料
            //    try
            //    {
            //        int I公式件數總計 = (int)row.GetCell(IRowCount-2).NumericCellValue;
            //        int I數量增減 = (int)row.GetCell(IRowCount - 1).NumericCellValue;
            //        int I件數總計確認 = 0;
            //        int I件異動後總件數 = 0;
            //        for (int j = 0; j < IRowCount; j++)
            //        {
            //            if(j<2)
            //            {
            //                D_dataRow[j] = row.GetCell(j).ToString().Trim();
            //                D_DtCulDataRow[j] = row.GetCell(j).ToString().Trim();
            //                ListColor.Add(row.GetCell(j).ToString().Trim());
            //            }
            //            else
            //            {
            //                int icount = 0;
            //                try
            //                {
            //                    switch (row.GetCell(j).CellType)
            //                    {
            //                        case CellType.Numeric:
            //                        case CellType.Formula:
            //                            if (j < IRowCount - 2)
            //                            {
            //                                I件數總計確認 += (int)row.GetCell(j).NumericCellValue;
            //                                if (j == IRowCount - 2 && I件數總計確認 != I公式件數總計)
            //                                {
            //                                    BError = true;
            //                                    StrError = "件數不同:件數加總" + I件數總計確認.ToString() + ",公式加總" + I公式件數總計.ToString();
            //                                }
            //                                icount = (I數量增減 != 0) ? (int)((float)row.GetCell(j).NumericCellValue + ((float)row.GetCell(j).NumericCellValue / I公式件數總計) * I數量增減) : (int)row.GetCell(j).NumericCellValue;
            //                                //D_dataRow[j + IRowCount - 2] = icount;
            //                                D_DtCulDataRow[j] = icount;
            //                                I件異動後總件數 += icount;
            //                            }
            //                            if (j == IRowCount - 2)
            //                                D_DtCulDataRow[IRowCount - 2] = I件異動後總件數;
            //                            D_dataRow[j] = (int)row.GetCell(j).NumericCellValue;
            //                            break;
            //                        case CellType.Error:
            //                        default:
            //                            D_dataRow[j] = 0;
            //                            break;
            //                    }
            //                }
            //                catch (Exception ex2)
            //                {
            //                    F_ErrorShow(ex2.ToString());
            //                }


            //            }
            //        }
            //        D_table.Rows.Add(D_dataRow);
            //        DtCula.Rows.Add(D_DtCulDataRow);
            //        if (BError)
            //        {
            //            D_erroraRow[0] = "Row " + i.ToString() + " " + StrError;
            //            D_errortable.Rows.Add(D_erroraRow);
            //        }
            //    }
            //    catch (Exception ex)
            //    {
            //        F_ErrorShow(ex.ToString());
            //    }
            //    #endregion
            //}
            #endregion
        }
Ejemplo n.º 18
0
 public void UpdateSegment(ColorClass cc, float length, float posX, float thickness = 0.05f)
 {
     UpdateLength(length, posX, thickness);
     UpdateColor(cc);
 }
Ejemplo n.º 19
0
        protected override void OnPaint(PaintEventArgs e)
        {
            base.OnPaint(e);
            Graphics g = e.Graphics;

            if (_maxValue == 0)
            {
                return;
            }

            g.SmoothingMode = SmoothingMode.AntiAlias;

            Pen pen = new Pen(Color.FromArgb(220, 220, 220));

            int       cWidth  = Width - 1;
            int       cHeight = Height - 2;
            Rectangle recry   = new Rectangle(0, 0, cWidth, cHeight); //所有区域

            int PieAng = cWidth / 2;                                  //半圆大小

            decimal OnePercentHeight = (cHeight - PieAng) / Convert.ToDecimal(100);

            decimal perCent = _value / _maxValue * 100;//溶液占用比例

            perCent = perCent > 100 ? 100 : perCent;
            perCent = perCent == 0 ? 1 : perCent;
            int hvalue = (cHeight - PieAng / 2) - (int)(OnePercentHeight * perCent);    //溶液所在高度

            Rectangle rectTop = new Rectangle(0, 0, cWidth, PieAng);                    //容器 顶部椭圆区域

            Rectangle rectrTop = new Rectangle(0, hvalue - PieAng / 2, cWidth, PieAng); //溶液 顶部椭圆区域

            Rectangle rect = new Rectangle(0, cHeight - PieAng, cWidth, PieAng);        //溶液 底部

            LinearGradientBrush lbry    = new LinearGradientBrush(recry, ColorClass.GetColor(ryColor, 0, 0, 70, 10), ColorClass.GetColor(ryColor, 0, -12, -47, 9), LinearGradientMode.Horizontal);
            LinearGradientBrush brushrt = new LinearGradientBrush(recry, ColorClass.GetColor(ryColor, 0, 200, 200, 200), ColorClass.GetColor(ryColor, 0, -4, 70, 2), LinearGradientMode.Horizontal);
            //LinearGradientBrush brushempty = new LinearGradientBrush(recry, ColorClass.GetColor(emptyColor, -100, 200, 200, 200), ColorClass.GetColor(emptyColor, -100, -20, -20, -20), LinearGradientMode.Horizontal);
            LinearGradientBrush brushempty = new LinearGradientBrush(recry, Color.FromArgb(230, 230, 230), Color.FromArgb(200, 200, 200), LinearGradientMode.Horizontal);


            if (_value > 0)
            {
                GraphicsPath gp = new GraphicsPath();
                gp.AddArc(rect, 0, 180);
                gp.AddArc(rectrTop, 180, -180);
                gp.CloseFigure();
                g.FillPath(lbry, gp);             //溶液

                g.FillEllipse(brushrt, rectrTop); //溶液 顶部
            }
            else
            {
                g.DrawEllipse(new Pen(ColorClass.GetColor(emptyColor, 0, 0, 0, 0)), rectrTop); //溶液 顶部
                g.FillEllipse(brushempty, rectrTop);                                           //溶液 顶部

                GraphicsPath gp = new GraphicsPath();
                gp.AddArc(rect, 0, 180);
                gp.AddArc(rectrTop, 180, -180);
                gp.CloseFigure();
                g.FillPath(lbry, gp);             //溶液

                g.FillEllipse(brushrt, rectrTop); //溶液 顶部
            }

            if (_value < _maxValue)
            {
                GraphicsPath gp1 = new GraphicsPath();
                gp1.AddArc(rectTop, 0, 180);
                gp1.AddArc(rectrTop, -180, 180);
                gp1.CloseFigure();
                g.FillPath(brushempty, gp1);//溶液
            }

            g.DrawEllipse(pen, rectTop);//容器 顶部

            //if (_value > 0)
            //{
            StringFormat sf = new StringFormat();

            sf.Alignment     = StringAlignment.Center;
            sf.LineAlignment = StringAlignment.Center;
            sf.Trimming      = StringTrimming.EllipsisCharacter;
            g.DrawString(_value.ToString(), Font, new SolidBrush(ForeColor), rectrTop, sf);
            //}
        }