- demo.zip
- diagram.png
- Example.exe
- TabStripControlLibrary.dll
- source.zip
- Source
- TabStripApp
- archive
- bin
- Release
- diagram.png
- Example.exe
- TabStripApp.pdb
- TabStripApp.vshost.exe
- TabStripControlLibrary.dll
- TabStripControlLibrary.pdb
- Form1.cs
- Form1.Designer.cs
- Form1.resx
- InfoForm.cs
- Program.cs
- Properties
- Resources
- advanced-directory.png
- B_click.png
- B_click1.png
- B_click11.png
- B_on.png
- B_on1.png
- B_on11.png
- config-users.png
- gnome-dev-harddisk-1394.png
- gnome-dev-removable-usb.png
- gnome-finance.png
- gnome-netstatus-rx.png
- gnome-searchtool-animation.png
- gnome-starthere.png
- logviewer.png
- mozilla-thunderbird.png
- pan.png
- stock_contact.png
- stock_mail-compose.png
- stock_mail-druid.png
- stock_mail-flag-for-followup-done.png
- stock_mail-receive.png
- stock_mail-receive1.png
- stock_mail-send.png
- stock_new-spreadsheet.png
- stock_outbox.png
- stock_weather-storm.png
- Thumbs.db
- xsane.png
- RibbonButton.cs
- TabPanel.cs
- TabStripApp.csproj
- TabStripApp.sln
- TabStripControlLibrary
|
using System.Diagnostics;
using System.Diagnostics.CodeAnalysis;
using System;
using System.IO;
using System.Collections;
using System.ComponentModel;
using System.ComponentModel.Design;
using System.Windows.Forms;
using System.Drawing;
using System.Drawing.Design;
using System.Design;
using System.Windows.Forms.ComponentModel;
using System.Runtime.Serialization;
using System.Windows.Forms.Design;
using System.Collections.Generic;
namespace TabStripApp {
[Serializable]
internal class TabStripToolboxItem : ToolboxItem {
public TabStripToolboxItem() { }
public TabStripToolboxItem(Type toolType)
: base(toolType) {
}
private TabStripToolboxItem(SerializationInfo info, StreamingContext context) {
Deserialize(info, context);
}
protected override IComponent[] CreateComponentsCore(IDesignerHost host) {
IComponent[] components = base.CreateComponentsCore(host);
Control parentControl = null;
ControlDesigner parentControlDesigner = null;
TabStrip tabStrip = null;
IComponentChangeService changeSvc = (IComponentChangeService)host.GetService(typeof(IComponentChangeService));
// fish out the parent we're adding the TabStrip to.
if (components.Length > 0 && components[0] is TabStrip) {
tabStrip = components[0] as TabStrip;
ITreeDesigner tabStripDesigner = host.GetDesigner(tabStrip) as ITreeDesigner;
parentControlDesigner = tabStripDesigner.Parent as ControlDesigner;
if (parentControlDesigner != null) {
parentControl = parentControlDesigner.Control;
}
}
// Create a ControlSwitcher on the same parent.
if (host != null) {
TabPageSwitcher controlSwitcher = null;
DesignerTransaction t = null;
try {
try {
t = host.CreateTransaction("add tabswitcher");
}
catch (CheckoutException ex) {
if (ex == CheckoutException.Canceled) {
return components;
}
throw ex;
}
MemberDescriptor controlsMember = TypeDescriptor.GetProperties(parentControlDesigner)["Controls"];
controlSwitcher = host.CreateComponent(typeof(TabPageSwitcher)) as TabPageSwitcher;
if (changeSvc != null) {
changeSvc.OnComponentChanging(parentControl, controlsMember);
changeSvc.OnComponentChanged(parentControl, controlsMember, null, null);
}
Dictionary<string, object> propertyValues = new Dictionary<string, object>();
propertyValues["Location"] = new Point(tabStrip.Left, tabStrip.Bottom + 3);
propertyValues["TabStrip"] = tabStrip;
SetProperties(controlSwitcher, propertyValues, host);
}
finally {
if (t != null)
t.Commit();
}
if (controlSwitcher != null) {
IComponent[] newComponents = new IComponent[components.Length + 1];
Array.Copy(components, newComponents, components.Length);
newComponents[newComponents.Length - 1] = controlSwitcher;
return newComponents;
}
}
return components;
}
private void SetProperties(Component component, Dictionary<string,object> properties, IDesignerHost host) {
IComponentChangeService changeSvc = (IComponentChangeService)host.GetService(typeof(IComponentChangeService));
foreach (string propname in properties.Keys) {
PropertyDescriptor propDescriptor = TypeDescriptor.GetProperties(component)[propname];
if (changeSvc != null) {
changeSvc.OnComponentChanging(component, propDescriptor);
}
if (propDescriptor != null) {
propDescriptor.SetValue(component, properties[propname]);
}
if (changeSvc != null) {
changeSvc.OnComponentChanged(component, propDescriptor, null, null);
}
}
}
}
}
|
By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.
If a file you wish to view isn't highlighted, and is a text file (not binary), please
let us know and we'll add colourisation support for it.
I'm Electronic Engineer, I did my end degree project at Astrophysical Institute and Tech Institute. I'm HP Procurve AIS and ASE ,Microsoft 3.5 MCTS
I live in Canary Islands ,developing customized solutions
Deeply involved in Xamarin Forms LOB (including Azure Cloud with offline support, custom controls, dependencies) projects, WP8.1 & W10 projects, WPF modern styled projects. Portable libraries like portablePDF, portableOneDrive, portableReports and portablePrinting (using Google Printing API).
Web and apps showcase at:
Expediteapps
Take a look to my blog
Blog