• 大小: 278KB
    文件类型: .rar
    金币: 2
    下载: 1 次
    发布日期: 2021-06-13
  • 语言: C#
  • 标签: C#  

资源简介

自己使用VS2017开发环境,C#语言编写的多进制计算器,可以实现二进制、十进制、十六进制的数字运算和逻辑运算,以及进制之间的转化,现将源代码分享给大家,有需要的小伙伴可以参考下

资源截图

代码片段和文件信息

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Text.Regularexpressions;
using System.Threading.Tasks;
using System.Windows.Forms;

namespace Calc
{
    public partial class Calc : Form
    {
        public Calc()
        {
            InitializeComponent();
            timer1.Interval = 10;
            timer1.Enabled = true;
        }

        //声明数据格式类型
        private enum DisplayFormat
        {
            HEX = 0
            DEC = 1
            BIN = 2
        }

        //声明字符类型
        private enum CharType
        {
            NONE = 0
            NUM = 1
            BINARYOPERATOR = 2     //双目运算符
            BRACKET
        }

        private DisplayFormat displayFormat = DisplayFormat.HEX;
        private CharType lastCharType = CharType.NONE;
        private string lastChar = “0“;
        private string strexpression = ““;        //用于显示输入表达式
        private string strHexResult = “0“;
        private string strDecResult = “0“;
        private string strBinResult = “0“;
        private long result = 0;
        private byte resultLength = 8;     //默认4字节存储
        private int leftBracketNum = 0;
        private int rightBracketNum = 0;


        //定时器每10ms刷新一次
        private void timer1_Tick(object sender EventArgs e)
        {
            Point pos = MousePosition;        //获取鼠标的绝对坐标
            int intResult = 0;
            short shortResult = 0;
            sbyte byteResult = 0;

            //刷新十六进制区域
            Rectangle rec = PnlHex.ClientRectangle;       
            rec.Offset(PointToScreen(PnlHex.Location));   //获取PnlHex控件所在长方形区域
            if (rec.Contains(pos))
            {
                PnlHex.BackColor = Color.LightGray;
                PnlHexIndicate.BackColor = Color.LightGray;
            }
            else
            { 
                PnlHex.BackColor = SystemColors.Control;
                PnlHexIndicate.BackColor = SystemColors.Control;
            }
            
            //刷新十进制区域
            rec = PnlDec.ClientRectangle;
            rec.Offset(PointToScreen(PnlDec.Location));   //获取PnlDec控件所在长方形区域
            if (rec.Contains(pos))
            {
                PnlDec.BackColor = Color.LightGray;
                PnlDecIndicate.BackColor = Color.LightGray;
            }
            else
            {
                PnlDec.BackColor = SystemColors.Control;
                PnlDecIndicate.BackColor = SystemColors.Control;
            }

            //刷新二进制区域
            rec = PnlBin.ClientRectangle;
            rec.Offset(PointToScreen(PnlBin.Location));   //获取PnlBin控件所在长方形区域
            if (rec.Contains(pos))
            {
                PnlBin.BackColor = Color.LightGray;
                PnlBinIndicate.BackColor = Color.LightGray;
            }
            else
            {
         

 属性            大小     日期    时间   名称
----------- ---------  ---------- -----  ----

    ..A..H.     60928  2018-09-09 15:33  Calc\.vs\Calc\v15\.suo

     文件          0  2018-08-12 23:35  Calc\.vs\Calc\v15\Server\sqlite3\db.lock

     文件     630784  2018-09-09 10:32  Calc\.vs\Calc\v15\Server\sqlite3\storage.ide

     文件      32768  2018-09-09 15:31  Calc\.vs\Calc\v15\Server\sqlite3\storage.ide-shm

     文件    4128272  2018-09-09 15:34  Calc\.vs\Calc\v15\Server\sqlite3\storage.ide-wal

     文件        189  2018-08-12 20:40  Calc\Calc\App.config

     文件      33280  2018-09-09 15:32  Calc\Calc\bin\Debug\Calc.exe

     文件        189  2018-08-12 20:40  Calc\Calc\bin\Debug\Calc.exe.config

     文件      42496  2018-09-09 15:32  Calc\Calc\bin\Debug\Calc.pdb

     文件      14848  2018-09-06 15:53  Calc\Calc\bin\Debug\Interop.MSscriptControl.dll

     文件       5632  2018-08-26 12:50  Calc\Calc\bin\Debug\RoundRect.dll

     文件      13824  2018-08-26 12:50  Calc\Calc\bin\Debug\RoundRect.pdb

     文件       6144  2018-08-12 20:12  Calc\Calc\bin\Debug\WindowsFormsControlLibrary1.dll

     文件      29975  2018-09-09 15:32  Calc\Calc\Calc.cs

     文件       4270  2018-09-06 15:56  Calc\Calc\Calc.csproj

     文件        144  2018-08-12 20:54  Calc\Calc\Calc.csproj.user

     文件      53630  2018-09-09 15:32  Calc\Calc\Calc.Designer.cs

     文件      17014  2018-09-09 15:32  Calc\Calc\Calc.resx

     文件       1716  2018-09-09 15:32  Calc\Calc\obj\Debug\Calc.Calc.resources

     文件          0  2018-09-09 15:32  Calc\Calc\obj\Debug\Calc.csproj.CopyComplete

     文件         42  2018-09-06 15:53  Calc\Calc\obj\Debug\Calc.csproj.CoreCompileInputs.cache

     文件       3499  2018-09-06 15:56  Calc\Calc\obj\Debug\Calc.csproj.FileListAbsolute.txt

     文件       1011  2018-09-09 15:32  Calc\Calc\obj\Debug\Calc.csproj.GenerateResource.cache

     文件        777  2018-09-06 15:53  Calc\Calc\obj\Debug\Calc.csproj.ResolveComReference.cache

     文件      55731  2018-08-30 11:50  Calc\Calc\obj\Debug\Calc.csprojAssemblyReference.cache

     文件      11236  2018-08-26 14:08  Calc\Calc\obj\Debug\Calc.csprojResolveAssemblyReference.cache

     文件      33280  2018-09-09 15:32  Calc\Calc\obj\Debug\Calc.exe

     文件      42496  2018-09-09 15:32  Calc\Calc\obj\Debug\Calc.pdb

     文件        180  2018-09-06 15:56  Calc\Calc\obj\Debug\Calc.Properties.Resources.resources

     文件       5898  2018-09-08 10:05  Calc\Calc\obj\Debug\DesignTimeResolveAssemblyReferences.cache

............此处省略30个文件信息

评论

共有 条评论