Skip to content

Commit

Permalink
* Added new directory browse dialog
Browse files Browse the repository at this point in the history
* Pushing v1 publish version
* Added EGA/CGA example files
  • Loading branch information
ChainedLupine committed May 7, 2016
1 parent a5a47e5 commit 389667c
Show file tree
Hide file tree
Showing 18 changed files with 497 additions and 14 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
EgaViewer_v2/bin/Debug/EgaViewer_v2.exe.config
EgaViewer_v2/bin/
EgaViewer_v2/obj/
EgaViewer_v2/publish/
51 changes: 51 additions & 0 deletions EgaViewer_v2/EgaViewer_v2.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,22 @@
<TargetFrameworkVersion>v4.5.2</TargetFrameworkVersion>
<FileAlignment>512</FileAlignment>
<AutoGenerateBindingRedirects>true</AutoGenerateBindingRedirects>
<IsWebBootstrapper>false</IsWebBootstrapper>
<PublishUrl>publish\</PublishUrl>
<Install>true</Install>
<InstallFrom>Disk</InstallFrom>
<UpdateEnabled>false</UpdateEnabled>
<UpdateMode>Foreground</UpdateMode>
<UpdateInterval>7</UpdateInterval>
<UpdateIntervalUnits>Days</UpdateIntervalUnits>
<UpdatePeriodically>false</UpdatePeriodically>
<UpdateRequired>false</UpdateRequired>
<MapFileExtensions>true</MapFileExtensions>
<ApplicationRevision>1</ApplicationRevision>
<ApplicationVersion>1.0.0.%2a</ApplicationVersion>
<UseApplicationTrust>false</UseApplicationTrust>
<PublishWizardCompleted>true</PublishWizardCompleted>
<BootstrapperEnabled>true</BootstrapperEnabled>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<PlatformTarget>AnyCPU</PlatformTarget>
Expand All @@ -32,6 +48,25 @@
<DefineConstants>TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
</PropertyGroup>
<PropertyGroup>
<ManifestCertificateThumbprint>C6E3E0E89DB9445D5B06F6C5FB703666BA0CAE87</ManifestCertificateThumbprint>
</PropertyGroup>
<PropertyGroup>
<ManifestKeyFile>EgaViewer_v2_TemporaryKey.pfx</ManifestKeyFile>
</PropertyGroup>
<PropertyGroup>
<GenerateManifests>true</GenerateManifests>
</PropertyGroup>
<PropertyGroup>
<TargetZone>LocalIntranet</TargetZone>
</PropertyGroup>
<PropertyGroup>
<ApplicationManifest>Properties\app.manifest</ApplicationManifest>
</PropertyGroup>
<PropertyGroup>
<SignManifests>true</SignManifests>
</PropertyGroup>
<ItemGroup>
<Reference Include="System" />
Expand All @@ -54,6 +89,7 @@
<Compile Include="CustomPictureBox.Designer.cs">
<DependentUpon>CustomPictureBox.cs</DependentUpon>
</Compile>
<Compile Include="FolderSelectDialog.cs" />
<Compile Include="FormMain.cs">
<SubType>Form</SubType>
</Compile>
Expand All @@ -62,6 +98,7 @@
</Compile>
<Compile Include="Program.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
<Compile Include="Reflector.cs" />
<EmbeddedResource Include="FormMain.resx">
<DependentUpon>FormMain.cs</DependentUpon>
</EmbeddedResource>
Expand All @@ -74,6 +111,8 @@
<AutoGen>True</AutoGen>
<DependentUpon>Resources.resx</DependentUpon>
</Compile>
<None Include="EgaViewer_v2_TemporaryKey.pfx" />
<None Include="Properties\app.manifest" />
<None Include="Properties\Settings.settings">
<Generator>SettingsSingleFileGenerator</Generator>
<LastGenOutput>Settings.Designer.cs</LastGenOutput>
Expand All @@ -87,6 +126,18 @@
<ItemGroup>
<None Include="App.config" />
</ItemGroup>
<ItemGroup>
<BootstrapperPackage Include=".NETFramework,Version=v4.5.2">
<Visible>False</Visible>
<ProductName>Microsoft .NET Framework 4.5.2 %28x86 and x64%29</ProductName>
<Install>true</Install>
</BootstrapperPackage>
<BootstrapperPackage Include="Microsoft.Net.Framework.3.5.SP1">
<Visible>False</Visible>
<ProductName>.NET Framework 3.5 SP1</ProductName>
<Install>false</Install>
</BootstrapperPackage>
</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
Binary file added EgaViewer_v2/EgaViewer_v2_TemporaryKey.pfx
Binary file not shown.
154 changes: 154 additions & 0 deletions EgaViewer_v2/FolderSelectDialog.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,154 @@
using System;
using System.Windows.Forms;

// ------------------------------------------------------------------
// Wraps System.Windows.Forms.OpenFileDialog to make it present
// a vista-style dialog.
// ------------------------------------------------------------------

namespace FolderSelect
{
/// <summary>
/// Wraps System.Windows.Forms.OpenFileDialog to make it present
/// a vista-style dialog.
/// </summary>
public class FolderSelectDialog
{
// Wrapped dialog
System.Windows.Forms.OpenFileDialog ofd = null;

/// <summary>
/// Default constructor
/// </summary>
public FolderSelectDialog()
{
ofd = new System.Windows.Forms.OpenFileDialog();

ofd.Filter = "Folders|\n";
ofd.AddExtension = false;
ofd.CheckFileExists = false;
ofd.DereferenceLinks = true;
ofd.Multiselect = false;
}

#region Properties

/// <summary>
/// Gets/Sets the initial folder to be selected. A null value selects the current directory.
/// </summary>
public string InitialDirectory
{
get { return ofd.InitialDirectory; }
set { ofd.InitialDirectory = value == null || value.Length == 0 ? Environment.CurrentDirectory : value; }
}

/// <summary>
/// Gets/Sets the title to show in the dialog
/// </summary>
public string Title
{
get { return ofd.Title; }
set { ofd.Title = value == null ? "Select a folder" : value; }
}

/// <summary>
/// Gets the selected folder
/// </summary>
public string FileName
{
get { return ofd.FileName; }
}

#endregion

#region Methods

/// <summary>
/// Shows the dialog
/// </summary>
/// <returns>True if the user presses OK else false</returns>
public bool ShowDialog()
{
return ShowDialog(IntPtr.Zero);
}

/// <summary>
/// Shows the dialog
/// </summary>
/// <param name="hWndOwner">Handle of the control to be parent</param>
/// <returns>True if the user presses OK else false</returns>
public bool ShowDialog(IntPtr hWndOwner)
{
bool flag = false;

if (Environment.OSVersion.Version.Major >= 6)
{
var r = new Reflector("System.Windows.Forms");

uint num = 0;
Type typeIFileDialog = r.GetType("FileDialogNative.IFileDialog");
object dialog = r.Call(ofd, "CreateVistaDialog");
r.Call(ofd, "OnBeforeVistaDialog", dialog);

uint options = (uint)r.CallAs(typeof(System.Windows.Forms.FileDialog), ofd, "GetOptions");
options |= (uint)r.GetEnum("FileDialogNative.FOS", "FOS_PICKFOLDERS");
r.CallAs(typeIFileDialog, dialog, "SetOptions", options);

object pfde = r.New("FileDialog.VistaDialogEvents", ofd);
object[] parameters = new object[] { pfde, num };
r.CallAs2(typeIFileDialog, dialog, "Advise", parameters);
num = (uint)parameters[1];
try
{
int num2 = (int)r.CallAs(typeIFileDialog, dialog, "Show", hWndOwner);
flag = 0 == num2;
}
finally
{
r.CallAs(typeIFileDialog, dialog, "Unadvise", num);
GC.KeepAlive(pfde);
}
}
else
{
var fbd = new FolderBrowserDialog();
fbd.Description = this.Title;
fbd.SelectedPath = this.InitialDirectory;
fbd.ShowNewFolderButton = false;
if (fbd.ShowDialog(new WindowWrapper(hWndOwner)) != DialogResult.OK) return false;
ofd.FileName = fbd.SelectedPath;
flag = true;
}

return flag;
}

#endregion
}

/// <summary>
/// Creates IWin32Window around an IntPtr
/// </summary>
public class WindowWrapper : System.Windows.Forms.IWin32Window
{
/// <summary>
/// Constructor
/// </summary>
/// <param name="handle">Handle to wrap</param>
public WindowWrapper(IntPtr handle)
{
_hwnd = handle;
}

/// <summary>
/// Original ptr
/// </summary>
public IntPtr Handle
{
get { return _hwnd; }
}

private IntPtr _hwnd;
}

}
22 changes: 21 additions & 1 deletion EgaViewer_v2/FormMain.Designer.cs

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

30 changes: 17 additions & 13 deletions EgaViewer_v2/FormMain.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
using System.IO;
using System.Drawing.Imaging;
using System.Drawing.Drawing2D;
using FolderSelect;

namespace EgaViewer_v2
{
Expand Down Expand Up @@ -265,20 +266,18 @@ private void FormMain_Resize(object sender, EventArgs e)

private void openPathToolStripMenuItem_Click(object sender, EventArgs e)
{
FolderBrowserDialog dialog = new FolderBrowserDialog();

dialog.SelectedPath = currPath;
dialog.Description = "Select path to files.";
dialog.ShowNewFolderButton = false;
dialog.RootFolder = Environment.SpecialFolder.MyComputer;

dialog.ShowDialog();

currPath = dialog.SelectedPath;
Properties.Settings.Default.LastDirectory = currPath;
Properties.Settings.Default.Save();
var fsd = new FolderSelectDialog();
fsd.Title = "Select a folder to browse.";
fsd.InitialDirectory = Properties.Settings.Default.LastDirectory;
if (fsd.ShowDialog(IntPtr.Zero))
{
Console.WriteLine(fsd.FileName);
currPath = fsd.FileName;
Properties.Settings.Default.LastDirectory = currPath;
Properties.Settings.Default.Save();

PopulateFiles();
PopulateFiles();
}
}

private void MenuItem_Options_Click(object sender, EventArgs e)
Expand All @@ -292,5 +291,10 @@ private void MenuItem_Options_Click(object sender, EventArgs e)

UpdateImage();
}

private void aboutToolStripMenuItem1_Click(object sender, EventArgs e)
{
MessageBox.Show("This program was created by ChainedLupine (aka David Grace).\n\nView it at https://github.com/ChainedLupine/BSAVEViewer");
}
}
}
Loading

0 comments on commit 389667c

Please sign in to comment.