示例#1
0
        public override void GetChildCollection(int index, ref FileCollectionBase new_collection, ref bool use_new, ref string preferred_focus)
        {
            internal_list.Keys[index].Update();

            if (!internal_list.Keys[index].DeviceReady)
            {
                Messages.ShowMessage(string.Format("Device {0} not ready.", internal_list.Keys[index].RootPathName));
                use_new = false;
                return;
            }


            preferred_focus = string.Empty;
            new_collection  = new DirectoryList(0, false, internal_list.Keys[index].RootPathName);
            try
            {
                new_collection.Refill();
                new_collection.MainWindow = this.MainWindow;
                use_new = true;
            }
            catch (Exception ex)
            {
                Messages.ShowException(ex);
            }
        }
示例#2
0
        public override void GetChildCollection(int index, ref FileCollectionBase new_collection, ref bool use_new, ref string preferred_focused_text)
        {
            if (!GetItemIsContainer(index))
            {
                use_new = false;
                return;
            }

            //returns DirectoryList of parent folder
            string target_dir = Path.GetDirectoryName(file_name_full);

            new_collection = new DirectoryList(0, false, target_dir);
            bool err = false;

            try
            {
                new_collection.Refill();
            }
            catch (Exception ex)
            {
                err = true;
                Messages.ShowException(ex);
            }

            if (err)
            {
                use_new = false;
            }
            else
            {
                use_new = true;
                preferred_focused_text = Path.GetFileName(file_name_full);
            }
        }
示例#3
0
        private void find_files(mFilePanel target_panel)
        {
            if (target_panel == null)
            {
                target_panel = doublePanel1.PanelActive;
            }

            DirectoryListFilterDialog filter_dialog = null;
            var filter = new DirectoryListFilter();

            filter.Load();

            if (doublePanel1.PanelActive.Source is DirectoryList)
            {
                filter.InCurrentDirectory            = true;
                filter.InCurrentDirectoryWithSubdirs = true;
                filter.CurrentDirectory = ((DirectoryList)doublePanel1.PanelActive.Source).DirectoryPath;
                filter.CurrentDrive     = Path.GetPathRoot(filter.CurrentDirectory);
            }

            filter_dialog      = new DirectoryListFilterDialog(true, filter);
            filter_dialog.Text = Options.GetLiteral(Options.LANG_FIND);
            if (filter_dialog.ShowDialog() == DialogResult.OK)
            {
                var result_dialog = new DirectorySearchResultDialog(filter_dialog.DirectoryListFilter);
                //result_dialog.BeginSearch(filter_dialog.DirectoryListFilter);
                if (result_dialog.ShowDialog() == DialogResult.OK)
                {
                    //go to...
                    var sel_file_name = result_dialog.SelectedResult;
                    if (string.IsNullOrEmpty(sel_file_name))
                    {
                        return;
                    }
                    var sel_dir  = Path.GetDirectoryName(sel_file_name);
                    var sel_file = Path.GetFileName(sel_file_name);
                    var dl       = new DirectoryList(target_panel.Source.SortCriteria, target_panel.Source.SortReverse, sel_dir);
                    target_panel.Source = dl;
                    dl.Refill();
                    var foc_index = dl.FindIndexOfName(sel_file);
                    if (foc_index != -1)
                    {
                        doublePanel1.PanelActive.FocusedIndex = foc_index;
                    }
                }
            }
        }
示例#4
0
        private void button1_Click(object sender, EventArgs e)
        {
            //DriveList dl = new DriveList(1, false);


            //mFilePanel1.Source = dl;
            //dl.Refill();

            //DirectoryList dirL = new DirectoryList(4, false, @"c:\temp");
            //dirL.Refill();

            DirectoryList dirL = new DirectoryList(0, false, @"d:\temp");

            mFilePanel1.Source = dirL;
            dirL.Refill();

            //DirectoryListFilterDialog f = new DirectoryListFilterDialog();
            //f.ShowDialog();
        }
示例#5
0
        public override void GetChildCollection(int index, ref FileCollectionBase new_collection, ref bool use_new, ref string preferred_focused_text)
        {
            if (index == 0)
            {
                //return container from wnet
                try
                {
                    NETRESOURCE      container = WinApiWNETwrapper.GetParentResource(server_ref);
                    WnetResourceList wnet_list = new WnetResourceList(SortCriteria, SortReverse, container);
                    preferred_focused_text = server_ref.lpRemoteName;
                    wnet_list.Refill();
                    use_new        = true;
                    new_collection = wnet_list;
                }
                catch (Exception ex)
                {
                    Messages.ShowException(ex);
                }
                return;
            }

            //else return DirectoryList
            try
            {
                string target_dir = string.Format
                                        ("{0}\\{1}",
                                        server_ref.lpRemoteName,
                                        internal_list.Keys[index - 1].shi1_netname);
                DirectoryList dir_list = new DirectoryList(SortCriteria, SortReverse, target_dir);
                dir_list.Refill();
                use_new        = true;
                new_collection = dir_list;
            }
            catch (Exception ex)
            {
                Messages.ShowException(ex);
            }
            return;
        }
示例#6
0
        public override void GetChildCollection
            (int index,
            ref FileCollectionBase new_collection,
            ref bool use_new,
            ref string preferred_focused_text)
        {
            if (!GetItemIsContainer(index))
            {
                use_new = false;
                return;
            }

            NETRESOURCE target_container = new NETRESOURCE();

            if (index == 0)
            {
                //go up to container of resourse_root

                //cache valid?
                if (parent_cache != null)
                {
                    //fill from cache
                    internal_list.Clear();
                    foreach (NETRESOURCE res in parent_cache.ResourceList)
                    {
                        internal_list.Add(res, null);
                    }
                    preferred_focused_text = resource_root.lpRemoteName;
                    resource_root          = parent_cache.ResourceRoot;
                    parent_cache           = parent_cache.ParentCache;
                    OnAfterRefill();
                    use_new = false;
                    return;
                }

                //workaround.
                //Wnet throws exception while getting parent of resource like 'Microsoft Windows Network'
                if ((resource_root.lpRemoteName == null) ||
                    (resource_root.dwDisplayType == ResourceDisplayType.NETWORK))
                {
                    target_container = WinApiWNETwrapper.RootNetresource;
                }
                else
                {
                    target_container = WinApiWNETwrapper.GetParentResource(resource_root);
                }

                preferred_focused_text = resource_root.lpRemoteName;

                //set new resource_root
                resource_root = target_container;

                //and fill
                Refill();

                //and return
                use_new = false;
                return;
            }//end of UP brunch

            //else go to down
            target_container = internal_list.Keys[index - 1];

            //case disk share - switch to DirectoryList
            if (target_container.dwType == ResourceType.DISK)
            {
                //switch to DirectoryList
                DirectoryList new_source = new DirectoryList
                                               (SortCriteria, SortReverse, target_container.lpRemoteName);
                new_source.MainWindow = MainWindow;

                try
                {
                    new_source.Refill();
                    use_new        = true;
                    new_collection = new_source;
                }
                catch (Win32Exception win5_ex)
                {
                    if (win5_ex.NativeErrorCode == 5) //access denied
                    {
                        //try to establish connection with creds
                        if (establish_connection(target_container))
                        {
                            try
                            {
                                //and retry
                                new_source.Refill();
                                use_new        = true;
                                new_collection = new_source;
                            }
                            catch (Exception ex)
                            {
                                Messages.ShowException(ex);
                            }
                        }
                    }
                    else
                    {
                        Messages.ShowException(win5_ex);
                    }
                }
                catch (Exception ex)
                {
                    Messages.ShowException(ex);
                }
                return;
            }

            //prepare parent cache
            InternalCache new_cache = new InternalCache(target_container);

            new_cache.ParentCache = parent_cache;
            new_cache.ResourceList.AddRange(internal_list.Keys);
            new_cache.ResourceRoot = resource_root;

            try
            {
                resource_root = target_container;
                use_new       = false;
                Refill();
                parent_cache = new_cache;
            }
            catch (Exception ex)
            {
                Messages.ShowException(ex);
            }
            return;
        }
示例#7
0
        public override void GetChildCollection
            (int index,
            ref FileCollectionBase new_collection,
            ref bool use_new,
            ref string preferred_focused_text)
        {
            if (LockSafe)
            {
                Messages.ShowMessage("Cannot change directory now.");
                return;
            }

            if (!GetItemIsContainer(index))
            {
                use_new = false;
                return;
            }

            //directory to go to..
            var target_dir   = internal_list.Keys[index];
            var old_virt_dir = string.Empty;

            if (target_dir == "..")
            {
                //up
                if (zip_virtual_dir == string.Empty)
                {
                    //go to directory list
                    try
                    {
                        new_collection         = new DirectoryList(0, false, Path.GetDirectoryName(zip_file_name));
                        preferred_focused_text = Path.GetFileName(zip_file_name);
                        use_new = true;
                        new_collection.MainWindow = (mainForm)Program.MainWindow;
                        new_collection.Refill();
                    }
                    catch (Exception ex)
                    {
                        Messages.ShowException(ex);
                    }
                    return;
                }
                else
                {
                    //up

                    old_virt_dir           = zip_virtual_dir;
                    zip_virtual_dir        = FtpPath.GetDirectory(zip_virtual_dir);
                    preferred_focused_text = old_virt_dir;
                    try
                    {
                        Refill();
                    }
                    catch (Exception ex)
                    {
                        zip_virtual_dir = old_virt_dir;
                        Messages.ShowException(ex);
                    }
                    return;
                }
            }
            else
            {
                //go to down

                old_virt_dir = zip_virtual_dir;

                //down
                zip_virtual_dir = target_dir;

                try
                {
                    Refill();
                }
                catch (Exception ex)
                {
                    zip_virtual_dir = old_virt_dir;
                    Messages.ShowException(ex);
                }
                return;
            }
        }