Exemple #1
0
    // Start is called before the first frame update
    void Start()
    {
        main = new Texture2D(16, 1);

        for (int i = 0; i < button.Length; i++)
        {
            button[i].onClick.AddListener(() =>
            {
                for (int j = 0; j < button.Length; j++)
                {
                    c[j] = new Color(Random.value, Random.value, Random.value);
                    button[j].GetComponent <Image>().color = c[j];
                    main = CTRL.SetNewBoxerTexture(c);
                }
            });
        }
    }
Exemple #2
0
        private static bool ConsoleCtrlHandler(CTRL sig)
        {
            WriteLine($"Exiting system due to external signal. CTRL_{sig}");
//			File.AppendAllText(@"Console.log", $"{DateTime.Now:yyyy-MM-dd HH:mm:ss} CTRL_{sig}");
            var e = new ConsoleExitEventArgs((ConsoleExitReason)sig);

            Exit?.Invoke(null, e);
            if (e.Cancel)
            {
                WriteLine("Exit canceled.");
                return(false);
            }

            WriteLine("Cleanup complete");
            //shutdown right away so there are no lingering threads
            Environment.Exit(0);
            return(true);
        }
Exemple #3
0
        /// <summary>
        /// 指定した文字列を内容に持つ、文字リテラル表記を取得します。
        /// </summary>
        /// <param name="content">文字リテラルの内容を指定します。</param>
        /// <returns>文字リテラル表記になった文字列を返します。</returns>
        public static string Characterize(string content)
        {
            System.Text.StringBuilder buf = new System.Text.StringBuilder();
            buf.Append('\'');

            for (int i = 0; i < content.Length; i++)
            {
                const string CTRL = "\a\b\r\n\f\v\t\0\\\'";
                const string ESC  = "abrnfvt0\\\'";
                int          ind  = CTRL.IndexOf(content[i]);
                if (ind < 0)
                {
                    buf.Append(content[i]);
                    continue;
                }

                buf.Append('\\');
                buf.Append(ESC[ind]);
            }

            buf.Append('\'');
            return(buf.ToString());
        }
        public static bool GetValidate(Control myContainer)
        {
            bool myResult = true;

            foreach (Control CTRL in myContainer.Controls)
            {
                // error checking code :
                // 0. eror provider title for error message
                // 1. empty value (text for textbox, combobox. and any checked item for checkbox)
                // 2. text value format. [0] = not checked, [1], cant be zero, [2] cant be negative, [3] cant be positive, [4] phone format, [5] email format
                // 3. date check. [0] not checked, [1] cant be same as today, [2] cant be smaller than today, [3] cant be greater than today
                // 1;Nama Login,1,0-,0-

                // 1
                //Nama Login,1,0-,0-

                //Nama Login
                //1
                //1-5
                //0-
                if (CTRL.Tag != null)
                {
                    myError.SetIconAlignment(CTRL, ErrorIconAlignment.MiddleRight);
                    myError.SetIconPadding(CTRL, 2);
                    myError.BlinkStyle = ErrorBlinkStyle.NeverBlink;
                    myError.SetError(CTRL, string.Empty);

                    string[] TagString = CTRL.Tag.ToString().Split(Convert.ToChar(";"));
                    string[] TagCode   = TagString[1].ToString().Split(Convert.ToChar(","));
                    string[] TextCode  = TagCode[2].ToString().Split(Convert.ToChar("-"));
                    string[] DateCode  = TagCode[3].ToString().Split(Convert.ToChar("-"));

                    switch (CTRL.GetType().Name.ToString())
                    {
                    case ("TextBox"):
                        if (TagCode[1] == "1" && string.IsNullOrEmpty((CTRL as TextBox).Text))
                        {
                            myError.SetError(CTRL, TagCode[0] + " tidak boleh kosong");
                            myResult = false;
                        }

                        int n;
                        if (Convert.ToInt32(TextCode[0]) > 0 && int.TryParse((CTRL as TextBox).Text, out n) == false)
                        {
                            myError.SetError(CTRL, TagCode[0] + " harus berisi numerik");
                            myResult = false;
                            break;
                        }
                        else
                        {
                            for (int i = 1; i < TextCode.Length; i++)
                            {
                                switch (TextCode[i])
                                {
                                case ("1"):
                                    if ((CTRL as TextBox).Text == "0")
                                    {
                                        myError.SetError(CTRL, TagCode[0] + " tidak boleh berisi 0");
                                        myResult = false;
                                    }
                                    break;

                                case ("2"):
                                    if (Convert.ToInt32((CTRL as TextBox).Text) < 0)
                                    {
                                        myError.SetError(CTRL, TagCode[0] + " tidak boleh negatif");
                                        myResult = false;
                                    }
                                    break;

                                case ("3"):
                                    if (Convert.ToInt32((CTRL as TextBox).Text) > 0)
                                    {
                                        myError.SetError(CTRL, TagCode[0] + " tidak boleh positif");
                                        myResult = false;
                                    }
                                    break;

                                case ("4"):
                                    // check phone format with regex
                                    //										if (Convert.ToInt32((CTRL as TextBox).Text) < 0)
                                    //										{
                                    //											MyError.SetError(CTRL, TagCode[0] + " tidak angka negatif");
                                    //											MyResult = false;
                                    //										}
                                    break;

                                case ("5"):
                                    // check email format with regex
                                    //										if (Convert.ToInt32((CTRL as TextBox).Text) < 0)
                                    //										{
                                    //											MyError.SetError(CTRL, TagCode[0] + " tidak angka negatif");
                                    //											MyResult = false;
                                    //										}
                                    break;
                                }
                            }
                        }
                        break;

                    case ("CheckedListBox"):
                        if (TagCode[1] == "1" && (CTRL as CheckedListBox).SelectedItems.Count < 1)
                        {
                            myError.SetError(CTRL, TagCode[0] + " harus dipilih salah satu");
                            myResult = false;
                        }
                        break;
                    }
                }
            }
            return(myResult);
        }