예제 #1
0
        public static string ConvertValue(GraphicsUnit from, GraphicsUnit to, string strText)
        {
            if (from == to)
            {
                return(strText);
            }

            strText = strText.Trim();
            if (string.IsNullOrEmpty(strText) == true)
            {
                return("");
            }

#if NO
            if (strText.IndexOfAny(new char[] { ',' }) != -1)
            {
                strError = "内容中不能使用中文逗号。应该使用西文逗号";
                return(-1);
            }
#endif
            strText = strText.Replace(",", ","); // 将中文逗号替换为西文逗号

            string[]      numbers = strText.Split(new char[] { ',' });
            StringBuilder text    = new StringBuilder();
            int           i       = 0;
            foreach (string number in numbers)
            {
                if (i > 0)
                {
                    text.Append(",");
                }

                decimal v = 0;
                if (decimal.TryParse(number, out v) == false)
                {
                    text.Append(number);
                }
                else
                {
                    text.Append(UniverseNumericUpDown.ConvertValue(from, to, v).ToString());
                }

                i++;
            }

            return(text.ToString());
        }
예제 #2
0
        protected override void OnHandleCreated(EventArgs e)
        {
            base.OnHandleCreated(e);

            if (this.toolTip1 == null)
            {
                this.toolTip1 = new System.Windows.Forms.ToolTip();
            }

            if (string.IsNullOrEmpty(this._unitString) == true)
            {
                this._unitString = UniverseNumericUpDown.GetUnitString(this.CurrentUnit);
            }

            if (this.toolTip1 != null &&
                string.IsNullOrEmpty(this._unitString) == false)
            {
                this.toolTip1.SetToolTip(this, this._unitString);
            }
        }