Skip to content

Commit 7918152

Browse files
committed
TabBar
1 parent 963a3ec commit 7918152

17 files changed

+363
-88
lines changed

NetDebug/App.xaml

Lines changed: 29 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -2,17 +2,36 @@
22
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
33
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
44
xmlns:local="clr-namespace:MeowType.NetDebug"
5-
StartupUri="MainWindow.xaml">
5+
>
6+
<!--StartupUri="MainWindow.xaml"-->
67
<Application.Resources>
78
<FontFamily x:Key="FiraCodeLight">pack://application:,,,/Fonts/#Fira Code Light</FontFamily>
8-
<Style TargetType="{x:Type local:Tab}">
9-
<!--<Setter Property="Template">
10-
<Setter.Value>
11-
<ControlTemplate TargetType="{x:Type UserControl}">
12-
13-
</ControlTemplate>
14-
</Setter.Value>
15-
</Setter>-->
16-
</Style>
9+
<ControlTemplate x:Key="ButtonBaseControlTemplateFuck" TargetType="{x:Type ButtonBase}">
10+
<Border x:Name="border" BorderBrush="{TemplateBinding BorderBrush}" BorderThickness="{TemplateBinding BorderThickness}" Background="{TemplateBinding Background}" SnapsToDevicePixels="True">
11+
<ContentPresenter x:Name="contentPresenter" ContentTemplate="{TemplateBinding ContentTemplate}" Content="{TemplateBinding Content}" ContentStringFormat="{TemplateBinding ContentStringFormat}" Focusable="False" HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}" Margin="{TemplateBinding Padding}" RecognizesAccessKey="True" SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}" VerticalAlignment="{TemplateBinding VerticalContentAlignment}"/>
12+
</Border>
13+
<ControlTemplate.Triggers>
14+
<Trigger Property="Button.IsDefaulted" Value="True">
15+
<Setter Property="BorderBrush" TargetName="border" Value="Transparent"/>
16+
</Trigger>
17+
<Trigger Property="IsMouseOver" Value="True">
18+
<Setter Property="Background" TargetName="border" Value="Transparent"/>
19+
<Setter Property="BorderBrush" TargetName="border" Value="Transparent"/>
20+
</Trigger>
21+
<Trigger Property="IsPressed" Value="True">
22+
<Setter Property="Background" TargetName="border" Value="Transparent"/>
23+
<Setter Property="BorderBrush" TargetName="border" Value="Transparent"/>
24+
</Trigger>
25+
<Trigger Property="ToggleButton.IsChecked" Value="True">
26+
<Setter Property="Background" TargetName="border" Value="Transparent"/>
27+
<Setter Property="BorderBrush" TargetName="border" Value="Transparent"/>
28+
</Trigger>
29+
<Trigger Property="IsEnabled" Value="False">
30+
<Setter Property="Background" TargetName="border" Value="Transparent"/>
31+
<Setter Property="BorderBrush" TargetName="border" Value="Transparent"/>
32+
<Setter Property="Foreground" Value="Transparent"/>
33+
</Trigger>
34+
</ControlTemplate.Triggers>
35+
</ControlTemplate>
1736
</Application.Resources>
1837
</Application>

NetDebug/Common/MsgBox.xaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
<RichTextBox Grid.Row="0" Name="Msg_Box" VerticalScrollBarVisibility="Auto" FontFamily="Consolas, Fira Code Light, Microsoft YaHei UI Light" IsReadOnly="True" Loaded="MsgBox_Loaded"/>
1515
<Grid Grid.Row="1" Margin="0,5,0,0">
1616
<Grid.ColumnDefinitions>
17-
<ColumnDefinition Width="55"></ColumnDefinition>
17+
<ColumnDefinition Width="65"></ColumnDefinition>
1818
<ColumnDefinition Width="1*"></ColumnDefinition>
1919
<ColumnDefinition Width="0.25*" MinWidth="50" MaxWidth="120"></ColumnDefinition>
2020
</Grid.ColumnDefinitions>

NetDebug/EmptyTab.xaml

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
<UserControl x:Class="MeowType.NetDebug.EmptyTab"
2+
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
3+
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
4+
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
5+
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
6+
xmlns:local="clr-namespace:MeowType.NetDebug"
7+
mc:Ignorable="d"
8+
d:DesignHeight="450" d:DesignWidth="800">
9+
<Grid>
10+
<Grid.ColumnDefinitions>
11+
<ColumnDefinition Width="*"></ColumnDefinition>
12+
<ColumnDefinition Width="2*" MinWidth="300"></ColumnDefinition>
13+
<ColumnDefinition Width="*"></ColumnDefinition>
14+
</Grid.ColumnDefinitions>
15+
<Grid.RowDefinitions>
16+
<RowDefinition Height="*"></RowDefinition>
17+
<RowDefinition Height="2*" MinHeight="200"></RowDefinition>
18+
<RowDefinition Height="*"></RowDefinition>
19+
</Grid.RowDefinitions>
20+
<Grid Grid.Row="1" Grid.Column="1">
21+
<Grid.ColumnDefinitions>
22+
<ColumnDefinition Width="*"></ColumnDefinition>
23+
<ColumnDefinition Width="*"></ColumnDefinition>
24+
</Grid.ColumnDefinitions>
25+
<Grid.RowDefinitions>
26+
<RowDefinition Height="*"></RowDefinition>
27+
<RowDefinition Height="*"></RowDefinition>
28+
</Grid.RowDefinitions>
29+
<Button Margin="10" FontSize="25">Tcp Server</Button>
30+
<Button Margin="10" FontSize="25" Grid.Column="1">Tcp Client</Button>
31+
<Button Margin="10" FontSize="25" Grid.Row="1" Click="Udp_Click">Udp</Button>
32+
<Button Margin="10" FontSize="25" Grid.Row="1" Grid.Column="1">Custom</Button>
33+
</Grid>
34+
</Grid>
35+
</UserControl>

NetDebug/EmptyTab.xaml.cs

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
using Dragablz;
2+
using System;
3+
using System.Collections.Generic;
4+
using System.Linq;
5+
using System.Text;
6+
using System.Threading.Tasks;
7+
using System.Windows;
8+
using System.Windows.Controls;
9+
using System.Windows.Data;
10+
using System.Windows.Documents;
11+
using System.Windows.Input;
12+
using System.Windows.Media;
13+
using System.Windows.Media.Imaging;
14+
using System.Windows.Navigation;
15+
using System.Windows.Shapes;
16+
17+
namespace MeowType.NetDebug
18+
{
19+
/// <summary>
20+
/// EmptyTab.xaml 的交互逻辑
21+
/// </summary>
22+
public partial class EmptyTab : UserControl
23+
{
24+
public EmptyTab()
25+
{
26+
InitializeComponent();
27+
}
28+
29+
public HeaderedItemViewModel TabView
30+
{
31+
get { return (HeaderedItemViewModel)GetValue(TabViewProperty); }
32+
set { SetValue(TabViewProperty, value); }
33+
}
34+
35+
// Using a DependencyProperty as the backing store for TabView. This enables animation, styling, binding, etc...
36+
public static readonly DependencyProperty TabViewProperty =
37+
DependencyProperty.Register("TabView", typeof(HeaderedItemViewModel), typeof(EmptyTab), new PropertyMetadata(default(HeaderedItemViewModel)));
38+
39+
private void Udp_Click(object sender, RoutedEventArgs e)
40+
{
41+
TabView.Header = "Udp";
42+
TabView.Content = new Udp();
43+
}
44+
}
45+
}

NetDebug/Main.cs

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
using Dragablz;
2+
using System;
3+
using System.Collections.Generic;
4+
using System.Linq;
5+
using System.Text;
6+
using System.Threading.Tasks;
7+
8+
namespace MeowType.NetDebug
9+
{
10+
public class MainObj
11+
{
12+
[STAThread]
13+
public static void Main(string[] args)
14+
{
15+
App app = new App();
16+
app.InitializeComponent();
17+
18+
var mw = new MainWindow();
19+
((TabViewModel)mw.InitialTabablzControl.DataContext).Items.Add(NewTab.New());
20+
mw.Show();
21+
22+
app.Run();
23+
}
24+
}
25+
}

NetDebug/MainWindow.xaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@
3030
<local:TabBar x:Name="tab_bar"></local:TabBar>
3131
</Grid>-->
3232
<Grid Margin="0,-30,0,0">
33-
<local:TabView></local:TabView>
33+
<local:TabView x:Name="InitialTabablzControl"></local:TabView>
3434
</Grid>
3535
</Grid>
3636
</Window>

NetDebug/NetDebug.csproj

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,9 @@
4949
<ErrorReport>prompt</ErrorReport>
5050
<WarningLevel>4</WarningLevel>
5151
</PropertyGroup>
52+
<PropertyGroup>
53+
<StartupObject>MeowType.NetDebug.MainObj</StartupObject>
54+
</PropertyGroup>
5255
<ItemGroup>
5356
<Reference Include="Dragablz, Version=0.0.3.203, Culture=neutral, processorArchitecture=MSIL">
5457
<HintPath>..\packages\Dragablz.0.0.3.203\lib\net45\Dragablz.dll</HintPath>
@@ -88,6 +91,11 @@
8891
<Compile Include="Common\TabView.xaml.cs">
8992
<DependentUpon>TabView.xaml</DependentUpon>
9093
</Compile>
94+
<Compile Include="EmptyTab.xaml.cs">
95+
<DependentUpon>EmptyTab.xaml</DependentUpon>
96+
</Compile>
97+
<Compile Include="Main.cs" />
98+
<Compile Include="TabBar\NewTab.cs" />
9199
<Compile Include="TabBar\Tab.xaml.cs">
92100
<DependentUpon>Tab.xaml</DependentUpon>
93101
</Compile>
@@ -125,6 +133,10 @@
125133
<SubType>Designer</SubType>
126134
<Generator>MSBuild:Compile</Generator>
127135
</Page>
136+
<Page Include="EmptyTab.xaml">
137+
<SubType>Designer</SubType>
138+
<Generator>MSBuild:Compile</Generator>
139+
</Page>
128140
<Page Include="MainWindow.xaml">
129141
<Generator>MSBuild:Compile</Generator>
130142
<SubType>Designer</SubType>

NetDebug/TabBar/NewTab.cs

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
using Dragablz;
2+
using System;
3+
using System.Collections.Generic;
4+
using System.Linq;
5+
using System.Text;
6+
using System.Threading.Tasks;
7+
8+
namespace MeowType.NetDebug
9+
{
10+
public static class NewTab
11+
{
12+
public static HeaderedItemViewModel New()
13+
{
14+
var item = new EmptyTab();
15+
var tab = new HeaderedItemViewModel()
16+
{
17+
Header = "New Tab",
18+
Content = item
19+
};
20+
item.TabView = tab;
21+
return tab;
22+
}
23+
public static Func<HeaderedItemViewModel> Factory => New;
24+
}
25+
}

NetDebug/TabBar/Tab.xaml

Lines changed: 15 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@
44
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
55
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
66
xmlns:local="clr-namespace:MeowType.NetDebug"
7+
xmlns:dragablz="http://dragablz.net/winfx/xaml/dragablz"
8+
xmlns:dockablz="http://dragablz.net/winfx/xaml/dockablz"
79
mc:Ignorable="d" Name="self"
810
d:DesignHeight="30" d:DesignWidth="200" MinWidth="50" MaxWidth="200">
911
<UserControl.Resources>
@@ -59,22 +61,31 @@
5961
<local:TabBg x:Name="tab_bg">
6062
<local:TabBg.Style>
6163
<Style TargetType="local:TabBg">
62-
<Setter Property="Opacity" Value="0"></Setter>
64+
<Setter Property="Opacity" Value="1"></Setter>
6365
<Style.Triggers>
64-
<DataTrigger Binding="{Binding IsSelected, ElementName=self}" Value="True">
65-
<Setter Property="Opacity" Value="1"></Setter>
66+
<DataTrigger Binding="{Binding IsSelected, ElementName=self}" Value="False">
67+
<Setter Property="Opacity" Value="0"></Setter>
68+
</DataTrigger>
69+
<DataTrigger Binding="{Binding IsHover, ElementName=self}" Value="True">
70+
<Setter Property="Opacity" Value="0.1"></Setter>
6671
</DataTrigger>
6772
</Style.Triggers>
6873
</Style>
6974
</local:TabBg.Style>
7075
</local:TabBg>
7176

77+
<Border Height="10" Width="1" Background="#77FFFFFF" HorizontalAlignment="Left"></Border>
78+
<Border Height="10" Width="1" Background="#77FFFFFF" HorizontalAlignment="Right"></Border>
79+
7280
<Grid WindowChrome.IsHitTestVisibleInChrome="True">
7381
<Grid.ColumnDefinitions>
7482
<ColumnDefinition Width="*"></ColumnDefinition>
7583
<ColumnDefinition Width="15"></ColumnDefinition>
7684
</Grid.ColumnDefinitions>
7785
<Label Name="TabContent" DataContext="{Binding ElementName=self}" Content="{Binding Title, Mode=OneWay, UpdateSourceTrigger=PropertyChanged}" Padding="5,0" Margin="5,0,15,0" VerticalAlignment="Center">
86+
<Label.Effect>
87+
<DropShadowEffect ShadowDepth="0" BlurRadius="5" Opacity="0.5"/>
88+
</Label.Effect>
7889
<Label.Style>
7990
<Style TargetType="Label">
8091
<Setter Property="Foreground" Value="#FFFCFCFC"></Setter>
@@ -86,7 +97,7 @@
8697
</Style>
8798
</Label.Style>
8899
</Label>
89-
<Button Grid.Column="1" Height="15" Width="15" BorderThickness="0" Padding="0" Margin="-15,0,0,0" Click="Close_Click" Style="{DynamicResource CloseButtonStyle}">
100+
<Button Command="{x:Static dragablz:TabablzControl.CloseItemCommand}" Grid.Column="1" Height="15" Width="15" BorderThickness="0" Padding="0" Margin="-15,0,0,0" Click="Close_Click" Style="{DynamicResource CloseButtonStyle}">
90101
<Button.OpacityMask>
91102
<VisualBrush>
92103
<VisualBrush.Visual>

NetDebug/TabBar/Tab.xaml.cs

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,16 @@ public bool IsSelected
3939
public static readonly DependencyProperty IsSelectedProperty =
4040
DependencyProperty.Register("IsSelected", typeof(bool), typeof(Tab), new PropertyMetadata(true));
4141

42+
public bool IsHover
43+
{
44+
get { return (bool)GetValue(IsHoverProperty); }
45+
set { SetValue(IsHoverProperty, value); }
46+
}
47+
48+
// Using a DependencyProperty as the backing store for IsSelected. This enables animation, styling, binding, etc...
49+
public static readonly DependencyProperty IsHoverProperty =
50+
DependencyProperty.Register("IsHover", typeof(bool), typeof(Tab), new PropertyMetadata(false));
51+
4252
public string Title
4353
{
4454
get { return (string)GetValue(TitleProperty); }

0 commit comments

Comments
 (0)