Skip to content

Commit 8f2207e

Browse files
committed
Added Import File
Added support to import a file though the project browser Fixed bug in creating a file added an image icon file so image files don't default to globe
1 parent 0a61112 commit 8f2207e

File tree

8 files changed

+93
-3
lines changed

8 files changed

+93
-3
lines changed

WebKidzPlus/DirectoryListing.xaml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,8 @@
1414
</MenuItem>
1515
<MenuItem Name="TV_CM_NewFile" Header="New File" Click="TV_CM_NewFile_Click">
1616
</MenuItem>
17+
<MenuItem Name="TV_CM_Import" Header="Import File" Click="TV_CM_Import_Click">
18+
</MenuItem>
1719
<MenuItem Name="TV_CM_Delete" Header="Delete" Click="TV_CM_Delete_Click">
1820
</MenuItem>
1921
</ContextMenu>

WebKidzPlus/DirectoryListing.xaml.cs

Lines changed: 44 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -132,7 +132,14 @@ private void TV_CM_NewDir_Click(object sender, RoutedEventArgs e)
132132
}
133133
else
134134
{
135-
path = ((TreeViewItem)tvi.Parent).Tag.ToString().Replace("/", "\\");
135+
try
136+
{
137+
path = ((TreeViewItem)tvi.Parent).Tag.ToString().Replace("/", "\\");
138+
}
139+
catch (Exception)
140+
{
141+
path = value + "\\";
142+
}
136143
}
137144
FileDialog fd = new FileDialog("Folder Name");
138145
if (fd.ShowDialog() == true)
@@ -187,5 +194,41 @@ private void TV_CM_Delete_Click(object sender, RoutedEventArgs e)
187194
SetPath(path);
188195
}
189196
}
197+
198+
private void TV_CM_Import_Click(object sender, RoutedEventArgs e)
199+
{
200+
Microsoft.Win32.OpenFileDialog dlg = new Microsoft.Win32.OpenFileDialog();
201+
202+
// Display OpenFileDialog by calling ShowDialog method
203+
Nullable<bool> result = dlg.ShowDialog();
204+
205+
// Get the selected file name and display in a TextBox
206+
if (result == true)
207+
{
208+
// Open document
209+
string filename = dlg.FileName;
210+
TreeViewItem tvi = (TreeViewItem)foldersItem.SelectedItem;
211+
212+
String value = tvi.Tag.ToString();
213+
String path = "";
214+
if (value.Contains("/"))
215+
{
216+
path = value.Replace("/", "\\");
217+
}
218+
else
219+
{
220+
try
221+
{
222+
path = ((TreeViewItem)tvi.Parent).Tag.ToString().Replace("/", "\\");
223+
}
224+
catch (Exception)
225+
{
226+
path = value + "\\";
227+
}
228+
}
229+
File.Copy(filename, path + filename.Substring(filename.LastIndexOf('\\') + 1));
230+
SetPath(path);
231+
}
232+
}
190233
}
191234
}

WebKidzPlus/Editors/Editor.xaml.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -93,6 +93,7 @@ private void Tabs_SelectionChanged(object sender, SelectionChangedEventArgs e)
9393
if(Tabs.SelectedIndex == 1)
9494
{
9595
webControl.Source = new System.Uri("file://" + filePath);
96+
webControl.Reload(true);
9697
}else
9798
{
9899

WebKidzPlus/HeaderToImageConverter.cs

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,10 +29,30 @@ public object Convert(object v, Type targetType, object parameter, CultureInfo c
2929
{
3030
path = "pack://application:,,,/Images/CSS.png";
3131
}
32+
if (value.Substring(value.Length - 5).ToLower() == ".tiff")
33+
{
34+
path = "pack://application:,,,/Images/image.png";
35+
}
36+
if (value.Substring(value.Length - 5).ToLower() == ".jpeg")
37+
{
38+
path = "pack://application:,,,/Images/image.png";
39+
}
3240
if (value.Substring(value.Length - 3).ToLower() == ".js")
3341
{
3442
path = "pack://application:,,,/Images/JS.png";
3543
}
44+
if (value.Substring(value.Length - 4).ToLower() == ".png")
45+
{
46+
path = "pack://application:,,,/Images/image.png";
47+
}
48+
if (value.Substring(value.Length - 4).ToLower() == ".jpg")
49+
{
50+
path = "pack://application:,,,/Images/image.png";
51+
}
52+
if (value.Substring(value.Length - 4).ToLower() == ".gif")
53+
{
54+
path = "pack://application:,,,/Images/image.png";
55+
}
3656
Uri uri = new Uri(path);
3757
BitmapImage source = new BitmapImage(uri);
3858
return source;

WebKidzPlus/Images/image.png

256 KB
Loading

WebKidzPlus/WebKidzPlus.csproj

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -187,6 +187,9 @@
187187
<Resource Include="Images\diskdrive.png" />
188188
<Resource Include="Images\folder.png" />
189189
</ItemGroup>
190+
<ItemGroup>
191+
<Resource Include="Images\image.png" />
192+
</ItemGroup>
190193
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
191194
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
192195
Other similar extension points exist, see Microsoft.Common.targets.

WebKidzPlus/bin/Debug/debug.log

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,3 +12,7 @@
1212
[0501/020356:INFO:(0)] Running Awesomium 1.7.4.2
1313
[0501/020504:INFO:(0)] WebCore is now online.
1414
[0501/020504:INFO:(0)] Running Awesomium 1.7.4.2
15+
[0501/022107:INFO:(0)] WebCore is now online.
16+
[0501/022107:INFO:(0)] Running Awesomium 1.7.4.2
17+
[0501/022745:INFO:(0)] WebCore is now online.
18+
[0501/022745:INFO:(0)] Running Awesomium 1.7.4.2

WebKidzPlus/obj/Debug/DirectoryListing.g.i.cs

Lines changed: 19 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
#pragma checksum "..\..\DirectoryListing.xaml" "{406ea660-64cf-4c82-b6f0-42d48172a799}" "2ECDDDF26F1B941D60DBBC84B06775C1"
1+
#pragma checksum "..\..\DirectoryListing.xaml" "{406ea660-64cf-4c82-b6f0-42d48172a799}" "4A9AFA716493D04CEFCC2CC4C6DDAACE"
22
//------------------------------------------------------------------------------
33
// <auto-generated>
44
// This code was generated by a tool.
@@ -67,6 +67,14 @@ public partial class DirectoryListing : System.Windows.Controls.UserControl, Sys
6767

6868
#line 17 "..\..\DirectoryListing.xaml"
6969
[System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1823:AvoidUnusedPrivateFields")]
70+
internal System.Windows.Controls.MenuItem TV_CM_Import;
71+
72+
#line default
73+
#line hidden
74+
75+
76+
#line 19 "..\..\DirectoryListing.xaml"
77+
[System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1823:AvoidUnusedPrivateFields")]
7078
internal System.Windows.Controls.MenuItem TV_CM_Delete;
7179

7280
#line default
@@ -130,9 +138,18 @@ void System.Windows.Markup.IComponentConnector.Connect(int connectionId, object
130138
#line hidden
131139
return;
132140
case 4:
133-
this.TV_CM_Delete = ((System.Windows.Controls.MenuItem)(target));
141+
this.TV_CM_Import = ((System.Windows.Controls.MenuItem)(target));
134142

135143
#line 17 "..\..\DirectoryListing.xaml"
144+
this.TV_CM_Import.Click += new System.Windows.RoutedEventHandler(this.TV_CM_Import_Click);
145+
146+
#line default
147+
#line hidden
148+
return;
149+
case 5:
150+
this.TV_CM_Delete = ((System.Windows.Controls.MenuItem)(target));
151+
152+
#line 19 "..\..\DirectoryListing.xaml"
136153
this.TV_CM_Delete.Click += new System.Windows.RoutedEventHandler(this.TV_CM_Delete_Click);
137154

138155
#line default

0 commit comments

Comments
 (0)