Imported Upstream version 4.0.0~alpha1

Former-commit-id: 806294f5ded97629b74c85c09952f2a74fe182d9
This commit is contained in:
Jo Shields
2015-04-07 09:35:12 +01:00
parent 283343f570
commit 3c1f479b9d
22469 changed files with 2931443 additions and 869343 deletions

View File

@@ -0,0 +1,76 @@
//------------------------------------------------------------------------------
// <copyright file="DefaultDialogButtons.cs" company="Microsoft">
// Copyright (c) Microsoft Corporation. All rights reserved.
// </copyright>
//------------------------------------------------------------------------------
// File created with Beta1 Windes. (Build 1.0.2204.21)
// Made to compile under new URT by 'sed "s/Windows.Forms/Windows.Forms/g"'
// Any manual modifications marked by HUMAN comments.
// Size of panel should be 237,23.
namespace System.Web.UI.Design.MobileControls.Util
{
using System;
using System.Drawing;
using System.ComponentModel;
using System.Windows.Forms;
[
System.Security.Permissions.SecurityPermission(System.Security.Permissions.SecurityAction.Demand,
Flags=System.Security.Permissions.SecurityPermissionFlag.UnmanagedCode)
]
[Obsolete("The System.Web.Mobile.dll assembly has been deprecated and should no longer be used. For information about how to develop ASP.NET mobile applications, see http://go.microsoft.com/fwlink/?LinkId=157231.")]
internal class DefaultDialogButtons : Panel
{
private System.ComponentModel.Container components;
internal System.Windows.Forms.Button CmdCancel;
internal System.Windows.Forms.Button CmdOK;
////////////////////////////////////////////////////////////////////////
// Begin WinDes Generated
////////////////////////////////////////////////////////////////////////
/// <summary>
/// Required by the Win Forms designer
/// </summary>
internal DefaultDialogButtons()
{
// Required for Win Form Designer support
InitializeComponent();
CmdOK.Text = SR.GetString(SR.GenericDialog_OKBtnCaption);
CmdCancel.Text = SR.GetString(SR.GenericDialog_CancelBtnCaption);
}
protected override void Dispose(bool disposing)
{
if(disposing)
{
components.Dispose();
}
base.Dispose(disposing);
}
private void InitializeComponent()
{
this.components = new System.ComponentModel.Container();
this.CmdOK = new System.Windows.Forms.Button();
this.CmdCancel = new System.Windows.Forms.Button();
CmdOK.Location = new System.Drawing.Point(81, 0);
CmdOK.Size = new System.Drawing.Size(75, 23);
CmdCancel.Location = new System.Drawing.Point(162, 0);
CmdCancel.Size = new System.Drawing.Size(75, 23);
this.Controls.Add(CmdOK);
this.Controls.Add(CmdCancel);
}
////////////////////////////////////////////////////////////////////////
// End WinDes Generated
////////////////////////////////////////////////////////////////////////
}
}

View File

@@ -0,0 +1,150 @@
//------------------------------------------------------------------------------
// <copyright file="DesignerUtility.cs" company="Microsoft">
// Copyright (c) Microsoft Corporation. All rights reserved.
// </copyright>
//------------------------------------------------------------------------------
namespace System.Web.UI.Design.MobileControls.Util
{
using System;
using System.Collections;
using System.Collections.Specialized;
using System.ComponentModel;
using System.ComponentModel.Design;
using System.Diagnostics;
using System.Reflection;
using System.Web.UI.MobileControls;
using System.Globalization;
[
System.Security.Permissions.SecurityPermission(System.Security.Permissions.SecurityAction.Demand,
Flags=System.Security.Permissions.SecurityPermissionFlag.UnmanagedCode)
]
[Obsolete("The System.Web.Mobile.dll assembly has been deprecated and should no longer be used. For information about how to develop ASP.NET mobile applications, see http://go.microsoft.com/fwlink/?LinkId=157231.")]
internal class DesignerUtility
{
/* Removed for DCR 4240
internal static bool IsValidName(String name)
{
if (name == null || name.Length == 0)
{
return false;
}
for (int pos = 0; pos < name.Length; pos++)
{
Char ch = name[pos];
if (Char.IsWhiteSpace(ch) || ch.Equals('"') || ch.Equals('<') ||
ch.Equals('>') || ch.Equals('\'') || ch.Equals('&'))
{
return false;
}
}
return true;
}
*/
internal static bool TopLevelControl(MobileControl control)
{
if (control is Form || control is StyleSheet)
{
return true;
}
return false;
}
internal static String ChoiceToUniqueIdentifier(DeviceSpecificChoice choice)
{
Debug.Assert(choice != null);
return ChoiceToUniqueIdentifier(choice.Filter, choice.Argument);
}
internal static String ChoiceToUniqueIdentifier(String filter, String argument)
{
if (String.IsNullOrEmpty(filter))
{
filter = SR.GetString(SR.DeviceFilter_DefaultChoice);
}
if (argument == null)
{
argument = String.Empty;
}
return String.Format(CultureInfo.InvariantCulture, "{0} (\"{1}\")", filter, argument);
}
// NOTE: Throws CheckoutException.Canceled if user cancels checkout.
internal static void EnsureFileCheckedOut(ISite site, String fileName)
{
Type serviceType = Type.GetType("Microsoft.VisualStudio.Shell.VsCheckoutService, " + AssemblyRef.MicrosoftVisualStudio);
// Do nothing if service cannot be found.
if (serviceType == null) {
// Debug.Fail("type Microsoft.VisualStudio.Shell.VsCheckoutService cannot be found in DesignerUtility.EnsureFileCheckedOut.");
return;
}
Object serviceInstance = System.Activator.CreateInstance(
serviceType, new Object[] { site });
try
{
Object[] args = new Object[] { fileName };
bool fileNeedsCheckout = (bool) serviceType.InvokeMember(
"DoesFileNeedCheckout",
BindingFlags.Default | BindingFlags.InvokeMethod,
null,
serviceInstance,
args, CultureInfo.InvariantCulture
);
if(fileNeedsCheckout)
{
serviceType.InvokeMember(
"CheckoutFile",
BindingFlags.Default | BindingFlags.InvokeMethod,
null,
serviceInstance,
args, CultureInfo.InvariantCulture
);
}
}
finally
{
serviceType.InvokeMember(
"Dispose",
BindingFlags.Default | BindingFlags.InvokeMethod,
null,
serviceInstance,
new Object[] {}, CultureInfo.InvariantCulture
);
serviceInstance = null;
}
}
// Ideally we would refactor the rest of the common code in the ADF/PO/DFE
// dialogs into a separate manager object.
internal static StringCollection GetDuplicateChoiceTreeNodes(ICollection treeNodes)
{
HybridDictionary visitedChoices = new HybridDictionary();
StringCollection duplicateChoices = new StringCollection();
foreach(ChoiceTreeNode node in treeNodes)
{
String key = ChoiceToUniqueIdentifier(node.Name, node.Argument);
if(visitedChoices[key] == null)
{
visitedChoices[key] = 1;
}
else
{
if((int)visitedChoices[key] == 1)
{
duplicateChoices.Add(key);
}
visitedChoices[key] = ((int)visitedChoices[key]) + 1;
}
}
return duplicateChoices;
}
}
}

View File

@@ -0,0 +1,356 @@
//------------------------------------------------------------------------------
// <copyright file="EditableTreeList.cs" company="Microsoft">
// Copyright (c) Microsoft Corporation. All rights reserved.
// </copyright>
//------------------------------------------------------------------------------
namespace System.Web.UI.Design.MobileControls.Util
{
using System;
using System.Diagnostics;
using System.Drawing;
using System.ComponentModel;
using System.Globalization;
using System.Windows.Forms;
using System.Web.UI.Design.MobileControls;
[
ToolboxItem(false),
System.Security.Permissions.SecurityPermission(System.Security.Permissions.SecurityAction.Demand,
Flags=System.Security.Permissions.SecurityPermissionFlag.UnmanagedCode)
]
[Obsolete("The System.Web.Mobile.dll assembly has been deprecated and should no longer be used. For information about how to develop ASP.NET mobile applications, see http://go.microsoft.com/fwlink/?LinkId=157231.")]
internal class EditableTreeList : Panel
{
private const String _assertMsgNullNodeSelected =
"Caller is responsible for ensuring a TreeNode is selected. "
+ "Modified TreeViewNode without calling UpdateButtonsEnabling()?";
private const String _assertMsgOutOfBounds =
"Caller is responsible for ensuring this action does not move the "
+ "selected TreeViewNode out of bounds. "
+ "Modified TvList without calling UpdateButtonsEnabling()?";
internal TreeNode LastNodeChanged = null;
internal TreeNode EditCandidateNode = null;
internal EventHandler RemoveHandler;
private bool _caseSensitive;
internal System.Windows.Forms.Button BtnAdd;
internal System.Windows.Forms.Button BtnRemove;
internal System.Windows.Forms.Button BtnDown;
internal System.Windows.Forms.Button BtnUp;
internal System.Windows.Forms.TreeView TvList;
internal System.Windows.Forms.Label LblTitle;
internal System.Windows.Forms.ContextMenu CntxtMenu;
internal System.Windows.Forms.MenuItem CntxtMenuItem;
internal EditableTreeList() : this(true, true, 16)
{
}
internal EditableTreeList(bool showAddButton, bool caseSensitive, int Y)
{
this.TvList = new System.Windows.Forms.TreeView();
this.BtnAdd = new System.Windows.Forms.Button();
this.BtnDown = new System.Windows.Forms.Button();
this.LblTitle = new System.Windows.Forms.Label();
this.BtnUp = new System.Windows.Forms.Button();
this.BtnRemove = new System.Windows.Forms.Button();
this.CntxtMenuItem = new System.Windows.Forms.MenuItem();
this.CntxtMenu = new System.Windows.Forms.ContextMenu();
LblTitle.Size = new System.Drawing.Size(210, 16);
LblTitle.Anchor = AnchorStyles.Top | AnchorStyles.Left | AnchorStyles.Right;;
TvList.Location = new System.Drawing.Point(0, 16);
TvList.Size = new System.Drawing.Size(178, 148);
TvList.ForeColor = System.Drawing.SystemColors.WindowText;
TvList.Anchor = AnchorStyles.Top
| AnchorStyles.Bottom
| AnchorStyles.Left
| AnchorStyles.Right;
TvList.LabelEdit = true;
TvList.ShowPlusMinus = false;
TvList.HideSelection = false;
TvList.Indent = 15;
TvList.ShowRootLines = false;
TvList.ShowLines = false;
TvList.ContextMenu = CntxtMenu;
BtnUp.AccessibleName = SR.GetString(SR.EditableTreeList_MoveUpName);
BtnUp.AccessibleDescription = SR.GetString(SR.EditableTreeList_MoveUpDescription);
BtnUp.Name = SR.GetString(SR.EditableTreeList_MoveUpName);
BtnUp.Location = new System.Drawing.Point(182, 16);
BtnUp.Size = new System.Drawing.Size(28, 27);
BtnUp.Anchor = AnchorStyles.Top | AnchorStyles.Right;;
BtnDown.AccessibleName = SR.GetString(SR.EditableTreeList_MoveDownName);
BtnDown.AccessibleDescription = SR.GetString(SR.EditableTreeList_MoveDownDescription);
BtnDown.Name = SR.GetString(SR.EditableTreeList_MoveDownName);
BtnDown.Location = new System.Drawing.Point(182, 48);
BtnDown.Size = new System.Drawing.Size(28, 27);
BtnDown.Anchor = AnchorStyles.Top | AnchorStyles.Right;
BtnRemove.AccessibleName = SR.GetString(SR.EditableTreeList_DeleteName);
BtnRemove.AccessibleDescription = SR.GetString(SR.EditableTreeList_DeleteDescription);
BtnRemove.Name = SR.GetString(SR.EditableTreeList_DeleteName);
BtnRemove.Location = new System.Drawing.Point(182, 136);
BtnRemove.Size = new System.Drawing.Size(28, 27);
BtnRemove.Anchor = AnchorStyles.Bottom | AnchorStyles.Right;
BtnAdd.AccessibleName = SR.GetString(SR.EditableTreeList_AddName);
BtnAdd.AccessibleDescription = SR.GetString(SR.EditableTreeList_AddDescription);
BtnAdd.Name = SR.GetString(SR.EditableTreeList_AddName);
BtnAdd.Location = new System.Drawing.Point(0, 168);
BtnAdd.Size = new System.Drawing.Size(178, 25);
BtnAdd.Anchor = AnchorStyles.Bottom | AnchorStyles.Left | AnchorStyles.Right;
CntxtMenuItem.Text = SR.GetString(SR.EditableTreeList_Rename);
CntxtMenu.MenuItems.Add(CntxtMenuItem);
this.Location = new System.Drawing.Point(8, Y);
this.Size = new System.Drawing.Size(210, 196);
this.Controls.Add(LblTitle);
this.Controls.Add(TvList);
this.Controls.Add(BtnUp);
this.Controls.Add(BtnDown);
this.Controls.Add(BtnRemove);
this.Controls.Add(BtnAdd);
BtnDown.Image = GenericUI.SortDownIcon;
BtnUp.Image = GenericUI.SortUpIcon;
BtnRemove.Image = GenericUI.DeleteIcon;
BtnUp.Click += new EventHandler(MoveSelectedItemUp);
BtnDown.Click += new EventHandler(MoveSelectedItemDown);
RemoveHandler = new EventHandler(OnRemove);
BtnRemove.Click += RemoveHandler;
TvList.AfterSelect += new TreeViewEventHandler(OnListSelect);
TvList.KeyDown += new KeyEventHandler(OnKeyDown);
TvList.MouseUp += new MouseEventHandler(OnListMouseUp);
TvList.MouseDown += new MouseEventHandler(OnListMouseDown);
CntxtMenu.Popup += new EventHandler(OnPopup);
CntxtMenuItem.Click += new EventHandler(OnContextMenuItemClick);
UpdateButtonsEnabling();
if(!showAddButton)
{
// stretch UI to occupy space where add button was.
BtnAdd.Visible = false;
int offset = 4 + BtnAdd.Height;
TvList.Height += offset;
BtnRemove.Top += offset;
}
_caseSensitive = caseSensitive;
}
////////////////////////////////////////////////////////////////////////
// End Windes Generated
////////////////////////////////////////////////////////////////////////
internal int SelectedIndex
{
get
{
TreeNode selectedNode = TvList.SelectedNode;
if(selectedNode != null)
{
return selectedNode.Index;
}
else
{
return -1;
}
}
}
internal TreeNode SelectedNode
{
get
{
return TvList.SelectedNode;
}
}
private TreeNode SelectedNodeChecked
{
get
{
TreeNode node = TvList.SelectedNode;
Debug.Assert(
node != null,
_assertMsgNullNodeSelected
);
return node;
}
}
private void MoveSelectedNode(int direction)
{
Debug.Assert(direction == 1 || direction == -1);
LastNodeChanged = TvList.SelectedNode;
Debug.Assert(
LastNodeChanged != null,
_assertMsgNullNodeSelected
);
int index = LastNodeChanged.Index;
Debug.Assert(
(index + direction >= 0)
&& ((index + direction) < TvList.Nodes.Count),
_assertMsgOutOfBounds
);
TvList.Nodes.RemoveAt(index);
TvList.Nodes.Insert(index + direction, LastNodeChanged);
TvList.SelectedNode = LastNodeChanged;
}
internal void MoveSelectedItemUp(Object sender, EventArgs e)
{
MoveSelectedNode(-1);
UpdateButtonsEnabling();
}
internal void MoveSelectedItemDown(Object sender, EventArgs e)
{
MoveSelectedNode(1);
UpdateButtonsEnabling();
}
internal void RemoveSelectedItem()
{
LastNodeChanged = SelectedNodeChecked;
TvList.Nodes.Remove(LastNodeChanged);
UpdateButtonsEnabling();
}
private void OnKeyDown(Object sender, KeyEventArgs e)
{
switch(e.KeyData)
{
case Keys.F2:
{
TreeNode selectedNode = TvList.SelectedNode;
if(selectedNode != null)
{
selectedNode.BeginEdit();
}
break;
}
case (Keys.Control | Keys.Home):
{
if(TvList.Nodes.Count > 0)
{
TvList.SelectedNode = TvList.Nodes[0];
}
break;
}
case (Keys.Control | Keys.End):
{
int numNodes = TvList.Nodes.Count;
if(numNodes > 0)
{
TvList.SelectedNode = TvList.Nodes[numNodes - 1];
}
break;
}
}
}
private void OnRemove(Object sender, EventArgs e)
{
RemoveSelectedItem();
}
private void OnListSelect(Object sender, TreeViewEventArgs e)
{
UpdateButtonsEnabling();
}
private void OnListMouseUp(Object sender, MouseEventArgs e)
{
EditCandidateNode= null;
if (e.Button == MouseButtons.Right)
{
EditCandidateNode = (TreeNode)TvList.GetNodeAt (e.X, e.Y);
}
}
private void OnListMouseDown(Object sender, MouseEventArgs e)
{
EditCandidateNode = null;
if (e.Button == MouseButtons.Right)
{
EditCandidateNode = (TreeNode)TvList.GetNodeAt (e.X, e.Y);
}
}
private void OnPopup(Object sender, EventArgs e)
{
CntxtMenuItem.Enabled = (EditCandidateNode != null ||
TvList.SelectedNode != null);
}
private void OnContextMenuItemClick(Object sender, EventArgs e)
{
if(EditCandidateNode == null)
{
// context menu key pressed
if (TvList.SelectedNode!=null)
{
TvList.SelectedNode.BeginEdit();
}
}
else
{
// right mouse-click
EditCandidateNode.BeginEdit();
}
EditCandidateNode = null;
}
internal String GetUniqueLabel(String label)
{
int index = 1;
String uniqueLabel = label + index;
while(LabelExists(uniqueLabel))
{
uniqueLabel = label + (++index);
}
return uniqueLabel;
}
internal bool LabelExists(String label)
{
foreach(TreeNode node in TvList.Nodes)
{
if(String.Compare(node.Text, label, ((!_caseSensitive) ? StringComparison.OrdinalIgnoreCase : StringComparison.Ordinal)) == 0)
{
return true;
}
}
return false;
}
internal void UpdateButtonsEnabling()
{
int selectedIndex = SelectedIndex;
bool anItemIsSelected = (selectedIndex >= 0);
BtnRemove.Enabled = anItemIsSelected;
if (anItemIsSelected)
{
BtnUp.Enabled = (selectedIndex > 0);
BtnDown.Enabled = (selectedIndex < TvList.Nodes.Count - 1);
}
else
{
BtnUp.Enabled = false;
BtnDown.Enabled = false;
}
}
}
}

View File

@@ -0,0 +1,55 @@
//------------------------------------------------------------------------------
// <copyright file="FileReader.cs" company="Microsoft">
// Copyright (c) Microsoft Corporation. All rights reserved.
// </copyright>
//------------------------------------------------------------------------------
namespace System.Web.UI.Design.MobileControls.Util
{
using System;
using System.Diagnostics;
using System.Net;
using System.IO;
[
System.Security.Permissions.SecurityPermission(System.Security.Permissions.SecurityAction.Demand,
Flags=System.Security.Permissions.SecurityPermissionFlag.UnmanagedCode)
]
[Obsolete("The System.Web.Mobile.dll assembly has been deprecated and should no longer be used. For information about how to develop ASP.NET mobile applications, see http://go.microsoft.com/fwlink/?LinkId=157231.")]
internal class FileReader
{
// Helper class should not be instantiated.
private FileReader() {
}
/// <summary>
/// This method reads a file specified by a uri and returns it
/// as a byte array. If the file is located on the local file
/// system, a FileStream is used instead of a WebRequest.
/// </summary>
internal static Byte[] Read(Uri uri)
{
int length;
Stream stream;
Byte[] buffer = null;
try
{
WebRequest request = WebRequest.Create(uri);
WebResponse response = request.GetResponse();
length = (int) response.ContentLength;
stream = response.GetResponseStream();
buffer = new Byte[length];
stream.Read(buffer, 0, length);
stream.Close();
}
catch(Exception e)
{
Debug.Fail("FileReader - Unable to read url '"
+ uri.ToString() + ":\r\n" + e.ToString());
return null;
}
return buffer;
}
}
}

View File

@@ -0,0 +1,207 @@
//------------------------------------------------------------------------------
// <copyright file="GenericUI.cs" company="Microsoft">
// Copyright (c) Microsoft Corporation. All rights reserved.
// </copyright>
//------------------------------------------------------------------------------
namespace System.Web.UI.Design.MobileControls.Util
{
using System;
using System.Collections;
using System.ComponentModel;
using System.Drawing;
using System.Diagnostics;
using System.Windows.Forms;
using System.Windows.Forms.Design;
using System.Text;
[
System.Security.Permissions.SecurityPermission(System.Security.Permissions.SecurityAction.Demand,
Flags=System.Security.Permissions.SecurityPermissionFlag.UnmanagedCode)
]
[Obsolete("The System.Web.Mobile.dll assembly has been deprecated and should no longer be used. For information about how to develop ASP.NET mobile applications, see http://go.microsoft.com/fwlink/?LinkId=157231.")]
internal class GenericUI
{
// Internal type should not be instantiated.
private GenericUI() {
}
internal static readonly Bitmap SortDownIcon =
new Icon(typeof(MobileControlDesigner), "SortDown.ico").ToBitmap();
internal static readonly Bitmap SortUpIcon =
new Icon(typeof(MobileControlDesigner), "SortUp.ico").ToBitmap();
internal static readonly Bitmap DeleteIcon =
new Icon(typeof(MobileControlDesigner), "Delete.ico").ToBitmap();
internal static readonly Bitmap ErrorIcon =
new Icon(typeof(MobileContainerDesigner), "Error.ico").ToBitmap();
internal static readonly Bitmap InfoIcon =
new Icon(typeof(MobileContainerDesigner), "Info.ico").ToBitmap();
internal static void InitDialog(
Form dialog,
ISite site
) {
dialog.FormBorderStyle = FormBorderStyle.FixedDialog;
dialog.Icon = null;
dialog.MaximizeBox = false;
dialog.MinimizeBox = false;
dialog.ShowInTaskbar = false;
dialog.StartPosition = FormStartPosition.CenterParent;
dialog.AutoScaleBaseSize = new Size(5, 14);
dialog.Font = GetVS7Font(site);
}
internal static Font GetVS7Font(ISite site)
{
System.Drawing.Font vsfont = Control.DefaultFont;
if (site != null)
{
IUIService uiService = (IUIService) site.GetService(
typeof(IUIService)
);
if (uiService != null)
{
vsfont = (Font) uiService.Styles["DialogFont"];
}
}
return vsfont;
}
// This version of InitDialog() handles merged UIs
internal static int InitDialog(
Form dialog,
IDeviceSpecificDesigner designer,
int mergingContext
) {
InitDialog(dialog, designer.UnderlyingControl.Site);
int tabOffset = 0;
designer.InitHeader(mergingContext);
Control header = designer.Header;
if (header != null)
{
// (6, 5) = Windows standard positioning
header.Location = new Point(6, 5);
dialog.Controls.Add(header);
// +6 = 6px space between header and first control
dialog.Height += header.Height + 6;
tabOffset = GenericUI.GetMaxContainedTabIndex(header);
// Changing the header width is going to magically
// cause everything to be repositioned vertically
// -10 = 5px padding on each side of the client area
header.Width = dialog.ClientSize.Width - 10;
}
return tabOffset;
}
internal static int GetMaxContainedTabIndex(Control control)
{
int maxTabIndex = control.TabIndex;
foreach(Control child in control.Controls)
{
int maxChildTabIndex = GetMaxContainedTabIndex(child);
if(maxChildTabIndex > maxTabIndex)
{
maxTabIndex = maxChildTabIndex;
}
}
return maxTabIndex;
}
internal static void ShowErrorMessage(String title, String message)
{
RTLAwareMessageBox.Show(
null,
message,
title,
MessageBoxButtons.OK,
MessageBoxIcon.Error,
MessageBoxDefaultButton.Button1,
0
);
}
internal static String BuildCommaDelimitedList(ICollection stringList)
{
StringBuilder delimitedString = new StringBuilder();
foreach (String str in stringList)
{
if(delimitedString.Length > 0)
{
delimitedString.Append(", ");
}
delimitedString.Append(str);
}
return delimitedString.ToString();
}
internal static void ShowWarningMessage(String title, String message)
{
RTLAwareMessageBox.Show(
null,
message,
title,
MessageBoxButtons.OK,
MessageBoxIcon.Exclamation,
MessageBoxDefaultButton.Button1,
0
);
}
internal static bool ConfirmYesNo(String title, String message)
{
DialogResult result = RTLAwareMessageBox.Show(
null,
message,
title,
MessageBoxButtons.YesNo,
MessageBoxIcon.Exclamation,
MessageBoxDefaultButton.Button1,
0
);
return result == DialogResult.Yes;
}
}
// Copied from ndp\fx\src\Designer\[....]\System\[....]\Design\RTLAwareMessageBox.cs
[Obsolete("The System.Web.Mobile.dll assembly has been deprecated and should no longer be used. For information about how to develop ASP.NET mobile applications, see http://go.microsoft.com/fwlink/?LinkId=157231.")]
internal sealed class RTLAwareMessageBox {
// Private helper class shouldn't be instantiated.
private RTLAwareMessageBox() {
}
/// <include file='doc\MessageBox.uex' path='docs/doc[@for="MessageBox.Show6"]/*' />
/// <devdoc>
/// <para>
/// Displays a message box with specified text, caption, and style.
/// Makes the dialog RTL if the resources for this dll have been localized to a RTL language.
/// </para>
/// </devdoc>
public static DialogResult Show(IWin32Window owner, string text, string caption, MessageBoxButtons buttons, MessageBoxIcon icon,
MessageBoxDefaultButton defaultButton, MessageBoxOptions options) {
if (RTLAwareMessageBox.IsRTLResources) {
options |= (MessageBoxOptions.RightAlign | MessageBoxOptions.RtlReading);
}
return MessageBox.Show(owner, text, caption, buttons, icon, defaultButton, options);
}
/// <devdoc>
/// Tells whether the current resources for this dll have been
/// localized for a RTL language.
/// </devdoc>
public static bool IsRTLResources {
get {
// Set RightToLeft mode based on resource file
string rtlText = SR.GetString(SR.RTL);
return !String.Equals(rtlText, "RTL_False", StringComparison.Ordinal);
}
}
}
}

View File

@@ -0,0 +1,57 @@
//------------------------------------------------------------------------------
// <copyright file="GroupLabel.cs" company="Microsoft">
// Copyright (c) Microsoft Corporation. All rights reserved.
// </copyright>
//------------------------------------------------------------------------------
namespace System.Web.UI.Design.MobileControls.Util
{
using System;
using System.Diagnostics;
using System.Drawing;
using System.Runtime.Serialization.Formatters;
using System.Windows.Forms;
[
System.Security.Permissions.SecurityPermission(System.Security.Permissions.SecurityAction.Demand,
Flags=System.Security.Permissions.SecurityPermissionFlag.UnmanagedCode)
]
[Obsolete("The System.Web.Mobile.dll assembly has been deprecated and should no longer be used. For information about how to develop ASP.NET mobile applications, see http://go.microsoft.com/fwlink/?LinkId=157231.")]
internal sealed class GroupLabel : Label
{
/// <summary>
/// Creates a new GroupLabel
/// </summary>
internal GroupLabel() : base()
{
SetStyle(ControlStyles.UserPaint, true);
}
/// <summary>
/// Custom UI is painted here
/// </summary>
protected override void OnPaint(PaintEventArgs e)
{
Graphics g = e.Graphics;
Rectangle r = ClientRectangle;
string text = Text;
Brush foreBrush = new SolidBrush(ForeColor);
g.DrawString(text, Font, foreBrush, 0, 0);
foreBrush.Dispose();
int etchLeft = r.X;
if (text.Length != 0)
{
Size sz = Size.Ceiling(g.MeasureString(text, Font));
etchLeft += 6 + sz.Width;
}
int etchTop = r.Height / 2;
g.DrawLine(SystemPens.ControlDark, etchLeft, etchTop, r.Width, etchTop);
etchTop++;
g.DrawLine(SystemPens.ControlLightLight, etchLeft, etchTop, r.Width, etchTop);
}
}
}

View File

@@ -0,0 +1,65 @@
//------------------------------------------------------------------------------
// <copyright file="HeaderLabel.cs" company="Microsoft">
// Copyright (c) Microsoft Corporation. All rights reserved.
// </copyright>
//------------------------------------------------------------------------------
namespace System.Web.UI.Design.MobileControls.Util
{
using System;
using System.Diagnostics;
using System.Drawing;
using System.Windows.Forms;
[
System.Security.Permissions.SecurityPermission(System.Security.Permissions.SecurityAction.Demand,
Flags=System.Security.Permissions.SecurityPermissionFlag.UnmanagedCode)
]
[Obsolete("The System.Web.Mobile.dll assembly has been deprecated and should no longer be used. For information about how to develop ASP.NET mobile applications, see http://go.microsoft.com/fwlink/?LinkId=157231.")]
internal class HeaderLabel : RichTextBox
{
private String _text;
internal HeaderLabel()
{
BackColor = SystemColors.Control;
BorderStyle = BorderStyle.None;
WordWrap = true;
ReadOnly = true;
TabStop = false;
ScrollBars = RichTextBoxScrollBars.None;
VisibleChanged += new EventHandler(OnVisibleChanged);
}
protected override void OnContentsResized(ContentsResizedEventArgs e)
{
HeaderPanel headerPanel = Parent as HeaderPanel;
Debug.Assert(headerPanel != null,
"HeaderLabel should be placed inside of a HeaderPanel.");
headerPanel.RequestNewHeight(this, e.NewRectangle.Height);
base.OnContentsResized(e);
}
public override String Text
{
get
{
return _text;
}
set
{
_text = value;
}
}
private void OnVisibleChanged(Object sender, EventArgs e)
{
if(Visible && _text != base.Text)
{
base.Text = _text;
}
}
}
}

View File

@@ -0,0 +1,85 @@
//------------------------------------------------------------------------------
// <copyright file="HeaderPanel.cs" company="Microsoft">
// Copyright (c) Microsoft Corporation. All rights reserved.
// </copyright>
//------------------------------------------------------------------------------
namespace System.Web.UI.Design.MobileControls.Util
{
using System;
using System.Diagnostics;
using System.Drawing;
using System.Windows.Forms;
[
System.Security.Permissions.SecurityPermission(System.Security.Permissions.SecurityAction.Demand,
Flags=System.Security.Permissions.SecurityPermissionFlag.UnmanagedCode)
]
[Obsolete("The System.Web.Mobile.dll assembly has been deprecated and should no longer be used. For information about how to develop ASP.NET mobile applications, see http://go.microsoft.com/fwlink/?LinkId=157231.")]
internal class HeaderPanel : Panel
{
private int _recursionCount = 0;
internal void RequestNewHeight(HeaderLabel header, int height)
{
int offset = height - header.Height;
try
{
// This is a workaround for a RTB issue that causes their
// algorithm to ---- up if OnContentsResize recurses. (Now
// that HeaderLabel does not resize the text untill after
// autoscaling, we do not seem to hit this, but just in case).
//
// On the first call the RTB guesses its best dimensions
// for the given text. We correct the Width which may cause
// a second recursive call to adjust the height.
if(_recursionCount < 2)
{
_recursionCount++;
header.Height = height;
//
foreach(Control child in Controls)
{
if(child.Top > header.Top)
{
child.Top += offset;
}
}
for(
Control controlIterator = this;
controlIterator != null;
controlIterator = controlIterator.Parent
) {
controlIterator.Height += offset;
}
}
else
{
Debug.Assert(offset == 0,
"On 3rd recursive call offset is not yet stabalized."
);
}
}
finally
{
_recursionCount = 0;
}
}
protected override void OnSizeChanged(EventArgs e)
{
foreach(Control child in Controls)
{
if(child is HeaderLabel)
{
child.Width = Width;
}
}
base.OnSizeChanged(e);
}
}
}

View File

@@ -0,0 +1,154 @@
//------------------------------------------------------------------------------
// <copyright file="ImageCreator.cs" company="Microsoft">
// Copyright (c) Microsoft Corporation. All rights reserved.
// </copyright>
//------------------------------------------------------------------------------
namespace System.Web.UI.Design.MobileControls.Util
{
using System;
using System.ComponentModel;
using System.Diagnostics;
using System.Drawing;
using System.IO;
[
System.Security.Permissions.SecurityPermission(System.Security.Permissions.SecurityAction.Demand,
Flags=System.Security.Permissions.SecurityPermissionFlag.UnmanagedCode)
]
[Obsolete("The System.Web.Mobile.dll assembly has been deprecated and should no longer be used. For information about how to develop ASP.NET mobile applications, see http://go.microsoft.com/fwlink/?LinkId=157231.")]
internal sealed class ImageCreator
{
const String _fontFamily = "Tahoma"; // default font used for the
// title and error message
private static int GetHeight(
String text,
Font font,
int width
) {
// THIS----S: I need a bitmap to get a graphics object to measure
// the string, but I can not create the bitmap I intend to return
// until I know how big it needs to be...
using(Bitmap bmp = new Bitmap(1,1))
{
using(Graphics g = Graphics.FromImage(bmp))
{
SizeF size = new SizeF(width, 0);
size = g.MeasureString(text, font, size);
return (int) (size.Height + 1);
}} // using bmp, g
}
internal static void CreateBackgroundImage(
ref TemporaryBitmapFile bmpFile,
String controlID,
String title,
String message,
bool infoMode,
int controlWidth
) {
// Really, anything this small is not practically going to
// show readable text. Truncate instead of trying to display
// the string vertically.
if(controlWidth < 75)
{
controlWidth = 75;
}
Bitmap errorIcon = infoMode? GenericUI.InfoIcon : GenericUI.ErrorIcon;
bool showMessage = message != null && message.Length != 0;
bool showTitle = (title != null && title.Length != 0)
|| (controlID != null && controlID.Length != 0);
Debug.Assert(showMessage || showTitle);
//
using(
Font normalFont = new Font(_fontFamily, 8, FontStyle.Regular),
boldFont = new Font(normalFont.FontFamily, 8, FontStyle.Bold)
) {
using(
Brush controlTextBrush = new SolidBrush(SystemColors.ControlText),
controlDarkBrush = new SolidBrush(SystemColors.ControlDark),
controlBrush = new SolidBrush(SystemColors.Control),
windowBrush = new SolidBrush(SystemColors.Window)
) {
using(
Pen controlDarkPen = new Pen(SystemColors.ControlDark),
windowPen = new Pen(SystemColors.Window)
) {
int barHeight = 0;
if(showTitle)
{
// We do not measure the height of the real title because
// we inted to truncate rather than wrap.
barHeight = GetHeight(
"'",
normalFont,
(controlWidth - 30)
) + 6;
}
int messageHeight = 0;
if(showMessage)
{
int textHeight = GetHeight(
message,
normalFont,
(controlWidth - 30)
);
messageHeight = (textHeight < (errorIcon.Height + 6)) ?
(errorIcon.Height + 6) : textHeight + 3;
}
int width = 500; // normally only 300px visible.
int height = barHeight + messageHeight;
Bitmap bitmap = new Bitmap(width, height);
using(Graphics g = Graphics.FromImage(bitmap))
{
if (showTitle)
{
// The rectangle area
g.FillRectangle(controlBrush, 0, 0, width, barHeight);
// The gray line below the controlID
g.DrawLine(controlDarkPen, 0, barHeight - 1, width, barHeight - 1);
// Draw the text "controlTypeName - controlID"
g.DrawString(controlID, boldFont, controlTextBrush, 2, 2);
if(title != null && title.Length > 0)
{
int strPelLen = (int) g.MeasureString(controlID, boldFont).Width;
g.DrawString(" - " + title, normalFont, controlTextBrush, 4 + strPelLen, 2);
}
}
if (showMessage)
{
// The transparent line between controlID and errormessage.
g.DrawLine(windowPen, 0, barHeight, width, barHeight);
// The message rectangle area
g.FillRectangle(controlDarkBrush, 0, barHeight + 1, width, messageHeight - 1);
// Draw the message text
g.DrawString(message, normalFont, windowBrush,
new RectangleF(20, barHeight + 1, controlWidth - 30, messageHeight - 1));
// Draw the icon
g.DrawImage(errorIcon, 2, barHeight + 3);
}
if(bmpFile == null)
{
bmpFile = new TemporaryBitmapFile(bitmap);
}
else
{
bmpFile.UnderlyingBitmap = bitmap;
}
} // using g
}}} // using Fonts, Brushes, and Pens
}
}
}

View File

@@ -0,0 +1,340 @@
//------------------------------------------------------------------------------
// <copyright file="InterchangeableLists.cs" company="Microsoft">
// Copyright (c) Microsoft Corporation. All rights reserved.
// </copyright>
//------------------------------------------------------------------------------
#if UNUSED_CODE
namespace System.Web.UI.Design.MobileControls.Util
{
using System;
using System.Collections;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Diagnostics;
using System.Web.UI.Design.MobileControls;
using System.Windows.Forms;
[
ToolboxItem(false),
System.Security.Permissions.SecurityPermission(System.Security.Permissions.SecurityAction.Demand,
Flags=System.Security.Permissions.SecurityPermissionFlag.UnmanagedCode)
]
internal sealed class InterchangeableLists : System.Windows.Forms.Panel
{
private System.Windows.Forms.Button _removeButton;
private System.Windows.Forms.Button _addButton;
private System.Windows.Forms.Button _upButton;
private System.Windows.Forms.TreeView _availableList;
private System.Windows.Forms.Label _availableFieldLabel;
private System.Windows.Forms.TreeView _selectedList;
private System.Windows.Forms.Button _downButton;
private System.Windows.Forms.Label _selectedFieldLabel;
private Hashtable _eventTable;
/// <summary>
/// Required designer variable.
/// </summary>
private static readonly Object _componentChangedEvent = new Object();
internal InterchangeableLists()
{
// This call is required by the Windows.Forms Form Designer.
InitializeComponent();
//
_downButton.Image = GenericUI.SortDownIcon;
_upButton.Image = GenericUI.SortUpIcon;
UpdateButtonEnabling();
this._eventTable = new Hashtable();
}
internal void SetTitles(
String availableListTitle,
String selectedListTitle)
{
this._selectedFieldLabel.Text = selectedListTitle;
this._availableFieldLabel.Text = availableListTitle;
}
internal void AddToAvailableList(Object obj)
{
AddItem(_availableList, new TreeNode(obj.ToString()));
}
internal void AddToSelectedList(Object obj)
{
AddItem(_selectedList, new TreeNode(obj.ToString()));
}
internal void Initialize()
{
if (_availableList.Nodes.Count > 0)
{
_availableList.SelectedNode = _availableList.Nodes[0];
}
if (_selectedList.Nodes.Count > 0)
{
_selectedList.SelectedNode = _selectedList.Nodes[0];
}
}
internal EventHandler OnComponentChanged
{
get
{
return (EventHandler)_eventTable[_componentChangedEvent];
}
set
{
_eventTable[_componentChangedEvent] = value;
}
}
private void NotifyChangeEvent()
{
EventHandler handler = (EventHandler)_eventTable[_componentChangedEvent];
if (handler != null)
{
handler(this, EventArgs.Empty);
}
}
internal void Clear()
{
_availableList.Nodes.Clear();
_selectedList.Nodes.Clear();
}
internal ICollection GetSelectedItems()
{
ArrayList list = new ArrayList();
foreach (TreeNode node in _selectedList.Nodes)
{
list.Add(node.Text);
}
return list;
}
/// <summary>
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
/// </summary>
private void InitializeComponent()
{
this._removeButton = new System.Windows.Forms.Button();
this._selectedFieldLabel = new System.Windows.Forms.Label();
this._addButton = new System.Windows.Forms.Button();
this._selectedList = new System.Windows.Forms.TreeView();
this._availableList = new System.Windows.Forms.TreeView();
this._availableFieldLabel = new System.Windows.Forms.Label();
this._upButton = new System.Windows.Forms.Button();
this._downButton = new System.Windows.Forms.Button();
this._removeButton.Location = new System.Drawing.Point(166, 69);
this._removeButton.Size = new System.Drawing.Size(32, 25);
this._removeButton.TabIndex = 4;
this._removeButton.Text = "<";
this._removeButton.Click += new System.EventHandler(this.RemoveNode);
this._removeButton.AccessibleName = SR.GetString(SR.EditableTreeList_DeleteName);
this._removeButton.AccessibleDescription = SR.GetString(SR.EditableTreeList_DeleteDescription);
this._removeButton.Name = SR.GetString(SR.EditableTreeList_DeleteName);
this._selectedFieldLabel.Location = new System.Drawing.Point(202, 8);
this._selectedFieldLabel.Size = new System.Drawing.Size(164, 16);
this._selectedFieldLabel.TabIndex = 5;
this._addButton.AccessibleName = SR.GetString(SR.EditableTreeList_AddName);
this._addButton.AccessibleDescription = SR.GetString(SR.EditableTreeList_AddDescription);
this._addButton.Name = SR.GetString(SR.EditableTreeList_AddName);
this._addButton.Location = new System.Drawing.Point(166, 40);
this._addButton.Size = new System.Drawing.Size(32, 25);
this._addButton.TabIndex = 3;
this._addButton.Text = ">";
this._addButton.Click += new System.EventHandler(this.AddNode);
this._selectedList.HideSelection = false;
this._selectedList.Indent = 15;
this._selectedList.Location = new System.Drawing.Point(202, 24);
this._selectedList.ShowLines = false;
this._selectedList.ShowPlusMinus = false;
this._selectedList.ShowRootLines = false;
this._selectedList.Size = new System.Drawing.Size(154, 89);
this._selectedList.TabIndex = 6;
this._selectedList.DoubleClick += new System.EventHandler(this.RemoveNode);
this._selectedList.AfterSelect += new System.Windows.Forms.TreeViewEventHandler(this.SelectedList_AfterSelect);
this._availableList.HideSelection = false;
this._availableList.Indent = 15;
this._availableList.Location = new System.Drawing.Point(8, 24);
this._availableList.ShowLines = false;
this._availableList.ShowPlusMinus = false;
this._availableList.ShowRootLines = false;
this._availableList.Size = new System.Drawing.Size(154, 89);
this._availableList.TabIndex = 2;
this._availableList.DoubleClick += new System.EventHandler(this.AddNode);
this._availableList.AfterSelect += new System.Windows.Forms.TreeViewEventHandler(this.AvailableList_AfterSelect);
this._availableFieldLabel.Location = new System.Drawing.Point(8, 8);
this._availableFieldLabel.Size = new System.Drawing.Size(164, 16);
this._availableFieldLabel.TabIndex = 1;
this._upButton.AccessibleName = SR.GetString(SR.EditableTreeList_MoveUpName);
this._upButton.AccessibleDescription = SR.GetString(SR.EditableTreeList_MoveUpDescription);
this._upButton.Name = SR.GetString(SR.EditableTreeList_MoveUpName);
this._upButton.Location = new System.Drawing.Point(360, 24);
this._upButton.Size = new System.Drawing.Size(28, 27);
this._upButton.TabIndex = 7;
this._upButton.Click += new System.EventHandler(this.Up_Click);
this._downButton.AccessibleName = SR.GetString(SR.EditableTreeList_MoveDownName);
this._downButton.AccessibleDescription = SR.GetString(SR.EditableTreeList_MoveDownDescription);
this._downButton.Name = SR.GetString(SR.EditableTreeList_MoveDownName);
this._downButton.Location = new System.Drawing.Point(360, 55);
this._downButton.Size = new System.Drawing.Size(28, 27);
this._downButton.TabIndex = 8;
this._downButton.Click += new System.EventHandler(this.Down_Click);
this.Controls.AddRange(new System.Windows.Forms.Control[] {this._availableFieldLabel,
this._selectedFieldLabel,
this._upButton,
this._downButton,
this._removeButton,
this._selectedList,
this._addButton,
this._availableList});
this.Size = new System.Drawing.Size(396, 119);
}
private void UpdateButtonEnabling()
{
bool anAvailableItemIsSelected =
(_availableList.SelectedNode != null);
bool anSelectedItemIsSelected =
(_selectedList.SelectedNode != null);
_addButton.Enabled = anAvailableItemIsSelected;
_removeButton.Enabled = anSelectedItemIsSelected;
if (anSelectedItemIsSelected)
{
int selectedIndex = _selectedList.SelectedNode.Index;
_upButton.Enabled = (selectedIndex > 0);
_downButton.Enabled =
(selectedIndex < _selectedList.Nodes.Count - 1);
}
else
{
_downButton.Enabled = false;
_upButton.Enabled = false;
}
}
private void AddNode(object sender, System.EventArgs e)
{
TreeNode selectedNode = _availableList.SelectedNode;
if (selectedNode != null)
{
RemoveItem(_availableList, selectedNode);
AddItem(_selectedList, selectedNode);
UpdateButtonEnabling();
NotifyChangeEvent();
}
}
private void RemoveItem(TreeView list, TreeNode node)
{
Debug.Assert (list.Nodes.Contains(node));
int itemCount = list.Nodes.Count;
int selectedIndex = list.SelectedNode.Index;
list.Nodes.Remove(node);
if (selectedIndex < itemCount - 1)
{
list.SelectedNode = list.Nodes[selectedIndex];
}
else if (selectedIndex >= 1)
{
list.SelectedNode = list.Nodes[selectedIndex-1];
}
else
{
Debug.Assert(itemCount == 1);
list.SelectedNode = null;
}
}
private void AddItem(TreeView list, TreeNode node)
{
Debug.Assert(node != null);
list.Nodes.Add(node);
list.SelectedNode = node;
//_selectedList.Select();
}
private void RemoveNode(object sender, System.EventArgs e)
{
TreeNode selectedNode = _selectedList.SelectedNode;
if (selectedNode != null)
{
RemoveItem(_selectedList, selectedNode);
AddItem(_availableList, selectedNode);
UpdateButtonEnabling();
}
//_availableList.Select();
NotifyChangeEvent();
}
private void MoveItem(
int direction /* 1 is up, -1 is down */)
{
Debug.Assert(direction == -1 || direction == 1);
int selectedIndex = _selectedList.SelectedNode.Index;
int newIndex = selectedIndex + direction;
TreeNode node = _selectedList.SelectedNode;
_selectedList.Nodes.RemoveAt(selectedIndex);
_selectedList.Nodes.Insert(newIndex, node);
_selectedList.SelectedNode = node;
}
private void Up_Click(object sender, System.EventArgs e)
{
MoveItem(-1);
UpdateButtonEnabling();
//_selectedList.Select();
NotifyChangeEvent();
}
private void Down_Click(object sender, System.EventArgs e)
{
MoveItem(+1);
UpdateButtonEnabling();
//_selectedList.Select();
NotifyChangeEvent();
}
private void AvailableList_AfterSelect(object sender, System.Windows.Forms.TreeViewEventArgs e)
{
UpdateButtonEnabling();
}
private void SelectedList_AfterSelect(object sender, System.Windows.Forms.TreeViewEventArgs e)
{
UpdateButtonEnabling();
}
}
}
#endif

View File

@@ -0,0 +1,398 @@
//------------------------------------------------------------------------------
// <copyright file="MSHTMLHost.cs" company="Microsoft">
// Copyright (c) Microsoft Corporation. All rights reserved.
// </copyright>
//------------------------------------------------------------------------------
// MSHTMLHost.cs
//
// 12/17/98: Created: [....]
//
namespace System.Web.UI.Design.MobileControls.Util {
using System.Runtime.Serialization.Formatters;
using System.Runtime.InteropServices;
using System.ComponentModel;
using System.Diagnostics;
using System;
using Microsoft.Win32;
using System.Windows.Forms;
/// <include file='doc\MSHTMLHost.uex' path='docs/doc[@for="MSHTMLHost"]/*' />
/// <devdoc>
/// Control that hosts a Trident DocObject.
/// </devdoc>
/// <internalonly/>
//
[System.Security.Permissions.SecurityPermission(System.Security.Permissions.SecurityAction.Demand, Flags=System.Security.Permissions.SecurityPermissionFlag.UnmanagedCode)]
[Obsolete("The System.Web.Mobile.dll assembly has been deprecated and should no longer be used. For information about how to develop ASP.NET mobile applications, see http://go.microsoft.com/fwlink/?LinkId=157231.")]
internal sealed class MSHTMLHost : Control {
private TridentSite tridentSite;
internal MSHTMLHost() : base() {
}
public NativeMethods.IHTMLDocument2 GetDocument() {
Debug.Assert(tridentSite != null,
"Cannot call getDocument before calling createTrident");
return tridentSite.GetDocument();
}
protected override CreateParams CreateParams {
get {
CreateParams cp = base.CreateParams;
cp.ExStyle |= NativeMethods.WS_EX_STATICEDGE;
return cp;
}
}
internal bool CreateTrident() {
Debug.Assert(Handle != IntPtr.Zero,
"MSHTMLHost must first be created before createTrident is called");
try {
tridentSite = new TridentSite(this);
}
catch (Exception e) {
Debug.WriteLine("Exception caught in MSHTMLHost::CreateTrident\n\t" + e.ToString());
return false;
}
return true;
}
internal void ActivateTrident() {
Debug.Assert(tridentSite != null,
"cannot call activateTrident before calling createTrident");
tridentSite.Activate();
}
}
/// <include file='doc\MSHTMLHost.uex' path='docs/doc[@for="TridentSite"]/*' />
/// <devdoc>
/// Implements the client site for Trident DocObject
/// </devdoc>
[ClassInterface(ClassInterfaceType.None)]
[Obsolete("The System.Web.Mobile.dll assembly has been deprecated and should no longer be used. For information about how to develop ASP.NET mobile applications, see http://go.microsoft.com/fwlink/?LinkId=157231.")]
internal class TridentSite : NativeMethods.IOleClientSite, NativeMethods.IOleDocumentSite, NativeMethods.IOleInPlaceSite, NativeMethods.IOleInPlaceFrame, NativeMethods.IDocHostUIHandler {
protected Control parentControl;
protected NativeMethods.IOleDocumentView tridentView;
protected NativeMethods.IOleObject tridentOleObject;
protected NativeMethods.IHTMLDocument2 tridentDocument;
protected EventHandler resizeHandler;
internal TridentSite(Control parent) {
Debug.Assert((parent != null) && (parent.Handle != IntPtr.Zero),
"Invalid control passed in as parent of Trident window");
parentControl = parent;
resizeHandler = new EventHandler(this.OnParentResize);
parentControl.Resize += resizeHandler;
CreateDocument();
}
public NativeMethods.IHTMLDocument2 GetDocument() {
return tridentDocument;
}
internal void Activate() {
ActivateDocument();
}
protected virtual void OnParentResize(object src, EventArgs e) {
if (tridentView != null) {
NativeMethods.COMRECT r = new NativeMethods.COMRECT();
NativeMethods.GetClientRect(parentControl.Handle, r);
tridentView.SetRect(r);
}
}
///////////////////////////////////////////////////////////////////////////
// IOleClientSite Implementation
public virtual void SaveObject() {
}
public virtual object GetMoniker(int dwAssign, int dwWhichMoniker) {
throw new COMException(String.Empty, NativeMethods.E_NOTIMPL);
}
public virtual int GetContainer(out NativeMethods.IOleContainer ppContainer) {
ppContainer = null;
return NativeMethods.E_NOINTERFACE;
}
public virtual void ShowObject() {
}
public virtual void OnShowWindow(int fShow) {
}
public virtual void RequestNewObjectLayout() {
}
///////////////////////////////////////////////////////////////////////////
// IOleDocumentSite Implementation
public virtual int ActivateMe(NativeMethods.IOleDocumentView pViewToActivate) {
Debug.Assert(pViewToActivate != null,
"Expected the view to be non-null");
if (pViewToActivate == null)
return NativeMethods.E_INVALIDARG;
NativeMethods.COMRECT r = new NativeMethods.COMRECT();
NativeMethods.GetClientRect(parentControl.Handle, r);
tridentView = pViewToActivate;
tridentView.SetInPlaceSite((NativeMethods.IOleInPlaceSite)this);
tridentView.UIActivate(1);
tridentView.SetRect(r);
tridentView.Show(1);
return NativeMethods.S_OK;
}
///////////////////////////////////////////////////////////////////////////
// IOleInPlaceSite Implementation
public virtual IntPtr GetWindow() {
return parentControl.Handle;
}
public virtual void ContextSensitiveHelp(int fEnterMode) {
throw new COMException(String.Empty, NativeMethods.E_NOTIMPL);
}
public virtual int CanInPlaceActivate() {
return NativeMethods.S_OK;
}
public virtual void OnInPlaceActivate() {
}
public virtual void OnUIActivate() {
}
public virtual void GetWindowContext(out NativeMethods.IOleInPlaceFrame ppFrame, out NativeMethods.IOleInPlaceUIWindow ppDoc, NativeMethods.COMRECT lprcPosRect, NativeMethods.COMRECT lprcClipRect, NativeMethods.tagOIFI lpFrameInfo) {
ppFrame = (NativeMethods.IOleInPlaceFrame)this;
ppDoc = null;
NativeMethods.GetClientRect(parentControl.Handle, lprcPosRect);
NativeMethods.GetClientRect(parentControl.Handle, lprcClipRect);
lpFrameInfo.cb = System.Runtime.InteropServices.Marshal.SizeOf(typeof(NativeMethods.tagOIFI));
lpFrameInfo.fMDIApp = 0;
lpFrameInfo.hwndFrame = parentControl.Handle;
lpFrameInfo.hAccel = IntPtr.Zero;
lpFrameInfo.cAccelEntries = 0;
}
public virtual int Scroll(NativeMethods.tagSIZE scrollExtant) {
return(NativeMethods.E_NOTIMPL);
}
public virtual void OnUIDeactivate(int fUndoable) {
// NOTE, [....], 7/99: Don't return E_NOTIMPL. Somehow doing nothing and returning S_OK
// fixes trident hosting in Win2000.
}
public virtual void OnInPlaceDeactivate() {
}
public virtual void DiscardUndoState() {
throw new COMException(SR.GetString(SR.MSHTMLHost_Not_Implemented), NativeMethods.E_NOTIMPL);
}
public virtual void DeactivateAndUndo() {
}
public virtual int OnPosRectChange(NativeMethods.COMRECT lprcPosRect) {
return NativeMethods.S_OK;
}
///////////////////////////////////////////////////////////////////////////
// IOleInPlaceFrame Implementation
public virtual void GetBorder(NativeMethods.COMRECT lprectBorder) {
throw new COMException(String.Empty, NativeMethods.E_NOTIMPL);
}
public virtual void RequestBorderSpace(NativeMethods.COMRECT pborderwidths) {
throw new COMException(String.Empty, NativeMethods.E_NOTIMPL);
}
public virtual void SetBorderSpace(NativeMethods.COMRECT pborderwidths) {
throw new COMException(String.Empty, NativeMethods.E_NOTIMPL);
}
public virtual void SetActiveObject(NativeMethods.IOleInPlaceActiveObject pActiveObject, string pszObjName) {
// NOTE, [....], 7/99: Don't return E_NOTIMPL. Somehow doing nothing and returning S_OK
// fixes trident hosting in Win2000.
// throw new COMException(String.Empty, NativeMethods.E_NOTIMPL);
}
public virtual void InsertMenus(IntPtr hmenuShared, object lpMenuWidths) {
throw new COMException(String.Empty, NativeMethods.E_NOTIMPL);
}
public virtual void SetMenu(IntPtr hmenuShared, IntPtr holemenu, IntPtr hwndActiveObject) {
throw new COMException(String.Empty, NativeMethods.E_NOTIMPL);
}
public virtual void RemoveMenus(IntPtr hmenuShared) {
throw new COMException(String.Empty, NativeMethods.E_NOTIMPL);
}
public virtual void SetStatusText(string pszStatusText) {
}
public virtual void EnableModeless(int fEnable) {
}
public virtual int TranslateAccelerator(ref NativeMethods.MSG lpmsg, short wID) {
return NativeMethods.S_FALSE;
}
///////////////////////////////////////////////////////////////////////////
// IDocHostUIHandler Implementation
public virtual int ShowContextMenu(int dwID, NativeMethods.POINT pt, object pcmdtReserved, object pdispReserved) {
return NativeMethods.S_OK;
}
public virtual int GetHostInfo(NativeMethods.DOCHOSTUIINFO info) {
info.dwDoubleClick = NativeMethods.DOCHOSTUIDBLCLICK.DEFAULT;
info.dwFlags = NativeMethods.DOCHOSTUIFLAG.FLAT_SCROLLBAR |
NativeMethods.DOCHOSTUIFLAG.NO3DBORDER |
NativeMethods.DOCHOSTUIFLAG.DIALOG |
NativeMethods.DOCHOSTUIFLAG.DISABLE_SCRIPT_INACTIVE;
return NativeMethods.S_OK;
}
public virtual int EnableModeless(bool fEnable) {
return NativeMethods.S_OK;
}
public virtual int ShowUI(int dwID, NativeMethods.IOleInPlaceActiveObject activeObject, NativeMethods.IOleCommandTarget commandTarget, NativeMethods.IOleInPlaceFrame frame, NativeMethods.IOleInPlaceUIWindow doc) {
return NativeMethods.S_OK;
}
public virtual int HideUI() {
return NativeMethods.S_OK;
}
public virtual int UpdateUI() {
return NativeMethods.S_OK;
}
public virtual int OnDocWindowActivate(bool fActivate) {
return NativeMethods.E_NOTIMPL;
}
public virtual int OnFrameWindowActivate(bool fActivate) {
return NativeMethods.E_NOTIMPL;
}
public virtual int ResizeBorder(NativeMethods.COMRECT rect, NativeMethods.IOleInPlaceUIWindow doc, bool fFrameWindow) {
return NativeMethods.E_NOTIMPL;
}
public virtual int GetOptionKeyPath(string[] pbstrKey, int dw) {
pbstrKey[0] = null;
return NativeMethods.S_OK;
}
public virtual int GetDropTarget(NativeMethods.IOleDropTarget pDropTarget, out NativeMethods.IOleDropTarget ppDropTarget) {
ppDropTarget = null;
return NativeMethods.S_FALSE;
}
public virtual int GetExternal(out object ppDispatch) {
ppDispatch = null;
return NativeMethods.S_OK;
}
public virtual int TranslateAccelerator(ref NativeMethods.MSG msg, ref Guid group, int nCmdID) {
return NativeMethods.S_OK;
}
public virtual int TranslateUrl(int dwTranslate, string strUrlIn, out string pstrUrlOut) {
pstrUrlOut = null;
return NativeMethods.E_NOTIMPL;
}
public virtual int FilterDataObject(NativeMethods.IOleDataObject pDO, out NativeMethods.IOleDataObject ppDORet) {
ppDORet = null;
return NativeMethods.S_OK;
}
///////////////////////////////////////////////////////////////////////////
// Implementation
/// <include file='doc\MSHTMLHost.uex' path='docs/doc[@for="TridentSite.CreateDocument"]/*' />
/// <devdoc>
/// Creates a new instance of mshtml and initializes it as a new document
/// using its IPersistStreamInit.
/// </devdoc>
protected void CreateDocument() {
try {
// Create an instance of Trident
tridentDocument = (NativeMethods.IHTMLDocument2)new NativeMethods.HTMLDocument();
tridentOleObject = (NativeMethods.IOleObject)tridentDocument;
// Initialize its client site
tridentOleObject.SetClientSite((NativeMethods.IOleClientSite)this);
// Initialize it
NativeMethods.IPersistStreamInit psi = (NativeMethods.IPersistStreamInit)tridentDocument;
psi.InitNew();
}
catch (Exception e) {
Debug.Fail(e.ToString());
throw e;
}
}
/// <include file='doc\MSHTMLHost.uex' path='docs/doc[@for="TridentSite.ActivateDocument"]/*' />
/// <devdoc>
/// Activates the mshtml instance
/// </devdoc>
protected void ActivateDocument() {
Debug.Assert(tridentOleObject != null,
"How'd we get here when trident is null!");
try {
NativeMethods.COMRECT r = new NativeMethods.COMRECT();
NativeMethods.GetClientRect(parentControl.Handle, r);
tridentOleObject.DoVerb(NativeMethods.OLEIVERB_UIACTIVATE, IntPtr.Zero, (NativeMethods.IOleClientSite)this, 0, parentControl.Handle, r);
}
catch (Exception e) {
Debug.Fail(e.ToString());
}
}
}
}

View File

@@ -0,0 +1,334 @@
//------------------------------------------------------------------------------
// <copyright file="SimpleParser.cs" company="Microsoft">
// Copyright (c) Microsoft Corporation. All rights reserved.
// </copyright>
//------------------------------------------------------------------------------
using System.Collections;
using System.Globalization;
using System.Text;
using System.Text.RegularExpressions;
using System.Web;
using System.Web.RegularExpressions;
using System.Web.Util;
using System.Web.UI.MobileControls;
namespace System.Web.UI.Design.MobileControls.Util
{
[
System.Security.Permissions.SecurityPermission(System.Security.Permissions.SecurityAction.Demand,
Flags=System.Security.Permissions.SecurityPermissionFlag.UnmanagedCode)
]
[Obsolete("The System.Web.Mobile.dll assembly has been deprecated and should no longer be used. For information about how to develop ASP.NET mobile applications, see http://go.microsoft.com/fwlink/?LinkId=157231.")]
internal class SimpleParser : BaseParser
{
private const int _stackInitialSize = 100;
private static Regex _unclosedTagRegex = null;
private const RegexOptions _options =
RegexOptions.Singleline | RegexOptions.Multiline;
private const String _pattern =
@"\G<(?<tagname>[\w:\.]+)" +
@"(" +
@"\s+(?<attrname>\w[-\w:]*)(" + // Attribute name
@"\s*=\s*""(?<attrval>[^""]*)""|" + // ="bar" attribute value
@"\s*=\s*'(?<attrval>[^']*)'|" + // ='bar' attribute value
@"\s*=\s*(?<attrval><%#.*?%>)|" + // =<%#expr%> attribute value
@"\s*=\s*(?!'|"")(?<attrval>[^\s=/>]*)(?!'|"")|" + // =bar attribute value
@"(?<attrval>\s*?)" + // no attrib value (with no '=')
@")" +
@")*" +
@"\s*(?<empty>)?>";
//@"\s*(?<empty>/)?>";
private static ElementTable _endTagOptionalElement = null;
private readonly static Regex _tagRegex = new TagRegex();
private readonly static Regex _directiveRegex = new DirectiveRegex();
private readonly static Regex _endtagRegex = new EndTagRegex();
private readonly static Regex _aspCodeRegex = new AspCodeRegex();
private readonly static Regex _aspExprRegex = new AspExprRegex();
private readonly static Regex _databindExprRegex = new DatabindExprRegex();
private readonly static Regex _commentRegex = new CommentRegex();
private readonly static Regex _includeRegex = new IncludeRegex();
private readonly static Regex _textRegex = new TextRegex();
// Regexes used in DetectSpecialServerTagError
private readonly static Regex _gtRegex = new GTRegex();
private readonly static Regex _ltRegex = new LTRegex();
private readonly static Regex _serverTagsRegex = new ServerTagsRegex();
private readonly static Regex _runatServerRegex = new RunatServerRegex();
/* Regex patterns
AspCodeRegex : \G<%(?!@)(?<code>.*?)%>
AspExprRegex : \G<%\s*?=(?<code>.*?)?%>
CommentRegex : \G<%--(([^-]*)-)*?-%>
DataBindExprRegex : \G<%#(?<code>.*?)?%>
DirectiveRegex : \G<%\s*@(\s*(?<attrname>\w+(?=\W))(\s*(?<equal>=)\s*"(?<attrval>[^"]*)"|\s*(?<equal>=)\s*'(?<attrval>[^']*)'|\s*(?<equal>=)\s*(?<attrval>[^\s%>]*)|(?<equal>)(?<attrval>\s*?)))*\s*?%>
EndTagRegex : \G</(?<tagname>[\w:\.]+)\s*>
GTRegex : [^%]>
IncludeRegex : \G<!--\s*#(?i:include)\s*(?<pathtype>[\w]+)\s*=\s*["']?(?<filename>[^\"']*?)["']?\s*-->
LTRegex : <
RunATServerRegex : runat\W*server
ServerTagsRegex : <%(?!#)(([^%]*)%)*?>
TagRegex : \G<(?<tagname>[\w:\.]+)(\s+(?<attrname>[-\w]+)(\s*=\s*"(?<attrval>[^"]*)"|\s*=\s*'(?<attrval>[^']*)'|\s*=\s*(?<attrval><%#.*?%>)|\s*=\s*(?<attrval>[^\s=/>]*)|(?<attrval>\s*?)))*\s*(?<empty>/)?>
TextRegex : \G[^<]+
//SimpleDirectiveRegex simpleDirectiveRegex = new SimpleDirectiveRegex();
*/
// static helper type should not be instantiated.
private SimpleParser() {
}
static SimpleParser()
{
_unclosedTagRegex = new Regex(_pattern, _options);
_endTagOptionalElement = new ElementTable();
/* following defnitions from MSDN Online WorkShop
http://msdn.microsoft.com/workshop/c-frame.htm#/workshop/author/default.asp
*/
_endTagOptionalElement.AddRange(
new String[] {
"area", "base", "basefront", "bgsound", "br",
"col", "colgroup", "dd", "dt", "embed", "frame",
"hr", "img", "input", "isindex", "li", "link",
"meta", "option", "p", "param", "rt"
});
}
/// <summary>
/// Simple parsing to check if input fragment is well-formed,
/// HTML elements that do not required end tags (i.e. <BR>)
/// will be ignored by this parser.
/// </summary>
/// <param name="text">
/// text being parsed
/// </param>
internal static bool IsWellFormed(String text)
{
int textPos = 0;
TagStack stack = new TagStack();
for (;;)
{
Match match = null;
// 1: scan for text up to the next tag.
if ((match = _textRegex.Match(text, textPos)).Success)
{
textPos = match.Index + match.Length;
}
// we might be done now
if (textPos == text.Length)
{
while (!stack.IsEmpty())
{
if (!IsEndTagOptional(stack.Pop()))
{
return false;
}
}
return true;
}
// First check if it's a unclosed tag (i.e. <mobile:Form >)
if ((match = _unclosedTagRegex.Match(text, textPos)).Success)
{
String startTag = match.Groups["tagname"].Value;
stack.Push(startTag);
}
// Check to see if it's a tag
else if ((match = _tagRegex.Match(text, textPos)).Success)
{
// skip
}
// Check to see if it's an end tag
else if ((match = _endtagRegex.Match(text, textPos)).Success)
{
String endTag = match.Groups["tagname"].Value;
bool matched = false;
while (!stack.IsEmpty())
{
String startTag = stack.Pop();
if (String.Compare(endTag, startTag, StringComparison.OrdinalIgnoreCase) != 0)
{
if (IsEndTagOptional(startTag))
{
continue;
}
// no match against start tag that requires an end tag
return false;
}
// we found a match here.
matched = true;
break;
}
if (!matched && stack.IsEmpty())
{
return false;
}
}
// Check to see if it's a directive (i.e. <%@ %> block)
else if ((match = _directiveRegex.Match(text, textPos)).Success)
{
// skip
}
// Check to see if it's a server side include
// e.g. <!-- #include file="foo.inc" -->
else if ((match = _includeRegex.Match(text, textPos)).Success)
{
// skip it
}
// Check to see if it's a comment (<%-- --%> block
// e.g. <!-- Blah! -->
else if ((match = _commentRegex.Match(text, textPos)).Success)
{
// skip
}
// Check to see if it's an asp expression block (i.e. <%= %> block)
else if ((match = _aspExprRegex.Match(text, textPos)).Success)
{
// skip
}
// Check to see if it's a databinding expression block (i.e. <%# %> block)
// This does not include <%# %> blocks used as values for
// attributes of server tags.
else if ((match = _databindExprRegex.Match(text, textPos)).Success)
{
// skip
}
// Check to see if it's an asp code block
else if ((match = _aspCodeRegex.Match(text, textPos)).Success)
{
// skip
}
// Did we process the block that started with a '<'?
if (match == null || !match.Success)
{
// Skip the '<'
textPos++;
}
else
{
textPos = match.Index + match.Length;
}
// we might be done now
if (textPos == text.Length)
{
while (!stack.IsEmpty())
{
if (!IsEndTagOptional(stack.Pop()))
{
return false;
}
}
return true;
}
}
}
private static bool IsEndTagOptional(String element)
{
return (_endTagOptionalElement.Contains(element));
}
/// <summary>
/// Private class used to store lowercase tags in a stack
/// return String.Empty if stack is empty
/// </summary>
[
System.Security.Permissions.SecurityPermission(System.Security.Permissions.SecurityAction.Demand,
Flags=System.Security.Permissions.SecurityPermissionFlag.UnmanagedCode)
]
private class TagStack
{
private Stack _tagStack = null;
internal TagStack() : this(_stackInitialSize)
{
}
internal TagStack(int initialCapacity)
{
_tagStack = new Stack(initialCapacity);
}
internal void Push(String tagName)
{
_tagStack.Push(tagName.ToLower(CultureInfo.InvariantCulture));
}
internal String Pop()
{
if (IsEmpty())
{
return String.Empty;
}
return (String)_tagStack.Pop();
}
internal bool IsEmpty()
{
return (_tagStack.Count == 0);
}
}
/// <summary>
/// Private class used to store recognizable lowercase elements
/// return true if element is in the list, otherwise false
/// </summary>
[
System.Security.Permissions.SecurityPermission(System.Security.Permissions.SecurityAction.Demand,
Flags=System.Security.Permissions.SecurityPermissionFlag.UnmanagedCode)
]
private class ElementTable
{
private Hashtable _table = null;
internal ElementTable() : this(_stackInitialSize)
{}
internal ElementTable(int initialCapacity)
{
_table = new Hashtable(initialCapacity, StringComparer.OrdinalIgnoreCase);
}
internal void Add(String key)
{
_table.Add(key, true);
}
internal bool Contains(String key)
{
return (_table.Contains(key));
}
internal void AddRange(String[] keysCollection)
{
foreach (String key in keysCollection)
{
this.Add(key);
}
}
}
}
}

View File

@@ -0,0 +1,103 @@
//------------------------------------------------------------------------------
// <copyright file="TemporaryBitmapFile.cs" company="Microsoft">
// Copyright (c) Microsoft Corporation. All rights reserved.
// </copyright>
//------------------------------------------------------------------------------
namespace System.Web.UI.Design.MobileControls.Util
{
using System;
using System.Diagnostics;
using System.Drawing;
using System.Drawing.Imaging;
using System.IO;
/// <summary>
/// This class encapsulates a bitmap and a file that represents
/// the bitmap on disk. It would have been cleaner to subclass
/// bitmap, but the bitmap class is sealed.
/// </summary>
[
System.Security.Permissions.SecurityPermission(System.Security.Permissions.SecurityAction.Demand,
Flags=System.Security.Permissions.SecurityPermissionFlag.UnmanagedCode)
]
[Obsolete("The System.Web.Mobile.dll assembly has been deprecated and should no longer be used. For information about how to develop ASP.NET mobile applications, see http://go.microsoft.com/fwlink/?LinkId=157231.")]
internal class TemporaryBitmapFile : IDisposable
{
private String _path;
private Bitmap _bitmap;
internal TemporaryBitmapFile(Bitmap bitmap)
{
Debug.Assert(bitmap != null,
"You must provide a valid bitmap object."
);
_bitmap = bitmap;
_path = Path.GetTempPath() + Guid.NewGuid().ToString() + ".bmp";
Sync();
}
public void Dispose()
{
if(_bitmap != null)
{
_bitmap.Dispose();
_bitmap = null;
}
if(_path != null)
{
FileAttributes fa = File.GetAttributes(_path);
File.SetAttributes(_path, fa & ~FileAttributes.ReadOnly);
File.Delete(_path);
_path = null;
}
}
private void Sync()
{
FileAttributes fa;
if(File.Exists(_path))
{
fa = File.GetAttributes(_path);
File.SetAttributes(_path, fa & ~FileAttributes.ReadOnly);
}
_bitmap.Save(_path, ImageFormat.Bmp);
// If the file did not exist previously, fa will not be valid.
fa = File.GetAttributes(_path);
File.SetAttributes(_path, fa | FileAttributes.ReadOnly);
}
internal String Url
{
get
{
return "file:///" + _path;
}
}
internal Bitmap UnderlyingBitmap
{
get
{
return _bitmap;
}
set
{
Debug.Assert(value != null,
"Do not set UnderlyingBitmap to null. Instead, "+
"dispose of this object and create a new one later if " +
"neccessary. (A zero sized bmp can not be written to disk)"
);
if(_bitmap != null)
{
_bitmap.Dispose();
}
_bitmap = value;
Sync();
}
}
}
}

View File

@@ -0,0 +1,137 @@
//------------------------------------------------------------------------------
// <copyright file="UnsettableComboBox.cs" company="Microsoft">
// Copyright (c) Microsoft Corporation. All rights reserved.
// </copyright>
//------------------------------------------------------------------------------
namespace System.Web.UI.Design.MobileControls.Util
{
using System;
using System.Collections;
using System.ComponentModel;
using System.Diagnostics;
using System.Drawing;
using System.Windows.Forms;
// Standard combobox with a "Not Set" item as the first item in its dropdown.
// It also automatically blanks out the "Not Set" item on losing focus.
[
System.Security.Permissions.SecurityPermission(System.Security.Permissions.SecurityAction.Demand,
Flags=System.Security.Permissions.SecurityPermissionFlag.UnmanagedCode)
]
[Obsolete("The System.Web.Mobile.dll assembly has been deprecated and should no longer be used. For information about how to develop ASP.NET mobile applications, see http://go.microsoft.com/fwlink/?LinkId=157231.")]
internal class UnsettableComboBox : ComboBox
{
private String notSetText;
private String notSetCompactText;
internal UnsettableComboBox()
{
notSetText = SR.GetString(SR.UnsettableComboBox_NotSetText);
notSetCompactText = SR.GetString(SR.UnsettableComboBox_NotSetCompactText);
}
internal String NotSetText
{
get
{
return notSetText;
}
set
{
notSetText = value;
}
}
internal String NotSetCompactText
{
get
{
return notSetCompactText;
}
set
{
notSetCompactText = value;
}
}
public override String Text
{
get
{
// handle DropDown styles in Templating Options dialog
// if (this.SelectedIndex == 0) || (this.SelectedIndex == -1))
if (this.SelectedIndex == 0)
{
return String.Empty;
}
else
{
return base.Text;
}
}
set
{
if (value == notSetCompactText)
{
base.Text = String.Empty;
}
else
{
base.Text = value;
}
}
}
internal void AddItem(Object item)
{
EnsureNotSetItem();
Items.Add(item);
}
internal void EnsureNotSetItem()
{
if (Items.Count == 0)
{
Items.Add(notSetText);
}
}
#if UNUSED_CODE
internal bool IsSet()
{
return SelectedIndex > 0;
}
#endif
protected override void OnLostFocus(EventArgs e)
{
base.OnLostFocus(e);
if (SelectedIndex == 0)
{
SelectedIndex = -1;
}
}
protected override void SetItemsCore(IList values)
{
Items.Clear();
if (!DesignMode)
{
Items.Add(notSetText);
}
// Unfortunately. the interfaces between SetItemsCore and
// AddItemsCore are mismatched as of 3106.
ArrayList items = new ArrayList();
foreach(Object item in values)
{
items.Add(item);
}
base.AddItemsCore(items.ToArray());
}
}
}

View File

@@ -0,0 +1,87 @@
//------------------------------------------------------------------------------
// <copyright file="WbmpConverter.cs" company="Microsoft">
// Copyright (c) Microsoft Corporation. All rights reserved.
// </copyright>
//------------------------------------------------------------------------------
namespace System.Web.UI.Design.MobileControls.Util
{
using System;
using System.Drawing;
using System.Diagnostics;
[
System.Security.Permissions.SecurityPermission(System.Security.Permissions.SecurityAction.Demand,
Flags=System.Security.Permissions.SecurityPermissionFlag.UnmanagedCode)
]
[Obsolete("The System.Web.Mobile.dll assembly has been deprecated and should no longer be used. For information about how to develop ASP.NET mobile applications, see http://go.microsoft.com/fwlink/?LinkId=157231.")]
internal class WbmpConverter
{
private static int ExtractMultiByte(Byte[] buffer, ref int cursor)
{
int sum = 0;
do
{
sum <<= 7;
sum += buffer[cursor] & 0x7F;
}
while((buffer[cursor++] & 0x80) != 0);
return sum;
}
internal static Bitmap Convert(Byte[] buffer)
{
try
{
int cursor = 0;
int type = buffer[cursor++];
if(type != 0)
{
Debug.Fail("Wbmp is not type 0. (Unsupported)");
return null;
}
int header = buffer[cursor++];
int width = ExtractMultiByte(buffer, ref cursor);
int height = ExtractMultiByte(buffer, ref cursor);
Bitmap bitmap = new Bitmap(width, height);
Byte mask = 0x80;
for(int y = 0; y < height; y++)
{
for(int x = 0; x < width; x++)
{
if((buffer[cursor] & mask) == 0)
{
bitmap.SetPixel(x, y, Color.Black);
}
else
{
bitmap.SetPixel(x, y, Color.White);
}
mask >>= 1;
if(mask == 0)
{
mask = 0x80;
cursor++;
}
}
// each row starts at the beginning of an octet
if(mask != 0x80)
{
mask = 0x80;
cursor++;
}
}
return bitmap;
}
catch
{
Debug.Fail("Wbmp file appears to be corrupt.");
return null;
}
}
}
}

View File

@@ -0,0 +1,430 @@
//------------------------------------------------------------------------------
// <copyright file="WebConfigManager.cs" company="Microsoft">
// Copyright (c) Microsoft Corporation. All rights reserved.
// </copyright>
//------------------------------------------------------------------------------
namespace System.Web.UI.Design.MobileControls.Util
{
using System;
using System.Collections;
using System.ComponentModel;
using System.Diagnostics;
using System.Reflection;
using System.IO;
using System.Windows.Forms;
using System.Web.UI.MobileControls;
using System.Web.UI.Design;
using System.Web.UI.Design.MobileControls;
using System.Xml;
using SR = System.Web.UI.Design.MobileControls.SR;
[
System.Security.Permissions.SecurityPermission(System.Security.Permissions.SecurityAction.Demand,
Flags=System.Security.Permissions.SecurityPermissionFlag.UnmanagedCode)
]
[Obsolete("The System.Web.Mobile.dll assembly has been deprecated and should no longer be used. For information about how to develop ASP.NET mobile applications, see http://go.microsoft.com/fwlink/?LinkId=157231.")]
internal class WebConfigManager
{
private readonly String _path = null;
private ISite _site = null;
private XmlDocument _document = null;
private WebConfigManager()
{
}
internal WebConfigManager(ISite site)
{
Debug.Assert(site != null);
_site = site;
IWebApplication webApplicationService = (IWebApplication)_site.GetService(typeof(IWebApplication));
if (webApplicationService != null) {
IProjectItem dataFileProjectItem = webApplicationService.GetProjectItemFromUrl("~/web.config");
if (dataFileProjectItem != null) {
_path = dataFileProjectItem.PhysicalPath;
}
}
/* VSWhidbey 271075, 257678
// the following inspired by:
// \VSDesigner\Designer\Microsoft\VisualStudio\Designer\Serialization\BaseDesignerLoader.cs
Type projectItemType = Type.GetType("EnvDTE.ProjectItem, " + AssemblyRef.EnvDTE);
if (projectItemType != null)
{
Object currentProjItem = _site.GetService(projectItemType);
PropertyInfo containingProjectProp = projectItemType.GetProperty("ContainingProject");
Object dteProject = containingProjectProp.GetValue(currentProjItem, new Object[0]);
Type projectType = Type.GetType("EnvDTE.Project, " + AssemblyRef.EnvDTE);
PropertyInfo fullNameProperty = projectType.GetProperty("FullName");
String projectPath = (String)fullNameProperty.GetValue(dteProject, new Object[0]);
_path = Path.GetDirectoryName(projectPath) + "\\web.config";
}
*/
}
internal XmlDocument Document
{
get
{
if (_document == null)
{
_document = new XmlDocument();
}
return _document;
}
}
private void LoadDocument()
{
try
{
Document.Load(_path);
}
catch (Exception ex)
{
Debug.Fail(ex.ToString());
throw new Exception(SR.GetString(SR.WebConfig_FileLoadException));
}
}
internal void EnsureWebConfigCheckedOut()
{
DesignerUtility.EnsureFileCheckedOut(_site, _path);
}
internal void EnsureWebConfigIsPresent()
{
if(!File.Exists(_path))
{
// We throw our own exception type so we can easily tell
// between a corrupt web.config and a missing one.
throw new FileNotFoundException(
SR.GetString(SR.WebConfig_FileNotFoundException)
);
}
}
internal ArrayList ReadDeviceFilters()
{
EnsureWebConfigIsPresent();
// Reload the document everytime we read filters
LoadDocument();
XmlNode filters = FindFilterSection(Document, false);
ArrayList DeviceFilterList = new ArrayList();
if (filters != null)
{
Hashtable filterTable = new Hashtable();
foreach(XmlNode childNode in filters.ChildNodes)
{
if (childNode.Name != null && childNode.Name.Equals("filter"))
{
// Ignore the empty filter.
if (childNode.Attributes["name"] == null ||
childNode.Attributes["name"].Value == null ||
childNode.Attributes["name"].Value.Length == 0)
{
continue;
}
String filterName = childNode.Attributes["name"].Value;
if (filterTable[filterName] != null)
{
throw new Exception(SR.GetString(SR.DeviceFilterEditorDialog_DuplicateNames));
}
DeviceFilterNode node = new DeviceFilterNode(this, childNode);
DeviceFilterList.Add(node);
filterTable[filterName] = true;
}
}
}
return DeviceFilterList;
}
private bool IsSystemWebSectionPresent()
{
EnsureWebConfigIsPresent();
XmlNode filters = FindFilterSection(Document, false);
return filters != null;
}
private XmlElement FindXmlNode(XmlNode node, string name) {
Debug.Assert(node != null);
if (node.HasChildNodes) {
foreach (XmlNode child in node.ChildNodes) {
if (String.Equals(child.Name, name, StringComparison.Ordinal) &&
child is XmlElement) {
return (XmlElement)child;
}
}
}
return null;
}
internal XmlElement FindFilterSection(XmlDocument document, bool createIfNotExists) {
XmlNode configSection = FindXmlNode(document, "configuration");
if (configSection == null) {
if (createIfNotExists) {
throw new Exception(SR.GetString(SR.WebConfig_FileLoadException));
}
return null;
}
XmlElement webSection = FindXmlNode(configSection, "system.web");
if (webSection == null) {
if (createIfNotExists) {
webSection = Document.CreateElement("system.web");
configSection.AppendChild(webSection);
}
return null;
}
XmlElement filters = FindXmlNode(webSection, "deviceFilters");
if (filters == null) {
if (createIfNotExists) {
filters = Document.CreateElement("deviceFilters");
webSection.AppendChild(filters);
}
return null;
}
return filters;
}
internal void EnsureSystemWebSectionIsPresent() {
if (!IsSystemWebSectionPresent()) {
Debug.Assert(Document != null);
FindFilterSection(Document, true);
}
}
internal void Save()
{
Document.Save(_path);
}
}
[
System.Security.Permissions.SecurityPermission(System.Security.Permissions.SecurityAction.Demand,
Flags=System.Security.Permissions.SecurityPermissionFlag.UnmanagedCode)
]
[Obsolete("The System.Web.Mobile.dll assembly has been deprecated and should no longer be used. For information about how to develop ASP.NET mobile applications, see http://go.microsoft.com/fwlink/?LinkId=157231.")]
internal class DeviceFilterNode : ICloneable
{
internal enum DeviceFilterMode
{
Compare,
Delegate
};
private WebConfigManager _webConfig = null;
private XmlNode _xmlNode = null;
internal DeviceFilterMode Mode;
private String _name;
private String _type;
private String _method;
private String _compare;
private String _argument;
internal DeviceFilterNode(WebConfigManager webConfig) : base()
{
_webConfig = webConfig;
_xmlNode = webConfig.Document.CreateElement("filter");
Name = SR.GetString(SR.DeviceFilterNode_DefaultFilterName);
Mode = DeviceFilterMode.Compare;
}
internal DeviceFilterNode(
WebConfigManager webConfig,
XmlNode xmlNode
) {
_webConfig = webConfig;
_xmlNode = xmlNode;
Debug.Assert(_xmlNode.Attributes != null);
if (_xmlNode.Attributes["type"] != null)
{
Mode = DeviceFilterMode.Delegate;
Debug.Assert(
_xmlNode.Attributes["argument"] == null && _xmlNode.Attributes["compare"] == null,
"Managementobject contains both Compare and Delegate mode properties."
);
}
else
{
Mode = DeviceFilterMode.Compare;
// we already know type is null, but it nevers hurts...
Debug.Assert(
_xmlNode.Attributes["type"] == null && _xmlNode.Attributes["method"] == null,
"Managementobject contains both Compare and Delegate mode properties."
);
}
_name = _xmlNode.Attributes["name"] == null?
null : _xmlNode.Attributes["name"].Value;
_compare = _xmlNode.Attributes["compare"] == null?
null : _xmlNode.Attributes["compare"].Value;
_argument = _xmlNode.Attributes["argument"] == null?
null : _xmlNode.Attributes["argument"].Value;
_type = _xmlNode.Attributes["type"] == null?
null : _xmlNode.Attributes["type"].Value;
_method = _xmlNode.Attributes["method"] == null?
null : _xmlNode.Attributes["method"].Value;
}
internal void Delete()
{
Debug.Assert(_xmlNode != null);
if (_xmlNode.ParentNode != null)
{
_xmlNode.ParentNode.RemoveChild(_xmlNode);
}
}
internal void Save()
{
Debug.Assert(_xmlNode != null);
if (_xmlNode.Attributes["name"] == null)
{
_xmlNode.Attributes.Append(_webConfig.Document.CreateAttribute("name"));
}
_xmlNode.Attributes["name"].Value = Name;
if(Mode == DeviceFilterMode.Compare)
{
Type = null;
Method = null;
_xmlNode.Attributes.RemoveNamedItem("type");
_xmlNode.Attributes.RemoveNamedItem("method");
if (_xmlNode.Attributes["compare"] == null)
{
_xmlNode.Attributes.Append(_webConfig.Document.CreateAttribute("compare"));
}
_xmlNode.Attributes["compare"].Value = Compare;
if (_xmlNode.Attributes["argument"] == null)
{
_xmlNode.Attributes.Append(_webConfig.Document.CreateAttribute("argument"));
}
_xmlNode.Attributes["argument"].Value = Argument;
}
else
{
Compare = null;
Argument = null;
_xmlNode.Attributes.RemoveNamedItem("compare");
_xmlNode.Attributes.RemoveNamedItem("argument");
if (_xmlNode.Attributes["type"] == null)
{
_xmlNode.Attributes.Append(_webConfig.Document.CreateAttribute("type"));
}
_xmlNode.Attributes["type"].Value = Type;
if (_xmlNode.Attributes["method"] == null)
{
_xmlNode.Attributes.Append(_webConfig.Document.CreateAttribute("method"));
}
_xmlNode.Attributes["method"].Value = Method;
}
_webConfig.EnsureSystemWebSectionIsPresent();
XmlNode filters = _webConfig.FindFilterSection(_webConfig.Document, false);
filters.AppendChild(_xmlNode);
}
// Cause the DeviceFilterNode to display correctly when inserted
// in a combo box.
public override String ToString()
{
if(Name == null || Name.Length == 0)
{
return SR.GetString(SR.DeviceFilter_DefaultChoice);
}
return Name;
}
internal String Name
{
get { return _name; }
set { _name = value; }
}
internal String Type
{
get { return _type; }
set { _type = value; }
}
internal String Method
{
get { return _method; }
set { _method = value; }
}
internal String Compare
{
get { return _compare; }
set { _compare = value; }
}
internal String Argument
{
get { return _argument; }
set { _argument = value; }
}
// <summary>
// Returns a copy of this node's encapsulated data. Does not
// copy TreeNode fields.
// </summary>
public Object Clone()
{
DeviceFilterNode newNode = new DeviceFilterNode(
_webConfig
);
newNode.Name = this.Name;
newNode.Mode = this.Mode;
if(this.Mode == DeviceFilterMode.Compare)
{
newNode.Compare = this.Compare;
newNode.Argument = this.Argument;
}
else
{
newNode.Type = this.Type;
newNode.Method = this.Method;
}
return (Object) newNode;
}
}
}