Thread: [Qttabbar-Commit] SF.net SVN: qttabbar:[340] branches/options/QTTabBar (Page 2)
Status: Beta
Brought to you by:
masamunexgp
From: <ka...@us...> - 2011-10-19 21:04:25
|
Revision: 340 http://qttabbar.svn.sourceforge.net/qttabbar/?rev=340&view=rev Author: kawanon Date: 2011-10-19 21:04:19 +0000 (Wed, 19 Oct 2011) Log Message: ----------- Code clean-up. Fixed Add Folder button on Groups tab. Modified Paths: -------------- branches/options/QTTabBar/OptionsDialog.xaml branches/options/QTTabBar/OptionsDialog.xaml.cs Modified: branches/options/QTTabBar/OptionsDialog.xaml =================================================================== --- branches/options/QTTabBar/OptionsDialog.xaml 2011-10-19 16:51:14 UTC (rev 339) +++ branches/options/QTTabBar/OptionsDialog.xaml 2011-10-19 21:04:19 UTC (rev 340) @@ -364,7 +364,7 @@ </Setter.Value> </Setter> </Style> - <DataTemplate x:Key="CellTemplate_Name"> + <DataTemplate x:Key="CellTemplate_Folder"> <DockPanel> <ToggleButton x:Name="Expander" Style="{StaticResource ExpandCollapseToggleStyle}" @@ -388,7 +388,7 @@ Stretch="Fill" Margin="0,0,2,0"/> <TextBlock Text="{Binding Name}" VerticalAlignment="Center"/> - <TextBlock Text="{Binding Path}" VerticalAlignment="Center"/> + <TextBlock Text="{Binding DisplayText}" VerticalAlignment="Center"/> </StackPanel> </Border> </DockPanel> @@ -405,7 +405,7 @@ </DataTemplate> <GridViewColumnCollection x:Key="gvcc"> <GridViewColumn Header="Folder" - CellTemplate="{StaticResource CellTemplate_Name}" + CellTemplate="{StaticResource CellTemplate_Folder}" Width="300"/> <GridViewColumn Header="Startup" Width="60"> <GridViewColumn.CellTemplate> Modified: branches/options/QTTabBar/OptionsDialog.xaml.cs =================================================================== --- branches/options/QTTabBar/OptionsDialog.xaml.cs 2011-10-19 16:51:14 UTC (rev 339) +++ branches/options/QTTabBar/OptionsDialog.xaml.cs 2011-10-19 21:04:19 UTC (rev 340) @@ -1074,19 +1074,16 @@ if(val == null) { return tvw.Items.Count; } - TreeViewItem container = (TreeViewItem)FindItemContainer(tvw, val); - if(container == null) { - return tvw.Items.Count; + if(val is FolderEntry) { + // Goes up one level when a child is selected. + val = GetParentGroup((FolderEntry)val); } - int index = tvw.ItemContainerGenerator.IndexFromContainer(container); - if(index == -1) { - return tvw.Items.Count; - } + int index = CurrentGroups.IndexOf(val); return index + 1; } - private void AddNew<T>(TreeView tvw, T item) { - IList<T> col = (IList<T>)tvw.ItemsSource; + private void AddNew(TreeView tvw, object item) { + System.Collections.IList col = (System.Collections.IList)tvw.ItemsSource; col.Insert( GetPreferredInsertionIndex(tvw), item); @@ -1104,17 +1101,17 @@ } private void btnGroupsAddSeparator_Click(object sender, RoutedEventArgs e) { - AddNew<object>(tvwGroups, new SeparatorEntry()); + AddNew(tvwGroups, new SeparatorEntry()); } private void btnGroupsAddGroup_Click(object sender, RoutedEventArgs e) { - AddNew<object>(tvwGroups, new GroupEntry("New Group")); + AddNew(tvwGroups, new GroupEntry("New Group")); } private void btnGroupsAddFolder_Click(object sender, RoutedEventArgs e) { // TODO: Generates new group if the view is empty. - object val = (GroupEntry)tvwGroups.SelectedItem; + object val = tvwGroups.SelectedItem; if(val == null) { return; } @@ -1125,10 +1122,9 @@ GroupEntry group; int index; if(val is FolderEntry) { - group = GetParentGroup((FolderEntry)val); - TreeViewItem child = (TreeViewItem)FindItemContainer(tvwGroups, val); - TreeViewItem parent = (TreeViewItem)FindItemContainer(tvwGroups, group); - index = parent.ItemContainerGenerator.IndexFromContainer(child) + 1; + FolderEntry entry = (FolderEntry)val; + group = GetParentGroup(entry); + index = group.Folders.IndexOf(entry) + 1; } else { group = (GroupEntry)val; @@ -1154,13 +1150,23 @@ if(val == null) { return; } + + System.Collections.IList col; if(val is FolderEntry) { GroupEntry group = GetParentGroup((FolderEntry)val); - group.Folders.Remove((FolderEntry)val); + col = group.Folders; } else { - CurrentGroups.Remove(val); + col = CurrentGroups; } + int index = col.IndexOf(val); + col.RemoveAt(index); + + if(index < col.Count) { + object next = col[index]; + TreeViewItem container = (TreeViewItem)FindItemContainer(tvwGroups, next); + container.IsSelected = true; + } } #endregion This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ka...@us...> - 2011-10-20 20:33:38
|
Revision: 341 http://qttabbar.svn.sourceforge.net/qttabbar/?rev=341&view=rev Author: kawanon Date: 2011-10-20 20:33:32 +0000 (Thu, 20 Oct 2011) Log Message: ----------- Exposed EditableHeader dependency properties. EditableHeader behaves like a system edit label now. Made Groups tab edit-in-place. Modified Paths: -------------- branches/options/QTTabBar/EditableHeader.xaml branches/options/QTTabBar/EditableHeader.xaml.cs branches/options/QTTabBar/OptionsDialog.xaml branches/options/QTTabBar/OptionsDialog.xaml.cs Modified: branches/options/QTTabBar/EditableHeader.xaml =================================================================== --- branches/options/QTTabBar/EditableHeader.xaml 2011-10-19 21:04:19 UTC (rev 340) +++ branches/options/QTTabBar/EditableHeader.xaml 2011-10-20 20:33:32 UTC (rev 341) @@ -1,4 +1,4 @@ -<UserControl x:Class="QTTabBarLib.EditableHeader" +<UserControl x:Class="QTTabBarLib.EditableHeader" x:Name="EditableHeaderControl" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" @@ -7,14 +7,23 @@ d:DesignHeight="300" d:DesignWidth="300"> <Grid> <Grid.ColumnDefinitions> - <ColumnDefinition Width="Auto"/> + <ColumnDefinition Width="*"/> </Grid.ColumnDefinitions> - - <TextBlock x:Name="txtHeader" - Text="New Header" + + <Border BorderThickness="3"> + <TextBlock x:Name="txtHeader" + Text="{Binding Path=Text, ElementName=EditableHeaderControl}" + VerticalAlignment="Center" + Padding="{Binding Path=Padding, ElementName=txtHeaderEdit}" + MinWidth="{Binding Path=MinWidth, ElementName=txtHeaderEdit}" + MouseDown="txtHeader_MouseDown" MouseUp="txtHeader_MouseUp"/> + </Border> <TextBox x:Name="txtHeaderEdit" - Text="New Header" + Text="{Binding Path=Text, ElementName=EditableHeaderControl}" + Padding="0" + VerticalContentAlignment="Center" + MinWidth="10" LostFocus="txtHeaderEdit_LostFocus" KeyDown="txtHeaderEdit_KeyDown" Visibility="Hidden" /> Modified: branches/options/QTTabBar/EditableHeader.xaml.cs =================================================================== --- branches/options/QTTabBar/EditableHeader.xaml.cs 2011-10-19 21:04:19 UTC (rev 340) +++ branches/options/QTTabBar/EditableHeader.xaml.cs 2011-10-20 20:33:32 UTC (rev 341) @@ -18,26 +18,62 @@ /// Interaction logic for EditableHeader.xaml /// </summary> public partial class EditableHeader : UserControl { - public EditableHeader(string initialName = "", TreeViewItem item = null) { + + private bool preparing = false; + + public string Text { + get { return (string)GetValue(TextProperty); } + set { SetValue(TextProperty, value); } + } + + public UIElement Container { + get { return (UIElement)GetValue(ContainerProperty); } + set { SetValue(ContainerProperty, value); } + } + + public static readonly DependencyProperty TextProperty = + DependencyProperty.Register("Text", typeof(string), typeof(EditableHeader), + new FrameworkPropertyMetadata("New Header", FrameworkPropertyMetadataOptions.BindsTwoWayByDefault)); + public static readonly DependencyProperty ContainerProperty = + DependencyProperty.Register("Container", typeof(UIElement), typeof(EditableHeader), + new FrameworkPropertyMetadata(null)); + + public EditableHeader(string initialName, TreeViewItem item = null) { InitializeComponent(); - txtHeaderEdit.Text = txtHeader.Text = initialName; + if(initialName != null) { + Text = initialName; + } + //# TODO Find a way to set the mouse focus on instantiation... } + public EditableHeader() : this(null) { + } + private void txtHeaderEdit_LostFocus(object sender, RoutedEventArgs e) { - txtHeader.Text = txtHeaderEdit.Text; + //txtHeader.Text = txtHeaderEdit.Text; txtHeaderEdit.Visibility = Visibility.Hidden; } private void txtHeaderEdit_KeyDown(object sender, KeyEventArgs e) { if(e.Key == Key.Enter) { - txtHeader.Text = txtHeaderEdit.Text; + //txtHeader.Text = txtHeaderEdit.Text; txtHeaderEdit.Visibility = Visibility.Hidden; } } + private void txtHeader_MouseDown(object sender, MouseButtonEventArgs e) { + preparing = (Container != null) + ? Container.IsFocused + : true; + } + private void txtHeader_MouseUp(object sender, MouseButtonEventArgs e) { + // Does not open the text box if editable area has got focus by clicking right now. + if(!preparing) { + return; + } txtHeaderEdit.Visibility = Visibility.Visible; txtHeaderEdit.CaptureMouse(); txtHeaderEdit.Focus(); Modified: branches/options/QTTabBar/OptionsDialog.xaml =================================================================== --- branches/options/QTTabBar/OptionsDialog.xaml 2011-10-19 21:04:19 UTC (rev 340) +++ branches/options/QTTabBar/OptionsDialog.xaml 2011-10-20 20:33:32 UTC (rev 341) @@ -35,6 +35,7 @@ <qt:StringEqualityConverter x:Key="StringEqualityConverter"/> <BooleanToVisibilityConverter x:Key="BooleanToVisibilityConverter"/> <qt:LevelToIndentConverter x:Key="LevelIndentConverter"/> + <qt:ObjectToClassNameConverter x:Key="ObjectToClassNameConverter"/> <Style x:Key="SectionHeaderStyle" TargetType="Label"> <Setter Property="Background" Value="#FFF0F2F5"/> @@ -364,6 +365,68 @@ </Setter.Value> </Setter> </Style> + <DataTemplate x:Key="GroupFolderCellTemplate"> + <Border Margin="0,2"> + <StackPanel Orientation="Horizontal"> + <Image + Source="{Binding Path=Icon, Converter={StaticResource BitmapToImageSourceConverter}}" + Width="16" + Height="16" + Stretch="Fill" + Margin="0,0,2,0"/> + <qt:EditableHeader + x:Name="txtName" + Text="{Binding Path=Name}" + Visibility="Collapsed" + Container="{Binding RelativeSource={RelativeSource AncestorType={x:Type TreeViewItem}}}"/> + <qt:EditableHeader + x:Name="txtPath" + Text="{Binding Path=Path}" + Visibility="Collapsed" + Container="{Binding RelativeSource={RelativeSource AncestorType={x:Type TreeViewItem}}}"/> + <TextBlock + x:Name="txtDisplayText" + Text="{Binding Path=DisplayText}" + Visibility="Collapsed"/> + </StackPanel> + </Border> + <DataTemplate.Triggers> + <DataTrigger + Binding="{Binding Converter={StaticResource ObjectToClassNameConverter}}" + Value="GroupEntry"> + <Setter + TargetName="txtName" + Property="Visibility" + Value="Visible"/> + </DataTrigger> + <MultiDataTrigger> + <MultiDataTrigger.Conditions> + <Condition + Binding="{Binding Converter={StaticResource ObjectToClassNameConverter}}" + Value="FolderEntry"/> + <Condition + Binding="{Binding Path=IsVirtualFolder}" + Value="False"/> + </MultiDataTrigger.Conditions> + <Setter + TargetName="txtPath" + Property="Visibility" + Value="Visible"/> + </MultiDataTrigger> + <DataTrigger + Binding="{Binding Path=IsVirtualFolder}" + Value="True"> + <Setter + TargetName="txtPath" + Property="Visibility" + Value="Collapsed"/> + <Setter + TargetName="txtDisplayText" + Property="Visibility" + Value="Visible"/> + </DataTrigger> + </DataTemplate.Triggers> + </DataTemplate> <DataTemplate x:Key="CellTemplate_Folder"> <DockPanel> <ToggleButton x:Name="Expander" @@ -379,18 +442,9 @@ AncestorType= {x:Type qt:TreeListViewItem}}}" ClickMode="Press"/> - <Border Margin="0,2"> - <StackPanel Orientation="Horizontal"> - <Image - Source="{Binding Path=Icon, Converter={StaticResource BitmapToImageSourceConverter}}" - Width="16" - Height="16" - Stretch="Fill" - Margin="0,0,2,0"/> - <TextBlock Text="{Binding Name}" VerticalAlignment="Center"/> - <TextBlock Text="{Binding DisplayText}" VerticalAlignment="Center"/> - </StackPanel> - </Border> + <ContentPresenter + Content="{Binding}" + ContentTemplate="{StaticResource GroupFolderCellTemplate}"/> </DockPanel> <DataTemplate.Triggers> <DataTrigger Binding="{Binding Path=HasItems, @@ -416,8 +470,8 @@ VerticalAlignment="Center"/> <DataTemplate.Triggers> <DataTrigger - Binding="{Binding Path=Startup, Converter={StaticResource BoolInverterConverter}}" - Value="{x:Null}"> + Binding="{Binding Converter={StaticResource ObjectToClassNameConverter}}" + Value="GroupEntry"> <Setter TargetName="chkStartup" Property="Visibility" @@ -435,8 +489,8 @@ VerticalAlignment="Center">Ctrl + A</TextBlock> <DataTemplate.Triggers> <DataTrigger - Binding="{Binding Path=Startup, Converter={StaticResource BoolInverterConverter}}" - Value="{x:Null}"> + Binding="{Binding Converter={StaticResource ObjectToClassNameConverter}}" + Value="GroupEntry"> <Setter TargetName="txtShortcutKey" Property="Visibility" Modified: branches/options/QTTabBar/OptionsDialog.xaml.cs =================================================================== --- branches/options/QTTabBar/OptionsDialog.xaml.cs 2011-10-19 21:04:19 UTC (rev 340) +++ branches/options/QTTabBar/OptionsDialog.xaml.cs 2011-10-20 20:33:32 UTC (rev 341) @@ -1685,7 +1685,7 @@ } public class FolderEntry { - public string Path { get; private set; } + public string Path { get; set; } public string DisplayText { get { return QTUtility2.MakePathDisplayText(Path, true); @@ -1696,6 +1696,11 @@ return QTUtility.GetIcon(Path, false).ToBitmap(); } } + public bool IsVirtualFolder { + get { + return Path.StartsWith("::"); + } + } public FolderEntry(string path) { Path = path; @@ -1705,7 +1710,7 @@ } public class GroupEntry { - public string Name { get; private set; } + public string Name { get; set; } public Image Icon { get { return Resources_Image.icoEmpty.ToBitmap(); @@ -1719,8 +1724,7 @@ Name = name; Folders = new ObservableCollection<FolderEntry>(); } - public GroupEntry() { - Folders = new ObservableCollection<FolderEntry>(); + public GroupEntry() : this(null) { } } @@ -1836,6 +1840,22 @@ private const double c_IndentSize = 19.0; } + // You can create ObjectToTypeConverter instead of this, + // but VS2010 WPF Designer would refuse an expression like {x:Type SomeClass+NestedClass} + [ValueConversion(typeof(object), typeof(string))] + public class ObjectToClassNameConverter : IValueConverter { + public object Convert(object value, Type targetType, object parameter, CultureInfo culture) { + if(value == null) { + return null; + } + return value.GetType().Name; + } + + public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture) { + throw new NotSupportedException(); + } + } + #endregion // Overloaded RadioButton class to work around .NET 3.5's horribly HORRIBLY This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ka...@us...> - 2011-10-20 21:47:45
|
Revision: 342 http://qttabbar.svn.sourceforge.net/qttabbar/?rev=342&view=rev Author: kawanon Date: 2011-10-20 21:47:39 +0000 (Thu, 20 Oct 2011) Log Message: ----------- Groups and folders change their own icons immediately. Minor code cleanup. Modified Paths: -------------- branches/options/QTTabBar/OptionsDialog.xaml branches/options/QTTabBar/OptionsDialog.xaml.cs Modified: branches/options/QTTabBar/OptionsDialog.xaml =================================================================== --- branches/options/QTTabBar/OptionsDialog.xaml 2011-10-20 20:33:32 UTC (rev 341) +++ branches/options/QTTabBar/OptionsDialog.xaml 2011-10-20 21:47:39 UTC (rev 342) @@ -387,6 +387,7 @@ <TextBlock x:Name="txtDisplayText" Text="{Binding Path=DisplayText}" + VerticalAlignment="Center" Visibility="Collapsed"/> </StackPanel> </Border> @@ -417,17 +418,13 @@ Binding="{Binding Path=IsVirtualFolder}" Value="True"> <Setter - TargetName="txtPath" - Property="Visibility" - Value="Collapsed"/> - <Setter TargetName="txtDisplayText" Property="Visibility" Value="Visible"/> </DataTrigger> </DataTemplate.Triggers> </DataTemplate> - <DataTemplate x:Key="CellTemplate_Folder"> + <DataTemplate x:Key="PrimaryCellTemplate"> <DockPanel> <ToggleButton x:Name="Expander" Style="{StaticResource ExpandCollapseToggleStyle}" @@ -459,7 +456,7 @@ </DataTemplate> <GridViewColumnCollection x:Key="gvcc"> <GridViewColumn Header="Folder" - CellTemplate="{StaticResource CellTemplate_Folder}" + CellTemplate="{StaticResource PrimaryCellTemplate}" Width="300"/> <GridViewColumn Header="Startup" Width="60"> <GridViewColumn.CellTemplate> @@ -467,7 +464,8 @@ <CheckBox x:Name="chkStartup" IsChecked="{Binding Path=Startup}" HorizontalAlignment="Center" - VerticalAlignment="Center"/> + VerticalAlignment="Center" + Visibility="Collapsed"/> <DataTemplate.Triggers> <DataTrigger Binding="{Binding Converter={StaticResource ObjectToClassNameConverter}}" @@ -475,7 +473,7 @@ <Setter TargetName="chkStartup" Property="Visibility" - Value="Collapsed"/> + Value="Visible"/> </DataTrigger> </DataTemplate.Triggers> </DataTemplate> @@ -486,7 +484,8 @@ <DataTemplate> <TextBlock x:Name="txtShortcutKey" HorizontalAlignment="Center" - VerticalAlignment="Center">Ctrl + A</TextBlock> + VerticalAlignment="Center" + Visibility="Collapsed">Ctrl + A</TextBlock> <DataTemplate.Triggers> <DataTrigger Binding="{Binding Converter={StaticResource ObjectToClassNameConverter}}" @@ -494,7 +493,7 @@ <Setter TargetName="txtShortcutKey" Property="Visibility" - Value="Collapsed"/> + Value="Visible"/> </DataTrigger> </DataTemplate.Triggers> </DataTemplate> Modified: branches/options/QTTabBar/OptionsDialog.xaml.cs =================================================================== --- branches/options/QTTabBar/OptionsDialog.xaml.cs 2011-10-20 20:33:32 UTC (rev 341) +++ branches/options/QTTabBar/OptionsDialog.xaml.cs 2011-10-20 21:47:39 UTC (rev 342) @@ -1476,6 +1476,18 @@ #region ---------- Binding Classes ---------- + private abstract class NotifyPropertyChanged : INotifyPropertyChanged { + public event PropertyChangedEventHandler PropertyChanged; + + protected virtual void OnPropertyChanged(string name) { + if(PropertyChanged == null) { + return; + } + + PropertyChanged(this, new PropertyChangedEventArgs(name)); + } + } + private class ButtonEntry { private OptionsDialog parent; @@ -1641,7 +1653,7 @@ } } - public class FileTypeEntry { + private class FileTypeEntry { public string DotExtension { get; private set; } public string Extension { get { @@ -1679,13 +1691,23 @@ } } - public class SeparatorEntry { + private class SeparatorEntry { public SeparatorEntry() { } } - public class FolderEntry { - public string Path { get; set; } + private class FolderEntry : NotifyPropertyChanged { + private string path; + + public string Path { + get { + return path; + } + set { + path = value; + OnPropertyChanged("Icon"); + } + } public string DisplayText { get { return QTUtility2.MakePathDisplayText(Path, true); @@ -1709,20 +1731,46 @@ } } - public class GroupEntry { + private class GroupEntry : NotifyPropertyChanged { public string Name { get; set; } public Image Icon { get { - return Resources_Image.icoEmpty.ToBitmap(); + if(Folders.Count == 0) { + return Resources_Image.icoEmpty.ToBitmap(); + } + else { + return Folders.First().Icon; + } } } public ObservableCollection<FolderEntry> Folders { get; private set; } public bool Startup { get; set; } public int ShortcutKey { get; set; } + private void Folders_CollectionChanged(object sender, System.Collections.Specialized.NotifyCollectionChangedEventArgs e) { + if(e.OldItems != null) { + foreach(FolderEntry child in e.OldItems) { + child.PropertyChanged -= new PropertyChangedEventHandler(FolderEntry_PropertyChanged); + } + } + if(e.NewItems != null) { + foreach(FolderEntry child in e.NewItems) { + child.PropertyChanged += new PropertyChangedEventHandler(FolderEntry_PropertyChanged); + } + } + OnPropertyChanged("Icon"); + } + + private void FolderEntry_PropertyChanged(object sender, PropertyChangedEventArgs e) { + if(Folders.Count > 0 && sender == Folders.First()) { + OnPropertyChanged("Icon"); + } + } + public GroupEntry(string name) { Name = name; Folders = new ObservableCollection<FolderEntry>(); + Folders.CollectionChanged += new System.Collections.Specialized.NotifyCollectionChangedEventHandler(Folders_CollectionChanged); } public GroupEntry() : this(null) { } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ka...@us...> - 2011-10-22 03:57:58
|
Revision: 344 http://qttabbar.svn.sourceforge.net/qttabbar/?rev=344&view=rev Author: kawanon Date: 2011-10-22 03:57:51 +0000 (Sat, 22 Oct 2011) Log Message: ----------- Fixed issue where margins of Group folders are different. Exposed some properties and methods of EditableHeader. Modified Paths: -------------- branches/options/QTTabBar/EditableHeader.xaml.cs branches/options/QTTabBar/OptionsDialog.xaml Modified: branches/options/QTTabBar/EditableHeader.xaml.cs =================================================================== --- branches/options/QTTabBar/EditableHeader.xaml.cs 2011-10-21 01:36:23 UTC (rev 343) +++ branches/options/QTTabBar/EditableHeader.xaml.cs 2011-10-22 03:57:51 UTC (rev 344) @@ -20,6 +20,7 @@ public partial class EditableHeader : UserControl { private bool preparing = false; + private string originalText; public string Text { get { return (string)GetValue(TextProperty); } @@ -31,13 +32,32 @@ set { SetValue(ContainerProperty, value); } } + public bool ReadOnly { + get { return (bool)GetValue(ReadOnlyProperty); } + set { SetValue(ReadOnlyProperty, value); } + } + + public bool CancelIfEmpty { + get { return (bool)GetValue(CancelIfEmptyProperty); } + set { SetValue(CancelIfEmptyProperty, value); } + } + public static readonly DependencyProperty TextProperty = DependencyProperty.Register("Text", typeof(string), typeof(EditableHeader), new FrameworkPropertyMetadata("New Header", FrameworkPropertyMetadataOptions.BindsTwoWayByDefault)); + public static readonly DependencyProperty ContainerProperty = DependencyProperty.Register("Container", typeof(UIElement), typeof(EditableHeader), new FrameworkPropertyMetadata(null)); + public static readonly DependencyProperty ReadOnlyProperty = + DependencyProperty.Register("ReadOnly", typeof(bool), typeof(EditableHeader), + new FrameworkPropertyMetadata(false)); + + public static readonly DependencyProperty CancelIfEmptyProperty = + DependencyProperty.Register("CancelIfEmpty", typeof(bool), typeof(EditableHeader), + new FrameworkPropertyMetadata(true)); + public EditableHeader(string initialName, TreeViewItem item = null) { InitializeComponent(); @@ -51,33 +71,52 @@ public EditableHeader() : this(null) { } - private void txtHeaderEdit_LostFocus(object sender, RoutedEventArgs e) { - //txtHeader.Text = txtHeaderEdit.Text; + public void EndEdit() { txtHeaderEdit.Visibility = Visibility.Hidden; + + BindingExpression expr = txtHeaderEdit.GetBindingExpression(TextBox.TextProperty); + expr.UpdateSource(); + + if(CancelIfEmpty && string.IsNullOrEmpty(Text)) { + Text = originalText; + } } + public void StartEdit() { + originalText = Text; + txtHeaderEdit.Visibility = Visibility.Visible; + txtHeaderEdit.CaptureMouse(); + txtHeaderEdit.Focus(); + txtHeaderEdit.ReleaseMouseCapture(); + } + + private void txtHeaderEdit_LostFocus(object sender, RoutedEventArgs e) { + EndEdit(); + } + private void txtHeaderEdit_KeyDown(object sender, KeyEventArgs e) { if(e.Key == Key.Enter) { - //txtHeader.Text = txtHeaderEdit.Text; - txtHeaderEdit.Visibility = Visibility.Hidden; + EndEdit(); } } private void txtHeader_MouseDown(object sender, MouseButtonEventArgs e) { + if(ReadOnly) { + // We can add a sound if you need to do so. + return; + } preparing = (Container != null) ? Container.IsFocused : true; } private void txtHeader_MouseUp(object sender, MouseButtonEventArgs e) { - // Does not open the text box if editable area has got focus by clicking right now. + // Does not open the text box if the editable area has got focus by clicking right now. if(!preparing) { return; } - txtHeaderEdit.Visibility = Visibility.Visible; - txtHeaderEdit.CaptureMouse(); - txtHeaderEdit.Focus(); - txtHeaderEdit.ReleaseMouseCapture(); + + StartEdit(); } } } Modified: branches/options/QTTabBar/OptionsDialog.xaml =================================================================== --- branches/options/QTTabBar/OptionsDialog.xaml 2011-10-21 01:36:23 UTC (rev 343) +++ branches/options/QTTabBar/OptionsDialog.xaml 2011-10-22 03:57:51 UTC (rev 344) @@ -387,10 +387,10 @@ Text="{Binding Path=Path}" Visibility="Collapsed" Container="{Binding RelativeSource={RelativeSource AncestorType={x:Type TreeViewItem}}}"/> - <TextBlock + <qt:EditableHeader x:Name="txtDisplayText" - Text="{Binding Path=DisplayText}" - VerticalAlignment="Center" + Text="{Binding Path=DisplayText, Mode=OneWay}" + ReadOnly="True" Visibility="Collapsed"/> </StackPanel> <Separator This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ka...@us...> - 2011-10-22 15:44:57
|
Revision: 345 http://qttabbar.svn.sourceforge.net/qttabbar/?rev=345&view=rev Author: kawanon Date: 2011-10-22 15:44:50 +0000 (Sat, 22 Oct 2011) Log Message: ----------- Changed newly added items to immediately go into rename mode. Modified Paths: -------------- branches/options/QTTabBar/EditableHeader.xaml branches/options/QTTabBar/OptionsDialog.xaml branches/options/QTTabBar/OptionsDialog.xaml.cs Modified: branches/options/QTTabBar/EditableHeader.xaml =================================================================== --- branches/options/QTTabBar/EditableHeader.xaml 2011-10-22 03:57:51 UTC (rev 344) +++ branches/options/QTTabBar/EditableHeader.xaml 2011-10-22 15:44:50 UTC (rev 345) @@ -21,7 +21,7 @@ </Border> <TextBox x:Name="txtHeaderEdit" Text="{Binding Path=Text, ElementName=EditableHeaderControl}" - Padding="0" + Padding="{Binding Path=Padding, ElementName=EditableHeaderControl}" VerticalContentAlignment="Center" MinWidth="10" LostFocus="txtHeaderEdit_LostFocus" Modified: branches/options/QTTabBar/OptionsDialog.xaml =================================================================== --- branches/options/QTTabBar/OptionsDialog.xaml 2011-10-22 03:57:51 UTC (rev 344) +++ branches/options/QTTabBar/OptionsDialog.xaml 2011-10-22 15:44:50 UTC (rev 345) @@ -301,14 +301,16 @@ Width="16" Height="16" Stretch="Fill"/> - <TextBlock + <qt:EditableHeader Text="{Binding Path=Extension}" - VerticalAlignment="Center" - Margin="4"/> + Padding="2,0" + Margin="0,2" + Container="{Binding RelativeSource={RelativeSource AncestorType={x:Type ListBoxItem}}}"/> <TextBlock Text="{Binding Path=FriendlyName}" VerticalAlignment="Center" - Foreground="DarkGray" FontSize="10" /> + Foreground="Gray" + FontSize="10" /> </StackPanel> </DataTemplate> <HierarchicalDataTemplate x:Key="GroupItemTemplate" ItemsSource="{Binding Path=Folders}"> Modified: branches/options/QTTabBar/OptionsDialog.xaml.cs =================================================================== --- branches/options/QTTabBar/OptionsDialog.xaml.cs 2011-10-22 03:57:51 UTC (rev 344) +++ branches/options/QTTabBar/OptionsDialog.xaml.cs 2011-10-22 15:44:50 UTC (rev 345) @@ -512,6 +512,9 @@ control.SelectedItem = item; control.ScrollIntoView(item); control.Focus(); + + EnsureGenerated(control, + () => EditLabel((ListBoxItem)FindItemContainer(control, item))); } private void FillFileTypes(ICollection<FileTypeEntry> fileTypes, string[] newValues) { @@ -993,18 +996,34 @@ } } - private object FindItemContainer(ItemsControl parent, object childItem) { + public static DependencyObject FindVisualChildByName(DependencyObject parent, string name) { + for(int i = 0; i < VisualTreeHelper.GetChildrenCount(parent); i++) { + DependencyObject child = VisualTreeHelper.GetChild(parent, i); + string controlName = child.GetValue(System.Windows.Controls.Control.NameProperty) as string; + if(controlName == name) { + return child; + } + else { + DependencyObject result = FindVisualChildByName(child, name); + if(result != null) + return result; + } + } + return null; + } + + private UIElement FindItemContainer(ItemsControl parent, object childItem) { if(parent.ItemContainerGenerator.Status != GeneratorStatus.ContainersGenerated) { return null; } - object container = parent.ItemContainerGenerator.ContainerFromItem(childItem); + UIElement container = (UIElement)parent.ItemContainerGenerator.ContainerFromItem(childItem); if(container != null) { return container; } foreach(object item in parent.Items) { ItemsControl child = parent.ItemContainerGenerator.ContainerFromItem(item) as ItemsControl; if(child != null && child.Items.Count > 0) { - object result = FindItemContainer(child, childItem); + UIElement result = FindItemContainer(child, childItem); if(result != null) { return result; } @@ -1069,6 +1088,42 @@ } } + private void EditLabel(FrameworkElement container) { + Action pred = delegate + { + // We'd rather call by "txtName". + EditableHeader edit = FindVisualChildByName(container, "EditableHeaderControl") as EditableHeader; + if(edit == null || edit.Visibility != Visibility.Visible) { + return; + } + edit.StartEdit(); + }; + if(container.IsLoaded) { + pred(); + } + else { + container.Loaded += delegate { pred(); }; + } + } + + private void EnsureGenerated(ItemsControl control, Action pred) { + ItemContainerGenerator gen = control.ItemContainerGenerator; + if(gen.Status == GeneratorStatus.ContainersGenerated) { + pred(); + return; + } + EventHandler handler = delegate { }; + handler = delegate + { + if(gen.Status != GeneratorStatus.ContainersGenerated) { + return; + } + pred(); + gen.StatusChanged -= handler; + }; + gen.StatusChanged += handler; + } + private int GetPreferredInsertionIndex(TreeView tvw) { object val = tvw.SelectedItem; if(val == null) { @@ -1088,8 +1143,12 @@ GetPreferredInsertionIndex(tvw), item); - TreeViewItem container = (TreeViewItem)FindItemContainer(tvw, item); - container.IsSelected = true; + EnsureGenerated(tvw, delegate + { + TreeViewItem container = (TreeViewItem)FindItemContainer(tvw, item); + container.IsSelected = true; + EditLabel(container); + }); } private void btnGroupsMoveNodeUp_Click(object sender, RoutedEventArgs e) { @@ -1137,12 +1196,15 @@ } FolderEntry folder = new FolderEntry(dlg.SelectedPath); group.Folders.Insert(index, folder); - // TODO: Doesn't work. item would be null. - //TreeViewItem item = FindContainerTreeViewItem(tvwGroups, folder); - //item.IsSelected = true; - TreeViewItem parent2 = (TreeViewItem)FindItemContainer(tvwGroups, val); - parent2.IsExpanded = true; + TreeViewItem parent = (TreeViewItem)FindItemContainer(tvwGroups, group); + parent.IsExpanded = true; + + EnsureGenerated(parent, delegate + { + TreeViewItem container = (TreeViewItem)FindItemContainer(tvwGroups, folder); + container.IsSelected = true; + }); } private void btnGroupsRemoveNode_Click(object sender, RoutedEventArgs e) { @@ -1653,16 +1715,33 @@ } } - private class FileTypeEntry { - public string DotExtension { get; private set; } + private class FileTypeEntry : NotifyPropertyChanged { + private string extension; + public string Extension { get { - return DotExtension.Substring(1); + return extension; } + set { + extension = value; + OnPropertyChanged("FriendlyName"); + OnPropertyChanged("Icon"); + } } + public string DotExtension { + get { + return "." + Extension; + } + set { + if(!value.StartsWith(".")) { + throw new ArgumentException(); + } + Extension = value.Substring(1); + } + } public string FriendlyName { get { - // PENDING: Instead of GetFileType or something. + // PENDING: Instead of something like GetFileType. SHFILEINFO psfi = new SHFILEINFO(); int sz = System.Runtime.InteropServices.Marshal.SizeOf(psfi); @@ -1688,6 +1767,7 @@ DotExtension = extension; } public FileTypeEntry() { + DotExtension = "."; } } @@ -1797,9 +1877,6 @@ //# But, without this we must interact with the TextBox in some way before the OK button saves it. workingConfig.bbar.ImageStripPath = ""; } - - - } #region ---------- Converters ---------- This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <mas...@us...> - 2011-11-14 23:18:18
|
Revision: 347 http://qttabbar.svn.sourceforge.net/qttabbar/?rev=347&view=rev Author: masamunexgp Date: 2011-11-14 23:18:11 +0000 (Mon, 14 Nov 2011) Log Message: ----------- Created MarginCombo control, started work on Appearance tab. Modified Paths: -------------- branches/options/QTTabBar/Config.cs branches/options/QTTabBar/OptionsDialog.xaml branches/options/QTTabBar/QTTabBar.csproj Added Paths: ----------- branches/options/QTTabBar/MarginCombo.xaml branches/options/QTTabBar/MarginCombo.xaml.cs Modified: branches/options/QTTabBar/Config.cs =================================================================== --- branches/options/QTTabBar/Config.cs 2011-10-22 17:01:58 UTC (rev 346) +++ branches/options/QTTabBar/Config.cs 2011-11-14 23:18:11 UTC (rev 347) @@ -350,8 +350,8 @@ public class _Skin { public bool UseTabSkin { get; set; } public string TabImageFile { get; set; } - public Rectangle TabSizeMargin { get; set; } - public Rectangle TabContentMargin { get; set; } + public Margin TabSizeMargin { get; set; } + public Margin TabContentMargin { get; set; } public int OverlapPixels { get; set; } public bool HitTestTransparent { get; set; } public int TabHeight { get; set; } @@ -373,14 +373,14 @@ public StretchMode RebarStretchMode { get; set; } public string RebarImageFile { get; set; } public bool RebarImageSeperateBars { get; set; } - public Rectangle RebarSizeMargin { get; set; } + public Margin RebarSizeMargin { get; set; } public bool ActiveTabInBold { get; set; } public _Skin() { UseTabSkin = false; TabImageFile = ""; - TabSizeMargin = new Rectangle(0, 0, 0, 0); - TabContentMargin = new Rectangle(0, 0, 0, 0); + TabSizeMargin = new Margin(); + TabContentMargin = new Margin(); OverlapPixels = 0; HitTestTransparent = false; TabHeight = 24; @@ -401,7 +401,7 @@ RebarStretchMode = StretchMode.Full; RebarImageFile = ""; RebarImageSeperateBars = false; - RebarSizeMargin = new Rectangle(0, 0, 0, 0); + RebarSizeMargin = new Margin(); ActiveTabInBold = false; } } Added: branches/options/QTTabBar/MarginCombo.xaml =================================================================== --- branches/options/QTTabBar/MarginCombo.xaml (rev 0) +++ branches/options/QTTabBar/MarginCombo.xaml 2011-11-14 23:18:11 UTC (rev 347) @@ -0,0 +1,62 @@ +<UserControl x:Class="QTTabBarLib.MarginCombo" + xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" + xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" + xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" + xmlns:d="http://schemas.microsoft.com/expression/blend/2008" + xmlns:theme="clr-namespace:Microsoft.Windows.Themes;assembly=PresentationFramework.Aero" + mc:Ignorable="d" + x:Name="MarginComboControl" + Height="22"> + <Grid + Height="{Binding Path=Height, ElementName=MarginComboControl}" + Width="{Binding Path=Width, ElementName=MarginComboControl}"> + <TextBox x:Name="txtMargin" + Padding="0, 0, 20, 0" + PreviewTextInput="txtMargin_PreviewTextInput" + TextChanged="txtMargin_TextChanged"/> + <ToggleButton + Content="▼" + HorizontalAlignment="Right" + IsChecked="{Binding ElementName=MyPopup, Path=IsOpen}" + Width="28"> + <ToggleButton.Resources> + <ScaleTransform x:Key="FontStretchExpanded" ScaleX="0.8" ScaleY="0.55" /> + <Style TargetType="theme:ButtonChrome"> + <Setter Property="RoundCorners" Value="False" /> + </Style> + <Style TargetType="ToggleButton"> + <Style.Setters> + <Setter Property="LayoutTransform" Value="{StaticResource FontStretchExpanded}" /> + </Style.Setters> + </Style> + </ToggleButton.Resources> + </ToggleButton> + <Popup x:Name="MyPopup" StaysOpen="False" > + <Border BorderThickness="1" Padding="5" Background="White"> + <Grid> + <Grid.ColumnDefinitions> + <ColumnDefinition/> + <ColumnDefinition/> + </Grid.ColumnDefinitions> + <Grid.RowDefinitions> + <RowDefinition/> + <RowDefinition/> + <RowDefinition/> + <RowDefinition/> + <RowDefinition/> + </Grid.RowDefinitions> + <Label Content="All" Grid.Row="0" Padding="0" Margin="05,0,10,0"/> + <Label Content="Left" Grid.Row="1" Padding="0" Margin="15,0,10,0"/> + <Label Content="Top" Grid.Row="2" Padding="0" Margin="15,0,10,0"/> + <Label Content="Right" Grid.Row="3" Padding="0" Margin="15,0,10,0"/> + <Label Content="Bottom" Grid.Row="4" Padding="0" Margin="15,0,10,0"/> + <TextBox x:Name="txtAll" Grid.Row="0" Grid.Column="1" Width="50" PreviewTextInput="txtLTRB_PreviewTextInput" TextChanged="txtLTRB_TextChanged"/> + <TextBox x:Name="txtLeft" Grid.Row="1" Grid.Column="1" Width="50" PreviewTextInput="txtLTRB_PreviewTextInput" TextChanged="txtLTRB_TextChanged" /> + <TextBox x:Name="txtTop" Grid.Row="2" Grid.Column="1" Width="50" PreviewTextInput="txtLTRB_PreviewTextInput" TextChanged="txtLTRB_TextChanged" /> + <TextBox x:Name="txtRight" Grid.Row="3" Grid.Column="1" Width="50" PreviewTextInput="txtLTRB_PreviewTextInput" TextChanged="txtLTRB_TextChanged" /> + <TextBox x:Name="txtBottom" Grid.Row="4" Grid.Column="1" Width="50" PreviewTextInput="txtLTRB_PreviewTextInput" TextChanged="txtLTRB_TextChanged" /> + </Grid> + </Border> + </Popup> + </Grid> +</UserControl> Added: branches/options/QTTabBar/MarginCombo.xaml.cs =================================================================== --- branches/options/QTTabBar/MarginCombo.xaml.cs (rev 0) +++ branches/options/QTTabBar/MarginCombo.xaml.cs 2011-11-14 23:18:11 UTC (rev 347) @@ -0,0 +1,188 @@ +using System; +using System.Globalization; +using System.Linq; +using System.Windows; +using System.Windows.Controls; +using System.Windows.Data; +using System.Windows.Input; + +namespace QTTabBarLib { + + // It *really* pisses me off that I can't use the Thickness class instead. + // The WPF devs forgot to mark it as Serializable! + [Serializable] + public struct Margin { + public int Left { get; set; } + public int Top { get; set; } + public int Right { get; set; } + public int Bottom { get; set; } + + public Margin(int left, int top, int right, int bottom) : this() { + Left = left; + Top = top; + Right = right; + Bottom = bottom; + } + } + + /// <summary> + /// Interaction logic for MarginCombo.xaml + /// </summary> + public partial class MarginCombo : UserControl { + private const int VAL_MAX = 99; + + public MarginCombo() { + InitializeComponent(); + + // Set bindings (so much easier doing it here than in xaml...) + var boxes = new TextBox[] {txtLeft, txtTop, txtRight, txtBottom}; + for(int i = 0; i < 4; i++) { + boxes[i].SetBinding(TextBox.TextProperty, new Binding("Value") { + Source = this, + Converter = new SingleTextConverter(i, this), + UpdateSourceTrigger = UpdateSourceTrigger.PropertyChanged + }); + } + + txtMargin.SetBinding(TextBox.TextProperty, new Binding("Value") { + Source = this, + Converter = new JoinedTextConverter(), + UpdateSourceTrigger = UpdateSourceTrigger.PropertyChanged + }); + + txtAll.SetBinding(TextBox.TextProperty, new MultiBinding { + Converter = new CommonMultiConverter(), + UpdateSourceTrigger = UpdateSourceTrigger.PropertyChanged, + Bindings = { + new Binding("Text") { Source = txtLeft }, + new Binding("Text") { Source = txtTop }, + new Binding("Text") { Source = txtRight }, + new Binding("Text") { Source = txtBottom }, + } + }); + } + + public static readonly DependencyProperty ValueProperty = DependencyProperty.Register("Value", + typeof(Margin), typeof(MarginCombo), new FrameworkPropertyMetadata(new Margin(), + FrameworkPropertyMetadataOptions.BindsTwoWayByDefault)); + + public Margin Value { + get { + return (Margin)GetValue(ValueProperty); + } + set { + SetValue(ValueProperty, value); + } + } + + #region Event Handlers + + //# The converter will do the validation for us. + private void txtMargin_TextChanged(object sender, RoutedEventArgs e) { + TextBox box = ((TextBox)sender); + int pos = box.CaretIndex; + BindingExpression bind = box.GetBindingExpression(TextBox.TextProperty); + if(bind != null) { + bind.UpdateTarget(); + box.CaretIndex = pos; + } + } + + //# Make sure the text stays numeric and in range.Z + private void txtLTRB_TextChanged(object sender, RoutedEventArgs e) { + int i; + TextBox box = ((TextBox)sender); + int pos = box.CaretIndex; + BindingExpression bind = box.GetBindingExpression(TextBox.TextProperty); + if(box.Text.Length == 0) return; + if(!int.TryParse(box.Text, out i)) { + if(bind != null) bind.UpdateTarget(); + } + else if(i > VAL_MAX) { + box.Text = VAL_MAX.ToString(); + box.CaretIndex = pos; + } + else if(i < 0) { + box.Text = "0"; + box.CaretIndex = pos; + } + } + + //# Allow only digits to be entered. We still need TextChanged to + //# make sure letters don't get in via pasting, drag & drop, etc. + private void txtMargin_PreviewTextInput(object sender, TextCompositionEventArgs e) { + e.Handled = !e.Text.ToCharArray().All(c => char.IsDigit(c) || c == ' ' || c == ','); + } + + private void txtLTRB_PreviewTextInput(object sender, TextCompositionEventArgs e) { + e.Handled = !e.Text.ToCharArray().All(char.IsDigit); + } + #endregion + + #region Converters + + [ValueConversion(typeof(Margin), typeof(string))] + private class JoinedTextConverter : IValueConverter { + public object Convert(object value, Type targetType, object parameter, CultureInfo culture) { + Margin t = (Margin)value; + return t.Left + ", " + t.Top + ", " + t.Right + ", " + t.Bottom; + } + + public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture) { + int i; + int[] v = value.ToString().Split(',').Select( + s => int.TryParse(s.Trim(), out i) ? Math.Min(Math.Max(i, 0), VAL_MAX) : 0).ToArray(); + Array.Resize(ref v, 4); + return new Margin(v[0], v[1], v[2], v[3]); + } + } + + [ValueConversion(typeof(Margin), typeof(string))] + private class SingleTextConverter : IValueConverter { + private int idx; + private MarginCombo parent; + + public SingleTextConverter(int idx, MarginCombo parent) { + this.idx = idx; + this.parent = parent; + } + + public object Convert(object value, Type targetType, object parameter, CultureInfo culture) { + switch(idx) { + case 0: return ((Margin)value).Left.ToString(); + case 1: return ((Margin)value).Top.ToString(); + case 2: return ((Margin)value).Right.ToString(); + default: return ((Margin)value).Bottom.ToString(); + } + } + + public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture) { + int i; + if(!int.TryParse(value.ToString().Trim(), out i) || i < 0 || i > VAL_MAX) return Binding.DoNothing; + Margin current = parent.Value; + switch(idx) { + case 0: current.Left = i; break; + case 1: current.Top = i; break; + case 2: current.Right = i; break; + default: current.Bottom = i; break; + } + return current; + } + } + + private class CommonMultiConverter : IMultiValueConverter { + public object Convert(object[] values, Type targetType, object parameter, CultureInfo culture) { + return values.All(o => o.Equals(values[0])) ? values[0] : ""; + } + + public object[] ConvertBack(object value, Type[] targetTypes, object parameter, CultureInfo culture) { + int i; + return Enumerable.Repeat( + int.TryParse(value.ToString().Trim(), out i) && i >= 0 ? i.ToString() : Binding.DoNothing, + targetTypes.Length).ToArray(); + } + } + + #endregion + } +} Modified: branches/options/QTTabBar/OptionsDialog.xaml =================================================================== --- branches/options/QTTabBar/OptionsDialog.xaml 2011-10-22 17:01:58 UTC (rev 346) +++ branches/options/QTTabBar/OptionsDialog.xaml 2011-11-14 23:18:11 UTC (rev 347) @@ -1509,7 +1509,6 @@ <ColumnDefinition Width="Auto"/> <ColumnDefinition Width="Auto"/> <ColumnDefinition Width="*"/> - <ColumnDefinition Width="Auto"/> </Grid.ColumnDefinitions> <Grid.RowDefinitions> <RowDefinition Height="Auto"/> @@ -1522,27 +1521,23 @@ Height="16" IsChecked="{Binding Path=UseTabSkin}" Margin="0,0,5,0"/> - <TextBox + <qt:FileFolderEntryBox + Folder="False" Grid.Column="1" Grid.ColumnSpan="3" Margin="5,1"/> - <Button - Content="..." - Grid.Column="4" - Margin="5,1" - Width="26"/> <Label Content="Sizing margins:" Grid.Row="1" Height="16" Margin="18,0,5,0" Padding="0"/> - <ComboBox + <qt:MarginCombo Grid.Column="1" Grid.Row="1" HorizontalAlignment="Left" - IsEditable="True" Margin="5,1" + Value="{Binding Path=TabSizeMargin}" Width="120"/> <Label Content="Overlap area:" @@ -1551,11 +1546,12 @@ Height="16" Margin="18,0,5,0" Padding="0"/> - <TextBox + <qt:Spinner Grid.Column="3" Grid.Row="1" HorizontalAlignment="Left" Margin="5,1" + Value="{Binding Path=OverlapPixels}" Width="80"/> <Label Content="Content margins:" @@ -1563,12 +1559,11 @@ Height="16" Margin="18,0,5,0" Padding="0"/> - <ComboBox + <qt:MarginCombo Grid.Column="1" Grid.Row="2" - HorizontalAlignment="Left" - IsEditable="True" Margin="5,1" + Value="{Binding Path=TabContentMargin}" Width="120"/> <CheckBox x:Name="chkHitTestTransparent" Content="Hit test transparent areas" @@ -1605,23 +1600,26 @@ Orientation="Horizontal"> <qt:Spinner Min="0" - Max="100"/> + Max="100" + Value="{Binding Path=TabHeight}"/> <Label Content="Min Width:" Height="16" Margin="18,0,5,0" Padding="0"/> <qt:Spinner - Min="0" - Max="100"/> + Min="10" + Max="200" + Value="{Binding Path=TabMinWidth}"/> <Label Content="Max Width:" Height="16" Margin="18,0,5,0" Padding="0"/> <qt:Spinner - Min="0" - Max="100"/> + Min="10" + Max="200" + Value="{Binding Path=TabMaxWith}"/> </StackPanel> <Label Content="Sizing mode:" @@ -1637,10 +1635,12 @@ <qt:RadioButtonEx Content="Full width" Height="16" + IsChecked="{Binding Path=FixedWidthTabs, Converter={StaticResource BoolInverterConverter}}" Margin="0,0,20,0"/> <qt:RadioButtonEx Content="Same size" Height="16" + IsChecked="{Binding Path=FixedWidthTabs}" Margin="0,0,10,0"/> </StackPanel> </Grid> @@ -1652,115 +1652,47 @@ <Grid.RowDefinitions> <RowDefinition Height="Auto"/> <RowDefinition Height="Auto"/> - <RowDefinition Height="Auto"/> - <RowDefinition Height="Auto"/> </Grid.RowDefinitions> <Grid.ColumnDefinitions> <ColumnDefinition Width="Auto"/> <ColumnDefinition Width="Auto"/> <ColumnDefinition Width="Auto"/> - <ColumnDefinition Width="Auto"/> </Grid.ColumnDefinitions> - <Label - Content="Font:" - Height="16" - Margin="0,3,8,3" - Padding="0"/> - <Label - Content="Text Color" - Grid.Row="1" - Height="16" - Margin="0,3,8,3" - Padding="0"/> - <Label - Content="Alignment:" - Grid.Row="3" - Height="23" - Margin="0,3,8,3" - Padding="0" - VerticalAlignment="Center" - VerticalContentAlignment="Center"/> <Button - Content="Active" - Grid.Column="1" - Grid.Row="1" + Content="Choose Text Colors ▼" Height="23" - HorizontalAlignment="Left" - Margin="3" - VerticalAlignment="Bottom" - Width="75"/> + Margin="0, 0, 20, 10" + Width="140" + VerticalAlignment="Center"/> <Button - Content="Mouseover" - Grid.Column="3" - Grid.Row="1" - Height="23" - HorizontalAlignment="Left" - Margin="3" - VerticalAlignment="Bottom" - Width="75"/> - <Button - Content="Inactive" - Grid.Column="2" - Grid.Row="1" - Height="23" - HorizontalAlignment="Left" - Margin="3" - VerticalAlignment="Bottom" - Width="75"/> - <Button - Content="Mouseover" - Grid.Column="3" - Grid.Row="2" - Height="23" - HorizontalAlignment="Left" - Margin="3" - VerticalAlignment="Bottom" - Width="75"/> - <Button - Content="Inactive" - Grid.Column="2" - Grid.Row="2" - Height="23" - HorizontalAlignment="Left" - Margin="3" - VerticalAlignment="Bottom" - Width="75"/> - <Button - Content="Active" + Content="Choose Text Font..." Grid.Column="1" - Grid.Row="2" Height="23" - HorizontalAlignment="Left" - Margin="3" - VerticalAlignment="Bottom" - Width="75"/> - <Button - Content="Microsoft Sans Serif, 8.25pt" - Grid.Column="1" - Grid.ColumnSpan="3" - Height="23" - HorizontalAlignment="Left" - Margin="3" - VerticalAlignment="Bottom" - Width="237"/> + Margin="0, 0, 20, 10" + Width="140" + VerticalAlignment="Center"/> <qt:RadioButtonEx x:Name="radTabTextCenteredNo" - Content="Left" - Grid.Column="1" - Grid.Row="3" + Content="Left Aligned" + Grid.Column="2" + Grid.Row="0" Height="16" - IsChecked="{Binding Path=TabTextCentered, Converter={StaticResource BoolInverterConverter}}"/> + IsChecked="{Binding Path=TabTextCentered, Converter={StaticResource BoolInverterConverter}}" + VerticalAlignment="Center"/> <qt:RadioButtonEx x:Name="radTabTextCenteredYes" - Content="Center" + Content="Center Aligned" Grid.Column="2" - Grid.Row="3" + Grid.Row="1" Height="16" - IsChecked="{Binding Path=TabTextCentered}"/> + IsChecked="{Binding Path=TabTextCentered}" + VerticalAlignment="Center"/> <CheckBox x:Name="chkTabTitleShadows" - Content="Text Shadow:" - Grid.Row="2" + Content="Text Drop Shadow" + Grid.Row="1" + Grid.Column="1" Height="16" + HorizontalAlignment="Left" IsChecked="{Binding Path=TabTitleShadows}" - Margin="0,3,8,3"/> + VerticalAlignment="Center"/> </Grid> <Label Content="Toolbar Background" @@ -1771,77 +1703,68 @@ <RowDefinition Height="Auto"/> <RowDefinition Height="Auto"/> <RowDefinition Height="Auto"/> - <RowDefinition Height="Auto"/> </Grid.RowDefinitions> <Grid.ColumnDefinitions> <ColumnDefinition Width="Auto"/> - <ColumnDefinition Width="274*"/> + <ColumnDefinition Width="*"/> <ColumnDefinition Width="Auto"/> + <ColumnDefinition Width="*"/> </Grid.ColumnDefinitions> - <CheckBox x:Name="chkUseRebarBGColor" - Content="Solid color" - Height="16" - IsChecked="{Binding Path=UseRebarBGColor}" - Margin="0,0,10,0"/> <CheckBox Content="Image" + Height="16" + Margin="0,0,15,0" + IsChecked="{Binding Path=UseRebarImage}"/> + <qt:FileFolderEntryBox + Grid.Column="1" + Grid.ColumnSpan="3" + Margin="0,2"/> + <CheckBox x:Name="chkUseRebarBGColor" + Content="Solid color" Grid.Row="1" Height="16" - Margin="0,0,10,0"/> + IsChecked="{Binding Path=UseRebarBGColor}" + Margin="0,0,15,0"/> <Button Content="Choose" Grid.Column="1" + Grid.Row="1" Height="23" HorizontalAlignment="Left" - Margin="4,2,0,2" + Margin="0,2" Width="75"/> + <CheckBox + Content="Image each bar seperately" + Grid.Row="2" + Grid.ColumnSpan="2" + Height="16" + IsChecked="{Binding Path=RebarImageSeperateBars}" + Margin="0,0,15,0"/> <Label Content="Stretch mode:" - Grid.Row="2" + Grid.Column="2" + Grid.Row="1" Height="16" - Margin="0,0,10,0" + Margin="0,0,15,0" Padding="0"/> + <ComboBox + Grid.Column="3" + Grid.Row="1" + Height="23" + HorizontalAlignment="Stretch"/> <Label Content="Sizing margins:" - Grid.Row="3" + Grid.Column="2" + Grid.Row="2" Height="16" - Margin="0,0,10,0" + Margin="0,0,15,0" Padding="0"/> - <StackPanel - Grid.Column="1" - Grid.ColumnSpan="2" + <qt:MarginCombo + Grid.Column="3" Grid.Row="2" - Height="27" - HorizontalAlignment="Stretch" - Margin="2,2,11,2" - Orientation="Horizontal"> - <ComboBox - Height="23" - Width="150"/> - <CheckBox - Content="Image each bar" - Height="16" - Margin="20,0,0,0" - Padding="4,0,0,0"/> - </StackPanel> - <ComboBox - Grid.Column="1" - Grid.Row="3" Height="23" - HorizontalAlignment="Left" - IsEditable="True" - Margin="2,2,0,2" - Width="150"/> - <Button - Content="..." - Grid.Column="2" - Grid.Row="1" - Margin="8,2" - Width="26"/> - <TextBox - Grid.Column="1" - Grid.Row="1" - Margin="2"/> + HorizontalAlignment="Stretch" + Value="{Binding Path=RebarSizeMargin}"/> </Grid> </StackPanel> </ScrollViewer> Modified: branches/options/QTTabBar/QTTabBar.csproj =================================================================== --- branches/options/QTTabBar/QTTabBar.csproj 2011-10-22 17:01:58 UTC (rev 346) +++ branches/options/QTTabBar/QTTabBar.csproj 2011-11-14 23:18:11 UTC (rev 347) @@ -77,6 +77,7 @@ <ItemGroup> <Reference Include="PresentationCore" /> <Reference Include="PresentationFramework" /> + <Reference Include="PresentationFramework.Aero" /> <Reference Include="System" /> <Reference Include="System.Core, Version=3.5.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089, processorArchitecture=MSIL"> <SpecificVersion>False</SpecificVersion> @@ -120,6 +121,9 @@ <Compile Include="Interop\ShellConstants.cs" /> <Compile Include="Interop\TBBUTTON.cs" /> <Compile Include="Interop\TBBUTTONINFO.cs" /> + <Compile Include="MarginCombo.xaml.cs"> + <DependentUpon>MarginCombo.xaml</DependentUpon> + </Compile> <Compile Include="OptionsDialog.xaml.cs"> <DependentUpon>OptionsDialog.xaml</DependentUpon> </Compile> @@ -414,6 +418,10 @@ <SubType>Designer</SubType> <Generator>MSBuild:Compile</Generator> </Page> + <Page Include="MarginCombo.xaml"> + <SubType>Designer</SubType> + <Generator>MSBuild:Compile</Generator> + </Page> <Page Include="OptionsDialog.xaml"> <SubType>Designer</SubType> <Generator>MSBuild:Compile</Generator> This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <mas...@us...> - 2011-11-16 23:36:39
|
Revision: 348 http://qttabbar.svn.sourceforge.net/qttabbar/?rev=348&view=rev Author: masamunexgp Date: 2011-11-16 23:36:32 +0000 (Wed, 16 Nov 2011) Log Message: ----------- Finished up FileFolderEntryBox. Figured out how to make SelectedIDL into a bindable DependencyProperty. Added relevant bindings in OptionsDialog. Modified Paths: -------------- branches/options/QTTabBar/FileFolderEntryBox.xaml branches/options/QTTabBar/FileFolderEntryBox.xaml.cs branches/options/QTTabBar/OptionsDialog.xaml Modified: branches/options/QTTabBar/FileFolderEntryBox.xaml =================================================================== --- branches/options/QTTabBar/FileFolderEntryBox.xaml 2011-11-14 23:18:11 UTC (rev 347) +++ branches/options/QTTabBar/FileFolderEntryBox.xaml 2011-11-16 23:36:32 UTC (rev 348) @@ -11,12 +11,12 @@ Width="{Binding Path=Width, ElementName=FileFolderEntryBoxControl}"> <Button x:Name="btnBrowse" Content="..." - Margin="8,2" + Margin="8, 1, 0, 1" Width="26" DockPanel.Dock="Right" Click="btnBrowse_Click" /> <Grid> <TextBox x:Name="txtLocation" x:FieldModifier="private" - Padding="22,2,0,0" + Padding="22,1,0,0" VerticalContentAlignment="Center" GotKeyboardFocus="txtLocation_GotKeyboardFocus" LostKeyboardFocus="txtLocation_LostKeyboardFocus" Modified: branches/options/QTTabBar/FileFolderEntryBox.xaml.cs =================================================================== --- branches/options/QTTabBar/FileFolderEntryBox.xaml.cs 2011-11-14 23:18:11 UTC (rev 347) +++ branches/options/QTTabBar/FileFolderEntryBox.xaml.cs 2011-11-16 23:36:32 UTC (rev 348) @@ -1,4 +1,7 @@ -using System.Windows.Controls; +using System.Collections.Generic; +using System.Linq; +using System.Windows.Controls; +using System.Windows.Data; using System.Windows.Media; using System.Windows.Forms; using UserControl = System.Windows.Controls.UserControl; @@ -10,32 +13,87 @@ /// Interaction logic for FileFolderEntryBox.xaml /// </summary> public partial class FileFolderEntryBox : UserControl { - private byte[] location = null; private bool file = true; private bool watermarkVisible = true; private string watermarkText = null; private bool showIcon = true; private bool updating = false; + private bool lockText = false; + public static readonly DependencyProperty SelectedPathProperty = + DependencyProperty.Register("SelectedPath", typeof(string), typeof(FileFolderEntryBox), + new FrameworkPropertyMetadata(string.Empty, FrameworkPropertyMetadataOptions.BindsTwoWayByDefault, + OnSelectedPathChanged)); + + // Apparently .NET 4 does support using an array type for a DependencyProperty, + // but using IEnumerable works just as well and allows us to stay on .NET 3.5. + // We can still bind this to a byte[], and that's what matters. + public static readonly DependencyProperty SelectedIDLProperty = + DependencyProperty.Register("SelectedIDL", typeof(IEnumerable<byte>), typeof(FileFolderEntryBox), + new FrameworkPropertyMetadata(null, FrameworkPropertyMetadataOptions.BindsTwoWayByDefault, + OnSelectedIDLChanged)); + public string SelectedPath { - get { - return (string)GetValue(SelectedPathProperty); - } + get { return (string)GetValue(SelectedPathProperty); } + set { SetValue(SelectedPathProperty, value); } + } + + public IEnumerable<byte> SelectedIDL { + get { return (IEnumerable<byte>)GetValue(SelectedIDLProperty); } set { - using(IDLWrapper wrapper = new IDLWrapper(value)) { - SetLocation(wrapper); - } + SetValue(SelectedIDLProperty, value == null + ? null + : value as byte[] ?? value.ToArray()); } } - public byte[] SelectedIDL { - get { - return location; + + private static object OnCoerceSelectedIDL(DependencyObject d, object baseValue) { + var box = (FileFolderEntryBox)d; + using(IDLWrapper wrapper = new IDLWrapper(box.SelectedPath)) { + return wrapper.IDL; } - set { - location = value; + } + + private static void OnSelectedIDLChanged(DependencyObject d, DependencyPropertyChangedEventArgs e) { + FileFolderEntryBox box = (FileFolderEntryBox)d; + if(box.updating) return; + string newPath = ""; + if(box.SelectedIDL != null) { + IEnumerable<byte> eidl = (IEnumerable<byte>)e.NewValue; + using(IDLWrapper wrapper = new IDLWrapper(eidl as byte[] ?? eidl.ToArray())) { + newPath = wrapper.Path; + } } + + box.updating = true; + box.SelectedPath = newPath; + box.updating = false; + box.Update(); } + private static void OnSelectedPathChanged(DependencyObject d, DependencyPropertyChangedEventArgs e) { + FileFolderEntryBox box = (FileFolderEntryBox)d; + if(box.updating) return; + using(IDLWrapper newIDL = new IDLWrapper((string)e.NewValue)) { + IEnumerable<byte> eidl = box.SelectedIDL; + if(eidl == null) { + box.updating = true; + } + else { + using(IDLWrapper oldIDL = new IDLWrapper(eidl as byte[] ?? eidl.ToArray())) { + // Don't change the IDL if current one has the same path. + box.updating = (oldIDL.Path != newIDL.Path); + } + } + + if(box.updating) { + box.SelectedIDL = newIDL.IDL; + box.updating = false; + } + } + box.Update(); + } + // PENDING: the "!File" expression does not explicitly mean using the folder chooser, // so I think the class should have both of them public bool File { @@ -47,9 +105,10 @@ return; } file = value; - ClearLocation(); + Update(); } } + public bool Folder { get { return !File; @@ -80,39 +139,23 @@ set { watermarkText = value; if(watermarkVisible) { - ClearLocation(); + Update(); } } } - public static readonly DependencyProperty SelectedPathProperty = - DependencyProperty.Register("SelectedPath", typeof(string), typeof(FileFolderEntryBox), - new FrameworkPropertyMetadata(string.Empty, FrameworkPropertyMetadataOptions.BindsTwoWayByDefault, - OnSelectedPathChanged)); - public FileFolderEntryBox() { InitializeComponent(); - - ClearLocation(); + ShowIcon = false; + Update(); } - private static void OnSelectedPathChanged(DependencyObject d, DependencyPropertyChangedEventArgs e) { - FileFolderEntryBox this_ = (FileFolderEntryBox)d; - if(this_.updating) { - return; - } - using(IDLWrapper wrapper = new IDLWrapper((string)e.NewValue)) { - this_.SetLocation(wrapper); - } - } - // In any case, we must use this method instead of txtLocation.Text - private void SetSelectedPath(string path, string displayName) { + private void SetTextboxText(string text) { updating = true; - - SetValue(SelectedPathProperty, path); - txtLocation.Text = displayName; - + int pos = txtLocation.CaretIndex; + txtLocation.Text = text; + txtLocation.CaretIndex = pos; updating = false; } @@ -145,60 +188,61 @@ string text; if(b) { // TODO: Localize this - text = (WatermarkText != null) - ? WatermarkText : string.Format("Choose your {0}", File ? "file" : "folder"); + text = WatermarkText ?? string.Format("Choose your {0}", File ? "file" : "folder"); } else { text = string.Empty; } - SetSelectedPath(string.Empty, text); + SetTextboxText(text); } - private void ClearLocation() { - if(!txtLocation.IsFocused) { - ShowWatermark(true); - } - imgIcon.Source = null; - location = null; - } - - private void SetLocation(IDLWrapper wrapper) { - if(string.IsNullOrEmpty(wrapper.Path)) { - ClearLocation(); + private void Update() { + if(string.IsNullOrEmpty(SelectedPath)) { + if(!txtLocation.IsFocused) { + ShowWatermark(true); + } + imgIcon.Source = null; return; } ShowWatermark(false); - string text; - if(wrapper.IDL == null) { - text = wrapper.Path; - } - else if(File) { - text = wrapper.Path; - } - else { - bool b = File ? wrapper.IsFileSystemFile : wrapper.IsFileSystemFolder; - text = b ? wrapper.Path : wrapper.DisplayName; - } - SetSelectedPath(wrapper.Path, text); + IDLWrapper wrapper = SelectedIDL == null + ? new IDLWrapper(SelectedPath) + : new IDLWrapper(SelectedIDL as byte[] ?? SelectedIDL.ToArray()); - Icon icon = QTUtility.GetIcon(wrapper.PIDL); - imgIcon.Source = - (ImageSource)new BitmapToImageSourceConverter().Convert(icon.ToBitmap(), null, null, null); + using(wrapper) { + if(!lockText) { + string text; + if(File || wrapper.IDL == null) { + text = wrapper.Path; + } + else { + bool b = File ? wrapper.IsFileSystemFile : wrapper.IsFileSystemFolder; + text = b ? wrapper.Path : wrapper.DisplayName; + } + SetTextboxText(text); + } - location = wrapper.IDL; + Icon icon = QTUtility.GetIcon(wrapper.PIDL); + imgIcon.Source = + (ImageSource)new BitmapToImageSourceConverter().Convert(icon.ToBitmap(), null, null, null); + } } private bool BrowseForFile() { - OpenFileDialog ofd = new OpenFileDialog(); - ofd.FileName = SelectedPath; - if(System.Windows.Forms.DialogResult.OK != ofd.ShowDialog()) { + OpenFileDialog ofd = new OpenFileDialog { FileName = SelectedPath }; + if(DialogResult.OK != ofd.ShowDialog()) { return false; } using(IDLWrapper wrapper = new IDLWrapper(ofd.FileName)) { - SetLocation(wrapper); + if(wrapper.IDL != null) { + SelectedIDL = wrapper.IDL; + } + else { + SelectedPath = wrapper.Path; + } } return true; } @@ -210,7 +254,12 @@ } using(IDLWrapper wrapper = new IDLWrapper(fbd.SelectedIDL)) { - SetLocation(wrapper); + if(wrapper.IDL != null) { + SelectedIDL = wrapper.IDL; + } + else { + SelectedPath = wrapper.Path; + } } return true; } @@ -241,15 +290,21 @@ } string path = txtLocation.Text; + lockText = true; if((File && !System.IO.File.Exists(path)) || (Folder && !System.IO.Directory.Exists(path))) { - ClearLocation(); - SetSelectedPath(path, path); - return; + SelectedPath = path; } - - using(IDLWrapper wrapper = new IDLWrapper(path)) { - SetLocation(wrapper); + else { + using(IDLWrapper wrapper = new IDLWrapper(path)) { + if(wrapper.IDL != null) { + SelectedIDL = wrapper.IDL; + } + else { + SelectedPath = wrapper.Path; + } + } } + lockText = false; } } } Modified: branches/options/QTTabBar/OptionsDialog.xaml =================================================================== --- branches/options/QTTabBar/OptionsDialog.xaml 2011-11-14 23:18:11 UTC (rev 347) +++ branches/options/QTTabBar/OptionsDialog.xaml 2011-11-16 23:36:32 UTC (rev 348) @@ -754,7 +754,11 @@ <StackPanel Margin="13,0" Orientation="Horizontal"> - <qt:FileFolderEntryBox x:Name="entDefaultLocation" Folder="True" Width="400"/> + <qt:FileFolderEntryBox x:Name="entDefaultLocation" + Folder="True" + SelectedIDL="{Binding Path=DefaultLocation}" + ShowIcon="True" + Width="400"/> </StackPanel> <Label x:Name="lblRestoreTabs" Content="Session saving" @@ -1525,7 +1529,8 @@ Folder="False" Grid.Column="1" Grid.ColumnSpan="3" - Margin="5,1"/> + Margin="5,1" + SelectedPath="{Binding Path=TabImageFile}"/> <Label Content="Sizing margins:" Grid.Row="1" @@ -1718,7 +1723,8 @@ <qt:FileFolderEntryBox Grid.Column="1" Grid.ColumnSpan="3" - Margin="0,2"/> + Margin="0,2" + SelectedPath="{Binding Path=RebarImageFile}"/> <CheckBox x:Name="chkUseRebarBGColor" Content="Solid color" Grid.Row="1" This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <mas...@us...> - 2011-11-17 06:30:26
|
Revision: 349 http://qttabbar.svn.sourceforge.net/qttabbar/?rev=349&view=rev Author: masamunexgp Date: 2011-11-17 06:30:19 +0000 (Thu, 17 Nov 2011) Log Message: ----------- Appearance tab Toolbar Background section fully implemented. Modified Paths: -------------- branches/options/QTTabBar/OptionsDialog.xaml branches/options/QTTabBar/OptionsDialog.xaml.cs branches/options/QTTabBar/OptionsDialog_OLD.cs branches/options/QTTabBar/QTTabBarClass.cs branches/options/QTTabBar/QTUtility.cs branches/options/QTTabBar/QTabControl.cs branches/options/QTTabBar/RebarController.cs Modified: branches/options/QTTabBar/OptionsDialog.xaml =================================================================== --- branches/options/QTTabBar/OptionsDialog.xaml 2011-11-16 23:36:32 UTC (rev 348) +++ branches/options/QTTabBar/OptionsDialog.xaml 2011-11-17 06:30:19 UTC (rev 349) @@ -1731,7 +1731,8 @@ Height="16" IsChecked="{Binding Path=UseRebarBGColor}" Margin="0,0,15,0"/> - <Button + <Button x:Name="btnRebarBGColorChoose" + Click="btnRebarBGColorChoose_Click" Content="Choose" Grid.Column="1" Grid.Row="1" @@ -1753,11 +1754,14 @@ Height="16" Margin="0,0,15,0" Padding="0"/> - <ComboBox + <ComboBox x:Name="cmbRebarStretchMode" + DisplayMemberPath="Value" Grid.Column="3" Grid.Row="1" Height="23" - HorizontalAlignment="Stretch"/> + HorizontalAlignment="Stretch" + SelectedValue="{Binding Path=RebarStretchMode}" + SelectedValuePath="Key"/> <Label Content="Sizing margins:" Grid.Column="2" @@ -1765,12 +1769,26 @@ Height="16" Margin="0,0,15,0" Padding="0"/> - <qt:MarginCombo + <qt:MarginCombo x:Name="mcbRebarMargin" Grid.Column="3" Grid.Row="2" Height="23" HorizontalAlignment="Stretch" - Value="{Binding Path=RebarSizeMargin}"/> + Value="{Binding Path=RebarSizeMargin}"> + <qt:MarginCombo.Style> + <Style TargetType="{x:Type qt:MarginCombo}"> + <Setter Property="IsEnabled" Value="False" /> + <Style.Triggers> + <DataTrigger Binding="{Binding Path=SelectedValue, ElementName=cmbRebarStretchMode}"> + <DataTrigger.Value> + <qt:StretchMode>Full</qt:StretchMode> + </DataTrigger.Value> + <Setter Property="IsEnabled" Value="True" /> + </DataTrigger> + </Style.Triggers> + </Style> + </qt:MarginCombo.Style> + </qt:MarginCombo> </Grid> </StackPanel> </ScrollViewer> Modified: branches/options/QTTabBar/OptionsDialog.xaml.cs =================================================================== --- branches/options/QTTabBar/OptionsDialog.xaml.cs 2011-11-16 23:36:32 UTC (rev 348) +++ branches/options/QTTabBar/OptionsDialog.xaml.cs 2011-11-17 06:30:19 UTC (rev 349) @@ -85,6 +85,12 @@ // todo: localize all of these #region ToLocalize + private readonly static Dictionary<StretchMode, string> StretchModeItems + = new Dictionary<StretchMode, string> { + {StretchMode.Full, "Stretch"}, + {StretchMode.Real, "True size"}, + {StretchMode.Tile, "Tile"}, + }; private readonly static Dictionary<TabPos, string> NewTabPosItems = new Dictionary<TabPos, string> { {TabPos.Left, "Left of the current tab" }, @@ -365,6 +371,7 @@ InitializeComponent(); cmbNewTabPos.ItemsSource = NewTabPosItems; cmbNextAfterClosed.ItemsSource = NextAfterCloseItems; + cmbRebarStretchMode.ItemsSource = StretchModeItems; InitializeTips(); InitializeMouse(); @@ -459,17 +466,16 @@ #region ---------- Tweaks ---------- private void btnBackgroundColor_Click(object sender, RoutedEventArgs e) { - ColorDialog cd = new ColorDialog(); + ColorDialogEx cd = new ColorDialogEx(); if(System.Windows.Forms.DialogResult.OK == cd.ShowDialog()) { Config.Tweaks.BackgroundColor = cd.Color; btnBackgroundColor.Background = new SolidColorBrush(Color.FromArgb( cd.Color.A, cd.Color.R, cd.Color.G, cd.Color.B)); } - } private void btnTextColor_Click(object sender, RoutedEventArgs e) { - ColorDialog cd = new ColorDialog(); + ColorDialogEx cd = new ColorDialogEx(); if(System.Windows.Forms.DialogResult.OK == cd.ShowDialog()) { Config.Tweaks.TextColor = cd.Color; btnTextColor.Foreground = new SolidColorBrush(Color.FromArgb( @@ -1904,6 +1910,21 @@ //# But, without this we must interact with the TextBox in some way before the OK button saves it. workingConfig.bbar.ImageStripPath = ""; } + + private sealed class ColorDialogEx : ColorDialog { + protected override int Options { + get { + return (base.Options | 2); + } + } + } + + private void btnRebarBGColorChoose_Click(object sender, RoutedEventArgs e) { + ColorDialogEx cd = new ColorDialogEx {Color = workingConfig.skin.RebarColor}; + if(System.Windows.Forms.DialogResult.OK == cd.ShowDialog()) { + workingConfig.skin.RebarColor = cd.Color; + } + } } #region ---------- Converters ---------- Modified: branches/options/QTTabBar/OptionsDialog_OLD.cs =================================================================== --- branches/options/QTTabBar/OptionsDialog_OLD.cs 2011-11-16 23:36:32 UTC (rev 348) +++ branches/options/QTTabBar/OptionsDialog_OLD.cs 2011-11-17 06:30:19 UTC (rev 349) @@ -4105,7 +4105,7 @@ chbUseTabSkin.Checked = btnHiliteClsc.Enabled = tbTabImagePath.Enabled = btnTabImage.Enabled = true; chbUseTabSkin.Enabled = false; } - tbTabImagePath.Text = QTUtility.Path_TabImage; + //tbTabImagePath.Text = QTUtility.Path_TabImage; tabImageSetting.SizingMargin = QTUtility.TabImageSizingMargin; cmbWhlClick.SelectedIndex = ((QTUtility.ConfigValues[6] & 0x80) == 0x80) ? 1 : 0; cmbWhlClick.Enabled = chbWhlClick.Checked; @@ -4190,7 +4190,7 @@ chbForceSysListView.Checked = Config.Tweaks.ForceSysListView; chbAlwaysShowHeader.Checked = Config.Tweaks.AlwaysShowHeaders; btnToolBarBGClr.Enabled = chbToolbarBGClr.Checked = (QTUtility.ConfigValues[7] & 4) == 4; - btnToolBarBGClr.BackColor = QTUtility.RebarBGColor; + //btnToolBarBGClr.BackColor = QTUtility.RebarBGColor; chbFolderIcon.Checked = (QTUtility.ConfigValues[7] & 2) == 2; chbGridLine.Checked = (QTUtility.ConfigValues[8] & 0x80) == 0x80; chbNoFulRowSelect.Checked = ((QTUtility.ConfigValues[8] & 0x40) == 0x40) ^ !QTUtility.IsXP; @@ -4200,7 +4200,7 @@ btnAlternate_Default.Enabled = btnAlternateColor.Enabled = btnAlternateColor_Text.Enabled = chbAlternateColor.Checked; if(isSupported) { chbRebarBGImage.Checked = (QTUtility.ConfigValues[11] & 0x80) == 0x80; - tbRebarImagePath.Text = QTUtility.Path_RebarImage; + //tbRebarImagePath.Text = QTUtility.Path_RebarImage; if((QTUtility.ConfigValues[11] & 0x40) == 0x40) { cmbRebarBGImageMode.SelectedIndex = 1; } @@ -4664,7 +4664,7 @@ key.SetValue("HighlightColorClassic", QTUtility.TabHiliteColor.ToArgb()); key.SetValue("TitleColorShadowActive", QTUtility.TabTextColor_ActivShdw.ToArgb()); key.SetValue("TitleColorShadowInActv", QTUtility.TabTextColor_InAtvShdw.ToArgb()); - key.SetValue("ToolbarBGColor", QTUtility.RebarBGColor.ToArgb()); + //key.SetValue("ToolbarBGColor", QTUtility.RebarBGColor.ToArgb()); key.SetValue("AlternateColor_Bk", QTUtility.ShellViewRowCOLORREF_Background); key.SetValue("AlternateColor_Text", QTUtility.ShellViewRowCOLORREF_Text); key.SetValue("Max_Undo", QTUtility.MaxCount_History); @@ -4682,7 +4682,7 @@ key.DeleteValue("TabFontSize", false); QTUtility.TabFont = null; } - key.SetValue("TabImage", QTUtility.Path_TabImage); + //key.SetValue("TabImage", QTUtility.Path_TabImage); byte[] buffer = new byte[] { (byte)QTUtility.TabImageSizingMargin.Left, (byte)QTUtility.TabImageSizingMargin.Top, (byte)QTUtility.TabImageSizingMargin.Right, (byte)QTUtility.TabImageSizingMargin.Bottom }; key.SetValue("TabImageSizingMargin", buffer); QTUtility.PreviewExtsList_Txt.Clear(); @@ -4724,7 +4724,7 @@ key2.SetValue("LanguageFile", QTUtility.Path_PluginLangFile); } } - key.SetValue("ToolbarBGImage", QTUtility.Path_RebarImage); + //key.SetValue("ToolbarBGImage", QTUtility.Path_RebarImage); QTUtility2.WriteRegBinary(Config.Keys.Shortcuts, "ShortcutKeys", key); } } Modified: branches/options/QTTabBar/QTTabBarClass.cs =================================================================== --- branches/options/QTTabBar/QTTabBarClass.cs 2011-11-16 23:36:32 UTC (rev 348) +++ branches/options/QTTabBar/QTTabBarClass.cs 2011-11-17 06:30:19 UTC (rev 349) @@ -1583,16 +1583,16 @@ } internal static Bitmap[] CreateTabImage() { - if(File.Exists(QTUtility.Path_TabImage)) { + if(File.Exists(Config.Skin.TabImageFile)) { try { Bitmap[] bitmapArray = new Bitmap[3]; - using(Bitmap bitmap = new Bitmap(QTUtility.Path_TabImage)) { + using(Bitmap bitmap = new Bitmap(Config.Skin.TabImageFile)) { int height = bitmap.Height / 3; bitmapArray[0] = bitmap.Clone(new Rectangle(0, 0, bitmap.Width, height), PixelFormat.Format32bppArgb); bitmapArray[1] = bitmap.Clone(new Rectangle(0, height, bitmap.Width, height), PixelFormat.Format32bppArgb); bitmapArray[2] = bitmap.Clone(new Rectangle(0, height * 2, bitmap.Width, height), PixelFormat.Format32bppArgb); } - if(Path.GetExtension(QTUtility.Path_TabImage).PathEquals(".bmp")) { + if(Path.GetExtension(Config.Skin.TabImageFile).PathEquals(".bmp")) { bitmapArray[0].MakeTransparent(Color.Magenta); bitmapArray[1].MakeTransparent(Color.Magenta); bitmapArray[2].MakeTransparent(Color.Magenta); Modified: branches/options/QTTabBar/QTUtility.cs =================================================================== --- branches/options/QTTabBar/QTUtility.cs 2011-11-16 23:36:32 UTC (rev 348) +++ branches/options/QTTabBar/QTUtility.cs 2011-11-17 06:30:19 UTC (rev 349) @@ -79,9 +79,7 @@ internal static string Path_LanguageFile; internal static string PATH_MYNETWORK; internal static string Path_PluginLangFile; - internal static string Path_RebarImage; internal static string PATH_SEARCHFOLDER; - internal static string Path_TabImage; internal static string PathToSelectInCommandLineArg; internal static List<string> PreviewExtsList_Img = new List<string>(); internal static List<string> PreviewExtsList_Txt = new List<string>(); @@ -89,7 +87,6 @@ internal static float PreviewFontSize; internal static int PreviewMaxHeight = 0x100; internal static int PreviewMaxWidth = 0x200; - internal static Color RebarBGColor; internal const string REGUSER = RegConst.Root; internal static string[] ResMain; internal static string[] ResMisc; @@ -168,7 +165,6 @@ TabHiliteColor = Color.FromArgb(QTUtility2.GetRegistryValueSafe(key, "HighlightColorClassic", SystemColors.Highlight.ToArgb())); TabTextColor_ActivShdw = Color.FromArgb(QTUtility2.GetRegistryValueSafe(key, "TitleColorShadowActive", Color.Silver.ToArgb())); TabTextColor_InAtvShdw = Color.FromArgb(QTUtility2.GetRegistryValueSafe(key, "TitleColorShadowInActv", Color.White.ToArgb())); - RebarBGColor = Color.FromArgb(QTUtility2.GetRegistryValueSafe(key, "ToolbarBGColor", SystemColors.Control.ToArgb())); ShellViewRowCOLORREF_Background = QTUtility2.GetRegistryValueSafe(key, "AlternateColor_Bk", 0xfaf5f1); ShellViewRowCOLORREF_Text = QTUtility2.GetRegistryValueSafe(key, "AlternateColor_Text", QTUtility2.MakeCOLORREF(SystemColors.WindowText)); string familyName = (string)key.GetValue("TabFont", string.Empty); @@ -201,7 +197,6 @@ } } RefreshGroupShortcutKeyDic(key); - Path_TabImage = (string)key.GetValue("TabImage", string.Empty); byte[] buffer2 = (byte[])key.GetValue("TabImageSizingMargin", new byte[4]); if(buffer2.Length != 4) { TabImageSizingMargin = Padding.Empty; @@ -209,10 +204,6 @@ else { TabImageSizingMargin = new Padding(buffer2[0], buffer2[1], buffer2[2], buffer2[3]); } - if((Path_TabImage.Length > 0) && !File.Exists(Path_TabImage)) { - Path_TabImage = string.Empty; - } - Path_RebarImage = (string)key.GetValue("ToolbarBGImage", string.Empty); RefreshLockedTabsList(); string str6 = (string)key.GetValue("StartUpGroups", string.Empty); if(str6.Length > 0) { Modified: branches/options/QTTabBar/QTabControl.cs =================================================================== --- branches/options/QTTabBar/QTabControl.cs 2011-11-16 23:36:32 UTC (rev 348) +++ branches/options/QTTabBar/QTabControl.cs 2011-11-17 06:30:19 UTC (rev 349) @@ -1206,7 +1206,7 @@ fForceClassic = Config.Skin.UseTabSkin; SetFont(QTUtility.TabFont); sizingMargin = QTUtility.TabImageSizingMargin + new Padding(0, 0, 1, 1); - if(Config.Skin.UseTabSkin && (QTUtility.Path_TabImage.Length > 0)) { + if(Config.Skin.UseTabSkin && Config.Skin.TabImageFile.Length > 0) { SetTabImages(QTTabBarClass.CreateTabImage()); } else { Modified: branches/options/QTTabBar/RebarController.cs =================================================================== --- branches/options/QTTabBar/RebarController.cs 2011-11-16 23:36:32 UTC (rev 348) +++ branches/options/QTTabBar/RebarController.cs 2011-11-17 06:30:19 UTC (rev 349) @@ -16,6 +16,7 @@ // along with QTTabBar. If not, see <http://www.gnu.org/licenses/>. using System; +using System.Collections.Generic; using System.Drawing; using System.Drawing.Drawing2D; using System.IO; @@ -80,7 +81,7 @@ if(DefaultRebarCOLORREF == -1) { DefaultRebarCOLORREF = (int)PInvoke.SendMessage(Handle, RB.GETBKCOLOR, IntPtr.Zero, IntPtr.Zero); } - int num2 = QTUtility2.MakeCOLORREF(QTUtility.RebarBGColor); + int num2 = QTUtility2.MakeCOLORREF(Config.Skin.RebarColor); PInvoke.SendMessage(Handle, RB.SETBKCOLOR, IntPtr.Zero, (IntPtr)num2); } @@ -96,12 +97,12 @@ textureBrushRebar.Dispose(); textureBrushRebar = null; } - if(!File.Exists(QTUtility.Path_RebarImage)) return; + if(!File.Exists(Config.Skin.RebarImageFile)) return; try { - using(Bitmap bitmap = new Bitmap(QTUtility.Path_RebarImage)) { + using(Bitmap bitmap = new Bitmap(Config.Skin.RebarImageFile)) { bmpRebar = new Bitmap(bitmap, bitmap.Size); textureBrushRebar = new TextureBrush(bmpRebar); - if(Path.GetExtension(QTUtility.Path_RebarImage).PathEquals(".bmp")) { + if(Path.GetExtension(Config.Skin.RebarImageFile).PathEquals(".bmp")) { bmpRebar.MakeTransparent(Color.Magenta); } } @@ -165,7 +166,7 @@ if(DefaultRebarCOLORREF == -1) { DefaultRebarCOLORREF = (int)PInvoke.SendMessage(Handle, RB.GETBKCOLOR, IntPtr.Zero, IntPtr.Zero); } - int c = QTUtility2.MakeCOLORREF(QTUtility.RebarBGColor); + int c = QTUtility2.MakeCOLORREF(Config.Skin.RebarColor); PInvoke.SendMessage(Handle, RB.SETBKCOLOR, IntPtr.Zero, (IntPtr)c); } else if(DefaultRebarCOLORREF != -1) { @@ -206,60 +207,104 @@ using(Graphics graphics = Graphics.FromHdc(m.WParam)) { RECT rect; PInvoke.GetWindowRect(Handle, out rect); - Rectangle rectangle = new Rectangle(0, 0, rect.Width, rect.Height); + Rectangle rectRebar = new Rectangle(0, 0, rect.Width, rect.Height); // Fill the Rebar background color if(Config.Skin.UseRebarBGColor) { - using(SolidBrush brush = new SolidBrush(QTUtility.RebarBGColor)) { - graphics.FillRectangle(brush, rectangle); + using(SolidBrush brush = new SolidBrush(Config.Skin.RebarColor)) { + graphics.FillRectangle(brush, rectRebar); fFilled = true; } } + else if(Config.Skin.RebarStretchMode == StretchMode.Real) { + rebarController.DefWndProc(ref m); + } // Draw the Rebar image - if(VisualStyleRenderer.IsSupported && Config.Skin.UseRebarImage && QTUtility.Path_RebarImage.Length > 0) { + if(VisualStyleRenderer.IsSupported && Config.Skin.UseRebarImage && Config.Skin.RebarImageFile.Length > 0) { if(bmpRebar == null) { CreateRebarImage(); } if(bmpRebar != null) { - switch(Config.Skin.RebarStretchMode) { - /* *case 1: { // Stretch on each band - // TODO - if(!fFilled) rebarController.DefWndProc(ref m); - int bandCount = (int)PInvoke.SendMessage(rebarController.Handle, RB.GETBANDCOUNT, IntPtr.Zero, IntPtr.Zero); - graphics.PixelOffsetMode = PixelOffsetMode.HighQuality; - RECT rectBand = new RECT(); - RECT rectMargin = new RECT(); - - // Draw the bitmap on each band - for(int i = 0; i < bandCount; i++) { - if(PInvoke.SendMessage(rebarController.Handle, RB.GETRECT, (IntPtr)i, ref rectBand) == IntPtr.Zero) { - continue; - } - PInvoke.SendMessage(rebarController.Handle, RB.GETBANDBORDERS, (IntPtr)i, ref rectMargin); - rectBand.left -= !QTUtility.IsXP ? 4 : rectMargin.left; - rectBand.top -= rectMargin.top; - rectBand.right += rectMargin.right; - rectBand.bottom += rectMargin.bottom; - graphics.DrawImage(bmpRebar, rectBand.ToRectangle()); + List<Rectangle> rectTargets = new List<Rectangle>(); + if(Config.Skin.RebarImageSeperateBars) { + int bandCount = (int)PInvoke.SendMessage(rebarController.Handle, RB.GETBANDCOUNT, IntPtr.Zero, IntPtr.Zero); + graphics.PixelOffsetMode = PixelOffsetMode.HighQuality; + RECT rectBand = new RECT(); + RECT rectMargin = new RECT(); + for(int i = 0; i < bandCount; i++) { + if(PInvoke.SendMessage(rebarController.Handle, RB.GETRECT, (IntPtr)i, ref rectBand) == IntPtr.Zero) { + continue; } - break; - } */ - case StretchMode.Real: { - if(!fFilled) rebarController.DefWndProc(ref m); - Rectangle destRect = new Rectangle(Point.Empty, bmpRebar.Size); - graphics.DrawImage(bmpRebar, destRect, destRect, GraphicsUnit.Pixel); - break; + PInvoke.SendMessage(rebarController.Handle, RB.GETBANDBORDERS, (IntPtr)i, ref rectMargin); + rectBand.left -= !QTUtility.IsXP ? 4 : rectMargin.left; + rectBand.top -= rectMargin.top; + rectBand.right += rectMargin.right; + rectBand.bottom += rectMargin.bottom; + rectTargets.Add(rectBand.ToRectangle()); } - case StretchMode.Tile: - textureBrushRebar = textureBrushRebar ?? new TextureBrush(bmpRebar); - graphics.FillRectangle(textureBrushRebar, rectangle); - break; + } + else { + rectTargets.Add(rectRebar); + } - default: // Full - graphics.PixelOffsetMode = PixelOffsetMode.HighQuality; - graphics.DrawImage(bmpRebar, rectangle); - break; + foreach(Rectangle destRect in rectTargets) { + switch(Config.Skin.RebarStretchMode) { + case StretchMode.Real: + Rectangle rectDest2 = new Rectangle(new Point(0, 0), destRect.Size); + Rectangle rectBmp = new Rectangle(new Point(0, 0), bmpRebar.Size); + rectBmp.Intersect(rectDest2); + rectDest2.Intersect(rectBmp); + rectDest2.Offset(destRect.Location); + graphics.DrawImage(bmpRebar, rectDest2, rectBmp, GraphicsUnit.Pixel); + break; + + case StretchMode.Tile: + textureBrushRebar = textureBrushRebar ?? new TextureBrush(bmpRebar); + textureBrushRebar.TranslateTransform(destRect.X, destRect.Y); + graphics.FillRectangle(textureBrushRebar, destRect); + textureBrushRebar.ResetTransform(); + break; + + default: // Full + // todo: make this a function + graphics.PixelOffsetMode = PixelOffsetMode.HighQuality; + Margin margin = Config.Skin.RebarSizeMargin; + int left = margin.Left; + int top = margin.Top; + int right = margin.Right; + int bottom = margin.Bottom; + int vertical = margin.Top + margin.Bottom; + int horizontal = margin.Left + margin.Right; + int width = bmpRebar.Width; + int height = bmpRebar.Height; + Rectangle[] dstRects = new Rectangle[] { + new Rectangle(destRect.X, destRect.Y, left, top), + new Rectangle(destRect.X + left, destRect.Y, destRect.Width - horizontal, top), + new Rectangle(destRect.Right - right, destRect.Y, right, top), + new Rectangle(destRect.X, destRect.Y + top, left, destRect.Height - vertical), + new Rectangle(destRect.X + left, destRect.Y + top, destRect.Width - horizontal, destRect.Height - vertical), + new Rectangle(destRect.Right - right, destRect.Y + top, right, destRect.Height - vertical), + new Rectangle(destRect.X, destRect.Bottom - bottom, left, bottom), + new Rectangle(destRect.X + left, destRect.Bottom - bottom, destRect.Width - horizontal, bottom), + new Rectangle(destRect.Right - right, destRect.Bottom - bottom, right, bottom) + }; + Rectangle[] srcRects = new Rectangle[] { + new Rectangle(0, 0, left, top), + new Rectangle(left, 0, width - horizontal, top), + new Rectangle(width - right, 0, right, top), + new Rectangle(0, top, left, height - vertical), + new Rectangle(left, top, width - horizontal, height - vertical), + new Rectangle(width - right, top, right, height - vertical), + new Rectangle(0, height - bottom, left, bottom), + new Rectangle(left, height - bottom, width - horizontal, bottom), + new Rectangle(width - right, height - bottom, right, bottom), + }; + for(int i = 0; i < 9; i++) { + graphics.DrawImage(bmpRebar, dstRects[i], srcRects[i], GraphicsUnit.Pixel); + } + break; + } } fFilled = true; } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <mas...@us...> - 2011-11-17 19:21:35
|
Revision: 350 http://qttabbar.svn.sourceforge.net/qttabbar/?rev=350&view=rev Author: masamunexgp Date: 2011-11-17 19:21:29 +0000 (Thu, 17 Nov 2011) Log Message: ----------- Oops, forgot the copyright comments in the MarginCombo files. Added. Modified Paths: -------------- branches/options/QTTabBar/MarginCombo.xaml branches/options/QTTabBar/MarginCombo.xaml.cs Modified: branches/options/QTTabBar/MarginCombo.xaml =================================================================== --- branches/options/QTTabBar/MarginCombo.xaml 2011-11-17 06:30:19 UTC (rev 349) +++ branches/options/QTTabBar/MarginCombo.xaml 2011-11-17 19:21:29 UTC (rev 350) @@ -1,4 +1,24 @@ -<UserControl x:Class="QTTabBarLib.MarginCombo" +<?xml version="1.0" encoding="UTF-8"?> +<!-- + This file is part of QTTabBar, a shell extension for Microsoft + Windows Explorer. + Copyright (C) 2007-2010 Quizo, Paul Accisano + + QTTabBar is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + QTTabBar is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with QTTabBar. If not, see <http://www.gnu.org/licenses/>. +--> + +<UserControl x:Class="QTTabBarLib.MarginCombo" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" Modified: branches/options/QTTabBar/MarginCombo.xaml.cs =================================================================== --- branches/options/QTTabBar/MarginCombo.xaml.cs 2011-11-17 06:30:19 UTC (rev 349) +++ branches/options/QTTabBar/MarginCombo.xaml.cs 2011-11-17 19:21:29 UTC (rev 350) @@ -1,4 +1,21 @@ -using System; +// This file is part of QTTabBar, a shell extension for Microsoft +// Windows Explorer. +// Copyright (C) 2007-2010 Quizo, Paul Accisano +// +// QTTabBar is free software: you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. +// +// QTTabBar is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with QTTabBar. If not, see <http://www.gnu.org/licenses/>. + +using System; using System.Globalization; using System.Linq; using System.Windows; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <mas...@us...> - 2011-11-19 00:34:56
|
Revision: 351 http://qttabbar.svn.sourceforge.net/qttabbar/?rev=351&view=rev Author: masamunexgp Date: 2011-11-19 00:34:49 +0000 (Sat, 19 Nov 2011) Log Message: ----------- Work done on the Tab Size section of the Appearance tab. Modified Paths: -------------- branches/options/QTTabBar/Config.cs branches/options/QTTabBar/MarginCombo.xaml.cs branches/options/QTTabBar/OptionsDialog_OLD.cs branches/options/QTTabBar/QTTabBarClass.cs branches/options/QTTabBar/QTUtility.cs branches/options/QTTabBar/QTabControl.cs branches/options/QTTabBar/RebarController.cs Modified: branches/options/QTTabBar/Config.cs =================================================================== --- branches/options/QTTabBar/Config.cs 2011-11-17 19:21:29 UTC (rev 350) +++ branches/options/QTTabBar/Config.cs 2011-11-19 00:34:49 UTC (rev 351) @@ -24,6 +24,7 @@ using System.Text; using System.Linq; using Microsoft.Win32; +using Padding = System.Windows.Forms.Padding; namespace QTTabBarLib { @@ -350,8 +351,8 @@ public class _Skin { public bool UseTabSkin { get; set; } public string TabImageFile { get; set; } - public Margin TabSizeMargin { get; set; } - public Margin TabContentMargin { get; set; } + public Padding TabSizeMargin { get; set; } + public Padding TabContentMargin { get; set; } public int OverlapPixels { get; set; } public bool HitTestTransparent { get; set; } public int TabHeight { get; set; } @@ -373,14 +374,14 @@ public StretchMode RebarStretchMode { get; set; } public string RebarImageFile { get; set; } public bool RebarImageSeperateBars { get; set; } - public Margin RebarSizeMargin { get; set; } + public Padding RebarSizeMargin { get; set; } public bool ActiveTabInBold { get; set; } public _Skin() { UseTabSkin = false; TabImageFile = ""; - TabSizeMargin = new Margin(); - TabContentMargin = new Margin(); + TabSizeMargin = Padding.Empty; + TabContentMargin = Padding.Empty; OverlapPixels = 0; HitTestTransparent = false; TabHeight = 24; @@ -401,7 +402,7 @@ RebarStretchMode = StretchMode.Full; RebarImageFile = ""; RebarImageSeperateBars = false; - RebarSizeMargin = new Margin(); + RebarSizeMargin = Padding.Empty; ActiveTabInBold = false; } } @@ -518,7 +519,6 @@ // DEATH ROW public static bool DontCaptureNewWnds { get; set; } public static bool AllRecentFiles { get; set; } - public static bool AlignTabTextCenter { get; set; } public static bool ShowTooltips { get; set; } public static bool CloseWhenGroup { get; set; } public static bool NoCaptureMidClick { get; set; } @@ -585,6 +585,15 @@ } // TODO non-props + + // TODO: more validation + if(Config.Skin.TabHeight > 50) { + Config.Skin.TabHeight = 50; + } + if(Config.Skin.TabHeight < 10) { + Config.Skin.TabHeight = 10; + } + } public static void WriteConfig() { const string RegPath = RegConst.Root + RegConst.Config; Modified: branches/options/QTTabBar/MarginCombo.xaml.cs =================================================================== --- branches/options/QTTabBar/MarginCombo.xaml.cs 2011-11-17 19:21:29 UTC (rev 350) +++ branches/options/QTTabBar/MarginCombo.xaml.cs 2011-11-19 00:34:49 UTC (rev 351) @@ -22,26 +22,10 @@ using System.Windows.Controls; using System.Windows.Data; using System.Windows.Input; +using Padding = System.Windows.Forms.Padding; namespace QTTabBarLib { - // It *really* pisses me off that I can't use the Thickness class instead. - // The WPF devs forgot to mark it as Serializable! - [Serializable] - public struct Margin { - public int Left { get; set; } - public int Top { get; set; } - public int Right { get; set; } - public int Bottom { get; set; } - - public Margin(int left, int top, int right, int bottom) : this() { - Left = left; - Top = top; - Right = right; - Bottom = bottom; - } - } - /// <summary> /// Interaction logic for MarginCombo.xaml /// </summary> @@ -79,13 +63,15 @@ }); } + // It *really* pisses me off that I can't use the Thickness class instead. + // The WPF devs forgot to mark it as Serializable! public static readonly DependencyProperty ValueProperty = DependencyProperty.Register("Value", - typeof(Margin), typeof(MarginCombo), new FrameworkPropertyMetadata(new Margin(), + typeof(Padding), typeof(MarginCombo), new FrameworkPropertyMetadata(System.Windows.Forms.Padding.Empty, FrameworkPropertyMetadataOptions.BindsTwoWayByDefault)); - public Margin Value { + public Padding Value { get { - return (Margin)GetValue(ValueProperty); + return (Padding)GetValue(ValueProperty); } set { SetValue(ValueProperty, value); @@ -138,10 +124,10 @@ #region Converters - [ValueConversion(typeof(Margin), typeof(string))] + [ValueConversion(typeof(Padding), typeof(string))] private class JoinedTextConverter : IValueConverter { public object Convert(object value, Type targetType, object parameter, CultureInfo culture) { - Margin t = (Margin)value; + Padding t = (Padding)value; return t.Left + ", " + t.Top + ", " + t.Right + ", " + t.Bottom; } @@ -150,11 +136,11 @@ int[] v = value.ToString().Split(',').Select( s => int.TryParse(s.Trim(), out i) ? Math.Min(Math.Max(i, 0), VAL_MAX) : 0).ToArray(); Array.Resize(ref v, 4); - return new Margin(v[0], v[1], v[2], v[3]); + return new Padding(v[0], v[1], v[2], v[3]); } } - [ValueConversion(typeof(Margin), typeof(string))] + [ValueConversion(typeof(Padding), typeof(string))] private class SingleTextConverter : IValueConverter { private int idx; private MarginCombo parent; @@ -166,17 +152,17 @@ public object Convert(object value, Type targetType, object parameter, CultureInfo culture) { switch(idx) { - case 0: return ((Margin)value).Left.ToString(); - case 1: return ((Margin)value).Top.ToString(); - case 2: return ((Margin)value).Right.ToString(); - default: return ((Margin)value).Bottom.ToString(); + case 0: return ((Padding)value).Left.ToString(); + case 1: return ((Padding)value).Top.ToString(); + case 2: return ((Padding)value).Right.ToString(); + default: return ((Padding)value).Bottom.ToString(); } } public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture) { int i; if(!int.TryParse(value.ToString().Trim(), out i) || i < 0 || i > VAL_MAX) return Binding.DoNothing; - Margin current = parent.Value; + Padding current = parent.Value; switch(idx) { case 0: current.Left = i; break; case 1: current.Top = i; break; Modified: branches/options/QTTabBar/OptionsDialog_OLD.cs =================================================================== --- branches/options/QTTabBar/OptionsDialog_OLD.cs 2011-11-17 19:21:29 UTC (rev 350) +++ branches/options/QTTabBar/OptionsDialog_OLD.cs 2011-11-19 00:34:49 UTC (rev 351) @@ -3691,9 +3691,9 @@ QTUtility.SetConfigAt(Settings.LimitedWidthTabs, true); } QTUtility.TabWidth = (int)nudTabWidth.Value; - QTUtility.TabHeight = (int)nudTabHeight.Value; - QTUtility.MaxTabWidth = (int)nudTabWidthMax.Value; - QTUtility.MinTabWidth = (int)nudTabWidthMin.Value; + Config.Skin.TabHeight = (int)nudTabHeight.Value; + Config.Skin.TabMaxWidth = (int)nudTabWidthMax.Value; + Config.Skin.TabMinWidth = (int)nudTabWidthMin.Value; if(chbNavBtn.Checked) { QTUtility.SetConfigAt(Settings.ShowNavButtons, true); } @@ -3778,7 +3778,7 @@ QTUtility.SetConfigAt(Settings.AlwaysShowHeaders, true); } QTUtility.Path_TabImage = tbTabImagePath.Text; - QTUtility.TabImageSizingMargin = tabImageSetting.SizingMargin; + Config.Skin.TabSizeMargin = tabImageSetting.SizingMargin; if(chbGridLine.Checked) { QTUtility.SetConfigAt(Settings.DetailsGridLines, true); } @@ -4084,7 +4084,7 @@ cmbTabDblClck.SelectedIndex = QTUtility.ConfigValues[3]; cmbBGDblClick.SelectedIndex = QTUtility.ConfigValues[4]; cmbTabWhlClck.SelectedIndex = QTUtility.ConfigValues[12]; - cmbTabTextAlignment.SelectedIndex = Config.AlignTabTextCenter ? 1 : 0; + //cmbTabTextAlignment.SelectedIndex = Config.AlignTabTextCenter ? 1 : 0; chbNavBtn.Checked = (QTUtility.ConfigValues[5] & 0x80) == 0x80; if((QTUtility.ConfigValues[5] & 0x40) == 0x40) { cmbNavBtn.SelectedIndex = 1; @@ -4106,7 +4106,7 @@ chbUseTabSkin.Enabled = false; } //tbTabImagePath.Text = QTUtility.Path_TabImage; - tabImageSetting.SizingMargin = QTUtility.TabImageSizingMargin; + //tabImageSetting.SizingMargin = Config.Skin.TabSizeMargin; cmbWhlClick.SelectedIndex = ((QTUtility.ConfigValues[6] & 0x80) == 0x80) ? 1 : 0; cmbWhlClick.Enabled = chbWhlClick.Checked; chbNCADblClck.Checked = (QTUtility.ConfigValues[6] & 0x40) == 0; @@ -4148,9 +4148,10 @@ cmbTabSizeMode.SelectedIndex = 0; nudTabWidth.Enabled = nudTabWidthMax.Enabled = nudTabWidthMin.Enabled = false; } - nudTabWidthMax.Value = QTUtility.MaxTabWidth; - nudTabWidthMin.Value = QTUtility.MinTabWidth; - nudTabHeight.Value = QTUtility.TabHeight; + nudTabWidthMax.Value = Config.Skin.TabMaxWidth; + nudTabWidthMin.Value = Config.Skin.TabMinWidth; + /* + nudTabHeight.Value = Config.Skin.TabHeight; if(QTUtility.TabWidth > nudTabWidth.Maximum) { nudTabWidth.Value = nudTabWidth.Maximum; } @@ -4159,7 +4160,7 @@ } else { nudTabWidth.Value = QTUtility.TabWidth; - } + }*/ btnActTxtClr.ForeColor = QTUtility.TabTextColor_Active; btnInactTxtClr.ForeColor = QTUtility.TabTextColor_Inactv; btnHiliteClsc.ForeColor = QTUtility.TabHiliteColor; @@ -4655,10 +4656,10 @@ using(RegistryKey key = Registry.CurrentUser.CreateSubKey(RegConst.Root)) { if(key != null) { key.SetValue("Config", QTUtility.ConfigValues); - key.SetValue("TabWidth", QTUtility.TabWidth); - key.SetValue("TabHeight", QTUtility.TabHeight); - key.SetValue("TabWidthMax", QTUtility.MaxTabWidth); - key.SetValue("TabWidthMin", QTUtility.MinTabWidth); + //key.SetValue("TabWidth", QTUtility.TabWidth); + //key.SetValue("TabHeight", Config.Skin.TabHeight); + key.SetValue("TabWidthMax", Config.Skin.TabMaxWidth); + key.SetValue("TabWidthMin", Config.Skin.TabMinWidth); key.SetValue("TitleColorActive", QTUtility.TabTextColor_Active.ToArgb()); key.SetValue("TitleColorInactive", QTUtility.TabTextColor_Inactv.ToArgb()); key.SetValue("HighlightColorClassic", QTUtility.TabHiliteColor.ToArgb()); @@ -4683,7 +4684,7 @@ QTUtility.TabFont = null; } //key.SetValue("TabImage", QTUtility.Path_TabImage); - byte[] buffer = new byte[] { (byte)QTUtility.TabImageSizingMargin.Left, (byte)QTUtility.TabImageSizingMargin.Top, (byte)QTUtility.TabImageSizingMargin.Right, (byte)QTUtility.TabImageSizingMargin.Bottom }; + byte[] buffer = new byte[] { (byte)Config.Skin.TabSizeMargin.Left, (byte)Config.Skin.TabSizeMargin.Top, (byte)Config.Skin.TabSizeMargin.Right, (byte)Config.Skin.TabSizeMargin.Bottom }; key.SetValue("TabImageSizingMargin", buffer); QTUtility.PreviewExtsList_Txt.Clear(); QTUtility.PreviewExtsList_Img.Clear(); Modified: branches/options/QTTabBar/QTTabBarClass.cs =================================================================== --- branches/options/QTTabBar/QTTabBarClass.cs 2011-11-17 19:21:29 UTC (rev 350) +++ branches/options/QTTabBar/QTTabBarClass.cs 2011-11-19 00:34:49 UTC (rev 351) @@ -190,7 +190,7 @@ InitializeStaticFields(); } QTUtility.InstancesCount++; - BandHeight = QTUtility.TabHeight + 2; + BandHeight = Config.Skin.TabHeight + 2; InitializeComponent(); lstActivatedTabs.Add(CurrentTab); } @@ -3415,8 +3415,8 @@ if(flag) { Controls.Add(toolStrip); } - MinSize = new Size(150, QTUtility.TabHeight + 2); - Height = QTUtility.TabHeight + 2; + MinSize = new Size(150, Config.Skin.TabHeight + 2); + Height = Config.Skin.TabHeight + 2; ContextMenuStrip = contextMenuSys; MouseDoubleClick += QTTabBarClass_MouseDoubleClick; MouseUp += QTTabBarClass_MouseUp; @@ -5039,7 +5039,7 @@ } private void SetBarRows(int count) { - BandHeight = (count * (QTUtility.TabHeight - 3)) + 5; + BandHeight = (count * (Config.Skin.TabHeight - 3)) + 5; rebarController.RefreshHeight(); } @@ -5676,7 +5676,7 @@ } if((flag && !flag2) && !Config.Tabs.MultipleTabRows) { Rectangle rectangle3 = tabControl1.GetTabRect(num, false); - Point p = new Point(rectangle3.X + (rectangle3.Width / 2), rectangle3.Y + (QTUtility.TabHeight / 2)); + Point p = new Point(rectangle3.X + (rectangle3.Width / 2), rectangle3.Y + (Config.Skin.TabHeight / 2)); Cursor.Position = tabControl1.PointToScreen(p); } SyncButtonBarCurrent(12); Modified: branches/options/QTTabBar/QTUtility.cs =================================================================== --- branches/options/QTTabBar/QTUtility.cs 2011-11-17 19:21:29 UTC (rev 350) +++ branches/options/QTTabBar/QTUtility.cs 2011-11-19 00:34:49 UTC (rev 351) @@ -66,8 +66,6 @@ internal const BindAction LAST_KEYBOARD_ACTION = BindAction.FocusTabBar; public static int MaxCount_Executed = 0x10; internal static int MaxCount_History = 0x10; - internal static int MaxTabWidth; - internal static int MinTabWidth; internal static List<string> NoCapturePathsList = new List<string>(); internal static bool NowDebugging = #if DEBUG @@ -100,14 +98,11 @@ internal static string StartUpGroupNameNowOpening = string.Empty; internal static Font StartUpTabFont; internal static Font TabFont; - internal static int TabHeight; internal static Color TabHiliteColor; - internal static Padding TabImageSizingMargin; internal static Color TabTextColor_Active; internal static Color TabTextColor_ActivShdw; internal static Color TabTextColor_Inactv; internal static Color TabTextColor_InAtvShdw; - internal static int TabWidth; internal static Dictionary<string, string[]> TextResourcesDic; internal static List<byte[]> TMPIDLList = new List<byte[]>(); internal static List<string> TMPPathList = new List<string>(); @@ -150,16 +145,6 @@ Path_LanguageFile = string.Empty; } ValidateTextResources(); - TabWidth = QTUtility2.GetRegistryValueSafe(key, "TabWidth", 80); - TabHeight = QTUtility2.GetRegistryValueSafe(key, "TabHeight", 0x18); - MaxTabWidth = QTUtility2.GetRegistryValueSafe(key, "TabWidthMax", 150); - MinTabWidth = QTUtility2.GetRegistryValueSafe(key, "TabWidthMin", 70); - if(TabHeight > 50) { - TabHeight = 50; - } - if(TabHeight < 10) { - TabHeight = 10; - } TabTextColor_Active = Color.FromArgb(QTUtility2.GetRegistryValueSafe(key, "TitleColorActive", SystemColors.ControlText.ToArgb())); TabTextColor_Inactv = Color.FromArgb(QTUtility2.GetRegistryValueSafe(key, "TitleColorInactive", SystemColors.ControlText.ToArgb())); TabHiliteColor = Color.FromArgb(QTUtility2.GetRegistryValueSafe(key, "HighlightColorClassic", SystemColors.Highlight.ToArgb())); @@ -197,13 +182,6 @@ } } RefreshGroupShortcutKeyDic(key); - byte[] buffer2 = (byte[])key.GetValue("TabImageSizingMargin", new byte[4]); - if(buffer2.Length != 4) { - TabImageSizingMargin = Padding.Empty; - } - else { - TabImageSizingMargin = new Padding(buffer2[0], buffer2[1], buffer2[2], buffer2[3]); - } RefreshLockedTabsList(); string str6 = (string)key.GetValue("StartUpGroups", string.Empty); if(str6.Length > 0) { Modified: branches/options/QTTabBar/QTabControl.cs =================================================================== --- branches/options/QTTabBar/QTabControl.cs 2011-11-17 19:21:29 UTC (rev 350) +++ branches/options/QTTabBar/QTabControl.cs 2011-11-19 00:34:49 UTC (rev 351) @@ -99,21 +99,13 @@ private VisualStyleRenderer vsr_RPressed; public event QTabCancelEventHandler CloseButtonClicked; - public event QTabCancelEventHandler Deselecting; - public event ItemDragEventHandler ItemDrag; - public event QTabCancelEventHandler PointedTabChanged; - public event QEventHandler RowCountChanged; - public event EventHandler SelectedIndexChanged; - public event QTabCancelEventHandler Selecting; - public event QTabCancelEventHandler TabCountChanged; - public event QTabCancelEventHandler TabIconMouseDown; public QTabControl() { @@ -1197,22 +1189,22 @@ sizeMode = TabSizeMode.Normal; fLimitSize = Config.LimitedWidthTabs; } - itemSize = new Size(QTUtility.TabWidth, QTUtility.TabHeight); - if((QTUtility.MaxTabWidth >= QTUtility.MinTabWidth) && (QTUtility.MinTabWidth > 9)) { - maxAllowedTabWidth = QTUtility.MaxTabWidth; - minAllowedTabWidth = QTUtility.MinTabWidth; + if((Config.Skin.TabMaxWidth >= Config.Skin.TabMinWidth) && (Config.Skin.TabMinWidth > 9)) { + maxAllowedTabWidth = Config.Skin.TabMaxWidth; + minAllowedTabWidth = Config.Skin.TabMinWidth; } + itemSize = new Size(minAllowedTabWidth, Config.Skin.TabHeight); fActiveTxtBold = Config.Skin.ActiveTabInBold; fForceClassic = Config.Skin.UseTabSkin; SetFont(QTUtility.TabFont); - sizingMargin = QTUtility.TabImageSizingMargin + new Padding(0, 0, 1, 1); + sizingMargin = Config.Skin.TabSizeMargin + new Padding(0, 0, 1, 1); if(Config.Skin.UseTabSkin && Config.Skin.TabImageFile.Length > 0) { SetTabImages(QTTabBarClass.CreateTabImage()); } else { SetTabImages(null); } - tabTextAlignment = Config.AlignTabTextCenter ? StringAlignment.Center : StringAlignment.Near; + tabTextAlignment = Config.Skin.TabTextCentered ? StringAlignment.Center : StringAlignment.Near; fAutoSubText = Config.Tabs.RenameAmbTabs; fDrawShadow = Config.Skin.TabTitleShadows; fDrawCloseButton = Config.Tabs.ShowCloseButtons && !Config.Tabs.CloseBtnsWithAlt; Modified: branches/options/QTTabBar/RebarController.cs =================================================================== --- branches/options/QTTabBar/RebarController.cs 2011-11-17 19:21:29 UTC (rev 350) +++ branches/options/QTTabBar/RebarController.cs 2011-11-19 00:34:49 UTC (rev 351) @@ -269,13 +269,13 @@ default: // Full // todo: make this a function graphics.PixelOffsetMode = PixelOffsetMode.HighQuality; - Margin margin = Config.Skin.RebarSizeMargin; + Padding margin = Config.Skin.RebarSizeMargin; int left = margin.Left; int top = margin.Top; int right = margin.Right; int bottom = margin.Bottom; - int vertical = margin.Top + margin.Bottom; - int horizontal = margin.Left + margin.Right; + int vertical = margin.Vertical; + int horizontal = margin.Horizontal; int width = bmpRebar.Width; int height = bmpRebar.Height; Rectangle[] dstRects = new Rectangle[] { This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <mas...@us...> - 2011-11-19 04:27:16
|
Revision: 352 http://qttabbar.svn.sourceforge.net/qttabbar/?rev=352&view=rev Author: masamunexgp Date: 2011-11-19 04:27:10 +0000 (Sat, 19 Nov 2011) Log Message: ----------- Small fix regarding tab sizing. A full implementation of the Same Size sizing mode will take a little more work than anticipated. Modified Paths: -------------- branches/options/QTTabBar/OptionsDialog.xaml branches/options/QTTabBar/QTabControl.cs Modified: branches/options/QTTabBar/OptionsDialog.xaml =================================================================== --- branches/options/QTTabBar/OptionsDialog.xaml 2011-11-19 00:34:49 UTC (rev 351) +++ branches/options/QTTabBar/OptionsDialog.xaml 2011-11-19 04:27:10 UTC (rev 352) @@ -1614,7 +1614,7 @@ Padding="0"/> <qt:Spinner Min="10" - Max="200" + Max="50" Value="{Binding Path=TabMinWidth}"/> <Label Content="Max Width:" @@ -1622,9 +1622,9 @@ Margin="18,0,5,0" Padding="0"/> <qt:Spinner - Min="10" - Max="200" - Value="{Binding Path=TabMaxWith}"/> + Min="50" + Max="999" + Value="{Binding Path=TabMaxWidth}"/> </StackPanel> <Label Content="Sizing mode:" Modified: branches/options/QTTabBar/QTabControl.cs =================================================================== --- branches/options/QTTabBar/QTabControl.cs 2011-11-19 00:34:49 UTC (rev 351) +++ branches/options/QTTabBar/QTabControl.cs 2011-11-19 04:27:10 UTC (rev 352) @@ -1187,13 +1187,13 @@ } else { sizeMode = TabSizeMode.Normal; - fLimitSize = Config.LimitedWidthTabs; + fLimitSize = true; // Config.LimitedWidthTabs; } if((Config.Skin.TabMaxWidth >= Config.Skin.TabMinWidth) && (Config.Skin.TabMinWidth > 9)) { maxAllowedTabWidth = Config.Skin.TabMaxWidth; minAllowedTabWidth = Config.Skin.TabMinWidth; } - itemSize = new Size(minAllowedTabWidth, Config.Skin.TabHeight); + itemSize = new Size(maxAllowedTabWidth, Config.Skin.TabHeight); fActiveTxtBold = Config.Skin.ActiveTabInBold; fForceClassic = Config.Skin.UseTabSkin; SetFont(QTUtility.TabFont); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <mas...@us...> - 2011-12-06 00:55:25
|
Revision: 353 http://qttabbar.svn.sourceforge.net/qttabbar/?rev=353&view=rev Author: masamunexgp Date: 2011-12-06 00:55:18 +0000 (Tue, 06 Dec 2011) Log Message: ----------- Redesigned Tab Text section (again) and implemented Text Font button. Modified Paths: -------------- branches/options/QTTabBar/Config.cs branches/options/QTTabBar/OptionsDialog.xaml branches/options/QTTabBar/OptionsDialog.xaml.cs branches/options/QTTabBar/OptionsDialog_OLD.cs branches/options/QTTabBar/QTUtility.cs branches/options/QTTabBar/QTabControl.cs Modified: branches/options/QTTabBar/Config.cs =================================================================== --- branches/options/QTTabBar/Config.cs 2011-11-19 04:27:10 UTC (rev 352) +++ branches/options/QTTabBar/Config.cs 2011-12-06 00:55:18 UTC (rev 353) @@ -23,11 +23,36 @@ using System.Runtime.Serialization.Json; using System.Text; using System.Linq; +using System.Windows.Forms; using Microsoft.Win32; using Padding = System.Windows.Forms.Padding; namespace QTTabBarLib { + // Wrapper class to get around Font serialization stupidity + [Serializable] + public class XmlSerializableFont { + public string FontName { get; set; } + public float FontSize { get; set; } + public FontStyle FontStyle { get; set; } + + public static XmlSerializableFont FromFont(Font font) { + return font == null ? null : new XmlSerializableFont + {FontName = font.Name, FontSize = font.Size, FontStyle = font.Style}; + } + + public Font ToFont() { + return ToFont(this); + } + + public static Font ToFont(XmlSerializableFont xmlSerializableFont) { + return new Font( + xmlSerializableFont.FontName, + xmlSerializableFont.FontSize, + xmlSerializableFont.FontStyle); + } + } + public enum TabPos { Rightmost, Right, @@ -321,6 +346,7 @@ ShowPreviewInfo = true; PreviewMaxWidth = 512; PreviewMaxHeight = 256; + PreviewFont = Control.DefaultFont; } } @@ -388,6 +414,7 @@ TabMinWidth = 70; // TODO TabMaxWidth = 150; // TODO FixedWidthTabs = false; + TabTextFont = Control.DefaultFont; TabTextActiveColor = Color.Black; TabTextInactiveColor = Color.Black; TabTextHotColor = Color.Black; @@ -572,9 +599,16 @@ prop.SetValue(val, Enum.Parse(t, obj.ToString()), null); } else { - DataContractJsonSerializer ser = new DataContractJsonSerializer(t); using(MemoryStream stream = new MemoryStream(Encoding.UTF8.GetBytes(obj.ToString()))) { - prop.SetValue(val, ser.ReadObject(stream), null); + if(t == typeof(Font)) { + DataContractJsonSerializer ser = new DataContractJsonSerializer(typeof(XmlSerializableFont)); + XmlSerializableFont xsf = ser.ReadObject(stream) as XmlSerializableFont; + prop.SetValue(val, xsf == null ? null : xsf.ToFont(), null); + } + else { + DataContractJsonSerializer ser = new DataContractJsonSerializer(t); + prop.SetValue(val, ser.ReadObject(stream), null); + } } } } @@ -593,7 +627,8 @@ if(Config.Skin.TabHeight < 10) { Config.Skin.TabHeight = 10; } - + Config.Skin.TabTextFont = Config.Skin.TabTextFont ?? Control.DefaultFont; + Config.Tips.PreviewFont = Config.Tips.PreviewFont ?? Control.DefaultFont; } public static void WriteConfig() { const string RegPath = RegConst.Root + RegConst.Config; @@ -612,9 +647,19 @@ key.SetValue(prop.Name, prop.GetValue(val, null)); } else { + object obj = prop.GetValue(val, null); + if(t == typeof(Font)) { + obj = XmlSerializableFont.FromFont((Font)obj); + t = typeof(XmlSerializableFont); + } DataContractJsonSerializer ser = new DataContractJsonSerializer(t); using(MemoryStream stream = new MemoryStream()) { - ser.WriteObject(stream, prop.GetValue(val, null)); + try { + ser.WriteObject(stream, obj); + } + catch(Exception e) { + QTUtility2.MakeErrorLog(e); + } stream.Position = 0; StreamReader reader = new StreamReader(stream); key.SetValue(prop.Name, reader.ReadToEnd()); Modified: branches/options/QTTabBar/OptionsDialog.xaml =================================================================== --- branches/options/QTTabBar/OptionsDialog.xaml 2011-11-19 04:27:10 UTC (rev 352) +++ branches/options/QTTabBar/OptionsDialog.xaml 2011-12-06 00:55:18 UTC (rev 353) @@ -1662,42 +1662,79 @@ <ColumnDefinition Width="Auto"/> <ColumnDefinition Width="Auto"/> <ColumnDefinition Width="Auto"/> + <ColumnDefinition Width="Auto"/> + <ColumnDefinition Width="*"/> </Grid.ColumnDefinitions> - <Button - Content="Choose Text Colors ▼" - Height="23" - Margin="0, 0, 20, 10" - Width="140" + <CheckBox x:Name="chkTextShadow" + Grid.Row="1" + Content="" + IsChecked="{Binding Path=TabTitleShadows}" VerticalAlignment="Center"/> - <Button - Content="Choose Text Font..." + <Label + Content="Text Colors:" Grid.Column="1" + Height="16" + Padding="0"/> + <Label + Content="Shadow Colors:" + Grid.Column="1" + Grid.Row="1" + Height="16" + Padding="0"/> + <ToggleButton + Content="▼" + Grid.Column="2" Height="23" - Margin="0, 0, 20, 10" + HorizontalAlignment="Left" + Margin="10, 5" Width="140" VerticalAlignment="Center"/> - <qt:RadioButtonEx x:Name="radTabTextCenteredNo" - Content="Left Aligned" + <ToggleButton + Content="▼" Grid.Column="2" - Grid.Row="0" - Height="16" - IsChecked="{Binding Path=TabTextCentered, Converter={StaticResource BoolInverterConverter}}" + Grid.Row="1" + Height="23" + HorizontalAlignment="Left" + Margin="10, 5" + Width="140" VerticalAlignment="Center"/> - <qt:RadioButtonEx x:Name="radTabTextCenteredYes" - Content="Center Aligned" - Grid.Column="2" - Grid.Row="1" + <Label + Content="Text Font:" + Grid.Column="3" Height="16" - IsChecked="{Binding Path=TabTextCentered}" - VerticalAlignment="Center"/> - <CheckBox x:Name="chkTabTitleShadows" - Content="Text Drop Shadow" + Padding="0"/> + <Label + Content="Alignment:" + Grid.Column="3" Grid.Row="1" - Grid.Column="1" Height="16" - HorizontalAlignment="Left" - IsChecked="{Binding Path=TabTitleShadows}" + Padding="0"/> + <Button x:Name="btnTextFont" + Click="btnTextFont_Click" + Content="Trebuchet MS, 12 pt" + Grid.Column="4" + Grid.Row="0" + Height="23" + HorizontalAlignment="Stretch" + Margin="10, 5" VerticalAlignment="Center"/> + <StackPanel + Orientation="Horizontal" + Grid.Column="4" + Grid.Row="1"> + <qt:RadioButtonEx x:Name="radTabTextCenteredNo" + Content="Left" + Height="16" + IsChecked="{Binding Path=TabTextCentered, Converter={StaticResource BoolInverterConverter}}" + Margin="10, 5" + VerticalAlignment="Center"/> + <qt:RadioButtonEx x:Name="radTabTextCenteredYes" + Content="Center" + Height="16" + IsChecked="{Binding Path=TabTextCentered}" + Margin="10, 5" + VerticalAlignment="Center"/> + </StackPanel> </Grid> <Label Content="Toolbar Background" Modified: branches/options/QTTabBar/OptionsDialog.xaml.cs =================================================================== --- branches/options/QTTabBar/OptionsDialog.xaml.cs 2011-11-19 04:27:10 UTC (rev 352) +++ branches/options/QTTabBar/OptionsDialog.xaml.cs 2011-12-06 00:55:18 UTC (rev 353) @@ -385,6 +385,9 @@ CreatePluginEntry(assembly, false); } lstPluginView.ItemsSource = CurrentPlugins; + + Font font = workingConfig.skin.TabTextFont; + btnTextFont.Content = string.Format("{0}, {1} pt", font.Name, font.SizeInPoints); } public void Dispose() { @@ -1925,6 +1928,19 @@ workingConfig.skin.RebarColor = cd.Color; } } + + private void btnTextFont_Click(object sender, RoutedEventArgs e) { + using(FontDialog dialog = new FontDialog()) { + dialog.Font = workingConfig.skin.TabTextFont; + dialog.ShowEffects = false; + dialog.AllowVerticalFonts = false; + if(System.Windows.Forms.DialogResult.OK == dialog.ShowDialog()) { + Font font = dialog.Font; + workingConfig.skin.TabTextFont = font; + btnTextFont.Content = string.Format("{0}, {1} pt", font.Name, Math.Round(font.SizeInPoints)); + } + } + } } #region ---------- Converters ---------- Modified: branches/options/QTTabBar/OptionsDialog_OLD.cs =================================================================== --- branches/options/QTTabBar/OptionsDialog_OLD.cs 2011-11-19 04:27:10 UTC (rev 352) +++ branches/options/QTTabBar/OptionsDialog_OLD.cs 2011-12-06 00:55:18 UTC (rev 353) @@ -4173,7 +4173,7 @@ InitializeTreeView_Group(); QTUtility.RefreshUserAppDic(false); InitializeTreeView_UserApps(); - btnTabFont.Font = QTUtility.TabFont; + ///btnTabFont.Font = QTUtility.TabFont; if(Config.HideMenuBar) { chbHideMenu.Checked = true; } @@ -4676,12 +4676,12 @@ if((tabFont != null) && !tabFont.Equals(DefaultFont)) { key.SetValue("TabFont", tabFont.Name); key.SetValue("TabFontSize", tabFont.SizeInPoints.ToString()); - QTUtility.TabFont = tabFont; + //QTUtility.TabFont = tabFont; } else { key.DeleteValue("TabFont", false); key.DeleteValue("TabFontSize", false); - QTUtility.TabFont = null; + //QTUtility.TabFont = null; } //key.SetValue("TabImage", QTUtility.Path_TabImage); byte[] buffer = new byte[] { (byte)Config.Skin.TabSizeMargin.Left, (byte)Config.Skin.TabSizeMargin.Top, (byte)Config.Skin.TabSizeMargin.Right, (byte)Config.Skin.TabSizeMargin.Bottom }; Modified: branches/options/QTTabBar/QTUtility.cs =================================================================== --- branches/options/QTTabBar/QTUtility.cs 2011-11-19 04:27:10 UTC (rev 352) +++ branches/options/QTTabBar/QTUtility.cs 2011-12-06 00:55:18 UTC (rev 353) @@ -97,7 +97,6 @@ internal static List<string> StartUpGroupList = new List<string>(); internal static string StartUpGroupNameNowOpening = string.Empty; internal static Font StartUpTabFont; - internal static Font TabFont; internal static Color TabHiliteColor; internal static Color TabTextColor_Active; internal static Color TabTextColor_ActivShdw; @@ -152,16 +151,6 @@ TabTextColor_InAtvShdw = Color.FromArgb(QTUtility2.GetRegistryValueSafe(key, "TitleColorShadowInActv", Color.White.ToArgb())); ShellViewRowCOLORREF_Background = QTUtility2.GetRegistryValueSafe(key, "AlternateColor_Bk", 0xfaf5f1); ShellViewRowCOLORREF_Text = QTUtility2.GetRegistryValueSafe(key, "AlternateColor_Text", QTUtility2.MakeCOLORREF(SystemColors.WindowText)); - string familyName = (string)key.GetValue("TabFont", string.Empty); - string s = (string)key.GetValue("TabFontSize", "0"); - if(float.TryParse(s, out num) && (num != 0f)) { - try { - TabFont = new Font(familyName, num); - } - catch { - TabFont = Control.DefaultFont; - } - } Action_BarDblClick = (string)key.GetValue("Action_BarDblClick", string.Empty); MaxCount_History = QTUtility2.GetRegistryValueSafe(key, "Max_Undo", 0x10); using(RegistryKey key2 = key.CreateSubKey("RecentlyClosed")) { Modified: branches/options/QTTabBar/QTabControl.cs =================================================================== --- branches/options/QTTabBar/QTabControl.cs 2011-11-19 04:27:10 UTC (rev 352) +++ branches/options/QTTabBar/QTabControl.cs 2011-12-06 00:55:18 UTC (rev 353) @@ -1196,7 +1196,7 @@ itemSize = new Size(maxAllowedTabWidth, Config.Skin.TabHeight); fActiveTxtBold = Config.Skin.ActiveTabInBold; fForceClassic = Config.Skin.UseTabSkin; - SetFont(QTUtility.TabFont); + SetFont(Config.Skin.TabTextFont); sizingMargin = Config.Skin.TabSizeMargin + new Padding(0, 0, 1, 1); if(Config.Skin.UseTabSkin && Config.Skin.TabImageFile.Length > 0) { SetTabImages(QTTabBarClass.CreateTabImage()); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <mas...@us...> - 2011-12-06 20:43:40
|
Revision: 354 http://qttabbar.svn.sourceforge.net/qttabbar/?rev=354&view=rev Author: masamunexgp Date: 2011-12-06 20:43:33 +0000 (Tue, 06 Dec 2011) Log Message: ----------- Implemented Text and Shadow Color controls. I'm finally satisfied with this section! Modified Paths: -------------- branches/options/QTTabBar/OptionsDialog.xaml branches/options/QTTabBar/OptionsDialog.xaml.cs branches/options/QTTabBar/OptionsDialog_OLD.cs branches/options/QTTabBar/QTUtility.cs branches/options/QTTabBar/QTabControl.cs Modified: branches/options/QTTabBar/OptionsDialog.xaml =================================================================== --- branches/options/QTTabBar/OptionsDialog.xaml 2011-12-06 00:55:18 UTC (rev 353) +++ branches/options/QTTabBar/OptionsDialog.xaml 2011-12-06 20:43:33 UTC (rev 354) @@ -36,6 +36,8 @@ <BooleanToVisibilityConverter x:Key="BooleanToVisibilityConverter"/> <qt:LevelToIndentConverter x:Key="LevelIndentConverter"/> <qt:ObjectToClassNameConverter x:Key="ObjectToClassNameConverter"/> + <qt:ColorToBrushConverter x:Key="ColorToBrushConverter"/> + <qt:FontStringConverter x:Key="FontStringConverter"/> <Style x:Key="SectionHeaderStyle" TargetType="Label"> <Setter Property="Background" Value="#FFF0F2F5"/> @@ -1222,7 +1224,7 @@ Height="16" Padding="0"/> <Button - Content="Microsoft Sans Serif, 8.25pt" + Content="{Binding Path=PreviewFont, Converter={StaticResource FontStringConverter}}" Height="23" Margin="8,1" Width="250"/> @@ -1654,6 +1656,15 @@ Style="{StaticResource SectionHeaderStyle}"/> <Grid Margin="13,1,0,1"> + <Grid.Resources> + <Style x:Key="ColorTileStyle" TargetType="Rectangle"> + <Setter Property="Stroke" Value="Black"/> + <Setter Property="StrokeThickness" Value="1"/> + <Setter Property="Height" Value="16"/> + <Setter Property="Width" Value="16"/> + <Setter Property="Margin" Value="4,0"/> + </Style> + </Grid.Resources> <Grid.RowDefinitions> <RowDefinition Height="Auto"/> <RowDefinition Height="Auto"/> @@ -1681,23 +1692,115 @@ Grid.Row="1" Height="16" Padding="0"/> - <ToggleButton - Content="▼" + <ToggleButton x:Name="btnTabTextColor" + Checked="btnShadTextColor_OnChecked" + ContextMenuService.Placement="Bottom" Grid.Column="2" Height="23" HorizontalAlignment="Left" - Margin="10, 5" - Width="140" - VerticalAlignment="Center"/> - <ToggleButton - Content="▼" + HorizontalContentAlignment="Stretch" + IsChecked="{Binding ElementName=ctxTabTextColor, Path=IsOpen, Mode=TwoWay}" + Margin="10, 5, 30, 5" + Width="100" + VerticalAlignment="Center"> + <DockPanel LastChildFill="True"> + <TextBlock + DockPanel.Dock="Right" + HorizontalAlignment="Right" + Margin="4,0" + Text="▼"/> + <StackPanel + HorizontalAlignment="Center" + Margin="0,1,0,0" + Orientation="Horizontal" + SnapsToDevicePixels="True"> + <Rectangle x:Name="rectTabTextActiveColor" + Style="{StaticResource ColorTileStyle}" + Fill="{Binding Path=Tag, RelativeSource={RelativeSource Self}, Converter={StaticResource ColorToBrushConverter}}" + Tag="{Binding Path=TabTextActiveColor, Mode=TwoWay}"/> + <Rectangle x:Name="rectTabTextInactiveColor" + Style="{StaticResource ColorTileStyle}" + Fill="{Binding Path=Tag, RelativeSource={RelativeSource Self}, Converter={StaticResource ColorToBrushConverter}}" + Tag="{Binding Path=TabTextInactiveColor, Mode=TwoWay}"/> + <Rectangle x:Name="rectTabTextHotColor" + Style="{StaticResource ColorTileStyle}" + Fill="{Binding Path=Tag, RelativeSource={RelativeSource Self}, Converter={StaticResource ColorToBrushConverter}}" + Tag="{Binding Path=TabTextHotColor, Mode=TwoWay}"/> + </StackPanel> + </DockPanel> + <ToggleButton.ContextMenu> + <ContextMenu x:Name="ctxTabTextColor" + PlacementTarget="{Binding ElementName=btnTabTextColor}"> + <MenuItem x:Name="miTabTextActiveColor" + Click="miColorMenuEntry_OnClick" + Header="Active Color" + Tag="{Binding ElementName=rectTabTextActiveColor}"/> + <MenuItem x:Name="miTabTextInactiveColor" + Click="miColorMenuEntry_OnClick" + Header="Inactive Color" + Tag="{Binding ElementName=rectTabTextInactiveColor}"/> + <MenuItem x:Name="miTabTextHotColor" + Click="miColorMenuEntry_OnClick" + Header="Mouseover Color" + Tag="{Binding ElementName=rectTabTextHotColor}"/> + </ContextMenu> + </ToggleButton.ContextMenu> + </ToggleButton> + <ToggleButton x:Name="btnShadowColor" + Checked="btnShadTextColor_OnChecked" + ContextMenuService.Placement="Bottom" + Grid.Row="1" Grid.Column="2" - Grid.Row="1" Height="23" HorizontalAlignment="Left" - Margin="10, 5" - Width="140" - VerticalAlignment="Center"/> + HorizontalContentAlignment="Stretch" + IsChecked="{Binding ElementName=ctxShadowTextColor, Path=IsOpen, Mode=TwoWay}" + Margin="10, 5, 30, 5" + Width="100" + VerticalAlignment="Center"> + <DockPanel LastChildFill="True"> + <TextBlock + DockPanel.Dock="Right" + HorizontalAlignment="Right" + Margin="4,0" + Text="▼"/> + <StackPanel + HorizontalAlignment="Center" + Margin="0,1,0,0" + Orientation="Horizontal" + SnapsToDevicePixels="True"> + <Rectangle x:Name="rectTabShadActiveColor" + Style="{StaticResource ColorTileStyle}" + Fill="{Binding Path=Tag, RelativeSource={RelativeSource Self}, Converter={StaticResource ColorToBrushConverter}}" + Tag="{Binding Path=TabShadActiveColor, Mode=TwoWay}"/> + <Rectangle x:Name="rectTabShadInactiveColor" + Style="{StaticResource ColorTileStyle}" + Fill="{Binding Path=Tag, RelativeSource={RelativeSource Self}, Converter={StaticResource ColorToBrushConverter}}" + Tag="{Binding Path=TabShadInactiveColor, Mode=TwoWay}"/> + <Rectangle x:Name="rectTabShadMouseoverColor" + Style="{StaticResource ColorTileStyle}" + Fill="{Binding Path=Tag, RelativeSource={RelativeSource Self}, Converter={StaticResource ColorToBrushConverter}}" + Tag="{Binding Path=TabShadHotColor, Mode=TwoWay}"/> + </StackPanel> + </DockPanel> + <ToggleButton.ContextMenu> + <ContextMenu x:Name="ctxShadowTextColor" + PlacementTarget="{Binding ElementName=btnTabTextColor}"> + <MenuItem x:Name="miTabShadActiveColor" + Click="miColorMenuEntry_OnClick" + Header="Active Color" + Tag="{Binding ElementName=rectTabShadActiveColor}"/> + <MenuItem x:Name="miTabShadInactiveColor" + Click="miColorMenuEntry_OnClick" + Header="Inactive Color" + Tag="{Binding ElementName=rectTabShadInactiveColor}"/> + <MenuItem x:Name="miTabShadMouseoverColor" + Click="miColorMenuEntry_OnClick" + Header="Mouseover Color" + Tag="{Binding ElementName=rectTabShadMouseoverColor}"/> + </ContextMenu> + </ToggleButton.ContextMenu> + </ToggleButton> <Label Content="Text Font:" Grid.Column="3" @@ -1711,7 +1814,7 @@ Padding="0"/> <Button x:Name="btnTextFont" Click="btnTextFont_Click" - Content="Trebuchet MS, 12 pt" + Content="{Binding Path=TabTextFont, Converter={StaticResource FontStringConverter}}" Grid.Column="4" Grid.Row="0" Height="23" Modified: branches/options/QTTabBar/OptionsDialog.xaml.cs =================================================================== --- branches/options/QTTabBar/OptionsDialog.xaml.cs 2011-12-06 00:55:18 UTC (rev 353) +++ branches/options/QTTabBar/OptionsDialog.xaml.cs 2011-12-06 20:43:33 UTC (rev 354) @@ -19,37 +19,28 @@ using System.Collections.Generic; using System.Collections.ObjectModel; using System.ComponentModel; -using System.Diagnostics; -using System.Drawing; using System.Globalization; using System.Linq; using System.Reflection; using System.Threading; using System.Windows; using System.Windows.Controls; +using System.Windows.Controls.Primitives; using System.Windows.Data; -using System.Windows.Forms; using System.Windows.Input; using System.Windows.Interop; using System.Windows.Media; using System.Windows.Media.Imaging; +using System.Windows.Shapes; using QTPlugin; using QTTabBarLib.Interop; -using Binding = System.Windows.Data.Binding; +using Microsoft.Win32; using Image = System.Drawing.Image; -using RadioButton = System.Windows.Controls.RadioButton; using Size = System.Drawing.Size; -using Brush = System.Windows.Media.Brushes; -using Color = System.Windows.Media.Color; -//using MessageBox = System.Windows.Forms.MessageBox; -using MessageBox = System.Windows.MessageBox; -using KeyEventArgs = System.Windows.Input.KeyEventArgs; -using Orientation = System.Windows.Controls.Orientation; -using TextBox = System.Windows.Controls.TextBox; -using Microsoft.Win32; +using Font = System.Drawing.Font; +using Bitmap = System.Drawing.Bitmap; using OpenFileDialog = System.Windows.Forms.OpenFileDialog; -using TreeView = System.Windows.Controls.TreeView; -using System.Windows.Controls.Primitives; +using Keys = System.Windows.Forms.Keys; namespace QTTabBarLib { /// <summary> @@ -386,8 +377,10 @@ } lstPluginView.ItemsSource = CurrentPlugins; - Font font = workingConfig.skin.TabTextFont; - btnTextFont.Content = string.Format("{0}, {1} pt", font.Name, font.SizeInPoints); + // Took me forever to figure out that this was necessary. Why isn't this the default?!! + // Bindings in context menus won't work without this. + NameScope.SetNameScope(ctxTabTextColor, NameScope.GetNameScope(this)); + NameScope.SetNameScope(ctxShadowTextColor, NameScope.GetNameScope(this)); } public void Dispose() { @@ -468,6 +461,7 @@ #region ---------- Tweaks ---------- + // TODO: rethink this private void btnBackgroundColor_Click(object sender, RoutedEventArgs e) { ColorDialogEx cd = new ColorDialogEx(); if(System.Windows.Forms.DialogResult.OK == cd.ShowDialog()) { @@ -1914,7 +1908,7 @@ workingConfig.bbar.ImageStripPath = ""; } - private sealed class ColorDialogEx : ColorDialog { + private sealed class ColorDialogEx : System.Windows.Forms.ColorDialog { protected override int Options { get { return (base.Options | 2); @@ -1930,17 +1924,53 @@ } private void btnTextFont_Click(object sender, RoutedEventArgs e) { - using(FontDialog dialog = new FontDialog()) { + using(var dialog = new System.Windows.Forms.FontDialog()) { dialog.Font = workingConfig.skin.TabTextFont; dialog.ShowEffects = false; dialog.AllowVerticalFonts = false; if(System.Windows.Forms.DialogResult.OK == dialog.ShowDialog()) { Font font = dialog.Font; workingConfig.skin.TabTextFont = font; - btnTextFont.Content = string.Format("{0}, {1} pt", font.Name, Math.Round(font.SizeInPoints)); + btnTextFont.GetBindingExpression(ContentProperty).UpdateTarget(); } } } + + // Draws a control to a bitmap + private static BitmapSource ConvertToBitmapSource(UIElement element) { + var target = new RenderTargetBitmap((int)(element.RenderSize.Width), (int)(element.RenderSize.Height), 96, 96, PixelFormats.Pbgra32); + var brush = new VisualBrush(element); + var visual = new DrawingVisual(); + var drawingContext = visual.RenderOpen(); + + drawingContext.DrawRectangle(brush, null, new Rect(new Point(0, 0), + new Point(element.RenderSize.Width, element.RenderSize.Height))); + drawingContext.Close(); + target.Render(visual); + return target; + } + + private void btnShadTextColor_OnChecked(object sender, RoutedEventArgs e) { + var button = ((ToggleButton)sender); + ContextMenu menu = button.ContextMenu; + foreach(MenuItem mi in menu.Items) { + mi.Icon = new System.Windows.Controls.Image { Source = ConvertToBitmapSource((Rectangle)mi.Tag) }; + } + // Yeah, this is necessary even with the IsChecked <=> IsOpen binding. + // Not sure why. + menu.PlacementTarget = button; + menu.Placement = PlacementMode.Bottom; + menu.IsOpen = true; + } + + private void miColorMenuEntry_OnClick(object sender, RoutedEventArgs e) { + var mi = (MenuItem)sender; + var rect = (Rectangle)mi.Tag; + ColorDialogEx cd = new ColorDialogEx { Color = (System.Drawing.Color)rect.Tag }; + if(System.Windows.Forms.DialogResult.OK == cd.ShowDialog()) { + rect.Tag = cd.Color; + } + } } #region ---------- Converters ---------- @@ -2011,6 +2041,30 @@ } } + [ValueConversion(typeof(System.Drawing.Color), typeof(Brush))] + public class ColorToBrushConverter : IValueConverter { + public object Convert(object value, Type targetType, object parameter, CultureInfo culture) { + var c = (System.Drawing.Color)(value ?? System.Drawing.Color.Red); + return new SolidColorBrush(Color.FromArgb(c.A, c.R, c.G, c.B)); + } + + public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture) { + throw new NotSupportedException(); + } + } + + [ValueConversion(typeof(Font), typeof(string))] + public class FontStringConverter : IValueConverter { + public object Convert(object value, Type targetType, object parameter, CultureInfo culture) { + Font font = (Font)value; + return string.Format("{0}, {1} pt", font.Name, Math.Round(font.SizeInPoints)); + } + + public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture) { + throw new NotSupportedException(); + } + } + /// <summary> /// Convert Level to left margin /// Pass a prarameter if you want a unit length other than 19.0. Modified: branches/options/QTTabBar/OptionsDialog_OLD.cs =================================================================== --- branches/options/QTTabBar/OptionsDialog_OLD.cs 2011-12-06 00:55:18 UTC (rev 353) +++ branches/options/QTTabBar/OptionsDialog_OLD.cs 2011-12-06 20:43:33 UTC (rev 354) @@ -4160,12 +4160,12 @@ } else { nudTabWidth.Value = QTUtility.TabWidth; - }*/ + } btnActTxtClr.ForeColor = QTUtility.TabTextColor_Active; btnInactTxtClr.ForeColor = QTUtility.TabTextColor_Inactv; btnHiliteClsc.ForeColor = QTUtility.TabHiliteColor; btnShadowAct.ForeColor = QTUtility.TabTextColor_ActivShdw; - btnShadowIna.ForeColor = QTUtility.TabTextColor_InAtvShdw; + btnShadowIna.ForeColor = QTUtility.TabTextColor_InAtvShdw;*/ chbTabTitleShadow.Checked = Config.Skin.TabTitleShadows; btnShadowAct.Enabled = btnShadowIna.Enabled = chbTabTitleShadow.Checked; textBoxAction_BarDblClck.Text = QTUtility.Action_BarDblClick; @@ -4660,11 +4660,11 @@ //key.SetValue("TabHeight", Config.Skin.TabHeight); key.SetValue("TabWidthMax", Config.Skin.TabMaxWidth); key.SetValue("TabWidthMin", Config.Skin.TabMinWidth); - key.SetValue("TitleColorActive", QTUtility.TabTextColor_Active.ToArgb()); - key.SetValue("TitleColorInactive", QTUtility.TabTextColor_Inactv.ToArgb()); - key.SetValue("HighlightColorClassic", QTUtility.TabHiliteColor.ToArgb()); - key.SetValue("TitleColorShadowActive", QTUtility.TabTextColor_ActivShdw.ToArgb()); - key.SetValue("TitleColorShadowInActv", QTUtility.TabTextColor_InAtvShdw.ToArgb()); + //key.SetValue("TitleColorActive", QTUtility.TabTextColor_Active.ToArgb()); + //key.SetValue("TitleColorInactive", QTUtility.TabTextColor_Inactv.ToArgb()); + //key.SetValue("HighlightColorClassic", QTUtility.TabHiliteColor.ToArgb()); + //key.SetValue("TitleColorShadowActive", QTUtility.TabTextColor_ActivShdw.ToArgb()); + //key.SetValue("TitleColorShadowInActv", QTUtility.TabTextColor_InAtvShdw.ToArgb()); //key.SetValue("ToolbarBGColor", QTUtility.RebarBGColor.ToArgb()); key.SetValue("AlternateColor_Bk", QTUtility.ShellViewRowCOLORREF_Background); key.SetValue("AlternateColor_Text", QTUtility.ShellViewRowCOLORREF_Text); Modified: branches/options/QTTabBar/QTUtility.cs =================================================================== --- branches/options/QTTabBar/QTUtility.cs 2011-12-06 00:55:18 UTC (rev 353) +++ branches/options/QTTabBar/QTUtility.cs 2011-12-06 20:43:33 UTC (rev 354) @@ -97,11 +97,6 @@ internal static List<string> StartUpGroupList = new List<string>(); internal static string StartUpGroupNameNowOpening = string.Empty; internal static Font StartUpTabFont; - internal static Color TabHiliteColor; - internal static Color TabTextColor_Active; - internal static Color TabTextColor_ActivShdw; - internal static Color TabTextColor_Inactv; - internal static Color TabTextColor_InAtvShdw; internal static Dictionary<string, string[]> TextResourcesDic; internal static List<byte[]> TMPIDLList = new List<byte[]>(); internal static List<string> TMPPathList = new List<string>(); @@ -144,11 +139,6 @@ Path_LanguageFile = string.Empty; } ValidateTextResources(); - TabTextColor_Active = Color.FromArgb(QTUtility2.GetRegistryValueSafe(key, "TitleColorActive", SystemColors.ControlText.ToArgb())); - TabTextColor_Inactv = Color.FromArgb(QTUtility2.GetRegistryValueSafe(key, "TitleColorInactive", SystemColors.ControlText.ToArgb())); - TabHiliteColor = Color.FromArgb(QTUtility2.GetRegistryValueSafe(key, "HighlightColorClassic", SystemColors.Highlight.ToArgb())); - TabTextColor_ActivShdw = Color.FromArgb(QTUtility2.GetRegistryValueSafe(key, "TitleColorShadowActive", Color.Silver.ToArgb())); - TabTextColor_InAtvShdw = Color.FromArgb(QTUtility2.GetRegistryValueSafe(key, "TitleColorShadowInActv", Color.White.ToArgb())); ShellViewRowCOLORREF_Background = QTUtility2.GetRegistryValueSafe(key, "AlternateColor_Bk", 0xfaf5f1); ShellViewRowCOLORREF_Text = QTUtility2.GetRegistryValueSafe(key, "AlternateColor_Text", QTUtility2.MakeCOLORREF(SystemColors.WindowText)); Action_BarDblClick = (string)key.GetValue("Action_BarDblClick", string.Empty); Modified: branches/options/QTTabBar/QTabControl.cs =================================================================== --- branches/options/QTTabBar/QTabControl.cs 2011-12-06 00:55:18 UTC (rev 353) +++ branches/options/QTTabBar/QTabControl.cs 2011-12-06 20:43:33 UTC (rev 354) @@ -116,7 +116,14 @@ sfTypoGraphic = StringFormat.GenericTypographic; sfTypoGraphic.FormatFlags |= StringFormatFlags.NoWrap; sfTypoGraphic.Trimming = StringTrimming.EllipsisCharacter; - colorSet = new Color[] { QTUtility.TabTextColor_Active, QTUtility.TabTextColor_Inactv, QTUtility.TabHiliteColor, QTUtility.TabTextColor_ActivShdw, QTUtility.TabTextColor_InAtvShdw }; + colorSet = new Color[] { + Config.Skin.TabTextActiveColor, + Config.Skin.TabTextInactiveColor, + Config.Skin.TabTextHotColor, + Config.Skin.TabShadActiveColor, + Config.Skin.TabShadInactiveColor, + Config.Skin.TabShadHotColor + }; brshActive = new SolidBrush(colorSet[0]); brshInactv = new SolidBrush(colorSet[1]); timerSuppressDoubleClick = new Timer(components); @@ -509,7 +516,7 @@ private static void DrawDriveLetter(Graphics g, string str, Font fnt, Rectangle rctFldImg, bool fSelected) { Rectangle layoutRectangle = new Rectangle(rctFldImg.X + 7, rctFldImg.Y + 6, 0x10, 0x10); - using(SolidBrush brush = new SolidBrush(QTUtility2.MakeModColor(fSelected ? QTUtility.TabTextColor_ActivShdw : QTUtility.TabTextColor_InAtvShdw))) { + using(SolidBrush brush = new SolidBrush(QTUtility2.MakeModColor(fSelected ? Config.Skin.TabShadActiveColor : Config.Skin.TabShadInactiveColor))) { Rectangle rectangle2 = layoutRectangle; rectangle2.Offset(1, 0); g.DrawString(str, fnt, brush, rectangle2); @@ -527,7 +534,7 @@ g.DrawString(str, fnt, brush, rectangle2); rectangle2.Offset(0, 2); g.DrawString(str, fnt, brush, rectangle2); - brush.Color = fSelected ? QTUtility.TabTextColor_Active : QTUtility.TabTextColor_Inactv; + brush.Color = fSelected ? Config.Skin.TabTextActiveColor : Config.Skin.TabTextInactiveColor; g.DrawString(str, fnt, brush, layoutRectangle); } } @@ -1176,7 +1183,14 @@ fDrawFolderImg = Config.Tabs.ShowFolderIcon; } else { - colorSet = new Color[] { QTUtility.TabTextColor_Active, QTUtility.TabTextColor_Inactv, QTUtility.TabHiliteColor, QTUtility.TabTextColor_ActivShdw, QTUtility.TabTextColor_InAtvShdw }; + colorSet = new Color[] { + Config.Skin.TabTextActiveColor, + Config.Skin.TabTextInactiveColor, + Config.Skin.TabTextHotColor, + Config.Skin.TabShadActiveColor, + Config.Skin.TabShadInactiveColor, + Config.Skin.TabShadHotColor + }; brshActive.Color = colorSet[0]; brshInactv.Color = colorSet[1]; } @@ -1267,24 +1281,44 @@ if(fntBold != null) { fntBold.Dispose(); } - fntBold = new Font(Font, FontStyle.Bold); + fntBold = Font; + try { + fntBold = new Font(Font, FontStyle.Bold); + } + catch {} if(fnt_Underline != null) { fnt_Underline.Dispose(); } - fnt_Underline = new Font(Font, FontStyle.Underline); + fnt_Underline = Font; + try { + fnt_Underline = new Font(Font, FontStyle.Underline); + } + catch {} if(fntBold_Underline != null) { fntBold_Underline.Dispose(); } - fntBold_Underline = new Font(Font, FontStyle.Underline | FontStyle.Bold); + fntBold_Underline = fntBold; + try { + fntBold_Underline = new Font(fntBold, FontStyle.Underline); + } + catch {} if(fntSubText != null) { fntSubText.Dispose(); } float sizeInPoints = Font.SizeInPoints; - fntSubText = new Font(Font.FontFamily, (sizeInPoints > 8.25f) ? (sizeInPoints - 0.75f) : sizeInPoints); + fntSubText = Font; + try { + fntSubText = new Font(Font.FontFamily, (sizeInPoints > 8.25f) ? (sizeInPoints - 0.75f) : sizeInPoints); + } + catch {} if(fntDriveLetter != null) { fntDriveLetter.Dispose(); } - fntDriveLetter = new Font(Font.FontFamily, 8.25f); + fntDriveLetter = Font; + try { + fntDriveLetter = new Font(Font.FontFamily, 8.25f); + } + catch {} QTabItemBase.TabFont = Font; } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <mas...@us...> - 2011-12-07 00:22:39
|
Revision: 355 http://qttabbar.svn.sourceforge.net/qttabbar/?rev=355&view=rev Author: masamunexgp Date: 2011-12-07 00:22:32 +0000 (Wed, 07 Dec 2011) Log Message: ----------- Fixed alternate row background/foreground color selection on the Tweaks tab. Modified Paths: -------------- branches/options/QTTabBar/Config.cs branches/options/QTTabBar/ExtendedSysListView32.cs branches/options/QTTabBar/OptionsDialog.xaml branches/options/QTTabBar/OptionsDialog.xaml.cs branches/options/QTTabBar/OptionsDialog_OLD.cs branches/options/QTTabBar/QTTabBarClass.cs branches/options/QTTabBar/QTUtility.cs Modified: branches/options/QTTabBar/Config.cs =================================================================== --- branches/options/QTTabBar/Config.cs 2011-12-06 20:43:33 UTC (rev 354) +++ branches/options/QTTabBar/Config.cs 2011-12-07 00:22:32 UTC (rev 355) @@ -302,10 +302,9 @@ public bool ToggleFullRowSelect { get; set; } public bool DetailsGridLines { get; set; } public bool AlternateRowColors { get; set; } - public Color BackgroundColor { get; set; } - public Color TextColor { get; set; } + public Color AltRowBackgroundColor { get; set; } + public Color AltRowForegroundColor { get; set; } - public _Tweaks() { AlwaysShowHeaders = false; KillExtWhileRenaming = true; @@ -318,8 +317,8 @@ ToggleFullRowSelect = false; DetailsGridLines = false; AlternateRowColors = false; - TextColor = new Color(); - BackgroundColor = new Color(); + AltRowForegroundColor = SystemColors.WindowText; + AltRowBackgroundColor = QTUtility2.MakeColor(0xfaf5f1); } } Modified: branches/options/QTTabBar/ExtendedSysListView32.cs =================================================================== --- branches/options/QTTabBar/ExtendedSysListView32.cs 2011-12-06 20:43:33 UTC (rev 354) +++ branches/options/QTTabBar/ExtendedSysListView32.cs 2011-12-07 00:22:32 UTC (rev 355) @@ -455,8 +455,8 @@ if(!QTUtility.IsXP) { int num4 = lstColumnFMT[structure.iSubItem]; - structure.clrTextBk = QTUtility.ShellViewRowCOLORREF_Background; - structure.clrText = QTUtility.ShellViewRowCOLORREF_Text; + structure.clrTextBk = QTUtility2.MakeCOLORREF(Config.Tweaks.AltRowBackgroundColor); + structure.clrText = QTUtility2.MakeCOLORREF(Config.Tweaks.AltRowForegroundColor); Marshal.StructureToPtr(structure, msg.LParam, false); bool drawingHotItem = (dwItemSpec == GetHotItem()); bool fullRowSel = !Config.Tweaks.ToggleFullRowSelect; @@ -475,7 +475,7 @@ if(!fullRowSel || (iListViewItemState & (LVIS.SELECTED | LVIS.DROPHILITED)) == 0) { using(Graphics graphics = Graphics.FromHdc(structure.nmcd.hdc)) { if(QTUtility.sbAlternate == null) { - QTUtility.sbAlternate = new SolidBrush(QTUtility2.MakeColor(QTUtility.ShellViewRowCOLORREF_Background)); + QTUtility.sbAlternate = new SolidBrush(Config.Tweaks.AltRowBackgroundColor); } graphics.FillRectangle(QTUtility.sbAlternate, structure.nmcd.rc.ToRectangle()); } @@ -513,7 +513,7 @@ Marshal.StructureToPtr(lvitem, ptr3, false); PInvoke.SendMessage(ListViewController.Handle, LVM.GETITEM, IntPtr.Zero, ptr3); if(QTUtility.sbAlternate == null) { - QTUtility.sbAlternate = new SolidBrush(QTUtility2.MakeColor(QTUtility.ShellViewRowCOLORREF_Background)); + QTUtility.sbAlternate = new SolidBrush(Config.Tweaks.AltRowBackgroundColor); } using(Graphics graphics2 = Graphics.FromHdc(structure.nmcd.hdc)) { Rectangle rect = rc.ToRectangle(); @@ -601,7 +601,7 @@ PInvoke.SetTextColor(structure.nmcd.hdc, QTUtility2.MakeCOLORREF((fListViewHasFocus || flag4) ? SystemColors.HighlightText : SystemColors.WindowText)); } else { - PInvoke.SetTextColor(structure.nmcd.hdc, QTUtility.ShellViewRowCOLORREF_Text); + PInvoke.SetTextColor(structure.nmcd.hdc, QTUtility2.MakeCOLORREF(Config.Tweaks.AltRowForegroundColor)); } PInvoke.DrawTextExW(structure.nmcd.hdc, lvitem.pszText, -1, ref rc, dwDTFormat, IntPtr.Zero); Marshal.FreeHGlobal(lvitem.pszText); Modified: branches/options/QTTabBar/OptionsDialog.xaml =================================================================== --- branches/options/QTTabBar/OptionsDialog.xaml 2011-12-06 20:43:33 UTC (rev 354) +++ branches/options/QTTabBar/OptionsDialog.xaml 2011-12-07 00:22:32 UTC (rev 355) @@ -1041,7 +1041,7 @@ <TabItem x:Name="tabTweaks" DataContext="{Binding Path=tweaks}" Header="Tweaks" - Width="0" Loaded="tabTweaks_Loaded"> + Width="0"> <StackPanel Margin="14,5,10,0" Orientation="Vertical"> @@ -1109,35 +1109,46 @@ IsChecked="{Binding Path=AlternateRowColors}" IsEnabled="{Binding Path=IsChecked, ElementName=chkForceSysListView}" Style="{StaticResource CheckStyle}"/> - <StackPanel - Orientation="Horizontal"> - <Button x:Name="btnBackgroundColor" - Click="btnBackgroundColor_Click" - Content="Background Color" - Height="23" - Margin="31,2,5,2" - Width="120"> - <Button.IsEnabled> - <MultiBinding Converter="{StaticResource LogicalAndMultiConverter}"> - <Binding Path="IsChecked" ElementName="chkAlternateRowColors"/> - <Binding Path="IsEnabled" ElementName="chkAlternateRowColors"/> - </MultiBinding> - </Button.IsEnabled> - </Button> - <Button x:Name="btnTextColor" - Click="btnTextColor_Click" - Content="Text Color" - Height="23" - Margin="5,2" - Width="120"> - <Button.IsEnabled> - <MultiBinding Converter="{StaticResource LogicalAndMultiConverter}"> - <Binding Path="IsChecked" ElementName="chkAlternateRowColors"/> - <Binding Path="IsEnabled" ElementName="chkAlternateRowColors"/> - </MultiBinding> - </Button.IsEnabled> - </Button> - </StackPanel> + <Grid Margin="31,2,5,2"> + <Grid.IsEnabled> + <MultiBinding Converter="{StaticResource LogicalAndMultiConverter}"> + <Binding Path="IsChecked" ElementName="chkAlternateRowColors"/> + <Binding Path="IsEnabled" ElementName="chkAlternateRowColors"/> + </MultiBinding> + </Grid.IsEnabled> + <Grid.ColumnDefinitions> + <ColumnDefinition Width="Auto"/> + <ColumnDefinition Width="Auto"/> + </Grid.ColumnDefinitions> + <Grid.RowDefinitions> + <RowDefinition Height="Auto"/> + <RowDefinition Height="Auto"/> + </Grid.RowDefinitions> + <Label + Content="Foreground color: " + Grid.Column="0" + Grid.Row="0"/> + <Label + Content="Background color: " + Grid.Column="0" + Grid.Row="1"/> + <Button x:Name="btnAltRowForeground" + Background="{Binding Path=Tag, RelativeSource={RelativeSource Self}, Converter={StaticResource ColorToBrushConverter}}" + Click="btnAltRowColor_Click" + Grid.Column="1" + Grid.Row="0" + Height="22" + Tag="{Binding Path=AltRowForegroundColor, Mode=TwoWay}" + Width="22"/> + <Button x:Name="btnAltRowBackground" + Background="{Binding Path=Tag, RelativeSource={RelativeSource Self}, Converter={StaticResource ColorToBrushConverter}}" + Click="btnAltRowColor_Click" + Grid.Column="1" + Grid.Row="1" + Height="22" + Tag="{Binding Path=AltRowBackgroundColor, Mode=TwoWay}" + Width="22" /> + </Grid> </StackPanel> </TabItem> <TabItem x:Name="tabTooltips" Modified: branches/options/QTTabBar/OptionsDialog.xaml.cs =================================================================== --- branches/options/QTTabBar/OptionsDialog.xaml.cs 2011-12-06 20:43:33 UTC (rev 354) +++ branches/options/QTTabBar/OptionsDialog.xaml.cs 2011-12-07 00:22:32 UTC (rev 355) @@ -461,34 +461,15 @@ #region ---------- Tweaks ---------- - // TODO: rethink this - private void btnBackgroundColor_Click(object sender, RoutedEventArgs e) { - ColorDialogEx cd = new ColorDialogEx(); + private void btnAltRowColor_Click(object sender, RoutedEventArgs e) { + // Works for both buttons. Each button's Tag is bound to the corresponding property. + var button = (Button)sender; + ColorDialogEx cd = new ColorDialogEx { Color = (System.Drawing.Color)button.Tag }; if(System.Windows.Forms.DialogResult.OK == cd.ShowDialog()) { - Config.Tweaks.BackgroundColor = cd.Color; - btnBackgroundColor.Background = new SolidColorBrush(Color.FromArgb( - cd.Color.A, cd.Color.R, cd.Color.G, cd.Color.B)); + button.Tag = cd.Color; } } - private void btnTextColor_Click(object sender, RoutedEventArgs e) { - ColorDialogEx cd = new ColorDialogEx(); - if(System.Windows.Forms.DialogResult.OK == cd.ShowDialog()) { - Config.Tweaks.TextColor = cd.Color; - btnTextColor.Foreground = new SolidColorBrush(Color.FromArgb( - cd.Color.A, cd.Color.R, cd.Color.G, cd.Color.B)); - } - } - - private void tabTweaks_Loaded(object sender, RoutedEventArgs e) { - System.Drawing.Color bg = Config.Tweaks.BackgroundColor; - System.Drawing.Color txt = Config.Tweaks.TextColor; - btnTextColor.Foreground = new SolidColorBrush(Color.FromArgb( - txt.A, txt.R, txt.G, txt.B)); - btnBackgroundColor.Background = new SolidColorBrush(Color.FromArgb( - bg.A, bg.R, bg.G, bg.B)); - } - #endregion #region ---------- Tooltips ---------- Modified: branches/options/QTTabBar/OptionsDialog_OLD.cs =================================================================== --- branches/options/QTTabBar/OptionsDialog_OLD.cs 2011-12-06 20:43:33 UTC (rev 354) +++ branches/options/QTTabBar/OptionsDialog_OLD.cs 2011-12-07 00:22:32 UTC (rev 355) @@ -631,10 +631,10 @@ private void btnAlternateColor_Click(object sender, EventArgs e) { if(sender == btnAlternate_Default) { - QTUtility.ShellViewRowCOLORREF_Background = 0xfaf5f1; + //QTUtility.ShellViewRowCOLORREF_Background = 0xfaf5f1; Color windowText = SystemColors.WindowText; - QTUtility.ShellViewRowCOLORREF_Text = QTUtility2.MakeCOLORREF(windowText); - btnAlternateColor.BackColor = QTUtility2.MakeColor(QTUtility.ShellViewRowCOLORREF_Background); + //QTUtility.ShellViewRowCOLORREF_Text = QTUtility2.MakeCOLORREF(windowText); + //btnAlternateColor.BackColor = QTUtility2.MakeColor(QTUtility.ShellViewRowCOLORREF_Background); btnAlternateColor_Text.ForeColor = windowText; } else { @@ -4196,8 +4196,8 @@ chbGridLine.Checked = (QTUtility.ConfigValues[8] & 0x80) == 0x80; chbNoFulRowSelect.Checked = ((QTUtility.ConfigValues[8] & 0x40) == 0x40) ^ !QTUtility.IsXP; chbAlternateColor.Checked = (QTUtility.ConfigValues[8] & 8) == 8; - btnAlternateColor.BackColor = QTUtility2.MakeColor(QTUtility.ShellViewRowCOLORREF_Background); - btnAlternateColor_Text.ForeColor = QTUtility2.MakeColor(QTUtility.ShellViewRowCOLORREF_Text); + //btnAlternateColor.BackColor = QTUtility2.MakeColor(QTUtility.ShellViewRowCOLORREF_Background); + //btnAlternateColor_Text.ForeColor = QTUtility2.MakeColor(QTUtility.ShellViewRowCOLORREF_Text); btnAlternate_Default.Enabled = btnAlternateColor.Enabled = btnAlternateColor_Text.Enabled = chbAlternateColor.Checked; if(isSupported) { chbRebarBGImage.Checked = (QTUtility.ConfigValues[11] & 0x80) == 0x80; @@ -4666,8 +4666,8 @@ //key.SetValue("TitleColorShadowActive", QTUtility.TabTextColor_ActivShdw.ToArgb()); //key.SetValue("TitleColorShadowInActv", QTUtility.TabTextColor_InAtvShdw.ToArgb()); //key.SetValue("ToolbarBGColor", QTUtility.RebarBGColor.ToArgb()); - key.SetValue("AlternateColor_Bk", QTUtility.ShellViewRowCOLORREF_Background); - key.SetValue("AlternateColor_Text", QTUtility.ShellViewRowCOLORREF_Text); + //key.SetValue("AlternateColor_Bk", QTUtility.ShellViewRowCOLORREF_Background); + //key.SetValue("AlternateColor_Text", QTUtility.ShellViewRowCOLORREF_Text); key.SetValue("Max_Undo", QTUtility.MaxCount_History); key.SetValue("Max_RecentFile", QTUtility.MaxCount_Executed); key.SetValue("PreviewMaxWidth", QTUtility.PreviewMaxWidth); Modified: branches/options/QTTabBar/QTTabBarClass.cs =================================================================== --- branches/options/QTTabBar/QTTabBarClass.cs 2011-12-06 20:43:33 UTC (rev 354) +++ branches/options/QTTabBar/QTTabBarClass.cs 2011-12-07 00:22:32 UTC (rev 355) @@ -4832,7 +4832,7 @@ SetBarRows(tabControl1.SetTabRowType(iType)); rebarController.RefreshBG(); if(Config.Tweaks.AlternateRowColors) { - Color color = QTUtility2.MakeColor(QTUtility.ShellViewRowCOLORREF_Background); + Color color = Config.Tweaks.AltRowBackgroundColor; if(QTUtility.sbAlternate == null) { QTUtility.sbAlternate = new SolidBrush(color); } Modified: branches/options/QTTabBar/QTUtility.cs =================================================================== --- branches/options/QTTabBar/QTUtility.cs 2011-12-06 20:43:33 UTC (rev 354) +++ branches/options/QTTabBar/QTUtility.cs 2011-12-07 00:22:32 UTC (rev 355) @@ -92,8 +92,6 @@ internal static SolidBrush sbAlternate; internal static readonly char[] SEPARATOR_CHAR = new char[] { ';' }; internal const string SEPARATOR_PATH_HASH_SESSION = "*?*?*"; - internal static int ShellViewRowCOLORREF_Background; - internal static int ShellViewRowCOLORREF_Text; internal static List<string> StartUpGroupList = new List<string>(); internal static string StartUpGroupNameNowOpening = string.Empty; internal static Font StartUpTabFont; @@ -139,8 +137,6 @@ Path_LanguageFile = string.Empty; } ValidateTextResources(); - ShellViewRowCOLORREF_Background = QTUtility2.GetRegistryValueSafe(key, "AlternateColor_Bk", 0xfaf5f1); - ShellViewRowCOLORREF_Text = QTUtility2.GetRegistryValueSafe(key, "AlternateColor_Text", QTUtility2.MakeCOLORREF(SystemColors.WindowText)); Action_BarDblClick = (string)key.GetValue("Action_BarDblClick", string.Empty); MaxCount_History = QTUtility2.GetRegistryValueSafe(key, "Max_Undo", 0x10); using(RegistryKey key2 = key.CreateSubKey("RecentlyClosed")) { This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <mas...@us...> - 2011-12-07 22:07:04
|
Revision: 356 http://qttabbar.svn.sourceforge.net/qttabbar/?rev=356&view=rev Author: masamunexgp Date: 2011-12-07 22:06:57 +0000 (Wed, 07 Dec 2011) Log Message: ----------- Cleaned up QTUtility static constructor a bit, moved Tooltip options to Config. Modified Paths: -------------- branches/options/QTTabBar/Config.cs branches/options/QTTabBar/HookLibManager.cs branches/options/QTTabBar/OptionsDialog_OLD.cs branches/options/QTTabBar/QTTabBarClass.cs branches/options/QTTabBar/QTUtility.cs branches/options/QTTabBar/ThumbnailTooltipForm.cs Modified: branches/options/QTTabBar/Config.cs =================================================================== --- branches/options/QTTabBar/Config.cs 2011-12-07 00:22:32 UTC (rev 355) +++ branches/options/QTTabBar/Config.cs 2011-12-07 22:06:57 UTC (rev 356) @@ -334,7 +334,9 @@ public int PreviewMaxWidth { get; set; } public int PreviewMaxHeight { get; set; } public Font PreviewFont { get; set; } - + public List<string> TextExt { get; set; } + public List<string> ImageExt { get; set; } + public _Tips() { ShowSubDirTips = true; SubDirTipsPreview = true; @@ -346,6 +348,8 @@ PreviewMaxWidth = 512; PreviewMaxHeight = 256; PreviewFont = Control.DefaultFont; + TextExt = new List<string> {".txt", ".ini", ".inf" ,".cs", ".log", ".js", ".vbs"}; + ImageExt = ThumbnailTooltipForm.MakeDefaultImgExts(); } } @@ -443,12 +447,9 @@ public string ImageStripPath { get; set; } public _BBar() { - // todo - // we can't check QTUtility.IsXP here, due to a circular reference between - // QTUtility's static constructor and ConfigManager's. - ButtonIndexes = //QTUtility.IsXP - //? new int[] {1, 2, 0, 3, 4, 5, 0, 6, 7, 0, 11, 13, 12, 14, 15, 0, 9, 20} - /*:*/ new int[] {3, 4, 5, 0, 6, 7, 0, 11, 13, 12, 14, 15, 0, 9, 20}; + ButtonIndexes = QTUtility.IsXP + ? new int[] {1, 2, 0, 3, 4, 5, 0, 6, 7, 0, 11, 13, 12, 14, 15, 0, 9, 20} + : new int[] {3, 4, 5, 0, 6, 7, 0, 11, 13, 12, 14, 15, 0, 9, 20}; LockDropDownButtons = false; LargeButtons = true; LockSearchBarWidth = false; @@ -570,7 +571,7 @@ public static class ConfigManager { public static Config LoadedConfig; - static ConfigManager() { + public static void Initialize() { LoadedConfig = new Config(); ReadConfig(); } @@ -628,6 +629,8 @@ } Config.Skin.TabTextFont = Config.Skin.TabTextFont ?? Control.DefaultFont; Config.Tips.PreviewFont = Config.Tips.PreviewFont ?? Control.DefaultFont; + Config.Tips.PreviewMaxWidth = QTUtility.ValidateMaxMin(Config.Tips.PreviewMaxWidth, 1920, 128); + Config.Tips.PreviewMaxHeight = QTUtility.ValidateMaxMin(Config.Tips.PreviewMaxHeight, 1200, 96); } public static void WriteConfig() { const string RegPath = RegConst.Root + RegConst.Config; Modified: branches/options/QTTabBar/HookLibManager.cs =================================================================== --- branches/options/QTTabBar/HookLibManager.cs 2011-12-07 00:22:32 UTC (rev 355) +++ branches/options/QTTabBar/HookLibManager.cs 2011-12-07 22:06:57 UTC (rev 356) @@ -20,7 +20,6 @@ using System.Linq; using System.Runtime.InteropServices; using System.Windows.Forms; -using Microsoft.Win32; using QTTabBarLib.Interop; namespace QTTabBarLib { @@ -61,7 +60,8 @@ UpdateWindowList, // Compatibility with SHOpenFolderAndSelectItems } - static HookLibManager() { + public static void Initialize() { + if(hHookLib != IntPtr.Zero) return; string installPath = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.CommonApplicationData), "QTTabBar"); string filename = IntPtr.Size == 8 ? "QTHookLib64.dll" : "QTHookLib32.dll"; hHookLib = PInvoke.LoadLibrary(Path.Combine(installPath, filename)); Modified: branches/options/QTTabBar/OptionsDialog_OLD.cs =================================================================== --- branches/options/QTTabBar/OptionsDialog_OLD.cs 2011-12-07 00:22:32 UTC (rev 355) +++ branches/options/QTTabBar/OptionsDialog_OLD.cs 2011-12-07 22:06:57 UTC (rev 356) @@ -429,10 +429,10 @@ cmbTabSizeMode.Items.AddRange(new string[] { ResOpt_DropDown[0x17], ResOpt_DropDown[0x18], ResOpt_DropDown[0x19] }); cmbTabTextAlignment.Items.AddRange(new string[] { ResOpt_DropDown[0x1d], ResOpt_DropDown[30] }); cmbTextExts.Items.Add("(Text file)"); - cmbTextExts.Items.AddRange(QTUtility.PreviewExtsList_Txt.ToArray()); + //cmbTextExts.Items.AddRange(QTUtility.PreviewExtsList_Txt.ToArray()); cmbTextExts.SelectedIndex = 0; cmbImgExts.Items.Add("(Image & movie file)"); - cmbImgExts.Items.AddRange(QTUtility.PreviewExtsList_Img.ToArray()); + //cmbImgExts.Items.AddRange(QTUtility.PreviewExtsList_Img.ToArray()); cmbImgExts.SelectedIndex = 0; cmbRebarBGImageMode.Items.AddRange(new string[] { ResOpt_DropDown[0x1a], ResOpt_DropDown[0x1b], ResOpt_DropDown[0x1c], ResOpt_DropDown[0x21] }); cmbMenuRenderer.Items.AddRange(new string[] { ResOpt[0x2a], ResOpt_DropDown[0x1f], ResOpt_DropDown[0x20] }); @@ -465,7 +465,7 @@ } } SetValues(); - tabControl1.SelectedIndex = QTUtility.OptionsDialogTabIndex; + //tabControl1.SelectedIndex = QTUtility.OptionsDialogTabIndex; ResumeLayout(); } @@ -4168,7 +4168,7 @@ btnShadowIna.ForeColor = QTUtility.TabTextColor_InAtvShdw;*/ chbTabTitleShadow.Checked = Config.Skin.TabTitleShadows; btnShadowAct.Enabled = btnShadowIna.Enabled = chbTabTitleShadow.Checked; - textBoxAction_BarDblClck.Text = QTUtility.Action_BarDblClick; + //textBoxAction_BarDblClck.Text = QTUtility.Action_BarDblClick; QTUtility.RefreshGroupsDic(); InitializeTreeView_Group(); QTUtility.RefreshUserAppDic(false); @@ -4224,15 +4224,15 @@ chbPreviewMode.Checked = Config.Tips.ShowPreviewsWithShift; chbPreviewInfo.Checked = !Config.Tips.ShowPreviewInfo; nudPreviewMaxWidth.Enabled = nudPreviewMaxHeight.Enabled = cmbTextExts.Enabled = btnAddTextExt.Enabled = btnDelTextExt.Enabled = btnDefaultTextExt.Enabled = cmbImgExts.Enabled = btnAddImgExt.Enabled = btnDelImgExt.Enabled = btnDefaultImgExt.Enabled = btnPreviewFont.Enabled = btnPreviewFontDefault.Enabled = chbPreviewInfo.Enabled = chbPreviewMode.Enabled = chbShowPreview.Checked; - nudPreviewMaxWidth.Value = QTUtility.PreviewMaxWidth; - nudPreviewMaxHeight.Value = QTUtility.PreviewMaxHeight; - if(QTUtility.PreviewFontName != null) { - try { - btnPreviewFont.Font = new Font(QTUtility.PreviewFontName, QTUtility.PreviewFontSize); - } - catch { - } - } + //nudPreviewMaxWidth.Value = QTUtility.PreviewMaxWidth; + //nudPreviewMaxHeight.Value = QTUtility.PreviewMaxHeight; + //if(QTUtility.PreviewFontName != null) { + // try { + // btnPreviewFont.Font = new Font(QTUtility.PreviewFontName, QTUtility.PreviewFontSize); + // } + // catch { + // } + //} chbSubDirTip.Checked = Config.Tips.ShowSubDirTips; chbSubDirTipMode.Checked = Config.Tips.SubDirTipsWithShift; chbSubDirTipModeHidden.Checked = Config.SubDirTipsHidden; @@ -4240,8 +4240,8 @@ chbSubDirTipPreview.Checked = !Config.Tips.SubDirTipsPreview; chbSubDirTipMode.Enabled = chbSubDirTipModeHidden.Enabled = chbSubDirTipModeFile.Enabled = chbSubDirTipPreview.Enabled = chbSubDirTip.Checked; chbSubDirTipModeSystem.Checked = Config.SubDirTipsSystem; - nudMaxUndo.Value = QTUtility.MaxCount_History; - nudMaxRecentFile.Value = QTUtility.MaxCount_Executed; + //nudMaxUndo.Value = QTUtility.MaxCount_History; + //nudMaxRecentFile.Value = QTUtility.MaxCount_Executed; chbDD.Checked = Config.Tabs.DragOverTabOpensSDT; chbNoTabFromOuteside.Checked = Config.Window.CaptureNewWindows; chbHolizontalScroll.Checked = !Config.Tweaks.HorizontalScroll; @@ -4281,7 +4281,7 @@ } private void tabControl1_SelectedIndexChanged(object sender, EventArgs e) { - QTUtility.OptionsDialogTabIndex = tabControl1.SelectedIndex; + //QTUtility.OptionsDialogTabIndex = tabControl1.SelectedIndex; } private void tbGroupKey_KeyPress(object sender, KeyPressEventArgs e) { @@ -4668,11 +4668,11 @@ //key.SetValue("ToolbarBGColor", QTUtility.RebarBGColor.ToArgb()); //key.SetValue("AlternateColor_Bk", QTUtility.ShellViewRowCOLORREF_Background); //key.SetValue("AlternateColor_Text", QTUtility.ShellViewRowCOLORREF_Text); - key.SetValue("Max_Undo", QTUtility.MaxCount_History); - key.SetValue("Max_RecentFile", QTUtility.MaxCount_Executed); - key.SetValue("PreviewMaxWidth", QTUtility.PreviewMaxWidth); - key.SetValue("PreviewMaxHeight", QTUtility.PreviewMaxHeight); - key.SetValue("Action_BarDblClick", QTUtility.Action_BarDblClick); + //key.SetValue("Max_Undo", QTUtility.MaxCount_History); + //key.SetValue("Max_RecentFile", QTUtility.MaxCount_Executed); + //key.SetValue("PreviewMaxWidth", QTUtility.PreviewMaxWidth); + //key.SetValue("PreviewMaxHeight", QTUtility.PreviewMaxHeight); + //key.SetValue("Action_BarDblClick", QTUtility.Action_BarDblClick); if((tabFont != null) && !tabFont.Equals(DefaultFont)) { key.SetValue("TabFont", tabFont.Name); key.SetValue("TabFontSize", tabFont.SizeInPoints.ToString()); @@ -4686,13 +4686,13 @@ //key.SetValue("TabImage", QTUtility.Path_TabImage); byte[] buffer = new byte[] { (byte)Config.Skin.TabSizeMargin.Left, (byte)Config.Skin.TabSizeMargin.Top, (byte)Config.Skin.TabSizeMargin.Right, (byte)Config.Skin.TabSizeMargin.Bottom }; key.SetValue("TabImageSizingMargin", buffer); - QTUtility.PreviewExtsList_Txt.Clear(); - QTUtility.PreviewExtsList_Img.Clear(); + //QTUtility.PreviewExtsList_Txt.Clear(); + //QTUtility.PreviewExtsList_Img.Clear(); string str = string.Empty; string str2 = string.Empty; if(strsTextExts != null) { foreach(string ext in strsTextExts) { - QTUtility.PreviewExtsList_Txt.Add(ext); + //QTUtility.PreviewExtsList_Txt.Add(ext); str = str + ext + ";"; } if(str.Length > 0) { @@ -4701,7 +4701,7 @@ } if(strsImgExts != null) { foreach(string ext in strsImgExts) { - QTUtility.PreviewExtsList_Img.Add(ext); + //QTUtility.PreviewExtsList_Img.Add(ext); str2 = str2 + ext + ";"; } if(str2.Length > 0) { @@ -4710,14 +4710,14 @@ } key.SetValue("TextExtensions", str); key.SetValue("ImageExtensions", str2); - if(QTUtility.PreviewFontName != null) { - key.SetValue("PreviewFont", QTUtility.PreviewFontName); - key.SetValue("PreviewFontSize", QTUtility.PreviewFontSize.ToString()); - } - else { - key.DeleteValue("PreviewFont", false); - key.DeleteValue("PreviewFontSize", false); - } + //if(QTUtility.PreviewFontName != null) { + // key.SetValue("PreviewFont", QTUtility.PreviewFontName); + // key.SetValue("PreviewFontSize", QTUtility.PreviewFontSize.ToString()); + //} + //else { + // key.DeleteValue("PreviewFont", false); + // key.DeleteValue("PreviewFontSize", false); + //} key.SetValue("NetworkTimeout", IDLWrapper.iPingTimeOutMS); key.SetValue("LanguageFile", QTUtility.Path_LanguageFile); using(RegistryKey key2 = key.CreateSubKey("Plugins")) { Modified: branches/options/QTTabBar/QTTabBarClass.cs =================================================================== --- branches/options/QTTabBar/QTTabBarClass.cs 2011-12-07 00:22:32 UTC (rev 355) +++ branches/options/QTTabBar/QTTabBarClass.cs 2011-12-07 22:06:57 UTC (rev 356) @@ -4756,8 +4756,8 @@ } RefreshTabBar(); SyncTabBarBroadcast(Handle); - QTUtility.ClosedTabHistoryList.MaxCapacity = QTUtility.MaxCount_History; - QTUtility.ExecutedPathsList.MaxCapacity = QTUtility.MaxCount_Executed; + QTUtility.ClosedTabHistoryList.MaxCapacity = Config.Misc.TabHistoryCount; + QTUtility.ExecutedPathsList.MaxCapacity = Config.Misc.FileHistoryCount; SyncButtonBarBroadCast(0x100); SyncButtonBarCurrent(0x3f); SyncTaskBarMenu(); Modified: branches/options/QTTabBar/QTUtility.cs =================================================================== --- branches/options/QTTabBar/QTUtility.cs 2011-12-07 00:22:32 UTC (rev 355) +++ branches/options/QTTabBar/QTUtility.cs 2011-12-07 22:06:57 UTC (rev 356) @@ -32,7 +32,6 @@ namespace QTTabBarLib { internal static class QTUtility { - internal static string Action_BarDblClick; internal static Version BetaRevision = new Version(0, 3); internal static PathList ClosedTabHistoryList = new PathList(0x10); internal static byte[] ConfigValues; @@ -59,13 +58,11 @@ internal const string IMAGEKEY_NOIMAGE = "noimage"; internal static ImageList ImageListGlobal; internal static int InstancesCount; - internal static readonly bool IsRTL; - internal static readonly bool IsXP; + internal static readonly bool IsRTL = CultureInfo.CurrentCulture.TextInfo.IsRightToLeft; + internal static readonly bool IsXP = Environment.OSVersion.Version.Major <= 5; internal static Dictionary<string, byte[]> ITEMIDLIST_Dic_Session = new Dictionary<string, byte[]>(); internal static List<string> LockedTabsToRestoreList = new List<string>(); internal const BindAction LAST_KEYBOARD_ACTION = BindAction.FocusTabBar; - public static int MaxCount_Executed = 0x10; - internal static int MaxCount_History = 0x10; internal static List<string> NoCapturePathsList = new List<string>(); internal static bool NowDebugging = #if DEBUG @@ -73,18 +70,11 @@ #else false; #endif - internal static int OptionsDialogTabIndex; internal static string Path_LanguageFile; internal static string PATH_MYNETWORK; internal static string Path_PluginLangFile; internal static string PATH_SEARCHFOLDER; internal static string PathToSelectInCommandLineArg; - internal static List<string> PreviewExtsList_Img = new List<string>(); - internal static List<string> PreviewExtsList_Txt = new List<string>(); - internal static string PreviewFontName; - internal static float PreviewFontSize; - internal static int PreviewMaxHeight = 0x100; - internal static int PreviewMaxWidth = 0x200; internal const string REGUSER = RegConst.Root; internal static string[] ResMain; internal static string[] ResMisc; @@ -103,31 +93,26 @@ internal static byte WindowAlpha = 0xff; static QTUtility() { - String processName = Process.GetCurrentProcess().ProcessName.ToLower(); - // I'm tempted to just return for everything except "explorer" // Maybe I should... + String processName = Process.GetCurrentProcess().ProcessName.ToLower(); if(processName == "iexplore" || processName == "regasm" || processName == "gacutil") { - //MessageBox.Show("Blocked " + processName); return; } - ImageListGlobal = new ImageList(); - ImageListGlobal.ColorDepth = ColorDepth.Depth32Bit; - ImageListGlobal.Images.Add("folder", GetIcon(string.Empty, false)); try { - IsXP = Environment.OSVersion.Version.Major <= 5; - // TODO: make this more comprehensible - //ConfigValues = new byte[] { 200, 0, 4, 0, 4, 0x60, 0x10, 0x22, 2, 8, 0xe0, 8, 0, 0x20, 0, 0 }; - //if(IsXP) { - //ConfigValues[13] = 0x30; - //} - //SetConfigAt(Settings.AutoUpdate, true); // TODO + // Load the config + ConfigManager.Initialize(); + + // Create and enable the API hooks + HookLibManager.Initialize(); + + // Create the global imagelist + ImageListGlobal = new ImageList { ColorDepth = ColorDepth.Depth32Bit }; + ImageListGlobal.Images.Add("folder", GetIcon(string.Empty, false)); + using(RegistryKey key = Registry.CurrentUser.CreateSubKey(RegConst.Root)) { if(key != null) { - float num; - byte[] inputValues = (byte[])key.GetValue("Config"); - //ConfigValues = GetSettingValue(inputValues, ConfigValues, false); string path = (string)key.GetValue("LanguageFile", string.Empty); if((path.Length > 0) && File.Exists(path)) { Path_LanguageFile = path; @@ -137,22 +122,20 @@ Path_LanguageFile = string.Empty; } ValidateTextResources(); - Action_BarDblClick = (string)key.GetValue("Action_BarDblClick", string.Empty); - MaxCount_History = QTUtility2.GetRegistryValueSafe(key, "Max_Undo", 0x10); + using(RegistryKey key2 = key.CreateSubKey("RecentlyClosed")) { if(key2 != null) { List<string> collection = key2.GetValueNames() .Select(str4 => (string)key2.GetValue(str4)).ToList(); - ClosedTabHistoryList = new PathList(collection, MaxCount_History); + ClosedTabHistoryList = new PathList(collection, Config.Misc.TabHistoryCount); } } if(Config.AllRecentFiles) { - MaxCount_Executed = QTUtility2.GetRegistryValueSafe(key, "Max_RecentFile", 0x10); using(RegistryKey key3 = key.CreateSubKey("RecentFiles")) { if(key3 != null) { List<string> list2 = key3.GetValueNames().Select(str5 => (string)key3.GetValue(str5)).ToList(); - ExecutedPathsList = new PathList(list2, MaxCount_Executed); + ExecutedPathsList = new PathList(list2, Config.Misc.FileHistoryCount); } } } @@ -169,14 +152,6 @@ if(!byte.TryParse((string)key.GetValue("WindowAlpha", "255"), out WindowAlpha)) { WindowAlpha = 0xff; } - RefreshPreviewExtensions(); - PreviewMaxWidth = ValidateMaxMin((int)key.GetValue("PreviewMaxWidth", 0x200), 0x780, 0x80); - PreviewMaxHeight = ValidateMaxMin((int)key.GetValue("PreviewMaxHeight", 0x100), 0x4b0, 0x60); - PreviewFontName = (string)key.GetValue("PreviewFont", null); - string str8 = (string)key.GetValue("PreviewFontSize", null); - if(!float.TryParse(str8, out PreviewFontSize)) { - PreviewFontSize = 10.5f; - } } } RefreshGroupsDic(); @@ -190,13 +165,12 @@ PATH_MYNETWORK = "::{208D2C60-3AEA-1069-A2D7-08002B30309D}"; GetShellClickMode(); } - PluginManager.Initialize(); - IsRTL = CultureInfo.CurrentCulture.TextInfo.IsRightToLeft; - // Make sure the hooklib is initialized - RuntimeHelpers.RunClassConstructor(typeof(HookLibManager).TypeHandle); + // Initialize plugins + PluginManager.Initialize(); } catch(Exception exception) { + // TODO: Any errors here would be very serious. Alert the user as such. QTUtility2.MakeErrorLog(exception); } } @@ -607,39 +581,6 @@ } } - public static void RefreshPreviewExtensions() { - const string defaultValue = ".txt;.ini;.inf;.cs;.log;.js;.vbs"; - using(RegistryKey key = Registry.CurrentUser.CreateSubKey(RegConst.Root)) { - string str2 = (string)key.GetValue("TextExtensions", defaultValue); - if(str2.Length > 0) { - foreach(string str3 in str2.Split(SEPARATOR_CHAR)) { - if(str3.Length > 0) { - string item = str3; - if(!str3.StartsWith(".")) { - item = "." + str3; - } - PreviewExtsList_Txt.Add(item); - } - } - } - string str5 = (string)key.GetValue("ImageExtensions"); - if(str5 == null) { - PreviewExtsList_Img = ThumbnailTooltipForm.MakeDefaultImgExts(); - } - else if(str5.Length > 0) { - foreach(string str6 in str5.Split(SEPARATOR_CHAR)) { - if(str6.Length > 0) { - string str7 = str6; - if(!str6.StartsWith(".")) { - str7 = "." + str6; - } - PreviewExtsList_Img.Add(str7); - } - } - } - } - } - public static void RefreshUserAppDic(bool fCheckShortcuts) { UserAppsDic.Clear(); using(RegistryKey key = Registry.CurrentUser.OpenSubKey(RegConst.Root + @"UserApps", false)) { @@ -859,7 +800,11 @@ // TODO } - private static int ValidateMaxMin(int value, int max, int min) { + public static void ValidateMaxMin(ref int value, int max, int min) { + value = ValidateMaxMin(value, min, max); + } + + public static int ValidateMaxMin(int value, int max, int min) { int num = Math.Max(max, min); int num2 = Math.Min(max, min); if(value < num2) { Modified: branches/options/QTTabBar/ThumbnailTooltipForm.cs =================================================================== --- branches/options/QTTabBar/ThumbnailTooltipForm.cs 2011-12-07 00:22:32 UTC (rev 355) +++ branches/options/QTTabBar/ThumbnailTooltipForm.cs 2011-12-07 22:06:57 UTC (rev 356) @@ -45,8 +45,8 @@ private const int MAX_TEXT_LENGTH = 0x400; public const int MAX_THUMBNAIL_HEIGHT = 0x4b0; public const int MAX_THUMBNAIL_WIDTH = 0x780; - private int maxHeight = QTUtility.PreviewMaxHeight; - private int maxWidth = QTUtility.PreviewMaxWidth; + private int maxHeight = Config.Tips.PreviewMaxHeight; + private int maxWidth = Config.Tips.PreviewMaxWidth; private PictureBox pictureBox1; private static string supportedImages; private static string supportedMovies = ".asf;.asx;.avi;.dvr-ms;.m1v;.wmv;.mpg;.mpeg;.mp2;.flv"; @@ -79,9 +79,9 @@ Size sizeActual = Size.Empty; lblInfo.Text = string.Empty; string toolTipText = null; - if((maxWidth != QTUtility.PreviewMaxWidth) || (maxHeight != QTUtility.PreviewMaxHeight)) { - maxWidth = QTUtility.PreviewMaxWidth; - maxHeight = QTUtility.PreviewMaxHeight; + if((maxWidth != Config.Tips.PreviewMaxWidth) || (maxHeight != Config.Tips.PreviewMaxHeight)) { + maxWidth = Config.Tips.PreviewMaxWidth; + maxHeight = Config.Tips.PreviewMaxHeight; pictureBox1.Image = null; imageCacheStore.Clear(); lstPathFailedThumbnail.Clear(); @@ -207,23 +207,16 @@ str4 = " *empty file"; } lblText.ForeColor = (ioException != null) ? Color.Red : (flag7 ? SystemColors.GrayText : SystemColors.InfoText); - if(!string.IsNullOrEmpty(QTUtility.PreviewFontName)) { - if((lblText.Font.Name != QTUtility.PreviewFontName) || (lblText.Font.Size != QTUtility.PreviewFontSize)) { - fFontAsigned = true; - try { - lblText.Font = new Font(QTUtility.PreviewFontName, QTUtility.PreviewFontSize); - } - catch { - } - } + try { + lblText.Font = Config.Tips.PreviewFont; + fFontAsigned = true; } - else if(fFontAsigned) { + catch { fFontAsigned = false; - lblText.Font = null; } int num2 = 0x100; if(fFontAsigned) { - num2 = Math.Max((int)(num2 * (QTUtility.PreviewFontSize / DefaultFont.Size)), 0x80); + num2 = Math.Max((int)(num2 * (Config.Tips.PreviewFont.SizeInPoints / DefaultFont.Size)), 0x80); formSize.Width = num2; } using(Graphics graphics2 = lblText.CreateGraphics()) { @@ -261,7 +254,7 @@ } private static bool ExtIsImage(string ext) { - return (((ext.Length != 0) && QTUtility.PreviewExtsList_Img.Contains(ext.ToLower())) && (ext != ".ico")); + return (ext.Length != 0 && Config.Tips.ImageExt.Contains(ext.ToLower()) && ext != ".ico"); } public static bool ExtIsSupported(string ext) { @@ -272,7 +265,7 @@ } private static bool ExtIsText(string ext) { - return ((ext.Length != 0) && QTUtility.PreviewExtsList_Txt.Contains(ext.ToLower())); + return (ext.Length != 0 && Config.Tips.TextExt.Contains(ext.ToLower())); } private static string FormatSize(long size) { @@ -360,18 +353,20 @@ sizeRaw = bitmap.Size; int width = sizeRaw.Width; int height = sizeRaw.Height; - if((height > QTUtility.PreviewMaxHeight) || (width > QTUtility.PreviewMaxWidth)) { - if(height > QTUtility.PreviewMaxHeight) { - width = (int)(((QTUtility.PreviewMaxHeight) / ((double)height)) * width); - height = QTUtility.PreviewMaxHeight; - if(width > QTUtility.PreviewMaxWidth) { - height = (int)(((QTUtility.PreviewMaxWidth) / ((double)width)) * height); - width = QTUtility.PreviewMaxWidth; + int maxWidth = Config.Tips.PreviewMaxWidth; + int maxHeight = Config.Tips.PreviewMaxHeight; + if((height > maxHeight) || (width > maxWidth)) { + if(height > maxHeight) { + width = (int)((maxHeight / ((double)height)) * width); + height = maxHeight; + if(width > maxWidth) { + height = (int)((maxWidth / ((double)width)) * height); + width = maxWidth; } } else { - height = (int)(((QTUtility.PreviewMaxWidth) / ((double)width)) * height); - width = QTUtility.PreviewMaxWidth; + height = (int)((maxWidth / ((double)width)) * height); + width = maxWidth; } sizeActual = new Size(width, height); if(ImageAnimator.CanAnimate(bitmap)) { @@ -447,7 +442,7 @@ uint flags = 0; uint pOutFlags = 0; WTS_THUMBNAILID pThumbnailID = new WTS_THUMBNAILID(); - uint cxyRequestedThumbSize = (uint)Math.Min(0x400, Math.Min(QTUtility.PreviewMaxWidth, QTUtility.PreviewMaxHeight)); + uint cxyRequestedThumbSize = (uint)Math.Min(0x400, Math.Min(Config.Tips.PreviewMaxWidth, Config.Tips.PreviewMaxHeight)); if(cache2.GetThumbnail(ppsi, cxyRequestedThumbSize, flags, out ppvThumb, ref pOutFlags, ref pThumbnailID) == 0) { IntPtr ptr2; if((pOutFlags & 2) == 2) { @@ -508,7 +503,7 @@ IExtractImage image = (IExtractImage)obj2; StringBuilder pszPathBuffer = new StringBuilder(260); int pdwPriority = 0; - Size prgSize = new Size(QTUtility.PreviewMaxWidth, QTUtility.PreviewMaxHeight); + Size prgSize = new Size(Config.Tips.PreviewMaxWidth, Config.Tips.PreviewMaxHeight); int pdwFlags = 0x60; if(((image.GetLocation(pszPathBuffer, pszPathBuffer.Capacity, ref pdwPriority, ref prgSize, 0x18, ref pdwFlags) == 0) && (image.Extract(out ptr2) == 0)) && (ptr2 != IntPtr.Zero)) { Bitmap bmp = Image.FromHbitmap(ptr2); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <mas...@us...> - 2011-12-08 04:41:20
|
Revision: 357 http://qttabbar.svn.sourceforge.net/qttabbar/?rev=357&view=rev Author: masamunexgp Date: 2011-12-08 04:41:13 +0000 (Thu, 08 Dec 2011) Log Message: ----------- Rearranged a few things, added more bindings. Modified Paths: -------------- branches/options/QTTabBar/Config.cs branches/options/QTTabBar/OptionsDialog.xaml branches/options/QTTabBar/OptionsDialog.xaml.cs branches/options/QTTabBar/ThumbnailTooltipForm.cs Modified: branches/options/QTTabBar/Config.cs =================================================================== --- branches/options/QTTabBar/Config.cs 2011-12-07 22:06:57 UTC (rev 356) +++ branches/options/QTTabBar/Config.cs 2011-12-08 04:41:13 UTC (rev 357) @@ -414,8 +414,8 @@ OverlapPixels = 0; HitTestTransparent = false; TabHeight = 24; - TabMinWidth = 70; // TODO - TabMaxWidth = 150; // TODO + TabMinWidth = 50; + TabMaxWidth = 200; FixedWidthTabs = false; TabTextFont = Control.DefaultFont; TabTextActiveColor = Color.Black; Modified: branches/options/QTTabBar/OptionsDialog.xaml =================================================================== --- branches/options/QTTabBar/OptionsDialog.xaml 2011-12-07 22:06:57 UTC (rev 356) +++ branches/options/QTTabBar/OptionsDialog.xaml 2011-12-08 04:41:13 UTC (rev 357) @@ -945,18 +945,20 @@ Content="Rename ambiguous tabs" IsChecked="{Binding Path=RenameAmbTabs}" Style="{StaticResource CheckStyle}"/> + <StackPanel Orientation="Horizontal"> + <Label + Content="When drag-hovering over a tab," + Style="{StaticResource LabelStyle}"/> + <qt:RadioButtonEx x:Name="radDragOverTabOpensSTD_No" + Content="Switch to it" + IsCheckedReal ="{Binding Path=DragOverTabOpensSDT, Converter={StaticResource BoolInverterConverter}}" + Margin="0,1,10,1"/> + <qt:RadioButtonEx x:Name="radDragOverTabOpensSDT_Yes" + Content="Show the Subfolder Tip menu" + IsCheckedReal ="{Binding Path=DragOverTabOpensSDT}" + Margin="0,1,10,1"/> + </StackPanel> <Label - Content="When drag-hovering over a tab," - Style="{StaticResource LabelStyle}"/> - <qt:RadioButtonEx x:Name="radDragOverTabOpensSTD_No" - Content="Switch to it" - IsCheckedReal ="{Binding Path=DragOverTabOpensSDT, Converter={StaticResource BoolInverterConverter}}" - Style="{StaticResource IndentedCheckStyle}"/> - <qt:RadioButtonEx x:Name="radDragOverTabOpensSDT_Yes" - Content="Show the Subfolder Tip menu" - IsCheckedReal ="{Binding Path=DragOverTabOpensSDT}" - Style="{StaticResource IndentedCheckStyle}"/> - <Label Content="Tab icons" Style="{StaticResource SectionHeaderStyle}"/> <CheckBox x:Name="chkShowFolderIcon" @@ -1179,14 +1181,17 @@ <CheckBox x:Name="chkSubDirTipsWithShift" Content="Only with the Shift key is down" IsChecked="{Binding Path=SubDirTipsWithShift}" + IsEnabled="{Binding Path=IsChecked, ElementName=chkShowSubDirTips}" Style="{StaticResource IndentedCheckStyle}"/> <CheckBox x:Name="chkSubDirTipsFiles" Content="Show files" IsChecked="{Binding Path=SubDirTipsFiles}" + IsEnabled="{Binding Path=IsChecked, ElementName=chkShowSubDirTips}" Style="{StaticResource IndentedCheckStyle}"/> <CheckBox x:Name="chkSubDirTipsPreview" Content="Show preview tooltips when mousing over menu items" IsChecked="{Binding Path=SubDirTipsPreview}" + IsEnabled="{Binding Path=IsChecked, ElementName=chkShowSubDirTips}" Style="{StaticResource IndentedCheckStyle}"/> <Label Content="Preview tooltips" @@ -1198,12 +1203,15 @@ <CheckBox x:Name="chkShowPreviewsWithShift" Content="Only with the Shift key is down" IsChecked="{Binding Path=ShowPreviewsWithShift}" + IsEnabled="{Binding Path=IsChecked, ElementName=chkShowTooltipPreviews}" Style="{StaticResource IndentedCheckStyle}"/> <CheckBox x:Name="chkShowPreviewInfo" Content="Show file information below images" IsChecked="{Binding Path=ShowPreviewInfo}" + IsEnabled="{Binding Path=IsChecked, ElementName=chkShowTooltipPreviews}" Style="{StaticResource IndentedCheckStyle}"/> <StackPanel + IsEnabled="{Binding Path=IsChecked, ElementName=chkShowTooltipPreviews}" Margin="31,1,0,1" Orientation="Horizontal"> <Label @@ -1211,34 +1219,36 @@ Height="16" Padding="0"/> <qt:Spinner - Width="100" - Height="23" - Min="0" - Max="100" - Margin="8,1"/> + Min="128" + Max="1920" + Margin="8,1" + Value="{Binding Path=PreviewMaxWidth}"/> <Label Content="x" Height="16" Margin="0" Padding="0"/> <qt:Spinner - Width="100" - Min="0" - Max="100" - Margin="8,1"/> + Min="96" + Max="1200" + Margin="8,1" + Value="{Binding Path=PreviewMaxHeight}"/> </StackPanel> <StackPanel - Margin="13,1,0,1" + IsEnabled="{Binding Path=IsChecked, ElementName=chkShowTooltipPreviews}" + Margin="31,1,0,1" Orientation="Horizontal"> <Label Content="Font:" Height="16" Padding="0"/> <Button - Content="{Binding Path=PreviewFont, Converter={StaticResource FontStringConverter}}" + Click="btnFontChoose_Click" + Content="{Binding Path=Tag, RelativeSource={RelativeSource Self}, Converter={StaticResource FontStringConverter}}" Height="23" Margin="8,1" - Width="250"/> + Tag="{Binding Path=PreviewFont, Mode=TwoWay}" + Width="200"/> </StackPanel> <Grid Margin="13,15,0,1"> <Grid.ColumnDefinitions> @@ -1400,24 +1410,26 @@ IsChecked="{Binding Path=KeepRecentFiles}" Height="16" Margin="13,1,10,1"/> - <qt:Spinner Grid.Column="1" Min="0" - Max="100" - Value="{Binding Path=FileHistoryCount}" /> + Max="50" + Value="{Binding Path=TabHistoryCount}"/> <qt:Spinner Grid.Column="1" Grid.Row="1" - Min="0" - Max="100"/> - <Button + Min="1" + Max="50" + Value="{Binding Path=FileHistoryCount}" /> + <Button x:Name="btnRecentTabsClear" + Click="btnRecentTabsClear_Click" Content="Clear now" Grid.Column="2" Height="23" Margin="5,2" Width="75"/> - <Button + <Button x:Name="btnRecentFilesClear" + Click="btnRecentFilesClear_Click" Content="Clear now" Grid.Column="2" Grid.Row="1" @@ -1438,8 +1450,9 @@ <qt:Spinner Height="23" Min="0" - Max="100" - Margin="5,2"/> + Max="120" + Margin="5,2" + Value="{Binding Path=NetworkTimeout}"/> </StackPanel> <StackPanel Orientation="Horizontal"> @@ -1447,7 +1460,8 @@ Content="Check for updates periodically" IsChecked="{Binding Path=AutoUpdate}" Style="{StaticResource CheckStyle}"/> - <Button + <Button x:Name="btnUpdateNow" + Click="btnUpdateNow_Click" Content="Check now" Height="23" Margin="5,2" @@ -1501,23 +1515,6 @@ VerticalAlignment="Bottom"/> </StackPanel> <Label - Content="Skin file" - Style="{StaticResource SectionHeaderStyle}"/> - <StackPanel - Margin="13,1,0,1" - Orientation="Horizontal"> - <Button - Content="Import Skin..." - Height="23" - Margin="0,0,10,0" - Width="100"/> - <Button - Content="Export Skin..." - Height="23" - Margin="0,0,10,0" - Width="100"/> - </StackPanel> - <Label Content="Tab image" Style="{StaticResource SectionHeaderStyle}"/> <Grid> @@ -1824,13 +1821,14 @@ Height="16" Padding="0"/> <Button x:Name="btnTextFont" - Click="btnTextFont_Click" - Content="{Binding Path=TabTextFont, Converter={StaticResource FontStringConverter}}" + Click="btnFontChoose_Click" + Content="{Binding Path=Tag, RelativeSource={RelativeSource Self}, Converter={StaticResource FontStringConverter}}" Grid.Column="4" Grid.Row="0" Height="23" HorizontalAlignment="Stretch" Margin="10, 5" + Tag="{Binding Path=TabTextFont, Mode=TwoWay}" VerticalAlignment="Center"/> <StackPanel Orientation="Horizontal" @@ -1941,6 +1939,23 @@ </qt:MarginCombo.Style> </qt:MarginCombo> </Grid> + <Label + Content="Skin file" + Style="{StaticResource SectionHeaderStyle}"/> + <StackPanel + Margin="13,1,0,1" + Orientation="Horizontal"> + <Button + Content="Import Skin..." + Height="23" + Margin="0,0,10,0" + Width="100"/> + <Button + Content="Export Skin..." + Height="23" + Margin="0,0,10,0" + Width="100"/> + </StackPanel> </StackPanel> </ScrollViewer> </TabItem> @@ -2445,20 +2460,8 @@ <Label Content="Custom Button Images" Style="{StaticResource SectionHeaderStyle}" /> - <StackPanel Orientation="Horizontal"> - <TextBox x:Name="txtCustomButtonImages" - Text="{Binding Path=ImageStripPath, Mode=TwoWay}" - Width="392" HorizontalAlignment="Left" /> - <Button x:Name="btnCustomButtonImages" - Click="btnCustomButtonImages_Click" - Content="..." - HorizontalAlignment="Left" - Width="64" /> - <Button x:Name="btnCustomButtonImagesDefault" - Click="btnCustomButtonImagesDefault_Click" - Content="Default" - Width="64" /> - </StackPanel> + <qt:FileFolderEntryBox + SelectedPath="{Binding Path=ImageStripPath}"/> </StackPanel> </TabItem> <TabItem x:Name="tabPlugins" Modified: branches/options/QTTabBar/OptionsDialog.xaml.cs =================================================================== --- branches/options/QTTabBar/OptionsDialog.xaml.cs 2011-12-07 22:06:57 UTC (rev 356) +++ branches/options/QTTabBar/OptionsDialog.xaml.cs 2011-12-08 04:41:13 UTC (rev 357) @@ -546,6 +546,32 @@ #endregion + #region ---------- Appearance ---------- + + private void btnShadTextColor_OnChecked(object sender, RoutedEventArgs e) { + var button = ((ToggleButton)sender); + ContextMenu menu = button.ContextMenu; + foreach(MenuItem mi in menu.Items) { + mi.Icon = new System.Windows.Controls.Image { Source = ConvertToBitmapSource((Rectangle)mi.Tag) }; + } + // Yeah, this is necessary even with the IsChecked <=> IsOpen binding. + // Not sure why. + menu.PlacementTarget = button; + menu.Placement = PlacementMode.Bottom; + menu.IsOpen = true; + } + + private void miColorMenuEntry_OnClick(object sender, RoutedEventArgs e) { + var mi = (MenuItem)sender; + var rect = (Rectangle)mi.Tag; + ColorDialogEx cd = new ColorDialogEx { Color = (System.Drawing.Color)rect.Tag }; + if(System.Windows.Forms.DialogResult.OK == cd.ShowDialog()) { + rect.Tag = cd.Color; + } + } + + #endregion + #region ---------- Mouse ---------- private void InitializeMouse() { @@ -1869,26 +1895,22 @@ #endregion - private void btnCustomButtonImages_Click(object sender, RoutedEventArgs e) { - OpenFileDialog d = new OpenFileDialog(); - d.Title = "Select custom button bar strip..."; - - if(d.ShowDialog() == System.Windows.Forms.DialogResult.OK) { - txtCustomButtonImages.Text = d.FileName; - //# We shouldn't have to manually assign this to the config - //# But, without this we must interact with the TextBox in some way before the OK button saves it. - workingConfig.bbar.ImageStripPath = d.FileName; + // Common Font Chooser button click handler. + private void btnFontChoose_Click(object sender, RoutedEventArgs e) { + var button = (Button)sender; + try { + using(var dialog = new System.Windows.Forms.FontDialog()) { + dialog.Font = (Font)button.Tag; + dialog.ShowEffects = false; + dialog.AllowVerticalFonts = false; + if(System.Windows.Forms.DialogResult.OK == dialog.ShowDialog()) { + button.Tag = dialog.Font; + } + } } - + catch {} } - private void btnCustomButtonImagesDefault_Click(object sender, RoutedEventArgs e) { - txtCustomButtonImages.Text = ""; - //# We shouldn't have to manually assign this to the config - //# But, without this we must interact with the TextBox in some way before the OK button saves it. - workingConfig.bbar.ImageStripPath = ""; - } - private sealed class ColorDialogEx : System.Windows.Forms.ColorDialog { protected override int Options { get { @@ -1904,19 +1926,6 @@ } } - private void btnTextFont_Click(object sender, RoutedEventArgs e) { - using(var dialog = new System.Windows.Forms.FontDialog()) { - dialog.Font = workingConfig.skin.TabTextFont; - dialog.ShowEffects = false; - dialog.AllowVerticalFonts = false; - if(System.Windows.Forms.DialogResult.OK == dialog.ShowDialog()) { - Font font = dialog.Font; - workingConfig.skin.TabTextFont = font; - btnTextFont.GetBindingExpression(ContentProperty).UpdateTarget(); - } - } - } - // Draws a control to a bitmap private static BitmapSource ConvertToBitmapSource(UIElement element) { var target = new RenderTargetBitmap((int)(element.RenderSize.Width), (int)(element.RenderSize.Height), 96, 96, PixelFormats.Pbgra32); @@ -1931,27 +1940,17 @@ return target; } - private void btnShadTextColor_OnChecked(object sender, RoutedEventArgs e) { - var button = ((ToggleButton)sender); - ContextMenu menu = button.ContextMenu; - foreach(MenuItem mi in menu.Items) { - mi.Icon = new System.Windows.Controls.Image { Source = ConvertToBitmapSource((Rectangle)mi.Tag) }; - } - // Yeah, this is necessary even with the IsChecked <=> IsOpen binding. - // Not sure why. - menu.PlacementTarget = button; - menu.Placement = PlacementMode.Bottom; - menu.IsOpen = true; + private void btnRecentFilesClear_Click(object sender, RoutedEventArgs e) { + // TODO } - private void miColorMenuEntry_OnClick(object sender, RoutedEventArgs e) { - var mi = (MenuItem)sender; - var rect = (Rectangle)mi.Tag; - ColorDialogEx cd = new ColorDialogEx { Color = (System.Drawing.Color)rect.Tag }; - if(System.Windows.Forms.DialogResult.OK == cd.ShowDialog()) { - rect.Tag = cd.Color; - } + private void btnRecentTabsClear_Click(object sender, RoutedEventArgs e) { + // TODO } + + private void btnUpdateNow_Click(object sender, RoutedEventArgs e) { + // TODO + } } #region ---------- Converters ---------- @@ -2037,6 +2036,7 @@ [ValueConversion(typeof(Font), typeof(string))] public class FontStringConverter : IValueConverter { public object Convert(object value, Type targetType, object parameter, CultureInfo culture) { + if(value == null) return ""; Font font = (Font)value; return string.Format("{0}, {1} pt", font.Name, Math.Round(font.SizeInPoints)); } Modified: branches/options/QTTabBar/ThumbnailTooltipForm.cs =================================================================== --- branches/options/QTTabBar/ThumbnailTooltipForm.cs 2011-12-07 22:06:57 UTC (rev 356) +++ branches/options/QTTabBar/ThumbnailTooltipForm.cs 2011-12-08 04:41:13 UTC (rev 357) @@ -139,7 +139,7 @@ width = sizeActual.Width; } bool flag4 = false; - if(!Config.Tips.ShowPreviewInfo) { + if(Config.Tips.ShowPreviewInfo) { SizeF ef; string text = Path.GetFileName(path) + "\r\n"; if(thumbnail && (toolTipText != null)) { This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <mas...@us...> - 2011-12-09 07:46:49
|
Revision: 359 http://qttabbar.svn.sourceforge.net/qttabbar/?rev=359&view=rev Author: masamunexgp Date: 2011-12-09 07:46:43 +0000 (Fri, 09 Dec 2011) Log Message: ----------- Cleaned up text/media extension listbox code, made a few improvements. Modified Paths: -------------- branches/options/QTTabBar/EditableHeader.xaml.cs branches/options/QTTabBar/OptionsDialog.xaml branches/options/QTTabBar/OptionsDialog.xaml.cs Modified: branches/options/QTTabBar/EditableHeader.xaml.cs =================================================================== --- branches/options/QTTabBar/EditableHeader.xaml.cs 2011-12-09 00:52:10 UTC (rev 358) +++ branches/options/QTTabBar/EditableHeader.xaml.cs 2011-12-09 07:46:43 UTC (rev 359) @@ -42,6 +42,11 @@ set { SetValue(CancelIfEmptyProperty, value); } } + public bool IsEditing { + get { return (bool)GetValue(IsEditingProperty); } + set { SetValue(IsEditingProperty, value); } + } + public static readonly DependencyProperty TextProperty = DependencyProperty.Register("Text", typeof(string), typeof(EditableHeader), new FrameworkPropertyMetadata("New Header", FrameworkPropertyMetadataOptions.BindsTwoWayByDefault)); @@ -58,6 +63,10 @@ DependencyProperty.Register("CancelIfEmpty", typeof(bool), typeof(EditableHeader), new FrameworkPropertyMetadata(true)); + public static readonly DependencyProperty IsEditingProperty = + DependencyProperty.Register("IsEditing", typeof(bool), typeof(EditableHeader), + new FrameworkPropertyMetadata(false, FrameworkPropertyMetadataOptions.BindsTwoWayByDefault, IsEditingChanged)); + public EditableHeader(string initialName, TreeViewItem item = null) { InitializeComponent(); @@ -70,6 +79,16 @@ public EditableHeader() : this(null) { } + + private static void IsEditingChanged(DependencyObject d, DependencyPropertyChangedEventArgs e) { + EditableHeader header = (EditableHeader)d; + if((bool)e.NewValue && header.txtHeaderEdit.Visibility == Visibility.Hidden) { + header.StartEdit(); + } + else if(!(bool)e.NewValue && header.txtHeaderEdit.Visibility == Visibility.Visible) { + header.EndEdit(); + } + } public void EndEdit() { txtHeaderEdit.Visibility = Visibility.Hidden; @@ -80,6 +99,7 @@ if(CancelIfEmpty && string.IsNullOrEmpty(Text)) { Text = originalText; } + IsEditing = false; } public void StartEdit() { @@ -88,6 +108,7 @@ txtHeaderEdit.CaptureMouse(); txtHeaderEdit.Focus(); txtHeaderEdit.ReleaseMouseCapture(); + IsEditing = true; } private void txtHeaderEdit_LostFocus(object sender, RoutedEventArgs e) { @@ -105,9 +126,7 @@ // We can add a sound if you need to do so. return; } - preparing = (Container != null) - ? Container.IsFocused - : true; + preparing = Container == null || Container.IsFocused; } private void txtHeader_MouseUp(object sender, MouseButtonEventArgs e) { Modified: branches/options/QTTabBar/OptionsDialog.xaml =================================================================== --- branches/options/QTTabBar/OptionsDialog.xaml 2011-12-09 00:52:10 UTC (rev 358) +++ branches/options/QTTabBar/OptionsDialog.xaml 2011-12-09 07:46:43 UTC (rev 359) @@ -305,14 +305,25 @@ Stretch="Fill"/> <qt:EditableHeader Text="{Binding Path=Extension}" + IsEditing="{Binding Path=IsEditing}" Padding="2,0" Margin="0,2" Container="{Binding RelativeSource={RelativeSource AncestorType={x:Type ListBoxItem}}}"/> <TextBlock Text="{Binding Path=FriendlyName}" VerticalAlignment="Center" - Foreground="Gray" - FontSize="10" /> + Margin="0,2,0,0" + FontSize="10"> + <TextBlock.Style> + <Style TargetType="{x:Type TextBlock}"> + <Style.Triggers> + <DataTrigger Binding="{Binding Path=IsSelected}" Value="False"> + <Setter Property="Foreground" Value="Gray"/> + </DataTrigger> + </Style.Triggers> + </Style> + </TextBlock.Style> + </TextBlock> </StackPanel> </DataTemplate> <HierarchicalDataTemplate x:Key="GroupItemTemplate" ItemsSource="{Binding Path=Folders}"> @@ -1267,11 +1278,13 @@ Content="Text filetypes" Height="16" Padding="0" + Margin="2,0" FontWeight="Bold"/> <Label Content="Image and Video filetypes" Height="16" Padding="0" + Margin="2,0" FontWeight="Bold" Grid.Column="2"/> <ListBox @@ -1281,7 +1294,17 @@ Height="200" Grid.Row="1" Grid.RowSpan="3" - Grid.Column="0" SelectionMode="Extended"></ListBox> + Grid.Column="0" + Margin="2" + SelectionMode="Extended"> + <ListBox.ItemContainerStyle> + <Style TargetType="{x:Type ListBoxItem}"> + <Setter + Property="IsSelected" + Value="{Binding Path=IsSelected, Mode=TwoWay}" /> + </Style> + </ListBox.ItemContainerStyle> + </ListBox> <ListBox x:Name="lstMediaFileTypes" ItemTemplate="{StaticResource FileTypeItemTemplate}" @@ -1289,7 +1312,17 @@ Height="200" Grid.Row="1" Grid.RowSpan="3" - Grid.Column="2" SelectionMode="Extended"></ListBox> + Grid.Column="2" + Margin="2" + SelectionMode="Extended"> + <ListBox.ItemContainerStyle> + <Style TargetType="{x:Type ListBoxItem}"> + <Setter + Property="IsSelected" + Value="{Binding Path=IsSelected, Mode=TwoWay}" /> + </Style> + </ListBox.ItemContainerStyle> + </ListBox> <Button x:Name="btnAddTextFileTypes" Content="Add" Modified: branches/options/QTTabBar/OptionsDialog.xaml.cs =================================================================== --- branches/options/QTTabBar/OptionsDialog.xaml.cs 2011-12-09 00:52:10 UTC (rev 358) +++ branches/options/QTTabBar/OptionsDialog.xaml.cs 2011-12-09 07:46:43 UTC (rev 359) @@ -16,6 +16,7 @@ // along with QTTabBar. If not, see <http://www.gnu.org/licenses/>. using System; +using System.Collections; using System.Collections.Generic; using System.Collections.ObjectModel; using System.ComponentModel; @@ -389,6 +390,7 @@ private void UpdateOptions() { List<PluginAssembly> assemblies; + CommitTips(); CommitMouse(); CommitPlugins(out assemblies); CommitButtonBar(); @@ -475,72 +477,64 @@ #region ---------- Tooltips ---------- private void InitializeTips() { - TextFileTypes = new ObservableCollection<FileTypeEntry>(); - MediaFileTypes = new ObservableCollection<FileTypeEntry>(); + TextFileTypes = new ObservableCollection<FileTypeEntry>( + workingConfig.tips.TextExt.Select(ext => new FileTypeEntry(ext))); + MediaFileTypes = new ObservableCollection<FileTypeEntry>( + workingConfig.tips.ImageExt.Select(ext => new FileTypeEntry(ext))); lstTextFileTypes.ItemsSource = TextFileTypes; lstMediaFileTypes.ItemsSource = MediaFileTypes; } - // PENDING: Where is the method like this..? - private void AddRange<TInput, TOutput>(ICollection<TOutput> dest, IEnumerable<TInput> src) where TInput : class where TOutput : class { - foreach(TInput val in src) { - dest.Add(val as TOutput); - } + private void CommitTips() { + workingConfig.tips.TextExt = TextFileTypes.Select(entry => entry.Extension).ToList(); + workingConfig.tips.ImageExt = MediaFileTypes.Select(entry => entry.Extension).ToList(); } - private void AddNewFileType(System.Windows.Controls.ListBox control) { + private void AddNewFileType(ListBox control) { ICollection<FileTypeEntry> source = (ICollection<FileTypeEntry>)control.ItemsSource; FileTypeEntry item = new FileTypeEntry(); source.Add(item); control.SelectedItem = item; control.ScrollIntoView(item); control.Focus(); - - EnsureGenerated(control, - () => EditLabel((ListBoxItem)FindItemContainer(control, item))); + EnsureGenerated(control, () => { + ((ListBoxItem)FindItemContainer(control, item)).Loaded += delegate { + item.IsEditing = true; + }; + }); + // TODO: leaving ext blank and deselecting should delete the item } - private void FillFileTypes(ICollection<FileTypeEntry> fileTypes, string[] newValues) { - fileTypes.Clear(); - AddRange( - fileTypes, - Array.ConvertAll( - newValues, - (ext) => new FileTypeEntry(ext))); - } - private void btnAddTextFileTypes_Click(object sender, RoutedEventArgs e) { AddNewFileType(lstTextFileTypes); } + private void btnAddMediaFileTypes_Click(object sender, RoutedEventArgs e) { + AddNewFileType(lstMediaFileTypes); + } + private void btnRemoveTextFileTypes_Click(object sender, RoutedEventArgs e) { - foreach(FileTypeEntry item in new System.Collections.ArrayList(lstTextFileTypes.SelectedItems)) { + foreach(FileTypeEntry item in new ArrayList(lstTextFileTypes.SelectedItems)) { TextFileTypes.Remove(item); } } - private void btnResetTextFileTypes_Click(object sender, RoutedEventArgs e) { - FillFileTypes(TextFileTypes, - new string[] { ".txt", ".ini", ".inf", ".cs", ".log", ".js", ".vbs" }); - - lstTextFileTypes.ScrollIntoView(TextFileTypes.First()); - } - - private void btnAddMediaFileTypes_Click(object sender, RoutedEventArgs e) { - AddNewFileType(lstMediaFileTypes); - } - private void btnRemoveMediaFileTypes_Click(object sender, RoutedEventArgs e) { - foreach(FileTypeEntry item in new System.Collections.ArrayList(lstMediaFileTypes.SelectedItems)) { + foreach(FileTypeEntry item in new ArrayList(lstMediaFileTypes.SelectedItems)) { MediaFileTypes.Remove(item); } } - private void btnResetMediaFileTypes_Click(object sender, RoutedEventArgs e) { - FillFileTypes(MediaFileTypes, - ThumbnailTooltipForm.MakeDefaultImgExts().ToArray()); + private void btnResetTextFileTypes_Click(object sender, RoutedEventArgs e) { + lstTextFileTypes.ItemsSource = TextFileTypes = new ObservableCollection<FileTypeEntry>( + new Config._Tips().TextExt.Select(ext => new FileTypeEntry(ext))); + lstTextFileTypes.ScrollIntoView(TextFileTypes.First()); + } + private void btnResetMediaFileTypes_Click(object sender, RoutedEventArgs e) { + lstMediaFileTypes.ItemsSource = MediaFileTypes = new ObservableCollection<FileTypeEntry>( + new Config._Tips().ImageExt.Select(ext => new FileTypeEntry(ext))); lstMediaFileTypes.ScrollIntoView(MediaFileTypes.First()); } @@ -1128,8 +1122,7 @@ return; } EventHandler handler = null; - handler = delegate - { + handler = delegate { if(gen.Status != GeneratorStatus.ContainersGenerated) { return; } @@ -1735,6 +1728,8 @@ private class FileTypeEntry : INotifyPropertyChanged { public event PropertyChangedEventHandler PropertyChanged; + public bool IsSelected { get; set; } + public bool IsEditing { get; set; } public string Extension { get; set; } public string DotExtension { This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <mas...@us...> - 2011-12-09 21:32:15
|
Revision: 360 http://qttabbar.svn.sourceforge.net/qttabbar/?rev=360&view=rev Author: masamunexgp Date: 2011-12-09 21:32:09 +0000 (Fri, 09 Dec 2011) Log Message: ----------- More improvements to the file extension listboxes. Modified Paths: -------------- branches/options/QTTabBar/EditableHeader.xaml.cs branches/options/QTTabBar/OptionsDialog.xaml branches/options/QTTabBar/OptionsDialog.xaml.cs Modified: branches/options/QTTabBar/EditableHeader.xaml.cs =================================================================== --- branches/options/QTTabBar/EditableHeader.xaml.cs 2011-12-09 07:46:43 UTC (rev 359) +++ branches/options/QTTabBar/EditableHeader.xaml.cs 2011-12-09 21:32:09 UTC (rev 360) @@ -90,13 +90,13 @@ } } - public void EndEdit() { + public void EndEdit(bool cancel = false) { txtHeaderEdit.Visibility = Visibility.Hidden; BindingExpression expr = txtHeaderEdit.GetBindingExpression(TextBox.TextProperty); expr.UpdateSource(); - if(CancelIfEmpty && string.IsNullOrEmpty(Text)) { + if(cancel || (CancelIfEmpty && string.IsNullOrEmpty(Text))) { Text = originalText; } IsEditing = false; @@ -119,6 +119,9 @@ if(e.Key == Key.Enter) { EndEdit(); } + else if(e.Key == Key.Escape) { + EndEdit(true); + } } private void txtHeader_MouseDown(object sender, MouseButtonEventArgs e) { Modified: branches/options/QTTabBar/OptionsDialog.xaml =================================================================== --- branches/options/QTTabBar/OptionsDialog.xaml 2011-12-09 07:46:43 UTC (rev 359) +++ branches/options/QTTabBar/OptionsDialog.xaml 2011-12-09 21:32:09 UTC (rev 360) @@ -1296,7 +1296,8 @@ Grid.RowSpan="3" Grid.Column="0" Margin="2" - SelectionMode="Extended"> + SelectionMode="Extended" + KeyDown="LstTextFileTypes_OnKeyDown"> <ListBox.ItemContainerStyle> <Style TargetType="{x:Type ListBoxItem}"> <Setter @@ -1314,7 +1315,8 @@ Grid.RowSpan="3" Grid.Column="2" Margin="2" - SelectionMode="Extended"> + SelectionMode="Extended" + KeyDown="LstMediaFileTypes_OnKeyDown"> <ListBox.ItemContainerStyle> <Style TargetType="{x:Type ListBoxItem}"> <Setter Modified: branches/options/QTTabBar/OptionsDialog.xaml.cs =================================================================== --- branches/options/QTTabBar/OptionsDialog.xaml.cs 2011-12-09 07:46:43 UTC (rev 359) +++ branches/options/QTTabBar/OptionsDialog.xaml.cs 2011-12-09 21:32:09 UTC (rev 360) @@ -478,9 +478,9 @@ private void InitializeTips() { TextFileTypes = new ObservableCollection<FileTypeEntry>( - workingConfig.tips.TextExt.Select(ext => new FileTypeEntry(ext))); + workingConfig.tips.TextExt.Select(ext => new FileTypeEntry(this, ext))); MediaFileTypes = new ObservableCollection<FileTypeEntry>( - workingConfig.tips.ImageExt.Select(ext => new FileTypeEntry(ext))); + workingConfig.tips.ImageExt.Select(ext => new FileTypeEntry(this, ext))); lstTextFileTypes.ItemsSource = TextFileTypes; lstMediaFileTypes.ItemsSource = MediaFileTypes; @@ -493,19 +493,29 @@ private void AddNewFileType(ListBox control) { ICollection<FileTypeEntry> source = (ICollection<FileTypeEntry>)control.ItemsSource; - FileTypeEntry item = new FileTypeEntry(); + FileTypeEntry item = new FileTypeEntry(this, ""); source.Add(item); control.SelectedItem = item; control.ScrollIntoView(item); control.Focus(); - EnsureGenerated(control, () => { - ((ListBoxItem)FindItemContainer(control, item)).Loaded += delegate { + FindItemContainerAsync(control, item, container => { + ((ListBoxItem)container).Loaded += delegate { item.IsEditing = true; }; }); - // TODO: leaving ext blank and deselecting should delete the item } + private void RemoveSelectedFileType(ListBox control) { + var list = (ObservableCollection<FileTypeEntry>)control.ItemsSource; + int idx = control.SelectedIndex; + if(idx == -1) return; + foreach(FileTypeEntry item in new ArrayList(control.SelectedItems)) { + list.Remove(item); + } + control.SelectedIndex = Math.Min(idx, list.Count-1); + FindItemContainerAsync(control, control.SelectedItem, container => container.Focus()); + } + private void btnAddTextFileTypes_Click(object sender, RoutedEventArgs e) { AddNewFileType(lstTextFileTypes); } @@ -515,29 +525,33 @@ } private void btnRemoveTextFileTypes_Click(object sender, RoutedEventArgs e) { - foreach(FileTypeEntry item in new ArrayList(lstTextFileTypes.SelectedItems)) { - TextFileTypes.Remove(item); - } + RemoveSelectedFileType(lstTextFileTypes); } private void btnRemoveMediaFileTypes_Click(object sender, RoutedEventArgs e) { - foreach(FileTypeEntry item in new ArrayList(lstMediaFileTypes.SelectedItems)) { - MediaFileTypes.Remove(item); - } + RemoveSelectedFileType(lstMediaFileTypes); } private void btnResetTextFileTypes_Click(object sender, RoutedEventArgs e) { lstTextFileTypes.ItemsSource = TextFileTypes = new ObservableCollection<FileTypeEntry>( - new Config._Tips().TextExt.Select(ext => new FileTypeEntry(ext))); + new Config._Tips().TextExt.Select(ext => new FileTypeEntry(this, ext))); lstTextFileTypes.ScrollIntoView(TextFileTypes.First()); } private void btnResetMediaFileTypes_Click(object sender, RoutedEventArgs e) { lstMediaFileTypes.ItemsSource = MediaFileTypes = new ObservableCollection<FileTypeEntry>( - new Config._Tips().ImageExt.Select(ext => new FileTypeEntry(ext))); + new Config._Tips().ImageExt.Select(ext => new FileTypeEntry(this, ext))); lstMediaFileTypes.ScrollIntoView(MediaFileTypes.First()); } + private void LstTextFileTypes_OnKeyDown(object sender, KeyEventArgs e) { + if(e.Key == Key.Delete) RemoveSelectedFileType(lstTextFileTypes); + } + + private void LstMediaFileTypes_OnKeyDown(object sender, KeyEventArgs e) { + if(e.Key == Key.Delete) RemoveSelectedFileType(lstMediaFileTypes); + } + #endregion #region ---------- Appearance ---------- @@ -564,6 +578,13 @@ } } + private void btnRebarBGColorChoose_Click(object sender, RoutedEventArgs e) { + ColorDialogEx cd = new ColorDialogEx { Color = workingConfig.skin.RebarColor }; + if(System.Windows.Forms.DialogResult.OK == cd.ShowDialog()) { + workingConfig.skin.RebarColor = cd.Color; + } + } + #endregion #region ---------- Mouse ---------- @@ -1022,26 +1043,6 @@ return null; } - private UIElement FindItemContainer(ItemsControl parent, object childItem) { - if(parent.ItemContainerGenerator.Status != GeneratorStatus.ContainersGenerated) { - return null; - } - UIElement container = (UIElement)parent.ItemContainerGenerator.ContainerFromItem(childItem); - if(container != null) { - return container; - } - foreach(object item in parent.Items) { - ItemsControl child = parent.ItemContainerGenerator.ContainerFromItem(item) as ItemsControl; - if(child != null && child.Items.Count > 0) { - UIElement result = FindItemContainer(child, childItem); - if(result != null) { - return result; - } - } - } - return null; - } - private GroupEntry GetParentGroup(FolderEntry folder) { return (GroupEntry)CurrentGroups.FirstOrDefault((entry) => { @@ -1115,23 +1116,6 @@ } } - private void EnsureGenerated(ItemsControl control, Action pred) { - ItemContainerGenerator gen = control.ItemContainerGenerator; - if(gen.Status == GeneratorStatus.ContainersGenerated) { - pred(); - return; - } - EventHandler handler = null; - handler = delegate { - if(gen.Status != GeneratorStatus.ContainersGenerated) { - return; - } - pred(); - gen.StatusChanged -= handler; - }; - gen.StatusChanged += handler; - } - private int GetPreferredInsertionIndex(TreeView tvw) { object val = tvw.SelectedItem; if(val == null) { @@ -1151,9 +1135,8 @@ GetPreferredInsertionIndex(tvw), item); - EnsureGenerated(tvw, delegate - { - TreeViewItem container = (TreeViewItem)FindItemContainer(tvw, item); + FindItemContainerAsync(tvw, item, obj => { + TreeViewItem container = (TreeViewItem)obj; container.IsSelected = true; if(editName != null) { @@ -1211,11 +1194,7 @@ TreeViewItem parent = (TreeViewItem)FindItemContainer(tvwGroups, group); parent.IsExpanded = true; - EnsureGenerated(parent, delegate - { - TreeViewItem container = (TreeViewItem)FindItemContainer(tvwGroups, folder); - container.IsSelected = true; - }); + FindItemContainerAsync(parent, folder, cont => ((TreeViewItem)cont).IsSelected = true); } private void btnGroupsRemoveNode_Click(object sender, RoutedEventArgs e) { @@ -1541,6 +1520,62 @@ #endregion + #region ---------- Common Utility Functions ---------- + + private UIElement FindItemContainer(ItemsControl parent, object childItem) { + if(parent.ItemContainerGenerator.Status != GeneratorStatus.ContainersGenerated) { + return null; + } + UIElement container = (UIElement)parent.ItemContainerGenerator.ContainerFromItem(childItem); + if(container != null) { + return container; + } + foreach(object item in parent.Items) { + ItemsControl child = parent.ItemContainerGenerator.ContainerFromItem(item) as ItemsControl; + if(child != null && child.Items.Count > 0) { + UIElement result = FindItemContainer(child, childItem); + if(result != null) { + return result; + } + } + } + return null; + } + + private delegate void ItemContainerAction(UIElement container); + private void FindItemContainerAsync(ItemsControl parent, object childItem, ItemContainerAction pred) { + ItemContainerGenerator gen = parent.ItemContainerGenerator; + if(gen.Status == GeneratorStatus.ContainersGenerated) { + pred(FindItemContainer(parent, childItem)); + return; + } + EventHandler handler = null; + handler = delegate { + if(gen.Status != GeneratorStatus.ContainersGenerated) { + return; + } + pred(FindItemContainer(parent, childItem)); + gen.StatusChanged -= handler; + }; + gen.StatusChanged += handler; + } + + // Draws a control to a bitmap + private static BitmapSource ConvertToBitmapSource(UIElement element) { + var target = new RenderTargetBitmap((int)(element.RenderSize.Width), (int)(element.RenderSize.Height), 96, 96, PixelFormats.Pbgra32); + var brush = new VisualBrush(element); + var visual = new DrawingVisual(); + var drawingContext = visual.RenderOpen(); + + drawingContext.DrawRectangle(brush, null, new Rect(new Point(0, 0), + new Point(element.RenderSize.Width, element.RenderSize.Height))); + drawingContext.Close(); + target.Render(visual); + return target; + } + + #endregion + #region ---------- Binding Classes ---------- #pragma warning disable 0067 // "The event 'PropertyChanged' is never used" // ReSharper disable MemberCanBePrivate.Local @@ -1727,9 +1762,21 @@ private class FileTypeEntry : INotifyPropertyChanged { public event PropertyChangedEventHandler PropertyChanged; + private OptionsDialog parent; + private bool _IsEditing; + public bool IsEditing { + get { return _IsEditing; } + set { + _IsEditing = value; + if(!_IsEditing && string.IsNullOrEmpty(Extension)) { + parent.TextFileTypes.Remove(this); + parent.MediaFileTypes.Remove(this); + } + } + } + public bool IsSelected { get; set; } - public bool IsEditing { get; set; } public string Extension { get; set; } public string DotExtension { @@ -1764,15 +1811,13 @@ return QTUtility.GetIcon(DotExtension, true).ToBitmap(); } } - public FileTypeEntry(string extension) { + public FileTypeEntry(OptionsDialog parent, string extension) { + this.parent = parent; if(!extension.StartsWith(".")) { extension = "." + extension; } DotExtension = extension; } - public FileTypeEntry() { - DotExtension = "."; - } } private class SeparatorEntry { @@ -1809,7 +1854,7 @@ private class GroupEntry : INotifyPropertyChanged { public event PropertyChangedEventHandler PropertyChanged; - public string Name { get; private set; } + public string Name { get; set; } public Image Icon { get; private set; } public ObservableCollection<FolderEntry> Folders { get; private set; } public bool Startup { get; set; } @@ -1879,27 +1924,6 @@ } } - private void btnRebarBGColorChoose_Click(object sender, RoutedEventArgs e) { - ColorDialogEx cd = new ColorDialogEx {Color = workingConfig.skin.RebarColor}; - if(System.Windows.Forms.DialogResult.OK == cd.ShowDialog()) { - workingConfig.skin.RebarColor = cd.Color; - } - } - - // Draws a control to a bitmap - private static BitmapSource ConvertToBitmapSource(UIElement element) { - var target = new RenderTargetBitmap((int)(element.RenderSize.Width), (int)(element.RenderSize.Height), 96, 96, PixelFormats.Pbgra32); - var brush = new VisualBrush(element); - var visual = new DrawingVisual(); - var drawingContext = visual.RenderOpen(); - - drawingContext.DrawRectangle(brush, null, new Rect(new Point(0, 0), - new Point(element.RenderSize.Width, element.RenderSize.Height))); - drawingContext.Close(); - target.Render(visual); - return target; - } - private void btnRecentFilesClear_Click(object sender, RoutedEventArgs e) { // TODO } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <mas...@us...> - 2011-12-10 05:29:20
|
Revision: 361 http://qttabbar.svn.sourceforge.net/qttabbar/?rev=361&view=rev Author: masamunexgp Date: 2011-12-10 05:29:13 +0000 (Sat, 10 Dec 2011) Log Message: ----------- Some optimizations to the Groups tab. Modified Paths: -------------- branches/options/QTTabBar/EditableHeader.xaml branches/options/QTTabBar/EditableHeader.xaml.cs branches/options/QTTabBar/OptionsDialog.xaml branches/options/QTTabBar/OptionsDialog.xaml.cs Modified: branches/options/QTTabBar/EditableHeader.xaml =================================================================== --- branches/options/QTTabBar/EditableHeader.xaml 2011-12-09 21:32:09 UTC (rev 360) +++ branches/options/QTTabBar/EditableHeader.xaml 2011-12-10 05:29:13 UTC (rev 361) @@ -25,6 +25,7 @@ VerticalContentAlignment="Center" MinWidth="10" LostFocus="txtHeaderEdit_LostFocus" + LostKeyboardFocus="txtHeaderEdit_LostFocus" KeyDown="txtHeaderEdit_KeyDown" Visibility="Hidden" /> </Grid> Modified: branches/options/QTTabBar/EditableHeader.xaml.cs =================================================================== --- branches/options/QTTabBar/EditableHeader.xaml.cs 2011-12-09 21:32:09 UTC (rev 360) +++ branches/options/QTTabBar/EditableHeader.xaml.cs 2011-12-10 05:29:13 UTC (rev 361) @@ -104,6 +104,7 @@ public void StartEdit() { originalText = Text; + txtHeaderEdit.SelectAll(); txtHeaderEdit.Visibility = Visibility.Visible; txtHeaderEdit.CaptureMouse(); txtHeaderEdit.Focus(); @@ -112,7 +113,7 @@ } private void txtHeaderEdit_LostFocus(object sender, RoutedEventArgs e) { - EndEdit(); + if(IsEditing) EndEdit(); } private void txtHeaderEdit_KeyDown(object sender, KeyEventArgs e) { Modified: branches/options/QTTabBar/OptionsDialog.xaml =================================================================== --- branches/options/QTTabBar/OptionsDialog.xaml 2011-12-09 21:32:09 UTC (rev 360) +++ branches/options/QTTabBar/OptionsDialog.xaml 2011-12-10 05:29:13 UTC (rev 361) @@ -396,6 +396,7 @@ x:Name="txtName" Text="{Binding Path=Name}" Visibility="Collapsed" + IsEditing="{Binding Path=IsEditing}" Container="{Binding RelativeSource={RelativeSource AncestorType={x:Type TreeViewItem}}}"/> <qt:EditableHeader x:Name="txtPath" Modified: branches/options/QTTabBar/OptionsDialog.xaml.cs =================================================================== --- branches/options/QTTabBar/OptionsDialog.xaml.cs 2011-12-09 21:32:09 UTC (rev 360) +++ branches/options/QTTabBar/OptionsDialog.xaml.cs 2011-12-10 05:29:13 UTC (rev 361) @@ -498,11 +498,8 @@ control.SelectedItem = item; control.ScrollIntoView(item); control.Focus(); - FindItemContainerAsync(control, item, container => { - ((ListBoxItem)container).Loaded += delegate { - item.IsEditing = true; - }; - }); + FindItemContainerAsync(control, item, container => + RunOnLoad((FrameworkElement)container, delegate { item.IsEditing = true; })); } private void RemoveSelectedFileType(ListBox control) { @@ -1018,44 +1015,13 @@ } } - public static DependencyObject FindVisualChildByName(DependencyObject parent, string name) { - for(int i = 0; i < VisualTreeHelper.GetChildrenCount(parent); i++) { - DependencyObject child = VisualTreeHelper.GetChild(parent, i); - string controlName = child.GetValue(System.Windows.Controls.Control.NameProperty) as string; - if(controlName == name) { - return child; - } - // The following makes it possible to find x:Name attributes. - if(child is ContentPresenter) { - ContentPresenter content = (ContentPresenter)child; - DataTemplate template = content.ContentTemplate; - if(template != null) { - object obj = template.FindName(name, content); - if(obj != null) { - return obj as DependencyObject; - } - } - } - DependencyObject result = FindVisualChildByName(child, name); - if(result != null) - return result; - } - return null; - } - private GroupEntry GetParentGroup(FolderEntry folder) { - return (GroupEntry)CurrentGroups.FirstOrDefault((entry) => - { - GroupEntry group = entry as GroupEntry; - if(group == null) { - return false; - } - return group.Folders.Contains(folder); - }); + return CurrentGroups.OfType<GroupEntry>().FirstOrDefault( + entry => entry.Folders.Contains(folder)); } private void UpDownOnTreeView(ItemsControl control, object val, bool up) { - System.Collections.IList col = (System.Collections.IList)control.ItemsSource; + IList col = (IList)control.ItemsSource; int index = col.IndexOf(val); if(index == -1) { return; @@ -1099,23 +1065,6 @@ } } - private void EditLabel(FrameworkElement container, string name = "EditableHeaderControl") { - Action pred = delegate - { - EditableHeader edit = FindVisualChildByName(container, name) as EditableHeader; - if(edit == null || edit.Visibility != Visibility.Visible) { - return; - } - edit.StartEdit(); - }; - if(container.IsLoaded) { - pred(); - } - else { - container.Loaded += delegate { pred(); }; - } - } - private int GetPreferredInsertionIndex(TreeView tvw) { object val = tvw.SelectedItem; if(val == null) { @@ -1129,18 +1078,17 @@ return index + 1; } - private void AddNew(TreeView tvw, object item, string editName = null) { - System.Collections.IList col = (System.Collections.IList)tvw.ItemsSource; - col.Insert( - GetPreferredInsertionIndex(tvw), - item); + private void AddNewGroupItem(TreeView tvw, object item) { + IList col = (IList)tvw.ItemsSource; + col.Insert(GetPreferredInsertionIndex(tvw), item); FindItemContainerAsync(tvw, item, obj => { TreeViewItem container = (TreeViewItem)obj; container.IsSelected = true; - if(editName != null) { - EditLabel(container, editName); + GroupEntry entry = item as GroupEntry; + if(entry != null) { + RunOnLoad(container, delegate { entry.IsEditing = true; }); } }); } @@ -1154,11 +1102,11 @@ } private void btnGroupsAddSeparator_Click(object sender, RoutedEventArgs e) { - AddNew(tvwGroups, new SeparatorEntry()); + AddNewGroupItem(tvwGroups, new SeparatorEntry()); } private void btnGroupsAddGroup_Click(object sender, RoutedEventArgs e) { - AddNew(tvwGroups, new GroupEntry("New Group"), "txtName"); + AddNewGroupItem(tvwGroups, new GroupEntry("New Group")); } private void btnGroupsAddFolder_Click(object sender, RoutedEventArgs e) { @@ -1522,7 +1470,16 @@ #region ---------- Common Utility Functions ---------- - private UIElement FindItemContainer(ItemsControl parent, object childItem) { + private static void RunOnLoad(FrameworkElement element, Action pred) { + RoutedEventHandler del = null; + del = delegate { + pred(); + element.Loaded -= del; + }; + element.Loaded += del; + } + + private static UIElement FindItemContainer(ItemsControl parent, object childItem) { if(parent.ItemContainerGenerator.Status != GeneratorStatus.ContainersGenerated) { return null; } @@ -1543,7 +1500,7 @@ } private delegate void ItemContainerAction(UIElement container); - private void FindItemContainerAsync(ItemsControl parent, object childItem, ItemContainerAction pred) { + private static void FindItemContainerAsync(ItemsControl parent, object childItem, ItemContainerAction pred) { ItemContainerGenerator gen = parent.ItemContainerGenerator; if(gen.Status == GeneratorStatus.ContainersGenerated) { pred(FindItemContainer(parent, childItem)); @@ -1859,6 +1816,7 @@ public ObservableCollection<FolderEntry> Folders { get; private set; } public bool Startup { get; set; } public int ShortcutKey { get; set; } + public bool IsEditing { get; set; } private void Folders_CollectionChanged(object sender, System.Collections.Specialized.NotifyCollectionChangedEventArgs e) { if(e.OldItems != null) { @@ -1881,7 +1839,7 @@ } private void RefreshIcon() { - Icon = Folders.Count == 0 ? Resources_Image.icoEmpty.ToBitmap() : Folders.First().Icon; + Icon = Folders.Count == 0 ? QTUtility.ImageListGlobal.Images["folder"] : Folders.First().Icon; } public GroupEntry(string name) { This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <mas...@us...> - 2011-12-12 07:22:45
|
Revision: 363 http://qttabbar.svn.sourceforge.net/qttabbar/?rev=363&view=rev Author: masamunexgp Date: 2011-12-12 07:22:38 +0000 (Mon, 12 Dec 2011) Log Message: ----------- Implemented shortcut keys for groups. Modified Paths: -------------- branches/options/QTTabBar/OptionsDialog.xaml branches/options/QTTabBar/OptionsDialog.xaml.cs Modified: branches/options/QTTabBar/OptionsDialog.xaml =================================================================== --- branches/options/QTTabBar/OptionsDialog.xaml 2011-12-11 21:08:19 UTC (rev 362) +++ branches/options/QTTabBar/OptionsDialog.xaml 2011-12-12 07:22:38 UTC (rev 363) @@ -1942,10 +1942,10 @@ <TabItem x:Name="tabGroups" Header="Groups" Width="0"> - <StackPanel - Margin="14,5,10,0" - Orientation="Vertical"> + <DockPanel + Margin="14,5,10,0"> <StackPanel + DockPanel.Dock="Top" Margin="0,0,0,4" Orientation="Horizontal"> <Image @@ -1957,6 +1957,7 @@ VerticalAlignment="Bottom"/> </StackPanel> <Grid + DockPanel.Dock="Top" Margin="0,10,0,0"> <Grid.ColumnDefinitions> <ColumnDefinition Width="Auto"/> @@ -2010,8 +2011,35 @@ Width="28" Click="btnGroupsRemoveNode_Click" /> </Grid> + <DockPanel + DataContext="{Binding ElementName=tvwGroups, Path=SelectedItem}" + DockPanel.Dock="Bottom" + Margin="0,10,0,20"> + <DockPanel.Style> + <Style TargetType="{x:Type DockPanel}"> + <Setter Property="IsEnabled" Value="False"/> + <Style.Triggers> + <DataTrigger Binding="{Binding Converter={StaticResource ObjectToClassNameConverter}}" Value="GroupEntry"> + <Setter Property="IsEnabled" Value="True"/> + </DataTrigger> + </Style.Triggers> + </Style> + </DockPanel.Style> + <Label + Content="Shortcut Key:" + DockPanel.Dock="Left" + Height="23" + Margin="0,0,10,0" + Padding="0" + VerticalContentAlignment="Center"/> + <TextBox x:Name="txtGroupHotkey" + Height="23" + IsReadOnly="True" + PreviewKeyDown="txtGroupHotkey_OnPreviewKeyDown" + Text="{Binding Path=HotkeyString, Mode=OneWay}"/> + </DockPanel> <r:TreeListView x:Name="tvwGroups" - Height="338"> + MouseDown="tvwGroups_MouseDown"> <TreeView.ItemTemplate> <HierarchicalDataTemplate ItemsSource="{Binding Path=Folders}"/> </TreeView.ItemTemplate> @@ -2101,18 +2129,7 @@ </GridViewColumn> </r:TreeListView.Columns> </r:TreeListView> - <DockPanel - Margin="0,10,0,0"> - <Label - Content="Shortcut Key:" - DockPanel.Dock="Left" - Height="23" - Margin="0,0,10,0" - Padding="0" - VerticalContentAlignment="Center"/> - <TextBox Height="23"/> - </DockPanel> - </StackPanel> + </DockPanel> </TabItem> <!-- ============= APPS ============= --> Modified: branches/options/QTTabBar/OptionsDialog.xaml.cs =================================================================== --- branches/options/QTTabBar/OptionsDialog.xaml.cs 2011-12-11 21:08:19 UTC (rev 362) +++ branches/options/QTTabBar/OptionsDialog.xaml.cs 2011-12-12 07:22:38 UTC (rev 363) @@ -72,8 +72,10 @@ private ObservableCollection<FileTypeEntry> MediaFileTypes; // Groups stuff - private ObservableCollection<object> CurrentGroups; + private ObservableCollection<GroupEntry> CurrentGroups; + private List<HotkeyEntry> HotkeyEntries; + // todo: localize all of these #region ToLocalize @@ -617,8 +619,7 @@ ICollectionView view = CollectionViewSource.GetDefaultView(MouseBindings); PropertyGroupDescription groupDescription = new PropertyGroupDescription("TargetText"); view.GroupDescriptions.Add(groupDescription); - lvwHotkeys.ItemsSource = view; - lvwMouseBindings.ItemsSource = MouseBindings; + lvwMouseBindings.ItemsSource = view; cmbMouseModifiers.ItemsSource = MouseModifierItems; cmbMouseTarget.ItemsSource = MouseTargetItems; @@ -798,10 +799,10 @@ string[] arrActions = QTUtility.TextResourcesDic["ShortcutKeys_ActionNames"]; string[] arrGrps = QTUtility.TextResourcesDic["ShortcutKeys_Groups"]; int[] keys = workingConfig.keys.Shortcuts; - List<HotkeyEntry> list = new List<HotkeyEntry>(); + HotkeyEntries = new List<HotkeyEntry>(); // todo: validate arrActions length for(int i = 0; i <= (int)QTUtility.LAST_KEYBOARD_ACTION; ++i) { - list.Add(new HotkeyEntry(keys, i, arrActions[i], arrGrps[0])); + HotkeyEntries.Add(new HotkeyEntry(keys, i, arrActions[i], arrGrps[0])); } foreach(string pluginID in QTUtility.dicPluginShortcutKeys.Keys) { @@ -816,9 +817,9 @@ // Hmm, I don't like this... QTUtility.dicPluginShortcutKeys[pluginID] = keys; } - list.AddRange(pi.ShortcutKeyActions.Select((act, i) => new HotkeyEntry(keys, i, act, group))); + HotkeyEntries.AddRange(pi.ShortcutKeyActions.Select((act, i) => new HotkeyEntry(keys, i, act, group))); } - ICollectionView view = CollectionViewSource.GetDefaultView(list); + ICollectionView view = CollectionViewSource.GetDefaultView(HotkeyEntries); PropertyGroupDescription groupDescription = new PropertyGroupDescription("Group"); view.GroupDescriptions.Add(groupDescription); lvwHotkeys.ItemsSource = view; @@ -826,22 +827,33 @@ private bool CheckForKeyConflicts(Keys key) { const string Conflict = "This key is already assigned to:\n{0}\n\nReassign?"; - //const string GroupPrefix = "Open group \"{0}\""; + const string GroupPrefix = "Open group \"{0}\""; //const string AppPrefix = "Launch application \"{0}\""; const string MsgTitle = "Keystroke conflict"; - foreach(HotkeyEntry entry in lvwHotkeys.Items) { - if(entry.Key == key) { - if(MessageBox.Show(string.Format(Conflict, entry.Action), MsgTitle, MessageBoxButton.OKCancel, MessageBoxImage.Warning) == MessageBoxResult.OK) { - entry.Key = Keys.None; - // todo: refresh? - } - else { - return false; - } + + HotkeyEntry hotkey = HotkeyEntries.FirstOrDefault(e => e.Key == key); + if(hotkey != null) { + if(MessageBox.Show(string.Format(Conflict, hotkey.Action), MsgTitle, MessageBoxButton.OKCancel, MessageBoxImage.Warning) == MessageBoxResult.OK) { + hotkey.Key = Keys.None; + return true; } + else { + return false; + } } - // todo gropus and apps + GroupEntry group = CurrentGroups.FirstOrDefault(e => e.ShortcutKey == key); + if(group != null) { + if(MessageBox.Show(string.Format(Conflict, string.Format(GroupPrefix, group.Name)), MsgTitle, MessageBoxButton.OKCancel, MessageBoxImage.Warning) == MessageBoxResult.OK) { + group.ShortcutKey = Keys.None; + return true; + } + else { + return false; + } + } + + // todo: apps return true; } @@ -910,35 +922,13 @@ private void lvwHotkeys_PreviewKeyDown(object sender, KeyEventArgs e) { if(lvwHotkeys.SelectedItems.Count != 1) return; - Key wpfKey = (e.Key == Key.System ? e.SystemKey : e.Key); - ModifierKeys wpfModKeys = Keyboard.Modifiers; - - // Ignore modifier keys. - if(wpfKey == Key.LeftShift || wpfKey == Key.RightShift - || wpfKey == Key.LeftCtrl || wpfKey == Key.RightCtrl - || wpfKey == Key.LeftAlt || wpfKey == Key.RightAlt - || wpfKey == Key.LWin || wpfKey == Key.RWin) { - return; - } - - // Urgh, so many conversions between WPF and WinForms... - Keys key = (Keys)KeyInterop.VirtualKeyFromKey(wpfKey); - Keys modKeys = Keys.None; - 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; - e.Handled = true; - } - else if(entry.Key != (key | modKeys) && !IsInvalidShortcutKey(key, modKeys) && CheckForKeyConflicts(key | modKeys)) { - bool enable = !entry.Assigned; - entry.Key = key | modKeys; - if(enable) entry.Enabled = true; - e.Handled = true; - } + Keys newKey; + if(!ProcessNewHotkey(e, entry.Key, out newKey)) return; + bool wasNotAssigned = !entry.Assigned; + entry.Key = newKey; + if(wasNotAssigned && entry.Assigned) entry.Enabled = true; + e.Handled = true; } private void lvwHotkeys_TextInput(object sender, TextCompositionEventArgs e) { @@ -950,13 +940,13 @@ #region ---------- Groups ---------- private void InitializeGroups() { - CurrentGroups = new ObservableCollection<object>(); + CurrentGroups = new ObservableCollection<GroupEntry>(); foreach(KeyValuePair<string, string> pair in QTUtility.GroupPathsDic) { GroupEntry group = new GroupEntry(pair.Key); group.Startup = QTUtility.StartUpGroupList.Contains(group.Name); if(QTUtility.dicGroupNamesAndKeys.ContainsKey(group.Name)) { - group.ShortcutKey = QTUtility.dicGroupNamesAndKeys[group.Name]; + //group.ShortcutKey = QTUtility.dicGroupNamesAndKeys[group.Name]; } foreach(string path in pair.Value.Split(QTUtility.SEPARATOR_CHAR)) { FolderEntry folder = new FolderEntry(path); @@ -975,8 +965,7 @@ QTUtility.dicGroupNamesAndKeys.Clear(); List<PluginKey> list = new List<PluginKey>(); int num = 1; - foreach(object entry in CurrentGroups) { - GroupEntry group = (GroupEntry)entry; + foreach(GroupEntry group in CurrentGroups) { if(group.Folders.Count > 0) { string text = group.Name; if(text.Length > 0) { @@ -991,11 +980,12 @@ QTUtility.StartUpGroupList.Add(item); } if(group.ShortcutKey != 0) { + /* if(group.ShortcutKey > 0x100000) { QTUtility.dicGroupShortcutKeys[group.ShortcutKey] = item; } QTUtility.dicGroupNamesAndKeys[item] = group.ShortcutKey; - list.Add(new PluginKey(item, new int[] { group.ShortcutKey })); + list.Add(new PluginKey(item, new int[] { group.ShortcutKey }));*/ } } } @@ -1068,16 +1058,10 @@ } private int GetPreferredInsertionIndex(TreeView tvw) { - object val = tvw.SelectedItem; - if(val == null) { - return tvw.Items.Count; - } - if(val is FolderEntry) { - // Goes up one level when a child is selected. - val = GetParentGroup((FolderEntry)val); - } - int index = CurrentGroups.IndexOf(val); - return index + 1; + object sel = tvw.SelectedItem; + return sel == null + ? tvw.Items.Count + : CurrentGroups.IndexOf(sel as GroupEntry ?? GetParentGroup((FolderEntry)sel)) + 1; } private void AddNewGroupItem(TreeView tvw, object item) { @@ -1110,27 +1094,23 @@ private void btnGroupsAddFolder_Click(object sender, RoutedEventArgs e) { // TODO: Generates new group if the view is empty. - object val = tvwGroups.SelectedItem; - if(val == null) { - return; - } + object sel = tvwGroups.SelectedItem; + if(sel == null) return; GroupEntry group; int index; - if(val is FolderEntry) { - FolderEntry entry = (FolderEntry)val; + if(sel is FolderEntry) { + FolderEntry entry = (FolderEntry)sel; group = GetParentGroup(entry); index = group.Folders.IndexOf(entry) + 1; } else { - group = (GroupEntry)val; + group = (GroupEntry)sel; index = group.Folders.Count; } FolderBrowserDialogEx dlg = new FolderBrowserDialogEx(); - if(dlg.ShowDialog() != System.Windows.Forms.DialogResult.OK) { - return; - } + if(dlg.ShowDialog() != System.Windows.Forms.DialogResult.OK) return; FolderEntry folder = new FolderEntry(dlg.SelectedPath); group.Folders.Insert(index, folder); @@ -1141,26 +1121,34 @@ } private void btnGroupsRemoveNode_Click(object sender, RoutedEventArgs e) { - object val = tvwGroups.SelectedItem; - if(val == null) { - return; - } + object sel = tvwGroups.SelectedItem; + if(sel == null) return; - System.Collections.IList col; - if(val is FolderEntry) { - GroupEntry group = GetParentGroup((FolderEntry)val); - col = group.Folders; - } - else { - col = CurrentGroups; - } - int index = col.IndexOf(val); + IList col = sel is GroupEntry + ? (IList)CurrentGroups + : GetParentGroup((FolderEntry)sel).Folders; + + int index = col.IndexOf(sel); col.RemoveAt(index); - if(index < col.Count) { - object next = col[index]; - TreeViewItem container = (TreeViewItem)FindItemContainer(tvwGroups, next); - container.IsSelected = true; + if(index >= col.Count) return; + object next = col[index]; + TreeViewItem container = (TreeViewItem)FindItemContainer(tvwGroups, next); + container.IsSelected = true; + } + + private void tvwGroups_MouseDown(object sender, MouseButtonEventArgs e) { + GroupEntry entry = tvwGroups.SelectedItem as GroupEntry; + if(entry != null) entry.IsEditing = false; + } + + private void txtGroupHotkey_OnPreviewKeyDown(object sender, KeyEventArgs e) { + e.Handled = true; + if(!(tvwGroups.SelectedItem is GroupEntry)) return; + GroupEntry entry = (GroupEntry)tvwGroups.SelectedItem; + Keys newKey; + if(ProcessNewHotkey(e, entry.ShortcutKey, out newKey)) { + entry.ShortcutKey = newKey; } } @@ -1465,6 +1453,41 @@ #region ---------- Common Utility Functions ---------- + private bool ProcessNewHotkey(KeyEventArgs e, Keys current, out Keys hotkey) { + Key wpfKey = (e.Key == Key.System ? e.SystemKey : e.Key); + ModifierKeys wpfModKeys = Keyboard.Modifiers; + + // Ignore modifier keys. + if(wpfKey == Key.LeftShift || wpfKey == Key.RightShift + || wpfKey == Key.LeftCtrl || wpfKey == Key.RightCtrl + || wpfKey == Key.LeftAlt || wpfKey == Key.RightAlt + || wpfKey == Key.LWin || wpfKey == Key.RWin) { + hotkey = Keys.None; + return false; + } + + // Urgh, so many conversions between WPF and WinForms... + hotkey = (Keys)KeyInterop.VirtualKeyFromKey(wpfKey); + Keys modKeys = Keys.None; + if((wpfModKeys & ModifierKeys.Alt) != 0) modKeys |= Keys.Alt; + if((wpfModKeys & ModifierKeys.Control) != 0) modKeys |= Keys.Control; + if((wpfModKeys & ModifierKeys.Shift) != 0) modKeys |= Keys.Shift; + + + if(hotkey == Keys.Escape) { + hotkey = Keys.None; + return true; + } + else if(current != (hotkey | modKeys) && !IsInvalidShortcutKey(hotkey, modKeys) && CheckForKeyConflicts(hotkey | modKeys)) { + hotkey |= modKeys; + return true; + } + else { + hotkey = Keys.None; + return false; + } + } + private static void RunOnLoad(FrameworkElement element, Action pred) { RoutedEventHandler del = null; del = delegate { @@ -1809,11 +1832,10 @@ public Image Icon { get; private set; } public ObservableCollection<FolderEntry> Folders { get; private set; } public bool Startup { get; set; } - public int ShortcutKey { get; set; } - public string HotkeyString { get { - // todo - return "Ctrl + A"; - }} + public Keys ShortcutKey { get; set; } + public string HotkeyString { + get { return QTUtility2.MakeKeyString(ShortcutKey); } + } public bool IsEditing { get; set; } private void Folders_CollectionChanged(object sender, System.Collections.Specialized.NotifyCollectionChangedEventArgs e) { This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <mas...@us...> - 2011-12-17 22:30:39
|
Revision: 364 http://qttabbar.svn.sourceforge.net/qttabbar/?rev=364&view=rev Author: masamunexgp Date: 2011-12-17 22:30:32 +0000 (Sat, 17 Dec 2011) Log Message: ----------- Completely overhauled the Groups code throughout the program. Moved group management code to its own file. Should be fully functional now. Modified Paths: -------------- branches/options/QTTabBar/Constants.cs branches/options/QTTabBar/CreateNewGroupForm.cs branches/options/QTTabBar/MenuUtility.cs branches/options/QTTabBar/OptionsDialog.xaml branches/options/QTTabBar/OptionsDialog.xaml.cs branches/options/QTTabBar/OptionsDialog_OLD.cs branches/options/QTTabBar/QTButtonBar.cs branches/options/QTTabBar/QTCoTaskBarClass.cs branches/options/QTTabBar/QTTabBar.csproj branches/options/QTTabBar/QTTabBarClass.cs branches/options/QTTabBar/QTUtility.cs Added Paths: ----------- branches/options/QTTabBar/GroupsManager.cs Modified: branches/options/QTTabBar/Constants.cs =================================================================== --- branches/options/QTTabBar/Constants.cs 2011-12-12 07:22:38 UTC (rev 363) +++ branches/options/QTTabBar/Constants.cs 2011-12-17 22:30:32 UTC (rev 364) @@ -23,5 +23,6 @@ static class RegConst { public const string Root = @"Software\QTTabBar\"; public const string Config = @"Config\"; + public const string Groups = @"Groups\"; } } Modified: branches/options/QTTabBar/CreateNewGroupForm.cs =================================================================== --- branches/options/QTTabBar/CreateNewGroupForm.cs 2011-12-12 07:22:38 UTC (rev 363) +++ branches/options/QTTabBar/CreateNewGroupForm.cs 2011-12-17 22:30:32 UTC (rev 364) @@ -24,7 +24,7 @@ internal sealed class CreateNewGroupForm : Form { private Button buttonCancel; private Button buttonOK; - private CheckBox checkBox1; + private CheckBox chkAllTabs; private Label label1; private string newPath; private QTabControl.QTabCollection Tabs; @@ -38,25 +38,21 @@ string[] strArray = QTUtility.TextResourcesDic["TabBar_NewGroup"]; Text = strArray[0]; label1.Text = strArray[1]; - checkBox1.Text = strArray[2]; + chkAllTabs.Text = strArray[2]; ActiveControl = textBox1; } private void buttonOK_Click(object sender, EventArgs e) { - string key = textBox1.Text.Replace(";", "_"); + string key = textBox1.Text; int num = 0; - string str2 = key; - while(QTUtility.GroupPathsDic.ContainsKey(str2)) { - str2 = key + "_" + ++num; + string tempKey = key; + while(GroupsManager.GetGroup(tempKey) != null) { + tempKey = key + " (" + ++num + ")"; } - key = str2; - if(!checkBox1.Checked) { - QTUtility.GroupPathsDic.Add(key, newPath); - } - else { - QTUtility.GroupPathsDic.Add(key, Tabs.Cast<QTabItem>() - .Select(item => item.CurrentPath).StringJoin(";")); - } + key = tempKey; + GroupsManager.AddGroup(key, chkAllTabs.Checked + ? Tabs.Cast<QTabItem>().Select(item => item.CurrentPath) + : new string[] { newPath }); } private void InitializeComponent() { @@ -64,7 +60,7 @@ buttonCancel = new Button(); label1 = new Label(); textBox1 = new TextBox(); - checkBox1 = new CheckBox(); + chkAllTabs = new CheckBox(); SuspendLayout(); buttonOK.DialogResult = DialogResult.OK; buttonOK.Enabled = false; @@ -85,16 +81,16 @@ textBox1.Size = new Size(170, 20); textBox1.TabIndex = 2; textBox1.TextChanged += textBox1_TextChanged; - checkBox1.AutoSize = true; - checkBox1.Location = new Point(12, 70); - checkBox1.Size = new Size(90, 0x1c); - checkBox1.TabIndex = 3; + chkAllTabs.AutoSize = true; + chkAllTabs.Location = new Point(12, 70); + chkAllTabs.Size = new Size(90, 0x1c); + chkAllTabs.TabIndex = 3; AcceptButton = buttonOK; AutoScaleDimensions = new SizeF(6f, 13f); AutoScaleMode = AutoScaleMode.Font; CancelButton = buttonCancel; ClientSize = new Size(0x133, 0x73); - Controls.Add(checkBox1); + Controls.Add(chkAllTabs); Controls.Add(textBox1); Controls.Add(label1); Controls.Add(buttonCancel); Added: branches/options/QTTabBar/GroupsManager.cs =================================================================== --- branches/options/QTTabBar/GroupsManager.cs (rev 0) +++ branches/options/QTTabBar/GroupsManager.cs 2011-12-17 22:30:32 UTC (rev 364) @@ -0,0 +1,131 @@ +// This file is part of QTTabBar, a shell extension for Microsoft +// Windows Explorer. +// Copyright (C) 2007-2010 Quizo, Paul Accisano +// +// QTTabBar is free software: you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. +// +// QTTabBar is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with QTTabBar. If not, see <http://www.gnu.org/licenses/>. + +using System.Collections; +using System.Collections.Generic; +using System.Linq; +using System.Windows.Forms; +using Microsoft.Win32; + +namespace QTTabBarLib { + + internal class Group { + public string Name { get; set; } + public Keys ShortcutKey { get; set; } + public List<string> Paths { get; private set; } + public bool Startup { get; set; } + + public Group(string name, Keys shortcutKey, bool startup, List<string> paths) { + Name = name; + ShortcutKey = shortcutKey; + Paths = paths; + Startup = startup; + } + } + + static class GroupsManager { + private static List<Group> groupList = new List<Group>(); + private static Dictionary<string, Group> groupDict = new Dictionary<string, Group>(); + + public static int GroupCount { + get { return groupList.Count; } + } + + public static IEnumerable<Group> Groups { + get { return groupList; } + set { + groupList = value.ToList(); + groupDict = groupList.ToDictionary(g => g.Name, g => g); + SaveGroups(); + } + } + + public static Group GetGroup(string name) { + Group group; + groupDict.TryGetValue(name, out group); + return group; + } + + public static void LoadGroups() { + List<Group> list = new List<Group>(); + using(RegistryKey key = Registry.CurrentUser.CreateSubKey(RegConst.Root + RegConst.Groups)) { + int i = 0; + while(true) { + using(RegistryKey gkey = key.OpenSubKey("" + i++)) { + if(gkey == null) break; + try { + string name = gkey.GetValue("") as string; + if(name == null) continue; + Keys shortcut = (Keys)gkey.GetValue("key", Keys.None); + bool startup = gkey.GetValue("startup") != null; + List<string> paths = new List<string>(); + int j = 0; + while(true) { + string path = gkey.GetValue("" + j++) as string; + if(path == null) break; + paths.Add(path); + } + list.Add(new Group(name, shortcut, startup, paths)); + } + catch { + } + } + } + } + Groups = list; + } + + public static void SaveGroups() { + Registry.CurrentUser.DeleteSubKeyTree(RegConst.Root + RegConst.Groups); + using(RegistryKey key = Registry.CurrentUser.CreateSubKey(RegConst.Root + RegConst.Groups)) { + for(int i = 0; i < groupList.Count; i++) { + Group g = groupList[i]; + using(RegistryKey gkey = key.CreateSubKey("" + i)) { + gkey.SetValue("", g.Name); + if(g.ShortcutKey != Keys.None) gkey.SetValue("key", (int)g.ShortcutKey); + if(g.Startup) gkey.SetValue("startup", ""); + for(int j = 0; j < g.Paths.Count; j++) { + gkey.SetValue("" + j, g.Paths[j]); + } + } + } + } + // todo: sync + } + + public static void AddGroup(string key, IEnumerable<string> paths) { + if(groupDict.ContainsKey(key)) return; + Group g = new Group(key, Keys.None, false, paths.ToList()); + groupList.Add(g); + groupDict[key] = g; + SaveGroups(); + } + + public static bool RemoveGroup(string groupName) { + if(!groupDict.ContainsKey(groupName)) return false; + groupList.Remove(groupDict[groupName]); + groupDict.Remove(groupName); + SaveGroups(); + return true; + } + + public static void RefreshGroupMenuesOnReorderFinished(ToolStripItemCollection itemsList) { + Groups = itemsList.Cast<ToolStripItem>().Select(item => groupDict[item.Text]); + SaveGroups(); + } + } +} Modified: branches/options/QTTabBar/MenuUtility.cs =================================================================== --- branches/options/QTTabBar/MenuUtility.cs 2011-12-12 07:22:38 UTC (rev 363) +++ branches/options/QTTabBar/MenuUtility.cs 2011-12-17 22:30:32 UTC (rev 364) @@ -105,37 +105,27 @@ } public static void CreateGroupItems(ToolStripDropDownItem dropDownItem) { - QTUtility.RefreshGroupsDic(); - if(QTUtility.GroupPathsDic.Count > 0) { - dropDownItem.Enabled = true; - DropDownMenuReorderable dropDown = (DropDownMenuReorderable)dropDownItem.DropDown; - while(dropDown.Items.Count > 0) { - dropDown.Items[0].Dispose(); - } - dropDown.ItemsClear(); - string key = "groups"; - foreach(string str2 in QTUtility.GroupPathsDic.Keys) { - string str3 = QTUtility.GroupPathsDic[str2]; - string path = str3.Split(QTUtility.SEPARATOR_CHAR)[0]; - if(str3.Length == 0) { - dropDown.AddItem(new ToolStripSeparator(), key); - } - else if(QTUtility2.PathExists(path)) { - QMenuItem item = new QMenuItem(str2, MenuGenre.Group); - item.SetImageReservationKey(path, null); - dropDown.AddItem(item, key); - if(QTUtility.StartUpGroupList.Contains(str2)) { - if(QTUtility.StartUpTabFont == null) { - QTUtility.StartUpTabFont = new Font(item.Font, FontStyle.Underline); - } - item.Font = QTUtility.StartUpTabFont; + DropDownMenuReorderable dropDown = (DropDownMenuReorderable)dropDownItem.DropDown; + while(dropDown.Items.Count > 0) { + dropDown.Items[0].Dispose(); + } + dropDown.ItemsClear(); + const string key = "groups"; + foreach(Group group in GroupsManager.Groups) { + if(group.Paths.Count != 0 && QTUtility2.PathExists(group.Paths[0])) { + QMenuItem item = new QMenuItem(group.Name, MenuGenre.Group); + item.SetImageReservationKey(group.Paths[0], null); + dropDown.AddItem(item, key); + if(group.Startup) { + if(QTUtility.StartUpTabFont == null) { + // todo, I don't like this here. + QTUtility.StartUpTabFont = new Font(item.Font, FontStyle.Underline); } + item.Font = QTUtility.StartUpTabFont; } } } - else { - dropDownItem.Enabled = false; - } + dropDownItem.Enabled = dropDown.Items.Count > 0; } public static QMenuItem CreateMenuItem(MenuItemArguments mia) { @@ -370,16 +360,14 @@ } } + // TODO: what does this do?! public static string TrackGroupContextMenu(string groupName, Point pnt, IntPtr pDropDownHandle) { - string str; string name = string.Empty; - if(!QTUtility.GroupPathsDic.TryGetValue(groupName, out str)) { - return name; - } - string[] strArray = str.Split(QTUtility.SEPARATOR_CHAR); + Group g = GroupsManager.GetGroup(groupName); + if(g == null) return name; ContextMenu menu = new ContextMenu(); if(!QTUtility.IsXP) { - foreach(string str2 in strArray) { + foreach(string str2 in g.Paths) { string text; if(str2.StartsWith(@"\\")) { text = str2; @@ -393,7 +381,7 @@ } } else { - foreach(string path in strArray) { + foreach(string path in g.Paths) { string displayName; if(path.StartsWith(@"\\")) { displayName = path; @@ -409,8 +397,8 @@ } List<IntPtr> list = new List<IntPtr>(); if(!QTUtility.IsXP) { - for(int k = 0; k < strArray.Length; k++) { - string imageKey = QTUtility.GetImageKey(strArray[k], null); + for(int k = 0; k < g.Paths.Count; k++) { + string imageKey = QTUtility.GetImageKey(g.Paths[k], null); IntPtr hbitmap = ((Bitmap)QTUtility.ImageListGlobal.Images[imageKey]).GetHbitmap(Color.Black); if(hbitmap != IntPtr.Zero) { list.Add(hbitmap); Modified: branches/options/QTTabBar/OptionsDialog.xaml =================================================================== --- branches/options/QTTabBar/OptionsDialog.xaml 2011-12-12 07:22:38 UTC (rev 363) +++ branches/options/QTTabBar/OptionsDialog.xaml 2011-12-17 22:30:32 UTC (rev 364) @@ -2132,7 +2132,7 @@ </DockPanel> </TabItem> - <!-- ============= APPS ============= --> + <!-- ============= APPS ============= --> <TabItem x:Name="tabApps" Header="Applications" Width="0"> @@ -2331,7 +2331,7 @@ </StackPanel> </TabItem> - <!-- ============= PLUGINS ============= --> + <!-- ============= PLUGINS ============= --> <TabItem x:Name="tabPlugins" Header="Plugins" Width="0"> @@ -2371,7 +2371,7 @@ </DockPanel> </TabItem> - <!-- ============= LANGUAGE ============= --> + <!-- ============= LANGUAGE ============= --> <TabItem x:Name="tabLanguage" DataContext="{Binding Path=lang}" Header="Language" @@ -2463,7 +2463,7 @@ </StackPanel> </TabItem> - <!-- ============= HELP ============= --> + <!-- ============= HELP ============= --> <TabItem x:Name="tabHelp" Header="About" Width="0"> Modified: branches/options/QTTabBar/OptionsDialog.xaml.cs =================================================================== --- branches/options/QTTabBar/OptionsDialog.xaml.cs 2011-12-12 07:22:38 UTC (rev 363) +++ branches/options/QTTabBar/OptionsDialog.xaml.cs 2011-12-17 22:30:32 UTC (rev 364) @@ -940,71 +940,15 @@ #region ---------- Groups ---------- private void InitializeGroups() { - CurrentGroups = new ObservableCollection<GroupEntry>(); - - foreach(KeyValuePair<string, string> pair in QTUtility.GroupPathsDic) { - GroupEntry group = new GroupEntry(pair.Key); - group.Startup = QTUtility.StartUpGroupList.Contains(group.Name); - if(QTUtility.dicGroupNamesAndKeys.ContainsKey(group.Name)) { - //group.ShortcutKey = QTUtility.dicGroupNamesAndKeys[group.Name]; - } - foreach(string path in pair.Value.Split(QTUtility.SEPARATOR_CHAR)) { - FolderEntry folder = new FolderEntry(path); - group.Folders.Add(folder); - } - CurrentGroups.Add(group); - - } - tvwGroups.ItemsSource = CurrentGroups; + tvwGroups.ItemsSource = CurrentGroups = new ObservableCollection<GroupEntry>( + GroupsManager.Groups.Select(g => new GroupEntry( + g.Name, g.ShortcutKey, g.Startup, g.Paths.Select(p => new FolderEntry(p))))); } - + private void CommitGroups() { - QTUtility.GroupPathsDic.Clear(); - QTUtility.StartUpGroupList.Clear(); - QTUtility.dicGroupShortcutKeys.Clear(); - QTUtility.dicGroupNamesAndKeys.Clear(); - List<PluginKey> list = new List<PluginKey>(); - int num = 1; - foreach(GroupEntry group in CurrentGroups) { - if(group.Folders.Count > 0) { - string text = group.Name; - if(text.Length > 0) { - string str2 = group.Folders - .Select(folder => folder.Path) - .Where(path => path.Length > 0) - .StringJoin(";"); - if(str2.Length > 0) { - string item = text.Replace(";", "_"); - QTUtility.GroupPathsDic[item] = str2; - if(group.Startup) { - QTUtility.StartUpGroupList.Add(item); - } - if(group.ShortcutKey != 0) { - /* - if(group.ShortcutKey > 0x100000) { - QTUtility.dicGroupShortcutKeys[group.ShortcutKey] = item; - } - QTUtility.dicGroupNamesAndKeys[item] = group.ShortcutKey; - list.Add(new PluginKey(item, new int[] { group.ShortcutKey }));*/ - } - } - } - } - } - using(RegistryKey rkUser = Registry.CurrentUser.CreateSubKey(RegConst.Root)) { - rkUser.DeleteSubKey("Groups", false); - using(RegistryKey key = rkUser.CreateSubKey("Groups")) { - if(key != null) { - foreach(string str4 in QTUtility.GroupPathsDic.Keys) { - key.SetValue(str4, QTUtility.GroupPathsDic[str4]); - } - } - } - rkUser.DeleteValue("ShortcutKeys_Group", false); - if(list.Count > 0) { - QTUtility2.WriteRegBinary(list.ToArray(), "ShortcutKeys_Group", rkUser); - } - } + GroupsManager.Groups = new List<Group>( + CurrentGroups.Select(g => new Group( + g.Name, g.ShortcutKey, g.Startup, g.Folders.Select(f => f.Path).ToList()))); } private GroupEntry GetParentGroup(FolderEntry folder) { @@ -1862,14 +1806,25 @@ Icon = Folders.Count == 0 ? QTUtility.ImageListGlobal.Images["folder"] : Folders.First().Icon; } + public GroupEntry(string name, Keys shortcutKey, bool startup, IEnumerable<FolderEntry> folders) { + Name = name; + Startup = startup; + ShortcutKey = shortcutKey; + Folders = new ObservableCollection<FolderEntry>(folders); + Folders.CollectionChanged += Folders_CollectionChanged; + RefreshIcon(); + } + public GroupEntry(string name) { Name = name; Folders = new ObservableCollection<FolderEntry>(); Folders.CollectionChanged += Folders_CollectionChanged; RefreshIcon(); } - public GroupEntry() - : this(null) { + + public GroupEntry() { + Folders.CollectionChanged += Folders_CollectionChanged; + RefreshIcon(); } } Modified: branches/options/QTTabBar/OptionsDialog_OLD.cs =================================================================== --- branches/options/QTTabBar/OptionsDialog_OLD.cs 2011-12-12 07:22:38 UTC (rev 363) +++ branches/options/QTTabBar/OptionsDialog_OLD.cs 2011-12-17 22:30:32 UTC (rev 364) @@ -3088,6 +3088,7 @@ } private void InitializeTreeView_Group() { + /* tnGroupsRoot = new TreeNode(ResOpt_Genre[4]); tnGroupsRoot.ImageKey = tnGroupsRoot.SelectedImageKey = "groupRoot"; treeViewGroup.BeginUpdate(); @@ -3130,7 +3131,7 @@ treeViewGroup.Nodes.Add(tnGroupsRoot); treeViewGroup.SelectedNode = tnGroupsRoot; tnGroupsRoot.Expand(); - treeViewGroup.EndUpdate(); + treeViewGroup.EndUpdate();*/ } private void InitializeTreeView_UserApps() { @@ -3525,55 +3526,55 @@ } } - private void SaveGroupTreeView(RegistryKey rkUser) { - QTUtility.GroupPathsDic.Clear(); - QTUtility.StartUpGroupList.Clear(); - QTUtility.dicGroupShortcutKeys.Clear(); - QTUtility.dicGroupNamesAndKeys.Clear(); - List<PluginKey> list = new List<PluginKey>(); - int num = 1; - foreach(TreeNode node in tnGroupsRoot.Nodes) { - MenuItemArguments tag = (MenuItemArguments)node.Tag; - if(tag == MIA_GROUPSEP) { - QTUtility.GroupPathsDic["Separator" + num++] = string.Empty; - } - else if(node.Nodes.Count > 0) { - string text = node.Text; - if(text.Length > 0) { - string str2 = node.Nodes.Cast<TreeNode>() - .Select(node2 => node2.Name) - .Where(name => name.Length > 0) - .StringJoin(";"); - if(str2.Length > 0) { - string item = text.Replace(";", "_"); - QTUtility.GroupPathsDic[item] = str2; - if(node.NodeFont == fntStartUpGroup) { - QTUtility.StartUpGroupList.Add(item); - } - if(tag.KeyShortcut != 0) { - if(tag.KeyShortcut > 0x100000) { - QTUtility.dicGroupShortcutKeys[tag.KeyShortcut] = item; - } - QTUtility.dicGroupNamesAndKeys[item] = tag.KeyShortcut; - list.Add(new PluginKey(item, new int[] { tag.KeyShortcut })); - } - } - } - } - } - rkUser.DeleteSubKey("Groups", false); - using(RegistryKey key = rkUser.CreateSubKey("Groups")) { - if(key != null) { - foreach(string str4 in QTUtility.GroupPathsDic.Keys) { - key.SetValue(str4, QTUtility.GroupPathsDic[str4]); - } - } - } - rkUser.DeleteValue("ShortcutKeys_Group", false); - if(list.Count > 0) { - QTUtility2.WriteRegBinary(list.ToArray(), "ShortcutKeys_Group", rkUser); - } - } + //private void SaveGroupTreeView(RegistryKey rkUser) { + // QTUtility.GroupPathsDic.Clear(); + // QTUtility.StartUpGroupList.Clear(); + // QTUtility.dicGroupShortcutKeys.Clear(); + // QTUtility.dicGroupNamesAndKeys.Clear(); + // List<PluginKey> list = new List<PluginKey>(); + // int num = 1; + // foreach(TreeNode node in tnGroupsRoot.Nodes) { + // MenuItemArguments tag = (MenuItemArguments)node.Tag; + // if(tag == MIA_GROUPSEP) { + // QTUtility.GroupPathsDic["Separator" + num++] = string.Empty; + // } + // else if(node.Nodes.Count > 0) { + // string text = node.Text; + // if(text.Length > 0) { + // string str2 = node.Nodes.Cast<TreeNode>() + // .Select(node2 => node2.Name) + // .Where(name => name.Length > 0) + // .StringJoin(";"); + // if(str2.Length > 0) { + // string item = text.Replace(";", "_"); + // QTUtility.GroupPathsDic[item] = str2; + // if(node.NodeFont == fntStartUpGroup) { + // QTUtility.StartUpGroupList.Add(item); + // } + // if(tag.KeyShortcut != 0) { + // if(tag.KeyShortcut > 0x100000) { + // QTUtility.dicGroupShortcutKeys[tag.KeyShortcut] = item; + // } + // QTUtility.dicGroupNamesAndKeys[item] = tag.KeyShortcut; + // list.Add(new PluginKey(item, new int[] { tag.KeyShortcut })); + // } + // } + // } + // } + // } + // rkUser.DeleteSubKey("Groups", false); + // using(RegistryKey key = rkUser.CreateSubKey("Groups")) { + // if(key != null) { + // foreach(string str4 in QTUtility.GroupPathsDic.Keys) { + // key.SetValue(str4, QTUtility.GroupPathsDic[str4]); + // } + // } + // } + // rkUser.DeleteValue("ShortcutKeys_Group", false); + // if(list.Count > 0) { + // QTUtility2.WriteRegBinary(list.ToArray(), "ShortcutKeys_Group", rkUser); + // } + //} private void SaveNoCapturePaths(RegistryKey rkUser) { string str = string.Empty; @@ -4169,7 +4170,7 @@ chbTabTitleShadow.Checked = Config.Skin.TabTitleShadows; btnShadowAct.Enabled = btnShadowIna.Enabled = chbTabTitleShadow.Checked; //textBoxAction_BarDblClck.Text = QTUtility.Action_BarDblClick; - QTUtility.RefreshGroupsDic(); + //QTUtility.RefreshGroupsDic(); InitializeTreeView_Group(); QTUtility.RefreshUserAppDic(false); InitializeTreeView_UserApps(); Modified: branches/options/QTTabBar/QTButtonBar.cs =================================================================== --- branches/options/QTTabBar/QTButtonBar.cs 2011-12-12 07:22:38 UTC (rev 363) +++ branches/options/QTTabBar/QTButtonBar.cs 2011-12-17 22:30:32 UTC (rev 364) @@ -327,7 +327,7 @@ ddmrGroupButton.Closed += dropDownButtons_DropDown_Closed; } button.DropDown = ddmrGroupButton; - button.Enabled = QTUtility.GroupPathsDic.Count > 0; + button.Enabled = GroupsManager.GroupCount > 0; break; case 4: @@ -665,13 +665,12 @@ ddmrGroupButton.Close(); if(ModifierKeys != (Keys.Control | Keys.Shift)) { QTUtility2.SendCOPYDATASTRUCT(tabBarHandle, wParam, e.ClickedItem.Text, IntPtr.Zero); - return; } - if(!QTUtility.StartUpGroupList.Contains(e.ClickedItem.Text)) { - QTUtility.StartUpGroupList.Add(e.ClickedItem.Text); - return; + else { + Group g = GroupsManager.GetGroup(e.ClickedItem.Text); + g.Startup = !g.Startup; + GroupsManager.SaveGroups(); } - QTUtility.StartUpGroupList.Remove(e.ClickedItem.Text); } return; @@ -695,7 +694,7 @@ DropDownMenuReorderable reorderable = (DropDownMenuReorderable)sender; switch(((int)reorderable.OwnerItem.Tag)) { case 3: - QTUtility.RefreshGroupMenuesOnReorderFinished(reorderable.Items); + GroupsManager.RefreshGroupMenuesOnReorderFinished(reorderable.Items); break; case 5: Modified: branches/options/QTTabBar/QTCoTaskBarClass.cs =================================================================== --- branches/options/QTTabBar/QTCoTaskBarClass.cs 2011-12-12 07:22:38 UTC (rev 363) +++ branches/options/QTTabBar/QTCoTaskBarClass.cs 2011-12-17 22:30:32 UTC (rev 364) @@ -403,6 +403,8 @@ } private void contextMenu_ItemClicked(object sender, ToolStripItemClickedEventArgs e) { + // todo +#if false TitleMenuItem clickedItem = e.ClickedItem as TitleMenuItem; if(clickedItem != null) { if(clickedItem.IsOpened) { @@ -465,9 +467,11 @@ } } } +#endif } private void contextMenu_ReorderFinished(object sender, ToolStripItemClickedEventArgs e) { +#if false QMenuItem clickedItem = e.ClickedItem as QMenuItem; if(clickedItem != null) { if(clickedItem.Genre == MenuGenre.Group) { @@ -514,6 +518,7 @@ QTUtility.fRequiredRefresh_App = true; } } +#endif } private void contextMenuForSetting_ItemClicked(object sender, ToolStripItemClickedEventArgs e) { @@ -747,7 +752,7 @@ } private void groupsMenuItem_ReorderFinished(object sender, ToolStripItemClickedEventArgs e) { - QTUtility.RefreshGroupMenuesOnReorderFinished(groupsMenuItem.DropDownItems); + GroupsManager.RefreshGroupMenuesOnReorderFinished(groupsMenuItem.DropDownItems); } private bool HandleKEYDOWN(IntPtr wParam, bool fRepeat) { @@ -825,6 +830,7 @@ mia.RestoreOriginalArgs(); } } +#if false // todo if(!fRepeat && QTUtility.dicGroupShortcutKeys.ContainsKey(key)) { Thread thread = new Thread(OpenGroup); thread.SetApartmentState(ApartmentState.STA); @@ -832,6 +838,7 @@ thread.Start(new object[] { QTUtility.dicGroupShortcutKeys[key], Keys.None }); return true; } +#endif } Label_02D8: return false; @@ -1153,6 +1160,7 @@ userAppsMenuItem.Text = labelUserAppTitle.Text = strArray[2]; recentFileMenuItem.Text = labelRecentFileTitle.Text = strArray[3]; if((ConfigValues[2] & 0x80) == 0) { +#if false QTUtility.RefreshGroupsDic(); foreach(string str in QTUtility.GroupPathsDic.Keys) { string str2 = QTUtility.GroupPathsDic[str]; @@ -1173,6 +1181,7 @@ } GroupItemsList.Add(item); } +#endif } if((ConfigValues[2] & 0x20) == 0) { UserappItemsList = MenuUtility.CreateAppLauncherItems(Handle, (ConfigValues[1] & 2) == 0, dropDownMenues_ItemRightClicked, subMenuItems_DoubleClick, true); @@ -1439,35 +1448,36 @@ } } - private void OpenGroup(object obj) { - string str2; - object[] objArray = (object[])obj; - string key = (string)objArray[0]; - Keys keys = (Keys)objArray[1]; - bool flag = keys == Keys.Control; - if(QTUtility.GroupPathsDic.TryGetValue(key, out str2) && (str2.Length > 0)) { - if(QTUtility.StartUpGroupList.Contains(key)) { - QTUtility.StartUpGroupNameNowOpening = key; - } - string path = str2.Split(QTUtility.SEPARATOR_CHAR)[0]; - using(IDLWrapper wrapper = new IDLWrapper(path, true)) { - IntPtr ptr; - bool flag2; - if(GetTargetWindow(wrapper, true, out ptr, out flag2)) { - if(flag2) { - QTUtility2.SendCOPYDATASTRUCT(ptr, (IntPtr)2, key, IntPtr.Zero); - } - else { - IntPtr wParam = flag ? ((IntPtr)3) : IntPtr.Zero; - if((wParam == IntPtr.Zero) && QTUtility2.TargetIsInNoCapture(IntPtr.Zero, path)) { - wParam = (IntPtr)3; - } - QTUtility2.SendCOPYDATASTRUCT(ptr, wParam, key, IntPtr.Zero); - } - } - } - } - } + // TODO... + //private void OpenGroup(object obj) { + // string str2; + // object[] objArray = (object[])obj; + // string key = (string)objArray[0]; + // Keys keys = (Keys)objArray[1]; + // bool flag = keys == Keys.Control; + // if(QTUtility.GroupPathsDic.TryGetValue(key, out str2) && (str2.Length > 0)) { + // if(QTUtility.StartUpGroupList.Contains(key)) { + // QTUtility.StartUpGroupNameNowOpening = key; + // } + // string path = str2.Split(QTUtility.SEPARATOR_CHAR)[0]; + // using(IDLWrapper wrapper = new IDLWrapper(path, true)) { + // IntPtr ptr; + // bool flag2; + // if(GetTargetWindow(wrapper, true, out ptr, out flag2)) { + // if(flag2) { + // QTUtility2.SendCOPYDATASTRUCT(ptr, (IntPtr)2, key, IntPtr.Zero); + // } + // else { + // IntPtr wParam = flag ? ((IntPtr)3) : IntPtr.Zero; + // if((wParam == IntPtr.Zero) && QTUtility2.TargetIsInNoCapture(IntPtr.Zero, path)) { + // wParam = (IntPtr)3; + // } + // QTUtility2.SendCOPYDATASTRUCT(ptr, wParam, key, IntPtr.Zero); + // } + // } + // } + // } + //} private void OpenTab(object obj) { IDLWrapper wrapper; Modified: branches/options/QTTabBar/QTTabBar.csproj =================================================================== --- branches/options/QTTabBar/QTTabBar.csproj 2011-12-12 07:22:38 UTC (rev 363) +++ branches/options/QTTabBar/QTTabBar.csproj 2011-12-17 22:30:32 UTC (rev 364) @@ -119,6 +119,7 @@ <Compile Include="FolderBrowserDialogEx.cs"> <SubType>Component</SubType> </Compile> + <Compile Include="GroupsManager.cs" /> <Compile Include="HookLibManager.cs" /> <Compile Include="Interop\BROWSEINFO.cs" /> <Compile Include="Interop\ShellConstants.cs" /> Modified: branches/options/QTTabBar/QTTabBarClass.cs =================================================================== --- branches/options/QTTabBar/QTTabBarClass.cs 2011-12-12 07:22:38 UTC (rev 363) +++ branches/options/QTTabBar/QTTabBarClass.cs 2011-12-17 22:30:32 UTC (rev 364) @@ -221,38 +221,24 @@ private void AddStartUpTabs(string openingGRP, string openingPath) { if(ModifierKeys == Keys.Shift || QTUtility.InstancesCount != 1) return; - if(QTUtility.StartUpGroupList.Count > 0) { - bool flag = Config.Tabs.NeverOpenSame; - foreach(string str in QTUtility.StartUpGroupList) { - string str2; - if((openingGRP != str) && QTUtility.GroupPathsDic.TryGetValue(str, out str2)) { - if(QTUtility.StartUpGroupNameNowOpening == str) { - QTUtility.StartUpGroupNameNowOpening = string.Empty; - } - else { - foreach(string str3 in str2.Split(QTUtility.SEPARATOR_CHAR)) { - if(flag) { - if(str3.PathEquals(openingPath)) { - tabControl1.TabPages.Relocate(0, tabControl1.TabCount - 1); - continue; - } - if(tabControl1.TabPages.Cast<QTabItem>().Any(item => str3.PathEquals(item.CurrentPath))) { - continue; - } - } - using(IDLWrapper wrapper = new IDLWrapper(str3)) { - if(wrapper.Available) { - QTabItem tabPage = new QTabItem(QTUtility2.MakePathDisplayText(str3, false), str3, tabControl1); - tabPage.NavigatedTo(str3, wrapper.IDL, -1, false); - tabPage.ToolTipText = QTUtility2.MakePathDisplayText(str3, true); - tabPage.UnderLine = true; - tabControl1.TabPages.Add(tabPage); - } - } - } - } + foreach(string path in GroupsManager.Groups.Where(g => g.Startup && openingGRP != g.Name).SelectMany(g => g.Paths)) { + if(Config.Tabs.NeverOpenSame) { + if(path.PathEquals(openingPath)) { + tabControl1.TabPages.Relocate(0, tabControl1.TabCount - 1); + continue; } + if(tabControl1.TabPages.Cast<QTabItem>().Any(item => path.PathEquals(item.CurrentPath))) { + continue; + } } + using(IDLWrapper wrapper = new IDLWrapper(path)) { + if(!wrapper.Available) continue; + QTabItem tabPage = new QTabItem(QTUtility2.MakePathDisplayText(path, false), path, tabControl1); + tabPage.NavigatedTo(path, wrapper.IDL, -1, false); + tabPage.ToolTipText = QTUtility2.MakePathDisplayText(path, true); + tabPage.UnderLine = true; + tabControl1.TabPages.Add(tabPage); + } } if(Config.Window.RestoreOnlyLocked) { RestoreTabsOnInitialize(1, openingPath); @@ -882,6 +868,8 @@ } } } + + // TODO: check this using(RegistryKey key = Registry.CurrentUser.CreateSubKey(RegConst.Root)) { if(Config.Misc.KeepHistory) { foreach(QTabItem item in tabControl1.TabPages) { @@ -896,7 +884,6 @@ where item2.TabLocked select item2.CurrentPath).ToArray(); QTUtility2.WriteRegBinary(list, "TabsLocked", key); - key.SetValue("StartUpGroups", QTUtility.StartUpGroupList.StringJoin(";")); if(InstanceManager.RemoveInstance(ExplorerHandle, this)) { InstanceManager.NextInstanceExists(); QTUtility2.WriteRegHandle("Handle", key, InstanceManager.CurrentHandle); @@ -1331,20 +1318,16 @@ } tsmiClose.Enabled = !ContextMenuedTab.TabLocked; tsmiLockThis.Text = ContextMenuedTab.TabLocked ? QTUtility.ResMain[20] : QTUtility.ResMain[6]; - QTUtility.RefreshGroupsDic(); - if(QTUtility.GroupPathsDic.Count > 0) { + if(GroupsManager.GroupCount > 0) { tsmiAddToGroup.DropDown.SuspendLayout(); tsmiAddToGroup.Enabled = true; while(tsmiAddToGroup.DropDownItems.Count > 0) { tsmiAddToGroup.DropDownItems[0].Dispose(); } - foreach(string str in QTUtility.GroupPathsDic.Keys) { - string str2 = QTUtility.GroupPathsDic[str]; - if(!string.IsNullOrEmpty(str2)) { - ToolStripMenuItem item = new ToolStripMenuItem(str); - item.ImageKey = QTUtility.GetImageKey(str2.Split(QTUtility.SEPARATOR_CHAR)[0], null); - tsmiAddToGroup.DropDownItems.Add(item); - } + foreach(Group g in GroupsManager.Groups.Where(g => g.Paths.Count > 0)) { + tsmiAddToGroup.DropDownItems.Add(new ToolStripMenuItem(g.Name) { + ImageKey = QTUtility.GetImageKey(g.Paths[0], null) + }); } tsmiAddToGroup.DropDown.ResumeLayout(); } @@ -1526,13 +1509,12 @@ private void CreateGroup(QTabItem contextMenuedTab) { NowModalDialogShown = true; - QTUtility.RefreshGroupsDic(); using(CreateNewGroupForm form = new CreateNewGroupForm(contextMenuedTab.CurrentPath, tabControl1.TabPages)) { if(NowTopMost) { form.TopMost = true; } if(DialogResult.OK == form.ShowDialog()) { - QTUtility.SaveGroupsReg(); + // TODO: should not be necessary SyncButtonBarBroadCast(1); SyncTaskBarMenu(); } @@ -3089,9 +3071,11 @@ } // Check for group hotkey - if(!fRepeat && QTUtility.dicGroupShortcutKeys.ContainsKey(imkey)) { - OpenGroup(QTUtility.dicGroupShortcutKeys[imkey], false); - return true; + if(!fRepeat) { + foreach(Group g in GroupsManager.Groups.Where(g => g.ShortcutKey == mkey)) { + OpenGroup(g.Name, false); + return true; + } } // This is important I guess? Not sure @@ -3805,22 +3789,15 @@ } private void menuitemAddToGroup_DropDownItemClicked(object sender, ToolStripItemClickedEventArgs e) { - string str3; - string text = e.ClickedItem.Text; + // TODO we should be using tags I think + string groupName = e.ClickedItem.Text; string currentPath = ContextMenuedTab.CurrentPath; - bool flag = ModifierKeys == Keys.Control; - if(QTUtility.GroupPathsDic.TryGetValue(text, out str3)) { - if(str3 == null) { - str3 = string.Empty; - } - if(!flag) { - if(str3.Split(QTUtility.SEPARATOR_CHAR).Any(str4 => - string.Equals(str4, currentPath, StringComparison.CurrentCultureIgnoreCase))) { - return; - } - } - QTUtility.GroupPathsDic[text] = ((str3.Length == 0) ? string.Empty : (str3 + ";")) + currentPath; - QTUtility.SaveGroupsReg(); + bool addSame = ModifierKeys == Keys.Control; + Group g = GroupsManager.GetGroup(groupName); + if(g == null) return; + if(addSame || !g.Paths.Any(p => p.PathEquals(currentPath))) { + g.Paths.Add(currentPath); + GroupsManager.SaveGroups(); } } @@ -3851,22 +3828,19 @@ private void menuitemGroups_DropDownItemClicked(object sender, ToolStripItemClickedEventArgs e) { Keys modifierKeys = ModifierKeys; - string text = e.ClickedItem.Text; + string groupName = e.ClickedItem.Text; if(modifierKeys == (Keys.Control | Keys.Shift)) { - if(QTUtility.StartUpGroupList.Contains(text)) { - QTUtility.StartUpGroupList.Remove(text); - } - else { - QTUtility.StartUpGroupList.Add(text); - } + Group g = GroupsManager.GetGroup(groupName); + g.Startup = !g.Startup; + GroupsManager.SaveGroups(); } else { - OpenGroup(text, modifierKeys == Keys.Control); + OpenGroup(groupName, modifierKeys == Keys.Control); } } private void menuitemGroups_ReorderFinished(object sender, ToolStripItemClickedEventArgs e) { - QTUtility.RefreshGroupMenuesOnReorderFinished(tsmiGroups.DropDownItems); + GroupsManager.RefreshGroupMenuesOnReorderFinished(tsmiGroups.DropDownItems); SyncTaskBarMenu(); } @@ -4433,6 +4407,7 @@ } private void OpenGroup(string groupName, bool fForceNewWindow) { + // todo clean if(!fForceNewWindow) { string str3; NowTabsAddingRemoving = true; @@ -4449,19 +4424,18 @@ flag3 = true; NowOpenedByGroupOpener = false; } - QTUtility.RefreshGroupsDic(); - if(QTUtility.GroupPathsDic.TryGetValue(groupName, out str3)) { - string[] strArray = str3.Split(QTUtility.SEPARATOR_CHAR); + Group g = GroupsManager.GetGroup(groupName); + if(g != null) { List<string> list = new List<string>(); List<QTabItem> list2 = new List<QTabItem>(); foreach(QTabItem item2 in tabControl1.TabPages) { list.Add(item2.CurrentPath.ToLower()); list2.Add(item2); } - if(strArray.Length != 0) { + if(g.Paths.Count != 0) { try { tabControl1.SetRedraw(false); - foreach(string gpath in strArray.Where(gpath => + foreach(string gpath in g.Paths.Where(gpath => QTUtility2.PathExists(gpath) || gpath.Contains("???"))) { if(str4 == null) { str4 = gpath; @@ -4516,8 +4490,9 @@ } else { string str; - if(QTUtility.GroupPathsDic.TryGetValue(groupName, out str) && (str.Length > 0)) { - string path = str.Split(QTUtility.SEPARATOR_CHAR)[0]; + Group g = GroupsManager.GetGroup(groupName); + if(g != null && g.Paths.Count > 0) { + string path = g.Paths[0]; QTUtility.CreateWindowTMPGroup = groupName; using(IDLWrapper wrapper = new IDLWrapper(path)) { if(wrapper.Available) { @@ -5433,7 +5408,7 @@ private static void SyncButtonBarBroadCast(int mask) { int num = mask << 0x10; - if(((mask & 1) == 1) && (QTUtility.GroupPathsDic.Count > 0)) { + if(((mask & 1) == 1) && (GroupsManager.GroupCount > 0)) { num++; } if(((mask & 2) == 2) && (QTUtility.ClosedTabHistoryList.Count > 0)) { @@ -6667,19 +6642,9 @@ } public bool AddGroup(string groupName, string[] paths) { - if((paths != null) && (paths.Length > 0)) { - string str = paths.StringJoin(";"); - if(str.Length > 0) { - string str2; - if(QTUtility.GroupPathsDic.TryGetValue(groupName, out str2)) { - str = ((str2.Length == 0) ? string.Empty : (str2 + ";")) + str; - } - QTUtility.GroupPathsDic[groupName] = str; - QTUtility.SaveGroupsReg(); - return true; - } - } - return false; + if(paths == null || paths.Length == 0) return false; + GroupsManager.AddGroup(groupName, paths); + return true; } internal void ClearEvents() { @@ -6885,11 +6850,8 @@ } public string[] GetGroupPaths(string groupName) { - string str; - if(QTUtility.GroupPathsDic.TryGetValue(groupName, out str)) { - return str.Split(QTUtility.SEPARATOR_CHAR); - } - return null; + Group g = GroupsManager.GetGroup(groupName); + return g == null ? null : g.Paths.ToArray(); } public ToolStripRenderer GetMenuRenderer() { @@ -7072,11 +7034,7 @@ } public bool RemoveGroup(string groupName) { - bool flag = QTUtility.GroupPathsDic.Remove(groupName); - if(flag) { - QTUtility.SaveGroupsReg(); - } - return flag; + return GroupsManager.RemoveGroup(groupName); } public bool TryGetLocalizedStrings(IPluginClient pluginClient, int count, out string[] arrStrings) { @@ -7120,9 +7078,7 @@ public string[] Groups { get { - string[] array = new string[QTUtility.GroupPathsDic.Keys.Count]; - QTUtility.GroupPathsDic.Keys.CopyTo(array, 0); - return array; + return GroupsManager.Groups.Select(g => g.Name).ToArray(); } } Modified: branches/options/QTTabBar/QTUtility.cs =================================================================== --- branches/options/QTTabBar/QTUtility.cs 2011-12-12 07:22:38 UTC (rev 363) +++ branches/options/QTTabBar/QTUtility.cs 2011-12-17 22:30:32 UTC (rev 364) @@ -38,10 +38,6 @@ internal static string CreateWindowTMPGroup = string.Empty; internal static string CreateWindowTMPPath = string.Empty; internal static Version CurrentVersion = new Version(1, 5, 0, 0); - internal static Dictionary<string, int> dicGroupNamesAndKeys = new Dictionary<string, int>(); - internal static Dictionary<int, string> dicGroupShortcutKeys = new Dictionary<int, string>(); - internal static Dictionary<string, int[]> dicPluginShortcutKeys = new Dictionary<string, int[]>(); - internal static Dictionary<int, MenuItemArguments> dicUserAppShortcutKeys = new Dictionary<int, MenuItemArguments>(); internal static Dictionary<string, string> DisplayNameCacheDic = new Dictionary<string, string>(); internal static PathList ExecutedPathsList = new PathList(0x10); internal static bool fExplorerPrevented; @@ -50,7 +46,6 @@ internal static bool fRequiredRefresh_App; internal static bool fRestoreFolderTree; internal static bool fSingleClick; - internal static Dictionary<string, string> GroupPathsDic = new Dictionary<string, string>(); internal static int iIconUnderLineVal; internal const string IMAGEKEY_FOLDER = "folder"; internal const string IMAGEKEY_MYNETWORK = "mynetwork"; @@ -82,8 +77,8 @@ internal static SolidBrush sbAlternate; internal static readonly char[] SEPARATOR_CHAR = new char[] { ';' }; internal const string SEPARATOR_PATH_HASH_SESSION = "*?*?*"; - internal static List<string> StartUpGroupList = new List<string>(); - internal static string StartUpGroupNameNowOpening = string.Empty; + internal static Dictionary<string, int[]> dicPluginShortcutKeys = new Dictionary<string, int[]>(); + internal static Dictionary<int, MenuItemArguments> dicUserAppShortcutKeys = new Dictionary<int, MenuItemArguments>(); internal static Font StartUpTabFont; internal static Dictionary<string, string[]> TextResourcesDic; internal static List<byte[]> TMPIDLList = new List<byte[]>(); @@ -111,6 +106,9 @@ ImageListGlobal = new ImageList { ColorDepth = ColorDepth.Depth32Bit }; ImageListGlobal.Images.Add("folder", GetIcon(string.Empty, false)); + // Load groups + GroupsManager.LoadGroups(); + using(RegistryKey key = Registry.CurrentUser.CreateSubKey(RegConst.Root)) { if(key != null) { string path = (string)key.GetValue("LanguageFile", string.Empty); @@ -139,12 +137,7 @@ } } } - RefreshGroupShortcutKeyDic(key); RefreshLockedTabsList(); - string str6 = (string)key.GetValue("StartUpGroups", string.Empty); - if(str6.Length > 0) { - StartUpGroupList = new List<string>(str6.Split(SEPARATOR_CHAR)); - } string str7 = (string)key.GetValue("NoCaptureAt", string.Empty); if(str7.Length > 0) { NoCapturePathsList = new List<string>(str7.Split(SEPARATOR_CHAR)); @@ -154,7 +147,6 @@ } } } - RefreshGroupsDic(); RefreshUserAppDic(true); if(!IsXP) { PATH_SEARCHFOLDER = "::{9343812E-1C37-4A49-A12E-4B2D810D956B}"; @@ -523,50 +515,6 @@ //return dictionary; } - public static void RefreshGroupMenuesOnReorderFinished(ToolStripItemCollection itemsList) { - Registry.CurrentUser.CreateSubKey(RegConst.Root).DeleteSubKey("Groups", false); - using(RegistryKey key = Registry.CurrentUser.CreateSubKey(RegConst.Root + @"Groups")) { - int num = 1; - foreach(ToolStripItem item in itemsList) { - if(item.Text.Length == 0) { - key.SetValue("Separator" + num++, string.Empty); - } - else { - key.SetValue(item.Text, GroupPathsDic[item.Text]); - } - } - } - } - - public static void RefreshGroupsDic() { - GroupPathsDic.Clear(); - using(RegistryKey key = Registry.CurrentUser.OpenSubKey(RegConst.Root + @"Groups", false)) { - if(key != null) { - foreach(string str in key.GetValueNames()) { - string str2 = (string)key.GetValue(str); - if(str2 != null) { - GroupPathsDic.Add(str, str2); - } - } - } - } - } - - private static void RefreshGroupShortcutKeyDic(RegistryKey rkUser) { - PluginKey[] keyArray = QTUtility2.ReadRegBinary<PluginKey>("ShortcutKeys_Group", rkUser); - if(keyArray != null) { - foreach(PluginKey key in keyArray) { - int[] keys = key.Keys; - if((keys != null) && (keys.Length == 1)) { - if((keys[0] & -1048577) != 0) { - dicGroupShortcutKeys[keys[0]] = key.PluginID; - } - dicGroupNamesAndKeys[key.PluginID] = keys[0]; - } - } - } - } - public static void RefreshLockedTabsList() { using(RegistryKey key = Registry.CurrentUser.CreateSubKey(RegConst.Root)) { if(key != null) { @@ -747,19 +695,6 @@ } } - public static void SaveGroupsReg() { - using(RegistryKey key = Registry.CurrentUser.CreateSubKey(RegConst.Root + @"Groups")) { - if(key != null) { - foreach(string str in key.GetValueNames()) { - key.DeleteValue(str, false); - } - foreach(string str2 in GroupPathsDic.Keys) { - key.SetValue(str2, GroupPathsDic[str2]); - } - } - } - } - public static void SaveRecentFiles(RegistryKey rkUser) { if(rkUser != null) { using(RegistryKey key = rkUser.CreateSubKey("RecentFiles")) { This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <mas...@us...> - 2011-12-25 03:01:09
|
Revision: 365 http://qttabbar.svn.sourceforge.net/qttabbar/?rev=365&view=rev Author: masamunexgp Date: 2011-12-25 03:00:58 +0000 (Sun, 25 Dec 2011) Log Message: ----------- Major cleanup to the TreeView and ListView code. Interacting with TreeViewItems and ListViewItems should NEVER be necessary; all code referencing these types outside of xaml has been redone. Everything should be done through binding. Started on the Apps tab. Modified Paths: -------------- branches/options/QTTabBar/EditableHeader.xaml.cs branches/options/QTTabBar/OptionsDialog.xaml branches/options/QTTabBar/OptionsDialog.xaml.cs branches/options/QTTabBar/QTTabBar.csproj Removed Paths: ------------- branches/options/QTTabBar/ApplicationsNode.xaml branches/options/QTTabBar/ApplicationsNode.xaml.cs Deleted: branches/options/QTTabBar/ApplicationsNode.xaml =================================================================== --- branches/options/QTTabBar/ApplicationsNode.xaml 2011-12-17 22:30:32 UTC (rev 364) +++ branches/options/QTTabBar/ApplicationsNode.xaml 2011-12-25 03:00:58 UTC (rev 365) @@ -1,111 +0,0 @@ -<UserControl x:Class="QTTabBarLib.ApplicationsNode" x:Name="ApplicationsNodeControl" - xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" - xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" - xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" - xmlns:d="http://schemas.microsoft.com/expression/blend/2008" - mc:Ignorable="d" d:DesignHeight="300" d:DesignWidth="500"> - - <Grid> - <Grid.ColumnDefinitions> - <ColumnDefinition Width="Auto"/> - <ColumnDefinition Width="255" /> - <ColumnDefinition Width="40" /> - </Grid.ColumnDefinitions> - <Grid.RowDefinitions> - <RowDefinition Height="Auto"/> - <RowDefinition Height="Auto"/> - <RowDefinition Height="Auto" /> - <RowDefinition Height="Auto" /> - <RowDefinition Height="Auto" /> - </Grid.RowDefinitions> - - <Label - Grid.Column="0" - Grid.Row="0" - Content="Path:" - VerticalAlignment="Top"/> - <TextBox x:Name="txtPath" - Grid.Column="1" - Grid.Row="0" - Margin="0,0,0,3" - Text=""/> - <Button x:Name="btnPath" - Click="btnPath_Click" - HorizontalAlignment="Left" - Content="..." - Grid.Column="2" - Grid.Row="0" - Margin="0,0,0,3" - Width="20"/> - - <Label - Grid.Column="0" - Grid.Row="1" - Content="Arguments:" - VerticalAlignment="Top"/> - <TextBox x:Name="txtArguments" - Grid.Column="1" - Grid.Row="1" - Margin="0,0,0,3" - Text=""/> - <Button x:Name="btnArguments" - Click="btnArguments_Click" - Content="%" - Grid.Column="2" - Grid.Row="1" - HorizontalAlignment="Left" - Margin="0,0,0,3" - Width="20"/> - - <Label - Grid.Column="0" - Grid.Row="2" - Content="Working Directory:" - VerticalAlignment="Top" /> - <TextBox x:Name="txtWorkingDir" - Grid.Column="1" - Grid.Row="2" - Margin="0,0,0,3" - Text=""/> - <StackPanel Orientation="Horizontal" Grid.Column="2" Grid.Row="2" Width="40"> - <Button x:Name="btnPath2" - Click="btnPath2_Click" - Content="..." - Grid.Column="2" - Grid.Row="0" - Margin="0,0,0,3" - Width="20"/> - <Button x:Name="btnWorkingDir" - Click="btnWorkingDir_Click" - Content="%" - Grid.Column="2" - Grid.Row="2" - Margin="0,0,0,3" - Width="20"/> - </StackPanel> - - <StackPanel - Orientation="Horizontal" - Grid.Column="0" - Grid.Row="3" - VerticalAlignment="Top"> - <Label - Content="Shortcut Key " - Grid.Column="0" - Grid.Row="3" /> - <CheckBox x:Name="chkShortcutKey" - Grid.Column="0" - Grid.Row="3" - VerticalAlignment="Center" - Checked="chkShortcutKey_Checked" Unchecked="chkShortcutKey_Checked"/> - </StackPanel> - - <TextBox x:Name="txtShortcutKey" - Grid.Column="1" - Grid.Row="3" - IsEnabled="False" - Text=""/> - - </Grid> - -</UserControl> Deleted: branches/options/QTTabBar/ApplicationsNode.xaml.cs =================================================================== --- branches/options/QTTabBar/ApplicationsNode.xaml.cs 2011-12-17 22:30:32 UTC (rev 364) +++ branches/options/QTTabBar/ApplicationsNode.xaml.cs 2011-12-25 03:00:58 UTC (rev 365) @@ -1,115 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Windows; -using System.Windows.Controls; -using System.Windows.Data; -using System.Windows.Documents; -using System.Windows.Forms; -using System.Windows.Input; -using System.Windows.Media; -using System.Windows.Media.Imaging; -using System.Windows.Navigation; -using System.Windows.Shapes; -using ContextMenu = System.Windows.Controls.ContextMenu; -using MenuItem = System.Windows.Controls.MenuItem; -using Point = System.Drawing.Point; -using UserControl = System.Windows.Controls.UserControl; - -namespace QTTabBarLib { - /// <summary> - /// Interaction logic for ApplicationsNode.xaml - /// </summary> - public partial class ApplicationsNode : UserControl { - public ApplicationsNode() { - InitializeComponent(); - } - - private void btnPath_Click( object sender, RoutedEventArgs e ) { - OpenFileDialog d = new OpenFileDialog(); - - if ( d.ShowDialog() == DialogResult.OK ) { - txtPath.Text = d.FileName; - } - } - - - - private void btnPath2_Click(object sender, RoutedEventArgs e) { - FolderBrowserDialogEx d = new FolderBrowserDialogEx(); - - if (d.ShowDialog() == DialogResult.OK) { - txtWorkingDir.Text = d.SelectedPath; - } - } - - private void btnArguments_Click( object sender, RoutedEventArgs e ) { - ContextMenu cm = new ContextMenu(); - Separator sep = new Separator(); - - MenuItem header = new MenuItem(); - header.IsEnabled = false; - header.Header = "The following keywords are replaced with double-quoted path strings at runtime."; - - MenuItem f = new MenuItem(); - f.Header = "%f% - Selected files."; - f.Click += delegate( object o, RoutedEventArgs a ) { txtArguments.AppendText( "%f%" ); }; - - MenuItem d = new MenuItem(); - d.Header = "%d% - Selected folders."; - d.Click += delegate( object o, RoutedEventArgs a ) { txtArguments.AppendText( "%d%" ); }; - - MenuItem s = new MenuItem(); - s.Header = "%s% - Selected files and folders."; - s.Click += delegate( object o, RoutedEventArgs a ) { txtArguments.AppendText( "%s%" ); }; - - MenuItem c = new MenuItem(); - c.Header = "%c% - Current folder."; - c.Click += delegate( object o, RoutedEventArgs a ) { txtArguments.AppendText( "%c%" ); }; - - MenuItem cd = new MenuItem(); - cd.Header = "%cd% - Current folder if no selection, otherwise selected folder."; - cd.Click += delegate( object o, RoutedEventArgs a ) { txtArguments.AppendText( "%cd%" ); }; - - cm.Items.Add( header ); - cm.Items.Add( sep ); - cm.Items.Add( f ); - cm.Items.Add( d ); - cm.Items.Add( s ); - cm.Items.Add( c ); - cm.Items.Add( cd ); - - cm.PlacementTarget = btnArguments; - cm.IsOpen = true; - } - - private void btnWorkingDir_Click( object sender, RoutedEventArgs e ) { - ContextMenu cm = new ContextMenu(); - Separator sep = new Separator(); - - MenuItem header = new MenuItem(); - header.IsEnabled = false; - header.Header = "The following keywords are replaced with double-quoted path strings at runtime."; - - MenuItem cd = new MenuItem(); - cd.Header = "%cd% - Current folder if no selection, otherwise selected folder."; - cd.Click += delegate( object o, RoutedEventArgs a ) { txtWorkingDir.AppendText( "%cd%" ); }; - - cm.Items.Add( header ); - cm.Items.Add( sep ); - cm.Items.Add( cd ); - - cm.PlacementTarget = btnWorkingDir; - cm.IsOpen = true; - } - - private void chkShortcutKey_Checked(object sender, RoutedEventArgs e) { - if(chkShortcutKey.IsChecked == true) { - txtShortcutKey.IsEnabled = true; - }else { - txtShortcutKey.IsEnabled = false; - } - } - } -} Modified: branches/options/QTTabBar/EditableHeader.xaml.cs =================================================================== --- branches/options/QTTabBar/EditableHeader.xaml.cs 2011-12-17 22:30:32 UTC (rev 364) +++ branches/options/QTTabBar/EditableHeader.xaml.cs 2011-12-25 03:00:58 UTC (rev 365) @@ -12,8 +12,7 @@ using System.Windows.Navigation; using System.Windows.Shapes; -namespace QTTabBarLib -{ +namespace QTTabBarLib { /// <summary> /// Interaction logic for EditableHeader.xaml /// </summary> @@ -21,6 +20,7 @@ private bool preparing = false; private string originalText; + private bool editOnLoad = false; public string Text { get { return (string)GetValue(TextProperty); } @@ -46,7 +46,7 @@ get { return (bool)GetValue(IsEditingProperty); } set { SetValue(IsEditingProperty, value); } } - + public static readonly DependencyProperty TextProperty = DependencyProperty.Register("Text", typeof(string), typeof(EditableHeader), new FrameworkPropertyMetadata("New Header", FrameworkPropertyMetadataOptions.BindsTwoWayByDefault)); @@ -66,31 +66,43 @@ public static readonly DependencyProperty IsEditingProperty = DependencyProperty.Register("IsEditing", typeof(bool), typeof(EditableHeader), new FrameworkPropertyMetadata(false, FrameworkPropertyMetadataOptions.BindsTwoWayByDefault, IsEditingChanged)); - - public EditableHeader(string initialName, TreeViewItem item = null) { + + public EditableHeader(string initialName) { InitializeComponent(); if(initialName != null) { Text = initialName; } - //# TODO Find a way to set the mouse focus on instantiation... + Loaded += delegate { + if(editOnLoad) StartEdit(); + editOnLoad = false; + }; } - public EditableHeader() : this(null) { + + public EditableHeader() + : this(null) { } - + private static void IsEditingChanged(DependencyObject d, DependencyPropertyChangedEventArgs e) { EditableHeader header = (EditableHeader)d; - if((bool)e.NewValue && header.txtHeaderEdit.Visibility == Visibility.Hidden) { + if((bool)e.NewValue) { header.StartEdit(); } - else if(!(bool)e.NewValue && header.txtHeaderEdit.Visibility == Visibility.Visible) { + else { header.EndEdit(); } } - public void EndEdit(bool cancel = false) { + private void EndEdit(bool cancel = false) { + if(!IsLoaded) { + editOnLoad = false; + return; + } + else if(txtHeaderEdit.Visibility == Visibility.Hidden) { + return; + } txtHeaderEdit.Visibility = Visibility.Hidden; BindingExpression expr = txtHeaderEdit.GetBindingExpression(TextBox.TextProperty); @@ -102,7 +114,14 @@ IsEditing = false; } - public void StartEdit() { + private void StartEdit() { + if(!IsLoaded) { + editOnLoad = true; + return; + } + else if(txtHeaderEdit.Visibility == Visibility.Visible) { + return; + } originalText = Text; txtHeaderEdit.SelectAll(); txtHeaderEdit.Visibility = Visibility.Visible; Modified: branches/options/QTTabBar/OptionsDialog.xaml =================================================================== --- branches/options/QTTabBar/OptionsDialog.xaml 2011-12-17 22:30:32 UTC (rev 364) +++ branches/options/QTTabBar/OptionsDialog.xaml 2011-12-25 03:00:58 UTC (rev 365) @@ -1009,8 +1009,7 @@ Margin="2,0" FontWeight="Bold" Grid.Column="2"/> - <ListBox - x:Name="lstTextFileTypes" + <ListBox x:Name="lstTextFileTypes" ItemTemplate="{StaticResource FileTypeItemTemplate}" Width="175" Height="200" @@ -1019,17 +1018,16 @@ Grid.Column="0" Margin="2" SelectionMode="Extended" - KeyDown="LstTextFileTypes_OnKeyDown"> + KeyDown="lstTextFileTypes_OnKeyDown"> <ListBox.ItemContainerStyle> <Style TargetType="{x:Type ListBoxItem}"> - <Setter - Property="IsSelected" - Value="{Binding Path=IsSelected, Mode=TwoWay}" /> + <Setter Property="IsSelected" Value="{Binding Path=IsSelected, Mode=TwoWay}" /> + <Setter Property="Tag" Value="{Binding RelativeSource={RelativeSource AncestorType={x:Type ListBox}}}" /> + <EventSetter Event="Selected" Handler="ListViewItem_Selected" /> </Style> </ListBox.ItemContainerStyle> </ListBox> - <ListBox - x:Name="lstMediaFileTypes" + <ListBox x:Name="lstMediaFileTypes" ItemTemplate="{StaticResource FileTypeItemTemplate}" Width="175" Height="200" @@ -1038,12 +1036,12 @@ Grid.Column="2" Margin="2" SelectionMode="Extended" - KeyDown="LstMediaFileTypes_OnKeyDown"> + KeyDown="lstMediaFileTypes_OnKeyDown"> <ListBox.ItemContainerStyle> <Style TargetType="{x:Type ListBoxItem}"> - <Setter - Property="IsSelected" - Value="{Binding Path=IsSelected, Mode=TwoWay}" /> + <Setter Property="IsSelected" Value="{Binding Path=IsSelected, Mode=TwoWay}" /> + <Setter Property="Tag" Value="{Binding RelativeSource={RelativeSource AncestorType={x:Type ListBox}}}" /> + <EventSetter Event="Selected" Handler="ListViewItem_Selected" /> </Style> </ListBox.ItemContainerStyle> </ListBox> @@ -1970,44 +1968,34 @@ <Button x:Name="btnGroupsMoveNodeUp" Content="^" Height="23" - HorizontalAlignment="Right" Margin="4" - VerticalAlignment="Top" Width="28" Click="btnGroupsMoveNodeUp_Click" /> <Button x:Name="btnGroupsMoveNodeDown" Content="v" Grid.Column="1" Height="23" - HorizontalAlignment="Right" Margin="4" - VerticalAlignment="Top" Width="28" Click="btnGroupsMoveNodeDown_Click" /> <Button x:Name="btnGroupsAddGroup" Content="G" Grid.Column="3" Height="23" - HorizontalAlignment="Right" Margin="4" - VerticalAlignment="Top" Width="28" Click="btnGroupsAddGroup_Click" /> <Button x:Name="btnGroupsAddFolder" Content="+" Grid.Column="4" Height="23" - HorizontalAlignment="Right" Margin="4" - VerticalAlignment="Top" Width="28" Click="btnGroupsAddFolder_Click" /> <Button x:Name="btnGroupsRemoveNode" Content="-" Grid.Column="5" Height="23" - HorizontalAlignment="Right" Margin="4" - VerticalAlignment="Top" Width="28" Click="btnGroupsRemoveNode_Click" /> </Grid> @@ -2039,7 +2027,13 @@ Text="{Binding Path=HotkeyString, Mode=OneWay}"/> </DockPanel> <r:TreeListView x:Name="tvwGroups" - MouseDown="tvwGroups_MouseDown"> + MouseDown="tvwGroupsApps_MouseDown"> + <TreeView.ItemContainerStyle> + <Style TargetType="{x:Type TreeViewItem}"> + <Setter Property="IsSelected" Value="{Binding Path=IsSelected, Mode=TwoWay}" /> + <Setter Property="IsExpanded" Value="{Binding Path=IsExpanded, Mode=TwoWay}" /> + </Style> + </TreeView.ItemContainerStyle> <TreeView.ItemTemplate> <HierarchicalDataTemplate ItemsSource="{Binding Path=Folders}"/> </TreeView.ItemTemplate> @@ -2059,37 +2053,25 @@ <qt:EditableHeader x:Name="ehrName" Container="{Binding RelativeSource={RelativeSource AncestorType={x:Type r:TreeListViewItem}}}" IsEditing="{Binding Path=IsEditing}" - Text="{Binding Path=Name}" - Margin="0" - Visibility="Collapsed"/> - <qt:EditableHeader x:Name="ehrPath" - Container="{Binding RelativeSource={RelativeSource AncestorType={x:Type r:TreeListViewItem}}}" - Text="{Binding Path=Path}" - Margin="0" - Visibility="Collapsed"/> - <qt:EditableHeader x:Name="txtDisplayText" - Text="{Binding Path=DisplayText, Mode=OneWay}" - ReadOnly="True" - Margin="0" - Visibility="Collapsed"/> + Margin="0"/> </StackPanel> <DataTemplate.Triggers> <DataTrigger Binding="{Binding Converter={StaticResource ObjectToClassNameConverter}}" Value="GroupEntry"> - <Setter TargetName="ehrName" Property="Visibility" Value="Visible"/> + <Setter TargetName="ehrName" Property="Text" Value="{Binding Path=Name}"/> </DataTrigger> <MultiDataTrigger> <MultiDataTrigger.Conditions> <Condition Binding="{Binding Converter={StaticResource ObjectToClassNameConverter}}" Value="FolderEntry"/> <Condition Binding="{Binding Path=IsVirtualFolder}" Value="False"/> </MultiDataTrigger.Conditions> - <Setter TargetName="ehrPath" Property="Visibility" Value="Visible"/> - </MultiDataTrigger> + <Setter TargetName="ehrName" Property="Text" Value="{Binding Path=Path}"/> </MultiDataTrigger> <MultiDataTrigger> <MultiDataTrigger.Conditions> <Condition Binding="{Binding Converter={StaticResource ObjectToClassNameConverter}}" Value="FolderEntry"/> <Condition Binding="{Binding Path=IsVirtualFolder}" Value="True"/> </MultiDataTrigger.Conditions> - <Setter TargetName="txtDisplayText" Property="Visibility" Value="Visible"/> + <Setter TargetName="ehrName" Property="Text" Value="{Binding Path=DisplayText, Mode=OneWay}"/> + <Setter TargetName="ehrName" Property="ReadOnly" Value="True"/> </MultiDataTrigger> </DataTemplate.Triggers> </DataTemplate> @@ -2136,10 +2118,10 @@ <TabItem x:Name="tabApps" Header="Applications" Width="0"> - <StackPanel - Margin="14,5,10,0" - Orientation="Vertical"> + <DockPanel + Margin="14,5,10,0"> <StackPanel + DockPanel.Dock="Top" Margin="0,0,0,4" Orientation="Horizontal"> <Image @@ -2151,11 +2133,11 @@ VerticalAlignment="Bottom"/> </StackPanel> <Grid + DockPanel.Dock="Top" Margin="0,10,0,0"> <Grid.ColumnDefinitions> <ColumnDefinition Width="Auto"/> - <ColumnDefinition Width="20"/> - <ColumnDefinition Width="16" /> + <ColumnDefinition Width="Auto"/> <ColumnDefinition Width="*"/> <ColumnDefinition Width="Auto"/> <ColumnDefinition Width="Auto"/> @@ -2165,64 +2147,101 @@ Click="btnAppsMoveNodeUp_Click" Content="^" Height="23" - HorizontalAlignment="Right" Margin="4" - VerticalAlignment="Top" Width="28"/> <Button x:Name="btnAppsMoveNodeDown" Click="btnAppsMoveNodeDown_Click" Content="v" Grid.Column="1" Height="23" - HorizontalAlignment="Right" - Margin="0,4,4,0" - VerticalAlignment="Top" - Width="28" Grid.ColumnSpan="2" /> - <Button x:Name="btnAppsAddSeparator" - Click="btnAppsAddSeparator_Click" - Content="---" - Grid.Column="3" - Height="23" - HorizontalAlignment="Right" Margin="4" - VerticalAlignment="Top" Width="28"/> <Button x:Name="btnAppsAddFolder" - Click="btnAppsAddFolder_Click" Content="F" - Grid.Column="4" + Grid.Column="3" Height="23" - HorizontalAlignment="Right" Margin="4" - VerticalAlignment="Top" Width="28"/> <Button x:Name="btnAppsAddNode" - Click="btnAppsAddNode_Click" Content="+" - Grid.Column="5" + Grid.Column="4" Height="23" - HorizontalAlignment="Right" Margin="4" - VerticalAlignment="Top" Width="28"/> <Button x:Name="btnAppsRemoveNode" - Click="btnAppsRemoveNode_Click" Content="-" - Grid.Column="6" + Grid.Column="5" Height="23" - HorizontalAlignment="Right" Margin="4" - VerticalAlignment="Top" Width="28"/> </Grid> - <TreeView x:Name="treeApps" - Height="489"> - <TreeViewItem x:Name="treeAppsRoot" - Header="Applications" - IsExpanded="True" - IsSelected="True"/> - </TreeView> - </StackPanel> + <DockPanel + DockPanel.Dock="Bottom" + Margin="0,10,0,20"> + <Label + Content="Path:" + DockPanel.Dock="Left" + Height="23" + Margin="0,0,10,0" + Padding="0" + VerticalContentAlignment="Center"/> + <TextBox x:Name="txtAppHotkey" + Height="23" + IsReadOnly="True" + Text="{Binding Path=HotkeyString, Mode=OneWay}"/> + </DockPanel> + <r:TreeListView x:Name="tvwApps" + MouseDown="tvwGroupsApps_MouseDown"> + <TreeView.ItemContainerStyle> + <Style TargetType="{x:Type TreeViewItem}"> + <Setter Property="IsSelected" Value="{Binding Path=IsSelected, Mode=TwoWay}" /> + <Setter Property="IsExpanded" Value="{Binding Path=IsExpanded, Mode=TwoWay}" /> + </Style> + </TreeView.ItemContainerStyle> + <TreeView.ItemTemplate> + <HierarchicalDataTemplate ItemsSource="{Binding Path=Folders}"/> + </TreeView.ItemTemplate> + <r:TreeListView.Columns> + <GridViewColumn Header="Application" Width="300"> + <GridViewColumn.CellTemplate> + <DataTemplate> + <StackPanel + Orientation="Horizontal" + VerticalAlignment="Center"> + <Image + Source="{Binding Path=Icon, Converter={StaticResource BitmapToImageSourceConverter}}" + Width="16" + Height="16" + Stretch="Fill" + Margin="0,0,2,0"/> + <qt:EditableHeader x:Name="ehrName" + Container="{Binding RelativeSource={RelativeSource AncestorType={x:Type r:TreeListViewItem}}}" + IsEditing="{Binding Path=IsEditing}" + Text="{Binding Path=Name}" + Margin="0"/> + </StackPanel> + </DataTemplate> + </GridViewColumn.CellTemplate> + </GridViewColumn> + <GridViewColumn Header="Shortcut Key" Width="100"> + <GridViewColumn.CellTemplate> + <DataTemplate> + <TextBlock x:Name="txtHotkey" + Text="{Binding Path=HotkeyString}" + HorizontalAlignment="Center" + VerticalAlignment="Center" + Visibility="Collapsed" /> + <DataTemplate.Triggers> + <DataTrigger Binding="{Binding Converter={StaticResource ObjectToClassNameConverter}}" Value="GroupEntry"> + <Setter TargetName="txtHotkey" Property="Visibility" Value="Visible"/> + </DataTrigger> + </DataTemplate.Triggers> + </DataTemplate> + </GridViewColumn.CellTemplate> + </GridViewColumn> + </r:TreeListView.Columns> + </r:TreeListView> + </DockPanel> </TabItem> <!-- ============= BUTTON BAR ============= --> Modified: branches/options/QTTabBar/OptionsDialog.xaml.cs =================================================================== --- branches/options/QTTabBar/OptionsDialog.xaml.cs 2011-12-17 22:30:32 UTC (rev 364) +++ branches/options/QTTabBar/OptionsDialog.xaml.cs 2011-12-25 03:00:58 UTC (rev 365) @@ -19,6 +19,7 @@ using System.Collections; using System.Collections.Generic; using System.Collections.ObjectModel; +using System.Collections.Specialized; using System.ComponentModel; using System.Globalization; using System.Linq; @@ -35,7 +36,6 @@ using System.Windows.Shapes; using QTPlugin; using QTTabBarLib.Interop; -using Microsoft.Win32; using Image = System.Drawing.Image; using Size = System.Drawing.Size; using Font = System.Drawing.Font; @@ -52,7 +52,7 @@ private static OptionsDialog instance; private static Thread instanceThread; public Config workingConfig { get; set; } - + // Button bar stuff private ImageStrip imageStripLarge; private ImageStrip imageStripSmall; @@ -71,8 +71,9 @@ private ObservableCollection<FileTypeEntry> TextFileTypes; private ObservableCollection<FileTypeEntry> MediaFileTypes; - // Groups stuff - private ObservableCollection<GroupEntry> CurrentGroups; + // Groups/Apps stuff + private ParentedCollection<GroupEntry> CurrentGroups; + private ParentedCollection<AppEntry> CurrentApps; private List<HotkeyEntry> HotkeyEntries; @@ -508,19 +509,18 @@ control.SelectedItem = item; control.ScrollIntoView(item); control.Focus(); - FindItemContainerAsync(control, item, container => - RunOnLoad((FrameworkElement)container, delegate { item.IsEditing = true; })); + item.IsEditing = true; } - private void RemoveSelectedFileType(ListBox control) { + private static void RemoveSelectedFileType(ListBox control) { var list = (ObservableCollection<FileTypeEntry>)control.ItemsSource; int idx = control.SelectedIndex; if(idx == -1) return; foreach(FileTypeEntry item in new ArrayList(control.SelectedItems)) { list.Remove(item); } + control.Focus(); control.SelectedIndex = Math.Min(idx, list.Count - 1); - FindItemContainerAsync(control, control.SelectedItem, container => container.Focus()); } private void btnAddTextFileTypes_Click(object sender, RoutedEventArgs e) { @@ -551,14 +551,20 @@ lstMediaFileTypes.ScrollIntoView(MediaFileTypes.First()); } - private void LstTextFileTypes_OnKeyDown(object sender, KeyEventArgs e) { + private void lstTextFileTypes_OnKeyDown(object sender, KeyEventArgs e) { if(e.Key == Key.Delete) RemoveSelectedFileType(lstTextFileTypes); } - private void LstMediaFileTypes_OnKeyDown(object sender, KeyEventArgs e) { + private void lstMediaFileTypes_OnKeyDown(object sender, KeyEventArgs e) { if(e.Key == Key.Delete) RemoveSelectedFileType(lstMediaFileTypes); } + private void ListViewItem_Selected(object sender, RoutedEventArgs e) { + FrameworkElement item = (FrameworkElement)sender; + FrameworkElement parent = (FrameworkElement)item.Tag; + if(parent.IsFocused) item.Focus(); + } + #endregion #region ---------- Appearance ---------- @@ -675,124 +681,6 @@ #endregion - #region ---------- Applications ---------- - - private void btnAppsAddFolder_Click(object sender, RoutedEventArgs e) { - appsDrawNode("New Folder", "dir"); - } - - private void btnAppsAddNode_Click(object sender, RoutedEventArgs e) { - appsDrawNode("New App", "app"); - } - - private void btnAppsAddSeparator_Click(object sender, RoutedEventArgs e) { - appsDrawNode("-------- SEPARATOR --------", "sep"); - } - - private void btnAppsRemoveNode_Click(object sender, RoutedEventArgs e) { - TreeViewItem item = treeApps.Tag as TreeViewItem; - - try { - //MessageBox.Show(item.Parent.GetType() + item.Uid); - ((TreeViewItem)item.Parent).Items.Remove(item); - } - catch(Exception ex) { - //MessageBox.Show("Exception: "+ex.ToString()); - } - } - - private void btnAppsMoveNodeDown_Click(object sender, RoutedEventArgs e) { - - } - - private void btnAppsMoveNodeUp_Click(object sender, RoutedEventArgs e) { - - } - - private void appsDrawNode(string name, String type, String icon = "none") { - TreeViewItem selected = null; - TreeViewItem item = appsGenerateNode(name, type, icon); - - string[] args = new string[5]; - - try { - selected = (TreeViewItem)treeApps.SelectedItem; - args = selected.Tag as string[]; - } - catch(Exception ex) { - return; - } - - if((selected == null) || (selected == treeAppsRoot)) { - treeAppsRoot.Items.Add(item); - } - else if(args[0] == "dir") { - selected.Items.Add(item); - } - } - - private TreeViewItem appsGenerateNode(string name = "New Application", String type = "app", String icon = "none") { - //# Core item - TreeViewItem item = new TreeViewItem(); - - //# Stored value for the tag. - string[] args = new string[5]; - args[0] = type; - - item.Tag = args; - - //# Add the appnode to child. - if(type == "app") { - ApplicationsNode node = new ApplicationsNode(); - item.Items.Add(node); - - //# Tag arguments -- could be used for binding. - args[1] = "No Path Selected"; - args[2] = "None"; - args[3] = "Working Dir"; - args[4] = "Shortcut"; - } - - //# Must add this here before the expand, and select code. - item.Selected += new RoutedEventHandler(appsOnNodeSelected); - - //# Automatically expand / select new folders and app nodes. - //# We leave separators alone - if(type != "sep") { - item.IsSelected = true; - item.IsExpanded = true; - item.Header = new EditableHeader(name, item); - } - else { - //# No soup for sep - item.Header = name; - } - - return item; - } - - private void appsOnNodeSelected(object sender, RoutedEventArgs e) { - try { - TreeViewItem item = e.OriginalSource as TreeViewItem; - string[] args = item.Tag as string[]; - - //# Handle any args we want to use for binding here? - - //# We need to tag the main TreeView so we can easily access information about the selected TreeViewItem with it. - //# We are unable to accurately handle the treeAps.SelectedItem property, unless we have this 'backup' - treeApps.Tag = item; - } - catch(Exception ex) { - //# This is only caught when the user clicks on a label from an appnode. We try to handle - //# the ugly blue background as best we can. - ((TreeViewItem)e.OriginalSource).Focusable = false; - ((TreeViewItem)e.OriginalSource).IsSelected = true; - return; - } - } - - #endregion - #region ---------- Keyboard ---------- private void InitializeKeys() { @@ -940,11 +828,11 @@ #region ---------- Groups ---------- private void InitializeGroups() { - tvwGroups.ItemsSource = CurrentGroups = new ObservableCollection<GroupEntry>( + tvwGroups.ItemsSource = CurrentGroups = new ParentedCollection<GroupEntry>( GroupsManager.Groups.Select(g => new GroupEntry( g.Name, g.ShortcutKey, g.Startup, g.Paths.Select(p => new FolderEntry(p))))); } - + private void CommitGroups() { GroupsManager.Groups = new List<Group>( CurrentGroups.Select(g => new Group( @@ -952,13 +840,14 @@ } private GroupEntry GetParentGroup(FolderEntry folder) { - return CurrentGroups.OfType<GroupEntry>().FirstOrDefault( - entry => entry.Folders.Contains(folder)); + return CurrentGroups.FirstOrDefault(entry => entry.Folders.Contains(folder)); } - private void UpDownOnTreeView(ItemsControl control, object val, bool up) { - IList col = (IList)control.ItemsSource; - int index = col.IndexOf(val); + private static void UpDownOnTreeView(TreeView tvw, bool up) { + ITreeViewItem val = tvw.SelectedItem as ITreeViewItem; + if(val == null) return; + IList list = val.ParentList; + int index = list.IndexOf(val); if(index == -1) { return; } @@ -968,61 +857,31 @@ } } else { - if(index == col.Count - 1) { + if(index == list.Count - 1) { return; } } - TreeViewItem container = (TreeViewItem)FindItemContainer(control, val); - bool expanded = container.IsExpanded; - - col.Remove(val); - col.Insert(index + (up ? -1 : 1), val); - - container = (TreeViewItem)FindItemContainer(control, val); - container.IsExpanded = expanded; - container.IsSelected = true; + bool expanded = val.IsExpanded; + list.RemoveAt(index); + list.Insert(index + (up ? -1 : 1), val); + val.IsExpanded = expanded; + val.IsSelected = true; } - private void UpDownOnTreeView(TreeView tvw, bool up) { - object val = tvw.SelectedItem; - if(val == null) { - return; - } - - // TODO: Needs to generalize this for the other TreeView more. - if(val is FolderEntry) { - object parent = GetParentGroup((FolderEntry)val); - TreeViewItem container = (TreeViewItem)FindItemContainer(tvw, parent); - UpDownOnTreeView(container, val, up); - } - else { - UpDownOnTreeView(tvw, val, up); - } - } - - private int GetPreferredInsertionIndex(TreeView tvw) { - object sel = tvw.SelectedItem; - return sel == null - ? tvw.Items.Count + private void btnGroupsAddGroup_Click(object sender, RoutedEventArgs e) { + GroupEntry item = new GroupEntry("New Group"); + tvwGroups.Focus(); + IList col = (IList)tvwGroups.ItemsSource; + object sel = tvwGroups.SelectedItem; + int idx = sel == null + ? tvwGroups.Items.Count : CurrentGroups.IndexOf(sel as GroupEntry ?? GetParentGroup((FolderEntry)sel)) + 1; + col.Insert(idx, item); + item.IsSelected = true; + item.IsEditing = true; } - private void AddNewGroupItem(TreeView tvw, object item) { - IList col = (IList)tvw.ItemsSource; - col.Insert(GetPreferredInsertionIndex(tvw), item); - - FindItemContainerAsync(tvw, item, obj => { - TreeViewItem container = (TreeViewItem)obj; - container.IsSelected = true; - - GroupEntry entry = item as GroupEntry; - if(entry != null) { - RunOnLoad(container, delegate { entry.IsEditing = true; }); - } - }); - } - private void btnGroupsMoveNodeUp_Click(object sender, RoutedEventArgs e) { UpDownOnTreeView(tvwGroups, true); } @@ -1031,10 +890,6 @@ UpDownOnTreeView(tvwGroups, false); } - private void btnGroupsAddGroup_Click(object sender, RoutedEventArgs e) { - AddNewGroupItem(tvwGroups, new GroupEntry("New Group")); - } - private void btnGroupsAddFolder_Click(object sender, RoutedEventArgs e) { // TODO: Generates new group if the view is empty. @@ -1057,39 +912,30 @@ if(dlg.ShowDialog() != System.Windows.Forms.DialogResult.OK) return; FolderEntry folder = new FolderEntry(dlg.SelectedPath); group.Folders.Insert(index, folder); - - TreeViewItem parent = (TreeViewItem)FindItemContainer(tvwGroups, group); - parent.IsExpanded = true; - - FindItemContainerAsync(parent, folder, cont => ((TreeViewItem)cont).IsSelected = true); + group.IsExpanded = true; + folder.IsSelected = true; } private void btnGroupsRemoveNode_Click(object sender, RoutedEventArgs e) { - object sel = tvwGroups.SelectedItem; + ITreeViewItem sel = tvwGroups.SelectedItem as ITreeViewItem; if(sel == null) return; - - IList col = sel is GroupEntry - ? (IList)CurrentGroups - : GetParentGroup((FolderEntry)sel).Folders; - + IList col = sel.ParentList; int index = col.IndexOf(sel); col.RemoveAt(index); - - if(index >= col.Count) return; - object next = col[index]; - TreeViewItem container = (TreeViewItem)FindItemContainer(tvwGroups, next); - container.IsSelected = true; + if(col.Count == 0) return; + if(index == col.Count) --index; + ((ITreeViewItem)col[index]).IsSelected = true; } - private void tvwGroups_MouseDown(object sender, MouseButtonEventArgs e) { - GroupEntry entry = tvwGroups.SelectedItem as GroupEntry; + private void tvwGroupsApps_MouseDown(object sender, MouseButtonEventArgs e) { + IEditableEntry entry = ((TreeView)sender).SelectedItem as IEditableEntry; if(entry != null) entry.IsEditing = false; } private void txtGroupHotkey_OnPreviewKeyDown(object sender, KeyEventArgs e) { e.Handled = true; - if(!(tvwGroups.SelectedItem is GroupEntry)) return; - GroupEntry entry = (GroupEntry)tvwGroups.SelectedItem; + GroupEntry entry = tvwGroups.SelectedItem as GroupEntry; + if(entry == null) return; Keys newKey; if(ProcessNewHotkey(e, entry.ShortcutKey, out newKey)) { entry.ShortcutKey = newKey; @@ -1098,6 +944,38 @@ #endregion + #region ---------- Applications ---------- + + private void InitializeApps() { + tvwApps.ItemsSource = CurrentApps = new ParentedCollection<AppEntry>(); + } + + private void CommitApps() { + // todo + } + + private void btnAddApp_Click(object sender, RoutedEventArgs e) { + + } + + private void btnAddAppFolder_Click(object sender, RoutedEventArgs e) { + } + + private void btnRemoveApp_Click(object sender, RoutedEventArgs e) { + + } + + private void btnAppsMoveNodeUp_Click(object sender, RoutedEventArgs e) { + UpDownOnTreeView(tvwApps, true); + } + + private void btnAppsMoveNodeDown_Click(object sender, RoutedEventArgs e) { + UpDownOnTreeView(tvwApps, false); + } + + + #endregion + #region ---------- Button Bar ---------- private void InitializeButtonBar() { @@ -1432,15 +1310,6 @@ } } - private static void RunOnLoad(FrameworkElement element, Action pred) { - RoutedEventHandler del = null; - del = delegate { - pred(); - element.Loaded -= del; - }; - element.Loaded += del; - } - private static UIElement FindItemContainer(ItemsControl parent, object childItem) { if(parent.ItemContainerGenerator.Status != GeneratorStatus.ContainersGenerated) { return null; @@ -1461,24 +1330,6 @@ return null; } - private delegate void ItemContainerAction(UIElement container); - private static void FindItemContainerAsync(ItemsControl parent, object childItem, ItemContainerAction pred) { - ItemContainerGenerator gen = parent.ItemContainerGenerator; - if(gen.Status == GeneratorStatus.ContainersGenerated) { - pred(FindItemContainer(parent, childItem)); - return; - } - EventHandler handler = null; - handler = delegate { - if(gen.Status != GeneratorStatus.ContainersGenerated) { - return; - } - pred(FindItemContainer(parent, childItem)); - gen.StatusChanged -= handler; - }; - gen.StatusChanged += handler; - } - // Draws a control to a bitmap private static BitmapSource ConvertToBitmapSource(UIElement element) { var target = new RenderTargetBitmap((int)(element.RenderSize.Width), (int)(element.RenderSize.Height), 96, 96, PixelFormats.Pbgra32); @@ -1495,6 +1346,49 @@ #endregion + #region ---------- Interfaces / Helper Classes ---------- + + private interface IEditableEntry { + bool IsEditing { get; set; } + } + + private interface IChildItem { + IList ParentList { get; set; } + } + + private interface ITreeViewItem : IChildItem { + bool IsSelected { get; set; } + bool IsExpanded { get; set; } + } + + private sealed class ParentedCollection<TChild> : ObservableCollection<TChild> + where TChild : class, IChildItem { + public ParentedCollection(IEnumerable<TChild> collection = null) { + if(collection != null) { + foreach(TChild child in collection) { + child.ParentList = this; + Add(child); + } + } + CollectionChanged += ParentedCollection_CollectionChanged; + } + + private void ParentedCollection_CollectionChanged(object sender, NotifyCollectionChangedEventArgs e) { + if(e.NewItems != null) { + foreach(TChild newItem in e.NewItems) { + newItem.ParentList = this; + } + } + if(e.OldItems != null) { + foreach(TChild oldItem in e.OldItems) { + oldItem.ParentList = null; + } + } + } + } + + #endregion + #region ---------- Binding Classes ---------- #pragma warning disable 0067 // "The event 'PropertyChanged' is never used" // ReSharper disable MemberCanBePrivate.Local @@ -1681,7 +1575,7 @@ } } - private class FileTypeEntry : INotifyPropertyChanged { + private class FileTypeEntry : INotifyPropertyChanged, IEditableEntry { public event PropertyChangedEventHandler PropertyChanged; private OptionsDialog parent; @@ -1741,10 +1635,13 @@ } } - private class FolderEntry : INotifyPropertyChanged { + private class FolderEntry : INotifyPropertyChanged, IEditableEntry, ITreeViewItem { public event PropertyChangedEventHandler PropertyChanged; - + public IList ParentList { get; set; } public string Path { get; set; } + public bool IsEditing { get; set; } + public bool IsSelected { get; set; } + public bool IsExpanded { get; set; } public string DisplayText { get { @@ -1770,19 +1667,22 @@ } } - private class GroupEntry : INotifyPropertyChanged { + private class GroupEntry : INotifyPropertyChanged, IEditableEntry, ITreeViewItem { public event PropertyChangedEventHandler PropertyChanged; + public IList ParentList { get; set; } public string Name { get; set; } public Image Icon { get; private set; } - public ObservableCollection<FolderEntry> Folders { get; private set; } + public ParentedCollection<FolderEntry> Folders { get; private set; } public bool Startup { get; set; } public Keys ShortcutKey { get; set; } public string HotkeyString { get { return QTUtility2.MakeKeyString(ShortcutKey); } } public bool IsEditing { get; set; } - - private void Folders_CollectionChanged(object sender, System.Collections.Specialized.NotifyCollectionChangedEventArgs e) { + public bool IsSelected { get; set; } + public bool IsExpanded { get; set; } + + private void Folders_CollectionChanged(object sender, NotifyCollectionChangedEventArgs e) { if(e.OldItems != null) { foreach(FolderEntry child in e.OldItems) { child.PropertyChanged -= FolderEntry_PropertyChanged; @@ -1810,14 +1710,14 @@ Name = name; Startup = startup; ShortcutKey = shortcutKey; - Folders = new ObservableCollection<FolderEntry>(folders); + Folders = new ParentedCollection<FolderEntry>(folders); Folders.CollectionChanged += Folders_CollectionChanged; RefreshIcon(); } public GroupEntry(string name) { Name = name; - Folders = new ObservableCollection<FolderEntry>(); + Folders = new ParentedCollection<FolderEntry>(); Folders.CollectionChanged += Folders_CollectionChanged; RefreshIcon(); } @@ -1828,6 +1728,33 @@ } } + private class AppEntry : INotifyPropertyChanged, IEditableEntry, ITreeViewItem { + public event PropertyChangedEventHandler PropertyChanged; + public IList ParentList { get; set; } + public ParentedCollection<AppEntry> Folders { get; set; } + public bool IsFolder { get { return Folders != null; } } + public bool IsEditing { get; set; } + public bool IsSelected { get; set; } + public bool IsExpanded { get; set; } + public string Name { get; set; } + public string Path { get; set; } + public string Args { get; set; } + public string Working { get; set; } + + public Image Icon { + get { + return IsFolder + ? QTUtility.ImageListGlobal.Images["folder"] + : QTUtility.GetIcon(Path, false).ToBitmap(); + } + } + + public AppEntry(bool folder, string name) { + Name = name; + if(folder) Folders = new ParentedCollection<AppEntry>(); + } + } + // ReSharper restore UnusedAutoPropertyAccessor.Local // ReSharper restore UnusedMember.Local // ReSharper restore MemberCanBePrivate.Local Modified: branches/options/QTTabBar/QTTabBar.csproj =================================================================== --- branches/options/QTTabBar/QTTabBar.csproj 2011-12-17 22:30:32 UTC (rev 364) +++ branches/options/QTTabBar/QTTabBar.csproj 2011-12-25 03:00:58 UTC (rev 365) @@ -100,9 +100,6 @@ </ItemGroup> <ItemGroup> <Compile Include="AppLauncher.cs" /> - <Compile Include="ApplicationsNode.xaml.cs"> - <DependentUpon>ApplicationsNode.xaml</DependentUpon> - </Compile> <Compile Include="AutoLoader.cs" /> <Compile Include="Automation\AutomationElement.cs" /> <Compile Include="Automation\AutomationElementFactory.cs" /> @@ -418,10 +415,6 @@ <SubType>Designer</SubType> <Generator>MSBuild:Compile</Generator> </Page> - <Page Include="ApplicationsNode.xaml"> - <SubType>Designer</SubType> - <Generator>MSBuild:Compile</Generator> - </Page> <Page Include="MarginCombo.xaml"> <SubType>Designer</SubType> <Generator>MSBuild:Compile</Generator> This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <mas...@us...> - 2011-12-25 22:52:19
|
Revision: 366 http://qttabbar.svn.sourceforge.net/qttabbar/?rev=366&view=rev Author: masamunexgp Date: 2011-12-25 22:52:13 +0000 (Sun, 25 Dec 2011) Log Message: ----------- Fixed reentrancy bug in OptionsDialog launching code. More work on Apps. Modified Paths: -------------- branches/options/QTTabBar/OptionsDialog.xaml branches/options/QTTabBar/OptionsDialog.xaml.cs Modified: branches/options/QTTabBar/OptionsDialog.xaml =================================================================== --- branches/options/QTTabBar/OptionsDialog.xaml 2011-12-25 03:00:58 UTC (rev 365) +++ branches/options/QTTabBar/OptionsDialog.xaml 2011-12-25 22:52:13 UTC (rev 366) @@ -2157,18 +2157,21 @@ Margin="4" Width="28"/> <Button x:Name="btnAppsAddFolder" + Click="btnAddAppFolder_Click" Content="F" Grid.Column="3" Height="23" Margin="4" Width="28"/> <Button x:Name="btnAppsAddNode" + Click="btnAddApp_Click" Content="+" Grid.Column="4" Height="23" Margin="4" Width="28"/> <Button x:Name="btnAppsRemoveNode" + Click="btnRemoveApp_Click" Content="-" Grid.Column="5" Height="23" @@ -2199,7 +2202,7 @@ </Style> </TreeView.ItemContainerStyle> <TreeView.ItemTemplate> - <HierarchicalDataTemplate ItemsSource="{Binding Path=Folders}"/> + <HierarchicalDataTemplate ItemsSource="{Binding Path=Children}"/> </TreeView.ItemTemplate> <r:TreeListView.Columns> <GridViewColumn Header="Application" Width="300"> Modified: branches/options/QTTabBar/OptionsDialog.xaml.cs =================================================================== --- branches/options/QTTabBar/OptionsDialog.xaml.cs 2011-12-25 03:00:58 UTC (rev 365) +++ branches/options/QTTabBar/OptionsDialog.xaml.cs 2011-12-25 22:52:13 UTC (rev 366) @@ -51,6 +51,7 @@ private static OptionsDialog instance; private static Thread instanceThread; + private static Thread launchingThread = null; public Config workingConfig { get; set; } // Button bar stuff @@ -316,24 +317,33 @@ public static void Open() { // TODO: Primary process only lock(typeof(OptionsDialog)) { - if(instance == null) { - instanceThread = new Thread(ThreadEntry); - instanceThread.SetApartmentState(ApartmentState.STA); - lock(instanceThread) { - instanceThread.Start(); - // Don't return until we know that instance is set. - Monitor.Wait(instanceThread); + // Prevent reentrant calls that might happen during the Wait call below. + if(launchingThread == Thread.CurrentThread) return; + try { + launchingThread = Thread.CurrentThread; + + if(instance == null) { + instanceThread = new Thread(ThreadEntry); + instanceThread.SetApartmentState(ApartmentState.STA); + lock(instanceThread) { + instanceThread.Start(); + // Don't return until we know that instance is set. + Monitor.Wait(instanceThread); + } } + else { + instance.Dispatcher.Invoke(new Action(() => { + if(instance.WindowState == WindowState.Minimized) { + instance.WindowState = WindowState.Normal; + } + else { + instance.Activate(); + } + })); + } } - else { - instance.Dispatcher.Invoke(new Action(() => { - if(instance.WindowState == WindowState.Minimized) { - instance.WindowState = WindowState.Normal; - } - else { - instance.Activate(); - } - })); + finally { + launchingThread = null; } } } @@ -378,6 +388,7 @@ InitializeMouse(); InitializeKeys(); InitializeGroups(); + InitializeApps(); InitializeButtonBar(); // Initialize the plugin tab @@ -955,10 +966,19 @@ } private void btnAddApp_Click(object sender, RoutedEventArgs e) { - + AppEntry entry = tvwApps.SelectedItem as AppEntry; + IList list = entry == null ? CurrentApps : entry.IsFolder ? entry.Children : entry.ParentList; + int idx = entry == null ? 0 : list.IndexOf(entry) + 1; + list.Insert(idx, new AppEntry(false, "New App")); + if(entry != null && entry.IsFolder) entry.IsExpanded = true; } private void btnAddAppFolder_Click(object sender, RoutedEventArgs e) { + AppEntry entry = tvwApps.SelectedItem as AppEntry; + IList list = entry == null ? CurrentApps : entry.IsFolder ? entry.Children : entry.ParentList; + int idx = entry == null ? 0 : list.IndexOf(entry) + 1; + list.Insert(idx, new AppEntry(true, "Folder")); + if(entry != null && entry.IsFolder) entry.IsExpanded = true; } private void btnRemoveApp_Click(object sender, RoutedEventArgs e) { @@ -1731,8 +1751,8 @@ private class AppEntry : INotifyPropertyChanged, IEditableEntry, ITreeViewItem { public event PropertyChangedEventHandler PropertyChanged; public IList ParentList { get; set; } - public ParentedCollection<AppEntry> Folders { get; set; } - public bool IsFolder { get { return Folders != null; } } + public ParentedCollection<AppEntry> Children { get; set; } + public bool IsFolder { get { return Children != null; } } public bool IsEditing { get; set; } public bool IsSelected { get; set; } public bool IsExpanded { get; set; } @@ -1751,7 +1771,7 @@ public AppEntry(bool folder, string name) { Name = name; - if(folder) Folders = new ParentedCollection<AppEntry>(); + if(folder) Children = new ParentedCollection<AppEntry>(); } } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <mas...@us...> - 2011-12-26 08:39:56
|
Revision: 367 http://qttabbar.svn.sourceforge.net/qttabbar/?rev=367&view=rev Author: masamunexgp Date: 2011-12-26 08:39:49 +0000 (Mon, 26 Dec 2011) Log Message: ----------- More work on the Apps tab. Modified Paths: -------------- branches/options/QTTabBar/FileFolderEntryBox.xaml branches/options/QTTabBar/OptionsDialog.xaml branches/options/QTTabBar/OptionsDialog.xaml.cs Modified: branches/options/QTTabBar/FileFolderEntryBox.xaml =================================================================== --- branches/options/QTTabBar/FileFolderEntryBox.xaml 2011-12-25 22:52:13 UTC (rev 366) +++ branches/options/QTTabBar/FileFolderEntryBox.xaml 2011-12-26 08:39:49 UTC (rev 367) @@ -10,10 +10,11 @@ Height="{Binding Path=Height, ElementName=FileFolderEntryBoxControl}" Width="{Binding Path=Width, ElementName=FileFolderEntryBoxControl}"> <Button x:Name="btnBrowse" + Click="btnBrowse_Click" Content="..." Margin="8, 1, 0, 1" Width="26" - DockPanel.Dock="Right" Click="btnBrowse_Click" /> + DockPanel.Dock="Right"/> <Grid> <TextBox x:Name="txtLocation" x:FieldModifier="private" Padding="22,1,0,0" Modified: branches/options/QTTabBar/OptionsDialog.xaml =================================================================== --- branches/options/QTTabBar/OptionsDialog.xaml 2011-12-25 22:52:13 UTC (rev 366) +++ branches/options/QTTabBar/OptionsDialog.xaml 2011-12-26 08:39:49 UTC (rev 367) @@ -2178,21 +2178,133 @@ Margin="4" Width="28"/> </Grid> - <DockPanel + <Grid x:Name="grdAppProps" + DataContext="{Binding ElementName=tvwApps, Path=SelectedItem}" DockPanel.Dock="Bottom" Margin="0,10,0,20"> + <Grid.Style> + <Style TargetType="{x:Type Grid}"> + <Setter Property="IsEnabled" Value="False"/> + <Style.Triggers> + <DataTrigger Binding="{Binding Path=IsFolder}" Value="False"> + <Setter Property="IsEnabled" Value="True"/> + </DataTrigger> + </Style.Triggers> + </Style> + </Grid.Style> + <Grid.ColumnDefinitions> + <ColumnDefinition Width="Auto"/> + <ColumnDefinition Width="*"/> + <ColumnDefinition Width="Auto"/> + </Grid.ColumnDefinitions> + <Grid.RowDefinitions> + <RowDefinition Height="Auto"/> + <RowDefinition Height="Auto"/> + <RowDefinition Height="Auto"/> + </Grid.RowDefinitions> <Label Content="Path:" - DockPanel.Dock="Left" + Grid.Column="0" + Grid.Row="0" Height="23" Margin="0,0,10,0" Padding="0" VerticalContentAlignment="Center"/> - <TextBox x:Name="txtAppHotkey" + <qt:FileFolderEntryBox x:Name="txtAppPath" + Folder="False" + Grid.Column="1" + Grid.ColumnSpan="2" + Grid.Row="0" Height="23" - IsReadOnly="True" - Text="{Binding Path=HotkeyString, Mode=OneWay}"/> - </DockPanel> + Margin="0,3" + SelectedPath="{Binding Path=Path}"/> + <Label + Content="Arguments:" + Grid.Column="0" + Grid.Row="1" + Height="23" + Margin="0,0,10,0" + Padding="0" + VerticalContentAlignment="Center"/> + <TextBox x:Name="txtAppArgs" + Grid.Column="1" + Grid.Row="1" + Height="23" + Margin="0,3" + Text="{Binding Path=Args}"/> + <Button x:Name="btnArgVars" + Click="btnVars_Click" + Content="%" + Grid.Column="2" + Grid.Row="1" + Height="23" + Margin="8, 1, 0, 1" + Width="26"> + <Button.ContextMenu> + <ContextMenu> + <MenuItem + Header="The following keywords are replaced with double-quoted path strings at runtime." + IsEnabled="False"/> + <Separator/> + <MenuItem + Click="miArgVars_Click" + Header="%f% - Selected files." + Tag="%f%"/> + <MenuItem + Click="miArgVars_Click" + Header="%d% - Selected folders." + Tag="%d%"/> + <MenuItem + Click="miArgVars_Click" + Header="%s% - Selected files and folders." + Tag="%s%"/> + <MenuItem + Click="miArgVars_Click" + Header="%c% - Current folder." + Tag="%c%"/> + <MenuItem + Click="miArgVars_Click" + Header="%cd% - Current folder if no selection, otherwise selected folder." + Tag="%cd%"/> + </ContextMenu> + </Button.ContextMenu> + </Button> + <Label + Content="Working Directory:" + Grid.Column="0" + Grid.Row="2" + Height="23" + Margin="0,0,10,0" + Padding="0" + VerticalContentAlignment="Center"/> + <TextBox x:Name="txtAppDir" + Grid.Column="1" + Grid.Row="2" + Height="23" + Margin="0,3" + Text="{Binding Path=WorkingDir}"/> + <Button x:Name="btnWorkingVars" + Click="btnVars_Click" + Content="%" + Grid.Column="2" + Grid.Row="2" + Height="23" + Margin="8, 1, 0, 1" + Width="26"> + <Button.ContextMenu> + <ContextMenu> + <MenuItem + Header="The following keywords are replaced with double-quoted path strings at runtime." + IsEnabled="False"/> + <Separator/> + <MenuItem + Click="miWorkingVars_Click" + Header="%cd% - Current folder if no selection, otherwise selected folder." + Tag="%cd%"/> + </ContextMenu> + </Button.ContextMenu> + </Button> + </Grid> <r:TreeListView x:Name="tvwApps" MouseDown="tvwGroupsApps_MouseDown"> <TreeView.ItemContainerStyle> Modified: branches/options/QTTabBar/OptionsDialog.xaml.cs =================================================================== --- branches/options/QTTabBar/OptionsDialog.xaml.cs 2011-12-25 22:52:13 UTC (rev 366) +++ branches/options/QTTabBar/OptionsDialog.xaml.cs 2011-12-26 08:39:49 UTC (rev 367) @@ -966,23 +966,42 @@ } private void btnAddApp_Click(object sender, RoutedEventArgs e) { - AppEntry entry = tvwApps.SelectedItem as AppEntry; - IList list = entry == null ? CurrentApps : entry.IsFolder ? entry.Children : entry.ParentList; - int idx = entry == null ? 0 : list.IndexOf(entry) + 1; - list.Insert(idx, new AppEntry(false, "New App")); - if(entry != null && entry.IsFolder) entry.IsExpanded = true; + string path; + using(OpenFileDialog ofd = new OpenFileDialog()) { + if(System.Windows.Forms.DialogResult.OK != ofd.ShowDialog()) return; + path = ofd.FileName; + } + AppEntry sel = tvwApps.SelectedItem as AppEntry; + IList list = sel == null ? CurrentApps : sel.IsFolder ? sel.Children : sel.ParentList; + int idx = sel == null ? 0 : list.IndexOf(sel) + 1; + AppEntry entry = new AppEntry(false, path); + list.Insert(idx, entry); + entry.IsSelected = true; + if(sel != null && sel.IsFolder) sel.IsExpanded = true; } private void btnAddAppFolder_Click(object sender, RoutedEventArgs e) { - AppEntry entry = tvwApps.SelectedItem as AppEntry; - IList list = entry == null ? CurrentApps : entry.IsFolder ? entry.Children : entry.ParentList; - int idx = entry == null ? 0 : list.IndexOf(entry) + 1; - list.Insert(idx, new AppEntry(true, "Folder")); - if(entry != null && entry.IsFolder) entry.IsExpanded = true; + AppEntry sel = tvwApps.SelectedItem as AppEntry; + IList list = sel == null ? CurrentApps : sel.IsFolder ? sel.Children : sel.ParentList; + int idx = sel == null ? 0 : list.IndexOf(sel) + 1; + AppEntry entry = new AppEntry(true, "Folder"); + list.Insert(idx, entry); + entry.IsSelected = true; + if(sel != null && sel.IsFolder) sel.IsExpanded = true; } private void btnRemoveApp_Click(object sender, RoutedEventArgs e) { - + AppEntry sel = tvwApps.SelectedItem as AppEntry; + if(sel == null) return; + if(sel.IsFolder && sel.Children.Count > 0) { + // todo: confirm + } + IList list = sel.ParentList; + int index = list.IndexOf(sel); + list.RemoveAt(index); + if(list.Count == 0) return; + if(index == list.Count) --index; + ((ITreeViewItem)list[index]).IsSelected = true; } private void btnAppsMoveNodeUp_Click(object sender, RoutedEventArgs e) { @@ -993,7 +1012,28 @@ UpDownOnTreeView(tvwApps, false); } + private void btnVars_Click(object sender, RoutedEventArgs e) { + var button = ((Button)sender); + ContextMenu menu = button.ContextMenu; + menu.PlacementTarget = button; + menu.Placement = PlacementMode.Bottom; + menu.IsOpen = true; + } + private void miArgVars_Click(object sender, RoutedEventArgs e) { + InsertVar(txtAppArgs, (string)((MenuItem)sender).Tag); + } + + private void miWorkingVars_Click(object sender, RoutedEventArgs e) { + InsertVar(txtAppDir, (string)((MenuItem)sender).Tag); + } + + private static void InsertVar(TextBox textbox, string var) { + int caret = textbox.CaretIndex; + textbox.Text = textbox.Text.Insert(caret, var); + textbox.CaretIndex = caret + var.Length; + } + #endregion #region ---------- Button Bar ---------- @@ -1330,26 +1370,6 @@ } } - private static UIElement FindItemContainer(ItemsControl parent, object childItem) { - if(parent.ItemContainerGenerator.Status != GeneratorStatus.ContainersGenerated) { - return null; - } - UIElement container = (UIElement)parent.ItemContainerGenerator.ContainerFromItem(childItem); - if(container != null) { - return container; - } - foreach(object item in parent.Items) { - ItemsControl child = parent.ItemContainerGenerator.ContainerFromItem(item) as ItemsControl; - if(child != null && child.Items.Count > 0) { - UIElement result = FindItemContainer(child, childItem); - if(result != null) { - return result; - } - } - } - return null; - } - // Draws a control to a bitmap private static BitmapSource ConvertToBitmapSource(UIElement element) { var target = new RenderTargetBitmap((int)(element.RenderSize.Width), (int)(element.RenderSize.Height), 96, 96, PixelFormats.Pbgra32); @@ -1759,7 +1779,7 @@ public string Name { get; set; } public string Path { get; set; } public string Args { get; set; } - public string Working { get; set; } + public string WorkingDir { get; set; } public Image Icon { get { @@ -1769,9 +1789,15 @@ } } - public AppEntry(bool folder, string name) { - Name = name; - if(folder) Children = new ParentedCollection<AppEntry>(); + public AppEntry(bool folder, string nameOrPath) { + if(folder) { + Name = nameOrPath; + Children = new ParentedCollection<AppEntry>(); + } + else { + Path = nameOrPath; + Name = System.IO.Path.GetFileNameWithoutExtension(Path); + } } } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <mas...@us...> - 2011-12-26 22:08:54
|
Revision: 368 http://qttabbar.svn.sourceforge.net/qttabbar/?rev=368&view=rev Author: masamunexgp Date: 2011-12-26 22:08:47 +0000 (Mon, 26 Dec 2011) Log Message: ----------- Apps tab interface mostly completed. Modified Paths: -------------- branches/options/QTTabBar/OptionsDialog.xaml branches/options/QTTabBar/OptionsDialog.xaml.cs Modified: branches/options/QTTabBar/OptionsDialog.xaml =================================================================== --- branches/options/QTTabBar/OptionsDialog.xaml 2011-12-26 08:39:49 UTC (rev 367) +++ branches/options/QTTabBar/OptionsDialog.xaml 2011-12-26 22:08:47 UTC (rev 368) @@ -1850,7 +1850,7 @@ Header="Keys" Width="0"> <DockPanel - Margin="14,5,10,0"> + Margin="14,5,10,16"> <StackPanel DockPanel.Dock="Top" Margin="0,0,0,4" @@ -1871,8 +1871,8 @@ <ListView x:Name="lvwHotkeys" PreviewKeyDown="lvwHotkeys_PreviewKeyDown" TextInput="lvwHotkeys_TextInput" - BorderThickness="1.000001" - Margin="0,10"> + SelectionMode="Single" + BorderThickness="1.000001"> <ListView.GroupStyle> <GroupStyle HeaderTemplate="{StaticResource WinFormsGroupStyle}"/> </ListView.GroupStyle> @@ -1941,7 +1941,7 @@ Header="Groups" Width="0"> <DockPanel - Margin="14,5,10,0"> + Margin="14,5,10,16"> <StackPanel DockPanel.Dock="Top" Margin="0,0,0,4" @@ -1954,9 +1954,14 @@ FontSize="13" VerticalAlignment="Bottom"/> </StackPanel> + <TextBlock + Text="To assign a Shortcut Key to a group, select it and press the appropriate key gesture.
Press Escape to clear the binding." + TextWrapping="Wrap" + DockPanel.Dock="Top" + Margin="5,10,5,5"/> <Grid DockPanel.Dock="Top" - Margin="0,10,0,0"> + Margin="0,5,0,0"> <Grid.ColumnDefinitions> <ColumnDefinition Width="Auto"/> <ColumnDefinition Width="Auto"/> @@ -1999,35 +2004,9 @@ Width="28" Click="btnGroupsRemoveNode_Click" /> </Grid> - <DockPanel - DataContext="{Binding ElementName=tvwGroups, Path=SelectedItem}" - DockPanel.Dock="Bottom" - Margin="0,10,0,20"> - <DockPanel.Style> - <Style TargetType="{x:Type DockPanel}"> - <Setter Property="IsEnabled" Value="False"/> - <Style.Triggers> - <DataTrigger Binding="{Binding Converter={StaticResource ObjectToClassNameConverter}}" Value="GroupEntry"> - <Setter Property="IsEnabled" Value="True"/> - </DataTrigger> - </Style.Triggers> - </Style> - </DockPanel.Style> - <Label - Content="Shortcut Key:" - DockPanel.Dock="Left" - Height="23" - Margin="0,0,10,0" - Padding="0" - VerticalContentAlignment="Center"/> - <TextBox x:Name="txtGroupHotkey" - Height="23" - IsReadOnly="True" - PreviewKeyDown="txtGroupHotkey_OnPreviewKeyDown" - Text="{Binding Path=HotkeyString, Mode=OneWay}"/> - </DockPanel> <r:TreeListView x:Name="tvwGroups" - MouseDown="tvwGroupsApps_MouseDown"> + MouseDown="tvwGroupsApps_MouseDown" + PreviewKeyDown="tvwGroups_PreviewKeyDown"> <TreeView.ItemContainerStyle> <Style TargetType="{x:Type TreeViewItem}"> <Setter Property="IsSelected" Value="{Binding Path=IsSelected, Mode=TwoWay}" /> @@ -2119,7 +2098,7 @@ Header="Applications" Width="0"> <DockPanel - Margin="14,5,10,0"> + Margin="14,5,10,16"> <StackPanel DockPanel.Dock="Top" Margin="0,0,0,4" @@ -2132,9 +2111,14 @@ FontSize="13" VerticalAlignment="Bottom"/> </StackPanel> + <TextBlock + Text="To assign a Shortcut Key to an application, select it and press the appropriate key gesture.
Press Escape to clear the binding." + TextWrapping="Wrap" + DockPanel.Dock="Top" + Margin="5,10,5,5"/> <Grid DockPanel.Dock="Top" - Margin="0,10,0,0"> + Margin="0,5,0,0"> <Grid.ColumnDefinitions> <ColumnDefinition Width="Auto"/> <ColumnDefinition Width="Auto"/> @@ -2181,7 +2165,7 @@ <Grid x:Name="grdAppProps" DataContext="{Binding ElementName=tvwApps, Path=SelectedItem}" DockPanel.Dock="Bottom" - Margin="0,10,0,20"> + Margin="0,10,0,0"> <Grid.Style> <Style TargetType="{x:Type Grid}"> <Setter Property="IsEnabled" Value="False"/> @@ -2231,7 +2215,7 @@ Grid.Row="1" Height="23" Margin="0,3" - Text="{Binding Path=Args}"/> + Text="{Binding Path=Args, UpdateSourceTrigger=PropertyChanged}"/> <Button x:Name="btnArgVars" Click="btnVars_Click" Content="%" @@ -2282,7 +2266,7 @@ Grid.Row="2" Height="23" Margin="0,3" - Text="{Binding Path=WorkingDir}"/> + Text="{Binding Path=WorkingDir, UpdateSourceTrigger=PropertyChanged}"/> <Button x:Name="btnWorkingVars" Click="btnVars_Click" Content="%" @@ -2306,7 +2290,8 @@ </Button> </Grid> <r:TreeListView x:Name="tvwApps" - MouseDown="tvwGroupsApps_MouseDown"> + MouseDown="tvwGroupsApps_MouseDown" + PreviewKeyDown="tvwApps_PreviewKeyDown"> <TreeView.ItemContainerStyle> <Style TargetType="{x:Type TreeViewItem}"> <Setter Property="IsSelected" Value="{Binding Path=IsSelected, Mode=TwoWay}" /> @@ -2345,9 +2330,9 @@ Text="{Binding Path=HotkeyString}" HorizontalAlignment="Center" VerticalAlignment="Center" - Visibility="Collapsed" /> + Visibility="Collapsed"/> <DataTemplate.Triggers> - <DataTrigger Binding="{Binding Converter={StaticResource ObjectToClassNameConverter}}" Value="GroupEntry"> + <DataTrigger Binding="{Binding Path=IsFolder}" Value="False"> <Setter TargetName="txtHotkey" Property="Visibility" Value="Visible"/> </DataTrigger> </DataTemplate.Triggers> @@ -2364,10 +2349,11 @@ DataContext="{Binding Path=bbar}" Header="Button Bar" Width="0"> - <StackPanel - Margin="14,5,10,0" - Orientation="Vertical"> + <DockPanel + LastChildFill="True" + Margin="14,5,10,16"> <StackPanel + DockPanel.Dock="Top" Margin="0,0,0,4" Orientation="Horizontal"> <Image @@ -2380,9 +2366,46 @@ </StackPanel> <Label Content="Buttons" + DockPanel.Dock="Top" Style="{StaticResource SectionHeaderStyle}"/> + <StackPanel + DockPanel.Dock="Bottom" + Orientation="Vertical"> + <Label + Content="Button Bar Options" + Style="{StaticResource SectionHeaderStyle}"/> + <CheckBox x:Name="chkLargeButtons" + Content="Large icons" + Height="16" + HorizontalAlignment="Left" + IsChecked="{Binding Path=LargeButtons}" + Margin="13,1,0,1"/> + <CheckBox x:Name="chkShowButtonLabels" + Content="Show labels on buttons" + Height="16" + HorizontalAlignment="Left" + IsChecked="{Binding Path=ShowButtonLabels}" + Margin="13,1,0,1"/> + <CheckBox x:Name="chkLockDropDownButtons" + Content="Lock the order of dropdown button menus" + Height="16" + HorizontalAlignment="Left" + IsChecked="{Binding Path=LockDropDownButtons}" + Margin="13,1,0,1"/> + <CheckBox x:Name="chkLockSearchBarWidth" + Content="Lock the size of the search box" + Height="16" + HorizontalAlignment="Left" + IsChecked="{Binding Path=LockSearchBarWidth}" + Margin="13,1,0,1"/> + <Label + Content="Custom Button Images" + Style="{StaticResource SectionHeaderStyle}" /> + <qt:FileFolderEntryBox + Margin="13,1,0,1" + SelectedPath="{Binding Path=ImageStripPath}"/> + </StackPanel> <Grid - Height="199" Margin="8"> <Grid.RowDefinitions> <RowDefinition Height="*"/> @@ -2430,39 +2453,7 @@ VerticalAlignment="Top" Width="30"/> </Grid> - <Label - Content="Button Bar Options" - Style="{StaticResource SectionHeaderStyle}"/> - <CheckBox x:Name="chkLargeButtons" - Content="Large icons" - Height="16" - HorizontalAlignment="Left" - IsChecked="{Binding Path=LargeButtons}" - Margin="13,1,0,1"/> - <CheckBox x:Name="chkShowButtonLabels" - Content="Show labels on buttons" - Height="16" - HorizontalAlignment="Left" - IsChecked="{Binding Path=ShowButtonLabels}" - Margin="13,1,0,1"/> - <CheckBox x:Name="chkLockDropDownButtons" - Content="Lock the order of dropdown button menus" - Height="16" - HorizontalAlignment="Left" - IsChecked="{Binding Path=LockDropDownButtons}" - Margin="13,1,0,1"/> - <CheckBox x:Name="chkLockSearchBarWidth" - Content="Lock the size of the search box" - Height="16" - HorizontalAlignment="Left" - IsChecked="{Binding Path=LockSearchBarWidth}" - Margin="13,1,0,1"/> - <Label - Content="Custom Button Images" - Style="{StaticResource SectionHeaderStyle}" /> - <qt:FileFolderEntryBox - SelectedPath="{Binding Path=ImageStripPath}"/> - </StackPanel> + </DockPanel> </TabItem> <!-- ============= PLUGINS ============= --> @@ -2470,7 +2461,7 @@ Header="Plugins" Width="0"> <DockPanel - Margin="14,5,10,0"> + Margin="14,5,10,16"> <StackPanel DockPanel.Dock="Top" Margin="0,0,0,4" @@ -2492,7 +2483,6 @@ <ListBox x:Name="lstPluginView" HorizontalContentAlignment="Stretch" ItemTemplate="{StaticResource PluginItemTemplate}" - Margin="0,10" ScrollViewer.HorizontalScrollBarVisibility="Disabled"> <ListBox.ItemContainerStyle> <Style TargetType="{x:Type ListBoxItem}"> Modified: branches/options/QTTabBar/OptionsDialog.xaml.cs =================================================================== --- branches/options/QTTabBar/OptionsDialog.xaml.cs 2011-12-26 08:39:49 UTC (rev 367) +++ branches/options/QTTabBar/OptionsDialog.xaml.cs 2011-12-26 22:08:47 UTC (rev 368) @@ -727,7 +727,7 @@ private bool CheckForKeyConflicts(Keys key) { const string Conflict = "This key is already assigned to:\n{0}\n\nReassign?"; const string GroupPrefix = "Open group \"{0}\""; - //const string AppPrefix = "Launch application \"{0}\""; + const string AppPrefix = "Launch application \"{0}\""; const string MsgTitle = "Keystroke conflict"; HotkeyEntry hotkey = HotkeyEntries.FirstOrDefault(e => e.Key == key); @@ -752,7 +752,17 @@ } } - // todo: apps + AppEntry app = FlattenAppList(CurrentApps).FirstOrDefault(e => e.ShortcutKey == key); + if(app != null) { + if(MessageBox.Show(string.Format(Conflict, string.Format(AppPrefix, app.Name)), MsgTitle, MessageBoxButton.OKCancel, MessageBoxImage.Warning) == MessageBoxResult.OK) { + app.ShortcutKey = Keys.None; + return true; + } + else { + return false; + } + } + return true; } @@ -943,14 +953,13 @@ if(entry != null) entry.IsEditing = false; } - private void txtGroupHotkey_OnPreviewKeyDown(object sender, KeyEventArgs e) { - e.Handled = true; + private void tvwGroups_PreviewKeyDown(object sender, KeyEventArgs e) { GroupEntry entry = tvwGroups.SelectedItem as GroupEntry; if(entry == null) return; Keys newKey; - if(ProcessNewHotkey(e, entry.ShortcutKey, out newKey)) { - entry.ShortcutKey = newKey; - } + if(!ProcessNewHotkey(e, entry.ShortcutKey, out newKey)) return; + entry.ShortcutKey = newKey; + e.Handled = true; } #endregion @@ -965,6 +974,19 @@ // todo } + private static IEnumerable<AppEntry> FlattenAppList(IEnumerable<AppEntry> AppRoot) { + foreach(AppEntry app in AppRoot) { + if(app.IsFolder) { + foreach(AppEntry child in FlattenAppList(app.Children)) { + yield return child; + } + } + else { + yield return app; + } + } + } + private void btnAddApp_Click(object sender, RoutedEventArgs e) { string path; using(OpenFileDialog ofd = new OpenFileDialog()) { @@ -976,18 +998,21 @@ int idx = sel == null ? 0 : list.IndexOf(sel) + 1; AppEntry entry = new AppEntry(false, path); list.Insert(idx, entry); + if(sel != null && sel.IsFolder) sel.IsExpanded = true; + tvwApps.Focus(); entry.IsSelected = true; - if(sel != null && sel.IsFolder) sel.IsExpanded = true; } private void btnAddAppFolder_Click(object sender, RoutedEventArgs e) { AppEntry sel = tvwApps.SelectedItem as AppEntry; IList list = sel == null ? CurrentApps : sel.IsFolder ? sel.Children : sel.ParentList; int idx = sel == null ? 0 : list.IndexOf(sel) + 1; - AppEntry entry = new AppEntry(true, "Folder"); + AppEntry entry = new AppEntry(true, "New Folder"); list.Insert(idx, entry); + if(sel != null && sel.IsFolder) sel.IsExpanded = true; + tvwApps.Focus(); entry.IsSelected = true; - if(sel != null && sel.IsFolder) sel.IsExpanded = true; + entry.IsEditing = true; } private void btnRemoveApp_Click(object sender, RoutedEventArgs e) { @@ -1012,6 +1037,15 @@ UpDownOnTreeView(tvwApps, false); } + private void tvwApps_PreviewKeyDown(object sender, KeyEventArgs e) { + AppEntry entry = tvwApps.SelectedItem as AppEntry; + if(entry == null || entry.IsFolder) return; + Keys newKey; + if(!ProcessNewHotkey(e, entry.ShortcutKey, out newKey)) return; + entry.ShortcutKey = newKey; + e.Handled = true; + } + private void btnVars_Click(object sender, RoutedEventArgs e) { var button = ((Button)sender); ContextMenu menu = button.ContextMenu; @@ -1780,6 +1814,10 @@ public string Path { get; set; } public string Args { get; set; } public string WorkingDir { get; set; } + public Keys ShortcutKey { get; set; } + public string HotkeyString { + get { return QTUtility2.MakeKeyString(ShortcutKey); } + } public Image Icon { get { This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |