Example #1
0
        /// <summary>Open the FS item at <paramref name="url"/> (if it's file, load; if it's directory, go to)</summary>
        /// <param name="clearhistory">The number of history entrie after that all entries must be removed</param>
        private void NavigateTo(string url, int?ClearHistory = null)
        {
            if (!url.Contains("://"))
            {
                //the path is relative
                NavigateTo(FS.CurrentDirectory + FS.DirSeparator + url);
            }

            Xwt.Menu hm = HistoryButton.Menu;

            if (ClearHistory == null)
            {
                //register current directory in history
                MenuItem hmi = new MenuItem(url);
                hmi.Clicked += (o, ea) => { NavigateTo(url, (int)hmi.Tag); };
                hmi.Tag      = hm.Items.Count;
                hm.Items.Add(hmi);
            }
            if (ClearHistory != null)
            {
                //loading from history menu, thus don't making duplicates.
            }


            try
            {
                if (FS.DirectoryExists(url))
                {                //it's directory
                    if (Navigate != null)
                    {
                        Navigate(url);                                       //raise event
                    }
                    else
                    {
                        Console.WriteLine("WARNING: the event FLP.Navigate was not handled by the host");
                    }

                    LoadDir(url);
                    return;
                }
                else
                {                //it's file
                    if (OpenFile != null)
                    {
                        OpenFile(url);                                       //raise event
                    }
                    else
                    {
                        Console.WriteLine("WARNING: the event FLP.OpenFile was not handled by the host");
                    }
                }
            }
            catch (pluginner.PleaseSwitchPluginException)
            {
                throw;                 //delegate authority to the mainwindow (it is it's jurisdiction).
            }
            catch (Exception ex)
            {
                ListingView.Sensitive = true;
                ListingView.Cursor    = Xwt.CursorType.Arrow;

                Xwt.MessageDialog.ShowError(ex.Message);
                Console.WriteLine(ex.Message + "\n" + ex.StackTrace);
                WriteDefaultStatusLabel();
            }
        }