Imported Upstream version 4.6.0.125

Former-commit-id: a2155e9bd80020e49e72e86c44da02a8ac0e57a4
This commit is contained in:
Xamarin Public Jenkins (auto-signing)
2016-08-03 10:59:49 +00:00
parent a569aebcfd
commit e79aa3c0ed
17047 changed files with 3137615 additions and 392334 deletions

View File

@@ -1,41 +0,0 @@
/*
Copyright (C) 2002-2010 Jeroen Frijters
This software is provided 'as-is', without any express or implied
warranty. In no event will the authors be held liable for any damages
arising from the use of this software.
Permission is granted to anyone to use this software for any purpose,
including commercial applications, and to alter it and redistribute it
freely, subject to the following restrictions:
1. The origin of this software must not be misrepresented; you must not
claim that you wrote the original software. If you use this software
in a product, an acknowledgment in the product documentation would be
appreciated but is not required.
2. Altered source versions must be plainly marked as such, and must not be
misrepresented as being the original software.
3. This notice may not be removed or altered from any source distribution.
Jeroen Frijters
jeroen@frijters.net
*/
using System.Reflection;
using System.Runtime.CompilerServices;
//
// General Information about an assembly is controlled through the following
// set of attributes. Change these attribute values to modify the information
// associated with an assembly.
//
[assembly: AssemblyTitle("IKVM.NET AWT Support")]
[assembly: AssemblyDescription("Winforms peers and 'native' code")]
[assembly: System.Security.AllowPartiallyTrustedCallers]
#if SIGNCODE
[assembly: InternalsVisibleTo("IKVM.OpenJDK.SwingAWT, PublicKey=@PUBLICKEY@")]
#else
[assembly: InternalsVisibleTo("IKVM.OpenJDK.SwingAWT")]
#endif

View File

@@ -1,161 +0,0 @@
<Project DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003" ToolsVersion="3.5">
<PropertyGroup>
<ProjectType>Local</ProjectType>
<ProductVersion>9.0.30729</ProductVersion>
<SchemaVersion>2.0</SchemaVersion>
<ProjectGuid>{E00A0FA2-1FD7-4DD9-8C06-7202CE366102}</ProjectGuid>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
<ApplicationIcon>
</ApplicationIcon>
<AssemblyKeyContainerName>
</AssemblyKeyContainerName>
<AssemblyName>IKVM.AWT.WinForms</AssemblyName>
<AssemblyOriginatorKeyFile>
</AssemblyOriginatorKeyFile>
<DefaultClientScript>JScript</DefaultClientScript>
<DefaultHTMLPageLayout>Grid</DefaultHTMLPageLayout>
<DefaultTargetSchema>IE50</DefaultTargetSchema>
<DelaySign>false</DelaySign>
<OutputType>Library</OutputType>
<RootNamespace>awt</RootNamespace>
<RunPostBuildEvent>OnBuildSuccess</RunPostBuildEvent>
<StartupObject>
</StartupObject>
<FileUpgradeFlags>
</FileUpgradeFlags>
<UpgradeBackupLocation>
</UpgradeBackupLocation>
<OldToolsVersion>2.0</OldToolsVersion>
<IsWebBootstrapper>false</IsWebBootstrapper>
<PublishUrl>publish\</PublishUrl>
<Install>true</Install>
<InstallFrom>Disk</InstallFrom>
<UpdateEnabled>false</UpdateEnabled>
<UpdateMode>Foreground</UpdateMode>
<UpdateInterval>7</UpdateInterval>
<UpdateIntervalUnits>Days</UpdateIntervalUnits>
<UpdatePeriodically>false</UpdatePeriodically>
<UpdateRequired>false</UpdateRequired>
<MapFileExtensions>true</MapFileExtensions>
<ApplicationRevision>0</ApplicationRevision>
<ApplicationVersion>1.0.0.%2a</ApplicationVersion>
<UseApplicationTrust>false</UseApplicationTrust>
<BootstrapperEnabled>true</BootstrapperEnabled>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<OutputPath>bin\Debug\</OutputPath>
<AllowUnsafeBlocks>false</AllowUnsafeBlocks>
<BaseAddress>285212672</BaseAddress>
<CheckForOverflowUnderflow>false</CheckForOverflowUnderflow>
<ConfigurationOverrideFile>
</ConfigurationOverrideFile>
<DefineConstants>TRACE;DEBUG;WHIDBEY</DefineConstants>
<DocumentationFile>
</DocumentationFile>
<DebugSymbols>true</DebugSymbols>
<FileAlignment>4096</FileAlignment>
<NoStdLib>false</NoStdLib>
<NoWarn>672,612</NoWarn>
<Optimize>false</Optimize>
<RegisterForComInterop>false</RegisterForComInterop>
<RemoveIntegerChecks>false</RemoveIntegerChecks>
<TreatWarningsAsErrors>false</TreatWarningsAsErrors>
<WarningLevel>4</WarningLevel>
<DebugType>full</DebugType>
<ErrorReport>prompt</ErrorReport>
</PropertyGroup>
<ItemGroup>
<Reference Include="IKVM.OpenJDK.Core, Version=0.39.3280.0, Culture=neutral, processorArchitecture=MSIL">
<SpecificVersion>False</SpecificVersion>
<HintPath>..\bin\IKVM.OpenJDK.Core.dll</HintPath>
</Reference>
<Reference Include="IKVM.OpenJDK.Media, Version=0.41.3440.0, Culture=neutral, processorArchitecture=MSIL">
<SpecificVersion>False</SpecificVersion>
<HintPath>..\bin\IKVM.OpenJDK.Media.dll</HintPath>
</Reference>
<Reference Include="IKVM.OpenJDK.Misc, Version=0.39.3280.0, Culture=neutral, processorArchitecture=MSIL">
<SpecificVersion>False</SpecificVersion>
<HintPath>..\bin\IKVM.OpenJDK.Misc.dll</HintPath>
</Reference>
<Reference Include="IKVM.OpenJDK.SwingAWT, Version=0.39.3280.0, Culture=neutral, processorArchitecture=MSIL">
<SpecificVersion>False</SpecificVersion>
<HintPath>..\bin\IKVM.OpenJDK.SwingAWT.dll</HintPath>
</Reference>
<Reference Include="IKVM.OpenJDK.Text, Version=0.39.3280.0, Culture=neutral, processorArchitecture=MSIL">
<SpecificVersion>False</SpecificVersion>
<HintPath>..\bin\IKVM.OpenJDK.Text.dll</HintPath>
</Reference>
<Reference Include="System">
<Name>System</Name>
</Reference>
<Reference Include="System.Data" />
<Reference Include="System.Drawing">
<Name>System.Drawing</Name>
</Reference>
<Reference Include="System.Windows.Forms">
<Name>System.Windows.Forms</Name>
</Reference>
<Reference Include="System.Xml" />
</ItemGroup>
<ItemGroup>
<Compile Include="..\CommonAssemblyInfo.cs">
<SubType>Code</SubType>
</Compile>
<Compile Include="AssemblyInfo.cs">
<SubType>Code</SubType>
</Compile>
<Compile Include="composite.cs" />
<Compile Include="converter.cs">
<SubType>Code</SubType>
</Compile>
<Compile Include="fonts-0.95.cs" />
<Compile Include="graphics.cs">
<SubType>Code</SubType>
</Compile>
<Compile Include="IconFactory.cs" />
<Compile Include="images.cs">
<SubType>Code</SubType>
</Compile>
<Compile Include="native.cs" />
<Compile Include="printing.cs" />
<Compile Include="robot.cs">
<SubType>Code</SubType>
</Compile>
<Compile Include="ShellApi.cs" />
<Compile Include="theming.cs" />
<Compile Include="toolkit-0.95.cs">
<SubType>Form</SubType>
</Compile>
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\runtime\IKVM.Runtime.8.csproj">
<Project>{F5C7B588-0403-4AF2-A4DE-5697DE21BC2C}</Project>
<Name>IKVM.Runtime.8</Name>
</ProjectReference>
</ItemGroup>
<ItemGroup>
<BootstrapperPackage Include="Microsoft.Net.Framework.2.0">
<Visible>False</Visible>
<ProductName>.NET Framework 2.0 %28x86%29</ProductName>
<Install>true</Install>
</BootstrapperPackage>
<BootstrapperPackage Include="Microsoft.Net.Framework.3.0">
<Visible>False</Visible>
<ProductName>.NET Framework 3.0 %28x86%29</ProductName>
<Install>false</Install>
</BootstrapperPackage>
<BootstrapperPackage Include="Microsoft.Net.Framework.3.5">
<Visible>False</Visible>
<ProductName>.NET Framework 3.5</ProductName>
<Install>false</Install>
</BootstrapperPackage>
</ItemGroup>
<Import Project="$(MSBuildBinPath)\Microsoft.CSharp.targets" />
<PropertyGroup>
<PreBuildEvent>
</PreBuildEvent>
<PostBuildEvent>
</PostBuildEvent>
</PropertyGroup>
</Project>

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@@ -1,72 +0,0 @@
<?xml version="1.0"?>
<project name="awt" default="awt">
<include buildfile="../ikvm.include" />
<target name="AssemblyInfo.cs">
<loadfile file="../tools/pubkey.txt" property="publickey" />
<copy file="AssemblyInfo.cs.in" tofile="AssemblyInfo.cs" overwrite="true">
<filterchain>
<replacetokens>
<token key="PUBLICKEY" value="${publickey}" />
</replacetokens>
</filterchain>
</copy>
</target>
<target name="first-pass" depends="AssemblyInfo.cs">
<property overwrite="false" name="signed" value="" />
<csc target="library" output="../bin/IKVM.AWT.WinForms.dll" define="FIRST_PASS;${signed}" rebuild="true" nostdlib="true" noconfig="true">
<sources>
<include name="../CommonAssemblyInfo.cs" />
<include name="AssemblyInfo.cs" />
<include name="native.cs" />
<include name="ShellApi.cs" />
<include name="theming.cs" />
</sources>
<references>
<include name="${ReferencePath}/mscorlib.dll" asis="true" />
<include name="${ReferencePath}/System.dll" asis="true" />
<include name="${ReferencePath}/System.Windows.Forms.dll" asis="true" />
<include name="${ReferencePath}/System.Drawing.dll" asis="true" />
</references>
</csc>
</target>
<target name="awt" depends="AssemblyInfo.cs">
<property overwrite="false" name="signed" value="" />
<csc target="library" output="../bin/IKVM.AWT.WinForms.dll" define="TRACE;${signed}" rebuild="true" nostdlib="true" noconfig="true">
<sources>
<include name="../CommonAssemblyInfo.cs" />
<include name="AssemblyInfo.cs" />
<include name="converter.cs" />
<include name="fonts-0.95.cs" />
<include name="graphics.cs" />
<include name="composite.cs" />
<include name="IconFactory.cs" />
<include name="images.cs" />
<include name="native.cs" />
<include name="printing.cs" />
<include name="robot.cs" />
<include name="toolkit-0.95.cs" />
<include name="ShellApi.cs" />
<include name="theming.cs" />
</sources>
<references>
<include name="../bin/IKVM.OpenJDK.Core.dll" asis="true" />
<include name="../bin/IKVM.OpenJDK.Text.dll" asis="true" />
<include name="../bin/IKVM.OpenJDK.SwingAWT.dll" asis="true" />
<include name="../bin/IKVM.OpenJDK.Media.dll" asis="true" />
<include name="../bin/IKVM.OpenJDK.Misc.dll" asis="true" />
<include name="../bin/IKVM.Runtime.dll" asis="true" />
<include name="${ReferencePath}/mscorlib.dll" asis="true" />
<include name="${ReferencePath}/System.dll" asis="true" />
<include name="${ReferencePath}/System.Windows.Forms.dll" asis="true" />
<include name="${ReferencePath}/System.Drawing.dll" asis="true" />
</references>
<nowarn>
<!-- disable warnings about obsolete members (because the peer API has lots of those) -->
<warning number="612" />
</nowarn>
</csc>
<if test="${property::exists('peverify')}">
<exec program="${peverify}" commandline="-nologo ../bin/IKVM.AWT.WinForms.dll" />
</if>
</target>
</project>

View File

@@ -1,143 +0,0 @@
/*
Copyright (C) 2010 Volker Berlin (i-net software)
This software is provided 'as-is', without any express or implied
warranty. In no event will the authors be held liable for any damages
arising from the use of this software.
Permission is granted to anyone to use this software for any purpose,
including commercial applications, and to alter it and redistribute it
freely, subject to the following restrictions:
1. The origin of this software must not be misrepresented; you must not
claim that you wrote the original software. If you use this software
in a product, an acknowledgment in the product documentation would be
appreciated but is not required.
2. Altered source versions must be plainly marked as such, and must not be
misrepresented as being the original software.
3. This notice may not be removed or altered from any source distribution.
Jeroen Frijters
jeroen@frijters.net
*/
using System;
using System.Drawing;
using System.Drawing.Drawing2D;
using System.Drawing.Imaging;
namespace ikvm.awt {
internal class CompositeHelper {
private readonly ImageAttributes imageAttributes = new ImageAttributes();
/// <summary>
/// Create a default CompositeHelper. Is used from Create only.
/// </summary>
protected CompositeHelper() {
}
internal static CompositeHelper Create(java.awt.Composite comp, Graphics graphics){
if (comp is java.awt.AlphaComposite) {
java.awt.AlphaComposite alphaComp = (java.awt.AlphaComposite)comp;
float alpha = alphaComp.getAlpha();
switch (alphaComp.getRule()) {
case java.awt.AlphaComposite.CLEAR:
graphics.CompositingMode = CompositingMode.SourceCopy;
return new ClearCompositeHelper();
case java.awt.AlphaComposite.SRC:
graphics.CompositingMode = CompositingMode.SourceCopy;
break;
case java.awt.AlphaComposite.SRC_OVER:
graphics.CompositingMode = CompositingMode.SourceOver;
break;
case java.awt.AlphaComposite.DST:
graphics.CompositingMode = CompositingMode.SourceOver;
alpha = 0.0F;
break;
default:
graphics.CompositingMode = CompositingMode.SourceOver;
Console.Error.WriteLine("AlphaComposite with Rule " + alphaComp.getRule() + " not supported.");
break;
}
if (alpha == 1.0) {
return new CompositeHelper();
} else {
return new AlphaCompositeHelper(alpha);
}
} else {
graphics.CompositingMode = CompositingMode.SourceOver;
Console.Error.WriteLine("Composite not supported: " + comp.GetType().FullName);
return new CompositeHelper();
}
}
internal virtual int GetArgb(java.awt.Color color) {
return color.getRGB();
}
internal virtual Color GetColor( java.awt.Color color ){
return color == null ? Color.Empty : Color.FromArgb(GetArgb(color));
}
internal virtual int ToArgb(Color color) {
return color.ToArgb();
}
internal virtual java.awt.Color GetColor(Color color) {
return color == Color.Empty ? null : new java.awt.Color(ToArgb(color), true);
}
/// <summary>
/// Get the ImageAttributes instance. Does not change it bcause it is not a copy.
/// </summary>
/// <returns></returns>
internal virtual ImageAttributes GetImageAttributes(){
return imageAttributes;
}
}
internal sealed class AlphaCompositeHelper : CompositeHelper {
private readonly float alpha;
/// <summary>
/// Create a AlphaCompositeHelper
/// </summary>
/// <param name="alpha">a value in the range from 0.0 to 1.0</param>
internal AlphaCompositeHelper(float alpha) {
this.alpha = alpha;
ColorMatrix matrix = new ColorMatrix();
matrix.Matrix33 = alpha;
GetImageAttributes().SetColorMatrix(matrix);
}
internal override int GetArgb(java.awt.Color color) {
uint argb = (uint)color.getRGB();
uint newAlpha = (uint)((0xff000000 & argb) * alpha + 0x800000);
uint newArgb = (0xff000000 & newAlpha) | (0xffffff & argb);
return (int)newArgb;
}
internal override int ToArgb(Color color) {
uint argb = (uint)color.ToArgb();
uint newAlpha = (uint)((0xff000000 & argb) / alpha + 0x800000);
uint newArgb = (0xff000000 & newAlpha) | (0xffffff & argb);
return (int)newArgb;
}
}
internal sealed class ClearCompositeHelper : CompositeHelper {
internal ClearCompositeHelper()
{
ColorMatrix matrix = new ColorMatrix();
matrix.Matrix00 = matrix.Matrix11 = matrix.Matrix22 = matrix.Matrix33 = 0.0F;
GetImageAttributes().SetColorMatrix(matrix);
}
internal override int GetArgb(java.awt.Color color) {
return 0;
}
}
}

View File

@@ -1,402 +0,0 @@
/*
Copyright (C) 2002, 2004, 2005, 2006, 2007 Jeroen Frijters
Copyright (C) 2006 Active Endpoints, Inc.
Copyright (C) 2006 - 2010 Volker Berlin (i-net software)
This software is provided 'as-is', without any express or implied
warranty. In no event will the authors be held liable for any damages
arising from the use of this software.
Permission is granted to anyone to use this software for any purpose,
including commercial applications, and to alter it and redistribute it
freely, subject to the following restrictions:
1. The origin of this software must not be misrepresented; you must not
claim that you wrote the original software. If you use this software
in a product, an acknowledgment in the product documentation would be
appreciated but is not required.
2. Altered source versions must be plainly marked as such, and must not be
misrepresented as being the original software.
3. This notice may not be removed or altered from any source distribution.
Jeroen Frijters
jeroen@frijters.net
*/
using System;
using System.Drawing;
using System.Drawing.Drawing2D;
using System.Drawing.Text;
using System.Drawing.Imaging;
using System.IO;
using System.Runtime.InteropServices;
using System.Threading;
using System.Windows.Forms;
using System.ComponentModel;
using System.Reflection;
using System.Text;
using java.awt.datatransfer;
using java.awt.image;
using java.awt.peer;
using java.net;
using java.util;
namespace ikvm.awt
{
/// <summary>
/// This class has some static convertion methods from Java to C# objects
/// </summary>
class J2C
{
internal static Color ConvertColor(java.awt.Color color)
{
return color == null ? Color.Empty : Color.FromArgb(color.getRGB());
}
internal static Bitmap ConvertImage(java.awt.Image img)
{
if (img is BufferedImage)
{
return ((BufferedImage)img).getBitmap();
}
if (img is NetVolatileImage)
{
return ((NetVolatileImage)img).bitmap;
}
if (img is sun.awt.image.ToolkitImage)
{
sun.awt.image.ImageRepresentation ir = ((sun.awt.image.ToolkitImage)img).getImageRep();
// start the production and wait if not produce the image
lock( ir ) {
ir.prepare(null);
while ( ir.getBufferedImage() == null ) {
ir.wait();
}
}
return ir.getBufferedImage().getBitmap();
}
if (img is NoImage)
{
return null;
}
Console.WriteLine(new System.Diagnostics.StackTrace());
throw new NotImplementedException("Image class:" + img.GetType().FullName);
}
internal static PointF ConvertPoint(java.awt.geom.Point2D point)
{
return new PointF((float)point.getX(), (float)point.getY());
}
internal static RectangleF ConvertRect(java.awt.geom.Rectangle2D rect)
{
return new RectangleF((float)rect.getX(), (float)rect.getY(), (float)rect.getWidth(), (float)rect.getHeight());
}
internal static Rectangle ConvertRect(java.awt.Rectangle rect)
{
return new Rectangle(rect.x, rect.y, rect.width, rect.height);
}
/// <summary>
/// Create a rounded rectangle using lines and arcs
/// </summary>
/// <param name="x">upper left x coordinate</param>
/// <param name="y">upper left y coordinate</param>
/// <param name="w">width</param>
/// <param name="h">height</param>
/// <param name="arcWidth">the horizontal diameter of the arc at the four corners</param>
/// <param name="arcHeight">the vertical diameter of the arc at the four corners</param>
/// <returns></returns>
internal static GraphicsPath ConvertRoundRect(int x, int y, int w, int h, int arcWidth, int arcHeight)
{
GraphicsPath gp = new GraphicsPath();
bool drawArc = arcWidth > 0 && arcHeight > 0;
int a = arcWidth / 2;
int b = arcHeight / 2;
gp.AddLine(x + a, y, x + w - a, y);
if (drawArc)
{
gp.AddArc(x + w - arcWidth, y, arcWidth, arcHeight, 270, 90); //upper right arc
}
gp.AddLine(x + w, y + b, x + w, y + h - b);
if (drawArc)
{
gp.AddArc(x + w - arcWidth, y + h - arcHeight, arcWidth, arcHeight, 0, 90); //lower right arc
}
gp.AddLine(x + w - a, y + h, x + a, y + h);
if (drawArc)
{
gp.AddArc(x, y + h - arcHeight, arcWidth, arcHeight, 90, 90);//lower left arc
}
gp.AddLine(x, y + h - b, x, y + b);
if (drawArc)
{
gp.AddArc(x, y, arcWidth, arcHeight, 180, 90); //upper left arc
}
gp.CloseFigure();
return gp;
}
internal static GraphicsPath ConvertShape(java.awt.Shape shape)
{
java.awt.geom.PathIterator iterator = shape.getPathIterator(null);
GraphicsPath gp = new GraphicsPath();
gp.FillMode = (FillMode)iterator.getWindingRule();
float[] coords = new float[6];
float x = 0;
float y = 0;
while (!iterator.isDone())
{
int type = iterator.currentSegment(coords);
switch (type)
{
case java.awt.geom.PathIterator.__Fields.SEG_MOVETO:
x = coords[0];
y = coords[1];
gp.StartFigure();
break;
case java.awt.geom.PathIterator.__Fields.SEG_LINETO:
gp.AddLine(x, y, coords[0], coords[1]);
x = coords[0];
y = coords[1];
break;
case java.awt.geom.PathIterator.__Fields.SEG_QUADTO:
gp.AddBezier(x, y, coords[0], coords[1], coords[0], coords[1], coords[2], coords[3]);
x = coords[2];
y = coords[3];
break;
case java.awt.geom.PathIterator.__Fields.SEG_CUBICTO:
gp.AddBezier(x, y, coords[0], coords[1], coords[2], coords[3], coords[4], coords[5]);
x = coords[4];
y = coords[5];
break;
case java.awt.geom.PathIterator.__Fields.SEG_CLOSE:
gp.CloseFigure();
break;
}
iterator.next();
}
return gp;
}
internal static LineJoin ConvertLineJoin(int join)
{
switch (join)
{
case java.awt.BasicStroke.JOIN_MITER:
return LineJoin.Miter;
case java.awt.BasicStroke.JOIN_ROUND:
return LineJoin.Round;
case java.awt.BasicStroke.JOIN_BEVEL:
return LineJoin.Bevel;
default:
Console.WriteLine("Unknown line join type:" + join);
return LineJoin.Miter;
}
}
internal static Matrix ConvertTransform(java.awt.geom.AffineTransform tx)
{
return new Matrix(
(float)tx.getScaleX(),
(float)tx.getShearY(),
(float)tx.getShearX(),
(float)tx.getScaleY(),
(float)tx.getTranslateX(),
(float)tx.getTranslateY());
}
internal static FontFamily CreateFontFamily(String name)
{
String name2 = name == null ? null : name.ToLower();
switch (name2)
{
case "monospaced":
case "courier":
return FontFamily.GenericMonospace;
case "serif":
return FontFamily.GenericSerif;
case "sansserif":
case "dialog":
case "dialoginput":
case null:
case "default":
return FontFamily.GenericSansSerif;
default:
try
{
return new FontFamily(name);
}
catch (ArgumentException)
{
return FontFamily.GenericSansSerif;
}
}
}
private static FontStyle ConvertFontStyle(int style)
{
FontStyle fs = FontStyle.Regular;
if ((style & java.awt.Font.BOLD) != 0)
{
fs |= FontStyle.Bold;
}
if ((style & java.awt.Font.ITALIC) != 0)
{
fs |= FontStyle.Italic;
}
return fs;
}
internal static Font ConvertFont(String name, int style, float size)
{
if (size <= 0)
{
size = 1;
}
FontFamily family = CreateFontFamily(name);
FontStyle fontStyle = ConvertFontStyle(style);
if (!family.IsStyleAvailable(fontStyle))
{
//Some Fonts (for example Aharoni) does not support Regular style. This throw an exception else it is not documented.
if(family.IsStyleAvailable(FontStyle.Regular)){
fontStyle = FontStyle.Regular;
}else
if(family.IsStyleAvailable(FontStyle.Bold)){
fontStyle = FontStyle.Bold;
}else
if(family.IsStyleAvailable(FontStyle.Italic)){
fontStyle = FontStyle.Italic;
}else
if(family.IsStyleAvailable(FontStyle.Bold | FontStyle.Italic)){
fontStyle = FontStyle.Bold | FontStyle.Italic;
}
}
return new Font(family, size, fontStyle, GraphicsUnit.Pixel);
}
internal static Region ConvertRegion(sun.java2d.pipe.Region shape)
{
if (shape == null)
{
return null;
}
if (shape.isRectangular())
{
int x = shape.getLoX();
int y = shape.getLoY();
int w = shape.getHiX() - x;
int h = shape.getHiY() - y;
if (w < 0 || h < 0)
{
return new Region();
}
else
{
return new Region(new Rectangle(x, y, w, h));
}
}
else
{
using (GraphicsPath path = new GraphicsPath())
{
sun.java2d.pipe.SpanIterator iter = shape.getSpanIterator();
int[] box = new int[4];
while (iter.nextSpan(box))
{
path.AddRectangle(new Rectangle(box[0], box[1], box[2] - box[0], box[3] - box[1]));
}
return new Region(path);
}
}
}
internal static string ConvertGlyphVector(java.awt.font.GlyphVector gv) {
int count = gv.getNumGlyphs();
char[] text = new char[count];
for (int i = 0; i < count; i++) {
text[i] = (char)gv.getGlyphCode(i);
}
return new string(text);
}
}
/// <summary>
/// This class has some static convertion function from C# to Java objects
/// </summary>
class C2J
{
internal static java.awt.geom.AffineTransform ConvertMatrix(Matrix matrix)
{
float[] elements = matrix.Elements;
return new java.awt.geom.AffineTransform(elements);
}
internal static java.awt.Rectangle ConvertRectangle(RectangleF rec)
{
return new java.awt.Rectangle((int)rec.X, (int)rec.Y, (int)rec.Width, (int)rec.Height);
}
internal static java.awt.Color ConvertColor(Color color)
{
return color == Color.Empty ? null : new java.awt.Color(color.ToArgb(),true);
}
internal static java.awt.Font ConvertFont(Font font)
{
float size = font.Size;
if (font.Unit != GraphicsUnit.Pixel)
{
size = font.SizeInPoints * java.awt.Toolkit.getDefaultToolkit().getScreenResolution() / 72;
}
java.awt.Font jFont = new java.awt.Font(font.Name, (int)font.Style, (int)size);
if (jFont.getSize2D() != size)
{
jFont = jFont.deriveFont(size);
}
//TODO performance we should set the .NET Font, we can do it with an aditional constructor.
return jFont;
}
internal static java.awt.Shape ConvertShape(GraphicsPath path) {
java.awt.geom.GeneralPath shape = new java.awt.geom.GeneralPath();
shape.setWindingRule((int)path.FillMode);
for (int i = 0; i < path.PointCount; i++) {
byte pathType = path.PathTypes[i];
int type = pathType & 0x07;
PointF point = path.PathPoints[i];
switch (type) {
case 0:
// Indicates that the point is the start of a figure.
shape.moveTo(point.X, point.Y);
break;
case 1:
// Indicates that the point is one of the two endpoints of a line.
shape.lineTo(point.X, point.Y);
break;
case 3:
// Indicates that the point is an endpoint or control point of a cubic B<>zier spline.
PointF point2 = path.PathPoints[++i];
PointF point3 = path.PathPoints[++i];
shape.curveTo(point.X, point.Y, point2.X, point2.Y, point3.X, point3.Y);
pathType = path.PathTypes[i];
break;
default:
Console.WriteLine("Unknown GraphicsPath type: " + type);
break;
}
if ((pathType & 0x80) > 0) {
// Specifies that the point is the last point in a closed subpath (figure).
shape.closePath();
}
}
return shape;
}
}
}

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@@ -1,211 +0,0 @@
/*
Copyright (C) 2002, 2004, 2005, 2006 Jeroen Frijters
Copyright (C) 2006 Active Endpoints, Inc.
Copyright (C) 2006 - 2013 Volker Berlin (i-net software)
This software is provided 'as-is', without any express or implied
warranty. In no event will the authors be held liable for any damages
arising from the use of this software.
Permission is granted to anyone to use this software for any purpose,
including commercial applications, and to alter it and redistribute it
freely, subject to the following restrictions:
1. The origin of this software must not be misrepresented; you must not
claim that you wrote the original software. If you use this software
in a product, an acknowledgment in the product documentation would be
appreciated but is not required.
2. Altered source versions must be plainly marked as such, and must not be
misrepresented as being the original software.
3. This notice may not be removed or altered from any source distribution.
Jeroen Frijters
jeroen@frijters.net
*/
using System;
using System.Drawing;
using java.awt.image;
using java.util;
using System.Drawing.Imaging;
namespace ikvm.awt
{
class NetVolatileImage : java.awt.image.VolatileImage
{
internal readonly Bitmap bitmap;
internal readonly java.awt.Component component;
private java.awt.Font defaultFont;
private readonly int width;
private readonly int height;
internal NetVolatileImage(java.awt.Component component, int width, int height)
{
this.component = component;
bitmap = new Bitmap(width, height);
this.width = width;
this.height = height;
using (Graphics g = Graphics.FromImage(bitmap))
{
g.Clear(Color.White);
}
}
internal NetVolatileImage(int width, int height) : this(null, width, height)
{
}
public override bool contentsLost()
{
return false;
}
private java.awt.Color getForeground()
{
if (component != null)
{
return component.getForeground();
}
else
{
return java.awt.Color.black;
}
}
private java.awt.Color getBackground()
{
if (component != null)
{
return component.getBackground();
}
else
{
return java.awt.Color.white;
}
}
private java.awt.Font getFont()
{
if (component != null)
{
return component.getFont();
}
else
{
if (defaultFont == null)
{
defaultFont = new java.awt.Font("Dialog", java.awt.Font.PLAIN, 12);
}
return defaultFont;
}
}
public override int getHeight(ImageObserver io)
{
return height; // bitmap.Height --> need invoke or lock
}
public override int getWidth(ImageObserver io)
{
return width; // bitmap.Width --> need invoke or lock
}
public override object getProperty(string str, ImageObserver io)
{
throw new NotImplementedException();
}
public override java.awt.Graphics2D createGraphics()
{
//Graphics g = Graphics.FromImage(bitmap);
// HACK for off-screen images we don't want ClearType or anti-aliasing
// TODO I'm sure Java 2D has a way to control text rendering quality, we should honor that
//g.TextRenderingHint = System.Drawing.Text.TextRenderingHint.SingleBitPerPixelGridFit;
return new BitmapGraphics(bitmap, getFont(), J2C.ConvertColor(getForeground()), J2C.ConvertColor(getBackground()));
}
public override int getHeight()
{
return height; // bitmap.Height --> need invoke or lock
}
public override int getWidth()
{
return width; // bitmap.Width --> need invoke or lock
}
public override BufferedImage getSnapshot()
{
return new BufferedImage(bitmap);
}
public override int validate(java.awt.GraphicsConfiguration gc)
{
return 0;
}
public override java.awt.ImageCapabilities getCapabilities()
{
throw new NotImplementedException();
}
public override void flush()
{
}
}
class NoImage : java.awt.Image
{
private sun.awt.image.InputStreamImageSource source;
internal NoImage(sun.awt.image.InputStreamImageSource source) {
this.source = source;
}
public override int getWidth(java.awt.image.ImageObserver observer)
{
if (observer != null)
{
observer.imageUpdate(this, java.awt.image.ImageObserver.__Fields.ERROR | java.awt.image.ImageObserver.__Fields.ABORT, 0, 0, -1, -1);
}
return -1;
}
public override int getHeight(java.awt.image.ImageObserver observer)
{
if (observer != null)
{
observer.imageUpdate(this, java.awt.image.ImageObserver.__Fields.ERROR | java.awt.image.ImageObserver.__Fields.ABORT, 0, 0, -1, -1);
}
return -1;
}
public override ImageProducer getSource()
{
return source;
}
public override java.awt.Graphics getGraphics()
{
// TODO throw java.lang.IllegalAccessError: getGraphics() only valid for images created with createImage(w, h)
return null;
}
public override object getProperty(string name, java.awt.image.ImageObserver observer)
{
if (observer != null)
{
observer.imageUpdate(this, java.awt.image.ImageObserver.__Fields.ERROR | java.awt.image.ImageObserver.__Fields.ABORT, 0, 0, -1, -1);
}
return null;
}
public override void flush()
{
}
}
}

File diff suppressed because it is too large Load Diff

View File

@@ -1,335 +0,0 @@
/*
Copyright (C) 2009 Volker Berlin (i-net software)
Copyright (C) 2010 Karsten Heinrich (i-net software)
This software is provided 'as-is', without any express or implied
warranty. In no event will the authors be held liable for any damages
arising from the use of this software.
Permission is granted to anyone to use this software for any purpose,
including commercial applications, and to alter it and redistribute it
freely, subject to the following restrictions:
1. The origin of this software must not be misrepresented; you must not
claim that you wrote the original software. If you use this software
in a product, an acknowledgment in the product documentation would be
appreciated but is not required.
2. Altered source versions must be plainly marked as such, and must not be
misrepresented as being the original software.
3. This notice may not be removed or altered from any source distribution.
Jeroen Frijters
jeroen@frijters.net
*/
using System;
using System.Runtime.InteropServices;
using Microsoft.Win32.SafeHandles;
using System.Drawing.Printing;
namespace ikvm.awt.printing
{
/// <summary>
/// Base Implementation of the PrintPeer
/// </summary>
abstract class BasePrintPeer : sun.print.PrintPeer
{
public virtual Object getPrinterStatus(String PrinterName, java.lang.Class category)
{
return null;
}
public String getDefaultPrinterName()
{
return new PrinterSettings().PrinterName;
}
public String[] getAllPrinterNames()
{
PrinterSettings.StringCollection printers = PrinterSettings.InstalledPrinters;
String[] result = new String[printers.Count];
printers.CopyTo(result, 0);
return result;
}
public java.awt.Graphics2D createGraphics(System.Drawing.Graphics g)
{
return new PrintGraphics(g);
}
}
/// <summary>
/// Implementation of the PrintPeer for Linux
/// </summary>
class LinuxPrintPeer : BasePrintPeer
{
}
/// <summary>
/// Implementation of the PrintPeer for Windows
/// </summary>
class Win32PrintPeer : BasePrintPeer
{
[StructLayout(LayoutKind.Sequential, CharSet = CharSet.Auto)]
private struct PRINTER_INFO_2
{
[MarshalAs(UnmanagedType.LPTStr)]
public string pServerName;
[MarshalAs(UnmanagedType.LPTStr)]
public string pPrinterName;
[MarshalAs(UnmanagedType.LPTStr)]
public string pShareName;
[MarshalAs(UnmanagedType.LPTStr)]
public string pPortName;
[MarshalAs(UnmanagedType.LPTStr)]
public string pDriverName;
[MarshalAs(UnmanagedType.LPTStr)]
public string pComment;
[MarshalAs(UnmanagedType.LPTStr)]
public string pLocation;
public IntPtr pDevMode;
[MarshalAs(UnmanagedType.LPTStr)]
public string pSepFile;
[MarshalAs(UnmanagedType.LPTStr)]
public string pPrintProcessor;
[MarshalAs(UnmanagedType.LPTStr)]
public string pDatatype;
[MarshalAs(UnmanagedType.LPTStr)]
public string pParameters;
public IntPtr pSecurityDescriptor;
public uint Attributes;
public uint Priority;
public uint DefaultPriority;
public uint StartTime;
public uint UntilTime;
public int Status;
public int cJobs;
public uint AveragePPM;
}
[DllImport("winspool.drv", CharSet = CharSet.Auto, SetLastError = true)]
private static extern bool GetPrinter(SafePrinterHandle hPrinter, int dwLevel, IntPtr pPrinter, int cbBuf, out int pcbNeeded);
[DllImport("winspool.drv", CharSet = CharSet.Auto, SetLastError = true)]
private static extern bool OpenPrinter(string pPrinterName, out SafePrinterHandle hPrinter, IntPtr pDefault);
private const int ERROR_INSUFFICIENT_BUFFER = 122;
private const int PRINTER_STATUS_PAUSED = 0x1;
private const int PRINTER_STATUS_ERROR = 0x2; // MSDN says that this value is not used
private const int PRINTER_STATUS_PENDING_DELETION = 0x4;
private const int PRINTER_STATUS_PAPER_JAM = 0x8;
private const int PRINTER_STATUS_PAPER_OUT = 0x10;
private const int PRINTER_STATUS_MANUAL_FEED = 0x20;
private const int PRINTER_STATUS_PAPER_PROBLEM = 0x40;
private const int PRINTER_STATUS_OFFLINE = 0x80;
private const int PRINTER_STATUS_IO_ACTIVE = 0x100;
private const int PRINTER_STATUS_BUSY = 0x200;
private const int PRINTER_STATUS_PRINTING = 0x400;
private const int PRINTER_STATUS_OUTPUT_BIN_FULL = 0x800;
private const int PRINTER_STATUS_NOT_AVAILABLE = 0x1000;
private const int PRINTER_STATUS_WAITING = 0x2000;
private const int PRINTER_STATUS_PROCESSING = 0x4000;
private const int PRINTER_STATUS_INITIALIZING = 0x8000;
private const int PRINTER_STATUS_WARMING_UP = 0x10000;
private const int PRINTER_STATUS_TONER_LOW = 0x20000;
private const int PRINTER_STATUS_NO_TONER = 0x40000;
private const int PRINTER_STATUS_PAGE_PUNT = 0x80000;
private const int PRINTER_STATUS_USER_INTERVENTION = 0x100000;
private const int PRINTER_STATUS_OUT_OF_MEMORY = 0x200000;
private const int PRINTER_STATUS_DOOR_OPEN = 0x400000;
private const int PRINTER_STATUS_SERVER_UNKNOWN = 0x800000;
private const int PRINTER_STATUS_POWER_SAVE = 0x1000000;
/// <summary>
/// Get a printer status
/// </summary>
/// <param name="printerName">a valid printer name</param>
/// <param name="category">a category that should request</param>
/// <returns>a printer attribute or null</returns>
public override Object getPrinterStatus(String printerName, java.lang.Class category)
{
int cJobs;
int status;
if (GetPrinterInfo2(printerName, out cJobs, out status))
{
if (category == (java.lang.Class)typeof(javax.print.attribute.standard.PrinterState))
{
if ((status &
(PRINTER_STATUS_ERROR | PRINTER_STATUS_NO_TONER | PRINTER_STATUS_OUT_OF_MEMORY |
PRINTER_STATUS_OFFLINE | PRINTER_STATUS_USER_INTERVENTION |
PRINTER_STATUS_DOOR_OPEN | PRINTER_STATUS_NOT_AVAILABLE )) > 0)
{
return javax.print.attribute.standard.PrinterState.STOPPED;
}
if( (status & (PRINTER_STATUS_BUSY | PRINTER_STATUS_PRINTING ))> 0 )
{
return javax.print.attribute.standard.PrinterState.PROCESSING;
}
return null;
// null seems to be the default instead of unknown - UNKOWN ist not used in the reference RT
// javax.print.attribute.standard.PrinterState.UNKNOWN;
}
if (category == (java.lang.Class)typeof(javax.print.attribute.standard.PrinterStateReasons))
{
return extractResions(status);
}
if (category == (java.lang.Class)typeof(javax.print.attribute.standard.QueuedJobCount))
{
return new javax.print.attribute.standard.QueuedJobCount(cJobs);
}
if (category == (java.lang.Class)typeof(javax.print.attribute.standard.PrinterIsAcceptingJobs))
{
if ((status &
(PRINTER_STATUS_ERROR |
PRINTER_STATUS_NO_TONER |
PRINTER_STATUS_OUT_OF_MEMORY |
PRINTER_STATUS_OFFLINE |
PRINTER_STATUS_USER_INTERVENTION |
PRINTER_STATUS_DOOR_OPEN)) > 0)
{
return javax.print.attribute.standard.PrinterIsAcceptingJobs.NOT_ACCEPTING_JOBS;
}
else
{
return javax.print.attribute.standard.PrinterIsAcceptingJobs.ACCEPTING_JOBS;
}
}
}
return null;
}
private javax.print.attribute.standard.PrinterStateReasons extractResions(int status)
{
javax.print.attribute.standard.PrinterStateReasons reasons = new javax.print.attribute.standard.PrinterStateReasons();
if ((status & PRINTER_STATUS_PAUSED) > 0)
{
reasons.put(javax.print.attribute.standard.PrinterStateReason.PAUSED, javax.print.attribute.standard.Severity.REPORT);
}
if ((status & PRINTER_STATUS_ERROR) > 0)
{
reasons.put(javax.print.attribute.standard.PrinterStateReason.OTHER, javax.print.attribute.standard.Severity.ERROR);
}
if ((status & PRINTER_STATUS_PENDING_DELETION) > 0) { }
if ((status & PRINTER_STATUS_PAPER_JAM) > 0)
{
reasons.put(javax.print.attribute.standard.PrinterStateReason.MEDIA_JAM, javax.print.attribute.standard.Severity.WARNING);
}
if ((status & PRINTER_STATUS_PAPER_OUT) > 0)
{
reasons.put(javax.print.attribute.standard.PrinterStateReason.MEDIA_EMPTY, javax.print.attribute.standard.Severity.WARNING);
}
if ((status & PRINTER_STATUS_MANUAL_FEED) > 0) { }
if ((status & PRINTER_STATUS_PAPER_PROBLEM) > 0) {}
if ((status & PRINTER_STATUS_OFFLINE) > 0) {
reasons.put(javax.print.attribute.standard.PrinterStateReason.TIMED_OUT, javax.print.attribute.standard.Severity.ERROR);
}
if ((status & PRINTER_STATUS_IO_ACTIVE) > 0) { }
if ((status & PRINTER_STATUS_BUSY) > 0) { }
if ((status & PRINTER_STATUS_PRINTING) > 0) { }
if ((status & PRINTER_STATUS_OUTPUT_BIN_FULL) > 0) {
reasons.put(javax.print.attribute.standard.PrinterStateReason.OUTPUT_AREA_FULL, javax.print.attribute.standard.Severity.WARNING);
}
if ((status & PRINTER_STATUS_NOT_AVAILABLE) > 0) { }
if ((status & PRINTER_STATUS_WAITING) > 0) { }
if ((status & PRINTER_STATUS_PROCESSING) > 0) { }
if ((status & PRINTER_STATUS_INITIALIZING) > 0) { }
if ((status & PRINTER_STATUS_WARMING_UP) > 0) { }
if ((status & PRINTER_STATUS_TONER_LOW) > 0) {
reasons.put(javax.print.attribute.standard.PrinterStateReason.TONER_LOW, javax.print.attribute.standard.Severity.WARNING);
}
if ((status & PRINTER_STATUS_NO_TONER) > 0) {
reasons.put(javax.print.attribute.standard.PrinterStateReason.TONER_EMPTY, javax.print.attribute.standard.Severity.ERROR);
}
if ((status & PRINTER_STATUS_PAGE_PUNT) > 0) { }
if ((status & PRINTER_STATUS_USER_INTERVENTION) > 0) {
reasons.put(javax.print.attribute.standard.PrinterStateReason.OTHER, javax.print.attribute.standard.Severity.ERROR);
}
if ((status & PRINTER_STATUS_OUT_OF_MEMORY) > 0) {
reasons.put(javax.print.attribute.standard.PrinterStateReason.OTHER, javax.print.attribute.standard.Severity.ERROR);
}
if ((status & PRINTER_STATUS_DOOR_OPEN) > 0) {
reasons.put(javax.print.attribute.standard.PrinterStateReason.DOOR_OPEN, javax.print.attribute.standard.Severity.ERROR);
}
if ((status & PRINTER_STATUS_SERVER_UNKNOWN) > 0) { }
if ((status & PRINTER_STATUS_POWER_SAVE) > 0) {
reasons.put(javax.print.attribute.standard.PrinterStateReason.PAUSED, javax.print.attribute.standard.Severity.REPORT);
}
return reasons.isEmpty() ? null : reasons;
}
/// <summary>
/// Get infos from the PRINTER_INFO_2 struc
/// </summary>
/// <param name="printerName">The name of a valid printer</param>
/// <param name="cJobs">returns the current count of print jobs</param>
/// <param name="status">returns the current status of the printer</param>
/// <returns>true if the return is valid</returns>
[System.Security.SecuritySafeCritical]
private static bool GetPrinterInfo2(string printerName, out int cJobs, out int status)
{
SafePrinterHandle printer = null;
try
{
int needed = 0;
if (OpenPrinter(printerName, out printer, IntPtr.Zero)
&& !GetPrinter(printer, 2, IntPtr.Zero, 0, out needed))
{
int lastWin32Error = Marshal.GetLastWin32Error();
if (lastWin32Error == ERROR_INSUFFICIENT_BUFFER)
{
IntPtr pPrinter = Marshal.AllocHGlobal((int)needed);
try
{
if (GetPrinter(printer, 2, pPrinter, needed, out needed))
{
PRINTER_INFO_2 printerInfo2 = (PRINTER_INFO_2)Marshal.PtrToStructure(pPrinter, typeof(PRINTER_INFO_2));
cJobs = printerInfo2.cJobs;
status = printerInfo2.Status;
return true;
}
}
finally
{
Marshal.FreeHGlobal(pPrinter);
}
}
}
}
finally
{
if (printer != null)
{
printer.Close();
}
}
cJobs = 0;
status = 0;
return false;
}
}
[System.Security.SecurityCritical]
sealed class SafePrinterHandle : SafeHandleZeroOrMinusOneIsInvalid
{
[DllImport("winspool.drv")]
private static extern bool ClosePrinter(IntPtr hPrinter);
private SafePrinterHandle()
: base(true)
{
}
[System.Security.SecurityCritical]
protected override bool ReleaseHandle()
{
return ClosePrinter(handle);
}
}
class Win32Print
{
}
}

View File

@@ -1,404 +0,0 @@
/*
Copyright (C) 2007 Volker Berlin
This software is provided 'as-is', without any express or implied
warranty. In no event will the authors be held liable for any damages
arising from the use of this software.
Permission is granted to anyone to use this software for any purpose,
including commercial applications, and to alter it and redistribute it
freely, subject to the following restrictions:
1. The origin of this software must not be misrepresented; you must not
claim that you wrote the original software. If you use this software
in a product, an acknowledgment in the product documentation would be
appreciated but is not required.
2. Altered source versions must be plainly marked as such, and must not be
misrepresented as being the original software.
3. This notice may not be removed or altered from any source distribution.
Jeroen Frijters
jeroen@frijters.net
*/
using System;
using System.Drawing;
using System.Runtime.InteropServices;
using System.Windows.Forms;
using java.awt.peer;
using java.awt.@event;
namespace ikvm.awt
{
internal class WindowsRobot : RobotPeer
{
internal WindowsRobot(java.awt.GraphicsDevice device)
{
}
public void dispose()
{
}
public int getRGBPixel(int x, int y)
{
Bitmap bitmap = new Bitmap(1, 1);
Graphics g = Graphics.FromImage(bitmap);
g.CopyFromScreen( x, y, 0, 0, new Size(1,1));
g.Dispose();
Color color = bitmap.GetPixel(0,0);
bitmap.Dispose();
return color.ToArgb();
}
public int[] getRGBPixels(java.awt.Rectangle r)
{
int width = r.width;
int height = r.height;
Bitmap bitmap = new Bitmap(width, height);
Graphics g = Graphics.FromImage(bitmap);
g.CopyFromScreen(r.x, r.y, 0, 0, new Size(width, height));
g.Dispose();
int[] pixels = new int[width * height];
for (int i = 0; i < width; i++)
{
for (int j = 0; j < height; j++)
{
pixels[i+j*width] = bitmap.GetPixel(i, j).ToArgb();
}
}
bitmap.Dispose();
return pixels;
}
private byte MapKeyCode(int keyCode)
{
//TODO there need a keymap for some special chars
//http://msdn.microsoft.com/library/default.asp?url=/library/en-us/winui/WinUI/WindowsUserInterface/UserInput/VirtualKeyCodes.asp
switch (keyCode)
{
case KeyEvent.VK_DELETE:
return VK_DELETE;
default:
return (byte)keyCode;
}
}
public void keyPress(int keycode)
{
keybd_event(MapKeyCode(keycode), 0, KEYEVENTF_KEYDOWN, IntPtr.Zero);
}
public void keyRelease(int keycode)
{
keybd_event(MapKeyCode(keycode), 0, KEYEVENTF_KEYUP, IntPtr.Zero);
}
public void mouseMove(int x, int y)
{
Cursor.Position = new Point(x,y);
}
public void mousePress(int button)
{
int dwFlags = 0;
switch (button)
{
case InputEvent.BUTTON1_MASK:
dwFlags |= MOUSEEVENTF_LEFTDOWN;
break;
case InputEvent.BUTTON2_MASK:
dwFlags |= MOUSEEVENTF_MIDDLEDOWN;
break;
case InputEvent.BUTTON3_MASK:
dwFlags |= MOUSEEVENTF_RIGHTDOWN;
break;
}
mouse_event(dwFlags, 0, 0, 0, IntPtr.Zero);
}
public void mouseRelease(int button)
{
int dwFlags = 0;
switch (button)
{
case InputEvent.BUTTON1_MASK:
dwFlags |= MOUSEEVENTF_LEFTUP;
break;
case InputEvent.BUTTON2_MASK:
dwFlags |= MOUSEEVENTF_MIDDLEUP;
break;
case InputEvent.BUTTON3_MASK:
dwFlags |= MOUSEEVENTF_RIGHTUP;
break;
}
mouse_event(dwFlags, 0, 0, 0, IntPtr.Zero);
}
public void mouseWheel(int wheel)
{
mouse_event(0, 0, 0, wheel, IntPtr.Zero);
}
[DllImport("user32.dll")]
private static extern void keybd_event(byte vk, byte scan, int flags, IntPtr extrainfo);
private const int KEYEVENTF_KEYDOWN = 0x0000;
private const int KEYEVENTF_KEYUP = 0x0002;
[DllImport("user32.dll")]
private static extern void mouse_event(
int dwFlags, // motion and click options
int dx, // horizontal position or change
int dy, // vertical position or change
int dwData, // wheel movement
IntPtr dwExtraInfo // application-defined information
);
private const int MOUSEEVENTF_LEFTDOWN = 0x0002;
private const int MOUSEEVENTF_LEFTUP = 0x0004;
private const int MOUSEEVENTF_RIGHTDOWN = 0x0008;
private const int MOUSEEVENTF_RIGHTUP = 0x0010;
private const int MOUSEEVENTF_MIDDLEDOWN = 0x0020;
private const int MOUSEEVENTF_MIDDLEUP = 0x0040;
private const int VK_BACK = 0x08;
private const int VK_TAB = 0x09;
/*
* 0x0A - 0x0B : reserved
*/
private const int VK_CLEAR = 0x0C;
private const int VK_RETURN = 0x0D;
private const int VK_SHIFT = 0x10;
private const int VK_CONTROL = 0x11;
private const int VK_MENU = 0x12;
private const int VK_PAUSE = 0x13;
private const int VK_CAPITAL = 0x14;
private const int VK_KANA = 0x15;
private const int VK_HANGEUL = 0x15; /* old name - should be here for compatibility */
private const int VK_HANGUL = 0x15;
private const int VK_JUNJA = 0x17;
private const int VK_FINAL = 0x18;
private const int VK_HANJA = 0x19;
private const int VK_KANJI = 0x19;
private const int VK_ESCAPE = 0x1B;
private const int VK_CONVERT = 0x1C;
private const int VK_NONCONVERT = 0x1D;
private const int VK_ACCEPT = 0x1E;
private const int VK_MODECHANGE = 0x1F;
private const int VK_SPACE = 0x20;
private const int VK_PRIOR = 0x21;
private const int VK_NEXT = 0x22;
private const int VK_END = 0x23;
private const int VK_HOME = 0x24;
private const int VK_LEFT = 0x25;
private const int VK_UP = 0x26;
private const int VK_RIGHT = 0x27;
private const int VK_DOWN = 0x28;
private const int VK_SELECT = 0x29;
private const int VK_PRINT = 0x2A;
private const int VK_EXECUTE = 0x2B;
private const int VK_SNAPSHOT = 0x2C;
private const int VK_INSERT = 0x2D;
private const int VK_DELETE = 0x2E;
private const int VK_HELP = 0x2F;
/*
* VK_0 - VK_9 are the same as ASCII '0' - '9' (0x30 - 0x39)
* 0x40 : unassigned
* VK_A - VK_Z are the same as ASCII 'A' - 'Z' (0x41 - 0x5A)
*/
private const int VK_LWIN = 0x5B;
private const int VK_RWIN = 0x5C;
private const int VK_APPS = 0x5D;
/*
* 0x5E : reserved
*/
private const int VK_SLEEP = 0x5F;
private const int VK_NUMPAD0 = 0x60;
private const int VK_NUMPAD1 = 0x61;
private const int VK_NUMPAD2 = 0x62;
private const int VK_NUMPAD3 = 0x63;
private const int VK_NUMPAD4 = 0x64;
private const int VK_NUMPAD5 = 0x65;
private const int VK_NUMPAD6 = 0x66;
private const int VK_NUMPAD7 = 0x67;
private const int VK_NUMPAD8 = 0x68;
private const int VK_NUMPAD9 = 0x69;
private const int VK_MULTIPLY = 0x6A;
private const int VK_ADD = 0x6B;
private const int VK_SEPARATOR = 0x6C;
private const int VK_SUBTRACT = 0x6D;
private const int VK_DECIMAL = 0x6E;
private const int VK_DIVIDE = 0x6F;
private const int VK_F1 = 0x70;
private const int VK_F2 = 0x71;
private const int VK_F3 = 0x72;
private const int VK_F4 = 0x73;
private const int VK_F5 = 0x74;
private const int VK_F6 = 0x75;
private const int VK_F7 = 0x76;
private const int VK_F8 = 0x77;
private const int VK_F9 = 0x78;
private const int VK_F10 = 0x79;
private const int VK_F11 = 0x7A;
private const int VK_F12 = 0x7B;
private const int VK_F13 = 0x7C;
private const int VK_F14 = 0x7D;
private const int VK_F15 = 0x7E;
private const int VK_F16 = 0x7F;
private const int VK_F17 = 0x80;
private const int VK_F18 = 0x81;
private const int VK_F19 = 0x82;
private const int VK_F20 = 0x83;
private const int VK_F21 = 0x84;
private const int VK_F22 = 0x85;
private const int VK_F23 = 0x86;
private const int VK_F24 = 0x87;
/*
* 0x88 - 0x8F : unassigned
*/
private const int VK_NUMLOCK = 0x90;
private const int VK_SCROLL = 0x91;
/*
* NEC PC-9800 kbd definitions
*/
private const int VK_OEM_NEC_EQUAL = 0x92; // '=' key on numpad
/*
* Fujitsu/OASYS kbd definitions
*/
private const int VK_OEM_FJ_JISHO = 0x92; // 'Dictionary' key
private const int VK_OEM_FJ_MASSHOU= 0x93; // 'Unregister word' key
private const int VK_OEM_FJ_TOUROKU= 0x94; // 'Register word' key
private const int VK_OEM_FJ_LOYA = 0x95; // 'Left OYAYUBI' key
private const int VK_OEM_FJ_ROYA = 0x96; // 'Right OYAYUBI' key
/*
* 0x97 - 0x9F : unassigned
*/
/*
* VK_L* & VK_R* - left and right Alt, Ctrl and Shift virtual keys.
* Used only as parameters to GetAsyncKeyState() and GetKeyState().
* No other API or message will distinguish left and right keys in this way.
*/
private const int VK_LSHIFT = 0xA0;
private const int VK_RSHIFT = 0xA1;
private const int VK_LCONTROL = 0xA2;
private const int VK_RCONTROL = 0xA3;
private const int VK_LMENU = 0xA4;
private const int VK_RMENU = 0xA5;
private const int VK_BROWSER_BACK = 0xA6;
private const int VK_BROWSER_FORWARD = 0xA7;
private const int VK_BROWSER_REFRESH = 0xA8;
private const int VK_BROWSER_STOP = 0xA9;
private const int VK_BROWSER_SEARCH = 0xAA;
private const int VK_BROWSER_FAVORITES = 0xAB;
private const int VK_BROWSER_HOME = 0xAC;
private const int VK_VOLUME_MUTE = 0xAD;
private const int VK_VOLUME_DOWN = 0xAE;
private const int VK_VOLUME_UP = 0xAF;
private const int VK_MEDIA_NEXT_TRACK = 0xB0;
private const int VK_MEDIA_PREV_TRACK = 0xB1;
private const int VK_MEDIA_STOP = 0xB2;
private const int VK_MEDIA_PLAY_PAUSE = 0xB3;
private const int VK_LAUNCH_MAIL = 0xB4;
private const int VK_LAUNCH_MEDIA_SELECT= 0xB5;
private const int VK_LAUNCH_APP1 = 0xB6;
private const int VK_LAUNCH_APP2 = 0xB7;
/*
* 0xB8 - 0xB9 : reserved
*/
private const int VK_OEM_1 = 0xBA; // ';:' for US
private const int VK_OEM_PLUS = 0xBB; // '+' any country
private const int VK_OEM_COMMA = 0xBC; // ',' any country
private const int VK_OEM_MINUS = 0xBD; // '-' any country
private const int VK_OEM_PERIOD = 0xBE; // '.' any country
private const int VK_OEM_2 = 0xBF; // '/?' for US
private const int VK_OEM_3 = 0xC0; // '`~' for US
/*
* 0xC1 - 0xD7 : reserved
*/
/*
* 0xD8 - 0xDA : unassigned
*/
private const int VK_OEM_4 = 0xDB; // '[{' for US
private const int VK_OEM_5 = 0xDC; // '\|' for US
private const int VK_OEM_6 = 0xDD; // ']}' for US
private const int VK_OEM_7 = 0xDE; // ''"' for US
private const int VK_OEM_8 = 0xDF;
/*
* 0xE0 : reserved
*/
/*
* Various extended or enhanced keyboards
*/
private const int VK_OEM_AX = 0xE1; // 'AX' key on Japanese AX kbd
private const int VK_OEM_102 = 0xE2; // "<>" or "\|" on RT 102-key kbd.
private const int VK_ICO_HELP = 0xE3; // Help key on ICO
private const int VK_ICO_00 = 0xE4; // 00 key on ICO
/*
* 0xE8 : unassigned
*/
/*
* Nokia/Ericsson definitions
*/
private const int VK_OEM_RESET = 0xE9;
private const int VK_OEM_JUMP = 0xEA;
private const int VK_OEM_PA1 = 0xEB;
private const int VK_OEM_PA2 = 0xEC;
private const int VK_OEM_PA3 = 0xED;
private const int VK_OEM_WSCTRL = 0xEE;
private const int VK_OEM_CUSEL = 0xEF;
private const int VK_OEM_ATTN = 0xF0;
private const int VK_OEM_FINISH = 0xF1;
private const int VK_OEM_COPY = 0xF2;
private const int VK_OEM_AUTO = 0xF3;
private const int VK_OEM_ENLW = 0xF4;
private const int VK_OEM_BACKTAB = 0xF5;
private const int VK_ATTN = 0xF6;
private const int VK_CRSEL = 0xF7;
private const int VK_EXSEL = 0xF8;
private const int VK_EREOF = 0xF9;
private const int VK_PLAY = 0xFA;
private const int VK_ZOOM = 0xFB;
private const int VK_NONAME = 0xFC;
private const int VK_PA1 = 0xFD;
private const int VK_OEM_CLEAR = 0xFE;
}
}

View File

@@ -1,94 +0,0 @@
/*
Copyright (C) 2012 Jeroen Frijters
This software is provided 'as-is', without any express or implied
warranty. In no event will the authors be held liable for any damages
arising from the use of this software.
Permission is granted to anyone to use this software for any purpose,
including commercial applications, and to alter it and redistribute it
freely, subject to the following restrictions:
1. The origin of this software must not be misrepresented; you must not
claim that you wrote the original software. If you use this software
in a product, an acknowledgment in the product documentation would be
appreciated but is not required.
2. Altered source versions must be plainly marked as such, and must not be
misrepresented as being the original software.
3. This notice may not be removed or altered from any source distribution.
Jeroen Frijters
jeroen@frijters.net
*/
using System;
using System.IO;
using System.Threading;
using System.Runtime.InteropServices;
using System.Security;
sealed class ThemingActivationContext : IDisposable
{
private IntPtr cookie;
[SecurityCritical]
public ThemingActivationContext()
{
if (Context.hActCtx != IntPtr.Zero)
{
IntPtr tmp;
if (ActivateActCtx(Context.hActCtx, out tmp))
{
cookie = tmp;
}
}
}
[SecuritySafeCritical]
public void Dispose()
{
IntPtr tmp = Interlocked.Exchange(ref cookie, IntPtr.Zero);
if (tmp != IntPtr.Zero)
{
DeactivateActCtx(0, tmp);
}
}
static class Context
{
internal static readonly IntPtr hActCtx;
[SecurityCritical]
static Context()
{
ACTCTX actctx = new ACTCTX();
actctx.cbSize = Marshal.SizeOf(typeof(ACTCTX));
actctx.lpSource = Path.Combine(RuntimeEnvironment.GetRuntimeDirectory(), "XPThemes.manifest");
IntPtr handle = CreateActCtx(ref actctx);
if (handle != new IntPtr(-1))
{
hActCtx = handle;
}
}
struct ACTCTX
{
internal int cbSize;
internal uint dwFlags;
internal string lpSource;
internal ushort wProcessorArchitecture;
internal ushort wLangId;
internal string lpAssemblyDirectory;
internal string lpResourceName;
internal string lpApplicationName;
}
[DllImport("kernel32.dll")]
extern static IntPtr CreateActCtx(ref ACTCTX actctx);
}
[DllImport("kernel32.dll")]
extern static bool ActivateActCtx(IntPtr hActCtx, out IntPtr lpCookie);
[DllImport("kernel32.dll")]
extern static bool DeactivateActCtx(uint dwFlags, IntPtr lpCookie);
}

View File

@@ -1 +0,0 @@
3326c8c8b604536ceedce48c5646eef4d04d2a8f

View File

@@ -1 +0,0 @@
This directory contains the Windows x64 specific version of JVM.DLL.

View File

@@ -1 +0,0 @@
This directory contains the Windows x86 specific version of JVM.DLL.

View File

@@ -1,15 +0,0 @@
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<assembly xmlns="urn:schemas-microsoft-com:asm.v1" manifestVersion="1.0">
<compatibility xmlns="urn:schemas-microsoft-com:compatibility.v1">
<application>
<!-- Windows 8.1 -->
<supportedOS Id="{1f676c76-80e1-4239-95bb-83d0f6d0da78}"/>
<!-- Windows 8 -->
<supportedOS Id="{4a2f28e3-53b9-4441-ba9c-d69d4a4a6e38}"/>
<!--The ID below indicates application support for Windows 7 -->
<supportedOS Id="{35138b9a-5d96-4fbd-8e2d-a2440225f93a}"/>
<!--The ID below indicates application support for Windows Vista -->
<supportedOS Id="{e2011457-1546-43c5-a5fe-008deee3d3f0}"/>
</application>
</compatibility>
</assembly>

View File

@@ -1,329 +0,0 @@
/*
Copyright (C) 2002, 2003, 2004, 2005, 2006 Jeroen Frijters
This software is provided 'as-is', without any express or implied
warranty. In no event will the authors be held liable for any damages
arising from the use of this software.
Permission is granted to anyone to use this software for any purpose,
including commercial applications, and to alter it and redistribute it
freely, subject to the following restrictions:
1. The origin of this software must not be misrepresented; you must not
claim that you wrote the original software. If you use this software
in a product, an acknowledgment in the product documentation would be
appreciated but is not required.
2. Altered source versions must be plainly marked as such, and must not be
misrepresented as being the original software.
3. This notice may not be removed or altered from any source distribution.
Jeroen Frijters
jeroen@frijters.net
*/
package gnu.java.net.protocol.ikvmres;
import cli.System.Reflection.Assembly;
import java.net.*;
import java.io.*;
class IkvmresURLConnection extends URLConnection
{
private InputStream inputStream;
IkvmresURLConnection(URL url)
{
super(url);
doOutput = false;
}
public void connect() throws IOException
{
if(!connected)
{
String assembly = url.getHost();
String resource = url.getFile();
if(assembly == null || resource == null || !resource.startsWith("/"))
{
throw new MalformedURLException(url.toString());
}
try
{
inputStream = Handler.readResourceFromAssembly(assembly, url.getPort(), resource);
connected = true;
}
catch(cli.System.IO.FileNotFoundException x)
{
throw (IOException)new FileNotFoundException(assembly).initCause(x);
}
catch(cli.System.BadImageFormatException x1)
{
throw (IOException)new IOException().initCause(x1);
}
catch(cli.System.Security.SecurityException x2)
{
throw (IOException)new IOException().initCause(x2);
}
}
}
public InputStream getInputStream() throws IOException
{
if(!connected)
{
connect();
}
return inputStream;
}
public OutputStream getOutputStream() throws IOException
{
throw new IOException("resource URLs are read only");
}
public long getLastModified()
{
return -1;
}
public int getContentLength()
{
return -1;
}
}
public class Handler extends URLStreamHandler
{
private static final String RFC2396_DIGIT = "0123456789";
private static final String RFC2396_LOWALPHA = "abcdefghijklmnopqrstuvwxyz";
private static final String RFC2396_UPALPHA = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";
private static final String RFC2396_ALPHA = RFC2396_LOWALPHA + RFC2396_UPALPHA;
private static final String RFC2396_ALPHANUM = RFC2396_DIGIT + RFC2396_ALPHA;
private static final String RFC2396_MARK = "-_.!~*'()";
private static final String RFC2396_UNRESERVED = RFC2396_ALPHANUM + RFC2396_MARK;
private static final String RFC2396_REG_NAME = RFC2396_UNRESERVED + "$,;:@&=+";
private static final String RFC2396_PCHAR = RFC2396_UNRESERVED + ":@&=+$,";
private static final String RFC2396_SEGMENT = RFC2396_PCHAR + ";";
private static final String RFC2396_PATH_SEGMENTS = RFC2396_SEGMENT + "/";
static InputStream readResourceFromAssembly(String assembly, int port, String resource)
throws cli.System.IO.FileNotFoundException,
cli.System.BadImageFormatException,
cli.System.Security.SecurityException,
IOException
{
if(assembly.equals("gen") && port != -1 && resource.endsWith(".class") && resource.indexOf('.') == resource.length() - 6)
{
ClassLoader loader = GetGenericClassLoaderById(port);
try
{
Class c = Class.forName(resource.substring(1, resource.length() - 6).replace('/', '.'), false, loader);
return new ByteArrayInputStream(GenerateStub(c));
}
catch(ClassNotFoundException _)
{
}
catch(LinkageError _)
{
}
}
return readResourceFromAssembly(LoadAssembly(assembly), resource);
}
public static InputStream readResourceFromAssembly(Assembly asm, String resource)
throws IOException
{
try
{
if(false) throw new cli.System.Security.SecurityException();
if(false) throw new cli.System.IO.FileNotFoundException();
if(false) throw new cli.System.IO.IOException();
return new ikvm.io.InputStreamWrapper(ReadResourceFromAssemblyImpl(asm, resource));
}
catch (cli.System.Security.SecurityException x)
{
throw (IOException)new IOException().initCause(x);
}
catch (cli.System.IO.FileNotFoundException x)
{
if(resource.endsWith(".class") && resource.indexOf('.') == resource.length() - 6)
{
Class c = LoadClassFromAssembly(asm, resource.substring(1, resource.length() - 6).replace('/', '.'));
if(c != null)
{
return new ByteArrayInputStream(GenerateStub(c));
}
}
throw (FileNotFoundException)new FileNotFoundException().initCause(x);
}
catch(cli.System.IO.IOException x)
{
throw (IOException)new IOException().initCause(x);
}
}
private static native byte[] GenerateStub(Class c);
private static native cli.System.IO.Stream ReadResourceFromAssemblyImpl(Assembly asm, String resource);
private static native Class LoadClassFromAssembly(Assembly asm, String className);
private static native Assembly LoadAssembly(String name)
throws cli.System.IO.FileNotFoundException, cli.System.BadImageFormatException, cli.System.Security.SecurityException;
private static native ClassLoader GetGenericClassLoaderById(int id);
protected URLConnection openConnection(URL url) throws IOException
{
return new IkvmresURLConnection(url);
}
protected void parseURL(URL url, String url_string, int start, int end)
{
try
{
// NOTE originally I wanted to use java.net.URI to handling parsing and constructing of these things,
// but it turns out that URI uses regex and that depends on resource loading...
url_string = url_string.substring(start, end);
if(url_string.startsWith("//"))
{
int slash = url_string.indexOf('/', 2);
if(slash == -1)
{
throw new RuntimeException("ikvmres: URLs must contain path");
}
String assembly = unquote(url_string.substring(2, slash));
String file = unquote(url_string.substring(slash));
setURL(url, "ikvmres", assembly, -1, file, null);
}
else if(url_string.startsWith("/"))
{
setURL(url, "ikvmres", url.getHost(), -1, url_string, null);
}
else
{
String[] baseparts = ((cli.System.String)(Object)url.getFile()).Split(new char[] { '/' });
String[] relparts = ((cli.System.String)(Object)url_string).Split(new char[] { '/' });
String[] target = new String[baseparts.length + relparts.length - 1];
for(int i = 1; i < baseparts.length; i++)
{
target[i - 1] = baseparts[i];
}
int p = baseparts.length - 2;
for(int i = 0; i < relparts.length; i++)
{
if(relparts[i].equals("."))
{
}
else if(relparts[i].equals(".."))
{
p = Math.max(0, p - 1);
}
else
{
target[p++] = relparts[i];
}
}
StringBuffer file = new StringBuffer();
for(int i = 0; i < p; i++)
{
file.append('/').append(target[i]);
}
setURL(url, "ikvmres", url.getHost(), -1, file.toString(), null);
}
}
catch(URISyntaxException x)
{
throw new RuntimeException(x.getMessage());
}
}
protected String toExternalForm(URL url)
{
// NOTE originally I wanted to use java.net.URI to handle parsing and constructing of these things,
// but it turns out that URI uses regex and that depends on resource loading...
return "ikvmres://" + quote(url.getHost(), RFC2396_REG_NAME) + quote(url.getFile(), RFC2396_PATH_SEGMENTS);
}
protected InetAddress getHostAddress(URL url)
{
return null;
}
private static String quote (String str, String legalCharacters)
{
StringBuffer sb = new StringBuffer(str.length());
for (int i = 0; i < str.length(); i++)
{
char c = str.charAt(i);
if (legalCharacters.indexOf(c) == -1)
{
String hex = "0123456789ABCDEF";
if (c <= 127)
{
sb.append('%')
.append(hex.charAt(c / 16))
.append(hex.charAt(c % 16));
}
else
{
try
{
// this is far from optimal, but it works
byte[] utf8 = str.substring(i, i + 1).getBytes("utf-8");
for (int j = 0; j < utf8.length; j++)
{
sb.append('%')
.append(hex.charAt((utf8[j] & 0xff) / 16))
.append(hex.charAt((utf8[j] & 0xff) % 16));
}
}
catch (java.io.UnsupportedEncodingException x)
{
throw (Error)new InternalError().initCause(x);
}
}
}
else
{
sb.append(c);
}
}
return sb.toString();
}
private static String unquote (String str)
throws URISyntaxException
{
if (str == null)
return null;
byte[] buf = new byte[str.length()];
int pos = 0;
for (int i = 0; i < str.length(); i++)
{
char c = str.charAt(i);
if (c > 127)
throw new URISyntaxException(str, "Invalid character");
if (c == '%')
{
if (i + 2 >= str.length())
throw new URISyntaxException(str, "Invalid quoted character");
String hex = "0123456789ABCDEF";
int hi = hex.indexOf(str.charAt(++i));
int lo = hex.indexOf(str.charAt(++i));
if (lo < 0 || hi < 0)
throw new URISyntaxException(str, "Invalid quoted character");
buf[pos++] = (byte)(hi * 16 + lo);
}
else
{
buf[pos++] = (byte)c;
}
}
try
{
return new String(buf, 0, pos, "utf-8");
}
catch (java.io.UnsupportedEncodingException x2)
{
throw (Error)new InternalError().initCause(x2);
}
}
}

File diff suppressed because it is too large Load Diff

Some files were not shown because too many files have changed in this diff Show More