コード例 #1
0
        private void DrawRuleMatrix(RuleTile tile, Rect rect, RuleTile.Rule rule)
        {
            var index = 0;
            var w     = rect.width / 3;
            var h     = rect.height / 3;
            var color = new Color(0, 0, 0, 0.2f);

            for (var y = 0; y <= 3; y++)
            {
                var top = rect.yMin + y * h;
                HandleHelper.DrawLine(new Vector2(rect.xMin, top), new Vector2(rect.xMax, top), color);
            }

            for (var x = 0; x <= 3; x++)
            {
                var left = rect.xMin + x * w;
                HandleHelper.DrawLine(new Vector3(left, rect.yMin), new Vector3(left, rect.yMax), color);
            }

            for (var y = 0; y <= 2; y++)
            {
                for (var x = 0; x <= 2; x++)
                {
                    var r = new Rect(rect.xMin + x * w, rect.yMin + y * h, w - 1, h - 1);

                    if (x != 1 || y != 1)
                    {
                        var currentRule = rule.Neighbors[index];

                        DrawRule(tile, r, new Vector2Int(x, y), currentRule);

                        index++;
                    }
                    else
                    {
                        if (!rule.UseReference)
                        {
                            if (rule.Tile.FlipHorizontal)
                            {
                                GUI.DrawTexture(r, RuleTileEditor.Textures[10]);
                            }

                            if (rule.Tile.FlipVertical)
                            {
                                GUI.DrawTexture(r, RuleTileEditor.Textures[11]);
                            }

                            if (rule.Tile.Rotation != 0)
                            {
                                GUI.DrawTexture(r, RuleTileEditor.Textures[5]);
                            }
                        }
                    }
                }
            }
        }
コード例 #2
0
 private void DrawTextHandle(TileInfo first, TileInfo second, string text, Vector2 position, TextAnchor alignment, Color color, Func <TileInfo, bool> func)
 {
     if (!string.IsNullOrEmpty(text))
     {
         if (func == null || (!func.Invoke(first) && !func.Invoke(second)))
         {
             HandleHelper.DrawText(position, text, alignment, color);
         }
     }
 }
コード例 #3
0
        private void DrawPart(Building.Part part)
        {
            if (part.Renderer.sprite)
            {
                var snap           = 1 / part.Renderer.sprite.pixelsPerUnit;
                var selectedBounds = HandleHelper.MoveHandle(part.Renderer.bounds.center, part.Bounds.size, new Vector2(snap, snap), Color.green, new Color(0.0f, 0.0f, 0.0f, 0.25f));
                selectedBounds -= (Vector2)part.Renderer.bounds.extents;

                UpdatePartTransform(part, selectedBounds);
            }
        }
コード例 #4
0
            public void GeneratesIdFromHandle()
            {
                HandleHelper.GenerateId("handle").Returns("derived-id");
                var spec = new ContainerSpec
                {
                    Handle = "handle",
                };

                var container = Service.CreateContainer(spec);

                Assert.Equal("derived-id", container.Id);
            }
コード例 #5
0
        public ContainerServiceTests()
        {
            ContainerBasePath  = @"C:\Containers";
            ContainerUserGroup = "ContainerUsers";

            ContainerPropertiesService = Substitute.For <IContainerPropertyService>();

            FileSystem = Substitute.For <IFileSystemManager>();

            Id = "DEADBEEF";

            HandleHelper = Substitute.For <ContainerHandleHelper>();
            HandleHelper.GenerateId(null).ReturnsForAnyArgs(Id);

            ProcessRunner  = Substitute.For <IProcessRunner>();
            TcpPortManager = Substitute.For <ILocalTcpPortManager>();
            UserManager    = Substitute.For <IUserManager>();

            ContainerHostClient = Substitute.For <IContainerHostClient>();

            ContainerHostService = Substitute.For <IContainerHostService>();
            ContainerHostService.StartContainerHost(null, null, null, null)
            .ReturnsForAnyArgs(ContainerHostClient);

            UserManager.CreateUser(null).ReturnsForAnyArgs(new NetworkCredential("username", "password"));
            sid = "S-1234";
            UserManager.GetSID(null).ReturnsForAnyArgs(sid);

            diskQuotaManager   = Substitute.For <IDiskQuotaManager>();
            containerDiskQuota = Substitute.For <IContainerDiskQuota>();
            diskQuotaManager.CreateDiskQuotaControl(null, "").ReturnsForAnyArgs(containerDiskQuota);

            var directoryFactory = Substitute.For <IContainerDirectoryFactory>();

            containerDirectory = Substitute.For <IContainerDirectory>();
            directoryFactory.Create(FileSystem, ContainerBasePath, Id).Returns(containerDirectory);

            var containerFactory = new TestContainerFactory();

            Service = new ContainerService(
                HandleHelper,
                UserManager,
                FileSystem,
                ContainerPropertiesService,
                TcpPortManager,
                ProcessRunner,
                ContainerHostService,
                diskQuotaManager,
                directoryFactory,
                containerFactory,
                ContainerBasePath
                );
        }
コード例 #6
0
        private void DrawBounds()
        {
            var bounds       = _building.Bounds;
            var roofPosition = new Vector2(bounds.center.x, bounds.yMax - _building.RoofHeight);
            var size         = HandleUtility.GetHandleSize(bounds.center) * 0.1f;

            HandleHelper.DrawLine(new Vector2(bounds.xMin, roofPosition.y), new Vector2(bounds.xMax, roofPosition.y), Color.cyan);

            var selectedBounds       = HandleHelper.BoundsHandle(bounds, new Vector2(0.5f, 0.5f), Color.blue, Color.clear, Color.white, Color.white);
            var selectedRoofPosition = HandleHelper.MoveHandle(roofPosition, new Vector2(size * 2.5f, size), Vector2.one, Color.cyan, Color.cyan);

            UpdateMainTransforms(selectedBounds, _building.SortPoint, bounds.yMax - selectedRoofPosition.y, true);
        }
コード例 #7
0
ファイル: MainWindow.xaml.cs プロジェクト: FFFirer/WTalk
        private void btnLogin_Click(object sender, RoutedEventArgs e)
        {
            GetConnected();
            string   ID    = txtId.Text.Trim();
            string   PWD   = txtPwd.Password.Trim();
            LoginMsg login = new LoginMsg(ID, PWD);

            bw.Write(string.Format("LOGIN@{0}", HandleHelper.XMLSer <LoginMsg>(login)));
            bw.Flush();
            //ChatWindow cw = new ChatWindow();
            //cw.Show();
            //this.Close();
        }
コード例 #8
0
            public void WhenHandleIsNotProvided_GeneratesHandle(string handle)
            {
                var expectedHandle = Guid.NewGuid().ToString("N");

                HandleHelper.GenerateHandle().Returns(expectedHandle);
                var spec = new ContainerSpec
                {
                    Handle = handle,
                };

                var container = Service.CreateContainer(spec);

                Assert.NotEqual(handle, container.Handle);
                Assert.Equal(expectedHandle, container.Handle);
            }
コード例 #9
0
 /// <summary>
 /// 启用毛玻璃
 /// </summary>
 protected void ActiveBlur(bool flag)
 {
     if (flag)
     {
         if (!IsInitialized)
         {
             SourceInitialized += YT_Window_SourceInitialized;
         }
         else
         {
             YT_Window_SourceInitialized(null, null);
         }
     }
     else
     {
         BlurEffect.EnableBlur(HandleHelper.GetVisualHandle(this), AccentState.ACCENT_DISABLED);
     }
 }
コード例 #10
0
        private void OnSceneGUI()
        {
            var area = new Rect(_areaController.transform.position.x - Mover.PositionOffset.x - _areaController.LeftDistance, _areaController.transform.position.y - Mover.PositionOffset.y - _areaController.DownDistance, 1 + _areaController.RightDistance + _areaController.LeftDistance, 1 + _areaController.UpDistance + _areaController.DownDistance);

            Handles.DrawSolidRectangleWithOutline(area, new Color(0.0f, 1.0f, 1.0f, 0.1f), Color.cyan);

            var bounds = HandleHelper.ScaleHandles(area, Vector2.one, Color.white, Color.white);

            using (new UndoScope(serializedObject))
            {
                _left.intValue  -= Mathf.RoundToInt(bounds.xMin - area.xMin);
                _right.intValue += Mathf.RoundToInt(bounds.xMax - area.xMax);
                _up.intValue    += Mathf.RoundToInt(bounds.yMax - area.yMax);
                _down.intValue  -= Mathf.RoundToInt(bounds.yMin - area.yMin);

                Validate();
            }
        }
コード例 #11
0
        private void DrawRuleMatrix(RuleTile tile, Rect rect, RuleTile.Rule rule)
        {
            var index = 0;
            var w     = rect.width / 3;
            var h     = rect.height / 3;
            var color = new Color(0, 0, 0, 0.2f);

            for (var y = 0; y <= 3; y++)
            {
                var top = rect.yMin + y * h;
                HandleHelper.DrawLine(new Vector2(rect.xMin, top), new Vector2(rect.xMax, top), color);
            }

            for (var x = 0; x <= 3; x++)
            {
                var left = rect.xMin + x * w;
                HandleHelper.DrawLine(new Vector2(left, rect.yMin), new Vector2(left, rect.yMax), color);
            }

            for (var y = 0; y <= 2; y++)
            {
                for (var x = 0; x <= 2; x++)
                {
                    var r = new Rect(rect.xMin + x * w, rect.yMin + y * h, w - 1, h - 1);

                    if (x != 1 || y != 1)
                    {
                        var currentRule = rule.Neighbors[index];

                        DrawRule(tile, r, new Vector2Int(x, y), currentRule);

                        if (Event.current.type == EventType.MouseDown && r.Contains(Event.current.mousePosition))
                        {
                            if (Event.current.button == 0)
                            {
                                rule.Neighbors[index] = (RuleTile.NeighborType)Mathf.Repeat((int)currentRule + 1, (int)RuleTile.NeighborType.Count);

                                GUI.changed = true;
                                Event.current.Use();
                            }
                        }

                        index++;
                    }
                    else
                    {
                        if (!rule.UseReference)
                        {
                            if (rule.Tile.FlipHorizontal)
                            {
                                GUI.DrawTexture(r, Textures[10]);
                            }

                            if (rule.Tile.FlipVertical)
                            {
                                GUI.DrawTexture(r, Textures[11]);
                            }

                            if (rule.Tile.Rotation != 0)
                            {
                                GUI.DrawTexture(r, Textures[5]);
                            }
                        }
                    }
                }
            }
        }
コード例 #12
0
        private void OnSceneGUI()
        {
            if (_mapProperties.ClampBounds)
            {
                var bounds = _mapProperties.GetBounds();

                var xMin   = _mapProperties.ClampLeftBounds ? _mapProperties.LeftBounds : bounds.xMin;
                var yMin   = _mapProperties.ClampBottomBounds ? _mapProperties.BottomBounds : bounds.yMin;
                var width  = (_mapProperties.ClampRightBounds ? _mapProperties.RightBounds : bounds.xMax) - xMin;
                var height = (_mapProperties.ClampTopBounds ? _mapProperties.TopBounds : bounds.yMax) - yMin;

                if (_mapProperties.ClampLeftBounds)
                {
                    Handles.DrawSolidRectangleWithOutline(new Rect(_mapProperties.LeftBounds - 0.5f, yMin, 0.5f, height), Color.black, Color.black);
                }

                if (_mapProperties.ClampRightBounds)
                {
                    Handles.DrawSolidRectangleWithOutline(new Rect(_mapProperties.RightBounds, yMin, 0.5f, height), Color.black, Color.black);
                }

                if (_mapProperties.ClampTopBounds)
                {
                    Handles.DrawSolidRectangleWithOutline(new Rect(xMin, _mapProperties.TopBounds, width, 0.5f), Color.black, Color.black);
                }

                if (_mapProperties.ClampBottomBounds)
                {
                    Handles.DrawSolidRectangleWithOutline(new Rect(xMin, _mapProperties.BottomBounds - 0.5f, width, 0.5f), Color.black, Color.black);
                }
            }

            var camera     = Camera.current;
            var screenRect = new Rect(camera.ScreenToWorldPoint(Vector2.zero) - Vector3.one, new Vector2(camera.orthographicSize * 2 * camera.aspect, camera.orthographicSize * 2) + Vector2.one);

            if (camera.orthographicSize > 10)
            {
                return;
            }

            foreach (var tile in _mapProperties.Tiles.Values)
            {
                if (!screenRect.Contains(tile.Position))
                {
                    continue;
                }

                var center     = tile.Position + new Vector2(0.5f, 0.5f);
                var leftCenter = tile.Position + new Vector2(0.05f, 0.55f);
                var topLeft    = tile.Position + new Vector2(0.05f, 1.0f);
                var bottomLeft = tile.Position + new Vector2(0.05f, 0.2f);

                var left   = _mapProperties.GetTile(tile.Position + Vector2Int.left);
                var top    = _mapProperties.GetTile(tile.Position + Vector2Int.up);
                var bottom = _mapProperties.GetTile(tile.Position + Vector2Int.down);

                if (tile.HasSpawnPoint && !string.IsNullOrEmpty(tile.SpawnPoint.Name))
                {
                    if (tile.SpawnPoint.Direction != MovementDirection.None)
                    {
                        HandleHelper.DrawArrow(center, Direction.GetVector(tile.SpawnPoint.Direction), 0.5f, Color.white);
                    }

                    DrawTextHandle(null, null, tile.SpawnPoint.Name, leftCenter, TextAnchor.MiddleLeft, Color.white, null);
                }

                if (tile.HasStairs)
                {
                    HandleHelper.DrawArrow(tile.Position + new Vector2(0.0f, 0.5f - (tile.Slope * 0.5f)), new Vector2(1.0f, tile.Slope), 1.0f, Color.white);

                    DrawTextHandle(top, left, "Slope: " + tile.Slope.ToString(), leftCenter, TextAnchor.MiddleLeft, Color.white, tile.IsSameStairsAs);
                }

                if (tile.HasEdge)
                {
                    if (tile.EdgeDirection != MovementDirection.None)
                    {
                        HandleHelper.DrawArrow(center, Direction.GetVector(tile.EdgeDirection), 0.5f, Color.white);
                    }

                    DrawTextHandle(top, left, "Edge: " + tile.EdgeDirection.ToString(), leftCenter, TextAnchor.MiddleLeft, Color.white, tile.IsSameEdgeAs);
                }

                if (tile.HasOffset)
                {
                    DrawTextHandle(bottom, left, "Offset: " + tile.Offset.ToString(), bottomLeft, TextAnchor.LowerLeft, Color.white, tile.IsSameOffsetAs);
                }
                if (tile.HasZoneTrigger && tile.Zone.TargetZone != null)
                {
                    DrawTextHandle(top, left, "Target Zone:\n" + tile.Zone.TargetZone.name, topLeft, TextAnchor.UpperLeft, Color.white, tile.IsSameZoneAs);
                }
                if (tile.CollisionLayer != CollisionLayer.None)
                {
                    DrawTextHandle(top, left, "Collision:\n" + tile.CollisionLayer.ToString(), topLeft, TextAnchor.UpperLeft, Color.white, tile.IsSameCollisionLayer);
                }
                if (tile.LayerChange != CollisionLayer.None)
                {
                    DrawTextHandle(bottom, left, "Layer: " + tile.LayerChange.ToString(), bottomLeft, TextAnchor.LowerLeft, Color.white, tile.IsSameCollisionLayerIncrement);
                }
                if (tile.HasEncounter && tile.Encounter != null)
                {
                    DrawTextHandle(top, left, "Encounter:\n " + tile.Encounter.name, topLeft, TextAnchor.UpperLeft, Color.white, tile.IsSameEncounterAs);
                }
            }
        }
コード例 #13
0
ファイル: YT_DialogBase.cs プロジェクト: 20154530/YControls
 private void YT_Window_SourceInitialized(object sender, EventArgs e)
 {
     BlurEffect.EnableBlur(HandleHelper.GetVisualHandle(this), AccentState.ACCENT_ENABLE_BLURBEHIND);
 }
コード例 #14
0
        private void OnSceneGUI()
        {
            if (_pathController.Path.Nodes.Length > 0)
            {
                var lineColor         = Color.cyan;
                var fillColor         = new Color(0.0f, 1.0f, 1.0f, 0.2f);
                var mover             = _pathController.GetComponent <Mover>();
                var pathfinding       = ComponentHelper.GetComponentInScene <Pathfinding>(_pathController.gameObject.scene.buildIndex, false);
                var transformPosition = _pathController.Path.UseAbsolutePositioning ? Vector2.zero : (Vector2)_pathController.transform.position;

                if (_pathController.Path.Nodes.Length > 2 && _pathController.Path.Type == Path.PathType.Loop)
                {
                    var first = _pathController.Path.Nodes[0];
                    var last  = _pathController.Path.Nodes[_pathController.Path.Nodes.Length - 1];

                    var firstPosition = GetPosition(first.Position, _pathController.transform.position, Mover.PositionOffset);
                    var lastPosition  = GetPosition(last.Position, transformPosition, Mover.PositionOffset);

                    if (_pathController.Path.UsePathfinding && pathfinding)
                    {
                        var pathFrom = GetPathPosition(first.Position, _pathController.transform.position);
                        var pathTo   = GetPathPosition(last.Position, transformPosition);
                        var path     = pathfinding.GetPath(mover.MovementLayer, pathFrom, pathTo, false);

                        if (path.Count > 1)
                        {
                            for (var n = 1; n < path.Count; n++)
                            {
                                var node     = path[n];
                                var position = node + Mover.PositionOffset;

                                HandleHelper.DrawLine(position, firstPosition, lineColor);

                                firstPosition = position;
                            }
                        }
                    }
                    else
                    {
                        HandleHelper.DrawLine(lastPosition, firstPosition, lineColor);
                    }
                }

                for (var i = 1; i < _pathController.Path.Nodes.Length; i++)
                {
                    var previous = _pathController.Path.Nodes[i - 1];
                    var current  = _pathController.Path.Nodes[i];

                    var previousPosition = GetPosition(previous.Position, i == 1 ? (Vector2)_pathController.transform.position : transformPosition, Mover.PositionOffset);
                    var currentPosition  = GetPosition(current.Position, transformPosition, Mover.PositionOffset);

                    if (_pathController.Path.UsePathfinding && pathfinding)
                    {
                        var pathFrom = GetPathPosition(previous.Position, i == 1 ? (Vector2)_pathController.transform.position : transformPosition);
                        var pathTo   = GetPathPosition(current.Position, transformPosition);
                        var path     = pathfinding.GetPath(mover.MovementLayer, pathFrom, pathTo, false);

                        if (path.Count > 1)
                        {
                            for (var n = 1; n < path.Count; n++)
                            {
                                var node     = path[n];
                                var position = node + Mover.PositionOffset;

                                HandleHelper.DrawLine(position, previousPosition, lineColor);

                                previousPosition = position;
                            }
                        }
                    }
                    else
                    {
                        HandleHelper.DrawLine(currentPosition, previousPosition, Color.cyan);
                    }
                }

                for (var i = 0; i < _pathController.Path.Nodes.Length; i++)
                {
                    var node             = _pathController.Path.Nodes[i];
                    var position         = GetPosition(node.Position, i == 0 ? (Vector2)_pathController.transform.position : transformPosition, Mover.PositionOffset);
                    var selectedPosition = HandleHelper.MoveHandle(position, Vector2.one, lineColor, fillColor, 0.25f);

                    if (i != 0 && position != selectedPosition)
                    {
                        selectedPosition -= transformPosition;

                        using (new UndoScope(_pathController, true))
                            _pathController.Path.Nodes[i].Position = Vector2Int.FloorToInt(selectedPosition);
                    }

                    if (node.Delay > 0 && node.Direction != MovementDirection.None)
                    {
                        HandleHelper.DrawArrow(selectedPosition, Direction.GetVector(node.Direction), 0.25f, Color.white);
                    }

                    HandleHelper.DrawText(new Vector2(selectedPosition.x, selectedPosition.y + 0.05f), i.ToString(), TextAnchor.MiddleCenter, Color.white);
                }
            }
        }