Skip to content

Commit

Permalink
Added Import File
Browse files Browse the repository at this point in the history
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
  • Loading branch information
barkermn01 committed May 1, 2016
1 parent 0a61112 commit 8f2207e
Show file tree
Hide file tree
Showing 8 changed files with 93 additions and 3 deletions.
2 changes: 2 additions & 0 deletions WebKidzPlus/DirectoryListing.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@
</MenuItem>
<MenuItem Name="TV_CM_NewFile" Header="New File" Click="TV_CM_NewFile_Click">
</MenuItem>
<MenuItem Name="TV_CM_Import" Header="Import File" Click="TV_CM_Import_Click">
</MenuItem>
<MenuItem Name="TV_CM_Delete" Header="Delete" Click="TV_CM_Delete_Click">
</MenuItem>
</ContextMenu>
Expand Down
45 changes: 44 additions & 1 deletion WebKidzPlus/DirectoryListing.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,14 @@ private void TV_CM_NewDir_Click(object sender, RoutedEventArgs e)
}
else
{
path = ((TreeViewItem)tvi.Parent).Tag.ToString().Replace("/", "\\");
try
{
path = ((TreeViewItem)tvi.Parent).Tag.ToString().Replace("/", "\\");
}
catch (Exception)
{
path = value + "\\";
}
}
FileDialog fd = new FileDialog("Folder Name");
if (fd.ShowDialog() == true)
Expand Down Expand Up @@ -187,5 +194,41 @@ private void TV_CM_Delete_Click(object sender, RoutedEventArgs e)
SetPath(path);
}
}

private void TV_CM_Import_Click(object sender, RoutedEventArgs e)
{
Microsoft.Win32.OpenFileDialog dlg = new Microsoft.Win32.OpenFileDialog();

// Display OpenFileDialog by calling ShowDialog method
Nullable<bool> result = dlg.ShowDialog();

// Get the selected file name and display in a TextBox
if (result == true)
{
// Open document
string filename = dlg.FileName;
TreeViewItem tvi = (TreeViewItem)foldersItem.SelectedItem;

String value = tvi.Tag.ToString();
String path = "";
if (value.Contains("/"))
{
path = value.Replace("/", "\\");
}
else
{
try
{
path = ((TreeViewItem)tvi.Parent).Tag.ToString().Replace("/", "\\");
}
catch (Exception)
{
path = value + "\\";
}
}
File.Copy(filename, path + filename.Substring(filename.LastIndexOf('\\') + 1));
SetPath(path);
}
}
}
}
1 change: 1 addition & 0 deletions WebKidzPlus/Editors/Editor.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,7 @@ private void Tabs_SelectionChanged(object sender, SelectionChangedEventArgs e)
if(Tabs.SelectedIndex == 1)
{
webControl.Source = new System.Uri("file://" + filePath);
webControl.Reload(true);
}else
{

Expand Down
20 changes: 20 additions & 0 deletions WebKidzPlus/HeaderToImageConverter.cs
Original file line number Diff line number Diff line change
Expand Up @@ -29,10 +29,30 @@ public object Convert(object v, Type targetType, object parameter, CultureInfo c
{
path = "pack://application:,,,/Images/CSS.png";
}
if (value.Substring(value.Length - 5).ToLower() == ".tiff")
{
path = "pack://application:,,,/Images/image.png";
}
if (value.Substring(value.Length - 5).ToLower() == ".jpeg")
{
path = "pack://application:,,,/Images/image.png";
}
if (value.Substring(value.Length - 3).ToLower() == ".js")
{
path = "pack://application:,,,/Images/JS.png";
}
if (value.Substring(value.Length - 4).ToLower() == ".png")
{
path = "pack://application:,,,/Images/image.png";
}
if (value.Substring(value.Length - 4).ToLower() == ".jpg")
{
path = "pack://application:,,,/Images/image.png";
}
if (value.Substring(value.Length - 4).ToLower() == ".gif")
{
path = "pack://application:,,,/Images/image.png";
}
Uri uri = new Uri(path);
BitmapImage source = new BitmapImage(uri);
return source;
Expand Down
Binary file added WebKidzPlus/Images/image.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
3 changes: 3 additions & 0 deletions WebKidzPlus/WebKidzPlus.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -187,6 +187,9 @@
<Resource Include="Images\diskdrive.png" />
<Resource Include="Images\folder.png" />
</ItemGroup>
<ItemGroup>
<Resource Include="Images\image.png" />
</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
4 changes: 4 additions & 0 deletions WebKidzPlus/bin/Debug/debug.log
Original file line number Diff line number Diff line change
Expand Up @@ -12,3 +12,7 @@
[0501/020356:INFO:(0)] Running Awesomium 1.7.4.2
[0501/020504:INFO:(0)] WebCore is now online.
[0501/020504:INFO:(0)] Running Awesomium 1.7.4.2
[0501/022107:INFO:(0)] WebCore is now online.
[0501/022107:INFO:(0)] Running Awesomium 1.7.4.2
[0501/022745:INFO:(0)] WebCore is now online.
[0501/022745:INFO:(0)] Running Awesomium 1.7.4.2
21 changes: 19 additions & 2 deletions WebKidzPlus/obj/Debug/DirectoryListing.g.i.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#pragma checksum "..\..\DirectoryListing.xaml" "{406ea660-64cf-4c82-b6f0-42d48172a799}" "2ECDDDF26F1B941D60DBBC84B06775C1"
#pragma checksum "..\..\DirectoryListing.xaml" "{406ea660-64cf-4c82-b6f0-42d48172a799}" "4A9AFA716493D04CEFCC2CC4C6DDAACE"
//------------------------------------------------------------------------------
// <auto-generated>
// This code was generated by a tool.
Expand Down Expand Up @@ -67,6 +67,14 @@ public partial class DirectoryListing : System.Windows.Controls.UserControl, Sys

#line 17 "..\..\DirectoryListing.xaml"
[System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1823:AvoidUnusedPrivateFields")]
internal System.Windows.Controls.MenuItem TV_CM_Import;

#line default
#line hidden


#line 19 "..\..\DirectoryListing.xaml"
[System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1823:AvoidUnusedPrivateFields")]
internal System.Windows.Controls.MenuItem TV_CM_Delete;

#line default
Expand Down Expand Up @@ -130,9 +138,18 @@ void System.Windows.Markup.IComponentConnector.Connect(int connectionId, object
#line hidden
return;
case 4:
this.TV_CM_Delete = ((System.Windows.Controls.MenuItem)(target));
this.TV_CM_Import = ((System.Windows.Controls.MenuItem)(target));

#line 17 "..\..\DirectoryListing.xaml"
this.TV_CM_Import.Click += new System.Windows.RoutedEventHandler(this.TV_CM_Import_Click);

#line default
#line hidden
return;
case 5:
this.TV_CM_Delete = ((System.Windows.Controls.MenuItem)(target));

#line 19 "..\..\DirectoryListing.xaml"
this.TV_CM_Delete.Click += new System.Windows.RoutedEventHandler(this.TV_CM_Delete_Click);

#line default
Expand Down

0 comments on commit 8f2207e

Please sign in to comment.