Example #1
0
 private void DrawGUIIndexes(HexGrid grid)
 {
     foreach (HexCell cell in grid)
     {
         HandleUtils.CenteredLabel(cell.transform.position, cell.index.ToStringInt());
     }
 }
Example #2
0
        public static SafeFileHandle GetComPortHandle(string name, FileAccess access, ShareMode shareMode, uint readTimeout, uint writeTimeout)
        {
            string         fileName = String.Format(@"\\.\{0}", name);
            SafeFileHandle handle   = HandleUtils.GetFileHandle(fileName, access, shareMode);

            if (!handle.IsInvalid)
            {
                SetCommTimeouts(handle, readTimeout, writeTimeout);
            }
            return(handle);
        }
        public void Test_World_After_Destroy()
        {
            IWorld world = Root.CreateWorld();

            HandleUtils.ForceDestroy(world.Handle);

            // IWorld methods can't throw any exception after handle destroy
            Assert.IsNull(world.CreateActor());
            world.Clear();
            world.Dispose();

            Assert.IsNull(HandleUtils.TryGetReferenceHolder(world.Handle));
        }
Example #4
0
 /// <param name="newAllocation">True if a new handle has been allocated for the caller, the caller must release the handle eventually</param>
 public static SafeFileHandle ObtainHandle(Guid volumeGuid, FileAccess access, ShareMode shareMode, out bool newAllocation)
 {
     if (m_handlePool.ContainsKey(volumeGuid))
     {
         newAllocation = false;
         return(m_handlePool[volumeGuid]);
     }
     else
     {
         newAllocation = true;
         SafeFileHandle handle = HandleUtils.GetVolumeHandle(volumeGuid, access, shareMode);
         m_handlePool.Add(volumeGuid, handle);
         return(handle);
     }
 }
Example #5
0
 /// <param name="newAllocation">True if a new handle has been allocated for the caller, the caller must release the handle eventually</param>
 public static SafeFileHandle ObtainHandle(int physicalDiskIndex, FileAccess access, ShareMode shareMode, out bool newAllocation)
 {
     if (m_handlePool.ContainsKey(physicalDiskIndex))
     {
         newAllocation = false;
         return(m_handlePool[physicalDiskIndex]);
     }
     else
     {
         newAllocation = true;
         SafeFileHandle handle = HandleUtils.GetDiskHandle(physicalDiskIndex, access, shareMode);
         m_handlePool.Add(physicalDiskIndex, handle);
         return(handle);
     }
 }
        public static List <int> GetPhysicalDiskIndexList()
        {
            List <string> devicePathList = DeviceInterfaceUtils.GetDevicePathList(DeviceInterfaceUtils.DiskClassGuid);
            List <int>    result         = new List <int>();

            foreach (string devicePath in devicePathList)
            {
                SafeFileHandle        hDevice = HandleUtils.GetFileHandle(devicePath, FileAccess.Read, ShareMode.ReadWrite);
                STORAGE_DEVICE_NUMBER number  = GetDeviceNumber(hDevice);
                hDevice.Close();
                result.Add((int)number.DeviceNumber);
            }
            // We'll now sort the list based on disk number
            result.Sort();
            return(result);
        }
Example #7
0
        /// <summary>
        ///     Draws a tangent handle.
        /// </summary>
        /// <returns>The new tangent.</returns>
        /// <param name="pointPosition">Point position.</param>
        /// <param name="tangent">Tangent.</param>
        public static Vector3 TangentHandle(Vector3 pointPosition, Vector3 tangent)
        {
            Vector3 tangentPosition = pointPosition + tangent;
            float   pointSize       = HandleUtils.GetDotSize(tangentPosition);

            Vector3 newTangentPosition = Handles.FreeMoveHandle(tangentPosition, Quaternion.identity, pointSize, Vector3.zero,
                                                                Handles.DotCap);

            Color oldColor = Handles.color;

            Handles.color = oldColor * new Color(1.0f, 1.0f, 1.0f, 0.5f);
            Handles.DrawLine(pointPosition, newTangentPosition);
            Handles.color = oldColor;

            return(newTangentPosition - pointPosition);
        }
Example #8
0
        public void Test_World()
        {
            IActor parent;

            using (IWorld world = Root.CreateWorld())
            {
                parent = world.CreateActor();
                ReferenceHolder referenceHolder = HandleUtils.TryGetReferenceHolder(parent.Handle);

                Assert.IsNotNull(world);
                Assert.AreEqual(world, parent.World);
                Assert.IsNotNull(referenceHolder);
                Assert.IsTrue(referenceHolder.IsStrong);
                Assert.IsFalse(referenceHolder.IsWeak);
            }

            Assert.IsTrue(HandleUtils.IsDestroyed(parent.Handle));
        }
Example #9
0
        /// <summary>
        ///     Draws the bezier segment between pointB and pointC.
        /// </summary>
        /// <param name="pointA">Point a.</param>
        /// <param name="pointB">Point b.</param>
        /// <param name="pointC">Point c.</param>
        /// <param name="pointD">Point d.</param>
        public static void BezierSegmentHandle(IBezierPoint pointA, IBezierPoint pointB, IBezierPoint pointC,
                                               IBezierPoint pointD)
        {
            if (Event.current.type != EventType.Repaint)
            {
                return;
            }

            BezierPath.GetSegmentPoints(ref s_BezierPoints, pointA, pointB, pointC, pointD);

            HandleUtils.BeginGL(GL.LINES, HandleUtils.handleWireMaterial);

            for (int index = 0; index < s_BezierPoints.Length - 1; index++)
            {
                GL.Vertex(s_BezierPoints[index]);
                GL.Vertex(s_BezierPoints[index + 1]);
            }

            HandleUtils.EndGL();
        }
Example #10
0
    void DrawGUINeighbours(HexCell cell)
    {
        if (cell.neighbours == null)
        {
            return;
        }

        var oldColor = Handles.color;

        Handles.color = Color.green;

        HandleUtils.CenteredLabel(cell.transform.position, cell.index.ToStringInt());

        foreach (HexCell neighbour in cell.neighbours)
        {
            Handles.DrawLine(cell.transform.position, neighbour.transform.position);
            HandleUtils.CenteredLabel(neighbour.transform.position, neighbour.index.ToStringInt());
        }

        Handles.color = oldColor;
    }
Example #11
0
        public void Test_Actor_After_Destroy()
        {
            using (IWorld world = Root.CreateWorld())
            {
                IActor puppetActor = world.CreateActor();
                IActor actor       = world.CreateActor();
                actor.Destroy();

                Assert.IsTrue(HandleUtils.IsDestroyed(actor.Handle));
                Assert.IsNull(HandleUtils.TryGetReferenceHolder(actor.Handle));

                // IActor methods can't throw any exception.
                actor.AddChild(puppetActor);
                actor.RemoveChild(puppetActor);
                actor.Destroy();
                actor.Detach();

                actor.Enabled = true;
                Assert.IsFalse(actor.Enabled);

                actor.CreateComponent <TestComponent>();
                Assert.IsNull(actor.Clone());
                Assert.IsNull(actor.GetComponent <TestComponent>());
                Assert.IsNotNull(actor.GetAllComponents());
                Assert.AreEqual(0, actor.GetAllComponents().Count);
                Assert.IsFalse(actor.HasComponent <TestComponent>());
                actor.RemoveComponent <TestComponent>();

                string testStr = "Actor";
                actor.Name = testStr;
                Assert.AreNotEqual(testStr, actor.Name);
                Assert.IsTrue(string.IsNullOrEmpty(actor.Name));
                Assert.AreEqual(-1, actor.Id);
                Assert.IsNull(actor.Parent);
                Assert.IsNull(actor.World);
                Assert.IsNotNull(actor.Children);
                Assert.AreEqual(0, actor.Children.Count);
            }
        }
Example #12
0
        /// <summary>
        /// Note: The NTFS file system treats a locked volume as a dismounted volume.
        /// </summary>
        public static bool IsVolumeMounted(Guid volumeGuid)
        {
            SafeFileHandle handle = HandleUtils.GetVolumeHandle(volumeGuid, FileAccess.Read, ShareMode.ReadWrite);

            return(IsVolumeMounted(handle));
        }
Example #13
0
        /// <summary>
        /// Note: The NTFS file system treats a locked volume as a dismounted volume.
        /// </summary>
        public static bool IsVolumeMounted(string path)
        {
            SafeFileHandle handle = HandleUtils.GetVolumeHandle(path, FileAccess.Read, ShareMode.ReadWrite);

            return(IsVolumeMounted(handle));
        }
Example #14
0
        /// <summary>
        /// Note: The NTFS file system treats a locked volume as a dismounted volume.
        /// </summary>
        public static bool IsVolumeMounted(char driveLetter)
        {
            SafeFileHandle handle = HandleUtils.GetVolumeHandle(driveLetter, FileAccess.Read, ShareMode.ReadWrite);

            return(IsVolumeMounted(handle));
        }
Example #15
0
 public SPTITarget(string path, bool emulateReportLUNs)
 {
     m_path              = path;
     m_handle            = HandleUtils.GetFileHandle(m_path, FileAccess.ReadWrite, ShareMode.None);
     m_emulateReportLUNs = emulateReportLUNs;
 }
Example #16
0
        public static SafeFileHandle GetComPortHandle(int portIndex, FileAccess access, ShareMode shareMode)
        {
            string fileName = String.Format(@"\\.\COM{0}", portIndex);

            return(HandleUtils.GetFileHandle(fileName, access, shareMode));
        }
Example #17
0
        /// <summary>
        ///     Draws the handle for a bezier point.
        /// </summary>
        /// <param name="point">Point.</param>
        public static void BezierPointHandle(IBezierPoint point)
        {
            float pointSize = HandleUtils.GetDotSize(point.position);

            point.position = Handles.FreeMoveHandle(point.position, Quaternion.identity, pointSize, Vector3.zero, Handles.DotCap);
        }