⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 displayratioform.cs

📁 在CSharpNotepad中可以创建和编辑简单文本文档
💻 CS
字号:
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;

namespace CSharpNotepad
{
    public partial class displayratioForm : Form
    {
        private mainForm _Owner;    //标记该子窗口的父窗口

        public displayratioForm()
        {
            InitializeComponent();
        }

        public displayratioForm(mainForm _Parent)
        {
            InitializeComponent();

            _Owner = _Parent;   //设置该子窗口的父窗口


        }

        private void displayratioForm_Load(object sender, EventArgs e)
        {
            for (int i = 1600; i >=10 ; i--)
            {
                string item = i.ToString() + "%";
                domainUpDown1.Items.Add(item);
            }

            this.richTextBox1.SelectionAlignment = HorizontalAlignment.Center;
            Clipboard.SetDataObject(Properties.Resources.demo);
            this.richTextBox1.Paste(DataFormats.GetFormat(DataFormats.Bitmap));
            this.richTextBox1.ReadOnly = true;

           this.richTextBox2.Text = "心想事成 AaBaCc\n心想事成 AaBaCc\n心想事成 AaBaCc\n心想事成 AaBaCc\n心想事成 AaBaCc\n心想事成 AaBaCc\n心想事成 AaBa"
                         + "Cc\n心想事成 AaBaCc\n心想事成 AaBaCc\n心想事成 AaBaCc";
        }


        private void okButton_Click(object sender, EventArgs e)
        {
            this._Owner.currentForm.richTextBox1.ZoomFactor = this.richTextBox1.ZoomFactor;
            this._Owner.tscbDisplayRatio.Text = this.domainUpDown1.Text;
            this.Close();
        }
        
        private void cancelButton_Click(object sender, EventArgs e)
        {
            this.Close();
        }

        private void radioButton1_CheckedChanged(object sender, EventArgs e)
        {
            this.domainUpDown1.Text = "200%";
        }

        private void radioButton2_CheckedChanged(object sender, EventArgs e)
        {
            this.domainUpDown1.Text = "100%";
        }

        private void radioButton3_CheckedChanged(object sender, EventArgs e)
        {
            this.domainUpDown1.Text = "75%";
        }

        private void radioButton4_CheckedChanged(object sender, EventArgs e)
        {
            this.domainUpDown1.Text = "114%";
        }

        private void radioButton5_CheckedChanged(object sender, EventArgs e)
        {
            this.domainUpDown1.Text = "159%";
        }

        private void radioButton6_CheckedChanged(object sender, EventArgs e)
        {
            this.domainUpDown1.Text = "50%";
        }
        
        private void domainUpDown1_KeyPress(object sender, KeyPressEventArgs e)
        {
            //e.KeyChar = 37 "%"
            if (e.KeyChar != (char)37)
            {
                if (!(Char.IsNumber(e.KeyChar) || e.KeyChar == (char)8))
                    e.Handled = true;
            }
            return;
        }

        private void domainUpDown1_TextChanged(object sender, EventArgs e)
        {
            string[] temp = this.domainUpDown1.Text.Split('%');

            if (temp[0] == "")
            {
                this.domainUpDown1.Text = "10%";
                return;
            }
            else
            {
                float ratio;

                this.domainUpDown1.Text = temp[0] + "%";
                ratio = float.Parse(temp[0]) / 100.0f;

                if (ratio <= 0.05)
                {
                    this.richTextBox1.ZoomFactor = 0.05f;
                    this.richTextBox2.ZoomFactor = 0.05f;
                }
                else if (ratio > 16.0)
                {
                    this.richTextBox1.ZoomFactor = 16.0f;
                    this.richTextBox2.ZoomFactor = 16.0f;
                }
                else
                {
                    this.richTextBox1.ZoomFactor = ratio;
                    this.richTextBox2.ZoomFactor = ratio;
                }
            }
        }
    }
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -