Permalink
Browse files

Initial commit.

  • Loading branch information...
Curtis Schlak
Curtis Schlak committed Mar 2, 2012
0 parents commit 10cdbae259619a0b6b00852e028e03addd43aa54
@@ -0,0 +1,3 @@
bin
obj
*.suo
@@ -0,0 +1,42 @@

Microsoft Visual Studio Solution File, Format Version 11.00
# Visual Studio 2010
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ChromiumTabsRunner", "ChromiumTabsRunner\ChromiumTabsRunner.csproj", "{8B45B6B7-1579-4F59-9A02-7F3C0BAC5DFC}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ChromiumTabs", "ChromiumTabs\ChromiumTabs.csproj", "{0208352A-D75A-44B1-9C21-AA54D64D24B6}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Debug|Mixed Platforms = Debug|Mixed Platforms
Debug|x86 = Debug|x86
Release|Any CPU = Release|Any CPU
Release|Mixed Platforms = Release|Mixed Platforms
Release|x86 = Release|x86
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{8B45B6B7-1579-4F59-9A02-7F3C0BAC5DFC}.Debug|Any CPU.ActiveCfg = Debug|x86
{8B45B6B7-1579-4F59-9A02-7F3C0BAC5DFC}.Debug|Mixed Platforms.ActiveCfg = Debug|x86
{8B45B6B7-1579-4F59-9A02-7F3C0BAC5DFC}.Debug|Mixed Platforms.Build.0 = Debug|x86
{8B45B6B7-1579-4F59-9A02-7F3C0BAC5DFC}.Debug|x86.ActiveCfg = Debug|x86
{8B45B6B7-1579-4F59-9A02-7F3C0BAC5DFC}.Debug|x86.Build.0 = Debug|x86
{8B45B6B7-1579-4F59-9A02-7F3C0BAC5DFC}.Release|Any CPU.ActiveCfg = Release|x86
{8B45B6B7-1579-4F59-9A02-7F3C0BAC5DFC}.Release|Mixed Platforms.ActiveCfg = Release|x86
{8B45B6B7-1579-4F59-9A02-7F3C0BAC5DFC}.Release|Mixed Platforms.Build.0 = Release|x86
{8B45B6B7-1579-4F59-9A02-7F3C0BAC5DFC}.Release|x86.ActiveCfg = Release|x86
{8B45B6B7-1579-4F59-9A02-7F3C0BAC5DFC}.Release|x86.Build.0 = Release|x86
{0208352A-D75A-44B1-9C21-AA54D64D24B6}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{0208352A-D75A-44B1-9C21-AA54D64D24B6}.Debug|Any CPU.Build.0 = Debug|Any CPU
{0208352A-D75A-44B1-9C21-AA54D64D24B6}.Debug|Mixed Platforms.ActiveCfg = Debug|Any CPU
{0208352A-D75A-44B1-9C21-AA54D64D24B6}.Debug|Mixed Platforms.Build.0 = Debug|Any CPU
{0208352A-D75A-44B1-9C21-AA54D64D24B6}.Debug|x86.ActiveCfg = Debug|Any CPU
{0208352A-D75A-44B1-9C21-AA54D64D24B6}.Release|Any CPU.ActiveCfg = Release|Any CPU
{0208352A-D75A-44B1-9C21-AA54D64D24B6}.Release|Any CPU.Build.0 = Release|Any CPU
{0208352A-D75A-44B1-9C21-AA54D64D24B6}.Release|Mixed Platforms.ActiveCfg = Release|Any CPU
{0208352A-D75A-44B1-9C21-AA54D64D24B6}.Release|Mixed Platforms.Build.0 = Release|Any CPU
{0208352A-D75A-44B1-9C21-AA54D64D24B6}.Release|x86.ActiveCfg = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
EndGlobal
@@ -0,0 +1,106 @@
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.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;
using System.Windows.Controls.Primitives;
using System.Collections.Specialized;
namespace ChromiumTabs
{
/// <summary>
/// Follow steps 1a or 1b and then 2 to use this custom control in a XAML file.
///
/// Step 1a) Using this custom control in a XAML file that exists in the current project.
/// Add this XmlNamespace attribute to the root element of the markup file where it is
/// to be used:
///
/// xmlns:MyNamespace="clr-namespace:ChromiumTabs"
///
///
/// Step 1b) Using this custom control in a XAML file that exists in a different project.
/// Add this XmlNamespace attribute to the root element of the markup file where it is
/// to be used:
///
/// xmlns:MyNamespace="clr-namespace:ChromiumTabs;assembly=ChromiumTabs"
///
/// You will also need to add a project reference from the project where the XAML file lives
/// to this project and Rebuild to avoid compilation errors:
///
/// Right click on the target project in the Solution Explorer and
/// "Add Reference"->"Projects"->[Select this project]
///
///
/// Step 2)
/// Go ahead and use your control in the XAML file.
///
/// <MyNamespace:CustomControl1/>
///
/// </summary>
public class ChromiumTabControl : Selector
{
public static readonly DependencyProperty SelectedContentProperty = DependencyProperty.Register("SelectedContent", typeof(object), typeof(ChromiumTabControl), new FrameworkPropertyMetadata(null, FrameworkPropertyMetadataOptions.AffectsRender));
static ChromiumTabControl()
{
DefaultStyleKeyProperty.OverrideMetadata(typeof(ChromiumTabControl), new FrameworkPropertyMetadata(typeof(ChromiumTabControl)));
}
public object SelectedContent
{
get { return (object)GetValue(SelectedContentProperty); }
set { SetValue(SelectedContentProperty, value); }
}
protected override void OnItemsChanged(NotifyCollectionChangedEventArgs e)
{
base.OnItemsChanged(e);
this.SetChildrenZ();
}
protected override void OnSelectionChanged(SelectionChangedEventArgs e)
{
base.OnSelectionChanged(e);
this.SetChildrenZ();
if (this.SelectedItem == null) { return; }
ChromiumTabItem item = this.SelectedItem as ChromiumTabItem;
this.SelectedContent = item.Content;
}
protected override bool IsItemItsOwnContainerOverride(object item)
{
return (item is ChromiumTabItem);
}
protected override DependencyObject GetContainerForItemOverride()
{
return new ChromiumTabItem();
}
private void SetChildrenZ()
{
int zindex = this.Items.Count - 1;
foreach (UIElement element in this.Items)
{
if (element == null) { continue; }
if (Selector.GetIsSelected(element))
{
Panel.SetZIndex(element, this.Items.Count);
}
else
{
Panel.SetZIndex(element, zindex);
}
zindex -= 1;
}
}
}
}
@@ -0,0 +1,91 @@
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.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;
using System.Windows.Controls.Primitives;
namespace ChromiumTabs
{
/// <summary>
/// Follow steps 1a or 1b and then 2 to use this custom control in a XAML file.
///
/// Step 1a) Using this custom control in a XAML file that exists in the current project.
/// Add this XmlNamespace attribute to the root element of the markup file where it is
/// to be used:
///
/// xmlns:MyNamespace="clr-namespace:ChromiumTabs"
///
///
/// Step 1b) Using this custom control in a XAML file that exists in a different project.
/// Add this XmlNamespace attribute to the root element of the markup file where it is
/// to be used:
///
/// xmlns:MyNamespace="clr-namespace:ChromiumTabs;assembly=ChromiumTabs"
///
/// You will also need to add a project reference from the project where the XAML file lives
/// to this project and Rebuild to avoid compilation errors:
///
/// Right click on the target project in the Solution Explorer and
/// "Add Reference"->"Projects"->[Browse to and select this project]
///
///
/// Step 2)
/// Go ahead and use your control in the XAML file.
///
/// <MyNamespace:ChromiumTabItem/>
///
/// </summary>
public class ChromiumTabItem : HeaderedContentControl
{
public static readonly DependencyProperty IsSelectedProperty = Selector.IsSelectedProperty.AddOwner(typeof(ChromiumTabItem), new FrameworkPropertyMetadata(false, FrameworkPropertyMetadataOptions.AffectsRender));
static ChromiumTabItem()
{
DefaultStyleKeyProperty.OverrideMetadata(typeof(ChromiumTabItem), new FrameworkPropertyMetadata(typeof(ChromiumTabItem)));
}
public bool IsSelected
{
get { return (bool)GetValue(IsSelectedProperty); }
set { SetValue(IsSelectedProperty, value); }
}
protected override void OnMouseLeftButtonDown(MouseButtonEventArgs e)
{
this.hasButtonDown = true;
base.OnMouseLeftButtonDown(e);
}
protected override void OnMouseLeave(MouseEventArgs e)
{
this.hasButtonDown = false;
base.OnMouseLeave(e);
}
protected override void OnMouseLeftButtonUp(MouseButtonEventArgs e)
{
base.OnMouseLeftButtonUp(e);
if (this.hasButtonDown)
{
ParentTabControl.SelectedItem = this;
}
this.hasButtonDown = false;
}
private ChromiumTabControl ParentTabControl
{
get { return ItemsControl.ItemsControlFromItemContainer(this) as ChromiumTabControl; }
}
private bool hasButtonDown;
}
}
@@ -0,0 +1,89 @@
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.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;
namespace ChromiumTabs
{
/// <summary>
/// Follow steps 1a or 1b and then 2 to use this custom control in a XAML file.
///
/// Step 1a) Using this custom control in a XAML file that exists in the current project.
/// Add this XmlNamespace attribute to the root element of the markup file where it is
/// to be used:
///
/// xmlns:MyNamespace="clr-namespace:ChromiumTabs"
///
///
/// Step 1b) Using this custom control in a XAML file that exists in a different project.
/// Add this XmlNamespace attribute to the root element of the markup file where it is
/// to be used:
///
/// xmlns:MyNamespace="clr-namespace:ChromiumTabs;assembly=ChromiumTabs"
///
/// You will also need to add a project reference from the project where the XAML file lives
/// to this project and Rebuild to avoid compilation errors:
///
/// Right click on the target project in the Solution Explorer and
/// "Add Reference"->"Projects"->[Browse to and select this project]
///
///
/// Step 2)
/// Go ahead and use your control in the XAML file.
///
/// <MyNamespace:ChromiumTabPanel/>
///
/// </summary>
public class ChromiumTabPanel : Panel
{
static ChromiumTabPanel()
{
DefaultStyleKeyProperty.OverrideMetadata(typeof(ChromiumTabPanel), new FrameworkPropertyMetadata(typeof(ChromiumTabPanel)));
}
protected override void OnRender(DrawingContext dc)
{
base.OnRender(dc);
Point start = new Point(0, Math.Round(finalSize.Height));
Point end = new Point(finalSize.Width, Math.Round(finalSize.Height));
Color penColor = (Color)ColorConverter.ConvertFromString("#FF999999");
Brush brush = new SolidColorBrush(penColor);
Pen pen = new Pen(brush, .5);
dc.DrawLine(pen, start, end);
}
protected override Size ArrangeOverride(Size finalSize)
{
this.finalSize = finalSize;
double offset = 0.0;
foreach (UIElement element in this.Children)
{
double thickness = 0.0;
Control c = element as Control;
if(c != null)
{
thickness = c.Margin.Bottom;
}
element.Arrange(new Rect(offset, 0, 100, finalSize.Height - thickness));
offset += 90;
}
return finalSize;
}
protected override Size MeasureOverride(Size availableSize)
{
return base.MeasureOverride(availableSize);
}
private Size finalSize;
}
}
Oops, something went wrong.

0 comments on commit 10cdbae

Please sign in to comment.