TECHNOLOGIES
FORUMS
JOBS
BOOKS
EVENTS
INTERVIEWS
Live
MORE
LEARN
Training
CAREER
MEMBERS
VIDEOS
NEWS
BLOGS
Sign Up
Login
No unread comment.
View All Comments
No unread message.
View All Messages
No unread notification.
View All Notifications
Answers
Post
An Article
A Blog
A News
A Video
An EBook
An Interview Question
Ask Question
Forums
Monthly Leaders
Forum guidelines
Sumit Kumawat
NA
454
414.8k
Navigation stack like windows explorer
Mar 12 2012 3:01 AM
I want to maintain a stack navigation in which we store path of directories.but in my code im able to store only current path and if i change my directories i lost my old stack.
for ex if i chande my directory from "My computer to Dowloads " then i am not able to keep path for my computer
here is my sample code
private void btnBack_Click(object sender, RoutedEventArgs e)
{
//string Tree1;
IList<DirInfo> childFileList = new List<DirInfo>();
// string Path = (sender as Button).ToString();
IList<DirInfo> childDirList = new List<DirInfo>();
if (stack.Count > 1)
{
stack.Pop();
stackNext.Push(stack.Peek());
string Path = stack.Peek().ToString();
isback = true;
//code for create button by sending drive info
//DirInfo dnr = new DirInfo();
//dnr.Path = Path;
//vm.createButton(dnr);
vm.createB(Path);
if (Path == "My Computer")
{
childDirList = (from rd in FileSystemExplorerService.GetRootDirectories1(vm.CurrentDirectory.Path)
select new DirInfo(rd)).ToList();
}
else if (Path == "My Favourite" || Path == "My Library")
{
childDirList = FileSystemExplorerService.GetRootDirectory1(Path);
}
else
{
childDirList = (from dir in FileSystemExplorerService.GetChildDirectories(Path)
select new DirInfo(dir)).ToList();
childFileList = (from fobj in FileSystemExplorerService.GetChildFiles(Path)
select new DirInfo(fobj)).ToList();
childDirList = childDirList.Concat(childFileList).ToList();
}
vm.CurrentItems = childDirList;
if (stack.Count > 1)
{
btnNext.IsEnabled = true;
}
else
btnBack.IsEnabled = false;
}
}
//private void RemoveRightSideButtonsFromNavigationBar(string Content)
//{
// bool flagRemove = false;
// List<Button> lstbuttonToBeRemoved = new List<Button>();
// foreach (Button btn in vm.NavigationStack)
// {
// if (btn.Content.ToString() == Content && !flagRemove)
// {
// flagRemove = true;
// }
// if (flagRemove && btn.Content.ToString() != Content)
// lstbuttonToBeRemoved.Add(btn);
// }
// foreach (Button btn in lstbuttonToBeRemoved)
// {
// vm.NavigationStack.Remove(btn);
// }
//}
private void btnNext_Click(object sender, RoutedEventArgs e)
{
IList<DirInfo> childFileList = new List<DirInfo>();
IList<DirInfo> childDirList = new List<DirInfo>();
if (stackNext.Count >= 1)
{
string Path = stackNext.Pop().ToString();
isback = true;
vm.createB(Path);
if (Path == "My Computer")
{
childDirList = (from rd in FileSystemExplorerService.GetRootDirectories1(Path)
select new DirInfo(rd)).ToList();
}
else if (Path == "My Favourite" || Path == "My Library")
{
childDirList = FileSystemExplorerService.GetRootDirectory1(Path);
}
else
{
childDirList = (from dir in FileSystemExplorerService.GetChildDirectories(Path)
select new DirInfo(dir)).ToList();
childFileList = (from fobj in FileSystemExplorerService.GetChildFiles(Path)
select new DirInfo(fobj)).ToList();
childDirList = childDirList.Concat(childFileList).ToList();
}
vm.CurrentItems = childDirList;
}
if (stackNext.Count >= 1)
{
btnBack.IsEnabled = true;
}
else
btnNext.IsEnabled = false;
}
Reply
Answers (
0
)
Linq syntax transfer
Opening powerpoint file through c sharp coding