Skip to content

Commit 8054017

Browse files
committed
Initial commit
0 parents  commit 8054017

25 files changed

+1935
-0
lines changed

.gitignore

+4
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
bin
2+
obj
3+
!.gitignore
4+
.*

App.config

+6
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
<?xml version="1.0" encoding="utf-8" ?>
2+
<configuration>
3+
<startup>
4+
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.7.2" />
5+
</startup>
6+
</configuration>

Exquad.csproj

+111
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,111 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<Project ToolsVersion="15.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
3+
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
4+
<PropertyGroup>
5+
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
6+
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
7+
<ProjectGuid>{95A18481-113E-417E-9F41-0459AB354A43}</ProjectGuid>
8+
<OutputType>WinExe</OutputType>
9+
<RootNamespace>Exquad</RootNamespace>
10+
<AssemblyName>Exquad</AssemblyName>
11+
<TargetFrameworkVersion>v4.7.2</TargetFrameworkVersion>
12+
<FileAlignment>512</FileAlignment>
13+
<AutoGenerateBindingRedirects>true</AutoGenerateBindingRedirects>
14+
<Deterministic>true</Deterministic>
15+
</PropertyGroup>
16+
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
17+
<PlatformTarget>AnyCPU</PlatformTarget>
18+
<DebugSymbols>true</DebugSymbols>
19+
<DebugType>full</DebugType>
20+
<Optimize>false</Optimize>
21+
<OutputPath>bin\Debug\</OutputPath>
22+
<DefineConstants>DEBUG;TRACE</DefineConstants>
23+
<ErrorReport>prompt</ErrorReport>
24+
<WarningLevel>4</WarningLevel>
25+
</PropertyGroup>
26+
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
27+
<PlatformTarget>AnyCPU</PlatformTarget>
28+
<DebugType>pdbonly</DebugType>
29+
<Optimize>true</Optimize>
30+
<OutputPath>bin\Release\</OutputPath>
31+
<DefineConstants>TRACE</DefineConstants>
32+
<ErrorReport>prompt</ErrorReport>
33+
<WarningLevel>4</WarningLevel>
34+
</PropertyGroup>
35+
<ItemGroup>
36+
<Reference Include="System" />
37+
<Reference Include="System.Core" />
38+
<Reference Include="System.Xml.Linq" />
39+
<Reference Include="System.Data.DataSetExtensions" />
40+
<Reference Include="Microsoft.CSharp" />
41+
<Reference Include="System.Data" />
42+
<Reference Include="System.Deployment" />
43+
<Reference Include="System.Drawing" />
44+
<Reference Include="System.Net.Http" />
45+
<Reference Include="System.Windows.Forms" />
46+
<Reference Include="System.Xml" />
47+
</ItemGroup>
48+
<ItemGroup>
49+
<Compile Include="FileExplorer.cs">
50+
<SubType>Component</SubType>
51+
</Compile>
52+
<Compile Include="MainForm.cs">
53+
<SubType>Form</SubType>
54+
</Compile>
55+
<Compile Include="MainForm.Designer.cs">
56+
<DependentUpon>MainForm.cs</DependentUpon>
57+
</Compile>
58+
<Compile Include="Program.cs" />
59+
<Compile Include="Properties\AssemblyInfo.cs" />
60+
<EmbeddedResource Include="MainForm.resx">
61+
<DependentUpon>MainForm.cs</DependentUpon>
62+
</EmbeddedResource>
63+
<EmbeddedResource Include="Properties\Resources.resx">
64+
<Generator>ResXFileCodeGenerator</Generator>
65+
<LastGenOutput>Resources.Designer.cs</LastGenOutput>
66+
<SubType>Designer</SubType>
67+
</EmbeddedResource>
68+
<Compile Include="Properties\Resources.Designer.cs">
69+
<AutoGen>True</AutoGen>
70+
<DependentUpon>Resources.resx</DependentUpon>
71+
<DesignTime>True</DesignTime>
72+
</Compile>
73+
<None Include="Properties\Settings.settings">
74+
<Generator>SettingsSingleFileGenerator</Generator>
75+
<LastGenOutput>Settings.Designer.cs</LastGenOutput>
76+
</None>
77+
<Compile Include="Properties\Settings.Designer.cs">
78+
<AutoGen>True</AutoGen>
79+
<DependentUpon>Settings.settings</DependentUpon>
80+
<DesignTimeSharedInput>True</DesignTimeSharedInput>
81+
</Compile>
82+
</ItemGroup>
83+
<ItemGroup>
84+
<None Include="App.config" />
85+
</ItemGroup>
86+
<ItemGroup>
87+
<None Include="res\blue-arrow-left.ico" />
88+
</ItemGroup>
89+
<ItemGroup>
90+
<None Include="res\blue-arrow-right.ico" />
91+
</ItemGroup>
92+
<ItemGroup>
93+
<None Include="res\blue-arrow-up.ico" />
94+
</ItemGroup>
95+
<ItemGroup>
96+
<None Include="res\blue-icon-open.ico" />
97+
</ItemGroup>
98+
<ItemGroup>
99+
<None Include="res\png\left.png" />
100+
</ItemGroup>
101+
<ItemGroup>
102+
<None Include="res\png\open.png" />
103+
</ItemGroup>
104+
<ItemGroup>
105+
<None Include="res\png\right.png" />
106+
</ItemGroup>
107+
<ItemGroup>
108+
<None Include="res\png\up.png" />
109+
</ItemGroup>
110+
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
111+
</Project>

Exquad.sln

+25
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
2+
Microsoft Visual Studio Solution File, Format Version 12.00
3+
# Visual Studio Version 16
4+
VisualStudioVersion = 16.0.32602.291
5+
MinimumVisualStudioVersion = 10.0.40219.1
6+
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Exquad", "Exquad.csproj", "{95A18481-113E-417E-9F41-0459AB354A43}"
7+
EndProject
8+
Global
9+
GlobalSection(SolutionConfigurationPlatforms) = preSolution
10+
Debug|Any CPU = Debug|Any CPU
11+
Release|Any CPU = Release|Any CPU
12+
EndGlobalSection
13+
GlobalSection(ProjectConfigurationPlatforms) = postSolution
14+
{95A18481-113E-417E-9F41-0459AB354A43}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
15+
{95A18481-113E-417E-9F41-0459AB354A43}.Debug|Any CPU.Build.0 = Debug|Any CPU
16+
{95A18481-113E-417E-9F41-0459AB354A43}.Release|Any CPU.ActiveCfg = Release|Any CPU
17+
{95A18481-113E-417E-9F41-0459AB354A43}.Release|Any CPU.Build.0 = Release|Any CPU
18+
EndGlobalSection
19+
GlobalSection(SolutionProperties) = preSolution
20+
HideSolutionNode = FALSE
21+
EndGlobalSection
22+
GlobalSection(ExtensibilityGlobals) = postSolution
23+
SolutionGuid = {641207BF-829F-46C4-A5B0-CE1B077D9247}
24+
EndGlobalSection
25+
EndGlobal

FileExplorer.cs

+154
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,154 @@
1+
/*
2+
Copyright 2022 Mark Lagodych
3+
4+
This file is part of Exquad.
5+
6+
Exquad is free software: you can redistribute it and/or modify it under the
7+
terms of the GNU General Public License as published by the Free Software
8+
Foundation, either version 3 of the License, or (at your option) any later
9+
version.
10+
11+
Exquad is distributed in the hope that it will be useful, but WITHOUT ANY
12+
WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
13+
A PARTICULAR PURPOSE. See the GNU General Public License for more details.
14+
15+
You should have received a copy of the GNU General Public License along with
16+
Exquad. If not, see <https://www.gnu.org/licenses/>.
17+
*/
18+
19+
using System;
20+
using System.IO;
21+
using System.Windows.Forms;
22+
23+
namespace Exquad
24+
{
25+
class FileExplorer : Control
26+
{
27+
private WebBrowser browser;
28+
private Button buttonBack, buttonForward, buttonUp, buttonOpen;
29+
private TextBox textboxPath;
30+
31+
public FileExplorer()
32+
{
33+
var table1 = new TableLayoutPanel();
34+
this.Controls.Add(table1);
35+
table1.Dock = DockStyle.Fill;
36+
table1.RowCount = 2;
37+
table1.ColumnCount = 1;
38+
table1.RowStyles.Add(new RowStyle(SizeType.AutoSize, 0));
39+
table1.RowStyles.Add(new RowStyle(SizeType.Percent, 100));
40+
41+
var table2 = new TableLayoutPanel();
42+
table1.Controls.Add(table2);
43+
table2.RowCount = 1;
44+
table2.ColumnCount = 5;
45+
table2.Dock = DockStyle.Fill;
46+
table2.Height = 35;
47+
//table2.RowStyles.Add(new RowStyle(SizeType.AutoSize, 0));
48+
table2.ColumnStyles.Add(new ColumnStyle(SizeType.AutoSize, 0));
49+
table2.ColumnStyles.Add(new ColumnStyle(SizeType.AutoSize, 0));
50+
table2.ColumnStyles.Add(new ColumnStyle(SizeType.AutoSize, 0));
51+
table2.ColumnStyles.Add(new ColumnStyle(SizeType.AutoSize, 0));
52+
table2.ColumnStyles.Add(new ColumnStyle(SizeType.Percent, 100));
53+
54+
buttonBack = new Button();
55+
table2.Controls.Add(buttonBack);
56+
buttonBack.BackgroundImage = Properties.Resources.IconLeft;
57+
buttonBack.Click += (sender, e) => { GoBack(); };
58+
59+
buttonForward = new Button();
60+
table2.Controls.Add(buttonForward);
61+
buttonForward.BackgroundImage = Properties.Resources.IconRight;
62+
buttonForward.Click += (sender, e) => { GoForward(); };
63+
64+
buttonUp = new Button();
65+
table2.Controls.Add(buttonUp);
66+
buttonUp.BackgroundImage = Properties.Resources.IconUp;
67+
buttonUp.Click += (sender, e) => { GoUp(); };
68+
69+
buttonOpen = new Button();
70+
table2.Controls.Add(buttonOpen);
71+
buttonOpen.BackgroundImage = Properties.Resources.IconOpen;
72+
buttonOpen.Click += (sender, e) => { OpenFolder(); };
73+
74+
textboxPath = new TextBox();
75+
table2.Controls.Add(textboxPath);
76+
textboxPath.Dock = DockStyle.Fill;
77+
textboxPath.Font = new System.Drawing.Font("Calibri", 11);
78+
textboxPath.KeyPress += (sender, e) => { if (e.KeyChar == (char)Keys.Enter) BrowsePath(); };
79+
80+
81+
browser = new WebBrowser();
82+
table1.Controls.Add(browser);
83+
browser.Navigated += (sender, e) => { UpdateControls(); };
84+
browser.Dock = DockStyle.Fill;
85+
browser.Navigate("C:\\");
86+
87+
foreach (var btn in new Button[] {buttonBack, buttonForward, buttonUp, buttonOpen})
88+
{
89+
btn.BackgroundImageLayout = ImageLayout.Zoom;
90+
btn.Size = new System.Drawing.Size(24, 24);
91+
btn.BackColor = System.Drawing.Color.Transparent;
92+
btn.FlatStyle = FlatStyle.Flat;
93+
btn.FlatAppearance.BorderSize = 0;
94+
}
95+
96+
}
97+
98+
private void GoBack()
99+
{
100+
if (browser.CanGoBack)
101+
browser.GoBack();
102+
}
103+
104+
private void GoForward()
105+
{
106+
if (browser.CanGoForward)
107+
browser.GoForward();
108+
}
109+
110+
private void GoUp()
111+
{
112+
var currentDir = browser.Url.LocalPath;
113+
var parentDir = Directory.GetParent(RemoveProtocolPrefix(currentDir));
114+
115+
if (parentDir != null)
116+
browser.Navigate(parentDir.FullName);
117+
}
118+
119+
private string RemoveProtocolPrefix(string path)
120+
{
121+
if (path.StartsWith("file:///"))
122+
return path.Remove(0, "file:///".Length);
123+
return path;
124+
}
125+
126+
private bool CanGoUp()
127+
{
128+
return Directory.GetParent(browser.Url.AbsolutePath) != null;
129+
}
130+
131+
private void UpdateControls()
132+
{
133+
buttonBack.Enabled = browser.CanGoBack;
134+
buttonForward.Enabled = browser.CanGoForward;
135+
buttonUp.Enabled = CanGoUp();
136+
textboxPath.Text = RemoveProtocolPrefix(browser.Url.ToString());
137+
}
138+
139+
private void OpenFolder()
140+
{
141+
var fd = new FolderBrowserDialog();
142+
fd.Description = "Select a location to display";
143+
fd.ShowNewFolderButton = true;
144+
145+
if (fd.ShowDialog() == DialogResult.OK)
146+
browser.Navigate(fd.SelectedPath);
147+
}
148+
149+
private void BrowsePath()
150+
{
151+
browser.Navigate(textboxPath.Text);
152+
}
153+
}
154+
}

0 commit comments

Comments
 (0)