[Qttabbar-Commit] SF.net SVN: qttabbar:[314] branches/options/QTTabBar
Status: Beta
Brought to you by:
masamunexgp
From: <mas...@us...> - 2011-09-04 18:31:55
|
Revision: 314 http://qttabbar.svn.sourceforge.net/qttabbar/?rev=314&view=rev Author: masamunexgp Date: 2011-09-04 18:31:48 +0000 (Sun, 04 Sep 2011) Log Message: ----------- Preliminary work on Mouse tab. Modified Paths: -------------- branches/options/QTTabBar/Config.cs branches/options/QTTabBar/OptionsDialog.xaml branches/options/QTTabBar/OptionsDialog.xaml.cs Modified: branches/options/QTTabBar/Config.cs =================================================================== --- branches/options/QTTabBar/Config.cs 2011-08-31 04:18:42 UTC (rev 313) +++ branches/options/QTTabBar/Config.cs 2011-09-04 18:31:48 UTC (rev 314) @@ -42,19 +42,115 @@ Tile, } - public enum MouseTargets { - // TODO + public enum MouseTarget { + Anywhere, + Tab, + TabBarBackground, + FolderLink, + ExplorerItem, + ExplorerBackground } - public enum MouseAction { - // TODO + [Flags] + public enum MouseChord { + None = 0, + Shift = 1, + Ctrl = 2, + Alt = 4, + Left = 8, + Right = 16, + Middle = 32, + Double = 64, + X1 = 128, + X2 = 256, } - public struct MouseChord { - public Keys modifiers; - public MouseButtons button; - public bool dbl; - public MouseTargets target; + // WARNING + // reordering these will break existing settings. + public enum BindAction { + GoBack, + GoForward, + GoFirst, + GoLast, + NextTab, + PreviousTab, + FirstTab, + LastTab, + CloseCurrent, + CloseAllButCurrent, + CloseLeft, + CloseRight, + CloseWindow, + RestoreLastClosed, + CloneCurrent, + TearOffCurrent, + LockCurrent, + LockAll, + BrowseFolder, + CreateNewGroup, + ShowOptions, + ShowToolbarMenu, + ShowTabMenuCurrent, + ShowGroupMenu, + ShowRecentFolderMenu, + ShowUserAppsMenu, + ToggleMenuBar, + CopySelectedPaths, + CopySelectedNames, + ChecksumSelected, + ToggleTopMost, + TransparencyPlus, + TransparencyMinus, + FocusFileList, + FocusSearchBarReal, + FocusSearchBarBBar, + ShowSDTSelected, + SendToTray, + FocusTabBar, + + // New + NewTab, + NewWindow, + NewFolder, + NewFile, + SwitchToLastActivated, + MergeWindows, + ShowRecentFilesMenu, + SortTabsByName, + SortTabsByPath, + SortTabsByActive, + + // Mouse-only from here on down + UpOneLevel, + Refresh, + Paste, + Maximize, + Minimize, + + // Item Actions + ItemOpenInNewTab, + ItemOpenInNewTabNoSel, + ItemOpenInNewWindow, + ItemCut, + ItemCopy, + ItemDelete, + ItemProperties, + CopyItemPath, + CopyItemName, + ChecksumItem, + + // Tab Actions + CloseTab, + CloseLeftTab, + CloseRightTab, + UpOneLevelTab, //hmm + LockTab, + ShowTabMenu, + TearOffTab, + CloneTab, + CopyTabPath, + TabProperties, + ShowTabSubfolderMenu, } [Serializable] @@ -328,11 +424,39 @@ [Serializable] public class _Mouse { public bool MouseScrollsHotWnd { get; set; } - public Dictionary<MouseChord, MouseAction> MouseActions; + public Dictionary<MouseChord, BindAction> GlobalMouseActions { get; set; } + public Dictionary<MouseChord, BindAction> TabActions { get; set; } + public Dictionary<MouseChord, BindAction> BarActions { get; set; } + public Dictionary<MouseChord, BindAction> LinkActions { get; set; } + public Dictionary<MouseChord, BindAction> ItemActions { get; set; } + public Dictionary<MouseChord, BindAction> MarginActions { get; set; } public _Mouse() { MouseScrollsHotWnd = false; - // TODO actions + GlobalMouseActions = new Dictionary<MouseChord, BindAction> { + {MouseChord.X1, BindAction.GoBack}, + {MouseChord.X2, BindAction.GoForward} + }; + TabActions = new Dictionary<MouseChord, BindAction> { + {MouseChord.Middle, BindAction.CloseTab}, + {MouseChord.Ctrl | MouseChord.Left, BindAction.LockTab}, + {MouseChord.Double, BindAction.UpOneLevelTab}, + }; + BarActions = new Dictionary<MouseChord, BindAction> { + {MouseChord.Double, BindAction.NewTab}, + {MouseChord.Middle, BindAction.RestoreLastClosed} + }; + LinkActions = new Dictionary<MouseChord, BindAction> { + {MouseChord.Middle, BindAction.ItemOpenInNewTab}, + {MouseChord.Ctrl | MouseChord.Middle, BindAction.ItemOpenInNewWindow} + }; + ItemActions = new Dictionary<MouseChord, BindAction> { + {MouseChord.Middle, BindAction.ItemOpenInNewTab}, + {MouseChord.Ctrl | MouseChord.Middle, BindAction.ItemOpenInNewWindow} + }; + MarginActions = new Dictionary<MouseChord, BindAction> { + {MouseChord.Double, BindAction.UpOneLevel} + }; } } Modified: branches/options/QTTabBar/OptionsDialog.xaml =================================================================== --- branches/options/QTTabBar/OptionsDialog.xaml 2011-08-31 04:18:42 UTC (rev 313) +++ branches/options/QTTabBar/OptionsDialog.xaml 2011-09-04 18:31:48 UTC (rev 314) @@ -129,7 +129,7 @@ <Image Source="{Binding Source={x:Static qt:Resources_Image.imgOptions_SelAndHot}, Converter={StaticResource BitmapToImageSourceConverter}}"/> <TextBlock Margin="10,1" - Text="{Binding Header}" + Text="{Binding Path=Header}" VerticalAlignment="Center"/> </Grid> </DataTemplate> @@ -142,7 +142,7 @@ <Image Source="{Binding Source={x:Static qt:Resources_Image.imgOptions_NoFocus}, Converter={StaticResource BitmapToImageSourceConverter}}"/> <TextBlock Margin="10,1" - Text="{Binding Header}" + Text="{Binding Path=Header}" VerticalAlignment="Center"/> </Grid> </DataTemplate> @@ -277,6 +277,21 @@ </StackPanel> </DockPanel> </DataTemplate> + <DataTemplate x:Key="WinFormsGroupStyle"> + <DockPanel LastChildFill="True"> + <TextBlock + DockPanel.Dock="Left" + Foreground="MediumBlue" + Margin="20, 1, 4, 4" + Text="{Binding Path=Name}"/> + <Border + BorderBrush="LightGray" + BorderThickness="1" + Height="1" + Margin="0,0,10,0" + SnapsToDevicePixels="True"/> + </DockPanel> + </DataTemplate> </Window.Resources> <!-- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - --> @@ -1531,54 +1546,96 @@ Height="16" Margin="0,0,15,0" Padding="0"/> - <ComboBox + <ComboBox x:Name="cmbMouseTarget" + DisplayMemberPath="Value" Height="23" + SelectedValuePath="Key" + SelectionChanged="cmbMouseTarget_SelectionChanged" Width="120"/> </StackPanel> <StackPanel - Margin="13,1,0,1" + Margin="0,10,0,1" Orientation="Horizontal"> - <StackPanel - Margin="0" - Orientation="Vertical"> - <CheckBox Content="Ctrl"/> - <CheckBox Content="Shift"/> - <CheckBox Content="Alt"/> - </StackPanel> - <Label - Content="+" - Margin="8,0" - Padding="0" - VerticalAlignment="Center"/> - <ComboBox + <ComboBox x:Name="cmbMouseModifiers" + DisplayMemberPath="Value" Height="23" - ItemsSource="{Binding}" + SelectedValuePath="Key" VerticalAlignment="Center" + Width="70" + Margin="0,0,10,0"> + </ComboBox> + <ComboBox x:Name="cmbMouseButtons" + DisplayMemberPath="Value" + Height="23" + SelectedValuePath="Key" + VerticalAlignment="Center" Width="100"> - <ComboBoxItem Content="Left Click"/> - <ComboBoxItem Content="Middle Click"/> - <ComboBoxItem Content="Right Click"/> - <ComboBoxItem Content="Double Click"/> </ComboBox> <Label Content="=" Margin="8,0" Padding="0" VerticalAlignment="Center"/> - <ComboBox + <ComboBox x:Name="cmbMouseAction" + DisplayMemberPath="Value" Height="23" + SelectedValuePath="Key" VerticalAlignment="Center" - Width="150"/> - <Button + Width="180"/> + <Button x:Name="btnMouseActionAdd" + Click="btnMouseActionAdd_Click" Content="Add" Height="23" Margin="20,0,0,0" - Width="50"/> + Width="50"> + <Button.Resources> + <Style TargetType="{x:Type Button}"> + <Style.Triggers> + <DataTrigger Binding="{Binding ElementName=cmbMouseAction, Path=SelectedIndex}" Value="-1"> + <Setter Property="IsEnabled" Value="False"/> + </DataTrigger> + <DataTrigger Binding="{Binding ElementName=cmbMouseButtons, Path=SelectedIndex}" Value="-1"> + <Setter Property="IsEnabled" Value="False"/> + </DataTrigger> + <DataTrigger Binding="{Binding ElementName=cmbMouseTarget, Path=SelectedIndex}" Value="-1"> + <Setter Property="IsEnabled" Value="False"/> + </DataTrigger> + </Style.Triggers> + </Style> + </Button.Resources> + </Button> </StackPanel> - <ListView + <ListView x:Name="lvwMouseBindings" Height="330" - IsSynchronizedWithCurrentItem="{x:Null}" - Margin="10"/> + BorderThickness="1.000001" + Margin="0,10"> + <ListView.GroupStyle> + <GroupStyle HeaderTemplate="{StaticResource WinFormsGroupStyle}"/> + </ListView.GroupStyle> + <ListView.View> + <GridView> + <GridViewColumn Header="Mouse Chord" Width="170"> + <GridViewColumn.CellTemplate> + <DataTemplate> + <TextBlock + Foreground="#FF000000" + Text="{Binding Path=GestureText}"/> + </DataTemplate> + </GridViewColumn.CellTemplate> + </GridViewColumn> + <GridViewColumn Header="Action" Width="310"> + <GridViewColumn.CellTemplate> + <DataTemplate> + <TextBlock + Foreground="#FF000000" + Text="{Binding Path=ActionText}" + TextAlignment="Center"/> + </DataTemplate> + </GridViewColumn.CellTemplate> + </GridViewColumn> + </GridView> + </ListView.View> + </ListView> <Label Content="Other mouse options" Style="{StaticResource SectionHeaderStyle}"/> @@ -1615,25 +1672,7 @@ BorderThickness="1.000001" Margin="0,10"> <ListView.GroupStyle> - <GroupStyle> - <GroupStyle.HeaderTemplate> - <DataTemplate> - <DockPanel LastChildFill="True"> - <TextBlock - DockPanel.Dock="Left" - Foreground="MediumBlue" - Margin="20, 1, 4, 4" - Text="{Binding Name}"/> - <Border - BorderBrush="LightGray" - BorderThickness="1" - Height="1" - Margin="0,0,10,0" - SnapsToDevicePixels="True"/> - </DockPanel> - </DataTemplate> - </GroupStyle.HeaderTemplate> - </GroupStyle> + <GroupStyle HeaderTemplate="{StaticResource WinFormsGroupStyle}"/> </ListView.GroupStyle> <ListView.View> <GridView> Modified: branches/options/QTTabBar/OptionsDialog.xaml.cs =================================================================== --- branches/options/QTTabBar/OptionsDialog.xaml.cs 2011-08-31 04:18:42 UTC (rev 313) +++ branches/options/QTTabBar/OptionsDialog.xaml.cs 2011-09-04 18:31:48 UTC (rev 314) @@ -65,21 +65,231 @@ private PluginManager pluginManager; private ObservableCollection<PluginEntry> CurrentPlugins; - // todo: localize - private static Dictionary<TabPos, string> NewTabPosItems = new Dictionary<TabPos, string> { + // Mouse stuff + private ObservableCollection<MouseEntry> MouseBindings; + + // todo: localize all of these + #region ToLocalize + + private readonly static Dictionary<TabPos, string> NewTabPosItems + = new Dictionary<TabPos, string> { {TabPos.Left, "Left of the current tab" }, {TabPos.Right, "Right of the current tab" }, {TabPos.Leftmost, "In the leftmost position" }, {TabPos.Rightmost, "In the rightmost position" }, }; - private static Dictionary<TabPos, string> NextAfterCloseItems = new Dictionary<TabPos, string> { + private readonly static Dictionary<TabPos, string> NextAfterCloseItems + = new Dictionary<TabPos, string> { {TabPos.Left, "Tab to the left" }, {TabPos.Right, "Tab to the right" }, {TabPos.Leftmost, "Leftmost tab" }, {TabPos.Rightmost, "Rightmost tab" }, {TabPos.LastActive, "Last activated tab"}, }; + private readonly static Dictionary<MouseTarget, string> MouseTargetItems + = new Dictionary<MouseTarget, string> { + {MouseTarget.Anywhere, "Anywhere" }, + {MouseTarget.Tab, "Tab" }, + {MouseTarget.TabBarBackground, "Tab Bar Background" }, + {MouseTarget.FolderLink, "Folder Link" }, + {MouseTarget.ExplorerItem, "File or Folder" }, + {MouseTarget.ExplorerBackground,"Explorer Background" }, + }; + private readonly static Dictionary<BindAction, string> MouseActionItems + = new Dictionary<BindAction, string> { + {BindAction.GoBack, "Go back"}, + {BindAction.GoForward, "Go forward"}, + {BindAction.GoFirst, "Go to back to start"}, + {BindAction.GoLast, "Go forward to end"}, + {BindAction.NextTab, "Next tab"}, + {BindAction.PreviousTab, "Previous tab"}, + {BindAction.FirstTab, "First tab"}, + {BindAction.LastTab, "Last tab"}, + {BindAction.CloseCurrent, "Close current tab"}, + {BindAction.CloseAllButCurrent, "Close all tabs except current"}, + {BindAction.CloseLeft, "Close tabs to the left of current"}, + {BindAction.CloseRight, "Close tabs to the right of current"}, + {BindAction.CloseWindow, "Close window"}, + {BindAction.RestoreLastClosed, "Restore last closed tab"}, + {BindAction.CloneCurrent, "Clone current tab"}, + {BindAction.TearOffCurrent, "Open current tab in new window"}, + {BindAction.LockCurrent, "Lock current tab"}, + {BindAction.LockAll, "Lock all tabs"}, + {BindAction.BrowseFolder, "Browse for folder"}, + {BindAction.CreateNewGroup, "Create new group"}, + {BindAction.ShowOptions, "Show options"}, + {BindAction.ShowToolbarMenu, "Show Toolbar menu"}, + {BindAction.ShowTabMenuCurrent, "Show current tab context menu"}, + {BindAction.ShowGroupMenu, "Show Button Bar Group menu"}, + {BindAction.ShowRecentFolderMenu, "Show Button Bar Recently Closed menu" }, + {BindAction.ShowUserAppsMenu, "Show Button Bar Apps menu"}, + {BindAction.ToggleMenuBar, "Toggle Explorer Menu Bar"}, + {BindAction.CopySelectedPaths, "Copy paths of selected files"}, + {BindAction.CopySelectedNames, "Copy names of selected files"}, + {BindAction.ChecksumSelected, "View checksums selected files"}, + {BindAction.ToggleTopMost, "Toggle always on top"}, + {BindAction.TransparencyPlus, "Transparency +"}, + {BindAction.TransparencyMinus, "Transparency -"}, + {BindAction.FocusFileList, "Focus file list"}, + {BindAction.FocusSearchBarReal, "Focus Explorer search box"}, + {BindAction.FocusSearchBarBBar, "Focus Button Bar search box"}, + {BindAction.ShowSDTSelected, "Show Subdirectory Tip menu for selected folder"}, + {BindAction.SendToTray, "Send window to tray"}, + {BindAction.FocusTabBar, "Focus tab bar"}, + {BindAction.NewTab, "Open new tab"}, + {BindAction.NewWindow, "Open new window"}, + {BindAction.NewFolder, "Create new folder"}, + {BindAction.NewFile, "Create new empty file"}, + {BindAction.SwitchToLastActivated, "Switch to last activated tab"}, + {BindAction.MergeWindows, "Merge open windows"}, + {BindAction.ShowRecentFilesMenu, "Show Button Bar Recent Files menu"}, + {BindAction.SortTabsByName, "Sort tabs by name"}, + {BindAction.SortTabsByPath, "Sort tabs by path"}, + {BindAction.SortTabsByActive, "Sort tabs by last activated"}, + {BindAction.UpOneLevel, "Up one level"}, + {BindAction.Refresh, "Refresh"}, + {BindAction.Paste, "Paste"}, + {BindAction.Maximize, "Maximize"}, + {BindAction.Minimize, "Minimize"}, + {BindAction.ItemOpenInNewTab, "Open in new tab"}, + {BindAction.ItemOpenInNewTabNoSel, "Open in new tab without activating"}, + {BindAction.ItemOpenInNewWindow, "Open in new window"}, + {BindAction.ItemCut, "Cut"}, + {BindAction.ItemCopy, "Copy"}, + {BindAction.ItemDelete, "Delete"}, + {BindAction.ItemProperties, "Properties"}, + {BindAction.CopyItemPath, "Copy path"}, + {BindAction.CopyItemName, "Copy name"}, + {BindAction.ChecksumItem, "View checksum"}, + {BindAction.CloseTab, "Close tab"}, + {BindAction.CloseLeftTab, "Close tabs to left"}, + {BindAction.CloseRightTab, "Close tabs to right"}, + {BindAction.UpOneLevelTab, "Up one level"}, + {BindAction.LockTab, "Lock"}, + {BindAction.ShowTabMenu, "Context menu"}, + {BindAction.TearOffTab, "Open in new window"}, + {BindAction.CloneTab, "Clone"}, + {BindAction.CopyTabPath, "Copy path"}, + {BindAction.TabProperties, "Properties"}, + {BindAction.ShowTabSubfolderMenu, "Show Subdirectory Tip menu"}, + }; + private static readonly Dictionary<MouseChord, string> MouseButtonItems + = new Dictionary<MouseChord, string> { + {MouseChord.Left, "Left Click"}, + {MouseChord.Right, "Right Click"}, + {MouseChord.Middle, "Middle Click"}, + {MouseChord.Double, "Double Click"}, + {MouseChord.X1, "X1 Click"}, + {MouseChord.X2, "X2 Click"}, + }; + private static readonly Dictionary<MouseChord, string> MouseModifierItems + = new Dictionary<MouseChord, string> { + {MouseChord.None, "-"}, + {MouseChord.Shift, "Shift"}, + {MouseChord.Ctrl, "Ctrl"}, + {MouseChord.Alt, "Alt"}, + }; + #endregion + // Which actions are valid for which targets? + private readonly static Dictionary<MouseTarget, Dictionary<BindAction, string>> MouseTargetActions + = new Dictionary<MouseTarget, Dictionary<BindAction, string>> { + {MouseTarget.Anywhere, new BindAction[] { + BindAction.GoBack, + BindAction.GoForward, + BindAction.NextTab, + BindAction.PreviousTab + }.ToDictionary(k => k, k => MouseActionItems[k])}, + {MouseTarget.Tab, new BindAction[] { + BindAction.CloseTab, + BindAction.UpOneLevelTab, + BindAction.LockTab, + BindAction.ShowTabMenu, + BindAction.CloneTab, + BindAction.TearOffTab, + BindAction.CopyTabPath, + BindAction.TabProperties, + BindAction.ShowTabSubfolderMenu, + }.ToDictionary(k => k, k => MouseActionItems[k])}, + {MouseTarget.TabBarBackground, new BindAction[] { + BindAction.NewTab, + BindAction.NewWindow, + BindAction.UpOneLevel, + BindAction.CloseAllButCurrent, + BindAction.CloseWindow, + BindAction.RestoreLastClosed, + BindAction.CloneCurrent, + BindAction.TearOffCurrent, + BindAction.LockAll, + BindAction.BrowseFolder, + BindAction.ShowOptions, + BindAction.ShowToolbarMenu, + BindAction.SortTabsByName, + BindAction.SortTabsByPath, + BindAction.SortTabsByActive, + }.ToDictionary(k => k, k => MouseActionItems[k])}, + {MouseTarget.FolderLink, new BindAction[] { + BindAction.ItemOpenInNewTab, + BindAction.ItemOpenInNewTabNoSel, + BindAction.ItemOpenInNewWindow, + BindAction.ItemProperties, + BindAction.CopyItemPath, + BindAction.CopyItemName, + }.ToDictionary(k => k, k => MouseActionItems[k])}, + {MouseTarget.ExplorerItem, new BindAction[] { + BindAction.ItemOpenInNewTab, + BindAction.ItemOpenInNewTabNoSel, + BindAction.ItemOpenInNewWindow, + BindAction.ItemCut, + BindAction.ItemCopy, + BindAction.ItemDelete, + BindAction.ItemProperties, + BindAction.CopyItemPath, + BindAction.CopyItemName, + BindAction.ChecksumItem, + }.ToDictionary(k => k, k => MouseActionItems[k])}, + {MouseTarget.ExplorerBackground, new BindAction[] { + BindAction.BrowseFolder, + BindAction.NewFolder, + BindAction.NewFile, + BindAction.UpOneLevel, + BindAction.Refresh, + BindAction.Paste, + BindAction.Maximize, + BindAction.Minimize, + }.ToDictionary(k => k, k => MouseActionItems[k])}, + }; + + // Which buttons are valid for which targets? + private static readonly Dictionary<MouseTarget, Dictionary<MouseChord, string>> MouseTargetButtons + = new Dictionary<MouseTarget, Dictionary<MouseChord, string>> { + {MouseTarget.Anywhere, new MouseChord[] { + MouseChord.X1, + MouseChord.X2, + }.ToDictionary(k => k, k => MouseButtonItems[k])}, + {MouseTarget.ExplorerBackground, new MouseChord[] { + MouseChord.Middle, + MouseChord.Double, + }.ToDictionary(k => k, k => MouseButtonItems[k])}, + {MouseTarget.ExplorerItem, new MouseChord[] { + MouseChord.Middle, + }.ToDictionary(k => k, k => MouseButtonItems[k])}, + {MouseTarget.FolderLink, new MouseChord[] { + MouseChord.Left, + MouseChord.Middle, + }.ToDictionary(k => k, k => MouseButtonItems[k])}, + {MouseTarget.Tab, new MouseChord[] { + MouseChord.Left, + MouseChord.Middle, + MouseChord.Double, + }.ToDictionary(k => k, k => MouseButtonItems[k])}, + {MouseTarget.TabBarBackground, new MouseChord[] { + MouseChord.Left, + MouseChord.Middle, + MouseChord.Double, + }.ToDictionary(k => k, k => MouseButtonItems[k])}, + }; + #region ---------- Static Methods ---------- public static void Open() { @@ -133,13 +343,14 @@ QTTabBarClass tabBar = InstanceManager.CurrentTabBar; if(tabBar != null) { // we should probably assert this. - pluginManager = tabBar.GetPluginManager(); + pluginManager = tabBar.GetPluginManager(); } workingConfig = QTUtility2.DeepClone(ConfigManager.LoadedConfig); InitializeComponent(); cmbNewTabPos.ItemsSource = NewTabPosItems; cmbNextAfterClosed.ItemsSource = NextAfterCloseItems; + InitializeMouse(); InitializeKeys(); InitializeButtonBar(); @@ -157,6 +368,7 @@ private void UpdateOptions() { List<PluginAssembly> assemblies; + CommitMouse(); CommitPlugins(out assemblies); CommitButtonBar(); bool fButtonBarNeedsRefresh = Config.BBar.LargeButtons != workingConfig.bbar.LargeButtons; @@ -268,7 +480,90 @@ btnBackgroundColor.Background = new SolidColorBrush(Color.FromArgb( bg.A, bg.R, bg.G, bg.B)); } + + #endregion + + #region ---------- Mouse ---------- + private void InitializeMouse() { + MouseBindings = new ObservableCollection<MouseEntry>(); + foreach(var p in workingConfig.mouse.GlobalMouseActions) { + MouseBindings.Add(new MouseEntry(MouseTarget.Anywhere, p.Key, p.Value)); + } + foreach(var p in workingConfig.mouse.MarginActions) { + MouseBindings.Add(new MouseEntry(MouseTarget.ExplorerBackground, p.Key, p.Value)); + } + foreach(var p in workingConfig.mouse.ItemActions) { + MouseBindings.Add(new MouseEntry(MouseTarget.ExplorerItem, p.Key, p.Value)); + } + foreach(var p in workingConfig.mouse.LinkActions) { + MouseBindings.Add(new MouseEntry(MouseTarget.FolderLink, p.Key, p.Value)); + } + foreach(var p in workingConfig.mouse.TabActions) { + MouseBindings.Add(new MouseEntry(MouseTarget.Tab, p.Key, p.Value)); + } + foreach(var p in workingConfig.mouse.BarActions) { + MouseBindings.Add(new MouseEntry(MouseTarget.TabBarBackground, p.Key, p.Value)); + } + ICollectionView view = CollectionViewSource.GetDefaultView(MouseBindings); + PropertyGroupDescription groupDescription = new PropertyGroupDescription("TargetText"); + view.GroupDescriptions.Add(groupDescription); + lvwHotkeys.ItemsSource = view; + lvwMouseBindings.ItemsSource = MouseBindings; + + cmbMouseModifiers.ItemsSource = MouseModifierItems; + cmbMouseTarget.ItemsSource = MouseTargetItems; + cmbMouseTarget.SelectedIndex = 0; + cmbMouseModifiers.SelectedIndex = 0; + cmbMouseButtons.SelectedIndex = 0; + } + + private void CommitMouse() { + workingConfig.mouse.GlobalMouseActions = MouseBindings + .Where(e => e.Target == MouseTarget.Anywhere) + .ToDictionary(e => e.Chord, e => e.Action); + workingConfig.mouse.MarginActions = MouseBindings + .Where(e => e.Target == MouseTarget.ExplorerBackground) + .ToDictionary(e => e.Chord, e => e.Action); + workingConfig.mouse.ItemActions = MouseBindings + .Where(e => e.Target == MouseTarget.ExplorerItem) + .ToDictionary(e => e.Chord, e => e.Action); + workingConfig.mouse.LinkActions = MouseBindings + .Where(e => e.Target == MouseTarget.FolderLink) + .ToDictionary(e => e.Chord, e => e.Action); + workingConfig.mouse.TabActions = MouseBindings + .Where(e => e.Target == MouseTarget.Tab) + .ToDictionary(e => e.Chord, e => e.Action); + workingConfig.mouse.BarActions = MouseBindings + .Where(e => e.Target == MouseTarget.TabBarBackground) + .ToDictionary(e => e.Chord, e => e.Action); + } + + private void cmbMouseTarget_SelectionChanged(object sender, SelectionChangedEventArgs e) { + var v = (KeyValuePair<MouseTarget, string>)e.AddedItems[0]; + cmbMouseAction.ItemsSource = MouseTargetActions[v.Key]; + cmbMouseButtons.ItemsSource = MouseTargetButtons[v.Key]; + cmbMouseButtons.SelectedIndex = 0; + } + + private void btnMouseActionAdd_Click(object sender, RoutedEventArgs e) { + MouseTarget target = (MouseTarget)cmbMouseTarget.SelectedValue; + BindAction action = (BindAction)cmbMouseAction.SelectedValue; + MouseChord chord = (MouseChord)cmbMouseModifiers.SelectedValue | (MouseChord)cmbMouseButtons.SelectedValue; + MouseEntry entry = MouseBindings.FirstOrDefault(m => m.Target == target && m.Chord == chord); + if(entry != null) { + const string removePlugin = "This mouse chord is already bound to the following action:\n\n{0}\n\nReplace?"; + if(MessageBox.Show(string.Format(removePlugin, entry.ActionText), string.Empty, MessageBoxButton.OKCancel, MessageBoxImage.Question) != MessageBoxResult.OK) { + return; + } + entry.Action = action; + lvwMouseBindings.Items.Refresh(); + } + else { + MouseBindings.Add(new MouseEntry(target, chord, action)); + } + } + #endregion #region ---------- Keyboard ---------- @@ -279,8 +574,8 @@ int[] keys = workingConfig.keys.Shortcuts; List<HotkeyEntry> list = arrActions.Select((act, i) => new HotkeyEntry(keys, i, act, arrGrps[0])).ToList(); foreach(string pluginID in QTUtility.dicPluginShortcutKeys.Keys) { - Plugin p; - keys = QTUtility.dicPluginShortcutKeys[pluginID]; + Plugin p; + keys = QTUtility.dicPluginShortcutKeys[pluginID]; if(!pluginManager.TryGetPlugin(pluginID, out p)) continue; PluginInformation pi = p.PluginInformation; if(pi.ShortcutKeyActions == null) continue; @@ -401,7 +696,7 @@ if((wpfModKeys & ModifierKeys.Alt) != 0) modKeys |= Keys.Alt; if((wpfModKeys & ModifierKeys.Control) != 0) modKeys |= Keys.Control; if((wpfModKeys & ModifierKeys.Shift) != 0) modKeys |= Keys.Shift; - + HotkeyEntry entry = (HotkeyEntry)lvwHotkeys.SelectedItem; if(key == Keys.Escape) { entry.Key = Keys.None; @@ -465,7 +760,7 @@ } } } - catch {} + catch { } } } } @@ -477,13 +772,13 @@ if(pluginIndex < PluginManager.ActivatedButtonsOrder.Count) { var pluginButton = PluginManager.ActivatedButtonsOrder[pluginIndex]; if(dicPluginListPos.ContainsKey(pluginButton.id)) { - CurrentButtons.Add(lstPluginButtons[dicPluginListPos[pluginButton.id] + pluginButton.index]); + CurrentButtons.Add(lstPluginButtons[dicPluginListPos[pluginButton.id] + pluginButton.index]); } } pluginIndex++; } else { - CurrentButtons.Add(new ButtonEntry(this, i)); + CurrentButtons.Add(new ButtonEntry(this, i)); } } @@ -500,7 +795,7 @@ } } lstButtonBarPool.ItemsSource = ButtonPool; - lstButtonBarCurrent.ItemsSource = CurrentButtons; + lstButtonBarCurrent.ItemsSource = CurrentButtons; } private void CommitButtonBar() { @@ -600,7 +895,7 @@ p.Instance.OnOption(); } catch(Exception ex) { - PluginManager.HandlePluginException(ex, new WindowInteropHelper(this).Handle, + PluginManager.HandlePluginException(ex, new WindowInteropHelper(this).Handle, entry.PluginInfo.Name, "Open plugin option."); } } @@ -623,7 +918,7 @@ } lstPluginView.Items.Refresh(); } - + private void btnPluginRemove_Click(object sender, RoutedEventArgs e) { if(lstPluginView.SelectedIndex == -1) return; PluginEntry entry = CurrentPlugins[lstPluginView.SelectedIndex]; @@ -725,7 +1020,7 @@ } #endregion - + #region ---------- ListBox Item Classes ---------- private class ButtonEntry { @@ -780,7 +1075,7 @@ else { return large ? parent.imageStripLarge[Index - 1] - : parent.imageStripSmall[Index - 1]; + : parent.imageStripSmall[Index - 1]; } } public ButtonEntry(OptionsDialog parent, int Index) { @@ -798,7 +1093,7 @@ private class PluginEntry { private OptionsDialog parent; public PluginInformation PluginInfo; - public PluginAssembly PluginAssembly; + public PluginAssembly PluginAssembly; public Image Icon { get { return PluginInfo.ImageLarge ?? Resources_Image.imgPlugin24; } } public string Title { get { return PluginInfo.Name + " " + PluginInfo.Version; } } @@ -832,7 +1127,7 @@ } return false; } - } + } public PluginEntry(OptionsDialog parent, PluginInformation pluginInfo, PluginAssembly pluginAssembly) { this.parent = parent; @@ -849,7 +1144,7 @@ } public bool Enabled { get { return (RawKey & QTUtility.FLAG_KEYENABLED) != 0 && RawKey != QTUtility.FLAG_KEYENABLED; } - set { if(value) RawKey |= QTUtility.FLAG_KEYENABLED; else RawKey &= ~QTUtility.FLAG_KEYENABLED; } + set { if(value) RawKey |= QTUtility.FLAG_KEYENABLED; else RawKey &= ~QTUtility.FLAG_KEYENABLED; } } public Keys Key { get { return (Keys)(RawKey & ~QTUtility.FLAG_KEYENABLED); } @@ -873,9 +1168,28 @@ } } + private class MouseEntry { + public string GestureText { get { + MouseChord modifier = Chord & (MouseChord.Alt | MouseChord.Ctrl | MouseChord.Shift); + MouseChord button = Chord & ~(MouseChord.Alt | MouseChord.Ctrl | MouseChord.Shift); + return (modifier != MouseChord.None ? MouseModifierItems[modifier] + " + " : "") + + MouseButtonItems[button]; + } } + public string TargetText { get { return MouseTargetItems[Target]; } } + public string ActionText { get { return MouseActionItems[Action]; } } + public MouseTarget Target { get; private set; } + public BindAction Action { get; set; } + public MouseChord Chord { get; private set; } + + public MouseEntry(MouseTarget target, MouseChord chord, BindAction action) { + Target = target; + Action = action; + Chord = chord; + } + } #endregion } - + #region ---------- Converters ---------- // Inverts the value of a boolean @@ -980,7 +1294,7 @@ private static void OnIsCheckedRealChanged(DependencyObject d, DependencyPropertyChangedEventArgs e) { RadioButtonEx rbx = ((RadioButtonEx)d); - rbx.bIsChanging = true; + rbx.bIsChanging = true; rbx.IsChecked = (bool?)e.NewValue; rbx.bIsChanging = false; } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |