Exemple #1
0
        private void show_network_root(mFilePanel target_panel)
        {
            var nl = new WnetResourceList
                         (0, false, netCommander.WNet.WinApiWNETwrapper.RootNetresource);

            nl.MainWindow       = this;
            target_panel.Source = nl;
            nl.Refill();
        }
Exemple #2
0
        private void jump_to(mFilePanel target_panel)
        {
            var dial = new JumpToDialog();

            dial.Text = Options.GetLiteral(Options.LANG_WHERE_TO_JUMP);

            if (dial.ShowDialog() != DialogResult.OK)
            {
                return;
            }

            var path = dial.textBoxPath.Text;
            FileCollectionBase new_source = null;

            try
            {
                //parse path
                if (path.StartsWith(@"\\"))
                {
                    //assume smb path

                    var target_res = WinApiWNETwrapper.GetResourceInfo(path);
                    if (target_res.dwDisplayType == netCommander.WNet.ResourceDisplayType.SHARE)
                    {
                        //it is network share - show directory list
                        new_source = new DirectoryList(0, false, path);
                    }
                    else if ((target_res.dwUsage & ResourceUsage.CONTAINER) != ResourceUsage.CONTAINER)
                    {
                        //target_res is not container - try show parent
                        target_res = WinApiWNETwrapper.GetParentResource(target_res);
                        new_source = new WnetResourceList(0, false, target_res);
                    }
                    else
                    {
                        //show target_resource
                        new_source = new WnetResourceList(0, false, target_res);
                    }
                }//end of stratsWith("\\") brunch
                else
                {
                    new_source = new DirectoryList(0, false, path);
                }

                //now refill source
                new_source.MainWindow = this;
                new_source.Refill();
                target_panel.Source = new_source;
                target_panel.Refresh();
            }
            catch (Exception ex)
            {
                Messages.ShowException(ex, string.Format(Options.GetLiteral(Options.LANG_CANNOT_SHOW_0), path));
            }
        }
Exemple #3
0
        protected override void internal_command_proc()
        {
            QueryPanelInfoEventArgs e = new QueryPanelInfoEventArgs();

            OnQueryCurrentPanel(e);

            WnetResourceList rl = (WnetResourceList)e.ItemCollection;

            if (rl.GetItemDisplayNameLong(e.FocusedIndex) == "..")
            {
                return;
            }

            NETRESOURCE res_info = rl[e.FocusedIndex];

            NetInfoDialog dialog = new NetInfoDialog();

            dialog.FillInfo(res_info);
            dialog.ShowDialog();
        }
Exemple #4
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;
        }
        public override void GetChildCollection
            (int index,
            ref FileCollectionBase new_collection,
            ref bool use_new,
            ref string preferred_focus)
        {
            if (!GetItemIsContainer(index))
            {
                use_new = false;
                return;
            }

            //directory to go to..
            string target_dir = Path.Combine(directory_path, internal_list.Keys[index].cFileName);

            target_dir = Path.GetFullPath(target_dir);

            //case for smb network paths
            if ((target_dir == directory_path) && (target_dir.StartsWith(@"\\")))
            {
                //go to share list
                try
                {
                    netCommander.WNet.NETRESOURCE target_res =
                        netCommander.WNet.WinApiWNETwrapper.GetParentResource
                            (netCommander.WNet.WinApiWNETwrapper.GetResourceInfo(directory_path));
                    WnetResourceList netsh_list = new WnetResourceList(0, false, target_res);
                    netsh_list.MainWindow = MainWindow;
                    netsh_list.Refill();
                    new_collection  = netsh_list;
                    use_new         = true;
                    preferred_focus = directory_path;
                }
                catch (Exception ex)
                {
                    Messages.ShowException(ex);
                }
                return;
            }

            //preferred focus text
            if (internal_list.Keys[index].cFileName == "..")
            {
                //go up
                string old_dir = Path.GetFileName(directory_path);
                preferred_focus = old_dir;
            }
            else
            {
                //go down - focus on 0
                preferred_focus = string.Empty;
            }

            //use current DirectoryList
            use_new = false;
            //save current directory path
            //needed if exception occur while filling
            string dir_old = directory_path;

            directory_path = target_dir;
            try
            {
                Refill();
            }
            catch (Exception ex)
            {
                //directory path not change
                directory_path = dir_old;
                Messages.ShowException(ex);
            }
        }