Skip to content

Commit

Permalink
add goofball wpf app, move some code
Browse files Browse the repository at this point in the history
  • Loading branch information
doubleyewdee committed Sep 29, 2018
1 parent 56f21d7 commit 59b5306
Show file tree
Hide file tree
Showing 16 changed files with 507 additions and 14 deletions.
8 changes: 7 additions & 1 deletion ConsoleBuffer.sln
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,9 @@ Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio 15
VisualStudioVersion = 15.0.28010.2036
MinimumVisualStudioVersion = 10.0.40219.1
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ConsoleBuffer", "ConsoleBuffer\ConsoleBuffer.csproj", "{A16D11B0-4785-434F-8514-ABCC16DDFBFD}"
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ConsoleBuffer", "src\ConsoleBuffer\ConsoleBuffer.csproj", "{A16D11B0-4785-434F-8514-ABCC16DDFBFD}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "condo", "src\condo\condo.csproj", "{D890EB09-11B9-41A8-B9A7-C1D159312A32}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Expand All @@ -15,6 +17,10 @@ Global
{A16D11B0-4785-434F-8514-ABCC16DDFBFD}.Debug|Any CPU.Build.0 = Debug|Any CPU
{A16D11B0-4785-434F-8514-ABCC16DDFBFD}.Release|Any CPU.ActiveCfg = Release|Any CPU
{A16D11B0-4785-434F-8514-ABCC16DDFBFD}.Release|Any CPU.Build.0 = Release|Any CPU
{D890EB09-11B9-41A8-B9A7-C1D159312A32}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{D890EB09-11B9-41A8-B9A7-C1D159312A32}.Debug|Any CPU.Build.0 = Debug|Any CPU
{D890EB09-11B9-41A8-B9A7-C1D159312A32}.Release|Any CPU.ActiveCfg = Release|Any CPU
{D890EB09-11B9-41A8-B9A7-C1D159312A32}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
Expand Down
File renamed without changes.
Original file line number Diff line number Diff line change
@@ -1,14 +1,27 @@
namespace ConsoleBuffer
{
using System;
using System.ComponentModel;
using System.IO;
using System.Runtime.InteropServices;
using System.Threading.Tasks;
using Microsoft.Win32.SafeHandles;

public sealed class ConsoleWrapper : IDisposable
public sealed class ConsoleWrapper : IDisposable, INotifyPropertyChanged
{
public string Contents { get; private set; }
private string contents;
public string Contents
{
get
{
return this.contents;
}
set
{
this.contents = value;
this.OnPropertyChanged(nameof(Contents));
}
}

public string Command { get; private set; }

Expand Down Expand Up @@ -134,19 +147,34 @@ private static void ThrowForHResult(int hr, string exceptionMessage)
throw new InvalidOperationException($"{exceptionMessage}: {Marshal.GetHRForLastWin32Error()}");
}

#region IDisposable Support
#region INotifyPropertyChanged
public event PropertyChangedEventHandler PropertyChanged;
public void OnPropertyChanged(string name)
{
this.PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(name));
}
#endregion

#region IDisposable
private bool disposed = false; // To detect redundant calls

void Dispose(bool disposing)
{
if (!this.disposed)
{
this.disposed = true;
if (disposing)
{
this.readHandle?.Dispose();
this.readHandle = null;
this.writeHandle?.Dispose();
this.writeHandle = null;
}

// We want to clear out managed resources first to allow our reader task to die naturally from having the other side of its
// pipe closed.
if (this.processInfo.hProcess != IntPtr.Zero)
{
// XXX: maybe don't?
NativeMethods.TerminateProcess(this.processInfo.hProcess, uint.MaxValue);

NativeMethods.CloseHandle(this.processInfo.hProcess);
this.processInfo.hProcess = IntPtr.Zero;
}
Expand All @@ -169,13 +197,7 @@ void Dispose(bool disposing)
this.startupInfo.lpAttributeList = IntPtr.Zero;
}

if (disposing)
{
this.readHandle?.Dispose();
this.readHandle = null;
this.writeHandle?.Dispose();
this.writeHandle = null;
}
this.disposed = true;
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,9 @@ internal static extern bool CreateProcess(string lpApplicationName, string lpCom
ref SECURITY_ATTRIBUTES lpThreadAttributes, bool bInheritHandles, uint dwCreationFlags,
IntPtr lpEnvironment, string lpCurrentDirectory, [In] ref STARTUPINFOEX lpStartupInfo,
out PROCESS_INFORMATION lpProcessInformation);
[DllImport("kernel32.dll")]
[return: MarshalAs(UnmanagedType.Bool)]
internal static extern bool TerminateProcess(IntPtr hProcess, uint exitCode);

[DllImport("kernel32.dll", SetLastError = true)]
[return: MarshalAs(UnmanagedType.Bool)]
Expand Down
File renamed without changes.
6 changes: 6 additions & 0 deletions src/condo/App.config
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<startup>
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.7.2" />
</startup>
</configuration>
9 changes: 9 additions & 0 deletions src/condo/App.xaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
<Application x:Class="condo.App"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:local="clr-namespace:condo"
StartupUri="MainWindow.xaml">
<Application.Resources>

</Application.Resources>
</Application>
17 changes: 17 additions & 0 deletions src/condo/App.xaml.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
using System;
using System.Collections.Generic;
using System.Configuration;
using System.Data;
using System.Linq;
using System.Threading.Tasks;
using System.Windows;

namespace condo
{
/// <summary>
/// Interaction logic for App.xaml
/// </summary>
public partial class App : Application
{
}
}
12 changes: 12 additions & 0 deletions src/condo/MainWindow.xaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
<Window x:Class="condo.MainWindow"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:local="clr-namespace:condo"
mc:Ignorable="d"
Title="MainWindow" Height="450" Width="800">
<Grid>
<TextBox Background="Black" Foreground="Gray" Name="stuff" Text="{Binding Content}"/>
</Grid>
</Window>
34 changes: 34 additions & 0 deletions src/condo/MainWindow.xaml.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;

namespace condo
{
/// <summary>
/// Interaction logic for MainWindow.xaml
/// </summary>
public partial class MainWindow : Window
{
private ConsoleBuffer.ConsoleWrapper consoleWrapper;

public MainWindow()
{
InitializeComponent();

this.consoleWrapper = new ConsoleBuffer.ConsoleWrapper("debian run yes");
this.stuff.DataContext = this.consoleWrapper;
this.stuff.Text = this.consoleWrapper.Contents;
}
}
}
55 changes: 55 additions & 0 deletions src/condo/Properties/AssemblyInfo.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
using System.Reflection;
using System.Resources;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using System.Windows;

// General Information about an assembly is controlled through the following
// set of attributes. Change these attribute values to modify the information
// associated with an assembly.
[assembly: AssemblyTitle("condo")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("condo")]
[assembly: AssemblyCopyright("Copyright © 2018")]
[assembly: AssemblyTrademark("")]
[assembly: AssemblyCulture("")]

// Setting ComVisible to false makes the types in this assembly not visible
// to COM components. If you need to access a type in this assembly from
// COM, set the ComVisible attribute to true on that type.
[assembly: ComVisible(false)]

//In order to begin building localizable applications, set
//<UICulture>CultureYouAreCodingWith</UICulture> in your .csproj file
//inside a <PropertyGroup>. For example, if you are using US english
//in your source files, set the <UICulture> to en-US. Then uncomment
//the NeutralResourceLanguage attribute below. Update the "en-US" in
//the line below to match the UICulture setting in the project file.

//[assembly: NeutralResourcesLanguage("en-US", UltimateResourceFallbackLocation.Satellite)]


[assembly: ThemeInfo(
ResourceDictionaryLocation.None, //where theme specific resource dictionaries are located
//(used if a resource is not found in the page,
// or application resource dictionaries)
ResourceDictionaryLocation.SourceAssembly //where the generic resource dictionary is located
//(used if a resource is not found in the page,
// app, or any theme specific resource dictionaries)
)]


// Version information for an assembly consists of the following four values:
//
// Major Version
// Minor Version
// Build Number
// Revision
//
// You can specify all the values or you can default the Build and Revision Numbers
// by using the '*' as shown below:
// [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("1.0.0.0")]
[assembly: AssemblyFileVersion("1.0.0.0")]
71 changes: 71 additions & 0 deletions src/condo/Properties/Resources.Designer.cs

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit 59b5306

Please sign in to comment.