Skip to content

Commit

Permalink
Improved icons, small bugfixes.
Browse files Browse the repository at this point in the history
  • Loading branch information
Baltasarq committed Jul 8, 2017
1 parent 1f3c115 commit 044a0d5
Show file tree
Hide file tree
Showing 28 changed files with 893 additions and 723 deletions.
5 changes: 4 additions & 1 deletion CSim.csproj
Expand Up @@ -219,7 +219,10 @@
<MonoDevelop>
<Properties>
<Policies>
<DotNetNamingPolicy DirectoryNamespaceAssociation="PrefixedHierarchical" ResourceNamePolicy="FileFormatDefault" />
<DotNetNamingPolicy ResourceNamePolicy="FileFormatDefault" DirectoryNamespaceAssociation="PrefixedHierarchical">
<inheritsSet />
<inheritsScope />
</DotNetNamingPolicy>
</Policies>
</Properties>
</MonoDevelop>
Expand Down
2 changes: 1 addition & 1 deletion Core/AppInfo.cs
Expand Up @@ -9,7 +9,7 @@ public static class AppInfo
/// <summary>Author of the app.</summary>
public const string Author = "jbgarcia@uvigo.es";
/// <summary>Version of the app.</summary>
public const string Version = "1.4 20170401";
public const string Version = "1.5 20170711";
/// <summary>Website for this app.</summary>
public const string Web = "http://webs.uvigo.es/jbgarcia/prys/csim/";
/// <summary>Extension for files created by this app.</summary>
Expand Down
52 changes: 52 additions & 0 deletions Core/ExtensionMethods.cs
Expand Up @@ -80,6 +80,58 @@ public static BigInteger ToBigInteger(this object value)
return toret;
}

/// <summary>
/// Tries to convert anything to a double, without exceptions,
/// unless impossible.
/// </summary>
/// <returns>The double value.</returns>
/// <param name="value">A primitive, probably boxed.</param>
public static double ToDouble(this object value)
{
double toret = 0.0;

if ( value == null ) {
throw new ArgumentException( "trying to convert null to double" );
}

if ( value is float
|| value is double )
{
toret = (double) value;
}
else
if ( value is sbyte
|| value is byte
|| value is short
|| value is ushort
|| value is int
|| value is uint
|| value is long
|| value is ulong )
{
toret = Convert.ToDouble( value );
}
else
if ( value is BigInteger ) {
toret = ( (double) ( (BigInteger) value ) );
} else {
throw new ArgumentException( "cannot convert to double from: " + value.GetType() );
}

return toret;
}

/// <summary>
/// Tries to convert anything to a float, without exceptions,
/// unless impossible.
/// </summary>
/// <returns>The float value.</returns>
/// <param name="value">A primitive, probably boxed.</param>
public static float ToFloat(this object value)
{
return (float) value.ToDouble();
}

/// <summary>
/// Converts a <see cref="BigInteger"/> to a byte.
/// Overflow is allowed, so for example from a 128bit value
Expand Down
2 changes: 1 addition & 1 deletion Core/Literals/DoubleLiteral.cs
Expand Up @@ -13,7 +13,7 @@ public class DoubleLiteral: Literal {
/// <param name="m">The <see cref="Machine"/>.</param>
/// <param name="x">A given double.</param>
public DoubleLiteral(Machine m, object x)
:this( m, System.Convert.ToDouble( x ) )
:this( m, x.ToDouble() )
{
}

Expand Down
2 changes: 1 addition & 1 deletion Core/Literals/FloatLiteral.cs
Expand Up @@ -14,7 +14,7 @@ public class FloatLiteral: Literal {
/// <param name="m">The <see cref="Machine"/>.</param>
/// <param name="x">A given double.</param>
public FloatLiteral(Machine m, object x)
:this( m, System.Convert.ToSingle( x ) )
:this( m, x.ToFloat() )
{
}

Expand Down
7 changes: 5 additions & 2 deletions Core/Native/Int128.cs
Expand Up @@ -2,9 +2,9 @@
// Int128.cs
//
// Author:
// Simon Mourier
// Simon Mourier
// Adapted by:
// baltasarq <baltasarq@gmail.com>
// baltasarq <baltasarq@gmail.com>
//
// Copyright (c) 2017 baltasarq
//
Expand All @@ -30,6 +30,7 @@ namespace CSim.Core {
using System;
using System.Numerics;

/// <summary>Represents 64 bits integer values.</summary>
public struct Int128 {
/// <summary>The length in bytes for this integer's
/// binary representation.</summary>
Expand Down Expand Up @@ -129,12 +130,14 @@ public Int128(BigInteger value)
{
}

/// <summary>Gets the value as a <see cref="BigInteger"/>.</summary>
public BigInteger Value {
get {
return new BigInteger();
}
}

/// <summary>Gets the representation in bytes.</summary>
public byte[] Bytes {
get {
return this.Value.ToByteArray();
Expand Down
Binary file modified Res/appIcon.ico
Binary file not shown.
Binary file modified Res/appIcon.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified Res/back.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified Res/dec.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified Res/diagram.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified Res/help.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified Res/hex.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified Res/info.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified Res/memory.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified Res/open.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified Res/play.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added Res/question.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified Res/random.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified Res/reset.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified Res/save.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified Res/settings.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified Res/stop.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified Res/zero.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified Res/zoom_in.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified Res/zoom_out.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
113 changes: 55 additions & 58 deletions Ui/MainWindow.cs
Expand Up @@ -333,8 +333,7 @@ private void ShowSettings()

// UI
this.tbIconBar.Hide();
this.pnlMain.Hide();
this.pnlIO.Hide();
this.splMain.Hide();
this.pnlSettings.Show();
this.cbLocales.Focus();
this.SetStatus( L18n.Get( L18n.Id.ActSettings ) );
Expand Down Expand Up @@ -395,8 +394,7 @@ private void ApplySettings()
this.UpdateView();
this.pnlSettings.Hide();
this.tbIconBar.Show();
this.pnlMain.Show();
this.pnlIO.Show();
this.splMain.Show();
this.SetStatus();
this.FocusOnInput();
}
Expand All @@ -416,14 +414,14 @@ private void DoReset()

private void DoOpen()
{
var dlg = new OpenFileDialog();
var dlg = new OpenFileDialog() {
Title = "Load session",
Filter = AppInfo.Name + "|*." + AppInfo.FileExt + "|*|*.*",
CheckFileExists = true,
FileName = Path.GetFullPath( CurrentDir )
};

dlg.Title = "Load session";
dlg.Filter = AppInfo.Name + "|*." + AppInfo.FileExt + "|*|*.*";
dlg.CheckFileExists = true;
dlg.FileName = Path.GetFullPath( CurrentDir );

this.SetStatus();
this.SetStatus();
if ( dlg.ShowDialog() == DialogResult.OK ) {
this.DoReset();

Expand Down Expand Up @@ -451,13 +449,13 @@ private void DoOpen()

private void DoSave()
{
var dlg = new SaveFileDialog();
var dlg = new SaveFileDialog() {
Title = "Save session",
Filter = AppInfo.Name + "|*." + AppInfo.FileExt + "|*|*.*",
FileName = Path.GetFullPath( CurrentDir )
};

dlg.Title = "Save session";
dlg.Filter = AppInfo.Name + "|*." + AppInfo.FileExt + "|*|*.*";
dlg.FileName = Path.GetFullPath( CurrentDir );

if ( dlg.ShowDialog() == DialogResult.OK ) {
if ( dlg.ShowDialog() == DialogResult.OK ) {
using( var writer = new StreamWriter( dlg.FileName, false ) )
{
foreach(string s in this.lbHistory.Items) {
Expand Down Expand Up @@ -512,15 +510,18 @@ private void UpdateWatches()

if ( !string.IsNullOrEmpty( input ) ) {
try {
result = this.machine.Execute( new ExpressionParser( input, this.machine ) );
result = this.machine.Execute(
new ExpressionParser( input, this.machine ) );

// Update output
lblWatch.ForeColor = Color.Navy;
lblWatch.ForeColor = SystemColors.InfoText;
lblWatch.BackColor = SystemColors.Info;
lblWatch.Text = result.Value.ToString();
}
catch(EngineException)
{
lblWatch.ForeColor = Color.DarkRed;
lblWatch.ForeColor = SystemColors.GrayText;
lblWatch.BackColor = SystemColors.Window;
lblWatch.Text = "ERROR";
}
}
Expand All @@ -538,7 +539,7 @@ private void UpdateSymbolTable()
if ( vble is TempVariable ) {
continue;
}

string varTypeAddr = vble.Type.Name + " :" + vble.Type.Size
+ " ["
+ FromIntToPrettyHex( vble.Address, this.machine.WordSize )
Expand Down Expand Up @@ -591,6 +592,19 @@ private int CharWidth
return this.charWidth;
}
}

private int CharHeight
{
get {
if ( this.charHeight == -1 ) {
Graphics grf = this.CreateGraphics();
SizeF fontSize = grf.MeasureString( "H", this.Font );
this.charHeight = (int) fontSize.Height +5;
}

return this.charHeight;
}
}

private void DoDrawing()
{
Expand Down Expand Up @@ -750,6 +764,11 @@ private void Execute(string input)
{
this.PrintError( exc.Message );
}
#if !DEBUG
catch(Exception exc) {
this.PrintError( "ERROR (internal): " + exc.Message );
}
#endif
finally {
this.UpdateView();
}
Expand All @@ -762,43 +781,20 @@ private void ChangeUILanguage(CultureInfo locale)
L18n.SetLanguage( locale );

// Toolbar buttons
ToolBar.ToolBarButtonCollection tbButtons = this.tbIconBar.Buttons;
for(int i = 0; i < tbButtons.Count; ++i) {
ToolBarButton button = tbButtons[ i ];

switch( i ) {
case 0: button.ToolTipText = L18n.Get( L18n.Id.ActReset );
break;
case 1: button.ToolTipText = L18n.Get( L18n.Id.ActOpen );
break;
case 2: button.ToolTipText = L18n.Get( L18n.Id.ActSave );
break;
case 3: button.ToolTipText = L18n.Get( L18n.Id.ActInHex );
break;
case 4: button.ToolTipText = L18n.Get( L18n.Id.ActInDec );
break;
case 5: button.ToolTipText = L18n.Get( L18n.Id.ActZoomIn );
break;
case 6: button.ToolTipText = L18n.Get( L18n.Id.ActZoomOut );
break;
case 7: button.ToolTipText = L18n.Get( L18n.Id.ActShowMemory );
break;
case 8: button.ToolTipText = L18n.Get( L18n.Id.ActShowDiagram );
break;
case 9: button.ToolTipText = L18n.Get( L18n.Id.ActSettings );
break;
case 10: button.ToolTipText = L18n.Get( L18n.Id.ActHelp );
break;
case 11: button.ToolTipText = L18n.Get( L18n.Id.ActAbout );
break;
case 12: button.ToolTipText = L18n.Get( L18n.Id.ActPlay );
break;
case 13: button.ToolTipText = L18n.Get( L18n.Id.ActStop );
break;
default:
throw new ArgumentException( "unexpected toolbar button: unhandled" );
}
}
this.tbbReset.ToolTipText = L18n.Get( L18n.Id.ActReset );
this.tbbOpen.ToolTipText = L18n.Get( L18n.Id.ActOpen );
this.tbbSave.ToolTipText = L18n.Get( L18n.Id.ActSave );
this.tbbHex.ToolTipText = L18n.Get( L18n.Id.ActInHex );
this.tbbDec.ToolTipText = L18n.Get( L18n.Id.ActInDec );
this.tbbZoomIn.ToolTipText = L18n.Get( L18n.Id.ActZoomIn );
this.tbbZoomOut.ToolTipText = L18n.Get( L18n.Id.ActZoomOut );
this.tbbMemory.ToolTipText = L18n.Get( L18n.Id.ActShowMemory );
this.tbbDiagram.ToolTipText = L18n.Get( L18n.Id.ActShowDiagram );
this.tbbStop.ToolTipText = L18n.Get( L18n.Id.ActStop );
this.tbbPlay.ToolTipText = L18n.Get( L18n.Id.ActPlay );
this.tbbSettings.ToolTipText = L18n.Get( L18n.Id.ActSettings );
this.tbbHelp.ToolTipText = L18n.Get( L18n.Id.ActHelp );
this.tbbAbout.ToolTipText = L18n.Get( L18n.Id.ActAbout );

// Tabbed panel
this.tcTabs.TabPages[ 0 ].Text = L18n.Get( L18n.Id.ActShowMemory );
Expand All @@ -820,6 +816,7 @@ private static string FromIntToPrettyHex(BigInteger value, int wordSize = 1)

private bool doNotApplySnapshot;
private int charWidth = -1;
private int charHeight = -1;
private Machine machine;
private SchemaDrawer sdDrawingBoard;
private string cfgFile = "";
Expand Down

0 comments on commit 044a0d5

Please sign in to comment.