Exemplo n.º 1
0
    override public async void OnStateEnter(Animator animator, AnimatorStateInfo stateInfo, int layerIndex)
    {
        try
        {
            if (pathWalker == null)
            {
                pathWalker = animator.gameObject.GetComponent <PathWalker>();
            }
            if (behaviourDisplay == null)
            {
                behaviourDisplay = animator.gameObject.GetComponentInChildren <TextMesh>();
            }
            if (mineDetector == null)
            {
                mineDetector = animator.gameObject.GetComponentInChildren <MineDetector>();
            }

            if (mineDetector.Mine == null)
            {
                animator.SetBool("MinesInView", false);
                return;
            }

            await pathWalker.WalkTo(mineDetector.Mine.Position);

            SoundManager.Instance.PlaySound(Sound.Peasant_More_Work_Sound_Effect);
            behaviourDisplay.text = $"{ GetType() }";
            collectedGold         = animator.GetInteger("Gold");
        }
        catch (Exception e)
        {
            Debug.LogError(e.Message);
        }
    }
Exemplo n.º 2
0
#pragma warning restore CA1707 // Identifiers should not contain underscores
#pragma warning restore SA1600 // Elements must be documented
#pragma warning restore CS1591 // Missing XML comment for publicly visible type or member
#pragma warning restore SA1313 // Parameter names must begin with lower-case letter
        //// ReSharper restore UnusedParameter.Global

        /// <summary>
        /// Tries to find C in this.C.P1.P2.
        /// </summary>
        /// <param name="expression">The <see cref="ExpressionSyntax"/>.</param>
        /// <param name="token">The root member.</param>
        /// <returns>True if root was found.</returns>
        public static bool TryFindRoot(ExpressionSyntax expression, out SyntaxToken token)
        {
            using (var walker = PathWalker.Borrow(expression))
            {
                return(walker.TryFirst(out token));
            }
        }
Exemplo n.º 3
0
    override public async void OnStateEnter(Animator animator, AnimatorStateInfo stateInfo, int layerIndex)
    {
        try
        {
            if (pathWalker == null)
            {
                pathWalker = animator.gameObject.GetComponent <PathWalker>();
            }
            if (behaviourDisplay == null)
            {
                behaviourDisplay = animator.gameObject.GetComponentInChildren <TextMesh>();
            }
            if (mineDetector == null)
            {
                mineDetector = animator.gameObject.GetComponentInChildren <MineDetector>();
            }
            if (creature == null)
            {
                creature = animator.gameObject.GetComponent <Creature>();
            }

            behaviourDisplay.text = $"{ GetType() }";
            await pathWalker.WalkTo(PathFinderManager.Instance.RandomWalkablePosition);
        }
        catch (Exception e)
        {
            Debug.LogError(e);
            OnStateEnter(animator, stateInfo, layerIndex);
        }
    }
Exemplo n.º 4
0
 /// <summary>
 /// Gets search config for find and replace
 /// </summary>
 private FRConfiguration GetFRConfig(String path, String mask, Boolean recursive)
 {
     if (path.Trim() == "<Project>")
     {
         if (PluginBase.CurrentProject != null)
         {
             PathWalker    walker;
             List <String> allFiles = new List <String>();
             IProject      project  = PluginBase.CurrentProject;
             String        projPath = Path.GetDirectoryName(project.ProjectPath);
             walker = new PathWalker(projPath, mask, recursive);
             List <String> projFiles = walker.GetFiles();
             foreach (String file in projFiles)
             {
                 if (!IsFileHidden(file, project))
                 {
                     allFiles.Add(file);
                 }
             }
             return(new FRConfiguration(allFiles, this.GetFRSearch()));
         }
         else
         {
             return(null);
         }
     }
     else
     {
         return(new FRConfiguration(path, mask, recursive, this.GetFRSearch()));
     }
 }
Exemplo n.º 5
0
        /// <summary> Compares equality by path. </summary>
        /// <param name="x">The first instance.</param>
        /// <param name="y">The other instance.</param>
        /// <returns>True if the instances are found equal.</returns>
        public static bool Equals(PathWalker x, PathWalker y)
        {
            if (ReferenceEquals(x, y))
            {
                return(true);
            }

            if (x is null || y is null)
            {
                return(false);
            }

            var xs = x.Tokens;
            var ys = y.Tokens;

            if (xs.Count == 0 ||
                xs.Count != ys.Count)
            {
                return(false);
            }

            for (var i = 0; i < xs.Count; i++)
            {
                if (xs[i].ValueText != ys[i].ValueText)
                {
                    return(false);
                }
            }

            return(true);
        }
Exemplo n.º 6
0
        /// <summary>
        /// Generates the menu for the selected sci control
        /// </summary>
        public void GenerateSnippets(ScintillaNet.ScintillaControl sci)
        {
            var files = new List <string>();

            string specific = Path.Combine(Path.Combine(PathHelper.SnippetDir, sci.ConfigurationLanguage), SurroundWithCommand.SurroundFolder);

            if (Directory.Exists(specific))
            {
                var walker = new PathWalker(specific, "*" + SurroundWithCommand.SurroundExt, false);
                files.AddRange(walker.GetFiles());
            }

            string global = Path.Combine(PathHelper.SnippetDir, SurroundWithCommand.SurroundFolder);

            if (Directory.Exists(global))
            {
                var walker = new PathWalker(global, "*" + SurroundWithCommand.SurroundExt, false);
                files.AddRange(walker.GetFiles());
            }

            items.Clear();
            if (files.Count > 0)
            {
                files.Sort();
                foreach (string file in files)
                {
                    string content = File.ReadAllText(file);
                    if (content.IndexOfOrdinal("{0}") >= 0)
                    {
                        items.Add(new SurroundWithItem(Path.GetFileNameWithoutExtension(file)));
                    }
                }
            }
        }
 /// <summary>
 /// Gets search config for find and replace
 /// </summary>
 private FRConfiguration GetFRConfig(String path, String mask, Boolean recursive)
 {
     if (path.Trim() == "<Project>")
     {
         if (PluginBase.CurrentProject != null)
         {
             PathWalker    walker;
             List <String> allFiles = new List <String>();
             IProject      project  = PluginBase.CurrentProject;
             String        projPath = Path.GetDirectoryName(project.ProjectPath);
             walker = new PathWalker(projPath, mask, recursive);
             allFiles.AddRange(walker.GetFiles());
             for (var i = 0; i < project.SourcePaths.Length; i++)
             {
                 String sourcePath = project.GetAbsolutePath(project.SourcePaths[i]);
                 if (Directory.Exists(sourcePath) && !sourcePath.StartsWith(projPath))
                 {
                     walker = new PathWalker(sourcePath, mask, recursive);
                     allFiles.AddRange(walker.GetFiles());
                 }
             }
             return(new FRConfiguration(allFiles, this.GetFRSearch()));
         }
         else
         {
             return(null);
         }
     }
     else
     {
         return(new FRConfiguration(path, mask, recursive, this.GetFRSearch()));
     }
 }
Exemplo n.º 8
0
        /// <summary>
        /// Gets the files
        /// </summary>
        public List <String> GetFiles()
        {
            switch (type)
            {
            case OperationType.FindInRange:
                return(this.files);

            case OperationType.FindInSource:
                if (this.files == null)
                {
                    this.files = new List <String>();
                    this.files.Add(path);
                }
                return(files);

            case OperationType.FindInFile:
                if (this.files == null)
                {
                    this.files = new List <String>();
                    this.files.Add(path);
                }
                return(this.files);

            case OperationType.FindInPath:
                if (this.files == null)
                {
                    PathWalker walker = new PathWalker(this.path, this.mask, this.recursive);
                    this.files = walker.GetFiles();
                }
                return(this.files);
            }
            return(null);
        }
Exemplo n.º 9
0
    override public async void OnStateEnter(Animator animator, AnimatorStateInfo stateInfo, int layerIndex)
    {
        try
        {
            if (pathWalker == null)
            {
                pathWalker = animator.gameObject.GetComponent <PathWalker>();
            }
            if (behaviourDisplay == null)
            {
                behaviourDisplay = animator.gameObject.GetComponentInChildren <TextMesh>();
            }
            if (base_home == null)
            {
                base_home = GameManager.Instance.GetBase();
            }
            if (mineDetector == null)
            {
                mineDetector = animator.gameObject.GetComponentInChildren <MineDetector>();
            }

            behaviourDisplay.text = $"{ GetType() }";
            collectedGold         = animator.GetInteger("Gold");
            base_home             = GameManager.Instance.GetBase();

            SoundManager.Instance.PlaySound(Sound.Peasant_Yes_My_Lord_Sound_Effect);
            await pathWalker.WalkTo(base_home.transform.position);
        }
        catch (Exception e)
        {
            Debug.LogError(e);
        }
    }
Exemplo n.º 10
0
    // OnStateEnter is called when a transition starts and the state machine starts to evaluate this state
    override public async void OnStateEnter(Animator animator, AnimatorStateInfo stateInfo, int layerIndex)
    {
        try
        {
            if (pathWalker == null)
            {
                pathWalker = animator.gameObject.GetComponent <PathWalker>();
            }
            if (creature == null)
            {
                creature = animator.gameObject.GetComponent <Creature>();
            }

            var go = GameManager.Instance.Creatures.Where(x => x.name.Contains("Enemy")).FirstOrDefault(x => (x.gameObject.transform.position - animator.gameObject.transform.position).magnitude < creature.view_range);

            if (go == null)
            {
                animator.SetBool("EnemyInRange", false);
                return;
            }

            SoundManager.Instance.PlaySound(Sound.Footman_Aggro);
            enemy = go.GetComponent <Creature>();
            await pathWalker.WalkTo(enemy.gameObject.transform.position + ((animator.transform.position - enemy.gameObject.transform.position).normalized * 1.5f));
        }
        catch (System.Exception e)
        {
            Debug.LogError(e.Message);
        }
    }
Exemplo n.º 11
0
        private IEnumerator Start()
        {
            Camera camera = m_camInputsManager.CurrentCamera;

            m_cameraFade = camera.GetComponent <CameraFade>();
            m_camera     = camera.transform;

            m_pathWalker = camera.GetComponentInParent <PathWalker>();


            if (m_camInputsManager.CurrentInputName == "Touch")
            {
                m_selectionRadial = m_touch.GetComponent <SelectionRadial>();
                m_reticle         = m_touch.GetComponent <Reticle>();
            }
            else
            {
                m_selectionRadial = camera.GetComponent <SelectionRadial>();
                m_reticle         = camera.GetComponent <Reticle>();
            }
            SessionData.SetGameType(m_gameType);
            //loop to all phases
            while (true)
            {
                yield return(StartCoroutine(StartPhase()));

                yield return(StartCoroutine(PlayPhase()));

                yield return(StartCoroutine(EndPhase()));
            }
        }
Exemplo n.º 12
0
 /// <summary>
 /// Checks that the path is empty, this is true for this. and base. calls.
 /// </summary>
 /// <param name="expression">The <see cref="ExpressionSyntax"/>.</param>
 /// <returns>True if the path is empty, this is true for this. and base. calls.</returns>
 public static bool IsEmpty(ExpressionSyntax expression)
 {
     using (var walker = PathWalker.Borrow(expression))
     {
         return(walker.Tokens.Count == 0);
     }
 }
Exemplo n.º 13
0
 /// <summary>
 /// Tries to find Baz in this.foo.Bar.Baz.
 /// </summary>
 /// <param name="expression">The <see cref="ExpressionSyntax"/>.</param>
 /// <param name="member">The leaf member.</param>
 /// <returns>True if leaf was found.</returns>
 public static bool TryFindLast(ExpressionSyntax expression, out IdentifierNameSyntax member)
 {
     using (var walker = PathWalker.Borrow(expression))
     {
         return(walker.IdentifierNames.TryLast(out member));
     }
 }
Exemplo n.º 14
0
 /// <summary>
 /// Walks the given walker through the path.
 /// </summary>
 /// <param name="walker">the walker.
 /// </param>
 /// <param name="error">the error matrix.
 /// </param>
 public virtual void walk(PathWalker walker, System.Drawing.Drawing2D.Matrix errorMatrix, double error)
 {
     for (int i = 0; i < subPaths.Length; i++)
     {
         subPaths[i].walk(walker, errorMatrix, error);
     }
 }
Exemplo n.º 15
0
    override public async void OnStateEnter(Animator animator, AnimatorStateInfo stateInfo, int layerIndex)
    {
        try
        {
            if (pathWalker == null)
            {
                pathWalker = animator.gameObject.GetComponent <PathWalker>();
            }
            if (behaviourDisplay == null)
            {
                behaviourDisplay = animator.gameObject.GetComponentInChildren <TextMesh>();
            }
            if (explorerDetector == null)
            {
                explorerDetector = animator.gameObject.GetComponentInChildren <MineDetector>();
            }

            behaviourDisplay.text = $"{ GetType() }";

            SoundManager.Instance.PlaySound(Sound.Footman_As_You_Wish_Sound_Effect);

            await pathWalker.WalkTo(explorerDetector.Mine.Position);
        }
        catch (Exception e)
        {
            Debug.LogError(e.Message);
        }
    }
Exemplo n.º 16
0
        internal static bool Uses(ExpressionSyntax assigned, ExpressionSyntax returned, SyntaxNodeAnalysisContext context, PooledHashSet <SyntaxNode> visited = null)
        {
            if (assigned is null ||
                returned is null)
            {
                return(false);
            }

            using (var assignedPath = PathWalker.Borrow(assigned))
            {
                var containingType = context.ContainingSymbol.ContainingType;
                if (UsedMemberWalker.Uses(returned, assignedPath, Search.TopLevel, containingType, context.SemanticModel, context.CancellationToken))
                {
                    return(true);
                }

                if (assignedPath.IdentifierNames.TrySingle(out var candidate) &&
                    containingType.TryFindPropertyRecursive(candidate.Identifier.ValueText, out var property) &&
                    property.TrySingleDeclaration(context.CancellationToken, out var declaration) &&
                    declaration.TryGetSetter(out var setter) &&
                    Property.TrySingleAssignmentInSetter(setter, out var assignment))
                {
                    using (visited = PooledHashSet <SyntaxNode> .BorrowOrIncrementUsage(visited))
                    {
                        if (visited.Add(candidate))
                        {
                            return(Uses(assignment.Left, returned, context, visited));
                        }
                    }
                }
            }

            return(false);
        }
Exemplo n.º 17
0
 protected override void Awake()
 {
     base.Awake();
     PathWalker = gameObject.AddComponent <PathWalker>();
     PathWalker.StartPathWalking();
     health.HealhDamagedEvent += OnHealthDamagedEvent;
     Ramses.Confactory.ConfactoryFinder.Instance.Give <ConEnemyTracker>().RegisterEnemy(this);
 }
Exemplo n.º 18
0
    void Start()
    {
        _anim = GetComponent <Animator> ();
        //CreateWaypointMap ();

        _pathWalker = new PathWalker(this.gameObject, _anim);

        GotoWayPoint();
    }
Exemplo n.º 19
0
 private void  walk(PathWalker walker, double[] points, int l, bool closed)
 {
     walker.beginSubPath(closed);
     for (int i = 0; i < l; i += 2)
     {
         walker.lineTo(points[i], points[i + 1]);
     }
     walker.endSubPath();
 }
    // Spawn a new pathwalker.
    private void SpawnPathWalker()
    {
        int random = Random.Range(0, 101);

        if (random < mapGenerator.PathWalkerChanceToSpawn)
        {
            PathWalker pathWalker = Instantiate(mapGenerator.pathWalkerPrefab, transform.position, Quaternion.identity, mapGenerator.pathWalkersContainer).GetComponent <PathWalker>();
            pathWalker.Initialize(position, maxSteps / 2);
        }
    }
Exemplo n.º 21
0
 public void Kill()
 {
     if (!_isDead)
     {
         Debug.Log(gameObject.name + " has been killer");
         _isDead = true;
         _anim.SetTrigger("Death");
         _pathWalker = null;
     }
 }
Exemplo n.º 22
0
		//UPGRADE_NOTE: ref keyword was added to struct-type parameters. 'ms-help://MS.VSCC.2003/commoner/redir/redirect.htm?keyword="jlca1303_3"'
		public virtual void  walk(PathWalker walker, ref System.Drawing.PointF position, System.Drawing.Drawing2D.Matrix errorMatrix, double error)
		{
			System.Drawing.PointF p1 = position;
			//UPGRADE_NOTE: ref keyword was added to struct-type parameters. 'ms-help://MS.VSCC.2003/commoner/redir/redirect.htm?keyword="jlca1303_3"'
			System.Drawing.PointF p2 = calcPoint(1.0, ref position);
			
			//UPGRADE_NOTE: ref keyword was added to struct-type parameters. 'ms-help://MS.VSCC.2003/commoner/redir/redirect.htm?keyword="jlca1303_3"'
			iterate(walker, ref position, errorMatrix, error, 0.0, ref p1, 1.0, ref p2);
			position.X = (float) p2.X;
			position.Y = (float) p2.Y;
		}
Exemplo n.º 23
0
        //UPGRADE_NOTE: ref keyword was added to struct-type parameters. 'ms-help://MS.VSCC.2003/commoner/redir/redirect.htm?keyword="jlca1303_3"'
        public virtual void walk(PathWalker walker, ref System.Drawing.PointF position, System.Drawing.Drawing2D.Matrix errorMatrix, double error)
        {
            System.Drawing.PointF p1 = position;
            //UPGRADE_NOTE: ref keyword was added to struct-type parameters. 'ms-help://MS.VSCC.2003/commoner/redir/redirect.htm?keyword="jlca1303_3"'
            System.Drawing.PointF p2 = calcPoint(1.0, ref position);

            //UPGRADE_NOTE: ref keyword was added to struct-type parameters. 'ms-help://MS.VSCC.2003/commoner/redir/redirect.htm?keyword="jlca1303_3"'
            iterate(walker, ref position, errorMatrix, error, 0.0, ref p1, 1.0, ref p2);
            position.X = (float) p2.X;
            position.Y = (float) p2.Y;
        }
Exemplo n.º 24
0
    private void Update()
    {
        if (pathWalker == null)
        {
            pathWalker = GetComponentInParent <PathWalker>();
        }

        Vector3 relative = transform.InverseTransformPoint(pathWalker.NextPosition);
        float   angle    = Mathf.Atan2(relative.x, relative.y) * Mathf.Rad2Deg - 90;

        transform.Rotate(0, 0, -angle);
    }
Exemplo n.º 25
0
        /// <summary> Walks the given walker through this subpath.
        ///
        /// </summary>
        /// <param name="walker">the walker.
        /// </param>
        /// <param name="error">the error matrix.
        /// </param>
        public virtual void walk(PathWalker walker, System.Drawing.Drawing2D.Matrix errorMatrix, double error)
        {
            System.Drawing.PointF position = new System.Drawing.PointF((float)startX, (float)startY);

            walker.beginSubPath(closed);
            walker.lineTo(startX, startY);
            for (int i = 0; i < segments.Length; i++)
            {
                //UPGRADE_NOTE: ref keyword was added to struct-type parameters. 'ms-help://MS.VSCC.2003/commoner/redir/redirect.htm?keyword="jlca1303_3"'
                segments[i].walk(walker, ref position, errorMatrix, error);
            }
            walker.endSubPath();
        }
    // Initialize the map generation
    public void InitGeneration()
    {
        origin = new Vector2(xSize * mapScale / 2, ySize * mapScale / 2);
        Camera.main.transform.position = new Vector3(origin.x, origin.y, Camera.main.transform.position.z);

        // Destroy all previous tiles, collectibles and pathwalkers
        foreach (Transform tile in tilesContainers)
        {
            Destroy(tile.gameObject);
        }

        foreach (Transform collectible in collectiblesContainers)
        {
            Destroy(collectible.gameObject);
        }

        foreach (Transform walker in pathWalkersContainer)
        {
            Destroy(walker.gameObject);
        }

        // Clear all lists
        pathWalkers.Clear();
        ammoChests.Clear();
        weaponChests.Clear();

        // Fill the list with empty tiles
        tiles = new List <List <GameObject> >();
        for (int x = 0; x < xSize; x++)
        {
            tiles.Add(new List <GameObject>());
            for (int y = 0; y < ySize; y++)
            {
                tiles[x].Add(null);
            }
        }

        // Initialize purcentage
        purcentageForward  = chanceForward;
        purcentageLeft     = purcentageForward + chanceLeft;
        purcentageRight    = purcentageLeft + chanceRight;
        purcentageBackward = purcentageRight + chanceBackward;

        // Create a new pathwalker
        PathWalker pathWalker = Instantiate(pathWalkerPrefab, origin, Quaternion.identity, pathWalkersContainer).GetComponent <PathWalker>();

        pathWalker.Initialize(new Vector2(xSize / 2, ySize / 2), PathWalkerDistance);
    }
Exemplo n.º 27
0
        /// <summary> Compares equality by path. </summary>
        /// <param name="x">The first instance.</param>
        /// <param name="y">The other instance.</param>
        /// <returns>True if the instances are found equal.</returns>
        public static bool Equals(ExpressionSyntax?x, ExpressionSyntax?y)
        {
            if (ReferenceEquals(x, y))
            {
                return(true);
            }

            if (x is null ||
                y is null)
            {
                return(false);
            }

            using var xWalker = PathWalker.Borrow(x);
            using var yWalker = PathWalker.Borrow(y);
            return(Equals(xWalker, yWalker));
        }
Exemplo n.º 28
0
        /// <summary>
        /// Generates the menu for the selected sci control
        /// </summary>
        public void GenerateSnippets(ScintillaNet.ScintillaControl sci)
        {
            String        path;
            String        content;
            PathWalker    walker;
            List <String> files;

            items = new List <String>();
            String surroundFolder = "surround";

            path = Path.Combine(PathHelper.SnippetDir, surroundFolder);
            if (Directory.Exists(path))
            {
                walker = new PathWalker(PathHelper.SnippetDir + surroundFolder, "*.fds", false);
                files  = walker.GetFiles();
                foreach (String file in files)
                {
                    items.Add(file);
                }
            }
            path = Path.Combine(PathHelper.SnippetDir, sci.ConfigurationLanguage);
            path = Path.Combine(path, surroundFolder);
            if (Directory.Exists(path))
            {
                walker = new PathWalker(path, "*.fds", false);
                files  = walker.GetFiles();
                foreach (String file in files)
                {
                    items.Add(file);
                }
            }
            if (items.Count > 0)
            {
                items.Sort();
            }
            this.DropDownItems.Clear();
            foreach (String itm in items)
            {
                content = File.ReadAllText(itm);
                if (content.IndexOf("{0}") > -1)
                {
                    this.DropDownItems.Insert(this.DropDownItems.Count, new ToolStripMenuItem(Path.GetFileNameWithoutExtension(itm), image));
                }
            }
        }
Exemplo n.º 29
0
            public static bool Uses(SyntaxNode scope, PathWalker backing, Search search, ITypeSymbol containingType, SemanticModel semanticModel, CancellationToken cancellationToken)
            {
                using (var walker = Borrow(scope, search, containingType, semanticModel, cancellationToken))
                {
                    foreach (var used in walker.usedMembers)
                    {
                        using (var usedPath = PathWalker.Borrow(used))
                        {
                            if (MemberPath.Equals(usedPath, backing))
                            {
                                return(true);
                            }
                        }
                    }
                }

                return(false);
            }
Exemplo n.º 30
0
        internal static bool Equals(ExpressionSyntax x, ExpressionSyntax y)
        {
            if (ReferenceEquals(x, y))
            {
                return(true);
            }

            if (x is null ||
                y is null)
            {
                return(false);
            }

            using (var xWalker = PathWalker.Borrow(x))
                using (var yWalker = PathWalker.Borrow(y))
                {
                    return(Equals(xWalker, yWalker));
                }
        }
Exemplo n.º 31
0
        internal static bool Equals(PathWalker xWalker, PathWalker yWalker)
        {
            var xPath = xWalker.IdentifierNames;
            var yPath = yWalker.IdentifierNames;

            if (xPath.Count == 0 ||
                xPath.Count != yPath.Count)
            {
                return(false);
            }

            for (var i = 0; i < xPath.Count; i++)
            {
                if (xPath[i].Identifier.ValueText != yPath[i].Identifier.ValueText)
                {
                    return(false);
                }
            }

            return(true);
        }
Exemplo n.º 32
0
        //UPGRADE_NOTE: ref keyword was added to struct-type parameters. 'ms-help://MS.VSCC.2003/commoner/redir/redirect.htm?keyword="jlca1303_3"'
        private void iterate(PathWalker walker, ref System.Drawing.PointF position, System.Drawing.Drawing2D.Matrix errorMatrix, double error, double t1, ref System.Drawing.PointF p1, double t2, ref System.Drawing.PointF p2)
        {
            double tc = (t1 + t2) / 2.0;
            //UPGRADE_NOTE: ref keyword was added to struct-type parameters. 'ms-help://MS.VSCC.2003/commoner/redir/redirect.htm?keyword="jlca1303_3"'
            System.Drawing.PointF pc = calcPoint(tc, ref position);
            double ex, ey, tex, tey;

            ex = (double) pc.X - ((double) p1.X + (double) p2.X) / 2.0;
            ey = (double) pc.Y - ((double) p1.Y + (double) p2.Y) / 2.0;
            tex = (float) errorMatrix.Elements.GetValue(0) * ex + (float) errorMatrix.Elements.GetValue(2) * ey;
            tey = (float) errorMatrix.Elements.GetValue(1) * ex + (float) errorMatrix.Elements.GetValue(3) * ey;
            if (tex * tex + tey * tey >= error * error)
            {
                //UPGRADE_NOTE: ref keyword was added to struct-type parameters. 'ms-help://MS.VSCC.2003/commoner/redir/redirect.htm?keyword="jlca1303_3"'
                iterate(walker, ref position, errorMatrix, error, t1, ref p1, tc, ref pc);
                //UPGRADE_NOTE: ref keyword was added to struct-type parameters. 'ms-help://MS.VSCC.2003/commoner/redir/redirect.htm?keyword="jlca1303_3"'
                iterate(walker, ref position, errorMatrix, error, tc, ref pc, t2, ref p2);
            }
            else
            {
                walker.lineTo(p2.X, p2.Y);
            }
        }
Exemplo n.º 33
0
 //UPGRADE_NOTE: ref keyword was added to struct-type parameters. 'ms-help://MS.VSCC.2003/commoner/redir/redirect.htm?keyword="jlca1303_3"'
 public virtual void walk(PathWalker walker, ref System.Drawing.PointF position, System.Drawing.Drawing2D.Matrix errorMatrix, double error)
 {
     walker.lineTo(x, y);
     position.X = (float)x;
     position.Y = (float)y;
 }
Exemplo n.º 34
0
        public virtual void walk(PathWalker walker, System.Drawing.Drawing2D.Matrix errorMatrix, double error)
        {
            //UPGRADE_TODO: Interface 'java.awt.geom.PathIterator' was converted to 'System.Drawing.Drawing2D.GraphicsPathIterator' which has a different behavior. 'ms-help://MS.VSCC.2003/commoner/redir/redirect.htm?keyword="jlca1073_3"'
            //UPGRADE_TODO: Method 'java.awt.Shape.getPathIterator' was converted to 'System.Drawing.Drawing2D.GraphicsPathIterator.GraphicsPathIterator' which has a different behavior. 'ms-help://MS.VSCC.2003/commoner/redir/redirect.htm?keyword="jlca1073_javaawtShapegetPathIterator_javaawtgeomAffineTransform_double_3"'
            System.Drawing.Drawing2D.GraphicsPathIterator itr = new System.Drawing.Drawing2D.GraphicsPathIterator(shape);
            double[] point = new double[6];
            int i = 0;
            System.Drawing.Drawing2D.Matrix inv;
            double m00, m01, m10, m11, dx, dy;

            try
            {
                System.Drawing.Drawing2D.Matrix temp_Matrix;
                temp_Matrix = new System.Drawing.Drawing2D.Matrix();
                temp_Matrix = errorMatrix.Clone();
                temp_Matrix.Invert();
                inv = temp_Matrix;
            }
            catch (System.Exception e)
            {
                return ;
            }

            m00 = (float) inv.Elements.GetValue(0);
            m01 = (float) inv.Elements.GetValue(2);
            m10 = (float) inv.Elements.GetValue(1);
            m11 = (float) inv.Elements.GetValue(3);
            dx = (System.Single) inv.OffsetX;
            dy = (System.Single) inv.OffsetY;

            //UPGRADE_ISSUE: Method 'java.awt.geom.PathIterator.isDone' was not converted. 'ms-help://MS.VSCC.2003/commoner/redir/redirect.htm?keyword="jlca1000_javaawtgeomPathIteratorisDone_3"'
            while (!itr.isDone())
            {
                //UPGRADE_ISSUE: Method 'java.awt.geom.PathIterator.currentSegment' was not converted. 'ms-help://MS.VSCC.2003/commoner/redir/redirect.htm?keyword="jlca1000_javaawtgeomPathIteratorcurrentSegment_double[]_3"'
                int type = itr.currentSegment(point);

                //UPGRADE_ISSUE: Method 'java.awt.geom.PathIterator.next' was not converted. 'ms-help://MS.VSCC.2003/commoner/redir/redirect.htm?keyword="jlca1000_javaawtgeomPathIteratornext_3"'
                itr.next();
                //UPGRADE_ISSUE: Field 'java.awt.geom.PathIterator.SEG_MOVETO' was not converted. 'ms-help://MS.VSCC.2003/commoner/redir/redirect.htm?keyword="jlca1000_javaawtgeomPathIteratorSEG_MOVETO_f_3"'
                if (type == PathIterator.SEG_MOVETO)
                {
                    if (i > 0)
                    {
                        walk(walker, points, i, false);
                        i = 0;
                    }
                    points[i++] = m00 * point[0] + m01 * point[1] + dx;
                    points[i++] = m10 * point[0] + m11 * point[1] + dy;
                }
                else
                {
                    //UPGRADE_ISSUE: Field 'java.awt.geom.PathIterator.SEG_LINETO' was not converted. 'ms-help://MS.VSCC.2003/commoner/redir/redirect.htm?keyword="jlca1000_javaawtgeomPathIteratorSEG_LINETO_f_3"'
                    if (type == PathIterator.SEG_LINETO)
                    {
                        points[i++] = m00 * point[0] + m01 * point[1] + dx;
                        points[i++] = m10 * point[0] + m11 * point[1] + dy;
                    }
                    else
                    {
                        //UPGRADE_ISSUE: Field 'java.awt.geom.PathIterator.SEG_CLOSE' was not converted. 'ms-help://MS.VSCC.2003/commoner/redir/redirect.htm?keyword="jlca1000_javaawtgeomPathIteratorSEG_CLOSE_f_3"'
                        if (type == PathIterator.SEG_CLOSE)
                        {
                            if (i > 0)
                            {
                                walk(walker, points, i, true);
                                i = 0;
                            }
                        }
                    }
                }
            }
            if (i > 0)
            {
                walk(walker, points, i, false);
                i = 0;
            }
        }
Exemplo n.º 35
0
 private void walk(PathWalker walker, double[] points, int l, bool closed)
 {
     walker.beginSubPath(closed);
     for (int i = 0; i < l; i += 2)
     {
         walker.lineTo(points[i], points[i + 1]);
     }
     walker.endSubPath();
 }
Exemplo n.º 36
0
 /// <summary> 
 /// Walks the given walker through the path.
 /// </summary>
 /// <param name="walker">the walker.
 /// </param>
 /// <param name="error">the error matrix.
 /// </param>
 public virtual void walk(PathWalker walker, System.Drawing.Drawing2D.Matrix errorMatrix, double error)
 {
     for (int i = 0; i < subPaths.Length; i++)
         subPaths[i].walk(walker, errorMatrix, error);
 }
        internal static bool CreateField(ITypeDescriptorContext context, ActivityBind activityBind, bool throwOnError)
        {
            //Check if the activity is root activity and has valid design time type
            if (!String.IsNullOrEmpty(activityBind.Path))
            {
                Type boundType = PropertyDescriptorUtils.GetBaseType(context.PropertyDescriptor, context.Instance, context);
                Activity activity = PropertyDescriptorUtils.GetComponent(context) as Activity;
                if (activity != null && boundType != null)
                {
                    activity = Helpers.ParseActivityForBind(activity, activityBind.Name);
                    if (activity == Helpers.GetRootActivity(activity))
                    {
                        bool isVB = (CompilerHelpers.GetSupportedLanguage(context) == SupportedLanguages.VB);
                        Type designedType = Helpers.GetDataSourceClass(activity, context);
                        if (designedType != null)
                        {
                            //field path could be nested too.
                            //need to find field only with the name up to the first dot (CimplexTypeField in the example below)
                            //and the right type (that would be tricky if the field doesnt exist yet)
                            //example: CimplexTypeField.myIDictionary_int_string[10].someOtherGood2

                            string fieldName = activityBind.Path;
                            int indexOfDot = fieldName.IndexOfAny(new char[] { '.', '/', '[' });
                            if (indexOfDot != -1)
                                fieldName = fieldName.Substring(0, indexOfDot); //path is a nested field access

                            MemberInfo matchingMember = ActivityBindPropertyDescriptor.FindMatchingMember(fieldName, designedType, isVB);
                            if (matchingMember != null)
                            {
                                Type memberType = null;
                                bool isPrivate = false;
                                if (matchingMember is FieldInfo)
                                {
                                    isPrivate = ((FieldInfo)matchingMember).IsPrivate;
                                    memberType = ((FieldInfo)matchingMember).FieldType;
                                }
                                else if (matchingMember is PropertyInfo)
                                {
                                    MethodInfo getMethod = ((PropertyInfo)matchingMember).GetGetMethod();
                                    MethodInfo setMethod = ((PropertyInfo)matchingMember).GetSetMethod();
                                    isPrivate = ((getMethod != null && getMethod.IsPrivate) || (setMethod != null && setMethod.IsPrivate));
                                }
                                else if (matchingMember is MethodInfo)
                                {
                                    isPrivate = ((MethodInfo)matchingMember).IsPrivate;
                                }

                                if (indexOfDot != -1)
                                { //need to find the type of the member the path references (and if the path is valid at all)
                                    PathWalker pathWalker = new PathWalker();
                                    PathMemberInfoEventArgs finalEventArgs = null;
                                    pathWalker.MemberFound += delegate(object sender, PathMemberInfoEventArgs eventArgs)
                                    { finalEventArgs = eventArgs; };

                                    if (pathWalker.TryWalkPropertyPath(designedType, activityBind.Path))
                                    {
                                        //successfully walked the entire path
                                        memberType = BindHelpers.GetMemberType(finalEventArgs.MemberInfo);
                                    }
                                    else
                                    {
                                        //the path is invalid
                                        if (throwOnError)
                                            throw new InvalidOperationException(SR.GetString(SR.Error_MemberWithSameNameExists, activityBind.Path, designedType.FullName));

                                        return false;
                                    }
                                }

                                if ((matchingMember.DeclaringType == designedType || !isPrivate) &&
                                    matchingMember is FieldInfo &&
                                    TypeProvider.IsAssignable(boundType, memberType))
                                {
                                    return true;
                                }
                                else
                                {
                                    if (throwOnError)
                                        throw new InvalidOperationException(SR.GetString(SR.Error_MemberWithSameNameExists, activityBind.Path, designedType.FullName));
                                    return false;
                                }
                            }
                            else
                            {
                                // Find out if the name conflicts with an existing activity that has not be flushed in to the 
                                // code beside.  An activity bind can bind to this field only if the type of the property
                                // is the assignable from the activity type.
                                Activity matchingActivity = null;
                                if (string.Compare(activity.Name, fieldName, isVB ? StringComparison.OrdinalIgnoreCase : StringComparison.Ordinal) == 0)
                                    matchingActivity = activity;
                                else if (activity is CompositeActivity)
                                {
                                    if (activity is CompositeActivity)
                                    {
                                        foreach (Activity existingActivity in Helpers.GetAllNestedActivities(activity as CompositeActivity))
                                        {
                                            if (string.Compare(existingActivity.Name, fieldName, isVB ? StringComparison.OrdinalIgnoreCase : StringComparison.Ordinal) == 0)
                                                matchingActivity = existingActivity;
                                        }
                                    }
                                }

                                if (matchingActivity != null)
                                {
                                    if (TypeProvider.IsAssignable(boundType, matchingActivity.GetType()))
                                        return true;
                                    else
                                    {
                                        if (throwOnError)
                                            throw new InvalidOperationException(SR.GetString(SR.Error_MemberWithSameNameExists, activityBind.Path, designedType.FullName));
                                        return false;
                                    }
                                }
                            }

                            IMemberCreationService memberCreationService = context.GetService(typeof(IMemberCreationService)) as IMemberCreationService;
                            if (memberCreationService == null)
                            {
                                if (throwOnError)
                                    throw new InvalidOperationException(SR.GetString(SR.General_MissingService, typeof(IMemberCreationService).FullName));
                            }
                            else
                            {
                                IDesignerHost designerHost = context.GetService(typeof(IDesignerHost)) as IDesignerHost;
                                if (designerHost == null)
                                {
                                    if (throwOnError)
                                        throw new InvalidOperationException(SR.GetString("General_MissingService", typeof(IDesignerHost).FullName));
                                }
                                else
                                {
                                    memberCreationService.CreateField(designerHost.RootComponentClassName, activityBind.Path, boundType, null, MemberAttributes.Public, null, false);
                                    return true;
                                }
                            }
                        }
                    }
                }
                else
                {
                    if (activity == null && throwOnError)
                        throw new InvalidOperationException(SR.GetString(SR.Error_InvalidActivityIdentifier, activityBind.Name));

                    if (boundType == null && throwOnError)
                        throw new InvalidOperationException(SR.GetString(SR.Error_PropertyTypeNotDefined, context.PropertyDescriptor.Name, typeof(ActivityBind).Name, typeof(IDynamicPropertyTypeProvider).Name));
                }
            }

            return false;
        }
Exemplo n.º 38
0
        /// <summary> Walks the given walker through this subpath.
        /// 
        /// </summary>
        /// <param name="walker">the walker.
        /// </param>
        /// <param name="error">the error matrix.
        /// </param>
        public virtual void walk(PathWalker walker, System.Drawing.Drawing2D.Matrix errorMatrix, double error)
        {
            System.Drawing.PointF position = new System.Drawing.PointF((float)startX, (float)startY);

            walker.beginSubPath(closed);
            walker.lineTo(startX, startY);
            for (int i = 0; i < segments.Length; i++)
            {
                //UPGRADE_NOTE: ref keyword was added to struct-type parameters. 'ms-help://MS.VSCC.2003/commoner/redir/redirect.htm?keyword="jlca1303_3"'
                segments[i].walk(walker, ref position, errorMatrix, error);
            }
            walker.endSubPath();
        }