コード例 #1
0
ファイル: Form1.cs プロジェクト: shaiatias/learning-c-sharp
        public int[] CallToServer(IndexColorType tempIndexColorType)
        {
            int[] returnArr = null;
            if (tempIndexColorType.mColor.R != 0 && Form1.ServerColor.Name == "Red"
                ||
                tempIndexColorType.mColor.G != 0 && Form1.ServerColor.Name == "Green"
                ||
                tempIndexColorType.mColor.B != 0 && Form1.ServerColor.Name == "Blue")
            {
                if (tempIndexColorType.mType == "Button")
                {
                    ButtonSortedList.Add(tempIndexColorType.mColor.R + tempIndexColorType.mColor.G + tempIndexColorType.mColor.B + Form1.ServerRand.Next(1000) * 0.00001, tempIndexColorType.mIndex);
                }
                else
                {
                    LabelSortedList.Add(tempIndexColorType.mColor.R + tempIndexColorType.mColor.G + tempIndexColorType.mColor.B + Form1.ServerRand.Next(1000) * 0.00001, tempIndexColorType.mIndex);
                }

                returnArr = new int[ButtonSortedList.Count + LabelSortedList.Count];
                int k = 0;
                for (int i = 0; i < ButtonSortedList.Count; i++)
                {
                    returnArr[k++] = (int)(ButtonSortedList.GetByIndex(i));
                }
                for (int i = 0; i < LabelSortedList.Count; i++)
                {
                    returnArr[k++] = (int)(LabelSortedList.GetByIndex(i));
                }
            }
            return(returnArr);
        }
コード例 #2
0
        private void allControls_Click(object sender, EventArgs e)
        {
            Control        tempControl        = (Control)sender;
            IndexColorType tempIndexColorType = new IndexColorType();

            tempIndexColorType.mIndex = tempControl.TabIndex;
            tempIndexColorType.mColor = tempControl.BackColor;
            tempIndexColorType.mType  = tempControl.GetType().Name;
            int[] resultArr = myICommon.CallToServer(tempIndexColorType);
            if (resultArr == null)
            {
                return;
            }
            int currPosition = 3;

            for (int i = 0; i < resultArr.Length; i++)
            {
                arrControls[resultArr[i]].Location = new Point(currPosition, 50);
                currPosition += 42;
            }
        }