Exemple #1
0
        //----< load file text in the selection window >------
        private void showFile(string fileName)
        {
            string fpath = saveFilePath + "\\" + fileName;

            fpath = System.IO.Path.GetFullPath(fpath);
            string          contents = File.ReadAllText(fpath);
            SelectionWindow popup    = new SelectionWindow();

            popup.codeView.Text = contents;
            popup.Show();
        }
        //----< handle mouse double click on files or folders in the Navigation view >---------------
        private void Dirs_MouseDoubleClick(object sender, MouseButtonEventArgs e)
        {
            MainWindow win = (MainWindow)Window.GetWindow(this);

            var temp = System.IO.Path.Combine(win.path, Dirs.SelectedItem.ToString());

            //detect whether its a directory or file
            if (Directory.Exists(temp))
            {
                string selectedDir = Dirs.SelectedItem.ToString();
                if (selectedDir == "..")
                {
                    win.path = getAncestorPath(1, win.path);
                }
                else
                {
                    win.path = System.IO.Path.Combine(win.path, selectedDir);
                }
                LoadNavTab(win.path);
            }
            else if (File.Exists(temp))
            {
                string fileName = Dirs.SelectedValue as string;
                try
                {
                    string          fpath    = System.IO.Path.Combine(win.path, fileName);
                    string          contents = File.ReadAllText(fpath);
                    SelectionWindow popup    = new SelectionWindow();
                    popup.codeView.Text = contents;
                    popup.Show();
                }
                catch (Exception ex)
                {
                    string          msg   = ex.Message;
                    SelectionWindow popup = new SelectionWindow();
                    popup.codeView.Text = msg;
                    popup.Show();
                }
            }
        }