Skip to content

Commit

Permalink
IMP improved Workflows
Browse files Browse the repository at this point in the history
Rewriten the workflow engine.
Also some bugfixes in the MainWindow as well LargeType
clean up in MainWindow by using partial classes
  • Loading branch information
moser96 committed Oct 10, 2015
1 parent 2d3b11f commit e5b3e46
Show file tree
Hide file tree
Showing 25 changed files with 700 additions and 196 deletions.
1 change: 1 addition & 0 deletions James.sln.DotSettings
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
<wpf:ResourceDictionary xml:space="preserve" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:s="clr-namespace:System;assembly=mscorlib" xmlns:ss="urn:shemas-jetbrains-com:settings-storage-xaml" xmlns:wpf="http://schemas.microsoft.com/winfx/2006/xaml/presentation">
<s:Boolean x:Key="/Default/CodeInspection/CodeAnnotations/NamespacesWithAnnotations/=James_002EAnnotations/@EntryIndexedValue">True</s:Boolean>
<s:Boolean x:Key="/Default/CodeInspection/CodeAnnotations/NamespacesWithAnnotations/=WinFred_002EAnnotations/@EntryIndexedValue">True</s:Boolean></wpf:ResourceDictionary>
7 changes: 3 additions & 4 deletions WinFred/App.config
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
<?xml version="1.0" encoding="utf-8"?>

<?xml version="1.0" encoding="utf-8"?>
<configuration>
<startup>
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.5.2" />
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.6"/>
</startup>
</configuration>
</configuration>
2 changes: 1 addition & 1 deletion WinFred/Config.cs
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ public static Config GetInstance()
{
var path = Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData) + "\\James";
Directory.CreateDirectory(path);
config = GeneralHelper.Derialize<Config>(path + "\\config.xml");
config = GeneralHelper.Deserialize<Config>(path + "\\config.xml");
}
catch (Exception)
{
Expand Down
51 changes: 29 additions & 22 deletions WinFred/HelperClasses/GeneralHelper.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
using System.Drawing;
using System.IO;
using System.Runtime.InteropServices;
using System.Runtime.Serialization;
using System.Text;
using System.Windows;
using System.Windows.Interop;
Expand All @@ -10,17 +11,18 @@
using System.Xml;
using System.Xml.Linq;
using System.Xml.Serialization;
using James.Workflows;
using James.Workflows.Actions;
using James.Workflows.Interfaces;
using James.Workflows.Outputs;
using James.Workflows.Triggers;

namespace James.HelperClasses
{
public static class GeneralHelper
{
public static string Serialize<T>(this T value)
{
if (value == null)
{
return string.Empty;
}
try
{
var xmlserializer = new XmlSerializer(typeof (T));
Expand All @@ -37,8 +39,18 @@ public static string Serialize<T>(this T value)
throw new Exception("An error occurred", ex);
}
}
public static string SerializeWorkflow(Workflow workflow)
{
MemoryStream ms = new MemoryStream();
DataContractSerializer ser = new DataContractSerializer(typeof(Workflow));
ms.Position = 0;
ser.WriteObject(ms, workflow);
ms.Position = 0;
string output = new StreamReader(ms).ReadToEnd();
return XDocument.Parse(output).ToString();
}

public static T Derialize<T>(string path)
public static T Deserialize<T>(string path)
{
try
{
Expand All @@ -52,6 +64,18 @@ public static T Derialize<T>(string path)
}
}

public static Workflow DeserializeWorkflow(string path)
{
using (Stream stream = new MemoryStream())
{
byte[] data = Encoding.UTF8.GetBytes(File.ReadAllText(path));
stream.Write(data, 0, data.Length);
stream.Position = 0;
DataContractSerializer deserializer = new DataContractSerializer(typeof(Workflow));
return (Workflow)deserializer.ReadObject(stream);
}
}

public static ImageSource ToImageSource(this Icon icon)
{
DateTime tmp = DateTime.Now;
Expand All @@ -63,23 +87,6 @@ public static ImageSource ToImageSource(this Icon icon)
return imageSource;
}

public static string BuildHtml(string htmlFromWorkflow)
{
var html = new StringBuilder(@"<!DOCTYPE html>
<html>
<head>
<meta charset=""utf-8"" />
<link rel=""stylesheet""
type=""text/css""
href=""http://holdirbootstrap.de/dist/css/bootstrap.min.css"" />
</head>
<body style=""-webkit-user-select: none;"">");

html.Append(htmlFromWorkflow);
html.Append("</body></html>");
return html.ToString();
}

[DllImport("shell32.dll")]
static extern IntPtr ExtractIcon(IntPtr hInst, string lpszExeFileName, int nIconIndex);

Expand Down
28 changes: 22 additions & 6 deletions WinFred/James.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -9,14 +9,16 @@
<AppDesignerFolder>Properties</AppDesignerFolder>
<RootNamespace>James</RootNamespace>
<AssemblyName>James</AssemblyName>
<TargetFrameworkVersion>v4.5.2</TargetFrameworkVersion>
<TargetFrameworkVersion>v4.6</TargetFrameworkVersion>
<FileAlignment>512</FileAlignment>
<ProjectTypeGuids>{60dc8134-eba5-43b8-bcc9-bb4bc16c2548};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids>
<WarningLevel>4</WarningLevel>
<SccProjectName>SAK</SccProjectName>
<SccLocalPath>SAK</SccLocalPath>
<SccAuxPath>SAK</SccAuxPath>
<SccProvider>SAK</SccProvider>
<IsWebBootstrapper>false</IsWebBootstrapper>
<TargetFrameworkProfile />
<PublishUrl>publish\</PublishUrl>
<Install>true</Install>
<InstallFrom>Disk</InstallFrom>
Expand All @@ -29,13 +31,11 @@
<MapFileExtensions>true</MapFileExtensions>
<ApplicationRevision>0</ApplicationRevision>
<ApplicationVersion>1.0.0.%2a</ApplicationVersion>
<IsWebBootstrapper>false</IsWebBootstrapper>
<UseApplicationTrust>false</UseApplicationTrust>
<BootstrapperEnabled>true</BootstrapperEnabled>
<TargetFrameworkProfile />
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<PlatformTarget>AnyCPU</PlatformTarget>
<PlatformTarget>x64</PlatformTarget>
<DebugSymbols>true</DebugSymbols>
<DebugType>full</DebugType>
<Optimize>false</Optimize>
Expand Down Expand Up @@ -128,9 +128,9 @@
<HintPath>..\packages\Mono.Cecil.0.9.6.1\lib\net45\Mono.Cecil.Rocks.dll</HintPath>
<Private>True</Private>
</Reference>
<Reference Include="SearchEngineWrapper, Version=1.0.5747.36362, Culture=neutral, processorArchitecture=x86">
<Reference Include="SearchEngineWrapper, Version=1.0.5756.37872, Culture=neutral, processorArchitecture=x86">
<SpecificVersion>False</SpecificVersion>
<HintPath>..\Debug\SearchEngineWrapper.dll</HintPath>
<HintPath>..\x64\Debug\SearchEngineWrapper.dll</HintPath>
</Reference>
<Reference Include="Splat, Version=1.6.2.0, Culture=neutral, processorArchitecture=MSIL">
<HintPath>..\packages\Splat.1.6.2\lib\Net45\Splat.dll</HintPath>
Expand All @@ -144,6 +144,7 @@
<Reference Include="System.Data" />
<Reference Include="System.Drawing" />
<Reference Include="System.Management" />
<Reference Include="System.Runtime.Serialization" />
<Reference Include="system.windows.controls.ribbon" />
<Reference Include="System.Windows.Forms" />
<Reference Include="System.Windows.Interactivity">
Expand Down Expand Up @@ -176,6 +177,7 @@
<Compile Include="Enumerations\AccentColorTypes.cs" />
<Compile Include="HelperClasses\GeneralHelper.cs" />
<Compile Include="HelperClasses\GridHelper.cs" />
<Compile Include="PartialConfigClasses\MainWindowConfig.cs" />
<Compile Include="SearchResultElement.cs" />
<Compile Include="UserControls\AboutUserControl.xaml.cs">
<DependentUpon>AboutUserControl.xaml</DependentUpon>
Expand Down Expand Up @@ -213,6 +215,19 @@
<Compile Include="WelcomeWindow.xaml.cs">
<DependentUpon>WelcomeWindow.xaml</DependentUpon>
</Compile>
<Compile Include="Workflows\Actions\BasicAction.cs" />
<Compile Include="Workflows\Interfaces\ICrossPlatform.cs" />
<Compile Include="Workflows\Interfaces\ISurviveable.cs" />
<Compile Include="Workflows\Outputs\BasicOutput.cs" />
<Compile Include="Workflows\Outputs\LargeTypeOutput.cs" />
<Compile Include="Workflows\Outputs\SearchResultOutput.cs" />
<Compile Include="Workflows\RunnableWorkflowComponent.cs" />
<Compile Include="Workflows\Triggers\BasicTrigger.cs" />
<Compile Include="Workflows\Triggers\IntervalTrigger.cs" />
<Compile Include="Workflows\Triggers\KeywordTrigger.cs" />
<Compile Include="Workflows\Workflow.cs" />
<Compile Include="Workflows\WorkflowComponent.cs" />
<Compile Include="Workflows\WorkflowManager.cs" />
<Page Include="ChangelogWindow.xaml">
<SubType>Designer</SubType>
<Generator>MSBuild:Compile</Generator>
Expand Down Expand Up @@ -327,6 +342,7 @@
<Install>false</Install>
</BootstrapperPackage>
</ItemGroup>
<ItemGroup />
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
Other similar extension points exist, see Microsoft.Common.targets.
Expand Down
25 changes: 20 additions & 5 deletions WinFred/LargeType.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -9,22 +9,37 @@ namespace James
/// </summary>
public partial class LargeType : Window
{
public LargeType(string message)
private static LargeType _largeType;
private static readonly object SingeltonLock = new object();
public static LargeType GetInstance()
{
lock (SingeltonLock)
{
return _largeType ?? (_largeType = new LargeType());
}
}

public string Message
{
get { return TextBlock.Text; }
set { TextBlock.Text = value; }
}

private LargeType()
{
InitializeComponent();
WindowState = WindowState.Maximized;
Width = SystemParameters.PrimaryScreenWidth;
Height = SystemParameters.PrimaryScreenHeight;
TextBlock.Text = message;
DataContext = Config.GetInstance();
}

private void Window_KeyDown(object sender, KeyEventArgs e)
{
if (e.KeyboardDevice.IsKeyDown(Key.Escape) ||
(e.KeyboardDevice.IsKeyDown(Key.L) && e.KeyboardDevice.IsKeyDown(Key.LeftAlt)))
if (e.KeyboardDevice.IsKeyDown(Key.Escape) /*||
(e.KeyboardDevice.IsKeyDown(Key.L) && e.KeyboardDevice.IsKeyDown(Key.LeftAlt))*/)
{
Close();
Hide();
}
}
}
Expand Down
8 changes: 2 additions & 6 deletions WinFred/MainWindow.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -6,15 +6,11 @@
ResizeMode="NoResize" WindowStyle="None"
Opacity="0.9" SizeToContent="Height" ShowInTaskbar="False" Loaded="Window_Loaded"
Deactivated="Window_Deactivated" BorderBrush="#FF777777" BorderThickness="1">
<Grid Loaded="Grid_Loaded" helper:GridHelper.RowDefinition="100|a|a">
<Grid helper:GridHelper.RowDefinition="100|a|a">
<TextBox Grid.Row="0" x:Name="SearchTextBox" Margin="0" TextWrapping="Wrap" HorizontalAlignment="Stretch"
VerticalAlignment="Top" FontSize="55" VerticalContentAlignment="Center" Padding="10,0,10,10"
Foreground="#FF383838" MaxLines="1" Height="100" KeyDown="SearchTextBox_KeyDown"
TextChanged="SearchTextBox_TextChanged" PreviewKeyDown="SearchTextBox_PreviewKeyDown"
Foreground="#FF383838" MaxLines="1" Height="100" TextChanged="SearchTextBox_TextChanged" PreviewKeyDown="SearchTextBox_PreviewKeyDown"
BorderBrush="{x:Null}" BorderThickness="0" UndoLimit="0" VerticalScrollBarVisibility="Disabled" />
<Grid Grid.Row="1">
<WebBrowser Name="OutputWebBrowser" Height="400" Visibility="Collapsed" Width="700" />
</Grid>
<userControls:SearchResultUserControl x:Name="searchResultControl" Grid.Row="2" />
</Grid>
</Window>
Loading

0 comments on commit e5b3e46

Please sign in to comment.