treeview字体扩大缩小

来源:互联网 发布:tf家族官方淘宝网 编辑:程序博客网 时间:2024/05/01 07:39

        private void tsbZoomIn_Click(object sender, EventArgs e)
        {
            try
            {
                //字体を拡大する
                this.trv.Font = new System.Drawing.Font("MS UI Gothic", ++fontSize, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(128)));
                this.trv.ItemHeight = this.trv.ItemHeight + 2;
            }
            catch (Exception ex)
            {
                StackFrame fr = new StackFrame(true);
                Log.WriteLine(fr.GetMethod().ReflectedType.FullName + "_" + fr.GetMethod().Name, ex.Message, LogLevel.Error);
            }
        }

        private void tsbZoomOut_Click(object sender, EventArgs e)
        {
            try
            {
                //字体を縮小する
                if (fontSize == 1.0)
                {
                    return;
                }
                this.trv.Font = new System.Drawing.Font("MS UI Gothic", --fontSize, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(128)));
                this.trv.ItemHeight = this.trv.ItemHeight - 2;
            }
            catch (Exception ex)
            {
                StackFrame fr = new StackFrame(true);
                Log.WriteLine(fr.GetMethod().ReflectedType.FullName + "_" + fr.GetMethod().Name, ex.Message, LogLevel.Error);
            }
        }

        private void tsbDefault_Click(object sender, EventArgs e)
        {
            try
            {
                //字体を回復する
                fontSize = 9F;
                this.trv.Font = new System.Drawing.Font("MS UI Gothic", fontSize, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(128)));
                this.trv.ItemHeight = 20;
            }
            catch (Exception ex)
            {
                StackFrame fr = new StackFrame(true);
                Log.WriteLine(fr.GetMethod().ReflectedType.FullName + "_" + fr.GetMethod().Name, ex.Message, LogLevel.Error);
            }
        }