Skip to content

Commit

Permalink
Break out more behavior in the logger into a stdlog, netlog, and mors…
Browse files Browse the repository at this point in the history
…e practice document.
  • Loading branch information
Kirk Goddard committed May 11, 2021
1 parent 3345e68 commit 788086b
Show file tree
Hide file tree
Showing 6 changed files with 115 additions and 17 deletions.
1 change: 1 addition & 0 deletions Editor/EditWindow2.cs
Expand Up @@ -2211,6 +2211,7 @@ public void ScrollTo( EDGE eEdge )
break;
}

SelectionClear();
if( oLine != null ) {
CaretPos.Line = oLine;
CaretPos.Offset = iOffset;
Expand Down
23 changes: 14 additions & 9 deletions Mjolnir/MainWin.cs
Expand Up @@ -528,13 +528,14 @@ protected class MainWinDocSlot : IPgBaseSite, IDocSlot {
_oTopMenu.Items.Add( oFileMenu );

List<ToolStripMenuItem> rgSubMenu = new List<ToolStripMenuItem>();
rgSubMenu.Add( new ToolStripMenuItem("Html", BitmapCreateFromChar( "\xE12b" ), new EventHandler(this.OnDocNewHtml )));
rgSubMenu.Add( new ToolStripMenuItem("Text", BitmapCreateFromChar( "\xE185" ), new EventHandler(this.OnDocNewText )));
rgSubMenu.Add( new ToolStripMenuItem("M3u", BitmapCreateFromChar( "\xE189" ), new EventHandler(this.OnDocNewM3u )));
rgSubMenu.Add( new ToolStripMenuItem("Scraps",BitmapCreateFromChar( "\xE0a5" ), new EventHandler(this.OnDocNewScraps)));
rgSubMenu.Add( new ToolStripMenuItem("Morse", BitmapCreateFromChar( "\xE113" ), new EventHandler(this.OnDocNewMorse )));
rgSubMenu.Add( new ToolStripMenuItem("Log", BitmapCreateFromChar( "\xE113" ), new EventHandler(this.OnDocNewLogger)));
rgSubMenu.Add( new ToolStripMenuItem("SSTV", BitmapCreateFromChar( "\xE114" ), new EventHandler(this.OnDocNewSSTV )));
rgSubMenu.Add( new ToolStripMenuItem("Html", BitmapCreateFromChar( "\xE12b" ), new EventHandler(this.OnDocNewHtml )));
rgSubMenu.Add( new ToolStripMenuItem("Text", BitmapCreateFromChar( "\xE185" ), new EventHandler(this.OnDocNewText )));
rgSubMenu.Add( new ToolStripMenuItem("M3u", BitmapCreateFromChar( "\xE189" ), new EventHandler(this.OnDocNewM3u )));
rgSubMenu.Add( new ToolStripMenuItem("Scraps", BitmapCreateFromChar( "\xE0a5" ), new EventHandler(this.OnDocNewScraps)));
rgSubMenu.Add( new ToolStripMenuItem("Morse", BitmapCreateFromChar( "\xE113" ), new EventHandler(this.OnDocNewMorse )));
rgSubMenu.Add( new ToolStripMenuItem("Net Log", BitmapCreateFromChar( "\xE113" ), new EventHandler(this.OnDocNewNetLogger)));
rgSubMenu.Add( new ToolStripMenuItem("Std Log", BitmapCreateFromChar( "\xE113" ), new EventHandler(this.OnDocNewStdLogger)));
rgSubMenu.Add( new ToolStripMenuItem("SSTV", BitmapCreateFromChar( "\xE114" ), new EventHandler(this.OnDocNewSSTV )));

oFileMenu.DropDownItems.Add(new ToolStripMenuItem("New", BitmapCreateFromChar( "\xE295" ), rgSubMenu.ToArray() ) );
oFileMenu.DropDownItems.Add(new ToolStripMenuItem( "Open...", BitmapCreateFromChar( "\xE132" ), new EventHandler(this.OnDocOpen), Keys.Control | Keys.O ));
Expand Down Expand Up @@ -938,8 +939,12 @@ protected override void OnClosing(CancelEventArgs e)
EditorInitNewShow( ".morse" );
}

public void OnDocNewLogger( object sender, EventArgs e ) {
EditorInitNewShow( ".mlog" );
public void OnDocNewNetLogger( object sender, EventArgs e ) {
EditorInitNewShow( ".netlog" );
}

public void OnDocNewStdLogger( object sender, EventArgs e ) {
EditorInitNewShow( ".stdlog" );
}

public void OnDocNewSSTV( object sender, EventArgs e ) {
Expand Down
1 change: 1 addition & 0 deletions Mjolnir/Program.cs
Expand Up @@ -1115,6 +1115,7 @@ public IEnumerator<string> EnumFileExtensions()
Controllers.Add( new Play.MusicWalker .M3uController() );
Controllers.Add( new Play.MorsePractice.MorseController() );
Controllers.Add( new Play.MorsePractice.MorseController2() );
Controllers.Add( new Play.MorsePractice.MorseController3() );
Controllers.Add( new Play.Clock .SolarController() );
Controllers.Add( new Play.SSTV .MySSTVController() );
}
Expand Down
55 changes: 53 additions & 2 deletions MorsePractice/Controller.cs
Expand Up @@ -6,6 +6,10 @@

namespace Play.MorsePractice
{
/// <summary>
/// This is the simple more code practice document. Which was the original reason I wrote
/// all this.
/// </summary>
public class MorseController :
Controller
{
Expand Down Expand Up @@ -69,11 +73,11 @@ public class MorseController2 :
protected readonly static Guid _guidSchedule = new Guid( "{7E7AAEE2-154F-4876-AD5B-7DA80E1A1055}" );

public MorseController2() {
_rgExtensions.Add( ".mlog" );
_rgExtensions.Add( ".netlog" );
}

public override IDisposable CreateDocument( IPgBaseSite oSite, string strExtension ) {
if( strExtension.ToLower() == ".mlog" ) {
if( strExtension.ToLower() == ".netlog" ) {
return( new DocNotes( oSite ) );
}

Expand Down Expand Up @@ -127,4 +131,51 @@ public class MorseController2 :
yield return new ViewType( "Logger", ViewLog.ViewLogger );
}
}

public class MorseController3 :
Controller
{
protected readonly static Guid _guidRawBio = new Guid( "{e6bfe197-9cbd-43cc-9098-4a8db5b19066}" );
protected readonly static Guid _guidRawPage = new Guid( "{2c71fdb9-c842-4df3-8f55-7fdffbb757bc}" );
protected readonly static Guid _guidSchedule = new Guid( "{7E7AAEE2-154F-4876-AD5B-7DA80E1A1055}" );

public MorseController3() {
_rgExtensions.Add( ".stdlog" );
}

public override IDisposable CreateDocument( IPgBaseSite oSite, string strExtension ) {
if( strExtension.ToLower() == ".stdlog" ) {
return new DocNotes( oSite ) { ScanCallsFlag = false };
}

return null;
}

public override IDisposable CreateView( IPgViewSite oBaseSite, object oDocument, Guid guidViewType ) {
DocNotes oMorsePractice = oDocument as DocNotes ?? throw new ArgumentException( "Argument must be an ImageWalkerDoc" );

try {
switch( guidViewType ) {
case Guid r when r == ViewSimple._guidViewCategory:
return new ViewSimple(oBaseSite, oMorsePractice);

default:
return new ViewSimple(oBaseSite, oMorsePractice );
}
} catch( Exception oEx ) {
Type[] rgErrors = { typeof( NullReferenceException ),
typeof( InvalidCastException ),
typeof( ArgumentNullException ),
typeof( ArgumentException ) };
if( rgErrors.IsUnhandled( oEx ) )
throw;

throw new InvalidOperationException( "Controller couldn't create view for Image document.", oEx );
}
}

public override IEnumerator<IPgViewType> GetEnumerator() {
yield return new ViewType( "Notes", ViewSimple._guidViewCategory );
}
}
}
17 changes: 11 additions & 6 deletions MorsePractice/DocMorse.cs
Expand Up @@ -269,6 +269,7 @@ protected class MorseDocSlot :
readonly Line _oDataGram = new TextLine( 0, string.Empty );
readonly Grammer<char> _oCiVGrammar;
readonly DatagramParser _oParse;
public bool ScanCallsFlag { get; set; } = true;

int _iFrequencyLast = -1;
Dictionary <int, RepeaterDir> _rgRepeaters = new Dictionary<int, RepeaterDir>();
Expand Down Expand Up @@ -386,6 +387,7 @@ public struct RepeaterDir {
Properties.UpdateValue( 0, "Timer triggered..." );
_oTaskTimer.Queue( ListenForTimout( oRepeater.Timeout ), 0 );
} else {
Properties.UpdateValue( 0, "Stopped." );
_oTaskTimer.Stop(); // stopped talking most likely.
}
_iFrequencyLast = iFrequency;
Expand Down Expand Up @@ -543,13 +545,14 @@ public struct RepeaterDir {
}

protected void InitRepeaters() {
List< RepeaterDir > _rgTemp = new List<RepeaterDir>();
List< RepeaterDir > rgTemp = new List<RepeaterDir>();

_rgTemp.Add( new RepeaterDir( 146960000, -600000, 180 ));
_rgTemp.Add( new RepeaterDir( 53170000, -1700000, 120 ));
_rgTemp.Add( new RepeaterDir( 146820000, -600000, 120 ));
rgTemp.Add( new RepeaterDir( 146960000, -600000, 180 ));
rgTemp.Add( new RepeaterDir( 53170000, -1700000, 120 ));
rgTemp.Add( new RepeaterDir( 146820000, -600000, 120 ));
rgTemp.Add( new RepeaterDir( 52870000, -1700000, 180 ));

foreach( RepeaterDir oItem in _rgTemp ) {
foreach( RepeaterDir oItem in rgTemp ) {
_rgRepeaters.Add( oItem.Input, oItem );
}
}
Expand Down Expand Up @@ -587,7 +590,9 @@ public struct RepeaterDir {

// Note: Change this to trigger after a notes parse.
//_oTaskSched.Queue( EnumCallsScanTask(), 3000 );
Notes.BufferEvent += Notes_BufferEvent;
if( ScanCallsFlag ) {
Notes.BufferEvent += Notes_BufferEvent;
}

if( !CallSign.InitNew())
return false;
Expand Down
35 changes: 35 additions & 0 deletions MorsePractice/ViewNotes.cs
Expand Up @@ -45,6 +45,41 @@ class ViewBio : EditWin {
}
}

public class ViewSimple : EditWindow2 {
public static readonly Guid _guidViewCategory = new Guid("{868D414A-5614-4D9D-8F7E-C46D85BCE294}");

public override Guid Catagory => _guidViewCategory;

protected readonly DocNotes _oDocMorse;

public ViewSimple(IPgViewSite oSiteView, DocNotes oDocument ) :
base( oSiteView, oDocument.Notes )
{
_oDocMorse = oDocument ?? throw new ArgumentNullException( "Document must not be null.");
}

public override object Decorate( IPgViewSite oBaseSite, Guid sGuid ) {
try {
if( sGuid.Equals( GlobalDecorations.Properties ) ) {
return new ViewStandardProperties( oBaseSite, _oDocMorse.Properties );
}
return base.Decorate(oBaseSite, sGuid);
} catch (Exception oEx) {
Type[] rgErrors = { typeof( NotImplementedException ),
typeof( NullReferenceException ),
typeof( ArgumentException ),
typeof( ArgumentNullException ) };
if (rgErrors.IsUnhandled(oEx))
throw;

LogError("decor", "Couldn't create EditWin decor: " + sGuid.ToString());
}

return (null);
}

}

/// <summary>
/// This is a stand alone document view to be used to show the notes.
/// </summary>
Expand Down

0 comments on commit 788086b

Please sign in to comment.