資源簡(jiǎn)介
自己使用VS2017開(kāi)發(fā)環(huán)境,C#語(yǔ)言編寫(xiě)的多進(jìn)制計(jì)算器,可以實(shí)現(xiàn)二進(jìn)制、十進(jìn)制、十六進(jìn)制的數(shù)字運(yùn)算和邏輯運(yùn)算,以及進(jìn)制之間的轉(zhuǎn)化,現(xiàn)將源代碼分享給大家,有需要的小伙伴可以參考下

代碼片段和文件信息
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;
????????}
????????//聲明數(shù)據(jù)格式類(lèi)型
????????private?enum?DisplayFormat
????????{
????????????HEX?=?0
????????????DEC?=?1
????????????BIN?=?2
????????}
????????//聲明字符類(lèi)型
????????private?enum?CharType
????????{
????????????NONE?=?0
????????????NUM?=?1
????????????BINARYOPERATOR?=?2?????//雙目運(yùn)算符
????????????BRACKET
????????}
????????private?DisplayFormat?displayFormat?=?DisplayFormat.HEX;
????????private?CharType?lastCharType?=?CharType.NONE;
????????private?string?lastChar?=?“0“;
????????private?string?strexpression?=?““;????????//用于顯示輸入表達(dá)式
????????private?string?strHexResult?=?“0“;
????????private?string?strDecResult?=?“0“;
????????private?string?strBinResult?=?“0“;
????????private?long?result?=?0;
????????private?byte?resultLength?=?8;?????//默認(rèn)4字節(jié)存儲(chǔ)
????????private?int?leftBracketNum?=?0;
????????private?int?rightBracketNum?=?0;
????????//定時(shí)器每10ms刷新一次
????????private?void?timer1_Tick(object?sender?EventArgs?e)
????????{
????????????Point?pos?=?MousePosition;????????//獲取鼠標(biāo)的絕對(duì)坐標(biāo)
????????????int?intResult?=?0;
????????????short?shortResult?=?0;
????????????sbyte?byteResult?=?0;
????????????//刷新十六進(jìn)制區(qū)域
????????????Rectangle?rec?=?PnlHex.ClientRectangle;???????
????????????rec.Offset(PointToScreen(PnlHex.Location));???//獲取PnlHex控件所在長(zhǎng)方形區(qū)域
????????????if?(rec.Contains(pos))
????????????{
????????????????PnlHex.BackColor?=?Color.LightGray;
????????????????PnlHexIndicate.BackColor?=?Color.LightGray;
????????????}
????????????else
????????????{?
????????????????PnlHex.BackColor?=?SystemColors.Control;
????????????????PnlHexIndicate.BackColor?=?SystemColors.Control;
????????????}
????????????
????????????//刷新十進(jìn)制區(qū)域
????????????rec?=?PnlDec.ClientRectangle;
????????????rec.Offset(PointToScreen(PnlDec.Location));???//獲取PnlDec控件所在長(zhǎng)方形區(qū)域
????????????if?(rec.Contains(pos))
????????????{
????????????????PnlDec.BackColor?=?Color.LightGray;
????????????????PnlDecIndicate.BackColor?=?Color.LightGray;
????????????}
????????????else
????????????{
????????????????PnlDec.BackColor?=?SystemColors.Control;
????????????????PnlDecIndicate.BackColor?=?SystemColors.Control;
????????????}
????????????//刷新二進(jìn)制區(qū)域
????????????rec?=?PnlBin.ClientRectangle;
????????????rec.Offset(PointToScreen(PnlBin.Location));???//獲取PnlBin控件所在長(zhǎng)方形區(qū)域
????????????if?(rec.Contains(pos))
????????????{
????????????????PnlBin.BackColor?=?Color.LightGray;
????????????????PnlBinIndicate.BackColor?=?Color.LightGray;
????????????}
????????????else
????????????{
?????????
?屬性????????????大小?????日期????時(shí)間???名稱(chēng)
-----------?---------??----------?-----??----
????..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.MSsc
?????文件???????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個(gè)文件信息
評(píng)論
共有 條評(píng)論