-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1 from arnab-sen/master
Created a small working example
- Loading branch information
Showing
3 changed files
with
143 additions
and
47 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,47 +1,55 @@ | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Linq; | ||
using System.Windows; | ||
using System.Windows.Media; | ||
using System.Windows.Shapes; | ||
using Libraries; | ||
using ProgrammingParadigms; | ||
using DomainAbstractions; | ||
|
||
namespace Application | ||
{ | ||
public class Application | ||
{ | ||
private MainWindow mainWindow = new MainWindow("AUT-Workshop-2020"); | ||
|
||
private Application Initialize() | ||
{ | ||
Wiring.PostWiringInitialize(); | ||
return this; | ||
} | ||
|
||
[STAThread] | ||
public static void Main() | ||
{ | ||
Application app = new Application(); | ||
app.Initialize().mainWindow.Run(); | ||
} | ||
|
||
private Application() | ||
{ | ||
// BEGIN AUTO-GENERATED INSTANTIATIONS FOR WiringDiagram.xmind | ||
// END AUTO-GENERATED INSTANTIATIONS FOR WiringDiagram.xmind | ||
|
||
// BEGIN AUTO-GENERATED WIRING FOR WiringDiagram.xmind | ||
// END AUTO-GENERATED WIRING FOR WiringDiagram.xmind | ||
|
||
// BEGIN manual instantiations | ||
|
||
// END manual instantiations | ||
|
||
// BEGIN manual wiring | ||
mainWindow.WireTo(new Text("Hello world.") { FontSize = 200 } ); | ||
// END manual wiring | ||
} | ||
} | ||
} | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Linq; | ||
using System.Windows; | ||
using System.Windows.Media; | ||
using System.Windows.Shapes; | ||
using Libraries; | ||
using ProgrammingParadigms; | ||
using DomainAbstractions; | ||
|
||
namespace Application | ||
{ | ||
public class Application | ||
{ | ||
private MainWindow mainWindow = new MainWindow("ALASandbox"); | ||
|
||
private Application Initialize() | ||
{ | ||
Wiring.PostWiringInitialize(); | ||
return this; | ||
} | ||
|
||
[STAThread] | ||
public static void Main() | ||
{ | ||
Application app = new Application(); | ||
app.Initialize().mainWindow.Run(); | ||
} | ||
|
||
private Application() | ||
{ | ||
// BEGIN AUTO-GENERATED INSTANTIATIONS FOR WiringDiagram.xmind | ||
FileReaderWriter id_ff00492ce4024f618f7632899e5f2568 = new FileReaderWriter("F:\\Projects\\Test\\test.txt" ) { InstanceName = "Default", WatchFile = true }; | ||
TextBox id_1a43d927cb44461e9c9419008b26dcbe = new TextBox() { InstanceName = "Default", Height = 300 }; | ||
TextBox id_2aeaeca5cbd147dc80410e3b98f6c9a3 = new TextBox() { InstanceName = "Default", Height = 300 }; | ||
Vertical id_60081e709ce64a2da8baae542eff69e0 = new Vertical() { InstanceName = "Default" }; | ||
// END AUTO-GENERATED INSTANTIATIONS FOR WiringDiagram.xmind | ||
|
||
// BEGIN AUTO-GENERATED WIRING FOR WiringDiagram.xmind | ||
mainWindow.WireTo(id_60081e709ce64a2da8baae542eff69e0, "iuiStructure"); // (@MainWindow (mainWindow).iuiStructure) -- [IUI] --> (Vertical (id_60081e709ce64a2da8baae542eff69e0).NEEDNAME) | ||
id_60081e709ce64a2da8baae542eff69e0.WireTo(id_1a43d927cb44461e9c9419008b26dcbe, "children"); // (Vertical (id_60081e709ce64a2da8baae542eff69e0).children) -- [List<IUI>] --> (TextBox (id_1a43d927cb44461e9c9419008b26dcbe).NEEDNAME) | ||
id_60081e709ce64a2da8baae542eff69e0.WireTo(id_2aeaeca5cbd147dc80410e3b98f6c9a3, "children"); // (Vertical (id_60081e709ce64a2da8baae542eff69e0).children) -- [List<IUI>] --> (TextBox (id_2aeaeca5cbd147dc80410e3b98f6c9a3).NEEDNAME) | ||
id_1a43d927cb44461e9c9419008b26dcbe.WireTo(id_ff00492ce4024f618f7632899e5f2568, "textOutput"); // (TextBox (id_1a43d927cb44461e9c9419008b26dcbe).textOutput) -- [IDataFlow<string>] --> (FileReaderWriter (id_ff00492ce4024f618f7632899e5f2568).contents) | ||
id_ff00492ce4024f618f7632899e5f2568.WireTo(id_2aeaeca5cbd147dc80410e3b98f6c9a3, "textContentOutput"); // (FileReaderWriter (id_ff00492ce4024f618f7632899e5f2568).textContentOutput) -- [IDataFlow<string>] --> (TextBox (id_2aeaeca5cbd147dc80410e3b98f6c9a3).NEEDNAME) | ||
// END AUTO-GENERATED WIRING FOR WiringDiagram.xmind | ||
|
||
// BEGIN manual instantiations | ||
|
||
// END manual instantiations | ||
|
||
// BEGIN manual wiring | ||
// END manual wiring | ||
} | ||
} | ||
} |
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,88 @@ | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Linq; | ||
using System.Text; | ||
using System.Threading.Tasks; | ||
using System.IO; | ||
using Libraries; | ||
using ProgrammingParadigms; | ||
|
||
namespace DomainAbstractions | ||
{ | ||
/// <summary> | ||
/// | ||
/// </summary> | ||
public class FileReaderWriter : IDataFlow<string>, IEvent | ||
{ | ||
// Public fields and properties | ||
public string InstanceName = "Default"; | ||
|
||
public bool WatchFile | ||
{ | ||
get => watcher.EnableRaisingEvents; | ||
set => watcher.EnableRaisingEvents = value; | ||
} | ||
|
||
// Private fields | ||
private string fullPath = ""; | ||
private string textContent = ""; | ||
private FileSystemWatcher watcher = new FileSystemWatcher(); | ||
|
||
// Ports | ||
private IDataFlow<string> textContentOutput; | ||
|
||
public FileReaderWriter(string url) | ||
{ | ||
fullPath = url; | ||
|
||
watcher.Path = Path.GetDirectoryName(fullPath); | ||
watcher.NotifyFilter = NotifyFilters.LastWrite; | ||
watcher.Filter = Path.GetFileName(fullPath); | ||
watcher.Changed += (sender, args) => | ||
{ | ||
try | ||
{ | ||
var contents = File.ReadAllText(fullPath); | ||
if (contents != textContent) | ||
{ | ||
textContent = contents; | ||
Push(contents); | ||
} | ||
} | ||
catch (IOException) | ||
{ | ||
} | ||
}; | ||
} | ||
|
||
private void WriteFileContents(string contents) | ||
{ | ||
textContent = contents; | ||
|
||
if (!File.Exists(fullPath)) File.WriteAllText(fullPath, ""); | ||
|
||
File.WriteAllText(fullPath, contents); | ||
} | ||
|
||
private void Push(string output) | ||
{ | ||
if (textContentOutput != null) textContentOutput.Data = output; | ||
} | ||
|
||
// IDataFlow<string> implementation | ||
string IDataFlow<string>.Data | ||
{ | ||
get => textContent; | ||
set | ||
{ | ||
WriteFileContents(value); | ||
} | ||
} | ||
|
||
// IEvent implementation | ||
void IEvent.Execute() | ||
{ | ||
WriteFileContents(""); | ||
} | ||
} | ||
} |