Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add code #10

Open
wants to merge 26 commits into
base: feature/test_branch
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
26 commits
Select commit Hold shift + click to select a range
0a0e35d
Added one more task to project
Jul 15, 2017
3e0e2d8
Merge pull request #7 from PP16V1/feature/add_abstractions
PP16V1 Jul 15, 2017
ac68eda
Change
ShemetViktoriia Jul 15, 2017
169b555
SMS
Darkvyl Jul 15, 2017
f92cd63
Merge pull request #9 from PP16V1/SMS
Darkvyl Jul 15, 2017
bc95390
File manager
IevgenSuturin Jul 15, 2017
9690707
Merge pull request #12 from PP16V1/File-Meneger
IevgenSuturin Jul 15, 2017
b008107
File manager
IevgenSuturin Jul 15, 2017
06994d8
Merge pull request #14 from PP16V1/File-Meneger
IevgenSuturin Jul 15, 2017
733f3d8
File Manager
IevgenSuturin Jul 16, 2017
02a8bdb
Merge pull request #15 from PP16V1/File-Meneger
IevgenSuturin Jul 16, 2017
0379a56
Merge pull request #16 from PP16V1/master
MedenetsO Jul 17, 2017
8f62ece
File Manager
IevgenSuturin Jul 17, 2017
1a090c5
Merge pull request #17 from PP16V1/File-Meneger
IevgenSuturin Jul 17, 2017
dc57463
Merge pull request #8 from PP16V1/Add_to_file_readme
PP16V1 Jul 20, 2017
4ee4744
Add Test for SMS
Darkvyl Jul 20, 2017
ccf5338
Organiser
Darkvyl Jul 20, 2017
cc02e5b
Merge pull request #18 from PP16V1/Organaiser
Darkvyl Jul 20, 2017
ac70e50
File Managr
IevgenSuturin Jul 21, 2017
a128277
Merge branch 'master' of https://github.com/PP16V1/iStepPhone
IevgenSuturin Jul 21, 2017
04aad4d
Add:
MedenetsO Jul 21, 2017
45d4508
Add: header, main Menu, UserSettings, ProgressBar
MedenetsO Jul 21, 2017
e3670ce
LoginPage in process.
MedenetsO Jul 22, 2017
710344a
Merge remote-tracking branch 'origin/master' into Menu
PP16V1 Jul 22, 2017
c89f0dc
Merge pull request #20 from PP16V1/Menu
PP16V1 Jul 22, 2017
cd05c62
Add method invoke
PP16V1 Jul 22, 2017
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,11 @@ Project structure:
user.ini;
menu.config;
logging; - Olha Medenets
- Address book;
- Address book - Shemet Viktoriya;
- SMS - Kirill Maneychik;
- Organaizer - Kirill Maneychik;
- Playmarket;
- XO;
- Snake;
- FileManager;
- FileManager - Ievgen Suturin;
- Backup, programs control center;
98 changes: 98 additions & 0 deletions _Basket/UICopier.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,98 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.IO;
using iStepPhone.FileManager.Abstract;
using iStepPhone.FileManager.Factory;

namespace iStepPhone.FileManager.Model
{
public class UICopier: IExecuteble
{
private UIExplorer explorer;
private List<UserDirectoryClass> Items;
private UserDirectoryClass selected;

public UICopier(UIExplorer _explorer, List<UserDirectoryClass> items, UserDirectoryClass _selected)
{
explorer = _explorer;
Items = items;
selected = _selected;
}

public void Copy()
{
Console.Clear();
string str = string.Format("You are about to copy file {0}\n Please, select the destination pass and pree \"Enter\"\n", selected.Name);
explorer.ShowExplorerForImplementation(Items, this, str);
}


private void CopyFile(UserDirectoryClass source, UserDirectoryClass baseDestination)
{
if(!File.Exists(source.FullName))
{
return;
}

if(!File.Exists(Path.Combine(baseDestination.FullName, source.Name)))
{
new FileInfo(source.FullName).CopyTo(Path.Combine(baseDestination.FullName, source.Name));
UserDirectoryClass destination = new UserDirectoryClass();
destination.Name = source.Name;
destination.Children = null;
destination.FullName = Path.Combine(baseDestination.FullName, source.Name);
baseDestination.Children.Add(destination);
}
}

private void CopyDirectory(UserDirectoryClass source, UserDirectoryClass baseDestination)
{
if (!Directory.Exists(source.FullName))
{
return;
}

if (!Directory.Exists(Path.Combine(baseDestination.FullName, source.Name)))
{
Directory.CreateDirectory(Path.Combine(baseDestination.FullName, source.Name));
}

UserDirectoryClass destination = new UserDirectoryClass();
int index = -1;
if ((index = baseDestination.Children.FindIndex(x => x.FullName == Path.Combine(baseDestination.FullName, source.Name))) < 0)
{
destination.Name = source.Name;
destination.FullName = Path.Combine(baseDestination.FullName, source.Name);
baseDestination.Children.Add(destination);
}
else
{
destination = baseDestination.Children[index];
}

foreach (UserDirectoryClass item in source.Children)
{
if (Directory.Exists(item.FullName))
CopyDirectory(item, destination);

if (File.Exists(item.FullName))
CopyFile(item, destination);
}
}

public void Execute(UserDirectoryClass destination)
{
if (Directory.Exists(destination.FullName))
{
if (File.Exists(selected.FullName))
CopyFile(selected, destination);

if (Directory.Exists(selected.FullName))
CopyDirectory(selected, destination);
}
}
}
}
17 changes: 17 additions & 0 deletions code/Test/SUBTEST1/FACTORY/CreateObject.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace iStepPhone.FileManager.Factory
{
class CreateObject
{
public static object CreateInstance(string typeName, string AssemblyName)
{
var instance = Activator.CreateInstance(AssemblyName, typeName).Unwrap();
return instance;
}
}
}
52 changes: 52 additions & 0 deletions code/Test/SUBTEST1/FACTORY/UIExplorerCreator.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.IO;

namespace iStepPhone.FileManager.Factory
{
public class UserDirectoryClass
{
public bool IsActive { get; set; }
public string Name { get; set; }
public string FullName { get; set; }
public List<UserDirectoryClass> Children { get; set; }
public UserDirectoryClass()
{
Children = new List<UserDirectoryClass>();
IsActive = false;
}
public override string ToString()
{
return Name;
}
}

class UIExplorerCreator
{
public List<UserDirectoryClass> MakingDirrectoryTree(string root)
{
DirectoryInfo dir = new DirectoryInfo(root);
List<UserDirectoryClass> list = new List<UserDirectoryClass>();
foreach (var item in dir.GetDirectories())
{
UserDirectoryClass userDir = new UserDirectoryClass();
userDir.Name = item.Name.ToUpper();
userDir.FullName = item.FullName;
list.Add(userDir);
userDir.Children.AddRange(MakingDirrectoryTree(item.FullName));
}

foreach (var item in dir.GetFiles())
{
UserDirectoryClass userDir = new UserDirectoryClass();
userDir.Name = item.Name;
userDir.FullName = item.FullName;
list.Add(userDir);
}
return list;
}
}
}
Loading