IterationChanged exception is not a option

--- Sharpex.GameLibrary/Framework/Game/Timing/GameLoop.cs
+++ Sharpex.GameLibrary/Framework/Game/Timing/GameLoop.cs
@@ -133,8 +133,9 @@
                     for (var i = 1; i <= lostFrames; i++)
                     {
                         //Process a tick in every subscriber
-                        foreach (var subscriber in _subscribers)
+                        for (int index = 0; index < _subscribers.Count; index++)
                         {
+                            var subscriber = _subscribers[index];
                             subscriber.Tick(_updateTime);
                         }
                     }
@@ -145,8 +146,9 @@
                 }
                 sw.Start();
                 //Process a tick in every subscriber
-                foreach (var subscriber in _subscribers)
-                {
+                for (var index = 0; index < _subscribers.Count; index++)
+                {
+                    var subscriber = _subscribers[index];
                     subscriber.Tick(_updateTime);
                 }
                 sw.Stop();
@@ -175,15 +177,18 @@
             while (!_cancelFlag)
             {
                 sw.Start();
+                SGL.CurrentRenderer.Begin();
                 //Only render, if the rendering is not suppressed
                 if (!_suppressRender)
                 {
                     //Process a render in every subscriber
-                    foreach (var subscriber in _subscribers)
-                    {
+                    for (int index = 0; index < _subscribers.Count; index++)
+                    {
+                        var subscriber = _subscribers[index];
                         subscriber.Render(SGL.CurrentRenderer, _renderTime);
                     }
                 }
+                SGL.CurrentRenderer.Close();
                 if (SGL.CurrentRenderer.VSync)
                 {
                     if (sw.ElapsedMilliseconds < 15)


Obtain the default window handle from process

Also added a property which indicates whether the handle of the
RenderTarget is still valid.

--- Sharpex.GameLibrary/Framework/Surface/RenderTarget.cs
+++ Sharpex.GameLibrary/Framework/Surface/RenderTarget.cs
@@ -1,4 +1,5 @@
 using System;
+using System.Runtime.InteropServices;
 using System.Windows.Forms;
 using SharpexGL.Framework.Components;

@@ -15,6 +16,19 @@
         {
             get { return new Guid("0F73D6D0-7CE8-4A77-A184-BE93E77E86B5"); }
         }
+
+        #endregion
+
+        #region WinApi
+
+        /// <summary>
+        /// A value indicating whether the Window is valid.
+        /// </summary>
+        /// <param name="hWnd">The Handle.</param>
+        /// <returns>True if window is valid</returns>
+        [DllImport("user32.dll")]
+        [return: MarshalAs(UnmanagedType.Bool)]
+        private static extern bool IsWindow(IntPtr hWnd);

         #endregion

@@ -44,6 +58,13 @@
             get { return ((WindowController) SurfaceControl).IsFullscreen(); }
         }
         /// <summary>
+        /// A value indicating whether the RenderTarget is valid.
+        /// </summary>
+        public bool IsValid
+        {
+            get { return IsWindow(Handle); }
+        }
+        /// <summary>
         /// Create a new RenderTarget from a specified handle.
         /// </summary>
         /// <param name="handle">The Handle.</param>
@@ -57,5 +78,20 @@

             throw new InvalidOperationException("The given Handle is not a window.");
         }
+        /// <summary>
+        /// Gets the RenderTarget associated with the current process.
+        /// </summary>
+        /// <returns>RenderTarget</returns>
+        public static RenderTarget GetDefault()
+        {
+            var handle = System.Diagnostics.Process.GetCurrentProcess().MainWindowHandle;
+
+            if (Control.FromHandle(handle) is Form)
+            {
+                return new RenderTarget(handle);
+            }
+
+            throw new InvalidOperationException("Could not get the handle associated with the current process.");
+        }
     }
 }


Update to fix for breaking changes in ISecurityProvider API in GSF.

--- Source/Applications/SIEGateManager/MainWindow.xaml.cs
+++ Source/Applications/SIEGateManager/MainWindow.xaml.cs
@@ -26,7 +26,6 @@
 using System.Collections.ObjectModel;
 using System.Diagnostics;
 using System.Net;
-using System.Threading;
 using System.Windows;
 using System.Windows.Controls;
 using System.Windows.Media;
@@ -91,11 +90,9 @@
             Title = ((App)Application.Current).Title;
             TextBoxTitle.Text = AssemblyInfo.EntryAssembly.Title;

-            CommonFunctions.CurrentUser = Thread.CurrentPrincipal.Identity.Name;
-            CommonFunctions.CurrentPrincipal = Thread.CurrentPrincipal as SecurityPrincipal;
-
-            if (!string.IsNullOrEmpty(CommonFunctions.CurrentUser))
-                Title += " - " + SecurityProviderCache.CurrentProvider.UserData.LoginID;
+            CommonFunctions.CurrentUser = SecurityPrincipal.Identity.Name;
+            CommonFunctions.CurrentPrincipal = SecurityPrincipal;
+            Title += " - " + SecurityPrincipal.Identity.Provider.UserData.LoginID;

             ConfigurationFile configFile = ConfigurationFile.Current;
             CategorizedSettingsElementCollection configSettings = configFile.Settings["systemSettings"];


Added DebuggerDisplay to PolicyMethodBinding

--- Source/Miruken/Callback/Policy/PolicyMethodBinding.cs
+++ Source/Miruken/Callback/Policy/PolicyMethodBinding.cs
@@ -1,6 +1,7 @@
 namespace Miruken.Callback.Policy
 {
     using System;
+    using System.Diagnostics;
     using System.Linq;

     public delegate PolicyMethodBinding BindMethodDelegate(
@@ -29,6 +30,7 @@
         public CategoryAttribute Category       { get; }
     }

+    [DebuggerDisplay("{" + nameof(DebuggerDisplay) + ",nq}")]
     public class PolicyMethodBinding : MethodBinding
     {
         public PolicyMethodBinding(CallbackPolicy policy,
@@ -197,5 +199,14 @@
             callbackType = callback.GetType();
             return callback;
         }
+
+        private string DebuggerDisplay
+        {
+            get
+            {
+                var category = Category.GetType().Name.Replace("Attribute", "");
+                return $"{category} | {Dispatcher.Method}";
+            }
+        }
     }
 }


Enhance increment/decrement brigtness functions

--- Source/Monitorian.Core/ViewModels/MonitorViewModel.cs
+++ Source/Monitorian.Core/ViewModels/MonitorViewModel.cs
@@ -105,11 +105,22 @@
 			}
 		}

-		public void IncrementBrightness()
+		public void IncrementBrightness() => IncrementBrightness(10);
+
+		public void IncrementBrightness(int tickSize, bool isCycle = true)
 		{
-			int brightness = (int)Math.Floor(Brightness / 10D) * 10 + 10;
+			int brightness = (Brightness / tickSize) * tickSize + tickSize;
 			if (100 < brightness)
-				brightness = 0;
+				brightness = isCycle ? 0 : 100;
+
+			SetBrightness(brightness);
+		}
+
+		public void DecrementBrightness(int tickSize, bool isCycle = true)
+		{
+			int brightness = (Brightness / tickSize) * tickSize - tickSize;
+			if (brightness < 0)
+				brightness = isCycle ? 100 : 0;

 			SetBrightness(brightness);
 		}


Database Initialization should create the single stickersalesperiod-object

--- Source/StickEmApp/StickEmApp/Dal/UnitOfWorkManager.cs
+++ Source/StickEmApp/StickEmApp/Dal/UnitOfWorkManager.cs
@@ -4,6 +4,7 @@
 using FluentNHibernate.Cfg.Db;
 using NHibernate;
 using NHibernate.Tool.hbm2ddl;
+using StickEmApp.Entities;

 namespace StickEmApp.Dal
 {
@@ -11,6 +12,8 @@
     {
         public static void Initialize(string databaseFile, DatabaseFileMode mode)
         {
+            var wasDatabaseCreated = false;
+
             _sessionFactory = Fluently.Configure()
                     .Database(
                         SQLiteConfiguration.Standard
@@ -29,9 +32,19 @@
                             // this NHibernate tool takes a configuration (with mapping info in)
                             // and exports a database schema from it
                             new SchemaExport(configuration).Create(false, true);
+                            wasDatabaseCreated = true;
                         }
                     }))
                     .BuildSessionFactory();
+
+            if (wasDatabaseCreated)
+            {
+                using (var session = _sessionFactory.OpenSession())
+                {
+                    session.Save(new StickerSalesPeriod());
+                    session.Flush();
+                }
+            }
         }

         public static void Initialize(ISessionFactory sessionFactory)


minor changes, removed extra parts physics updates on linking nonroot  prims

--- OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs
+++ OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs
@@ -3066,7 +3066,7 @@
             part.LinkNum = linkNum;

             // Compute the new position of this SOP relative to the group position
-            part.OffsetPosition = part.GroupPosition - AbsolutePosition;
+            part.OffsetPosition = newPos - AbsolutePosition;

             // (radams1 20120711: I don't know why part.OffsetPosition is set multiple times.
             //   It would have the affect of setting the physics engine position multiple
@@ -3087,7 +3087,8 @@

             // Since this SOP's state has changed, push those changes into the physics engine
             //    and the simulator.
-            part.UpdatePrimFlags(UsesPhysics, IsTemporary, IsPhantom, IsVolumeDetect, false);
+            // done on caller
+//            part.UpdatePrimFlags(UsesPhysics, IsTemporary, IsPhantom, IsVolumeDetect, false);
         }

         /// <summary>


IntListメソッドを追加。

IntListメソッドを追加。

--- Implem.Pleasanter/Libraries/Requests/Forms.cs
+++ Implem.Pleasanter/Libraries/Requests/Forms.cs
@@ -45,6 +45,14 @@
         public static DateTime DateTime(string key)
         {
             return Data(key).ToDateTime();
+        }
+
+        public static IEnumerable<int> IntList(string name)
+        {
+            return Forms.Data(name)
+                .Split(',')
+                .Select(o => o.ToInt())
+                .Distinct();
         }

         public static IEnumerable<long> LongList(string name)


version

version

--- nMars.RedCode/Properties/VersionInfo.cs
+++ nMars.RedCode/Properties/VersionInfo.cs
@@ -1,8 +1,7 @@
 using System.Reflection;
 [assembly: AssemblyCompany("nMars")]
-[assembly: AssemblyCopyright("Pavel Savara")]
 [assembly: AssemblyProduct("nMars - Corewars MARS for .NET ")]
 [assembly: AssemblyVersion("0.8.3.0")]
 [assembly: AssemblyFileVersion("0.8.3.0")]
-[assembly: AssemblyCopyright("http://sourceforge.net/projects/nmars")]
+[assembly: AssemblyCopyright("Pavel Savara - http://sourceforge.net/projects/nmars")]
 [assembly: AssemblyDescription("http://sourceforge.net/projects/nmars")]


minor: remove mono compiler warning

minor: remove mono compiler warning

--- OpenSim/Services/PresenceService/PresenceService.cs
+++ OpenSim/Services/PresenceService/PresenceService.cs
@@ -54,7 +54,8 @@
         public bool LoginAgent(string userID, UUID sessionID,
                 UUID secureSessionID)
         {
-            PresenceData[] d = m_Database.Get("UserID", userID);
+            //PresenceData[] d = m_Database.Get("UserID", userID);
+            m_Database.Get("UserID", userID);

             PresenceData data = new PresenceData();


Does not compile Updated ContactSolver to revision 218.

--- SourceFiles/Box2DX/Dynamics/Contacts/ContactSolver.cs
+++ SourceFiles/Box2DX/Dynamics/Contacts/ContactSolver.cs
@@ -34,16 +34,14 @@
 #warning "CAS"
 	public class ContactConstraintPoint
 	{
-		public Vec2 LocalAnchor1;
-		public Vec2 LocalAnchor2;
-		public Vec2 R1;
-		public Vec2 R2;
+        public Vec2 LocalPoint;
+		public Vec2 RA;
+		public Vec2 RB;
 		public float NormalImpulse;
 		public float TangentImpulse;
 		public float NormalMass;
 		public float TangentMass;
 		public float EqualizedMass;
-		public float Separation;
 		public float VelocityBias;
 	}

@@ -51,12 +49,16 @@
 	public class ContactConstraint
 	{
 		public ContactConstraintPoint[] Points = new ContactConstraintPoint[Settings.MaxManifoldPoints];
+        public Vec2 LocalPlaneNormal;
+        public Vec2 LocalPoint;
 		public Vec2 Normal;
 		public Mat22 NormalMass;
 		public Mat22 K;
 		public Manifold Manifold;
-		public Body Body1;
-		public Body Body2;
+		public Body BodyA;
+		public Body BodyB;
+        public Manifold.ManifoldType Type;
+        public float Radius;
 		public float Friction;
 		public float Restitution;
 		public int PointCount;
@@ -79,14 +81,14 @@
             _step = step;

             _constraintCount = contactCount;
-            _constraints = (ContactConstraint)m_allocator->Allocate(m_constraintCount * sizeof(b2ContactConstraint));
+            _constraints = new ContactConstraint[_constraintCount];

             for (int i = 0; i < _constraintCount; ++i)
             {
                 Contact contact = contacts[i];

-                Fixture fixtureA = contact._fixtureA;
-                Fixture fixtureB = contact._fixtureB;
+                Fixture fixtureA = contact.GetFixtureA();
+                Fixture fixtureB = contact.GetFixtureB();
                 Shape shapeA = fixtureA.GetShape();
                 Shape shapeB = fixtureB.GetShape();
                 float radiusA = shapeA.Radius;
@@ -103,40 +105,40 @@
                 float wA = bodyA._angularVelocity;
                 float wB = bodyB._angularVelocity;

-                Box2DXDebug.Assert(manifold.m_pointCount > 0);
+                Box2DXDebug.Assert(manifold.PointCount > 0);

                 WorldManifold worldManifold;
-                worldManifold.Initialize(manifold, bodyA._xf, radiusA, bodyB._xf, radiusB);
+                worldManifold.Initialize(manifold, bodyA.GetXForm(), radiusA, bodyB.GetXForm(), radiusB);

                 ContactConstraint cc = _constraints[i];
-                cc.Body1 = bodyA;
-                cc.Body2 = bodyB;
+                cc.BodyA = bodyA;
+                cc.BodyB = bodyB;
                 cc.Manifold = manifold;
-                cc.Normal = worldManifold.m_normal;
-                cc.PointCount = manifold.m_pointCount;
+                cc.Normal = worldManifold.Normal;
+                cc.PointCount = manifold.PointCount;
                 cc.Friction = friction;
                 cc.Restitution = restitution;

-                cc.localPlaneNormal = manifold.m_localPlaneNormal;
-                cc.LocalPoint = manifold.m_localPoint;
+                cc.LocalPlaneNormal = manifold.LocalPlaneNormal;
+                cc.LocalPoint = manifold.LocalPoint;
                 cc.Radius = radiusA + radiusB;
-                cc.Type = manifold.m_type;
+                cc.Type = manifold.Type;

                 for (int j = 0; j < cc.PointCount; ++j)
                 {
-                    ManifoldPoint cp = manifold.m_points + j;
-                    ContactConstraintPoint ccp = cc.points + j;
-
-                    ccp.NormalImpulse = cp.m_normalImpulse;
-                    ccp.TangentImpulse = cp.m_tangentImpulse;
-
-                    ccp.localPoint = cp.m_localPoint;
-
-                    ccp.R1 = worldManifold.m_points[j] - bodyA._sweep.C;
-                    ccp.R2 = worldManifold.m_points[j] - bodyB._sweep.C;
-
-                    float rnA = Vec2.Cross(ccp.R1, cc.Normal);
-                    float rnB = Vec2.Cross(ccp.R2, cc.Normal);
+                    ManifoldPoint cp = manifold.Points[j];
+                    ContactConstraintPoint ccp = cc.Points[j];
+
+                    ccp.NormalImpulse = cp.NormalImpulse;
+                    ccp.TangentImpulse = cp.TangentImpulse;
+
+                    ccp.LocalPoint = cp.LocalPoint;
+
+                    ccp.RA = WorldManifold.Points[j] - bodyA._sweep.C;
+                    ccp.RB = WorldManifold.Points[j] - bodyB._sweep.C;
+
+                    float rnA = Vec2.Cross(ccp.RA, cc.Normal);
+                    float rnB = Vec2.Cross(ccp.RB, cc.Normal);
                     rnA *= rnA;
                     rnB *= rnB;

@@ -153,59 +155,59 @@

                     Vec2 tangent = Vec2.Cross(cc.Normal, 1.0f);

-                    float rtA = Vec2.Cross(ccp.R1, tangent);
-                    float rtB = Vec2.Cross(ccp.R2, tangent);
+                    float rtA = Vec2.Cross(ccp.RA, tangent);
+                    float rtB = Vec2.Cross(ccp.RB, tangent);
                     rtA *= rtA;
                     rtB *= rtB;

                     float kTangent = bodyA._invMass + bodyB._invMass + bodyA._invI * rtA + bodyB._invI * rtB;

                     Box2DXDebug.Assert(kTangent > Settings.FLT_EPSILON);
-                    ccp->tangentMass = 1.0f / kTangent;
+                    ccp.TangentMass = 1.0f / kTangent;

                     // Setup a velocity bias for restitution.
-                    ccp->velocityBias = 0.0f;
-                    float32 vRel = b2Dot(cc->normal, vB + b2Cross(wB, ccp->rB) - vA - b2Cross(wA, ccp->rA));
-                    if (vRel < -b2_velocityThreshold)
+                    ccp.VelocityBias = 0.0f;
+                    float vRel = Vec2.Dot(cc.Normal, vB + Vec2.Cross(wB, ccp.RB) - vA - Vec2.Cross(wA, ccp.RA));
+                    if (vRel < -Settings.VelocityThreshold)
                     {
-                        ccp->velocityBias = -cc->restitution * vRel;
+                        ccp.VelocityBias = -cc.Restitution * vRel;
                     }
                 }

                 // If we have two points, then prepare the block solver.
-                if (cc->pointCount == 2)
+                if (cc.PointCount == 2)
                 {
-                    b2ContactConstraintPoint* ccp1 = cc->points + 0;
-                    b2ContactConstraintPoint* ccp2 = cc->points + 1;
-
-                    float32 invMassA = bodyA->m_invMass;
-                    float32 invIA = bodyA->m_invI;
-                    float32 invMassB = bodyB->m_invMass;
-                    float32 invIB = bodyB->m_invI;
-
-                    float32 rn1A = b2Cross(ccp1->rA, cc->normal);
-                    float32 rn1B = b2Cross(ccp1->rB, cc->normal);
-                    float32 rn2A = b2Cross(ccp2->rA, cc->normal);
-                    float32 rn2B = b2Cross(ccp2->rB, cc->normal);
-
-                    float32 k11 = invMassA + invMassB + invIA * rn1A * rn1A + invIB * rn1B * rn1B;
-                    float32 k22 = invMassA + invMassB + invIA * rn2A * rn2A + invIB * rn2B * rn2B;
-                    float32 k12 = invMassA + invMassB + invIA * rn1A * rn2A + invIB * rn1B * rn2B;
+                    ContactConstraintPoint ccp1 = cc.Points[0];
+                    ContactConstraintPoint ccp2 = cc.Points[1];
+
+                    float invMassA = bodyA._invMass;
+                    float invIA = bodyA._invI;
+                    float invMassB = bodyB._invMass;
+                    float invIB = bodyB._invI;
+
+                    float rn1A = Vec2.Cross(ccp1.RA, cc.Normal);
+                    float rn1B = Vec2.Cross(ccp1.RB, cc.Normal);
+                    float rn2A = Vec2.Cross(ccp2.RA, cc.Normal);
+                    float rn2B = Vec2.Cross(ccp2.RB, cc.Normal);
+
+                    float k11 = invMassA + invMassB + invIA * rn1A * rn1A + invIB * rn1B * rn1B;
+                    float k22 = invMassA + invMassB + invIA * rn2A * rn2A + invIB * rn2B * rn2B;
+                    float k12 = invMassA + invMassB + invIA * rn1A * rn2A + invIB * rn1B * rn2B;

                     // Ensure a reasonable condition number.
-                    const float32 k_maxConditionNumber = 100.0f;
+                    const float k_maxConditionNumber = 100.0f;
                     if (k11 * k11 < k_maxConditionNumber * (k11 * k22 - k12 * k12))
                     {
                         // K is safe to invert.
-                        cc->K.col1.Set(k11, k12);
-                        cc->K.col2.Set(k12, k22);
-                        cc->normalMass = cc->K.GetInverse();
+                        cc.K.Col1.Set(k11, k12);
+                        cc.K.Col2.Set(k12, k22);
+                        cc.NormalMass = cc.K.Invert();
                     }
                     else
                     {
                         // The constraints are redundant, just use one.
                         // TODO_ERIN use deepest?
-                        cc->pointCount = 1;
+                        cc.PointCount = 1;
                     }
                 }
             }
@@ -223,8 +225,8 @@
 			{
 				ContactConstraint c = _constraints[i];

-				Body b1 = c.Body1;
-				Body b2 = c.Body2;
+				Body b1 = c.BodyA;
+				Body b2 = c.BodyB;
 				float invMass1 = b1._invMass;
 				float invI1 = b1._invI;
 				float invMass2 = b2._invMass;
@@ -240,9 +242,9 @@
 						ccp.NormalImpulse *= step.DtRatio;
 						ccp.TangentImpulse *= step.DtRatio;
 						Vec2 P = ccp.NormalImpulse * normal + ccp.TangentImpulse * tangent;
-						b1._angularVelocity -= invI1 * Vec2.Cross(ccp.R1, P);
+						b1._angularVelocity -= invI1 * Vec2.Cross(ccp.RA, P);
 						b1._linearVelocity -= invMass1 * P;
-						b2._angularVelocity += invI2 * Vec2.Cross(ccp.R2, P);
+						b2._angularVelocity += invI2 * Vec2.Cross(ccp.RB, P);
 						b2._linearVelocity += invMass2 * P;
 					}
 				}
@@ -263,8 +265,8 @@
 			for (int i = 0; i < _constraintCount; ++i)
 			{
 				ContactConstraint c = _constraints[i];
-				Body b1 = c.Body1;
-				Body b2 = c.Body2;
+				Body b1 = c.BodyA;
+				Body b2 = c.BodyB;
 				float w1 = b1._angularVelocity;
 				float w2 = b2._angularVelocity;
 				Vec2 v1 = b1._linearVelocity;
@@ -279,113 +281,142 @@

 				Box2DXDebug.Assert(c.PointCount == 1 || c.PointCount == 2);

+                // Solve tangent constraints
+                for (int j = 0; j < c.PointCount; ++j)
+                {
+                    ContactConstraintPoint ccp = c.Points[j];
+
+                    // Relative velocity at contact
+                    Vec2 dv = v2 + Vec2.Cross(w2, ccp.RB) - v2 - Vec2.Cross(w1, ccp.RA);
+
+                    // Compute tangent force
+                    float vt = Vec2.Dot(dv, tangent);
+                    float lambda = ccp.TangentMass * (-vt);
+
+                    // b2Clamp the accumulated force
+                    float maxFriction = friction * ccp.NormalImpulse;
+                    float newImpulse = Common.Math.Clamp(ccp.TangentImpulse + lambda, -maxFriction, maxFriction);
+                    lambda = newImpulse - ccp.TangentImpulse;
+
+                    // Apply contact impulse
+                    Vec2 P = lambda * tangent;
+
+                    v1 -= invMass1 * P;
+                    w1 -= invI1 * Vec2.Cross(ccp.RA, P);
+
+                    v2 += invMass2 * P;
+                    w2 += invI2 * Vec2.Cross(ccp.RB, P);
+
+                    ccp.TangentImpulse = newImpulse;
+                }
+
 				// Solve normal constraints
-				if (c.PointCount == 1)
-				{
-					ContactConstraintPoint ccp = c.Points[0];
-
-					// Relative velocity at contact
-					Vec2 dv = v2 + Vec2.Cross(w2, ccp.R2) - v1 - Vec2.Cross(w1, ccp.R1);
-
-					// Compute normal impulse
-					float vn = Vec2.Dot(dv, normal);
-					float lambda = -ccp.NormalMass * (vn - ccp.VelocityBias);
-
-					// Clamp the accumulated impulse
-					float newImpulse = Common.Math.Max(ccp.NormalImpulse + lambda, 0.0f);
-					lambda = newImpulse - ccp.NormalImpulse;
-
-					// Apply contact impulse
-					Vec2 P = lambda * normal;
-
-					v1 -= invMass1 * P;
-					w1 -= invI1 * Vec2.Cross(ccp.R1, P);
-
-					v2 += invMass2 * P;
-					w2 += invI2 * Vec2.Cross(ccp.R2, P);
-
-					ccp.NormalImpulse = newImpulse;
-				}
-				else
-				{
-					// Block solver developed in collaboration with Dirk Gregorius (back in 01/07 on Box2D_Lite).
-					// Build the mini LCP for this contact patch
-					//
-					// vn = A * x + b, vn >= 0, , vn >= 0, x >= 0 and vn_i * x_i = 0 with i = 1..2
-					//
-					// A = J * W * JT and J = ( -n, -r1 x n, n, r2 x n )
-					// b = vn_0 - velocityBias
-					//
-					// The system is solved using the "Total enumeration method" (s. Murty). The complementary constraint vn_i * x_i
-					// implies that we must have in any solution either vn_i = 0 or x_i = 0. So for the 2D contact problem the cases
-					// vn1 = 0 and vn2 = 0, x1 = 0 and x2 = 0, x1 = 0 and vn2 = 0, x2 = 0 and vn1 = 0 need to be tested. The first valid
-					// solution that satisfies the problem is chosen.
-					//
-					// In order to account of the accumulated impulse 'a' (because of the iterative nature of the solver which only requires
-					// that the accumulated impulse is clamped and not the incremental impulse) we change the impulse variable (x_i).
-					//
-					// Substitute:
-					//
-					// x = x' - a
-					//
-					// Plug into above equation:
-					//
-					// vn = A * x + b
-					//    = A * (x' - a) + b
-					//    = A * x' + b - A * a
-					//    = A * x' + b'
-					// b' = b - A * a;
-
-					ContactConstraintPoint cp1 = c.Points[0];
-					ContactConstraintPoint cp2 = c.Points[1];
-
-					Vec2 a = new Vec2(cp1.NormalImpulse, cp2.NormalImpulse);
-					Box2DXDebug.Assert(a.X >= 0.0f && a.Y >= 0.0f);
-
-					// Relative velocity at contact
-					Vec2 dv1 = v2 + Vec2.Cross(w2, cp1.R2) - v1 - Vec2.Cross(w1, cp1.R1);
-					Vec2 dv2 = v2 + Vec2.Cross(w2, cp2.R2) - v1 - Vec2.Cross(w1, cp2.R1);
-
-					// Compute normal velocity
-					float vn1 = Vec2.Dot(dv1, normal);
-					float vn2 = Vec2.Dot(dv2, normal);
-
-					Vec2 b;
-					b.X = vn1 - cp1.VelocityBias;
-					b.Y = vn2 - cp2.VelocityBias;
-					b -= Common.Math.Mul(c.K, a);
-
-					const float k_errorTol = 1e-3f;
-					for (; ; )
-					{
-						//
-						// Case 1: vn = 0
-						//
-						// 0 = A * x' + b'
-						//
-						// Solve for x':
-						//
-						// x' = - inv(A) * b'
-						//
-						Vec2 x = -Common.Math.Mul(c.NormalMass, b);
-
-						if (x.X >= 0.0f && x.Y >= 0.0f)
-						{
-							// Resubstitute for the incremental impulse
-							Vec2 d = x - a;
-
-							// Apply incremental impulse
-							Vec2 P1 = d.X * normal;
-							Vec2 P2 = d.Y * normal;
-							v1 -= invMass1 * (P1 + P2);
-							w1 -= invI1 * (Vec2.Cross(cp1.R1, P1) + Vec2.Cross(cp2.R1, P2));
-
-							v2 += invMass2 * (P1 + P2);
-							w2 += invI2 * (Vec2.Cross(cp1.R2, P1) + Vec2.Cross(cp2.R2, P2));
-
-							// Accumulate
-							cp1.NormalImpulse = x.X;
-							cp2.NormalImpulse = x.Y;
+                if (c.PointCount == 1)
+                {
+                    ContactConstraintPoint ccp = c.Points[0];
+
+                    // Relative velocity at contact
+                    Vec2 dv = v2 + Vec2.Cross(w2, ccp.RB) - v1 - Vec2.Cross(w1, ccp.RA);
+
+                    // Compute normal impulse
+                    float vn = Vec2.Dot(dv, normal);
+                    float lambda = -ccp.NormalMass * (vn - ccp.VelocityBias);
+
+                    // Clamp the accumulated impulse
+                    float newImpulse = Common.Math.Max(ccp.NormalImpulse + lambda, 0.0f);
+                    lambda = newImpulse - ccp.NormalImpulse;
+
+                    // Apply contact impulse
+                    Vec2 P = lambda * normal;
+
+                    v1 -= invMass1 * P;
+                    w1 -= invI1 * Vec2.Cross(ccp.RA, P);
+
+                    v2 += invMass2 * P;
+                    w2 += invI2 * Vec2.Cross(ccp.RB, P);
+
+                    ccp.NormalImpulse = newImpulse;
+                }
+                else
+                {
+                    // Block solver developed in collaboration with Dirk Gregorius (back in 01/07 on Box2D_Lite).
+                    // Build the mini LCP for this contact patch
+                    //
+                    // vn = A * x + b, vn >= 0, , vn >= 0, x >= 0 and vn_i * x_i = 0 with i = 1..2
+                    //
+                    // A = J * W * JT and J = ( -n, -r1 x n, n, r2 x n )
+                    // b = vn_0 - velocityBias
+                    //
+                    // The system is solved using the "Total enumeration method" (s. Murty). The complementary constraint vn_i * x_i
+                    // implies that we must have in any solution either vn_i = 0 or x_i = 0. So for the 2D contact problem the cases
+                    // vn1 = 0 and vn2 = 0, x1 = 0 and x2 = 0, x1 = 0 and vn2 = 0, x2 = 0 and vn1 = 0 need to be tested. The first valid
+                    // solution that satisfies the problem is chosen.
+                    //
+                    // In order to account of the accumulated impulse 'a' (because of the iterative nature of the solver which only requires
+                    // that the accumulated impulse is clamped and not the incremental impulse) we change the impulse variable (x_i).
+                    //
+                    // Substitute:
+                    //
+                    // x = x' - a
+                    //
+                    // Plug into above equation:
+                    //
+                    // vn = A * x + b
+                    //    = A * (x' - a) + b
+                    //    = A * x' + b - A * a
+                    //    = A * x' + b'
+                    // b' = b - A * a;
+
+                    ContactConstraintPoint cp1 = c.Points[0];
+                    ContactConstraintPoint cp2 = c.Points[1];
+
+                    Vec2 a = new Vec2(cp1.NormalImpulse, cp2.NormalImpulse);
+                    Box2DXDebug.Assert(a.X >= 0.0f && a.Y >= 0.0f);
+
+                    // Relative velocity at contact
+                    Vec2 dv1 = v2 + Vec2.Cross(w2, cp1.RB) - v1 - Vec2.Cross(w1, cp1.RA);
+                    Vec2 dv2 = v2 + Vec2.Cross(w2, cp2.RB) - v1 - Vec2.Cross(w1, cp2.RA);
+
+                    // Compute normal velocity
+                    float vn1 = Vec2.Dot(dv1, normal);
+                    float vn2 = Vec2.Dot(dv2, normal);
+
+                    Vec2 b;
+                    b.X = vn1 - cp1.VelocityBias;
+                    b.Y = vn2 - cp2.VelocityBias;
+                    b -= Common.Math.Mul(c.K, a);
+
+                    //const float k_errorTol = 1e-3f;
+                    for (; ; )
+                    {
+                        //
+                        // Case 1: vn = 0
+                        //
+                        // 0 = A * x' + b'
+                        //
+                        // Solve for x':
+                        //
+                        // x' = - inv(A) * b'
+                        //
+                        Vec2 x = -Common.Math.Mul(c.NormalMass, b);
+
+                        if (x.X >= 0.0f && x.Y >= 0.0f)
+                        {
+                            // Resubstitute for the incremental impulse
+                            Vec2 d = x - a;
+
+                            // Apply incremental impulse
+                            Vec2 P1 = d.X * normal;
+                            Vec2 P2 = d.Y * normal;
+                            v1 -= invMass1 * (P1 + P2);
+                            w1 -= invI1 * (Vec2.Cross(cp1.RA, P1) + Vec2.Cross(cp2.RA, P2));
+
+                            v2 += invMass2 * (P1 + P2);
+                            w2 += invI2 * (Vec2.Cross(cp1.RB, P1) + Vec2.Cross(cp2.RB, P2));
+
+                            // Accumulate
+                            cp1.NormalImpulse = x.X;
+                            cp2.NormalImpulse = x.Y;

 #if B2_DEBUG_SOLVER
 							// Postconditions
@@ -399,37 +430,37 @@
 							Box2DXDebug.Assert(Common.Math.Abs(vn1 - cp1.VelocityBias) < k_errorTol);
 							Box2DXDebug.Assert(Common.Math.Abs(vn2 - cp2.VelocityBias) < k_errorTol);
 #endif
-							break;
-						}
-
-						//
-						// Case 2: vn1 = 0 and x2 = 0
-						//
-						//   0 = a11 * x1' + a12 * 0 + b1'
-						// vn2 = a21 * x1' + a22 * 0 + b2'
-						//
-						x.X = -cp1.NormalMass * b.X;
-						x.Y = 0.0f;
-						vn1 = 0.0f;
-						vn2 = c.K.Col1.Y * x.X + b.Y;
-
-						if (x.X >= 0.0f && vn2 >= 0.0f)
-						{
-							// Resubstitute for the incremental impulse
-							Vec2 d = x - a;
-
-							// Apply incremental impulse
-							Vec2 P1 = d.X * normal;
-							Vec2 P2 = d.Y * normal;
-							v1 -= invMass1 * (P1 + P2);
-							w1 -= invI1 * (Vec2.Cross(cp1.R1, P1) + Vec2.Cross(cp2.R1, P2));
-
-							v2 += invMass2 * (P1 + P2);
-							w2 += invI2 * (Vec2.Cross(cp1.R2, P1) + Vec2.Cross(cp2.R2, P2));
-
-							// Accumulate
-							cp1.NormalImpulse = x.X;
-							cp2.NormalImpulse = x.Y;
+                            break;
+                        }
+
+                        //
+                        // Case 2: vn1 = 0 and x2 = 0
+                        //
+                        //   0 = a11 * x1' + a12 * 0 + b1'
+                        // vn2 = a21 * x1' + a22 * 0 + b2'
+                        //
+                        x.X = -cp1.NormalMass * b.X;
+                        x.Y = 0.0f;
+                        vn1 = 0.0f;
+                        vn2 = c.K.Col1.Y * x.X + b.Y;
+
+                        if (x.X >= 0.0f && vn2 >= 0.0f)
+                        {
+                            // Resubstitute for the incremental impulse
+                            Vec2 d = x - a;
+
+                            // Apply incremental impulse
+                            Vec2 P1 = d.X * normal;
+                            Vec2 P2 = d.Y * normal;
+                            v1 -= invMass1 * (P1 + P2);
+                            w1 -= invI1 * (Vec2.Cross(cp1.RA, P1) + Vec2.Cross(cp2.RA, P2));
+
+                            v2 += invMass2 * (P1 + P2);
+                            w2 += invI2 * (Vec2.Cross(cp1.RB, P1) + Vec2.Cross(cp2.RB, P2));
+
+                            // Accumulate
+                            cp1.NormalImpulse = x.X;
+                            cp2.NormalImpulse = x.Y;

 #if B2_DEBUG_SOLVER
 							// Postconditions
@@ -440,38 +471,38 @@

 							Box2DXDebug.Assert(Common.Math.Abs(vn1 - cp1.VelocityBias) < k_errorTol);
 #endif
-							break;
-						}
-
-
-						//
-						// Case 3: w2 = 0 and x1 = 0
-						//
-						// vn1 = a11 * 0 + a12 * x2' + b1'
-						//   0 = a21 * 0 + a22 * x2' + b2'
-						//
-						x.X = 0.0f;
-						x.Y = -cp2.NormalMass * b.Y;
-						vn1 = c.K.Col2.X * x.Y + b.X;
-						vn2 = 0.0f;
-
-						if (x.Y >= 0.0f && vn1 >= 0.0f)
-						{
-							// Resubstitute for the incremental impulse
-							Vec2 d = x - a;
-
-							// Apply incremental impulse
-							Vec2 P1 = d.X * normal;
-							Vec2 P2 = d.Y * normal;
-							v1 -= invMass1 * (P1 + P2);
-							w1 -= invI1 * (Vec2.Cross(cp1.R1, P1) + Vec2.Cross(cp2.R1, P2));
-
-							v2 += invMass2 * (P1 + P2);
-							w2 += invI2 * (Vec2.Cross(cp1.R2, P1) + Vec2.Cross(cp2.R2, P2));
-
-							// Accumulate
-							cp1.NormalImpulse = x.X;
-							cp2.NormalImpulse = x.Y;
+                            break;
+                        }
+
+
+                        //
+                        // Case 3: w2 = 0 and x1 = 0
+                        //
+                        // vn1 = a11 * 0 + a12 * x2' + b1'
+                        //   0 = a21 * 0 + a22 * x2' + b2'
+                        //
+                        x.X = 0.0f;
+                        x.Y = -cp2.NormalMass * b.Y;
+                        vn1 = c.K.Col2.X * x.Y + b.X;
+                        vn2 = 0.0f;
+
+                        if (x.Y >= 0.0f && vn1 >= 0.0f)
+                        {
+                            // Resubstitute for the incremental impulse
+                            Vec2 d = x - a;
+
+                            // Apply incremental impulse
+                            Vec2 P1 = d.X * normal;
+                            Vec2 P2 = d.Y * normal;
+                            v1 -= invMass1 * (P1 + P2);
+                            w1 -= invI1 * (Vec2.Cross(cp1.RA, P1) + Vec2.Cross(cp2.RA, P2));
+
+                            v2 += invMass2 * (P1 + P2);
+                            w2 += invI2 * (Vec2.Cross(cp1.RB, P1) + Vec2.Cross(cp2.RB, P2));
+
+                            // Accumulate
+                            cp1.NormalImpulse = x.X;
+                            cp2.NormalImpulse = x.Y;

 #if B2_DEBUG_SOLVER
 							// Postconditions
@@ -482,73 +513,44 @@

 							Box2DXDebug.Assert(Common.Math.Abs(vn2 - cp2.VelocityBias) < k_errorTol);
 #endif
-							break;
-						}
-
-						//
-						// Case 4: x1 = 0 and x2 = 0
-						//
-						// vn1 = b1
-						// vn2 = b2;
-						x.X = 0.0f;
-						x.Y = 0.0f;
-						vn1 = b.X;
-						vn2 = b.Y;
-
-						if (vn1 >= 0.0f && vn2 >= 0.0f)
-						{
-							// Resubstitute for the incremental impulse
-							Vec2 d = x - a;
-
-							// Apply incremental impulse
-							Vec2 P1 = d.X * normal;
-							Vec2 P2 = d.Y * normal;
-							v1 -= invMass1 * (P1 + P2);
-							w1 -= invI1 * (Vec2.Cross(cp1.R1, P1) + Vec2.Cross(cp2.R1, P2));
-
-							v2 += invMass2 * (P1 + P2);
-							w2 += invI2 * (Vec2.Cross(cp1.R2, P1) + Vec2.Cross(cp2.R2, P2));
-
-							// Accumulate
-							cp1.NormalImpulse = x.X;
-							cp2.NormalImpulse = x.Y;
-
-							break;
-						}
-
-						// No solution, give up. This is hit sometimes, but it doesn't seem to matter.
-						break;
-					}
-				}
-
-				// Solve tangent constraints
-				for (int j = 0; j < c.PointCount; ++j)
-				{
-					ContactConstraintPoint ccp = c.Points[j];
-
-					// Relative velocity at contact
-					Vec2 dv = v2 + Vec2.Cross(w2, ccp.R2) - v1 - Vec2.Cross(w1, ccp.R1);
-
-					// Compute tangent force
-					float vt = Vec2.Dot(dv, tangent);
-					float lambda = ccp.TangentMass * (-vt);
-
-					// Clamp the accumulated force
-					float maxFriction = friction * ccp.NormalImpulse;
-					float newImpulse = Common.Math.Clamp(ccp.TangentImpulse + lambda, -maxFriction, maxFriction);
-					lambda = newImpulse - ccp.TangentImpulse;
-
-					// Apply contact impulse
-					Vec2 P = lambda * tangent;
-
-					v1 -= invMass1 * P;
-					w1 -= invI1 * Vec2.Cross(ccp.R1, P);
-
-					v2 += invMass2 * P;
-					w2 += invI2 * Vec2.Cross(ccp.R2, P);
-
-					ccp.TangentImpulse = newImpulse;
-				}
+                            break;
+                        }
+
+                        //
+                        // Case 4: x1 = 0 and x2 = 0
+                        //
+                        // vn1 = b1
+                        // vn2 = b2;
+                        x.X = 0.0f;
+                        x.Y = 0.0f;
+                        vn1 = b.X;
+                        vn2 = b.Y;
+
+                        if (vn1 >= 0.0f && vn2 >= 0.0f)
+                        {
+                            // Resubstitute for the incremental impulse
+                            Vec2 d = x - a;
+
+                            // Apply incremental impulse
+                            Vec2 P1 = d.X * normal;
+                            Vec2 P2 = d.Y * normal;
+                            v1 -= invMass1 * (P1 + P2);
+                            w1 -= invI1 * (Vec2.Cross(cp1.RA, P1) + Vec2.Cross(cp2.RA, P2));
+
+                            v2 += invMass2 * (P1 + P2);
+                            w2 += invI2 * (Vec2.Cross(cp1.RB, P1) + Vec2.Cross(cp2.RB, P2));
+
+                            // Accumulate
+                            cp1.NormalImpulse = x.X;
+                            cp2.NormalImpulse = x.Y;
+
+                            break;
+                        }
+
+                        // No solution, give up. This is hit sometimes, but it doesn't seem to matter.
+                        break;
+                    }
+                }

 				b1._linearVelocity = v1;
 				b1._angularVelocity = w1;
@@ -572,64 +574,126 @@
 			}
 		}

-#if FIRST
-		public bool SolvePositionConstraints(float baumgarte)
-		{
-			float minSeparation = 0.0f;
-
-			for (int i = 0; i < _constraintCount; ++i)
-			{
-				ContactConstraint c = _constraints[i];
-				Body b1 = c.Body1;
-				Body b2 = c.Body2;
-				float invMass1 = b1._mass * b1._invMass;
-				float invI1 = b1._mass * b1._invI;
-				float invMass2 = b2._mass * b2._invMass;
-				float invI2 = b2._mass * b2._invI;
-
-				Vec2 normal = c.Normal;
-
-				// Solver normal constraints
-				for (int j = 0; j < c.PointCount; ++j)
-				{
-					ContactConstraintPoint ccp = c.Points[j];
-
-					Vec2 r1 = Common.Math.Mul(b1.GetXForm().R, ccp.LocalAnchor1 - b1.GetLocalCenter());
-					Vec2 r2 = Common.Math.Mul(b2.GetXForm().R, ccp.LocalAnchor2 - b2.GetLocalCenter());
-
-					Vec2 p1 = b1._sweep.C + r1;
-					Vec2 p2 = b2._sweep.C + r2;
-					Vec2 dp = p2 - p1;
-
-					// Approximate the current separation.
-					float separation = Vec2.Dot(dp, normal) + ccp.Separation;
-
-					// Track max constraint error.
-					minSeparation = Common.Math.Min(minSeparation, separation);
-
-					// Prevent large corrections and allow slop.
-					float C = baumgarte * Common.Math.Clamp(separation + Settings.LinearSlop, -Settings.MaxLinearCorrection, 0.0f);
-
-					// Compute normal impulse
-					float impulse = -ccp.EqualizedMass * C;
-
-					Vec2 P = impulse * normal;
-
-					b1._sweep.C -= invMass1 * P;
-					b1._sweep.A -= invI1 * Vec2.Cross(r1, P);
-					b1.SynchronizeTransform();
-
-					b2._sweep.C += invMass2 * P;
-					b2._sweep.A += invI2 * Vec2.Cross(r2, P);
-					b2.SynchronizeTransform();
-				}
-			}
-
-			// We can't expect minSpeparation >= -Settings.LinearSlop because we don't
-			// push the separation above -Settings.LinearSlop.
-			return minSeparation >= -1.5f * Settings.LinearSlop;
-		}
+        // Sequential solver.
+        public bool SolvePositionConstraints(float baumgarte)
+        {
+	        float minSeparation = 0.0f;
+
+	        for (int i = 0; i < _constraintCount; ++i)
+	        {
+		        ContactConstraint c = _constraints[i];
+		        Body bodyA = c.BodyA;
+		        Body bodyB = c.BodyB;
+
+		        float invMassA = bodyA._mass * bodyA._invMass;
+		        float invIA = bodyA._mass * bodyA._invI;
+		        float invMassB = bodyB._mass * bodyB._invMass;
+		        float invIB = bodyB._mass * bodyB._invI;
+
+		        PositionSolverManifold psm = new PositionSolverManifold();
+		        psm.Initialize(c);
+		        Vec2 normal = psm.Normal;
+
+		        // Solve normal constraints
+		        for (int j = 0; j < c.PointCount; ++j)
+		        {
+			        ContactConstraintPoint ccp = c.Points[j];
+
+			        Vec2 point = psm.Points[j];
+			        float separation = psm.Separations[j];
+
+			        Vec2 rA = point - bodyA._sweep.C;
+			        Vec2 rB = point - bodyB._sweep.C;
+
+			        // Track max constraint error.
+			        minSeparation = Common.Math.Min(minSeparation, separation);
+
+			        // Prevent large corrections and allow slop.
+			        float C = baumgarte * Common.Math.Clamp(separation + Settings.LinearSlop, -Settings.MaxLinearCorrection, 0.0f);
+
+			        // Compute normal impulse
+			        float impulse = -ccp.EqualizedMass * C;
+
+			        Vec2 P = impulse * normal;
+
+			        bodyA._sweep.C -= invMassA * P;
+			        bodyA._sweep.A -= invIA * Vec2.Cross(rA, P);
+			        bodyA.SynchronizeTransform();
+
+			        bodyB._sweep.C += invMassB * P;
+			        bodyB._sweep.A += invIB * Vec2.Cross(rB, P);
+			        bodyB.SynchronizeTransform();
+		        }
+	        }
+
+	        // We can't expect minSpeparation >= -b2_linearSlop because we don't
+	        // push the separation above -b2_linearSlop.
+	        return minSeparation >= -1.5f * Settings.LinearSlop;
+        }
 	}
-#else
-#endif
+
+    public class PositionSolverManifold
+    {
+	    public void Initialize(ContactConstraint cc)
+	    {
+		    Box2DXDebug.Assert(cc.PointCount > 0);
+
+		    switch (cc.Type)
+		    {
+		    case Manifold.ManifoldType.Circles:
+			    {
+				    Vec2 pointA = cc.BodyA.GetWorldPoint(cc.LocalPoint);
+				    Vec2 pointB = cc.BodyB.GetWorldPoint(cc.Points[0].LocalPoint);
+				    if (Vec2.DistanceSquared(pointA, pointB) > Settings.FLT_EPSILON * Settings.FLT_EPSILON)
+				    {
+					    Normal = pointB - pointA;
+					    Normal.Normalize();
+				    }
+				    else
+				    {
+					    Normal.Set(1.0f, 0.0f);
+				    }
+
+				    Points[0] = 0.5f * (pointA + pointB);
+				    Separations[0] = Vec2.Dot(pointB - pointA, Normal) - cc.Radius;
+			    }
+			    break;
+
+		    case Manifold.ManifoldType.FaceA:
+			    {
+				    Normal = cc.BodyA.GetWorldVector(cc.LocalPlaneNormal);
+				    Vec2 planePoint = cc.BodyA.GetWorldPoint(cc.LocalPoint);
+
+				    for (int i = 0; i < cc.PointCount; ++i)
+				    {
+					    Vec2 clipPoint = cc.BodyB.GetWorldPoint(cc.Points[i].LocalPoint);
+					    Separations[i] = Vec2.Dot(clipPoint - planePoint, Normal) - cc.Radius;
+					    Points[i] = clipPoint;
+				    }
+			    }
+			    break;
+
+		    case Manifold.ManifoldType.FaceB:
+			    {
+				    Normal = cc.BodyB.GetWorldVector(cc.LocalPlaneNormal);
+				    Vec2 planePoint = cc.BodyB.GetWorldPoint(cc.LocalPoint);
+
+				    for (int i = 0; i < cc.PointCount; ++i)
+				    {
+					    Vec2 clipPoint = cc.BodyA.GetWorldPoint(cc.Points[i].LocalPoint);
+					    Separations[i] = Vec2.Dot(clipPoint - planePoint, Normal) - cc.Radius;
+					    Points[i] = clipPoint;
+				    }
+
+				    // Ensure normal points from A to B
+				    Normal = -Normal;
+			    }
+			    break;
+		    }
+	    }
+
+	    public Vec2 Normal;
+	    public Vec2[] Points = new Vec2[Settings.MaxManifoldPoints];
+        public float[] Separations = new float[Settings.MaxManifoldPoints];
+    }
 }


add comment

add comment

--- CSharpGL/IFontTexture/FontTexture/FontBitmapHelper.cs
+++ CSharpGL/IFontTexture/FontTexture/FontBitmapHelper.cs
@@ -41,11 +41,6 @@
             int width, height;
             PrepareFinalBitmapSize(fontBitmap, out width, out height);
             PrintBitmap(fontBitmap, singleCharWidth, singleCharHeight, width, height);
-            //GetGlyphSizes(fontBitmap, charSet);
-            //GetGlyphPositions(fontBitmap, charSet, out width, out height);
-            //PrintBitmap(fontBitmap, charSet, width, height);
-            //RetargetGlyphRectangleInwards(fontBitmap);
-            //ReprintBitmap(fontBitmap);
             if (drawBoundary)
             {
                 using (var graphics = Graphics.FromImage(fontBitmap.GlyphBitmap))
@@ -65,7 +60,8 @@
         }

         /// <summary>
-        /// rpint the final bitmap that contains all glyphs.
+        /// Print the final bitmap that contains all glyphs.
+        /// And also setup glyph's xoffset, yoffset.
         /// </summary>
         /// <param name="fontBitmap"></param>
         /// <param name="singleCharWidth"></param>
@@ -141,8 +137,6 @@
                 {
                     if (currentX + item.Value.width < sideLength)
                     {
-                        //item.Value.xoffset = currentX;
-                        //item.Value.yoffset = currentY;
                         currentX += item.Value.width + glyphInterval;
                     }
                     else
@@ -150,17 +144,31 @@
                         if (maxWidth < currentX) { maxWidth = currentX; }
                         currentX = leftMargin;
                         currentY += maxGlyphHeight;
-                        //item.Value.xoffset = currentX;
-                        //item.Value.yoffset = currentY;
                         currentX += item.Value.width + glyphInterval;
                     }
                 }
-                maxHeight = currentY + maxGlyphHeight;
+                if (currentX > leftMargin)
+                {
+                    maxHeight = currentY + maxGlyphHeight;
+                }
+                else
+                {
+                    maxHeight = currentY;
+                }
                 width = maxWidth;
                 height = maxHeight;
             }
         }

+        /// <summary>
+        /// Get glyph's size by graphics.MeasureString().
+        /// Then shrink glyph's size.
+        /// xoffset now means offset in a single glyph's bitmap.
+        /// </summary>
+        /// <param name="fontBitmap"></param>
+        /// <param name="charSet"></param>
+        /// <param name="singleCharWidth"></param>
+        /// <param name="singleCharHeight"></param>
         private static void PrepareInitialGlyphDict(FontBitmap fontBitmap, string charSet, out int singleCharWidth, out int singleCharHeight)
         {
             // Get glyph's size by graphics.MeasureString().


Wrap key fix #152

Wrap key fix #152

--- Jumoo.uSync.BackOffice/Helpers/NameChecker.cs
+++ Jumoo.uSync.BackOffice/Helpers/NameChecker.cs
@@ -79,23 +79,30 @@
             if (!File.Exists(file))
                 return Guid.Empty;

-            XElement node = XElement.Load(file);
-            if (node == null)
-                return Guid.Empty;
+            try
+            {
+                XElement node = XElement.Load(file);
+                if (node == null)
+                    return Guid.Empty;

-            var fileKey = node.Element("Key").ValueOrDefault(Guid.Empty);
+                var fileKey = node.Element("Key").ValueOrDefault(Guid.Empty);

-            if (fileKey == Guid.Empty && node.Element("Info") != null)
-                fileKey = node.Element("Info").Element("Key").ValueOrDefault(Guid.Empty);
+                if (fileKey == Guid.Empty && node.Element("Info") != null)
+                    fileKey = node.Element("Info").Element("Key").ValueOrDefault(Guid.Empty);

-            if (fileKey == Guid.Empty)
-                fileKey = node.Attribute("Key").ValueOrDefault(Guid.Empty);
+                if (fileKey == Guid.Empty)
+                    fileKey = node.Attribute("Key").ValueOrDefault(Guid.Empty);

-            if (fileKey == Guid.Empty)
-                fileKey = node.Attribute("guid").ValueOrDefault(Guid.Empty);
+                if (fileKey == Guid.Empty)
+                    fileKey = node.Attribute("guid").ValueOrDefault(Guid.Empty);

-            return fileKey;
+                return fileKey;
+            }
+            catch
+            {
+                return Guid.Empty;
+            }
         }


code cleanup

code cleanup

--- Purchasing.Web/Views/Report/TotalByWorkgroup.cshtml
+++ Purchasing.Web/Views/Report/TotalByWorkgroup.cshtml
@@ -4,7 +4,6 @@
 @{
     ViewBag.Title = "Total By Workgroup";
     ViewBag.SingleColumn = false;
-    ViewBag.GetMethod = "Index";
     ViewBag.LoadTableTools = true;
     ViewBag.LoadFixedHeaders = true;

@@ -16,37 +15,37 @@
 }

-

-
-

+

+
+

-    @using (Html.BeginForm("TotalByWorkgroup", "Report", FormMethod.Get))
-    {
-

+            @using (Html.BeginForm("TotalByWorkgroup", "Report", FormMethod.Get))
+            {
+

-

-

-                    @Html.LabelFor(model => model.StartDate)
-

-

-                    @Html.EditorFor(model => model.StartDate)
-

-

-

-

-                    @Html.LabelFor(model => model.EndDate)
-

-

-                    @Html.EditorFor(model => model.EndDate)
-

-

-

-                <input class="button" type="submit" value="Apply" />
-

-

-    }
-

-

+

+

+                            @Html.LabelFor(model => model.StartDate)
+

+

+                            @Html.EditorFor(model => model.StartDate)
+

+

+

+

+                            @Html.LabelFor(model => model.EndDate)
+

+

+                            @Html.EditorFor(model => model.EndDate)
+

+

+

+                        <input class="button" type="submit" value="Apply" />
+

+

+            }
+

+


#3007 Breakpoints with line number >512 don't work in mixed mode

Copy the actual data written to MemoryStream, rather than the entire backing buffer (which can be overallocated).

--- Python/Product/Debugger/DkmDebugger/TraceManager.cs
+++ Python/Product/Debugger/DkmDebugger/TraceManager.cs
@@ -142,7 +142,7 @@

         private void WriteBreakpoints() {
             int maxLineNumber = _breakpoints.Keys.Select(loc => loc.LineNumber).DefaultIfEmpty().Max();
-            var lineNumbersStream = new MemoryStream(maxLineNumber * sizeof(int));
+            var lineNumbersStream = new MemoryStream((maxLineNumber + 1) * sizeof(int));
             var lineNumbersWriter = new BinaryWriter(lineNumbersStream);

             var stringsStream = new MemoryStream();
@@ -201,16 +201,16 @@
             bpData.maxLineNumber = maxLineNumber;
             if (lineNumbersStream.Length > 0) {
                 bpData.lineNumbers = _process.AllocateVirtualMemory(0, (int)lineNumbersStream.Length, NativeMethods.MEM_COMMIT | NativeMethods.MEM_RESERVE, NativeMethods.PAGE_READWRITE);
-                _process.WriteMemory(bpData.lineNumbers, lineNumbersStream.GetBuffer());
+                _process.WriteMemory(bpData.lineNumbers, lineNumbersStream.ToArray());
             } else {
                 bpData.lineNumbers = 0;
             }

             bpData.fileNamesOffsets = _process.AllocateVirtualMemory(0, (int)fileNamesOffsetsStream.Length, NativeMethods.MEM_COMMIT | NativeMethods.MEM_RESERVE, NativeMethods.PAGE_READWRITE);
-            _process.WriteMemory(bpData.fileNamesOffsets, fileNamesOffsetsStream.GetBuffer());
+            _process.WriteMemory(bpData.fileNamesOffsets, fileNamesOffsetsStream.ToArray());

             bpData.strings = _process.AllocateVirtualMemory(0, (int)stringsStream.Length, NativeMethods.MEM_COMMIT | NativeMethods.MEM_RESERVE, NativeMethods.PAGE_READWRITE);
-            _process.WriteMemory(bpData.strings, stringsStream.GetBuffer());
+            _process.WriteMemory(bpData.strings, stringsStream.ToArray());

             bpDataProxy.Write(bpData);
         }


store the create date as a string without milliseconds (reduce false positives)

--- uSync8.ContentEdition/Serializers/ContentSerializerBase.cs
+++ uSync8.ContentEdition/Serializers/ContentSerializerBase.cs
@@ -97,7 +97,7 @@
             info.Add(new XElement("Path", GetItemPath(item)));
             info.Add(GetTrashedInfo(item));
             info.Add(new XElement("ContentType", item.ContentType.Alias));
-            info.Add(new XElement("CreateDate", item.CreateDate));
+            info.Add(new XElement("CreateDate", item.CreateDate.ToString("s")));

             var title = new XElement("NodeName", new XAttribute("Default", item.Name));
             foreach (var culture in item.AvailableCultures)


tidy test

tidy test

--- Spa2/NakedObjects.Spa.Selenium.Test/tests/CCAtests.cs
+++ Spa2/NakedObjects.Spa.Selenium.Test/tests/CCAtests.cs
@@ -291,11 +291,11 @@
             wait.Until(dr => dr.FindElements(By.CssSelector("td")).Count > 30);

             SelectCheckBox("#item1-all"); //To clear
-            Thread.Sleep(2000);
+
             Click(GetObjectAction("Clear Comments"));
-            Thread.Sleep(2000);
-            Reload();
-            Thread.Sleep(4000);
+
+            Reload();
+
             //wait.Until(dr => dr.FindElements(By.CssSelector("td:nth-child(7)")).Count(el => el.Text.Contains("User unhappy")) == 0);

             //SelectCheckBox("#item1-all", true); //To clear
@@ -305,24 +305,24 @@
             SelectCheckBox("#item1-1");
             SelectCheckBox("#item1-2");
             SelectCheckBox("#item1-3");
-            Thread.Sleep(2000);
+
             Click(GetObjectAction("Comment As Users Unhappy"));
-            Thread.Sleep(1000); //Because there is no visible change to wait for
-            Reload();
-            Thread.Sleep(2000);
+            Thread.Sleep(2000); //Because there is no visible change to wait for
+            Reload();
+
             wait.Until(dr => dr.FindElements(By.CssSelector("span.loading:empty")));
-            Thread.Sleep(2000);
+
             wait.Until(dr => dr.FindElements(By.CssSelector("td:nth-child(7)")).Count(el => el.Text.Contains("User unhappy")) == 3);

             //Confirm that the three checkboxes have now been cleared
             wait.Until(dr => !dr.FindElements(By.CssSelector("input")).Where(el => el.GetAttribute("type") == "checkbox").Any(el => el.Selected));

             SelectCheckBox("#item1-all"); //To clear
-            Thread.Sleep(2000);
+
             Click(GetObjectAction("Clear Comments"));
-            Thread.Sleep(2000);
-            Reload();
-            Thread.Sleep(1000);
+
+            Reload();
+
             wait.Until(dr => dr.FindElements(By.CssSelector("span.loading:empty")));
             wait.Until(dr => dr.FindElements(By.CssSelector("td:nth-child(7)")).Count(el => el.Text.Contains("User unhappy")) == 0);
         }


Fixing Websocket configuration override

Fixing Websocket configuration override

--- ReactiveXComponent/WebSocket/WebSocketConnection.cs
+++ ReactiveXComponent/WebSocket/WebSocketConnection.cs
@@ -44,7 +44,7 @@
                 endpoint.Type = configurationOverrides.WebSocketType.Value;
             }

-            return new WebSocketSession(_endpoint, _timeout, _xcConfiguration, _privateCommunicationIdentifier);
+            return new WebSocketSession(endpoint, _timeout, _xcConfiguration, _privateCommunicationIdentifier);
         }
     }
 }


Added missing DummyCompanyController initialization to constructor of DatabaseAdapter.

--- StockExchangeGame/Database/Generic/DatabaseAdapter.cs
+++ StockExchangeGame/Database/Generic/DatabaseAdapter.cs
@@ -19,6 +19,7 @@
             _boughtController = new BoughtController(connectionString);
             _companyEndingsController = new CompanyEndingsController(connectionString);
             _companyNamesController = new CompanyNamesController(connectionString);
+            _dummyCompanyController = new DummyCompanyController(connectionString);
         }

         public string GetConnectionString()


Added support for AsciiDoc.

Added support for AsciiDoc.

--- Structurizr.Core/Documentation/DocumentationFormat.cs
+++ Structurizr.Core/Documentation/DocumentationFormat.cs
@@ -3,7 +3,8 @@
     public enum DocumentationFormat
     {

-        Markdown
+        Markdown,
+        AsciiDoc

     }
 }


fix S_DUNGEON_COOL_TIME_LIST

fix S_DUNGEON_COOL_TIME_LIST

--- TCC.Core/Parsing/Messages/S_DUNGEON_COOL_TIME_LIST.cs
+++ TCC.Core/Parsing/Messages/S_DUNGEON_COOL_TIME_LIST.cs
@@ -18,11 +18,14 @@
                 reader.Skip(4);
                 for (var i = 0; i < count; i++)
                 {
-                    reader.Skip(4);
+                    reader.Skip(2);
+                    var next = reader.ReadUInt16();
                     var id = reader.ReadUInt32();
-                    reader.Skip(8);
+                    reader.Skip(10);
                     var entries = reader.ReadInt16();
                     DungeonCooldowns.Add(id, entries);
+                    if (next == 0) return;
+                    reader.RepositionAt(next);
                 }

             }


don't crash on wrong DungeonCooltimeList

--- TCC.Core/Parsing/Messages/S_DUNGEON_COOL_TIME_LIST.cs
+++ TCC.Core/Parsing/Messages/S_DUNGEON_COOL_TIME_LIST.cs
@@ -9,17 +9,26 @@
         public readonly Dictionary<uint, short> DungeonCooldowns;
         public S_DUNGEON_COOL_TIME_LIST(TeraMessageReader reader) : base(reader)
         {
-            var count = reader.ReadUInt16();
-            reader.Skip(2); //var offset = reader.ReadUInt16();
-            reader.Skip(4);
             DungeonCooldowns = new Dictionary<uint, short>();
-            for (var i = 0; i < count; i++)
+
+            try
             {
+                var count = reader.ReadUInt16();
+                reader.Skip(2); //var offset = reader.ReadUInt16();
                 reader.Skip(4);
-                var id = reader.ReadUInt32();
-                reader.Skip(8);
-                var entries = reader.ReadInt16();
-                DungeonCooldowns.Add(id, entries);
+                for (var i = 0; i < count; i++)
+                {
+                    reader.Skip(4);
+                    var id = reader.ReadUInt32();
+                    reader.Skip(8);
+                    var entries = reader.ReadInt16();
+                    DungeonCooldowns.Add(id, entries);
+                }
+
+            }
+            catch (System.Exception)
+            {
+                Log.F($"[S_DUNGEON_COOL_TIME_LIST] Failed to parse packet");
             }
         }
     }


fix tests

fix tests

--- Test/NakedObjects.SystemTest/Reflect/ReflectorTest.cs
+++ Test/NakedObjects.SystemTest/Reflect/ReflectorTest.cs
@@ -8,6 +8,7 @@
 using System;
 using System.Collections.Generic;
 using System.Diagnostics;
+using System.IO;
 using System.Linq;
 using System.Security.Principal;
 using AdventureWorksModel;
@@ -134,7 +135,7 @@
         // this still fails - looks to be one of the facets on the OneToOneSpecImmutable causing a BinaryHeader error
         // need further investigation
         // how about wring a test that serialises/deserialises all facets ?
-        [TestMethod, Ignore]
+        [TestMethod]
         public void SerializeAdventureworks() {
             // load adventurework

@@ -174,6 +175,8 @@
             //    Console.WriteLine(" field facet  {0}", f);
             //}

+            Directory.CreateDirectory(@"c:\testmetadata");
+
             const string file = @"c:\testmetadata\metadataAW.bin";

             SerializeDeserialize(cache, file);
@@ -209,7 +212,7 @@
                 deserializeInterval);
         }

-        [TestMethod, Ignore]
+        [TestMethod]
         public void SerializeAdventureworksByType() {
             // load adventurework

@@ -238,6 +241,8 @@

             var cache = container.Resolve<ISpecificationCache>();

+            Directory.CreateDirectory(@"c:\testmetadata");
+
             const string file = @"c:\testmetadata\metadataAWT.bin";

             SerializeDeserialize(cache, file);


Adding fuzzyness in image compare in unit tests

--- Tests/Mapsui.Rendering.Xaml.Tests/MapRendererTests.cs
+++ Tests/Mapsui.Rendering.Xaml.Tests/MapRendererTests.cs
@@ -1,4 +1,5 @@
-using System.Drawing;
+using System;
+using System.Drawing;
 using System.IO;
 using Mapsui.Tests.Common;
 using NUnit.Framework;
@@ -62,9 +63,9 @@

             // aside
             File.WriteToGeneratedFolder(fileName, bitmap);
-
-            // assert
-            Assert.IsTrue(CompareBitmaps(File.ReadFromOriginalFolder(fileName), bitmap));
+
+            // assert
+            Assert.IsTrue(CompareBitmaps(File.ReadFromOriginalFolder(fileName), bitmap, 1));
         }

         [Test]
@@ -135,7 +136,6 @@
             Assert.IsTrue(CompareBitmaps(File.ReadFromOriginalFolder(fileName), bitmap));
         }

-        [Ignore]
         [Test]
         public void RenderTiles()
         {
@@ -150,7 +150,7 @@
             File.WriteToGeneratedFolder(fileName, bitmap);

             // assert
-            Assert.IsTrue(CompareBitmaps(File.ReadFromOriginalFolder(fileName), bitmap));
+            Assert.IsTrue(CompareBitmaps(File.ReadFromOriginalFolder(fileName), bitmap, 1));
         }

         [Test]
@@ -169,11 +169,28 @@
             // assert
             Assert.IsTrue(CompareBitmaps(File.ReadFromOriginalFolder(fileName), bitmap));
         }
-
-        private bool CompareBitmaps(Stream bitmapStream1, Stream bitmapStream2)
-        {
+
+        private bool CompareColors(Color color1, Color color2, int allowedColorDistance)
+        {
+            if (Math.Abs(color1.A - color2.A) > allowedColorDistance) return false;
+            if (Math.Abs(color1.R - color2.R) > allowedColorDistance) return false;
+            if (Math.Abs(color1.G - color2.G) > allowedColorDistance) return false;
+            if (Math.Abs(color1.B - color2.B) > allowedColorDistance) return false;
+            return true;
+        }
+
+        private bool CompareBitmaps(Stream bitmapStream1, Stream bitmapStream2, int allowedColorDistance = 0, double proportionCorrect = 1)
+        {
+            // The bitmaps in WPF can slightly differ from test to test. No idea why. So introduced proportion correct.
+
+            // use this if you want to know where the unit test framework writes the new files.
+            // var path = System.AppDomain.CurrentDomain.BaseDirectory;
+
             bitmapStream1.Position = 0;
             bitmapStream2.Position = 0;
+
+            long trueCount = 0;
+            long falseCount = 0;

             var bitmap1 = (Bitmap)Image.FromStream(bitmapStream1);
             var bitmap2 = (Bitmap)Image.FromStream(bitmapStream2);
@@ -182,14 +199,22 @@
             {
                 for (var y = 0; y < bitmap1.Height; y++)
                 {
-                    if (bitmap1.GetPixel(x, y) != bitmap2.GetPixel(x, y))
+                    var color1 = bitmap1.GetPixel(x, y);
+                    var color2 = bitmap2.GetPixel(x, y);
+                    if (color1 == color2)
+                        trueCount++;
+                    else
                     {
-                        return false;
+                        if (CompareColors(color1, color2, allowedColorDistance))
+                            trueCount++;
+                        else
+                            falseCount++;
                     }
                 }
             }

-            return true;
+            var propertion = (double) (trueCount - falseCount) / trueCount;
+            return proportionCorrect <= propertion;
         }
     }
 }


Update SessionEventArgs.cs

Update SessionEventArgs.cs

--- Titanium.Web.Proxy/EventArguments/SessionEventArgs.cs
+++ Titanium.Web.Proxy/EventArguments/SessionEventArgs.cs
@@ -467,7 +467,7 @@
         /// <returns></returns>
         public async Task GenericResponse(string html, HttpStatusCode status)
         {
-            await GenericResponse(html, null, status);
+            await GenericResponse(html, null, status);
         }

         /// <summary>


fixing typo

fixing typo

--- Samples/Sample.Net.ConsoleApp.App.Config/Program.cs
+++ Samples/Sample.Net.ConsoleApp.App.Config/Program.cs
@@ -15,7 +15,7 @@
             // The Rollbar Notifier is configured within the app.config.
             // Let's just start using it:
             RollbarLocator.RollbarInstance.AsBlockingLogger(TimeSpan.FromSeconds(3))
-                .Info($"{typeof(Program).Namespace} sample: Rollbar is alive based on the app.config settings!.");
+                .Info($"{typeof(Program).Namespace} sample: Rollbar is alive based on the app.config settings!");
         }
     }
 }


fix .. problem with POP3

fix .. problem with POP3

--- Signum.Engine.Extensions/Mailing/Pop3/Pop3Client.cs
+++ Signum.Engine.Extensions/Mailing/Pop3/Pop3Client.cs
@@ -120,7 +120,10 @@
             StringBuilder sb = new StringBuilder();
             while (!(response = reader.ReadLine()).Equals("."))
             {
-                sb.AppendLine(response);
+                if (response.StartsWith(".."))
+                    sb.AppendLine(response.Substring(1));
+                else
+                    sb.AppendLine(response);
             }
             return sb.ToString();
         }


Reformatted the InterceptorExtensions of the CodeSamples to match the coding style of the documentation.

--- SimpleInjector.CodeSamples/InterceptorExtensions.cs
+++ SimpleInjector.CodeSamples/InterceptorExtensions.cs
@@ -1,4 +1,5 @@
-namespace SimpleInjector.CodeSamples
+// <auto-generated />
+namespace SimpleInjector.CodeSamples
 {
     /*
     // Example usage
@@ -46,14 +47,9 @@

     public interface IInvocation
     {
-        IMethodCallMessage Message { get; }
-
         object InvocationTarget { get; }
-
         object ReturnValue { get; set; }
-
         void Proceed();
-
         MethodBase GetConcreteMethod();
     }

@@ -61,19 +57,16 @@
     // NOTE: These extension methods can only intercept interfaces, not abstract types.
     public static class InterceptorExtensions
     {
-        public static void InterceptWith<TInterceptor>(this Container container,
+        public static void InterceptWith<TInterceptor>(this Container container,
             Func<Type, bool> predicate)
-            where TInterceptor : class, IInterceptor
-        {
-            RequiresIsNotNull(container, "container");
-            RequiresIsNotNull(predicate, "predicate");
-
-            container.Options.ConstructorResolutionBehavior.GetConstructor(typeof(TInterceptor),
-                typeof(TInterceptor));
-
-            var interceptWith = new InterceptionHelper(container)
-            {
-                BuildInterceptorExpression =
+            where TInterceptor : class, IInterceptor {
+            RequiresIsNotNull(container, "container");
+            RequiresIsNotNull(predicate, "predicate");
+            container.Options.ConstructorResolutionBehavior.GetConstructor(
+                typeof(TInterceptor), typeof(TInterceptor));
+
+            var interceptWith = new InterceptionHelper(container) {
+                BuildInterceptorExpression =
                     e => BuildInterceptorExpression<TInterceptor>(container),
                 Predicate = type => predicate(type)
             };
@@ -81,17 +74,14 @@
             container.ExpressionBuilt += interceptWith.OnExpressionBuilt;
         }

-        public static void InterceptWith(this Container container,
-            Func<IInterceptor> interceptorCreator,
-            Func<Type, bool> predicate)
-        {
+        public static void InterceptWith(this Container container,
+            Func<IInterceptor> interceptorCreator, Func<Type, bool> predicate) {
             RequiresIsNotNull(container, "container");
             RequiresIsNotNull(interceptorCreator, "interceptorCreator");
             RequiresIsNotNull(predicate, "predicate");

-            var interceptWith = new InterceptionHelper(container)
-            {
-                BuildInterceptorExpression =
+            var interceptWith = new InterceptionHelper(container) {
+                BuildInterceptorExpression =
                     e => Expression.Invoke(Expression.Constant(interceptorCreator)),
                 Predicate = type => predicate(type)
             };
@@ -101,14 +91,12 @@

         public static void InterceptWith(this Container container,
             Func<ExpressionBuiltEventArgs, IInterceptor> interceptorCreator,
-            Func<Type, bool> predicate)
-        {
+            Func<Type, bool> predicate) {
             RequiresIsNotNull(container, "container");
             RequiresIsNotNull(interceptorCreator, "interceptorCreator");
             RequiresIsNotNull(predicate, "predicate");

-            var interceptWith = new InterceptionHelper(container)
-            {
+            var interceptWith = new InterceptionHelper(container) {
                 BuildInterceptorExpression = e => Expression.Invoke(
                     Expression.Constant(interceptorCreator),
                     Expression.Constant(e)),
@@ -118,16 +106,13 @@
             container.ExpressionBuilt += interceptWith.OnExpressionBuilt;
         }

-        public static void InterceptWith(this Container container,
-            IInterceptor interceptor,
-            Func<Type, bool> predicate)
-        {
+        public static void InterceptWith(this Container container,
+            IInterceptor interceptor, Func<Type, bool> predicate) {
             RequiresIsNotNull(container, "container");
             RequiresIsNotNull(interceptor, "interceptor");
             RequiresIsNotNull(predicate, "predicate");

-            var interceptWith = new InterceptionHelper(container)
-            {
+            var interceptWith = new InterceptionHelper(container) {
                 BuildInterceptorExpression = e => Expression.Constant(interceptor),
                 Predicate = predicate
             };
@@ -136,13 +121,13 @@
         }

         [DebuggerStepThrough]
-        private static Expression BuildInterceptorExpression<TInterceptor>(Container container)
-            where TInterceptor : class
+        private static Expression BuildInterceptorExpression<TInterceptor>(
+            Container container)
+            where TInterceptor : class
         {
             var interceptorRegistration = container.GetRegistration(typeof(TInterceptor));

-            if (interceptorRegistration == null)
-            {
+            if (interceptorRegistration == null) {
                 // This will throw an ActivationException
                 container.GetInstance<TInterceptor>();
             }
@@ -150,10 +135,8 @@
             return interceptorRegistration.BuildExpression();
         }

-        private static void RequiresIsNotNull(object instance, string paramName)
-        {
-            if (instance == null)
-            {
+        private static void RequiresIsNotNull(object instance, string paramName) {
+            if (instance == null) {
                 throw new ArgumentNullException(paramName);
             }
         }
@@ -167,51 +150,43 @@
                 select method)
                 .Single();

-            public InterceptionHelper(Container container)
+            public InterceptionHelper(Container container) {
+                this.Container = container;
+            }
+
+            internal Container Container { get; private set; }
+
+            internal Func<ExpressionBuiltEventArgs, Expression> BuildInterceptorExpression
             {
-                this.Container = container;
-            }
-
-            internal Container Container { get; private set; }
-
-            internal Func<ExpressionBuiltEventArgs, Expression> BuildInterceptorExpression { get; set; }
+                get;
+                set;
+            }

             internal Func<Type, bool> Predicate { get; set; }

             [DebuggerStepThrough]
-            public void OnExpressionBuilt(object sender,
-                ExpressionBuiltEventArgs e)
-            {
-                if (this.Predicate(e.RegisteredServiceType))
-                {
-                    ThrowIfServiceTypeIsNotAnInterface(e);
-
+            public void OnExpressionBuilt(object sender, ExpressionBuiltEventArgs e) {
+                if (this.Predicate(e.RegisteredServiceType)) {
+                    ThrowIfServiceTypeNotAnInterface(e);
                     e.Expression = this.BuildProxyExpression(e);
                 }
             }

             [DebuggerStepThrough]
-            private static void ThrowIfServiceTypeIsNotAnInterface(
-                ExpressionBuiltEventArgs e)
-            {
-                // NOTE: We can only handle interfaces, because
-                // System.Runtime.Remoting.Proxies.RealProxy
-                // only supports interfaces.
-                if (!e.RegisteredServiceType.IsInterface)
-                {
-                    throw new NotSupportedException(
-                        "Can't intercept type " +
-                        e.RegisteredServiceType.Name +
-                        " because it is not an interface.");
-                }
-            }
-
-            [DebuggerStepThrough]
-            private Expression BuildProxyExpression(ExpressionBuiltEventArgs e)
-            {
+            private static void ThrowIfServiceTypeNotAnInterface(ExpressionBuiltEventArgs e) {
+                // NOTE: We can only handle interfaces, because
+                // System.Runtime.Remoting.Proxies.RealProxy only supports interfaces.
+                if (!e.RegisteredServiceType.IsInterface) {
+                    throw new NotSupportedException("Can't intercept type " +
+                        e.RegisteredServiceType.Name + " because it is not an interface.");
+                }
+            }
+
+            [DebuggerStepThrough]
+            private Expression BuildProxyExpression(ExpressionBuiltEventArgs e) {
                 var interceptor = this.BuildInterceptorExpression(e);

-                // Create call to
+                // Create call to
                 // (ServiceType)Interceptor.CreateProxy(Type, IInterceptor, object)
                 var proxyExpression =
                     Expression.Convert(
@@ -221,8 +196,7 @@
                             e.Expression),
                         e.RegisteredServiceType);

-                if (e.Expression is ConstantExpression && interceptor is ConstantExpression)
-                {
+                if (e.Expression is ConstantExpression && interceptor is ConstantExpression) {
                     return Expression.Constant(CreateInstance(proxyExpression),
                         e.RegisteredServiceType);
                 }
@@ -231,9 +205,8 @@
             }

             [DebuggerStepThrough]
-            private static object CreateInstance(Expression expression)
-            {
-                var instanceCreator = Expression.Lambda<Func<object>>(expression,
+            private static object CreateInstance(Expression expression) {
+                var instanceCreator = Expression.Lambda<Func<object>>(expression,
                     new ParameterExpression[0])
                     .Compile();

@@ -244,48 +217,39 @@

     public static class Interceptor
     {
-        public static T CreateProxy<T>(IInterceptor interceptor, T realInstance)
-        {
+        public static T CreateProxy<T>(IInterceptor interceptor, T realInstance) {
             return (T)CreateProxy(typeof(T), interceptor, realInstance);
         }

         [DebuggerStepThrough]
-        public static object CreateProxy(Type serviceType, IInterceptor interceptor,
-            object realInstance)
-        {
+        public static object CreateProxy(Type serviceType, IInterceptor interceptor,
+            object realInstance) {
             var proxy = new InterceptorProxy(serviceType, realInstance, interceptor);
-
             return proxy.GetTransparentProxy();
         }

         private sealed class InterceptorProxy : RealProxy
         {
-            private static readonly MethodBase GetTypeMethod = typeof(object).GetMethod("GetType");
+            private static MethodBase GetTypeMethod = typeof(object).GetMethod("GetType");

             private object realInstance;
             private IInterceptor interceptor;

             [DebuggerStepThrough]
-            public InterceptorProxy(Type classToProxy, object realInstance,
+            public InterceptorProxy(Type classToProxy, object realInstance,
                 IInterceptor interceptor)
-                : base(classToProxy)
-            {
+                : base(classToProxy) {
                 this.realInstance = realInstance;
                 this.interceptor = interceptor;
             }

-            public override IMessage Invoke(IMessage msg)
-            {
-                if (msg is IMethodCallMessage)
-                {
+            public override IMessage Invoke(IMessage msg) {
+                if (msg is IMethodCallMessage) {
                     var message = (IMethodCallMessage)msg;

-                    if (object.ReferenceEquals(message.MethodBase, GetTypeMethod))
-                    {
+                    if (object.ReferenceEquals(message.MethodBase, GetTypeMethod)) {
                         return this.Bypass(message);
-                    }
-                    else
-                    {
+                    } else {
                         return this.InvokeMethodCall(message);
                     }
                 }
@@ -293,23 +257,19 @@
                 return msg;
             }

-            private IMessage InvokeMethodCall(IMethodCallMessage message)
-            {
+            private IMessage InvokeMethodCall(IMethodCallMessage message) {
                 var invocation = new Invocation { Proxy = this, Message = message };

-                invocation.Proceeding += (s, e) =>
-                {
+                invocation.Proceeding += () => {
                     invocation.ReturnValue = message.MethodBase.Invoke(
                         this.realInstance, message.Args);
                 };

                 this.interceptor.Intercept(invocation);
-
                 return new ReturnMessage(invocation.ReturnValue, null, 0, null, message);
             }

-            private IMessage Bypass(IMethodCallMessage message)
-            {
+            private IMessage Bypass(IMethodCallMessage message) {
                 object value = message.MethodBase.Invoke(this.realInstance, message.Args);

                 return new ReturnMessage(value, null, 0, null, message);
@@ -317,29 +277,20 @@

             private class Invocation : IInvocation
             {
-                public event EventHandler Proceeding;
-
+                public event Action Proceeding;
                 public InterceptorProxy Proxy { get; set; }
-
                 public IMethodCallMessage Message { get; set; }
-
                 public object ReturnValue { get; set; }

-                public object InvocationTarget
-                {
+                public object InvocationTarget {
                     get { return this.Proxy.realInstance; }
                 }

-                public void Proceed()
-                {
-                    if (this.Proceeding != null)
-                    {
-                        this.Proceeding(this, EventArgs.Empty);
-                    }
-                }
-
-                public MethodBase GetConcreteMethod()
-                {
+                public void Proceed() {
+                    this.Proceeding();
+                }
+
+                public MethodBase GetConcreteMethod() {
                     return this.Message.MethodBase;
                 }
             }


Corrigido Tipo Funcionario

Corrigido Tipo Funcionario

--- SistemaMundoAnimal/Forms/FormCadastroFuncionario.cs
+++ SistemaMundoAnimal/Forms/FormCadastroFuncionario.cs
@@ -33,7 +33,7 @@
                     }
                 }

-                if (grupo is TextBox || grupo is ComboBox || grupo is RichTextBox) {
+                if (grupo is TextBox || grupo is ComboBox || grupo is RichTextBox || grupo is MaskedTextBox) {
                     grupo.Text = "";
                 }
             }
@@ -96,7 +96,7 @@
                 int ano = Convert.ToInt32(TxtNascimento.Text.Substring(4, 4));

                 // <TODO: Pesquisar ultimo id no banco!>
-                funcionario.SetId(5);
+                funcionario.SetId(6);
                 // </TODO>
                 funcionario.SetNome(TxtNome.Text);
                 funcionario.SetSobrenome(TxtSobrenome.Text);
@@ -105,7 +105,7 @@
                 funcionario.SetRG(TxtRG.Text);
                 funcionario.SetCPF(TxtCPF.Text);
                 funcionario.SetNascimento(dia, mes, ano);
-                funcionario.SetCargo((TipoCargo) ComboCargoFuncionario.Items.IndexOf(ComboCargoFuncionario.Text));
+                funcionario.SetCargo((TipoCargo) ComboCargoFuncionario.Items.IndexOf(ComboCargoFuncionario.Text) + 1);
                 funcionario.SetSalario(Convert.ToDouble(TxtSalarioFuncionario.Text));
                 funcionario.SetValeAlimentacao(Convert.ToDouble(TxtValeAlimentacao.Text));
                 funcionario.SetValeTransporte(Convert.ToDouble(TxtValeTransporte.Text));
@@ -124,7 +124,7 @@
                 funcionario = new Funcionario();

             } catch (Exception ex) {
-                MessageBox.Show(ex.StackTrace + "\n" + ex.Message);
+                MessageBox.Show(ex.StackTrace + "\n\n" + ex.Message);
             }
         }

@@ -133,7 +133,7 @@
         /// </summary>
         private void BtnAddContato_Click(object sender, EventArgs e) {
             try {
-                int index = ComboTipoContato.Items.IndexOf(ComboTipoContato.Text);
+                int index = ComboTipoContato.Items.IndexOf(ComboTipoContato.Text) + 1;
                 var contato = FabricaContato.GetContato(TxtContato.Text, (TipoContato)index);

                 funcionario.AddContato(contato);


removed empty line

removed empty line

--- Snippets/Snippets_5/Persistence/PersistenceOrder.cs
+++ Snippets/Snippets_5/Persistence/PersistenceOrder.cs
@@ -47,7 +47,6 @@
             config.UsePersistence<InMemoryPersistence>()
                 .For(Storage.GatewayDeduplication);

-
             // This one will override the above settings!
             config.UsePersistence<RavenDBPersistence>();
             #endregion


replace more stuff

replace more stuff

--- UnityProject/Assets/Scripts/Doors/InteractableDoor.cs
+++ UnityProject/Assets/Scripts/Doors/InteractableDoor.cs
@@ -58,7 +58,7 @@
 			}
 			else
 			{
-				Controller.ServerTryOpen(byPlayer);
+				TryOpen(byPlayer);
 			}
 		}
 	}
@@ -88,7 +88,7 @@
 		}
 		else
 		{
-			Controller.ServerTryOpen(interaction.Performer);
+			TryOpen(interaction.Performer);
 		}
 	}


Fix for getting the recording device.

Fix for getting the recording device.

--- Source/ChromeCast.Desktop.AudioStreamer/MainForm.cs
+++ Source/ChromeCast.Desktop.AudioStreamer/MainForm.cs
@@ -311,11 +311,24 @@
         {
             if (InvokeRequired)
             {
+                try
+                {
+                    SetDevice(startRecordingSetDevice);
+                    return;
+                }
+                catch (Exception)
+                {
+                }
                 Invoke(new Action<Action<MMDevice>>(GetRecordingDevice), new object[] { startRecordingSetDevice });
                 return;
             }
             if (IsDisposed) return;

+            SetDevice(startRecordingSetDevice);
+        }
+
+        private void SetDevice(Action<MMDevice> startRecordingSetDevice)
+        {
             if (cmbRecordingDevice.Items.Count > 0)
                 startRecordingSetDevice((MMDevice)cmbRecordingDevice.SelectedItem);
             else


Make public APIs for Effect registration...
A developer who wants to add their own effect currently has no way to do this other than writing then compiling their effect into the set of shaders in Helix. Making these methods public enables a third-party to compile their own shader from source, and register an input layout and associated RenderTechniques.

Make effect registration methods public.
Improve doc comments.

--- Source/HelixToolkit.Wpf.SharpDX/Controls/Effects.cs
+++ Source/HelixToolkit.Wpf.SharpDX/Controls/Effects.cs
@@ -518,32 +518,32 @@
         }

         /// <summary>
-        ///
-        /// </summary>
-        /// <param name="shaderEffectString"></param>
+        /// Register an effect for a RenderTechnique.
+        /// </summary>
+        /// <param name="shaderEffectString">A string representing the shader code.</param>
         /// <param name="techniqueName"></param>
         /// <param name="sFlags"></param>
         /// <param name="eFlags"></param>
-        internal void RegisterEffect(string shaderEffectString, RenderTechnique techniqueName, ShaderFlags sFlags = ShaderFlags.None, EffectFlags eFlags = EffectFlags.None)
-        {
-            RegisterEffect(shaderEffectString, new[] { techniqueName }, sFlags, eFlags);
-        }
-
-        /// <summary>
-        ///
-        /// </summary>
-        /// <param name="shaderEffectString"></param>
-        /// <param name="techniqueNames"></param>
+        public void RegisterEffect(string shaderEffectString, RenderTechnique technique, ShaderFlags sFlags = ShaderFlags.None, EffectFlags eFlags = EffectFlags.None)
+        {
+            RegisterEffect(shaderEffectString, new[] { technique }, sFlags, eFlags);
+        }
+
+        /// <summary>
+        /// Register an effect for a set of RenderTechniques.
+        /// </summary>
+        /// <param name="shaderEffectString">A string representing the shader code.</param>
+        /// <param name="techniques">A set of RenderTechnique objects for which to associate the Effect.</param>
         /// <param name="sFlags"></param>
         /// <param name="eFlags"></param>
-        internal void RegisterEffect(string shaderEffectString, RenderTechnique[] techniqueNames, ShaderFlags sFlags = ShaderFlags.None, EffectFlags eFlags = EffectFlags.None)
+        public void RegisterEffect(string shaderEffectString, RenderTechnique[] techniques, ShaderFlags sFlags = ShaderFlags.None, EffectFlags eFlags = EffectFlags.None)
         {
 #if PRECOMPILED_SHADERS

             try
             {
-                var shaderBytes = Techniques.TechniquesSourceDict[techniqueNames[0]];
-                this.RegisterEffect(shaderBytes, techniqueNames);
+                var shaderBytes = Techniques.TechniquesSourceDict[techniques[0]];
+                this.RegisterEffect(shaderBytes, techniques);
             }
             catch (Exception ex)
             {
@@ -564,13 +564,13 @@
             var preposessMacros = new List<ShaderMacro>();

 #if DEFERRED
-    #if DEFERRED_MSAA
+#if DEFERRED_MSAA
             preposessMacros.Add(new ShaderMacro("DEFERRED_MSAA", true));
-    #endif
-
-    #if SSAO
+#endif
+
+#if SSAO
             preposessMacros.Add(new ShaderMacro("SSAO", true));
-    #endif
+#endif
 #endif
             var preprocess = ShaderBytecode.Preprocess(shaderEffectString, preposessMacros.ToArray(), new IncludeHandler());
             var hashCode = preprocess.GetHashCode();
@@ -580,7 +580,7 @@
                 {
                     var shaderBytes = ShaderBytecode.Compile(preprocess, "fx_5_0", sFlags, eFlags);
                     shaderBytes.Bytecode.Save(hashCode.ToString());
-                    this.RegisterEffect(shaderBytes.Bytecode, techniqueNames);
+                    this.RegisterEffect(shaderBytes.Bytecode, techniques);
                 }
                 catch (Exception ex)
                 {
@@ -592,18 +592,18 @@
             else
             {
                 var shaderBytes = ShaderBytecode.FromFile(hashCode.ToString());
-                this.RegisterEffect(shaderBytes, techniqueNames);
-            }
-#endif
-        }
-
-        /// <summary>
-        ///
-        /// </summary>
-        /// <param name="shaderEffectBytecode"></param>
-        /// <param name="techniques"></param>
+                this.RegisterEffect(shaderBytes, techniques);
+            }
+#endif
+        }
+
+        /// <summary>
+        /// Register an effect for a set of RenderTechniques.
+        /// </summary>
+        /// <param name="shaderEffectBytecode">A byte array representing the compiled shader.</param>
+        /// <param name="techniques">A set of RenderTechnique objects for which to associate the Effect.</param>
         /// <param name="eFlags"></param>
-        internal void RegisterEffect(byte[] shaderEffectBytecode, RenderTechnique[] techniques, EffectFlags eFlags = EffectFlags.None)
+        public void RegisterEffect(byte[] shaderEffectBytecode, RenderTechnique[] techniques, EffectFlags eFlags = EffectFlags.None)
         {
             var effect = new Effect(device, shaderEffectBytecode, eFlags);
             foreach (var tech in techniques)
@@ -611,30 +611,30 @@
         }

         /// <summary>
-        ///
-        /// </summary>
-        /// <param name="technique"></param>
-        /// <param name="layout"></param>
-        internal void RegisterLayout(RenderTechnique technique, InputLayout layout)
+        /// Register an InputLayout for a RenderTechnique.
+        /// </summary>
+        /// <param name="technique">A RenderTechnique object.</param>
+        /// <param name="layout">An InputLayout object.</param>
+        public void RegisterLayout(RenderTechnique technique, InputLayout layout)
         {
             data[technique.Name + "Layout"] = layout;
         }

         /// <summary>
-        ///
-        /// </summary>
-        /// <param name="techniques"></param>
-        /// <param name="layout"></param>
-        internal void RegisterLayout(RenderTechnique[] techniques, InputLayout layout)
+        /// Register an InputLayout for a set of RenderTechniques
+        /// </summary>
+        /// <param name="techniques">An array of RenderTechnique objects.</param>
+        /// <param name="layout">An InputLayout object.</param>
+        public void RegisterLayout(RenderTechnique[] techniques, InputLayout layout)
         {
             foreach (var tech in techniques)
                 data[tech.Name + "Layout"] = layout;
         }

         /// <summary>
-        ///
-        /// </summary>
-        /// <param name="technique"></param>
+        /// Get the Effect associated with a RenderTechnique.
+        /// </summary>
+        /// <param name="technique">A RenderTechnique object.</param>
         /// <returns></returns>
         public Effect GetEffect(RenderTechnique technique)
         {
@@ -642,9 +642,9 @@
         }

         /// <summary>
-        ///
-        /// </summary>
-        /// <param name="technique"></param>
+        /// Get the InputLayout associated with a RenderTechnique
+        /// </summary>
+        /// <param name="technique">A RenderTechnique object.</param>
         /// <returns></returns>
         public InputLayout GetLayout(RenderTechnique technique)
         {