Updated to v1.1.0.0

master v1.1.0.0
Jonatan Nilsson 2014-03-16 19:05:31 +00:00
parent b3da45eb94
commit eda4064af3
20 changed files with 431 additions and 221 deletions

View File

@ -3,14 +3,16 @@
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:converters="clr-namespace:ProgramQueuer.Helpers" xmlns:converters="clr-namespace:ProgramQueuer.Helpers"
xmlns:properties="clr-namespace:ProgramQueuer.Properties" xmlns:properties="clr-namespace:ProgramQueuer.Properties"
Title="MainWindow" Title="Program Queuer"
Closing="Window_Closing" Closing="Window_Closing"
AllowDrop="True" AllowDrop="True"
DragEnter="ListView_DragEnter" Drop="ListView_Drop" DragEnter="ListView_DragEnter" Drop="ListView_Drop"
Loaded="Window_Loaded"
Width="{Binding Path=width, Source={x:Static properties:Settings.Default}, Mode=TwoWay}" Width="{Binding Path=width, Source={x:Static properties:Settings.Default}, Mode=TwoWay}"
Height="{Binding Path=height, Source={x:Static properties:Settings.Default}, Mode=TwoWay}" Loaded="Window_Loaded" Icon="/ProgramQueuer;component/reports.ico"> Height="{Binding Path=height, Source={x:Static properties:Settings.Default}, Mode=TwoWay}" Icon="/ProgramQueuer;component/program.ico" StateChanged="Window_StateChanged">
<Window.Resources> <Window.Resources>
<converters:BoolToVisibility x:Key="boolToVisible" /> <converters:BoolToVisibility x:Key="boolToVisible" />
<converters:BooleanInverter x:Key="BooleanInverter" />
<converters:ValueConverterGroup x:Key="boolInvertedToVisible"> <converters:ValueConverterGroup x:Key="boolInvertedToVisible">
<converters:BooleanInverter /> <converters:BooleanInverter />
<converters:BoolToVisibility /> <converters:BoolToVisibility />
@ -18,9 +20,9 @@
</Window.Resources> </Window.Resources>
<Grid> <Grid>
<Grid.RowDefinitions> <Grid.RowDefinitions>
<RowDefinition Height="{Binding Path=split_height, Source={x:Static properties:Settings.Default}, Mode=OneWay}" />
<RowDefinition Height="9" />
<RowDefinition Height="*" /> <RowDefinition Height="*" />
<RowDefinition Height="9" />
<RowDefinition Height="Auto" />
<RowDefinition Height="Auto" /> <RowDefinition Height="Auto" />
</Grid.RowDefinitions> </Grid.RowDefinitions>
<Grid> <Grid>
@ -35,7 +37,7 @@
<GridViewColumn.CellTemplate> <GridViewColumn.CellTemplate>
<DataTemplate> <DataTemplate>
<StackPanel Orientation="Horizontal"> <StackPanel Orientation="Horizontal">
<Image Height="16" Width="16" Source="/ProgramQueuer;component/Resources/play.png" Visibility="{Binding Path=Working, Converter={StaticResource boolToVisible}}" /> <!--<Image Height="16" Width="16" Source="/ProgramQueuer;component/Resources/play.png" Visibility="{Binding Path=Working, Converter={StaticResource boolToVisible}}" />-->
<Image Height="16" Width="16" Source="/ProgramQueuer;component/Resources/application.png" Visibility="{Binding Path=Finished, Converter={StaticResource boolInvertedToVisible}}" /> <Image Height="16" Width="16" Source="/ProgramQueuer;component/Resources/application.png" Visibility="{Binding Path=Finished, Converter={StaticResource boolInvertedToVisible}}" />
<Image Height="16" Width="16" Source="/ProgramQueuer;component/Resources/accept.png" Visibility="{Binding Path=Finished, Converter={StaticResource boolToVisible}}" /> <Image Height="16" Width="16" Source="/ProgramQueuer;component/Resources/accept.png" Visibility="{Binding Path=Finished, Converter={StaticResource boolToVisible}}" />
</StackPanel> </StackPanel>
@ -59,6 +61,9 @@
<Button Margin="0 0 6 0" BorderBrush="Transparent" Background="Transparent" Visibility="{Binding Path=Working, Converter={StaticResource boolToVisible}}" Click="buttonStopCurrent_Click"> <Button Margin="0 0 6 0" BorderBrush="Transparent" Background="Transparent" Visibility="{Binding Path=Working, Converter={StaticResource boolToVisible}}" Click="buttonStopCurrent_Click">
<Image Height="16" Width="16" Source="/ProgramQueuer;component/Resources/stop.png" /> <Image Height="16" Width="16" Source="/ProgramQueuer;component/Resources/stop.png" />
</Button> </Button>
<Button Margin="0 0 6 0" BorderBrush="Transparent" Background="Transparent" Visibility="{Binding Path=Working, Converter={StaticResource boolInvertedToVisible}}" Click="buttonStartCurrent_Click">
<Image Height="16" Width="16" Source="/ProgramQueuer;component/Resources/force_run.png" />
</Button>
<!--<Button Margin="0 0 6 0" BorderBrush="Transparent" Background="Transparent"> <!--<Button Margin="0 0 6 0" BorderBrush="Transparent" Background="Transparent">
<Image Height="16" Width="16" Source="/ProgramQueuer;component/Resources/window.png" /> <Image Height="16" Width="16" Source="/ProgramQueuer;component/Resources/window.png" />
</Button>--> </Button>-->
@ -76,15 +81,40 @@
</GridView> </GridView>
</ListView.View> </ListView.View>
</ListView> </ListView>
<StackPanel Grid.Column="1"> <StackPanel Grid.Column="1" Orientation="Vertical">
<Button Margin="0 6 6 6" BorderBrush="Transparent" Background="Transparent" Visibility="{Binding Path=Working, Converter={StaticResource boolInvertedToVisible}}" Click="buttonAdd_Click"> <Button Margin="0 6 6 6" BorderBrush="Transparent" Background="Transparent" Click="buttonAdd_Click" ToolTip="Add a Program to the batch">
<Image Height="16" Width="16" Source="/ProgramQueuer;component/Resources/add.png" /> <Image Height="16" Width="16" Source="/ProgramQueuer;component/Resources/add.png" />
</Button> </Button>
<Button x:Name="buttonEmpty" Margin="0 6 6 6" BorderBrush="Transparent" Background="Transparent" Click="buttonClear_Click" ToolTip="Clear list">
<Image Height="16" Width="16" Source="/ProgramQueuer;component/Resources/trash-icon.png" />
</Button>
<Popup HorizontalOffset="-228" VerticalOffset="0" Width="250" Height="Auto" x:Name="popupEmpty" PlacementTarget="{Binding ElementName=buttonEmpty}" StaysOpen="False">
<Border Background="White" BorderBrush="LightGray" BorderThickness="1">
<StackPanel>
<Button BorderBrush="Transparent" Background="Transparent" Click="buttonClearFinished_Click">Remove Finished Entries</Button>
<Button BorderBrush="Transparent" Background="Transparent" Click="buttonClearAll_Click" IsEnabled="{Binding Path=Working, Converter={StaticResource BooleanInverter}}">Remove All Entries</Button>
</StackPanel>
</Border>
</Popup>
</StackPanel> </StackPanel>
</Grid> </Grid>
<GridSplitter ResizeDirection="Rows" Grid.Row="1" BorderThickness="1" Background="Transparent" HorizontalAlignment="Stretch" VerticalAlignment="Stretch" DragCompleted="GridSplitter_DragCompleted" /> <GridSplitter ResizeDirection="Rows" Grid.Row="1" BorderThickness="1" Background="Transparent" HorizontalAlignment="Stretch" VerticalAlignment="Stretch" DragCompleted="GridSplitter_DragCompleted" />
<GroupBox Grid.Row="2" Margin="6 0 6 6" Header="Output" Padding="0 3 0 0"> <GroupBox Grid.Row="2" Margin="6 0 6 6" Padding="0 3 0 0">
<TextBox x:Name="textboxStatus" AcceptsReturn="True" IsReadOnly="True" Background="Black" Foreground="White" Text="{Binding Path=SelectedItem.Output, ElementName=listPrograms}" TextChanged="TextBox_TextChanged" VerticalScrollBarVisibility="Auto" HorizontalScrollBarVisibility="Auto" FontFamily="Fixedsys Excelsior 2.00"> <GroupBox.Header>
<StackPanel Orientation="Horizontal">
<TextBlock>Output</TextBlock>
<CheckBox x:Name="checkboxOverrideOutput" Margin="6 2 0 0" IsChecked="{Binding Path=RedirectOutput, Mode=TwoWay}" IsEnabled="{Binding Path=Working, Converter={StaticResource BooleanInverter}}" Checked="checkboxOverrideOutput_Checked" Unchecked="checkboxOverrideOutput_Unchecked">Override Console Window</CheckBox>
<Button x:Name="buttonHelp" Margin="6 0 0 0" BorderBrush="Transparent" Background="#01FFFFFF" Cursor="Help" Visibility="{Binding Path=Working, Converter={StaticResource boolInvertedToVisible}}" Click="ButtonHelp_Click">
<Image Height="16" Width="16" Source="/ProgramQueuer;component/Resources/help.png" />
</Button>
<Popup HorizontalOffset="0" VerticalOffset="0" Width="350" Height="Auto" x:Name="popupHelp" PlacementTarget="{Binding ElementName=buttonHelp}" StaysOpen="False">
<Border BorderBrush="DarkGray" BorderThickness="1" Background="White">
<TextBlock Margin="6" TextWrapping="Wrap">Controls whether the cmd (command line window) is displayed or not.<LineBreak /><LineBreak />If this is checked, ProgramQueuer will hide the window and transfer all output in the textbox below.<LineBreak /><LineBreak />If this is not checked, the original cmd window is displayed.</TextBlock>
</Border>
</Popup>
</StackPanel>
</GroupBox.Header>
<TextBox Height="{Binding Path=split_height, Source={x:Static properties:Settings.Default}, Mode=OneWay}" x:Name="textboxStatus" AcceptsReturn="True" IsReadOnly="True" Background="Black" Foreground="White" Text="{Binding Path=SelectedItem.Output, ElementName=listPrograms}" TextChanged="TextBox_TextChanged" VerticalScrollBarVisibility="Auto" HorizontalScrollBarVisibility="Auto" FontFamily="Fixedsys Excelsior 2.00">
</TextBox> </TextBox>
</GroupBox> </GroupBox>

View File

@ -1,7 +1,9 @@
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Drawing;
using System.Linq; using System.Linq;
using System.Text; using System.Text;
using System.IO;
using System.Windows; using System.Windows;
using System.Windows.Controls; using System.Windows.Controls;
using System.Windows.Data; using System.Windows.Data;
@ -11,8 +13,13 @@ using System.Windows.Media;
using System.Windows.Media.Imaging; using System.Windows.Media.Imaging;
using System.Windows.Navigation; using System.Windows.Navigation;
using System.Windows.Shapes; using System.Windows.Shapes;
using System.Resources;
using System.Windows.Threading;
using ProgramQueuer.Queuer; using ProgramQueuer.Queuer;
using WPF.JoshSmith.ServiceProviders.UI; using WPF.JoshSmith.ServiceProviders.UI;
using Microsoft.Win32;
using NotifyIcon = System.Windows.Forms.NotifyIcon;
namespace ProgramQueuer namespace ProgramQueuer
{ {
@ -22,24 +29,45 @@ namespace ProgramQueuer
public partial class MainWindow : Window public partial class MainWindow : Window
{ {
EntryManager _manager; EntryManager _manager;
OpenFileDialog _openFile;
NotifyIcon _icon;
public MainWindow() public MainWindow()
{ {
InitializeComponent(); InitializeComponent();
_manager = new EntryManager(); _manager = new EntryManager();
_openFile = new OpenFileDialog { Filter = "All Files (*.*)|*.*",
CheckFileExists = true,
Multiselect = true,
InitialDirectory = ProgramQueuer.Properties.Settings.Default.lastPath };
this._icon = new NotifyIcon { Icon = Properties.Resources.program, Visible = true };
this._icon.MouseClick += new System.Windows.Forms.MouseEventHandler(_icon_MouseClick);
this.DataContext = _manager; this.DataContext = _manager;
this.listPrograms.ItemsSource = _manager.QueueList; this.listPrograms.ItemsSource = _manager.QueueList;
} }
void _icon_MouseClick(object sender, System.Windows.Forms.MouseEventArgs e)
{
this.Visibility = System.Windows.Visibility.Visible;
Application.Current.Dispatcher.BeginInvoke(DispatcherPriority.Background,
new Action(delegate()
{
this.WindowState = WindowState.Normal;
this.Activate();
})
);
}
private void Window_Loaded(object sender, RoutedEventArgs e) private void Window_Loaded(object sender, RoutedEventArgs e)
{ {
_manager.RedirectOutput = ProgramQueuer.Properties.Settings.Default.redirectOutput;
new ListViewDragDropManager<ProgramEntry>(this.listPrograms); new ListViewDragDropManager<ProgramEntry>(this.listPrograms);
} }
private void GridSplitter_DragCompleted(object sender, System.Windows.Controls.Primitives.DragCompletedEventArgs e) private void GridSplitter_DragCompleted(object sender, System.Windows.Controls.Primitives.DragCompletedEventArgs e)
{ {
ProgramQueuer.Properties.Settings.Default.split_height = (int)((sender as GridSplitter).Parent as Grid).RowDefinitions[2].Height.Value; ProgramQueuer.Properties.Settings.Default.split_height = textboxStatus.Height;
} }
private void Window_Closing(object sender, System.ComponentModel.CancelEventArgs e) private void Window_Closing(object sender, System.ComponentModel.CancelEventArgs e)
@ -50,6 +78,11 @@ namespace ProgramQueuer
e.Cancel = true; e.Cancel = true;
return; return;
} }
else
_manager.ForceStop();
this._icon.Visible = false;
ProgramQueuer.Properties.Settings.Default.redirectOutput = _manager.RedirectOutput;
ProgramQueuer.Properties.Settings.Default.lastPath = _openFile.InitialDirectory;
ProgramQueuer.Properties.Settings.Default.Save(); ProgramQueuer.Properties.Settings.Default.Save();
} }
@ -87,6 +120,7 @@ namespace ProgramQueuer
foreach (string file in files) foreach (string file in files)
{ {
_manager.QueueList.Add(new ProgramEntry { Name = file , Status = "Queued"}); _manager.QueueList.Add(new ProgramEntry { Name = file , Status = "Queued"});
_openFile.InitialDirectory = new FileInfo(file).DirectoryName;
} }
} }
} }
@ -98,9 +132,19 @@ namespace ProgramQueuer
private void buttonStopCurrent_Click(object sender, RoutedEventArgs e) private void buttonStopCurrent_Click(object sender, RoutedEventArgs e)
{ {
if (MessageBox.Show("Are you sure you want to stop current running process and continue to next?", "Stop current worker?", MessageBoxButton.YesNo) == MessageBoxResult.Yes) if (_manager.CurrentEntry == ((sender as Control).DataContext as ProgramEntry))
{ {
_manager.ForceStopCurrent(); if (MessageBox.Show("Are you sure you want to kill this process and continue with the next one available?", "Stop current process?", MessageBoxButton.YesNo) == MessageBoxResult.Yes)
{
((sender as Control).DataContext as ProgramEntry).Process.Kill();
}
}
else
{
if (MessageBox.Show("Are you sure you want to kill this process?", "Stop selected process?", MessageBoxButton.YesNo) == MessageBoxResult.Yes)
{
((sender as Control).DataContext as ProgramEntry).Process.Kill();
}
} }
} }
@ -112,7 +156,80 @@ namespace ProgramQueuer
private void buttonAdd_Click(object sender, RoutedEventArgs e) private void buttonAdd_Click(object sender, RoutedEventArgs e)
{ {
if (_openFile.ShowDialog() == true)
{
foreach (string file in _openFile.FileNames)
{
_manager.QueueList.Add(new ProgramEntry { Name = file, Status = "Queued" });
_openFile.InitialDirectory = new FileInfo(file).DirectoryName;
}
}
}
private void checkboxOverrideOutput_Checked(object sender, RoutedEventArgs e)
{
if (textboxStatus != null)
textboxStatus.Visibility = Visibility.Visible;
}
private void checkboxOverrideOutput_Unchecked(object sender, RoutedEventArgs e)
{
if (textboxStatus != null)
textboxStatus.Visibility = Visibility.Collapsed;
}
private void ButtonHelp_Click(object sender, RoutedEventArgs e)
{
popupHelp.IsOpen = true;
}
private void buttonStartCurrent_Click(object sender, RoutedEventArgs e)
{
_manager.RunProgram((sender as Control).DataContext as ProgramEntry);
}
private void buttonClear_Click(object sender, RoutedEventArgs e)
{
popupEmpty.IsOpen = true;/*
*/
}
private void Window_StateChanged(object sender, EventArgs e)
{
if (this.WindowState == System.Windows.WindowState.Minimized)
{
this.Visibility = System.Windows.Visibility.Collapsed;
}
}
private void buttonClearFinished_Click(object sender, RoutedEventArgs e)
{
for (int i = 0; i < _manager.QueueList.Count; i++)
{
if (_manager.QueueList[i].Finished == true)
{
_manager.QueueList.Remove(_manager.QueueList[i]);
i--;
}
}
popupEmpty.IsOpen = false;
}
private void buttonClearAll_Click(object sender, RoutedEventArgs e)
{
for (int i = 0; i < _manager.QueueList.Count; i++)
{
if (_manager.QueueList[i].Working)
{
MessageBox.Show("Cannot clear list while program are still in working mode. Please stop all running instances.", "Processes still running.");
return;
}
}
if (MessageBox.Show("Are you sure you want to clear list?", "Clear list?", MessageBoxButton.YesNo) == MessageBoxResult.Yes)
{
_manager.QueueList.Clear();
}
popupEmpty.IsOpen = false;
} }
} }
} }

View File

@ -35,11 +35,13 @@
<WarningLevel>4</WarningLevel> <WarningLevel>4</WarningLevel>
</PropertyGroup> </PropertyGroup>
<PropertyGroup> <PropertyGroup>
<ApplicationIcon>reports.ico</ApplicationIcon> <ApplicationIcon>program.ico</ApplicationIcon>
</PropertyGroup> </PropertyGroup>
<ItemGroup> <ItemGroup>
<Reference Include="System" /> <Reference Include="System" />
<Reference Include="System.Data" /> <Reference Include="System.Data" />
<Reference Include="System.Drawing" />
<Reference Include="System.Windows.Forms" />
<Reference Include="System.Xml" /> <Reference Include="System.Xml" />
<Reference Include="System.Core" /> <Reference Include="System.Core" />
<Reference Include="System.Xml.Linq" /> <Reference Include="System.Xml.Linq" />
@ -63,9 +65,6 @@
<Compile Include="Queuer\EntryManager.cs" /> <Compile Include="Queuer\EntryManager.cs" />
<Compile Include="Queuer\ProcessIOManager.cs" /> <Compile Include="Queuer\ProcessIOManager.cs" />
<Compile Include="Queuer\ProgramEntry.cs" /> <Compile Include="Queuer\ProgramEntry.cs" />
<Compile Include="Settings.xaml.cs">
<DependentUpon>Settings.xaml</DependentUpon>
</Compile>
<Page Include="MainWindow.xaml"> <Page Include="MainWindow.xaml">
<Generator>MSBuild:Compile</Generator> <Generator>MSBuild:Compile</Generator>
<SubType>Designer</SubType> <SubType>Designer</SubType>
@ -78,10 +77,6 @@
<DependentUpon>MainWindow.xaml</DependentUpon> <DependentUpon>MainWindow.xaml</DependentUpon>
<SubType>Code</SubType> <SubType>Code</SubType>
</Compile> </Compile>
<Page Include="Settings.xaml">
<SubType>Designer</SubType>
<Generator>MSBuild:Compile</Generator>
</Page>
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<Compile Include="Properties\AssemblyInfo.cs"> <Compile Include="Properties\AssemblyInfo.cs">
@ -126,10 +121,22 @@
<Resource Include="Resources\play.png" /> <Resource Include="Resources\play.png" />
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<Resource Include="reports.ico" /> <Resource Include="Resources\add.png" />
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<Resource Include="Resources\add.png" /> <Resource Include="Resources\Help.png" />
</ItemGroup>
<ItemGroup>
<Resource Include="Resources\force_run.png" />
</ItemGroup>
<ItemGroup>
<Resource Include="Resources\trash-icon.png" />
</ItemGroup>
<ItemGroup>
<Resource Include="program.ico" />
</ItemGroup>
<ItemGroup>
<None Include="Resources\Program.ico" />
</ItemGroup> </ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" /> <Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
<!-- To modify your build process, add your task inside one of the targets below and uncomment it. <!-- To modify your build process, add your task inside one of the targets below and uncomment it.

View File

@ -8,7 +8,7 @@ using System.Windows;
// set of attributes. Change these attribute values to modify the information // set of attributes. Change these attribute values to modify the information
// associated with an assembly. // associated with an assembly.
[assembly: AssemblyTitle("ProgramQueuer")] [assembly: AssemblyTitle("ProgramQueuer")]
[assembly: AssemblyDescription("")] [assembly: AssemblyDescription("Provides easy interface to queue programs or batch.")]
[assembly: AssemblyConfiguration("")] [assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("Microsoft")] [assembly: AssemblyCompany("Microsoft")]
[assembly: AssemblyProduct("ProgramQueuer")] [assembly: AssemblyProduct("ProgramQueuer")]
@ -51,5 +51,5 @@ using System.Windows;
// You can specify all the values or you can default the Build and Revision Numbers // You can specify all the values or you can default the Build and Revision Numbers
// by using the '*' as shown below: // by using the '*' as shown below:
// [assembly: AssemblyVersion("1.0.*")] // [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("1.0.0.0")] [assembly: AssemblyVersion("1.1.0.0")]
[assembly: AssemblyFileVersion("1.0.0.0")] [assembly: AssemblyFileVersion("1.1.0.0")]

View File

@ -1,71 +1,70 @@
//------------------------------------------------------------------------------ //------------------------------------------------------------------------------
// <auto-generated> // <auto-generated>
// This code was generated by a tool. // This code was generated by a tool.
// Runtime Version:4.0.30319.1 // Runtime Version:4.0.30319.269
// //
// Changes to this file may cause incorrect behavior and will be lost if // Changes to this file may cause incorrect behavior and will be lost if
// the code is regenerated. // the code is regenerated.
// </auto-generated> // </auto-generated>
//------------------------------------------------------------------------------ //------------------------------------------------------------------------------
namespace ProgramQueuer.Properties namespace ProgramQueuer.Properties {
{ using System;
/// <summary> /// <summary>
/// A strongly-typed resource class, for looking up localized strings, etc. /// A strongly-typed resource class, for looking up localized strings, etc.
/// </summary> /// </summary>
// This class was auto-generated by the StronglyTypedResourceBuilder // This class was auto-generated by the StronglyTypedResourceBuilder
// class via a tool like ResGen or Visual Studio. // class via a tool like ResGen or Visual Studio.
// To add or remove a member, edit your .ResX file then rerun ResGen // To add or remove a member, edit your .ResX file then rerun ResGen
// with the /str option, or rebuild your VS project. // with the /str option, or rebuild your VS project.
[global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "4.0.0.0")] [global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "4.0.0.0")]
[global::System.Diagnostics.DebuggerNonUserCodeAttribute()] [global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
[global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()] [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()]
internal class Resources internal class Resources {
{
private static global::System.Resources.ResourceManager resourceMan;
private static global::System.Resources.ResourceManager resourceMan;
private static global::System.Globalization.CultureInfo resourceCulture;
private static global::System.Globalization.CultureInfo resourceCulture;
[global::System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")]
[global::System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")] internal Resources() {
internal Resources() }
{
} /// <summary>
/// Returns the cached ResourceManager instance used by this class.
/// <summary> /// </summary>
/// Returns the cached ResourceManager instance used by this class. [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)]
/// </summary> internal static global::System.Resources.ResourceManager ResourceManager {
[global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)] get {
internal static global::System.Resources.ResourceManager ResourceManager if (object.ReferenceEquals(resourceMan, null)) {
{ global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("ProgramQueuer.Properties.Resources", typeof(Resources).Assembly);
get resourceMan = temp;
{ }
if ((resourceMan == null)) return resourceMan;
{ }
global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("ProgramQueuer.Properties.Resources", typeof(Resources).Assembly); }
resourceMan = temp;
} /// <summary>
return resourceMan; /// Overrides the current thread's CurrentUICulture property for all
} /// resource lookups using this strongly typed resource class.
} /// </summary>
[global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)]
/// <summary> internal static global::System.Globalization.CultureInfo Culture {
/// Overrides the current thread's CurrentUICulture property for all get {
/// resource lookups using this strongly typed resource class. return resourceCulture;
/// </summary> }
[global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)] set {
internal static global::System.Globalization.CultureInfo Culture resourceCulture = value;
{ }
get }
{
return resourceCulture; internal static System.Drawing.Icon program {
} get {
set object obj = ResourceManager.GetObject("program", resourceCulture);
{ return ((System.Drawing.Icon)(obj));
resourceCulture = value; }
} }
} }
}
} }

View File

@ -46,7 +46,7 @@
mimetype: application/x-microsoft.net.object.binary.base64 mimetype: application/x-microsoft.net.object.binary.base64
value : The object must be serialized with value : The object must be serialized with
: System.Serialization.Formatters.Binary.BinaryFormatter : System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
: and then encoded with base64 encoding. : and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.soap.base64 mimetype: application/x-microsoft.net.object.soap.base64
@ -60,6 +60,7 @@
: and then encoded with base64 encoding. : and then encoded with base64 encoding.
--> -->
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata"> <xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
<xsd:element name="root" msdata:IsDataSet="true"> <xsd:element name="root" msdata:IsDataSet="true">
<xsd:complexType> <xsd:complexType>
<xsd:choice maxOccurs="unbounded"> <xsd:choice maxOccurs="unbounded">
@ -68,9 +69,10 @@
<xsd:sequence> <xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" /> <xsd:element name="value" type="xsd:string" minOccurs="0" />
</xsd:sequence> </xsd:sequence>
<xsd:attribute name="name" type="xsd:string" /> <xsd:attribute name="name" use="required" type="xsd:string" />
<xsd:attribute name="type" type="xsd:string" /> <xsd:attribute name="type" type="xsd:string" />
<xsd:attribute name="mimetype" type="xsd:string" /> <xsd:attribute name="mimetype" type="xsd:string" />
<xsd:attribute ref="xml:space" />
</xsd:complexType> </xsd:complexType>
</xsd:element> </xsd:element>
<xsd:element name="assembly"> <xsd:element name="assembly">
@ -85,9 +87,10 @@
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" /> <xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" /> <xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
</xsd:sequence> </xsd:sequence>
<xsd:attribute name="name" type="xsd:string" msdata:Ordinal="1" /> <xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" /> <xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" /> <xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
<xsd:attribute ref="xml:space" />
</xsd:complexType> </xsd:complexType>
</xsd:element> </xsd:element>
<xsd:element name="resheader"> <xsd:element name="resheader">
@ -114,4 +117,8 @@
<resheader name="writer"> <resheader name="writer">
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value> <value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader> </resheader>
<assembly alias="System.Windows.Forms" name="System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" />
<data name="program" type="System.Resources.ResXFileRef, System.Windows.Forms">
<value>..\program.ico;System.Drawing.Icon, System.Drawing, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
</data>
</root> </root>

View File

@ -1,7 +1,7 @@
//------------------------------------------------------------------------------ //------------------------------------------------------------------------------
// <auto-generated> // <auto-generated>
// This code was generated by a tool. // This code was generated by a tool.
// Runtime Version:4.0.30319.1 // Runtime Version:4.0.30319.269
// //
// Changes to this file may cause incorrect behavior and will be lost if // Changes to this file may cause incorrect behavior and will be lost if
// the code is regenerated. // the code is regenerated.
@ -73,7 +73,7 @@ namespace ProgramQueuer.Properties {
[global::System.Configuration.UserScopedSettingAttribute()] [global::System.Configuration.UserScopedSettingAttribute()]
[global::System.Diagnostics.DebuggerNonUserCodeAttribute()] [global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
[global::System.Configuration.DefaultSettingValueAttribute("50")] [global::System.Configuration.DefaultSettingValueAttribute("75")]
public double columnWidth2 { public double columnWidth2 {
get { get {
return ((double)(this["columnWidth2"])); return ((double)(this["columnWidth2"]));
@ -94,5 +94,29 @@ namespace ProgramQueuer.Properties {
this["columnWidth3"] = value; this["columnWidth3"] = value;
} }
} }
[global::System.Configuration.UserScopedSettingAttribute()]
[global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
[global::System.Configuration.DefaultSettingValueAttribute("True")]
public bool redirectOutput {
get {
return ((bool)(this["redirectOutput"]));
}
set {
this["redirectOutput"] = value;
}
}
[global::System.Configuration.UserScopedSettingAttribute()]
[global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
[global::System.Configuration.DefaultSettingValueAttribute("")]
public string lastPath {
get {
return ((string)(this["lastPath"]));
}
set {
this["lastPath"] = value;
}
}
} }
} }

View File

@ -15,10 +15,16 @@
<Value Profile="(Default)">300</Value> <Value Profile="(Default)">300</Value>
</Setting> </Setting>
<Setting Name="columnWidth2" Type="System.Double" Scope="User"> <Setting Name="columnWidth2" Type="System.Double" Scope="User">
<Value Profile="(Default)">50</Value> <Value Profile="(Default)">75</Value>
</Setting> </Setting>
<Setting Name="columnWidth3" Type="System.Double" Scope="User"> <Setting Name="columnWidth3" Type="System.Double" Scope="User">
<Value Profile="(Default)">200</Value> <Value Profile="(Default)">200</Value>
</Setting> </Setting>
<Setting Name="redirectOutput" Type="System.Boolean" Scope="User">
<Value Profile="(Default)">True</Value>
</Setting>
<Setting Name="lastPath" Type="System.String" Scope="User">
<Value Profile="(Default)" />
</Setting>
</Settings> </Settings>
</SettingsFile> </SettingsFile>

View File

@ -12,32 +12,19 @@ namespace ProgramQueuer.Queuer
public class EntryManager : INotifyPropertyChanged public class EntryManager : INotifyPropertyChanged
{ {
bool _working; bool _working;
bool _clearNext; bool _redirectOutput;
string _buffer;
ProgramEntry _currentEntry; ProgramEntry _currentEntry;
Process _currentProcess;
ProcessIOManager _processManager;
public EntryManager() public EntryManager()
{ {
QueueList = new ObservableCollection<ProgramEntry>(); QueueList = new ObservableCollection<ProgramEntry>();
_buffer = "";
_currentEntry = null; _currentEntry = null;
_processManager = new ProcessIOManager(); _redirectOutput = true;
_processManager.StderrTextRead += new StringReadEventHandler(_processManager_StdoutTextRead);
_processManager.StdoutTextRead += new StringReadEventHandler(_processManager_StdoutTextRead);
_currentProcess = new Process();
_currentProcess.StartInfo.UseShellExecute = false;
_currentProcess.StartInfo.RedirectStandardOutput = true;
_currentProcess.StartInfo.RedirectStandardError = true;
_currentProcess.StartInfo.RedirectStandardInput = true;
_currentProcess.StartInfo.CreateNoWindow = true;
_currentProcess.EnableRaisingEvents = true;
_currentProcess.Exited += new EventHandler(_currentProcess_Exited);
} }
public ObservableCollection<ProgramEntry> QueueList; public ObservableCollection<ProgramEntry> QueueList;
public event PropertyChangedEventHandler PropertyChanged = delegate { }; public event PropertyChangedEventHandler PropertyChanged = delegate { };
public event EventHandler OnEntryFinish = delegate { };
public ProgramEntry CurrentEntry public ProgramEntry CurrentEntry
{ {
@ -59,45 +46,49 @@ namespace ProgramQueuer.Queuer
} }
} }
public bool RedirectOutput
{
get { return _redirectOutput; }
set
{
_redirectOutput = value;
PropertyChanged(this, new PropertyChangedEventArgs("RedirectOutput"));
}
}
public void RunQueuer() public void RunQueuer()
{ {
if (QueueList.Count > 0) if (QueueList.Count > 0)
{ {
Working = true; Working = true;
_currentEntry = QueueList[0];
RunProgram(QueueList[0]); RunProgram(QueueList[0]);
} }
} }
public void ForceStopCurrent()
{
_currentProcess.Kill();
}
public void ForceStop() public void ForceStop()
{ {
this.Working = false; this.Working = false;
_currentProcess.Kill(); foreach (var entry in QueueList)
if (entry.Working)
entry.Process.Kill();
} }
private void RunProgram(ProgramEntry entry) public void RunProgram(ProgramEntry entry)
{ {
try try
{ {
_currentEntry = entry; entry.Output = "";
_currentEntry.Output = ""; entry.Working = true;
_currentEntry.Working = true; entry.Process.Exited += _currentProcess_Exited;
_currentEntry.Status = "Starting"; entry.StartProcess(_redirectOutput);
_currentProcess.StartInfo.FileName = _currentEntry.Name; entry.Status = "Running";
_currentProcess.StartInfo.WorkingDirectory = new FileInfo(_currentEntry.Name).DirectoryName;
_currentProcess.Start();
_processManager.RunningProcess = _currentProcess;
_processManager.StartProcessOutputRead();
} }
catch (Exception e) catch (Exception e)
{ {
_currentEntry.Working = false; entry.Working = false;
_currentEntry.Finished = false; entry.Finished = false;
_currentEntry.Output += string.Format("Error while starting {0}:\n\n{1}", _currentEntry.Name, e.ToString()); entry.Status = string.Format("Error while starting: {0}", e.Message);
entry.Output += string.Format("Error while starting {0}:\n\n{1}", _currentEntry.Name, e.ToString());
if (RunNext()) if (RunNext())
{ {
_currentEntry = null; _currentEntry = null;
@ -108,68 +99,46 @@ namespace ProgramQueuer.Queuer
private bool RunNext() private bool RunNext()
{ {
_currentEntry.Status = "Finished"; for (int i = 0; i < QueueList.Count; i++)
if (QueueList.IndexOf(_currentEntry) >= 0 && QueueList.IndexOf(_currentEntry) < QueueList.Count - 1) {
RunProgram(QueueList[QueueList.IndexOf(_currentEntry) + 1]); if (!QueueList[i].Finished && !QueueList[i].Working)
else {
return true; _currentEntry = QueueList[i];
return false; RunProgram(_currentEntry);
return false;
}
}
return true;
} }
void _currentProcess_Exited(object sender, EventArgs e) void _currentProcess_Exited(object sender, EventArgs e)
{ {
_processManager.StopMonitoringProcessOutput(); string path = (sender as Process).StartInfo.FileName;
_currentEntry.Working = false; ProgramEntry curr = null;
_currentEntry.Finished = true; foreach (var entry in QueueList)
if (!this.Working)
return;
if (RunNext())
{ {
_currentEntry = null; if (entry.Process == sender as Process)
this.Working = false; {
curr = entry;
break;
}
} }
} if (_redirectOutput)
curr.ProcessManager.StopMonitoringProcessOutput();
curr.Working = false;
curr.Finished = true;
curr.Status = "Finished";
void _processManager_StdoutTextRead(string text) OnEntryFinish(curr, new EventArgs());
{
string[] lines = text.Split('\r');
if (!text.EndsWith("\r") && !text.EndsWith("\n") && _clearNext)
{
_buffer += text;
return;
}
else
{
text = _buffer + text;
_buffer = "";
}
if (curr == _currentEntry)
if (_clearNext && text == "\n") if (!this.Working)
_clearNext = false; return;
else if (RunNext())
while (text.IndexOf('\b') >= 0) {
{ _currentEntry = null;
if (_currentEntry.Output.Length > 0 && _currentEntry.Output[_currentEntry.Output.Length - 1] != '\n') this.Working = false;
_currentEntry.Output = _currentEntry.Output.Remove(_currentEntry.Output.Length - 1); }
text = text.Remove(text.IndexOf('\b'), 1);
}
if (_clearNext && text.Replace("\n", "").Replace("\r", "").Trim() != "")
if (_currentEntry.Output.LastIndexOf('\n') < _currentEntry.Output.Length - 1)
_currentEntry.Output = _currentEntry.Output.Remove(_currentEntry.Output.LastIndexOf('\n') + 1) + text;
else
_currentEntry.Output += text;
else
_currentEntry.Output += text;
if (text.Replace("\n", "").Trim() != "")
_currentEntry.Status = text.Replace("\n", "").Replace("\r", "");
if (lines.Length == 2 && lines[1] == "")
_clearNext = true;
else
_clearNext = false;
} }
} }
} }

View File

@ -248,7 +248,7 @@ namespace ProgramQueuer.Queuer
StderrTextRead(textbuffer.ToString()); StderrTextRead(textbuffer.ToString());
} }
} }
catch (Exception e) catch (Exception)
{ {
} }
// 'Clear' the text buffer // 'Clear' the text buffer

View File

@ -1,8 +1,10 @@
using System; using System;
using System.Diagnostics;
using System.ComponentModel; using System.ComponentModel;
using System.Collections.Generic; using System.Collections.Generic;
using System.Linq; using System.Linq;
using System.Text; using System.Text;
using System.IO;
namespace ProgramQueuer.Queuer namespace ProgramQueuer.Queuer
{ {
@ -11,13 +13,25 @@ namespace ProgramQueuer.Queuer
bool _error; bool _error;
bool _working; bool _working;
bool _finished; bool _finished;
bool _clearNext;
string _name; string _name;
string _output; string _output;
string _status; string _status;
string _buffer;
Process _process;
ProcessIOManager _processManager;
public ProgramEntry() public ProgramEntry()
{ {
Finished = false; Finished = false;
_process = new Process();
_process.StartInfo.UseShellExecute = false;
_process.EnableRaisingEvents = true;
_processManager = new ProcessIOManager();
_processManager.StderrTextRead += new StringReadEventHandler(_processManager_StdoutTextRead);
_processManager.StdoutTextRead += new StringReadEventHandler(_processManager_StdoutTextRead);
} }
public event PropertyChangedEventHandler PropertyChanged = delegate { }; public event PropertyChangedEventHandler PropertyChanged = delegate { };
@ -62,6 +76,17 @@ namespace ProgramQueuer.Queuer
} }
} }
public Process Process
{
get { return _process; }
set { _process = value; }
}
public ProcessIOManager ProcessManager
{
get { return _processManager; }
set { _processManager = value; }
}
public bool Working public bool Working
{ {
get { return _working; } get { return _working; }
@ -81,5 +106,63 @@ namespace ProgramQueuer.Queuer
PropertyChanged(this, new PropertyChangedEventArgs("Error")); PropertyChanged(this, new PropertyChangedEventArgs("Error"));
} }
} }
public void StartProcess(bool redirect)
{
_process.StartInfo.RedirectStandardOutput = redirect;
_process.StartInfo.RedirectStandardError = redirect;
_process.StartInfo.RedirectStandardInput = redirect;
_process.StartInfo.CreateNoWindow = redirect;
_process.StartInfo.FileName = this.Name;
_process.StartInfo.WorkingDirectory = new FileInfo(this.Name).DirectoryName;
_process.Start();
if (redirect)
{
_processManager.RunningProcess = _process;
_processManager.StartProcessOutputRead();
}
}
void _processManager_StdoutTextRead(string text)
{
string[] lines = text.Split('\r');
if (!text.EndsWith("\r") && !text.EndsWith("\n") && _clearNext)
{
_buffer += text;
return;
}
else
{
text = _buffer + text;
_buffer = "";
}
if (_clearNext && text == "\n")
_clearNext = false;
while (text.IndexOf('\b') >= 0)
{
if (this.Output.Length > 0 && this.Output[this.Output.Length - 1] != '\n')
this.Output = this.Output.Remove(this.Output.Length - 1);
text = text.Remove(text.IndexOf('\b'), 1);
}
if (_clearNext && text.Replace("\n", "").Replace("\r", "").Trim() != "")
if (this.Output.LastIndexOf('\n') < this.Output.Length - 1)
this.Output = this.Output.Remove(this.Output.LastIndexOf('\n') + 1) + text;
else
this.Output += text;
else
this.Output += text;
if (text.Replace("\n", "").Trim() != "")
this.Status = text.Replace("\n", "").Replace("\r", "");
if (lines.Length == 2 && lines[1] == "")
_clearNext = true;
else
_clearNext = false;
}
} }
} }

BIN
ProgramQueuer/Resources/Help.png Executable file

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.3 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.1 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 373 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 824 B

View File

@ -1,12 +0,0 @@
<Window x:Class="ProgramQueuer.Settings"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
Title="Settings" Height="300" Width="300">
<Grid>
<Grid.RowDefinitions>
<RowDefinition Height="*" />
<RowDefinition Height="*" />
<RowDefinition Height="Auto" />
</Grid.RowDefinitions>
</Grid>
</Window>

View File

@ -1,26 +0,0 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
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.Shapes;
namespace ProgramQueuer
{
/// <summary>
/// Interaction logic for Settings.xaml
/// </summary>
public partial class Settings : Window
{
public Settings()
{
InitializeComponent();
}
}
}

View File

@ -20,11 +20,17 @@
<value>300</value> <value>300</value>
</setting> </setting>
<setting name="columnWidth2" serializeAs="String"> <setting name="columnWidth2" serializeAs="String">
<value>50</value> <value>75</value>
</setting> </setting>
<setting name="columnWidth3" serializeAs="String"> <setting name="columnWidth3" serializeAs="String">
<value>200</value> <value>200</value>
</setting> </setting>
<setting name="redirectOutput" serializeAs="String">
<value>True</value>
</setting>
<setting name="lastPath" serializeAs="String">
<value />
</setting>
</ProgramQueuer.Properties.Settings> </ProgramQueuer.Properties.Settings>
</userSettings> </userSettings>
</configuration> </configuration>

BIN
ProgramQueuer/program.ico Executable file

Binary file not shown.

After

Width:  |  Height:  |  Size: 222 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 109 KiB