Ejemplo n.º 1
0
        public void NewTab(string Location, bool IsNavigate = false)
        {
            CloseableTabItem newt = new CloseableTabItem();
            CreateTabbarRKMenu(newt);

            ShellObject DefPath;
            if (Location.IndexOf("::") == 0 && Location.IndexOf(@"\") == -1)
                DefPath = ShellObject.FromParsingName("shell:" + Location);
            else
                DefPath = ShellObject.FromParsingName(Location);
            DefPath.Thumbnail.CurrentSize = new System.Windows.Size(16, 16);
            DefPath.Thumbnail.FormatOption = ShellThumbnailFormatOption.IconOnly;
            newt.Header = DefPath.GetDisplayName(DisplayNameType.Default);
            newt.TabIcon = DefPath.Thumbnail.BitmapSource;
            newt.Path = DefPath;
            newt.IsNavigate = IsNavigate;
            newt.Index = tabControl1.Items.Count;
            newt.AllowDrop = true;
            newt.CloseTab += new RoutedEventHandler(newt_CloseTab);
            newt.DragEnter += new DragEventHandler(newt_DragEnter);
            newt.DragOver += new DragEventHandler(newt_DragOver);
            newt.PreviewMouseMove += new MouseEventHandler(newt_PreviewMouseMove);
            newt.TabSelected += newt_TabSelected;
            newt.Drop += new DragEventHandler(newt_Drop);

            tabControl1.Items.Add(newt);
            LastTabIndex = tabControl1.SelectedIndex;
            if (IsNavigate)
            {
                //IsCancel = true;

                tabControl1.SelectedIndex = tabControl1.Items.Count - 1;
                tabControl1.SelectedItem = tabControl1.Items[tabControl1.Items.Count - 1];
                //IsCancel = false;
            }
            else
            {
                newt.log.CurrentLocation = DefPath;
            }

            CurrentTabIndex = tabControl1.Items.Count - 1;
            ConstructMoveToCopyToMenu();
        }
Ejemplo n.º 2
0
        void CreateTabbarRKMenu(CloseableTabItem tabitem)
        {
            tabitem.mnu = new ContextMenu();
            MenuItem miclosecurrentr = new MenuItem();
            miclosecurrentr.Header = "Close current tab";
            miclosecurrentr.Tag = tabitem;
            miclosecurrentr.Click += new RoutedEventHandler(miclosecurrentr_Click);
            tabitem.mnu.Items.Add(miclosecurrentr);

            MenuItem miclosealltab = new MenuItem();
            miclosealltab.Header = "Close all tabs";
            miclosealltab.Click += new RoutedEventHandler(miclosealltab_Click);
            tabitem.mnu.Items.Add(miclosealltab);

            MenuItem miclosealltabbd = new MenuItem();
            miclosealltabbd.Header = "Close all other tabs";
            miclosealltabbd.Tag = tabitem;
            miclosealltabbd.Click += new RoutedEventHandler(miclosealltabbd_Click);
            tabitem.mnu.Items.Add(miclosealltabbd);

            tabitem.mnu.Items.Add(new Separator());


            //tabitem.mnu.Items.Add(new Separator());

            MenuItem miopeninnew = new MenuItem();
            miopeninnew.Header = "Open in new window";
            miopeninnew.Tag = tabitem;
            miopeninnew.Click += new RoutedEventHandler(miopeninnew_Click);
            //tabitem.mnu.Items.Add(miopeninnew);

        }
Ejemplo n.º 3
0
        void CloseAllTabsButThis(CloseableTabItem tabitem)
        {
            List<CloseableTabItem> tabs = new List<CloseableTabItem>();
            foreach (object item in tabControl1.Items)
            {
                CloseableTabItem it = item as CloseableTabItem;
                tabs.Add(it);
            }


            foreach (CloseableTabItem item in tabs)
            {

                if (true)
                {
                    if (item != tabitem)
                    {
                        CloseTab(item);
                    }

                }

            }

            tabs = null;
            ConstructMoveToCopyToMenu();

        }
Ejemplo n.º 4
0
        void CloseTab(CloseableTabItem thetab, bool allowreopening = true)
        {
            if (thetab.Index == 0 && tabControl1.Items.Count == 1)
            {
                Close();
                return;
            }


            if (thetab.Index == 0 && tabControl1.Items.Count > 1)
            {
                tabControl1.SelectedIndex = thetab.Index + 1;
                tabControl1.Items.Remove(thetab);
            }
            else if (thetab.Index == tabControl1.Items.Count - 1)
            {
                tabControl1.SelectedIndex = thetab.Index - 1;
                tabControl1.Items.Remove(thetab);
            }
            else
            {

                for (int i = thetab.Index + 1; i < tabControl1.Items.Count; i++)
                {
                    CloseableTabItem tab = tabControl1.Items[i] as CloseableTabItem;
                    tab.Index = tab.Index - 1;
                }
                tabControl1.Items.Remove(thetab);
            }
            
            ConstructMoveToCopyToMenu();

            if (allowreopening == true)
            {
                reopenabletabs.Add(thetab.log);
                btnUndoClose.IsEnabled = true;
            }

            CloseableTabItem itb = tabControl1.SelectedItem as CloseableTabItem;

            isGoingBackOrForward = itb.log.HistoryItemsList.Count != 0;
            if (itb != null)
            {
                try
                {
                    BeforeLastTabIndex = LastTabIndex;

                    //tabControl1.SelectedIndex = itb.Index;
                    //LastTabIndex = itb.Index;
                    //CurrentTabIndex = LastTabIndex;
                    if (itb.Path != Explorer.NavigationLog.CurrentLocation)
                    {


                        if (!Keyboard.IsKeyDown(Key.Tab))
                        {
                            Explorer.Navigate(itb.Path);
                        }
                        else
                        {
                            t.Interval = 500;
                            t.Tag = itb.Path;
                            t.Tick += new EventHandler(t_Tick);
                            t.Start();
                        }

                    }
                }
                catch (StackOverflowException)
                {

                }
                //'btnTabCloseC.IsEnabled = tabControl1.Items.Count > 1;
                //'there's a bug that has this enabled when there's only one tab open, but why disable it
                //'if it never crashes the program? Closing the last tab simply closes the program, so I
                //'thought, what the heck... let's just keep it enabled. :) -JaykeBird
            }


            Explorer.ExplorerSetFocus();
            Explorer.Focus();
            
        }
Ejemplo n.º 5
0
        /// <summary>
        /// Re-opens a previously closed tab using that tab's navigation log data.
        /// </summary>
        /// <param name="log">The navigation log data from the previously closed tab.</param>
        public void ReOpenTab(NavigationLog log)
        {
            CloseableTabItem newt = new CloseableTabItem();
            CreateTabbarRKMenu(newt);

            ShellObject DefPath = log.CurrentLocation;
            DefPath.Thumbnail.CurrentSize = new System.Windows.Size(16, 16);
            DefPath.Thumbnail.FormatOption = ShellThumbnailFormatOption.IconOnly;
            newt.Header = DefPath.GetDisplayName(DisplayNameType.Default);
            newt.TabIcon = DefPath.Thumbnail.BitmapSource;
            newt.Path = DefPath;
            newt.IsNavigate = false;
            newt.Index = tabControl1.Items.Count;
            newt.AllowDrop = true;
            newt.CloseTab += new RoutedEventHandler(newt_CloseTab);
            newt.DragEnter += new DragEventHandler(newt_DragEnter);
            newt.DragOver += new DragEventHandler(newt_DragOver);
            newt.PreviewMouseMove += new MouseEventHandler(newt_PreviewMouseMove);
            newt.Drop += new DragEventHandler(newt_Drop);
            newt.TabSelected += newt_TabSelected;
            tabControl1.Items.Add(newt);
            LastTabIndex = tabControl1.SelectedIndex;
            newt.log.ImportData(log);

            CurrentTabIndex = tabControl1.Items.Count - 1;
            ConstructMoveToCopyToMenu();
        }
Ejemplo n.º 6
0
 public void CloneTab(CloseableTabItem CurTab)
 {
     CloseableTabItem newt = new CloseableTabItem();
     CreateTabbarRKMenu(newt);
     newt.Header = CurTab.Header;
     newt.TabIcon = CurTab.TabIcon;
     newt.Path = CurTab.Path;
     newt.Index = tabControl1.Items.Count;
     newt.CloseTab += new RoutedEventHandler(newt_CloseTab);
     newt.DragEnter += new DragEventHandler(newt_DragEnter);
     newt.DragLeave += new DragEventHandler(newt_DragLeave);
     newt.DragOver += new DragEventHandler(newt_DragOver);
     newt.PreviewMouseMove += new MouseEventHandler(newt_PreviewMouseMove);
     newt.Drop += new DragEventHandler(newt_Drop);
     newt.TabSelected += newt_TabSelected;
     newt.AllowDrop = true;
     newt.log.CurrentLocation = CurTab.Path;
     tabControl1.Items.Add(newt);
     tabControl1.SelectedIndex = tabControl1.Items.Count - 1;
     tabControl1.SelectedItem = tabControl1.Items[tabControl1.Items.Count - 1];
     LastTabIndex = CurrentTabIndex;
     CurrentTabIndex = tabControl1.Items.Count - 1;
     ConstructMoveToCopyToMenu();
 }
Ejemplo n.º 7
0
        private void Window_Loaded(object sender, RoutedEventArgs e)
        {
            bool exitApp = false;
            try
            {
                if (WindowsAPI.getOSInfo() == WindowsAPI.OsVersionInfo.Windows8)
                {
                    TheStatusBar.Visibility = System.Windows.Visibility.Collapsed;
                    rStatusbar.Height = new GridLength(0);
                }



                Handle = new WindowInteropHelper(Application.Current.MainWindow).Handle;
                //Itmpop = new ItemPopup();
                //Itmpop.Visibility = System.Windows.Visibility.Hidden;
                //Itmpop.Owner = this;
                //Itmpop.Show();

                //'sets up FileSystemWatcher for Favorites folder
                String FavPath = "";
                try
                {
                    FavPath = KnownFolders.Links.ParsingName;
                    FileSystemWatcher fsw = new FileSystemWatcher(FavPath);
                    fsw.Created += new FileSystemEventHandler(fsw_Created);
                    fsw.Deleted += new FileSystemEventHandler(fsw_Deleted);
                    fsw.Renamed += new RenamedEventHandler(fsw_Renamed);
                    fsw.EnableRaisingEvents = true;
                }
                catch
                {

                    FavPath = "";
                }

                //' set up breadcrumb bar
                breadcrumbBarControl1.SetDragHandlers(new DragEventHandler(bbi_DragEnter), new DragEventHandler(bbi_DragLeave), new DragEventHandler(bbi_DragOver), new DragEventHandler(bbi_Drop));

                Dispatcher.BeginInvoke(System.Windows.Threading.DispatcherPriority.Normal,
                                 (ThreadStart)(() =>
                                 {
                                     //PicturePreview = new PreviewMedia();

                                     //'set up Favorites menu (note that BetterExplorer does not support links to a Control Panel. lol -JaykeBird)
                                     //'I will probably use a modification to this code in the new breadcrumbbar
                                     if (FavPath != "")
                                     {
                                         DirectoryInfo FavInfo = new DirectoryInfo(FavPath);
                                         FileInfo[] FavFiles = FavInfo.GetFiles();
                                         foreach (FileInfo item in FavFiles)
                                         {
                                             if (Path.GetExtension(item.FullName).ToLowerInvariant() == ".lnk")
                                             {
                                                 try
                                                 {
                                                     ShellObject so = ShellObject.FromParsingName(item.FullName);
                                                     MenuItem mi = new MenuItem();
                                                     mi.Header = so.GetDisplayName(DisplayNameType.Default);
                                                     ShellLink lnk = new ShellLink(so.ParsingName);
                                                     string Target = lnk.Target;
                                                     if (Target.Contains("::"))
                                                     {
                                                         Target = "shell:" + Target;
                                                     }
                                                     if (item.Name.ToLowerInvariant() == "recentplaces.lnk")
                                                     {
                                                         Target = "shell:::{22877a6d-37a1-461a-91b0-dbda5aaebc99}";
                                                     }
                                                     mi.Tag = Target;
                                                     lnk.Dispose();
                                                     so.Thumbnail.FormatOption = ShellThumbnailFormatOption.IconOnly;
                                                     so.Thumbnail.CurrentSize = new System.Windows.Size(16, 16);
                                                     ImageSource icon = so.Thumbnail.BitmapSource;
                                                     mi.Focusable = false;
                                                     mi.Icon = icon;
                                                     mi.Click += new RoutedEventHandler(mif_Click);
                                                     so.Dispose();
                                                     btnFavorites.Items.Add(mi);
                                                 }
                                                 catch
                                                 {


                                                 }
                                             }
                                         }
                                     }
                                     else
                                     {
                                         btnFavorites.Visibility = System.Windows.Visibility.Collapsed;
                                     }

                                     //'set up Explorer control
                                     Explorer.SelectionChanged += new EventHandler(ExplorerBrowserControl_SelectionChanged);
                                     Explorer.NavigationComplete += new EventHandler<NavigationCompleteEventArgs>(ExplorerBrowserControl_NavigationComplete);
                                     Explorer.ViewEnumerationComplete += new EventHandler(ExplorerBrowserControl_ViewEnumerationComplete);
                                     Explorer.NavigationPending += new EventHandler<NavigationPendingEventArgs>(Explorer_NavigationPending);
                                     Explorer.GotFocus += new EventHandler(Explorer_GotFocus);
                                     Explorer.ExplorerGotFocus += new EventHandler(Explorer_ExplorerGotFocus);
                                     //Explorer.ExplorerGotFocus += new EventHandler(Explorer_ExplorerGotFocus);
                                     Explorer.RenameFinished += new EventHandler(Explorer_RenameFinished);
                                     Explorer.KeyUP += new EventHandler<ExplorerKeyUPEventArgs>(Explorer_KeyUP);
                                     Explorer.KeyUp += new System.Windows.Forms.KeyEventHandler(explorerBrowser1_KeyUp);
                                     Explorer.LostFocus += new EventHandler(Explorer_LostFocus);

                                     Explorer.NavigationOptions.PaneVisibility.Commands = PaneVisibilityState.Hide;
                                     Explorer.NavigationOptions.PaneVisibility.CommandsOrganize = PaneVisibilityState.Hide;
                                     Explorer.NavigationOptions.PaneVisibility.CommandsView = PaneVisibilityState.Hide;
                                     Explorer.ItemsChanged += new EventHandler(Explorer_ItemsChanged);
                                     Explorer.ContentOptions.FullRowSelect = true;
                                     //Explorer.ContentOptions.CheckSelect = false;
                                     Explorer.ClientSizeChanged += new EventHandler(ExplorerBrowserControl_ClientSizeChanged);
                                     Explorer.Paint += new System.Windows.Forms.PaintEventHandler(ExplorerBrowserControl_Paint);
                                     Explorer.ViewChanged += new EventHandler<ViewChangedEventArgs>(Explorer_ViewChanged);
                                     //Explorer.ItemHot += new EventHandler<ExplorerAUItemEventArgs>(Explorer_ItemHot);
                                     Explorer.ExplorerBrowserMouseLeave += new EventHandler(Explorer_ExplorerBrowserMouseLeave);
                                     Explorer.MouseMove += new System.Windows.Forms.MouseEventHandler(Explorer_MouseMove);
                                     IsCalledFromLoading = true;
                                     WindowsAPI.SHELLSTATE state = new WindowsAPI.SHELLSTATE();
                                     WindowsAPI.SHGetSetSettings(ref state, WindowsAPI.SSF.SSF_SHOWALLOBJECTS | WindowsAPI.SSF.SSF_SHOWEXTENSIONS, false);
                                     chkHiddenFiles.IsChecked = (state.fShowAllObjects == 1);
                                     chkExtensions.IsChecked = (state.fShowExtensions == 1);
                                     IsCalledFromLoading = false;
                                     isOnLoad = true;
                                     //'load from Registry
                                     RegistryKey rk = Registry.CurrentUser;
                                     RegistryKey rks = rk.CreateSubKey(@"Software\BExplorer");

                                     switch (Convert.ToString(rks.GetValue(@"CurrentTheme", "Blue")))
                                     {
                                         case "Blue":
                                             btnBlue.IsChecked = true;
                                             break;
                                         case "Silver":
                                             btnSilver.IsChecked = true;
                                             break;
                                         case "Black":
                                             btnBlack.IsChecked = true;
                                             break;
                                         case "Green":
                                             btnGreen.IsChecked = true;
                                             break;
                                         default:
                                             btnBlue.IsChecked = true;
                                             break;
                                     }
                                     int HFlyoutEnabled = (int)rks.GetValue(@"HFlyoutEnabled", 0);

                                     IsHFlyoutEnabled = (HFlyoutEnabled == 1);
                                     chkIsFlyout.IsChecked = IsHFlyoutEnabled;

                                     int InfoPaneEnabled = (int)rks.GetValue(@"InfoPaneEnabled", 0);

                                     IsInfoPaneEnabled = (InfoPaneEnabled == 1);
                                     btnInfoPane.IsChecked = IsInfoPaneEnabled;

                                     int PreviewPaneEnabled = (int)rks.GetValue(@"PreviewPaneEnabled", 0);

                                     IsPreviewPaneEnabled = (PreviewPaneEnabled == 1);
                                     btnPreviewPane.IsChecked = IsPreviewPaneEnabled;

                                     int NavigationPaneEnabled = (int)rks.GetValue(@"NavigationPaneEnabled", 1);

                                     IsNavigationPaneEnabled = (NavigationPaneEnabled == 1);
                                     btnNavigationPane.IsChecked = IsNavigationPaneEnabled;

                                     int CheckBoxesEnabled = (int)rks.GetValue(@"CheckModeEnabled", 0);

                                     isCheckModeEnabled = (CheckBoxesEnabled == 1);
                                     chkShowCheckBoxes.IsChecked = isCheckModeEnabled;

                                     int ExFileOpEnabled = (int)rks.GetValue(@"FileOpExEnabled", 0);

                                     IsExtendedFileOpEnabled = (ExFileOpEnabled == 1);
                                     Explorer.IsExFileOpEnabled = IsExtendedFileOpEnabled;
                                     chkIsTerraCopyEnabled.IsChecked = IsExtendedFileOpEnabled;

                                     int CompartibleRename = (int)rks.GetValue(@"CompartibleRename", 1);

                                     IsCompartibleRename = (CompartibleRename == 1);

                                     //chkIsCompartibleRename.IsChecked = IsCompartibleRename;

                                     int RestoreTabs = (int)rks.GetValue(@"IsRestoreTabs", 1);

                                     IsrestoreTabs = (RestoreTabs == 1);

                                     chkIsRestoreTabs.IsChecked = IsrestoreTabs;

                                     int LogActions = (int)rks.GetValue(@"EnableActionLog", 0);

                                     canlogactions = (LogActions == 1);
                                     chkLogHistory.IsChecked = canlogactions;

                                     // load settings for auto-switch to contextual tab
                                     asFolder = ((int)rks.GetValue(@"AutoSwitchFolderTools", 0) == 1);
                                     asArchive = ((int)rks.GetValue(@"AutoSwitchArchiveTools", 1) == 1);
                                     asImage = ((int)rks.GetValue(@"AutoSwitchImageTools", 1) == 1);
                                     asApplication = ((int)rks.GetValue(@"AutoSwitchApplicationTools", 0) == 1);
                                     asLibrary = ((int)rks.GetValue(@"AutoSwitchLibraryTools", 1) == 1);
                                     asDrive = ((int)rks.GetValue(@"AutoSwitchDriveTools", 0) == 1);

                                     chkFolder.IsChecked = asFolder;
                                     chkArchive.IsChecked = asArchive;
                                     chkImage.IsChecked = asImage;
                                     chkApp.IsChecked = asApplication;
                                     chkLibrary.IsChecked = asLibrary;
                                     chkDrive.IsChecked = asDrive;

                                     // load OverwriteOnImages setting (default is false)
                                     int oor = (int)rks.GetValue(@"OverwriteImageWhileEditing", 0);
                                     OverwriteOnRotate = (oor == 1);
                                     chkOverwriteImages.IsChecked = (oor == 1);

                                     // set up history on breadcrumb bar (currently missing try-catch statement in order to catch error)
                                     try
                                     {
                                         breadcrumbBarControl1.ClearHistory();
                                         breadcrumbBarControl1.HistoryItems = ReadHistoryFromFile(Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData) + "\\history.txt");
                                     }
                                     catch (FileNotFoundException)
                                     {
                                       logger.Warn(String.Format("History file not found at location:{0}\\history.txt", Environment.SpecialFolder.LocalApplicationData));
                                     }

                                     AddToLog("Session Began");

                                     StartUpLocation =
                                          rks.GetValue(@"StartUpLoc", KnownFolders.Libraries.ParsingName).ToString();

                                     if (StartUpLocation == "")
                                     {
                                         rks.SetValue(@"StartUpLoc", KnownFolders.Libraries.ParsingName);
                                         StartUpLocation = KnownFolders.Libraries.ParsingName;
                                     }
                                     char[] delimiters = new char[] { ';' };
                                     string LastOpenedTabs = rks.GetValue(@"OpenedTabs", "").ToString();
                                     string[] Tabs = LastOpenedTabs.Split(delimiters, StringSplitOptions.RemoveEmptyEntries);

                                     rks.Close();
                                     rk.Close();

                                     try
                                     {
                                         RegistryKey rkbe = Registry.ClassesRoot;
                                         RegistryKey rksbe = rkbe.OpenSubKey(@"Folder\shell", RegistryKeyPermissionCheck.ReadSubTree);
                                         bool IsThereDefault = rksbe.GetValue("", "-1").ToString() != "";
                                         chkIsDefault.IsChecked = IsThereDefault;
                                         chkIsDefault.IsEnabled = true;
                                         rksbe.Close();
                                         rkbe.Close();
                                     }
                                     catch (Exception)
                                     {
                                         chkIsDefault.IsChecked = false;
                                         chkIsDefault.IsEnabled = false;
                                     }

                                     RegistryKey rkfe = Registry.CurrentUser;
                                     RegistryKey rksfe = rk.OpenSubKey(@"Software\Microsoft\Windows\CurrentVersion\Explorer\Advanced", RegistryKeyPermissionCheck.ReadSubTree);
                                     chkTreeExpand.IsChecked = (int)rksfe.GetValue("NavPaneExpandToCurrentFolder", 0) == 1;
                                     rksfe.Close();
                                     rkfe.Close();

                                     isOnLoad = false;


                                     //'Rest of the setup of Explorer control. We have to set up that here after 
                                     //the initialization of registry settings
                                     Explorer.NavigationOptions.PaneVisibility.Preview =
                                         IsPreviewPaneEnabled ? PaneVisibilityState.Show : PaneVisibilityState.Hide;
                                     Explorer.NavigationOptions.PaneVisibility.Details =
                                         IsInfoPaneEnabled ? PaneVisibilityState.Show : PaneVisibilityState.Hide;

                                     Explorer.NavigationOptions.PaneVisibility.Navigation =
                                         IsNavigationPaneEnabled ? PaneVisibilityState.Show : PaneVisibilityState.Hide;



                                     Explorer.ContentOptions.CheckSelect = isCheckModeEnabled;

                                     if (StartUpLocation.IndexOf("::") == 0 && StartUpLocation.IndexOf(@"\") == -1)
                                     {
                                         btnSetCurrentasStartup.Header =
                                            ShellObject.FromParsingName("Shell:" + StartUpLocation).GetDisplayName(DisplayNameType.Default);
                                         btnSetCurrentasStartup.Icon = ShellObject.FromParsingName("Shell:" + StartUpLocation).Thumbnail.BitmapSource;
                                     }
                                     else
                                     {
                                         try
                                         {
                                             btnSetCurrentasStartup.Header =
                                                  ShellObject.FromParsingName(StartUpLocation).GetDisplayName(DisplayNameType.Default);

                                             btnSetCurrentasStartup.Icon = ShellObject.FromParsingName(StartUpLocation).Thumbnail.BitmapSource;
                                         }
                                         catch 
                                         {
                                             
                                            
                                         }
                                     }

                                     //'set StartUp location
                                     if (Application.Current.Properties["cmd"] != null)
                                     {

                                         String cmd = Application.Current.Properties["cmd"].ToString();

                                         if (cmd.IndexOf("::") == 0)
                                         {

                                             Explorer.Navigate(ShellObject.FromParsingName("shell:" + cmd));
                                         }
                                         else
                                             Explorer.Navigate(ShellObject.FromParsingName(cmd.Replace("\"", "")));

                                         
                                         CloseableTabItem cti = new CloseableTabItem();
                                         CreateTabbarRKMenu(cti);
                                         Explorer.NavigationLog.CurrentLocation.Thumbnail.CurrentSize = new System.Windows.Size(16, 16);
                                         cti.TabIcon = Explorer.NavigationLog.CurrentLocation.Thumbnail.BitmapSource;
                                         cti.Header = Explorer.NavigationLog.CurrentLocation.GetDisplayName(DisplayNameType.Default);
                                         cti.Path = Explorer.NavigationLog.CurrentLocation;
                                         cti.Index = 0;
                                         cti.log.CurrentLocation = Explorer.NavigationLog.CurrentLocation;
                                         cti.CloseTab += new RoutedEventHandler(cti_CloseTab);
                                         tabControl1.Items.Add(cti);
                                         //tabControl1.SelectedIndex = 0;
                                         //CurrentTabIndex = tabControl1.SelectedIndex;
                                     }
                                     else
                                     {
                                         if (Tabs.Length == 0 || !IsrestoreTabs)
                                         {
                                             if (StartUpLocation.IndexOf("::") == 0 && StartUpLocation.IndexOf(@"\") == -1)
                                                 Explorer.Navigate(ShellObject.FromParsingName("shell:" + StartUpLocation));
                                             else
                                                 try
                                                 {
                                                     Explorer.Navigate(ShellObject.FromParsingName(StartUpLocation));
                                                 }
                                                 catch
                                                 {
                                                     Explorer.Navigate((ShellObject)KnownFolders.Libraries);
                                                 }
                                         }
                                         if (IsrestoreTabs)
                                         {
                                             isOnLoad = true;
                                             int i = 0;
                                             foreach (string str in Tabs)
                                             {
                                                 try
                                                 {
                                                     i++;
                                                     if (i == Tabs.Length)
                                                     {
                                                         NewTab(str, true);
                                                     }
                                                     else
                                                     {
                                                         NewTab(str, false);
                                                     }
                                                     if (i == Tabs.Count())
                                                     {
                                                         if (str.IndexOf("::") == 0)
                                                         {

                                                             Explorer.Navigate(ShellObject.FromParsingName("shell:" + str));
                                                         }
                                                         else
                                                             Explorer.Navigate(ShellObject.FromParsingName(str.Replace("\"", "")));
                                                         (tabControl1.SelectedItem as CloseableTabItem).Path = Explorer.NavigationLog.CurrentLocation;
                                                     }
                                                 }
                                                 catch
                                                 {
                                                     //AddToLog(String.Format("Unable to load {0} into a tab!", str));
                                                     MessageBox.Show("BetterExplorer is unable to load one of the tabs from your last session. Your other tabs are perfectly okay though! \r\n\r\nThis location was unable to be loaded: " + str, "Unable to Create New Tab", MessageBoxButton.OK, MessageBoxImage.Error);
                                                     //NewTab();
                                                 }

                                             }
                                             if (tabControl1.Items.Count == 0) { 
                                                 NewTab();
                                                 if (StartUpLocation.IndexOf("::") == 0)
                                                 {

                                                     Explorer.Navigate(ShellObject.FromParsingName("shell:" + StartUpLocation));
                                                 }
                                                 else
                                                     Explorer.Navigate(ShellObject.FromParsingName(StartUpLocation.Replace("\"", "")));
                                                 (tabControl1.SelectedItem as CloseableTabItem).Path = Explorer.NavigationLog.CurrentLocation;
                                             };
                                             isOnLoad = false;

                                         }
                                     }

                                     //sets up Jump List
                                     AppJL.ShowRecentCategory = true;
                                     AppJL.ShowFrequentCategory = true;
                                     JumpList.SetJumpList(Application.Current, AppJL);
                                     JumpTask newTab = new JumpTask();
                                     newTab.ApplicationPath = System.Diagnostics.Process.GetCurrentProcess().MainModule.FileName;
                                     newTab.Arguments = "t";
                                     newTab.Title = "Open Tab";
                                     newTab.Description = "Opens new tab with default location";

                                     JumpTask newWindow = new JumpTask();
                                     newWindow.ApplicationPath = System.Diagnostics.Process.GetCurrentProcess().MainModule.FileName;
                                     newWindow.Arguments = "/nw";
                                     newWindow.Title = "New Window";
                                     newWindow.Description = "Creates a new window with default location";

                                     AppJL.JumpItems.Add(newTab);
                                     AppJL.JumpItems.Add(newWindow); 
                                     AppJL.Apply();


                                     //Setup Clipboard monitor
                                     cbm.ClipboardChanged += new EventHandler<ClipboardChangedEventArgs>(cbm_ClipboardChanged);

                                   #region unneeded code
                                   //if (Tabs.Length == 0 || !IsrestoreTabs)
                                   //{
                                   //    CloseableTabItem cti = new CloseableTabItem();
                                   //    CreateTabbarRKMenu(cti);
                                   //    Explorer.NavigationLog.CurrentLocation.Thumbnail.CurrentSize = new System.Windows.Size(16, 16);
                                   //    cti.TabIcon = Explorer.NavigationLog.CurrentLocation.Thumbnail.BitmapSource;
                                   //    cti.Header = Explorer.NavigationLog.CurrentLocation.GetDisplayName(DisplayNameType.Default);
                                   //    cti.Path = Explorer.NavigationLog.CurrentLocation;
                                   //    cti.Index = 0;
                                   //    cti.log.CurrentLocation = Explorer.NavigationLog.CurrentLocation;
                                   //    cti.CloseTab += new RoutedEventHandler(cti_CloseTab);
                                   //    tabControl1.Items.Add(cti);
                                   //    tabControl1.SelectedIndex = 0;
                                   //    CurrentTabIndex = tabControl1.SelectedIndex;
                                   //} 
                                   #endregion
                                     


                                 }
               ));

                if (exitApp)
                {

                    Application.Current.Shutdown();
                    return;
                }

                try
                {

                    Updater = UpdateManager.Instance;
                    Updater.UpdateFeedReader = new NAppUpdate.Framework.FeedReaders.NauXmlFeedReader();
                    Updater.UpdateExecutableName = "Web Update.exe";
                    Updater.UpdateSource = new NAppUpdate.Framework.Sources.SimpleWebSource("http://better-explorer.com/onlineupdate/update.xml");
                    //TODO: reeable updates when there is site ready
                    //CheckForUpdate(false);
                }
                catch (IOException)
                {
                    this.stiUpdate.Content = "Switch to another BetterExplorer window or restart to check for updates.";
                    this.btnUpdateCheck.IsEnabled = false;
                }

                verNumber.Content = "Version " + (System.Reflection.Assembly.GetExecutingAssembly().GetCustomAttributes(typeof(AssemblyInformationalVersionAttribute), false).FirstOrDefault() as AssemblyInformationalVersionAttribute).InformationalVersion;
                lblArchitecture.Content = Is64bitProcess(Process.GetCurrentProcess()) ? "64-bit version" : "32-bit version";
                if (!TheRibbon.IsMinimized)
                {
                    TheRibbon.SelectedTabItem = HomeTab;
                    this.TheRibbon.SelectedTabIndex = 0;
                }


                //MessageBox.Show(TheRibbon.SelectedTabIndex.ToString(), "SelectedTabIndex Should be 0", MessageBoxButton.OK, MessageBoxImage.Information);
            }
            catch (Exception exe)
            {
                MessageBox.Show("An error occurred while loading the window. Please report this issue at http://bexplorer.codeplex.com/. \r\n\r\n Here is some information about the error: \r\n\r\n" + exe.Message + "\r\n\r\n" + exe.ToString(), "Error While Loading", MessageBoxButton.OK, MessageBoxImage.Error);
            }

        }
Ejemplo n.º 8
0
        /// <summary>
        /// Single instance callback handler.
        /// </summary>
        /// <param name="sender">The sender.</param>
        /// <param name="args">The <see cref="SingleInstanceApplication.InstanceCallbackEventArgs"/> instance containing the event data.</param>
        private void SingleInstanceCallback(object sender, InstanceCallbackEventArgs args)
        {
            string StartUpLocation = KnownFolders.Libraries.ParsingName;
            RegistryKey rk = Registry.CurrentUser;
            RegistryKey rks = rk.OpenSubKey(@"Software\BExplorer", false);

            StartUpLocation =
                 rks.GetValue(@"StartUpLoc", KnownFolders.Libraries.ParsingName).ToString();

            rks.Close();
            rk.Close();

            if (args == null || Dispatcher == null) return;
            Action<bool> d = (bool x) =>
            {
                var win = MainWindow as MainWindow;
                if (win == null) return;

                win.ApendArgs(args.CommandLineArgs);
                //win.Activate(x);
                if (x)
                {
                    ShellObject sho = null;
                    if (args != null && args.CommandLineArgs != null)
                    {
                        if (args.CommandLineArgs.Length > 1 && args.CommandLineArgs[1] != null)
                        {
                            if (args.CommandLineArgs[1] != "t")
                            {
                                if (args.CommandLineArgs[1] == "nw")
                                {
                                    BetterExplorer.MainWindow g = new MainWindow();
                                    g.Show();
                                    return;
                                }
                                else
                                {
                                    String cmd = args.CommandLineArgs[1];
                                    if (cmd.IndexOf("::") == 0)
                                    {
                                       sho = ShellObject.FromParsingName("shell:" + cmd);
                                    }
                                    else
                                        sho = ShellObject.FromParsingName(args.CommandLineArgs[1].Replace("\"", ""));
                                }
                            }
                            else
                            {
                                    if (StartUpLocation.IndexOf("::") == 0 && StartUpLocation.IndexOf(@"\") == -1)
                                        sho = ShellObject.FromParsingName("shell:" + StartUpLocation);
                                    else
                                        try
                                        {
                                            sho = ShellObject.FromParsingName(StartUpLocation);
                                        }
                                        catch
                                        {
                                            sho = (ShellObject)KnownFolders.Libraries;
                                        }
                            }
                        }
                        else
                            if (StartUpLocation.IndexOf("::") == 0 && StartUpLocation.IndexOf(@"\") == -1)
                                sho = ShellObject.FromParsingName("shell:" + StartUpLocation);
                            else
                                try
                                {
                                    sho = ShellObject.FromParsingName(StartUpLocation);
                                }
                                catch
                                {
                                    sho = (ShellObject)KnownFolders.Libraries;
                                }

                        sho.Thumbnail.FormatOption = ShellThumbnailFormatOption.IconOnly;
                        sho.Thumbnail.CurrentSize = new Size(16, 16);
                        CloseableTabItem newt = new CloseableTabItem();
                        newt.Header = sho.GetDisplayName(DisplayNameType.Default);
                        newt.TabIcon = sho.Thumbnail.BitmapSource;
                        newt.Path = sho;
                        win.CloneTab(newt);
                        win.NavigateAfterTabChange();
                        
                        IntPtr MainWinHandle = WindowsHelper.WindowsAPI.FindWindow(null, Process.GetCurrentProcess().MainWindowTitle);
                        if (win.WindowState == WindowState.Minimized)
                        {
                            WindowsHelper.WindowsAPI.ShowWindow((int)MainWinHandle, 
                                (int)WindowsHelper.WindowsAPI.ShowCommands.SW_RESTORE);
                        }
                        WindowsHelper.WindowsAPI.BringWindowToTop(MainWinHandle);
                        WindowsHelper.WindowsAPI.SetForegroundWindow(MainWinHandle);
                        win.Activate();

                    }
                }
            };
            Dispatcher.BeginInvoke(d, true);
        }
Ejemplo n.º 9
0
        public void NewTab(bool IsNavigate = true)
        {
            CloseableTabItem newt = new CloseableTabItem();
            CreateTabbarRKMenu(newt);

            ShellObject DefPath;
            if (StartUpLocation.IndexOf("::") == 0 && StartUpLocation.IndexOf(@"\") == -1)
                DefPath = ShellObject.FromParsingName("shell:" + StartUpLocation);
            else
                try
                {
                    DefPath = ShellObject.FromParsingName(StartUpLocation);
                }
                catch
                {
                    DefPath = (ShellObject)KnownFolders.Libraries;
                }
            DefPath.Thumbnail.CurrentSize = new System.Windows.Size(16, 16);
            DefPath.Thumbnail.FormatOption = ShellThumbnailFormatOption.IconOnly;
            newt.Header = DefPath.GetDisplayName(DisplayNameType.Default);
            newt.TabIcon = DefPath.Thumbnail.BitmapSource;
            newt.Path = DefPath;
            newt.IsNavigate = IsNavigate;
            newt.Index = tabControl1.Items.Count;
            newt.AllowDrop = true;
            newt.log.CurrentLocation = DefPath;

            newt.CloseTab += new RoutedEventHandler(newt_CloseTab);
            newt.DragEnter += new DragEventHandler(newt_DragEnter);
            newt.DragOver += new DragEventHandler(newt_DragOver);
            newt.Drop += new DragEventHandler(newt_Drop);
            tabControl1.Items.Add(newt);
            LastTabIndex = tabControl1.SelectedIndex;
            tabControl1.SelectedIndex = tabControl1.Items.Count - 1;
            tabControl1.SelectedItem = tabControl1.Items[tabControl1.Items.Count - 1];

            CurrentTabIndex = tabControl1.Items.Count - 1;
            ConstructMoveToCopyToMenu();
        }
Ejemplo n.º 10
0
        void CloseTab(CloseableTabItem thetab)
        {
            if (thetab.Index == 0 && tabControl1.Items.Count == 1)
            {
                Close();
                return;
            }

            int CurSelIndex = thetab.Index;
            if (CurSelIndex == 0)
            {
                if (LastTabIndex != -1)
                {
                    try
                    {
                        tabControl1.SelectedItem = tabControl1.Items[LastTabIndex];
                        CurrentTabIndex = LastTabIndex;
                    }
                    catch
                    {

                        tabControl1.SelectedItem = tabControl1.Items[tabControl1.Items.Count - 1];
                        CurrentTabIndex = tabControl1.Items.Count - 1;
                    }
                }
                else
                {
                    tabControl1.SelectedItem = tabControl1.Items[1];
                    CurrentTabIndex = 0;
                }

            }
            else
            {
                if (CurSelIndex == tabControl1.Items.Count - 1)
                {
                    if (CurSelIndex == LastTabIndex)
                    {
                        if (BeforeLastTabIndex != -1 && tabControl1.Items.Count >= BeforeLastTabIndex + 1)
                        {
                            tabControl1.SelectedItem = tabControl1.Items[BeforeLastTabIndex];
                            CurrentTabIndex = BeforeLastTabIndex;
                        }
                        else
                        {
                            tabControl1.SelectedItem = tabControl1.Items[CurSelIndex - 1];
                            CurrentTabIndex = CurSelIndex - 1;
                            LastTabIndex = CurrentTabIndex;
                        }

                    }
                    else
                    {
                        if (LastTabIndex != -1)
                        {
                            try
                            {
                                tabControl1.SelectedItem = tabControl1.Items[LastTabIndex];
                                CurrentTabIndex = LastTabIndex;
                            }
                            catch
                            {
                                 
                               //Handle the exeption on using Close all tabs command since we dont need to keep any index just to close the app
                            }
                        }
                    }

                }
                else
                {
                    if (CurSelIndex == LastTabIndex)
                    {
                        if (BeforeLastTabIndex != -1 && tabControl1.Items.Count >= BeforeLastTabIndex + 1)
                        {
                            tabControl1.SelectedItem = tabControl1.Items[BeforeLastTabIndex];
                            CurrentTabIndex = BeforeLastTabIndex;
                        }
                        else
                        {
                            tabControl1.SelectedItem = tabControl1.Items[CurSelIndex + 1];
                            CurrentTabIndex = CurSelIndex + 1;
                            LastTabIndex = CurrentTabIndex;
                        }
                    }
                    else
                    {
                        if (LastTabIndex != -1)
                        {
                            try
                            {
                                tabControl1.SelectedItem = tabControl1.Items[LastTabIndex];
                                CurrentTabIndex = LastTabIndex;
                            }
                            catch
                            {
                                if (LastTabIndex != 0)
                                {
                                    tabControl1.SelectedItem = tabControl1.Items[tabControl1.Items.Count - 1];
                                    CurrentTabIndex = tabControl1.Items.Count - 1;
                                }
                                else
                                {
                                    tabControl1.SelectedItem = tabControl1.Items[0];
                                    CurrentTabIndex = 0;
                                }

                            }
                        }
                    }
                }
            }

            for (int i = CurSelIndex + 1; i < tabControl1.Items.Count; i++)
            {
                CloseableTabItem tab = tabControl1.Items[i] as CloseableTabItem;
                tab.Index = tab.Index - 1;
            }
            try
            {
                tabControl1.Items.RemoveAt(CurSelIndex);
            }
            catch
            {
                tabControl1.Items.RemoveAt(CurSelIndex - 1);
            }
            ConstructMoveToCopyToMenu();
        }