Example #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);
            }
        }
        protected override void internal_command_proc()
        {
            QueryPanelInfoEventArgs e_current = new QueryPanelInfoEventArgs();
            QueryPanelInfoEventArgs e_other   = new QueryPanelInfoEventArgs();

            OnQueryCurrentPanel(e_current);
            OnQueryOtherPanel(e_other);
            DirectoryList dl_current = (DirectoryList)e_current.ItemCollection;
            DirectoryList dl_other   = null;

            if (e_other.ItemCollection is DirectoryList)
            {
                dl_other = (DirectoryList)e_other.ItemCollection;
            }

            //prepare dialog
            CreateDirectoryDialog dialog = new CreateDirectoryDialog();

            dialog.Text = "Create directory";
            dialog.labelParentDir.Text              = dl_current.DirectoryPath + Path.DirectorySeparatorChar;
            dialog.checkBoxUseTemplate.Checked      = false;
            dialog.textBoxTemplateDirectory.Enabled = false;
            if ((dl_other == null) || (e_other.FocusedIndex <= 0))
            {
                dialog.checkBoxUseTemplate.Checked      = false;
                dialog.textBoxTemplateDirectory.Enabled = false;
            }
            else
            {
                dialog.textBoxTemplateDirectory.Text = Path.Combine(dl_other.DirectoryPath, dl_other.GetItemDisplayNameLong(e_other.FocusedIndex));
            }

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

            if (dialog.textBoxDirectoryName.Text == string.Empty)
            {
                Messages.ShowMessage("Directory exists.");
                return;
            }

            string new_directory_name = Path.Combine(dl_current.DirectoryPath, dialog.textBoxDirectoryName.Text);
            string template_dir       = string.Empty;

            if (dialog.checkBoxUseTemplate.Checked)
            {
                template_dir = dialog.textBoxTemplateDirectory.Text;
            }

            try
            {
                Wrapper.CreateDirectoryTree(new_directory_name, template_dir);
            }
            catch (Exception ex)
            {
                Messages.ShowException(ex, string.Format("Failed to create directory '{0}'.", new_directory_name));
            }
        }
Example #3
0
 void sort_menu_item_Click(object sender, EventArgs e)
 {
     try
     {
         var src_menu = (MenuItem)sender;
         var ind      = internal_sort_menu.IndexOf(src_menu);
         if (ind < 0)
         {
             return;
         }
         if (ind == SortCriteria)
         {
             //change sort order
             SortReverse = !SortReverse;
         }
         else
         {
             SortCriteria = ind;
         }
     }
     catch (Exception ex)
     {
         Messages.ShowException(ex);
     }
 }
Example #4
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);
            }
        }
Example #5
0
        private bool establish_connection(NETRESOURCE target_resource)
        {
            //ask creds
            string user_name = string.Empty;
            string ps        = string.Empty;

            if (Messages.AskCredentials
                    ("Network login",
                    "Connect to " + target_resource.lpRemoteName,
                    ref user_name,
                    ref ps) != System.Windows.Forms.DialogResult.OK)
            {
                return(false);
            }

            int res = WinApiWNET.WNetAddConnection2
                          (ref target_resource,
                          ps,
                          user_name,
                          WNetConnectOptions.None);

            if (res != WinApiWNET.NO_ERROR)
            {
                Win32Exception win_ex = new Win32Exception(res);
                Messages.ShowException(win_ex);
                return(false);
            }
            return(true);
        }
Example #6
0
        private void intern_execute()
        {
            var reg_pattern = Options.REGEX_PARSE_COMMAND;
            var rex         = new Regex(reg_pattern);

            try
            {
                var splitted = rex.Split(textBox1.Text, 2);
                if (splitted.Length < 2)
                {
                    throw new ArgumentException(Options.GetLiteral(Options.LANG_CANNOT_PARSE_COMMAND_LINE));
//                  throw new ApplicationException(Options.GetLiteral(Options.LANG_CANNOT_PARSE_COMMAND_LINE));
                }

                var command_name = splitted[1];
                var command_args = splitted.Length > 2 ? splitted[2] : string.Empty;

                var psi = new ProcessStartInfo();
                psi.Arguments        = command_args;
                psi.CreateNoWindow   = false;
                psi.ErrorDialog      = false;
                psi.FileName         = command_name;
                psi.UseShellExecute  = true;
                psi.WorkingDirectory = Directory.GetCurrentDirectory();

                var p = new Process();
                p.StartInfo = psi;
                p.Start();
            }
            catch (Exception ex)
            {
                Messages.ShowException(ex, string.Format(Options.GetLiteral(Options.LANG_CANNOT_EXECUTE_0), textBox1.Text));
            }
        }
Example #7
0
 private void process_exceptions(Exception ex)
 {
     if (!supress_exceptions)
     {
         Messages.ShowException(ex);
     }
 }
Example #8
0
        private bool establish_connection(NETRESOURCE target_resource)
        {
            //ask creds
            var user_name = string.Empty;
            var ps        = string.Empty;

            if (Messages.AskCredentials
                    (Options.GetLiteral(Options.LANG_NETWORK_LOGIN),
                    "Connect to " + target_resource.lpRemoteName,
                    ref user_name,
                    ref ps) != System.Windows.Forms.DialogResult.OK)
            {
                return(false);
            }

            var res = WinApiWNET.WNetAddConnection2
                          (ref target_resource,
                          ps,
                          user_name,
                          WNetConnectOptions.None);

            if (res != WinApiWNET.NO_ERROR)
            {
                var win_ex = new Win32Exception(res);
                Messages.ShowException(win_ex);
                return(false);
            }
            return(true);
        }
Example #9
0
        protected override void internal_command_proc()
        {
            QueryPanelInfoEventArgs e = new QueryPanelInfoEventArgs();

            OnQueryCurrentPanel(e);

            if (!(e.ItemCollection is DirectoryList))
            {
                return;
            }

            try
            {
                DirectoryList   dl   = (DirectoryList)e.ItemCollection;
                VolumeSpaceInfo info = WinAPiFSwrapper.GetVolumeSpaceInfo(dl.DirectoryPath);

                VolumeSpaceInfoDialog dialog = new VolumeSpaceInfoDialog();
                dialog.textBoxTotalSize.Text      = IOhelper.SizeToString(info.TotalNumberOfBytes);
                dialog.textBoxTotalAvailable.Text = IOhelper.SizeToString(info.FreeBytesAvailable);
                dialog.Text = dl.DirectoryPath;
                dialog.ShowDialog();
            }
            catch (Exception ex)
            {
                Messages.ShowException(ex);
            }
        }
Example #10
0
        public void Init(MenuItem parent_menu)
        {
            parent_plugin_menu = parent_menu;
            plugins_loaded.Clear();

            //first get plugins dll
            var plugins_dll = Directory.GetFiles
                                  (Path.GetDirectoryName(Application.ExecutablePath),
                                  "plugin_*.dll",
                                  SearchOption.TopDirectoryOnly);

            //iterate throw dlls
            foreach (var plugin_dll in plugins_dll)
            {
                try
                {
                    //load assembly
                    Assembly plugin_assembly = null;
                    plugin_assembly = Assembly.LoadFile(plugin_dll);
                    if (plugin_assembly == null)
                    {
                        continue;
                    }

                    var plugin_types = plugin_assembly.GetTypes();
                    //iterate throw assembly types
                    foreach (var one_type in plugin_types)
                    {
                        //continue if type is not class and not public public
                        if (!(one_type.IsClass && one_type.IsPublic))
                        {
                            continue;
                        }

                        //check if type implements IPlugin interface
                        var plugin_interface_type = one_type.GetInterface("IPlugin", true);
                        if (plugin_interface_type == null)
                        {
                            continue;
                        }

                        //create plugin instance
                        var one_plugin = (IPlugin)plugin_assembly.CreateInstance(one_type.FullName);

                        //add to list
                        plugins_loaded.Add(one_plugin);

                        //bind to query callback
                        one_plugin.QueryHostInfo += new QueryHostInfoEventHandler(one_plugin_QueryHostInfo);

                        //call init
                        one_plugin.Init();
                    }
                }//to next type
                catch (Exception ex)
                {
                    Messages.ShowException(ex, string.Format(Options.GetLiteral(Options.LANG_FAILED_TO_LOAD_PLUGIN_FROM_0), plugin_dll));
                }
            }//to next dll
        }
Example #11
0
        private void create_fs_directory(QueryPanelInfoEventArgs e_current, QueryPanelInfoEventArgs e_other)
        {
            var           dl_current = (DirectoryList)e_current.ItemCollection;
            DirectoryList dl_other   = null;

            if (e_other.ItemCollection is DirectoryList)
            {
                dl_other = (DirectoryList)e_other.ItemCollection;
            }

            //prepare dialog
            var dialog = new CreateDirectoryDialog();

            dialog.Text = CommandMenu.Text;
            dialog.labelParentDir.Text              = dl_current.DirectoryPath + Path.DirectorySeparatorChar;
            dialog.checkBoxUseTemplate.Checked      = false;
            dialog.textBoxTemplateDirectory.Enabled = false;
            if ((dl_other == null) || (e_other.FocusedIndex <= 0))
            {
                dialog.checkBoxUseTemplate.Checked      = false;
                dialog.textBoxTemplateDirectory.Enabled = false;
            }
            else
            {
                dialog.textBoxTemplateDirectory.Text = Path.Combine(dl_other.DirectoryPath, dl_other.GetItemDisplayNameLong(e_other.FocusedIndex));
            }

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

            if (dialog.textBoxDirectoryName.Text == string.Empty)
            {
                Messages.ShowMessage(Options.GetLiteral(Options.LANG_DIRECTORY_EXISTS));
                return;
            }

            var new_directory_name = Path.Combine(dl_current.DirectoryPath, dialog.textBoxDirectoryName.Text);
            var template_dir       = string.Empty;

            if (dialog.checkBoxUseTemplate.Checked)
            {
                template_dir = dialog.textBoxTemplateDirectory.Text;
            }

            try
            {
                WinAPiFSwrapper.CreateDirectoryTree(new_directory_name, template_dir);
            }
            catch (Exception ex)
            {
                Messages.ShowException
                    (ex,
                    string.Format
                        (Options.GetLiteral(Options.LANG_CANNOT_CREATE_DIRECTORY_0),
                        new_directory_name));
            }
        }
Example #12
0
        private void FillStandardPage(string file_name)
        {
            IntPtr file_handle  = IntPtr.Zero;
            string nt_file_name = IOhelper.GetUnicodePath(file_name);

            try
            {
                textBoxName.Text = string.Format
                                       ("{0}",
                                       Path.GetFileName(file_name));

                // find data --------------------------------------
                WIN32_FIND_DATA f_data = new WIN32_FIND_DATA();
                WinAPiFSwrapper.GetFileInfo(file_name, ref f_data);
                textBoxAttributes.Text = f_data.dwFileAttributes.ToString();
                textBoxAltname.Text    = f_data.cAlternateFileName;
                textBoxReaprseTag.Text = f_data.ReparseTag.ToString();
                //--------------------------------------------------

                fileSystemSecurityViewer1.FillContains(file_name);

                try
                {
                    fill_basic_info();
                    //fill_device();
                    fill_standard_info();
                    //fill_volume_attr();
                    //fill_volume_info();
                    fill_links(f_data.ReparseTag);
                    fill_dir_size();
                }
                catch (Exception ex)
                {
                    Messages.ShowException(ex);
                }

                try
                {
                    streamViewer1.FillContents(file_name);
                }
                catch (Exception)
                {
                }
            }
            catch (Exception ex)
            {
                Messages.ShowException(ex);
            }
            finally
            {
                if ((file_handle != IntPtr.Zero) && (file_handle.ToInt32() != WinApiFS.INVALID_HANDLE_VALUE))
                {
                    WinApiFS.CloseHandle(file_handle);
                }
            }
        }
Example #13
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));
            }
        }
Example #14
0
        protected override void internal_command_proc()
        {
            QueryPanelInfoEventArgs e = new QueryPanelInfoEventArgs();

            OnQueryCurrentPanel(e);

            if (e.FocusedIndex < 0)
            {
                return;
            }

            DirectoryList dl_list = (DirectoryList)e.ItemCollection;

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

            //check volume caps
            string     root_path = Path.GetPathRoot(dl_list.DirectoryPath);
            VolumeInfo vi        = new VolumeInfo(root_path);

            if ((vi.FileSystemFlags & VolumeCaps.NamedStreams) != VolumeCaps.NamedStreams)
            {
                Messages.ShowMessage
                    (string.Format
                        ("File system on drive {0} not support named streams",
                        root_path));
                return;
            }

            StreamList new_source = new StreamList
                                        (Path.Combine(dl_list.DirectoryPath, dl_list.GetItemDisplayNameLong(e.FocusedIndex)),
                                        false,
                                        0,
                                        false);

            try
            {
                new_source.Refill();
            }
            catch (Exception ex)
            {
                Messages.ShowException(ex);
                return;
            }

            SetNewSourceEventArgs e_new_source = new SetNewSourceEventArgs
                                                     (new_source,
                                                     false,
                                                     string.Empty);

            OnSetNewSource(e_new_source);
        }
Example #15
0
 public override string GetCommandlineTextLong(int index)
 {
     try
     {
         return(this[index].MainModule.FileName);
     }
     catch (Exception ex)
     {
         Messages.ShowException(ex);
         return(string.Empty);
     }
 }
Example #16
0
        private void create_zip_directory(QueryPanelInfoEventArgs e_current)
        {
            var zd = (ZipDirectory)e_current.ItemCollection;

            //prepare dialog
            var dialog = new CreateDirectoryDialog();

            dialog.Text = CommandMenu.Text;
            dialog.labelParentDir.Text              = zd.CurrentZipDirectory + "/";
            dialog.checkBoxUseTemplate.Checked      = false;
            dialog.checkBoxUseTemplate.Enabled      = false;
            dialog.textBoxTemplateDirectory.Enabled = false;

            if (dialog.ShowDialog() != DialogResult.OK)
            {
                return;
            }
            if (dialog.textBoxDirectoryName.Text.Length == 0)
            {
                Messages.ShowMessage("directory name cannot be empty");
                return;
            }

            var new_directory_name = string.Empty;

            if (zd.CurrentZipDirectory == string.Empty)
            {
                new_directory_name = dialog.textBoxDirectoryName.Text;
            }
            else
            {
                new_directory_name = zd.CurrentZipDirectory + "/" + dialog.textBoxDirectoryName.Text;
            }
            if (!new_directory_name.EndsWith("/"))
            {
                new_directory_name = new_directory_name + "/";
            }

            try
            {
                var dir_entry = zd.ZipFile.EntryFactory.MakeDirectoryEntry(new_directory_name);
                dir_entry.Size           = 0;
                dir_entry.CompressedSize = 0; //required, else exception throws
                zd.ZipFile.BeginUpdate();
                zd.ZipFile.Add(dir_entry);
                zd.ZipFile.CommitUpdate();
                zd.Refill();
            }
            catch (Exception ex)
            {
                Messages.ShowException(ex);
            }
        }
Example #17
0
        protected override void internal_command_proc()
        {
            QueryPanelInfoEventArgs e_current = new QueryPanelInfoEventArgs();

            OnQueryCurrentPanel(e_current);
            FtpDirectoryList ftp_list = (FtpDirectoryList)e_current.ItemCollection;

            string current_dir = ftp_list.DirectoryPath;

            //show dialog
            CreateDirectoryDialog dialog = new CreateDirectoryDialog();

            dialog.Text = Options.GetLiteral(Options.LANG_DIRECTORY_CREATE);
            dialog.labelParentDir.Text              = current_dir;
            dialog.checkBoxUseTemplate.Enabled      = false;
            dialog.textBoxTemplateDirectory.Enabled = false;

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

            string new_dir = FtpPath.Combine(current_dir, dialog.textBoxDirectoryName.Text);

            //create dir tree
            if (ftp_list.MainWindow != null)
            {
                ftp_list.MainWindow.NotifyLongOperation
                    (string.Format
                        (Options.GetLiteral(Options.LANG_DIRECTORY_CREATE_0),
                        new_dir),
                    true);
            }

            try
            {
                ftp_list.Connection.CreateDirectoryTree(new_dir);
            }
            catch (Exception ex)
            {
                Messages.ShowException(ex);
            }

            if (ftp_list.MainWindow != null)
            {
                ftp_list.MainWindow.NotifyLongOperation
                    (string.Empty,
                    false);
            }

            ftp_list.Refill();
        }
Example #18
0
        private void copy_selection(bool unicode)
        {
            try
            {
                var selection_len = (int)(TextViewControl.SelectionEnd - TextViewControl.SelectionStart);

                if (selection_len <= 0)
                {
                    return;
                }

                var char_buffer  = IntPtr.Zero;
                var chars_filled = 0;
                var eof          = false;

                try
                {
                    text_provider.GetCharParagraph
                        (TextViewControl.SelectionStart,
                        selection_len,
                        false,
                        out char_buffer,
                        out chars_filled,
                        out eof);

                    var sel_string = string.Empty;
                    sel_string = Marshal.PtrToStringUni(char_buffer, chars_filled);
                    if (unicode)
                    {
                        Clipboard.SetText(sel_string, TextDataFormat.UnicodeText);
                    }
                    else
                    {
                        Clipboard.SetText(sel_string, TextDataFormat.Text);
                    }
                }
                finally
                {
                    if (char_buffer != IntPtr.Zero)
                    {
                        //Marshal.FreeHGlobal(char_buffer);
                        //буфер не надо освобождать
                    }
                }
            }
            catch (Exception ex)
            {
                Messages.ShowException(ex);
            }
        }
Example #19
0
        private void internal_delete_selected()
        {
            if (listViewStreams.SelectedItems.Count == 0)
            {
                return;
            }

            if (Messages.ShowQuestionYesNo
                    (Options.GetLiteral(Options.LANG_DELETE_PROMPT),
                    Options.GetLiteral(Options.LANG_DELETE)) != DialogResult.Yes)
            {
                return;
            }

            var stream_info = new NT_FILE_STREAM_INFORMATION();

            foreach (InternalListViewItem item in listViewStreams.SelectedItems)
            {
                try
                {
                    stream_info = item.InternalData;
                    if (stream_info.StreamName.StartsWith("::$"))
                    {
                        Messages.ShowMessage(Options.GetLiteral(Options.LANG_CANNOT_DELETE_DEFAULT_DATA_STREAM));
                    }
                    else
                    {
                        var del_name = string.Format("{0}{1}", FileName, stream_info.StreamName);
                        var res      = WinApiFS.DeleteFile(del_name);
                        if (res == 0)
                        {
                            throw new Win32Exception(Marshal.GetLastWin32Error());
                        }
                    }
                }
                catch (Exception ex)
                {
                    Messages.ShowException
                        (ex,
                        string.Format
                            (Options.GetLiteral(Options.LANG_CANNOT_DELETE_DEFAULT_DATA_STREAM),
                            stream_info.StreamName));
                }
            }

            //update list
            FillContents(FileName);
        }
Example #20
0
        private void show_directory(mFilePanel target_panel, string dir_path)
        {
            try
            {
                DirectoryList old_dl = null;

                if ((target_panel.Source != null) && (target_panel.Source is DirectoryList))
                {
                    old_dl = (DirectoryList)target_panel.Source;
                }

                DirectoryList dl = null;

                if (old_dl == null)
                {
                    dl = new DirectoryList
                             (0,
                             false,
                             dir_path);
                }
                else
                {
                    dl = new DirectoryList
                             (old_dl.SortCriteria,
                             old_dl.SortReverse,
                             dir_path);
                }

                dl.MainWindow       = this;
                target_panel.Source = dl;
                try
                {
                    dl.Refill();
                }
                catch (Exception ex_inner)
                {
                    if (old_dl != null)
                    {
                        target_panel.Source = old_dl;
                    }
                    throw ex_inner;
                }
            }
            catch (Exception ex)
            {
                Messages.ShowException(ex);
            }
        }
Example #21
0
        void engine_SearchResult(object sender, SearchResultEventArgs e)
        {
            try
            {
                switch (e.Reason)
                {
                case SearchResultReason.ChangeDirectory:
                    if (InvokeRequired)
                    {
                        Invoke(update_current_dir_invoker, new object[] { e.DirectoryPath });
                    }
                    else
                    {
                        update_current_dir(e.DirectoryPath);
                    }
                    break;

                case SearchResultReason.FindFile:
                    if (InvokeRequired)
                    {
                        Invoke(add_result_invoker, new object[] { e.DirectoryPath, e.Find });
                    }
                    else
                    {
                        add_result(e.DirectoryPath, e.Find);
                    }
                    break;

                case SearchResultReason.SearchFinish:
                    if (InvokeRequired)
                    {
                        Invoke(update_current_dir_invoker, new object[] { Options.GetLiteral(Options.LANG_DONE) });
                    }
                    else
                    {
                        update_current_dir(Options.GetLiteral(Options.LANG_DONE));
                    }
                    break;
                }
            }
            catch (Exception ex)
            {
                Messages.ShowException(ex);
            }
        }
Example #22
0
        static void Main()
        {
            try
            {
                Application.EnableVisualStyles();
                Application.SetCompatibleTextRenderingDefault(false);

                System.Threading.Thread.CurrentThread.CurrentCulture   = Options.CultureInfo;
                System.Threading.Thread.CurrentThread.CurrentUICulture = Options.CultureInfo;

                main_window = new mainForm();
                Application.Run(main_window);
                //Application.Run(new mainForm());
            }
            catch (Exception ex)
            {
                Messages.ShowException(ex, "Critical exception. Cannot continue.");
            }
        }
Example #23
0
        private void copy_selected_to_file()
        {
            if (listViewResult.SelectedItems.Count == 0)
            {
                return;
            }

            FileStreamInfo sel_info = ((InternalListViewItem)listViewResult.SelectedItems[0]).InternalData;

            string source = internal_file_name + sel_info.Name;

            saveFileDialog1.AddExtension       = false;
            saveFileDialog1.AutoUpgradeEnabled = true;
            saveFileDialog1.CheckFileExists    = false;
            saveFileDialog1.CheckFileExists    = false;
            saveFileDialog1.OverwritePrompt    = true;
            saveFileDialog1.ValidateNames      = true;

            if (saveFileDialog1.ShowDialog() == DialogResult.OK)
            {
                string destinsation = saveFileDialog1.FileName;

                this.UseWaitCursor = true;

                try
                {
                    WinAPiFSwrapper.CopyFile
                        (source,
                        destinsation,
                        true,
                        null,
                        IntPtr.Zero,
                        131072);
                }
                catch (Exception ex)
                {
                    UseWaitCursor = false;
                    Messages.ShowException(ex);
                }

                UseWaitCursor = false;
            }
        }
Example #24
0
        protected override void internal_command_proc()
        {
            try
            {
                var e_current = new QueryPanelInfoEventArgs();
                OnQueryCurrentPanel(e_current);

                var pl = (ProcessList)e_current.ItemCollection;
                var p = pl[e_current.FocusedIndex];

                var dialog = new ProcessInfoDialog();
                //p.Refresh();
                dialog.Fill(p);
                dialog.ShowDialog();
            }
            catch (Exception ex)
            {
                Messages.ShowException(ex);
            }
        }
Example #25
0
        private void show_ftp_server(mFilePanel target_panel)
        {
            var opts   = Options.FtpOptions;
            var dialog = new FtpConnectionDialog();

            dialog.FtpConnectionOptions = opts;
            dialog.Text = Options.GetLiteral(Options.LANG_CONNECT_TO_FTP_SERVER);

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

            opts = dialog.FtpConnectionOptions;
            Options.FtpOptions = opts;

            if (!opts.Anonymous)
            {
                var user = opts.UserName;
                var pass = opts.Password;
                Messages.AskCredentials
                    (Options.GetLiteral(Options.LANG_LOGIN_TO_FTP_SERVER), opts.ServerName, ref user, ref pass);
                opts.UserName = user;
                opts.Password = pass;
            }

            var conn = new FtpConnection(opts);
            var fl   = new FtpDirectoryList(0, false, conn);

            try
            {
                fl.MainWindow = this;
                fl.Refill();
                target_panel.Source = fl;
                target_panel.Refresh();
            }
            catch (Exception ex)
            {
                Messages.ShowException(ex);
            }
        }
Example #26
0
        protected override void internal_refill()
        {
            //get list
            List <FileStreamInfo> stream_list = new List <FileStreamInfo>();

            try
            {
                stream_list = WinAPiFSwrapper.GetFileStreamInfo_fromBackup(file_name_full, read_sec_streams);
            }
            catch (Exception ex)
            {
                Messages.ShowException(ex);
            }
            internal_list.Clear();
            total_size = 0UL;
            internal_list.Add(internal_parent_info, null);
            foreach (FileStreamInfo info in stream_list)
            {
                internal_list.Add(info, null);
                total_size += info.Size;
            }
        }
Example #27
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;
        }
Example #28
0
        protected override void internal_command_proc()
        {
            try
            {
                var e = new QueryPanelInfoEventArgs();
                OnQueryCurrentPanel(e);

                if (!(e.ItemCollection is DirectoryList))
                {
                    return;
                }

                var dl        = (DirectoryList)e.ItemCollection;
                var file_name = dl[e.FocusedIndex].FullName;

                var dialog = new FileViewEditDialog();
                dialog.OpenView(file_name);
                dialog.Show();
            }
            catch (Exception ex)
            {
                Messages.ShowException(ex);
            }
        }
Example #29
0
        private void fill_listview(string file_name)
        {
            List <FileStreamInfo> stream_list = new List <FileStreamInfo>();

            try
            {
                stream_list = WinAPiFSwrapper.GetFileStreamInfo_fromBackup(file_name, false);
            }
            catch (Exception ex)
            {
                Messages.ShowException(ex);
            }

            foreach (FileStreamInfo data in stream_list)
            {
                InternalListViewItem new_item = new InternalListViewItem(data);
                listViewResult.Items.Add(new_item);
            }

            if (listViewResult.Items.Count > 0)
            {
                listViewResult.Items[0].Selected = true;
            }
        }
Example #30
0
        protected override void internal_command_proc()
        {
            QueryPanelInfoEventArgs e = new QueryPanelInfoEventArgs();

            OnQueryCurrentPanel(e);

            if (e.FocusedIndex == -1)
            {
                return;
            }

            bool group_mode = false;

            int[] sel_indices = e.SelectedIndices;
            //we not need cache selection
            //becouse e.ItemsCollection must not change (DirectoryList not sort on attributes)
            group_mode = (sel_indices.Length > 1);
            DirectoryList   dl     = (DirectoryList)e.ItemCollection;
            WIN32_FIND_DATA f_data = new WIN32_FIND_DATA();

            string target_file = string.Empty;

            if (!group_mode)
            {
                if (sel_indices.Length == 0)
                {
                    target_file = Path.Combine(dl.DirectoryPath, dl.GetItemDisplayNameLong(e.FocusedIndex));
                }
                else
                {
                    target_file = Path.Combine(dl.DirectoryPath, dl.GetItemDisplayNameLong(sel_indices[0]));
                }
                if (target_file.EndsWith(".."))
                {
                    target_file = dl.DirectoryPath;
                }
                if (!WinAPiFSwrapper.GetFileInfo(target_file, ref f_data))
                {
                    return;
                }
            }



            FileAttributesEditDialog dialog = new FileAttributesEditDialog();

            if (!group_mode)
            {
                dialog.buttonClear.Enabled = false;
                set_attributes_to_dialog(dialog, f_data.dwFileAttributes);
                dialog.Text = String.Format
                                  (Options.GetLiteral(Options.LANG_FILE_ATTRIBUTES) + " [{0}]", target_file);
            }
            else
            {
                dialog.buttonClear.Enabled = true;
                dialog.buttonOK.Text       = Options.GetLiteral(Options.LANG_ADD);
                dialog.Text = string.Format
                                  (Options.GetLiteral(Options.LANG_FILE_ATTRIBUTES) + " [{0} " + Options.GetLiteral(Options.LANG_ENTRIES) + "]", sel_indices.Length);
            }
            set_readonly_attributes(dialog);

            DialogResult d_res = dialog.ShowDialog();

            switch (d_res)
            {
            case DialogResult.OK:
                //group mode = add attributes
                //single mode = set attributes
                if (!group_mode)
                {
                    try
                    {
                        set_attributes_file(target_file, get_attributes_from_dialog(dialog));
                    }
                    catch (Exception ex)
                    {
                        Messages.ShowException(ex);
                    }
                }
                else
                {
                    //group mode
                    FileAttributes add_fa = get_attributes_from_dialog(dialog);
                    foreach (int one_index in sel_indices)
                    {
                        target_file = Path.Combine(dl.DirectoryPath, dl.GetItemDisplayNameLong(one_index));
                        try
                        {
                            add_attributes_file(target_file, add_fa);
                            OnItemProcessDone(new ItemEventArs(one_index));
                        }
                        catch (Exception ex)
                        {
                            Messages.ShowException(ex);
                        }
                    }
                }
                break;

            case DialogResult.Yes:
                //group mode only = clear attributes
                FileAttributes clear_fa = get_attributes_from_dialog(dialog);
                foreach (int one_index in sel_indices)
                {
                    target_file = Path.Combine(dl.DirectoryPath, dl.GetItemDisplayNameLong(one_index));
                    try
                    {
                        clear_attributes_file(target_file, clear_fa);
                        OnItemProcessDone(new ItemEventArs(one_index));
                    }
                    catch (Exception ex)
                    {
                        Messages.ShowException(ex);
                    }
                }
                break;
            }
        }