資源簡介
自己使用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.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個文件信息
- 上一篇:C# 通用自動更新程序含源碼
- 下一篇:C# 實現的實時獲取DOS輸出結果程序
評論
共有 條評論