Exemple #1
0
        private void ultraDropDownButton1_Click(object sender, EventArgs e)
        {
            if (scrobblerInit)
            {
                if (trackList.Items.Count > 0)
                {
                    object[] files = trackList.Items.All;

                    if (files.Length > 50)
                    {
                        MessageBox.Show("Scrobbling more than 50 tracks - last.fm response may be lagged.", "Tracks, a lot!", MessageBoxButtons.OK, MessageBoxIcon.Information);
                    }

                    //UltraListViewItem item = (UltraListViewItem)files[0];

                    C5.ArrayList <TrackInfo> tracks = new C5.ArrayList <TrackInfo>();

                    try
                    {
                        foreach (object file in files)
                        {
                            UltraListViewItem item = (UltraListViewItem)file;

                            TrackInfo info = new TrackInfo(item.SubItems[1].Value.ToString(), item.SubItems[2].Value.ToString(), item.SubItems[0].Value.ToString());                                //artist (!empty), album (may be empty), title (!empty)
                            info.Username     = userLogin;
                            info.Duration     = (int)TimeSpan.Parse(item.SubItems[3].Value.ToString()).TotalSeconds;
                            info.SourceString = "P";
                            info.timeStampMe();

                            for (int i = 0; i < (int)item.SubItems[4].Value; i++)
                            {
                                tracks.Add(info);
                            }
                        }
                        tracks.Shuffle();

                        ScrobblerCache cache = new ScrobblerCache(userLogin);
                        cache.Append(new List <TrackInfo>(tracks.ToArray()), true);

                        sm.Scrobble(ref cache);
                        MessageBox.Show("Scrobbled successfully!", "Oll Korrect", MessageBoxButtons.OK, MessageBoxIcon.Information);
                    }
                    catch (Exception exp)
                    {
                    }
                }
                else
                {
                    MessageBox.Show("Alas, nothing to scrobble!", "Oops, no tracks at all", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                }
            }
            else
            {
                MessageBox.Show("Hold yer horses! Enter user info first - click 'options' and so on", "Methinks we're forgetting something...", MessageBoxButtons.OK, MessageBoxIcon.Hand);
            }
        }
Exemple #2
0
 public void AddInteraction(Interaction interaction)
 {
     AvailableInteractions.Add(interaction);
 }
Exemple #3
0
        private void ultraDropDownButton1_Click(object sender, EventArgs e)
        {
            if (scrobblerInit)
            {
                if (trackList.Items.Count > 0)
                {
                    object[] files = trackList.Items.All;

                    if (files.Length > 50)
                    {
                        MessageBox.Show("Scrobbling more than 50 tracks - last.fm response may be lagged.", "Tracks, a lot!", MessageBoxButtons.OK, MessageBoxIcon.Information);
                    }

                    //UltraListViewItem item = (UltraListViewItem)files[0];

                    C5.ArrayList<TrackInfo> tracks = new C5.ArrayList<TrackInfo>();

                    try
                    {
                        foreach (object file in files)
                        {
                            UltraListViewItem item = (UltraListViewItem)file;

                            TrackInfo info = new TrackInfo(item.SubItems[1].Value.ToString(), item.SubItems[2].Value.ToString(), item.SubItems[0].Value.ToString());    //artist (!empty), album (may be empty), title (!empty)
                            info.Username = userLogin;
                            info.Duration = (int)TimeSpan.Parse(item.SubItems[3].Value.ToString()).TotalSeconds;
                            info.SourceString = "P";
                            info.timeStampMe();

                            for (int i = 0; i < (int)item.SubItems[4].Value; i++ )
                                tracks.Add(info);
                        }
                        tracks.Shuffle();

                        ScrobblerCache cache = new ScrobblerCache(userLogin);
                        cache.Append(new List<TrackInfo>(tracks.ToArray()), true);

                        sm.Scrobble(ref cache);
                        MessageBox.Show("Scrobbled successfully!", "Oll Korrect", MessageBoxButtons.OK, MessageBoxIcon.Information);
                    }
                    catch(Exception exp)
                    {
                    }
                }
                else
                {
                    MessageBox.Show("Alas, nothing to scrobble!", "Oops, no tracks at all", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                }
            }
            else
            {
                MessageBox.Show("Hold yer horses! Enter user info first - click 'options' and so on", "Methinks we're forgetting something...", MessageBoxButtons.OK, MessageBoxIcon.Hand);
            }
        }
    /// <summary>
    /// Optimizes navmesh by deleting some triangles
    /// </summary>
    /// <param name="itm"></param>
    public IEnumerator OptimizeMesh()
    {
        C5.HashSet <Vector3>  open  = new C5.HashSet <Vector3>();
        C5.HashSet <Triangle> openT = new C5.HashSet <Triangle>();
        open.AddAll(vertex2Triangle.Keys);

        while (!open.IsEmpty)    //loop through all vertices

        {
            Vector3 current = open.Pop();

            if (vertex2Triangle[current].Count < 3) //if less than 3, they cannot form a "circle"
            {
                continue;
            }

            openT.Clear();
            openT.AddAll(vertex2Triangle[current]);

            //Debug.Log("Opening " + current);

            //start at arbitrary triangle
            C5.IList <Triangle> circle = new C5.ArrayList <Triangle>();
            circle.Add(openT.Pop());

            //find connected circle
            while (openT.Count > 0)
            {
                Triangle[] circleElement = openT.Intersect(triangleIncidence[circle.Last]).ToArray();
                if (circleElement.Length < 1) //no candidate - break
                {
                    break;
                }
                circle.Add(circleElement[0]);

                openT.Remove(circle.Last);
            }
            if (openT.Count == 0 && triangleIncidence[circle.Last].Contains(circle.First))
            {
                //Debug.Log( "Unbroken: "+current );
                //check height differences
                bool isFlatEnough = true;
                foreach (Triangle trg in vertex2Triangle[current])
                {
                    foreach (Vector3 vct in trg.vertices)
                    {
                        if (Mathf.Abs(vct.y - current.y) > maxHeightDifference)
                        {
                            isFlatEnough = false;
                        }
                    }
                }
                if (!isFlatEnough)
                {
                    continue;
                }

                ArrayList <Vector3> vctList = new ArrayList <Vector3>();

                //remove old triangles
                foreach (Triangle trg in circle)   //ToArray() is to create a buffer (to prevent concurrent modification)
                {
                    RemoveTriangle(trg);
                    for (int i = 0; i < 3; i++)
                    {
                        //find the CURRENT vertex - the one that is beeing removed
                        if (trg.vertices[i] == current)
                        {
                            //add the NEXT to the list
                            vctList.Add(trg.vertices[(i + 1) % 3]);
                        }
                    }
                }

                if (Outline.IsClockwise(vctList))
                {
                    vctList.Reverse();
                }
                //build new triangles and add them
                foreach (IEnumerable <int> newTriangles in Utils.TriangulatePolygon(vctList, Enumerable.Range(0, vctList.Count)).Chunks(3))
                {
                    Triangle newTriag = new Triangle(newTriangles.Select(x => vctList[x]).ToArray());
                    AddTriangleByReference(newTriag);
                }

                //reopen used vertices
                //open.AddAll(vctList); - maybe not necessary????
                //yield return new WaitForSeconds(1);
                yield return(null);
            }
        }
    }