Esempio n. 1
0
 private void checkBox1_CheckedChanged(object sender, EventArgs e)
 {
     if (listBox1.SelectedIndex == -1)
     {
         return;
     }
     networks[listBox1.SelectedIndex].Visible = checkBox1.Checked;
     OnNetworkChanged?.Invoke(this, networks[listBox1.SelectedIndex]);
 }
Esempio n. 2
0
 private void pictureBox2_Click(object sender, EventArgs e)
 {
     if (listBox1.SelectedIndex == -1)
     {
         return;
     }
     if (cd.ShowDialog() == DialogResult.OK)
     {
         pictureBox2.BackColor = cd.Color;
         networks[listBox1.SelectedIndex].ColorCoherency = cd.Color;
         OnNetworkChanged?.Invoke(this, networks[listBox1.SelectedIndex]);
     }
 }
Esempio n. 3
0
        private void trackBarCH_Scroll(object sender, EventArgs e)
        {
            if (listBox1.SelectedIndex == -1)
            {
                return;
            }
            SFNWOscGraph sfnwog = ((SFNWOscGraph)listBox1.SelectedItem);

            sfnwog.MacroCoherencyK = new PointF(
                GetTrackValue(trackBar4, 0.05, 20),
                GetTrackValue(trackBar3, 0.05, 20)
                );
            sfnwog.MacroCoherencyKTB = new PointF(trackBar1.Value, trackBar2.Value);
            label7.Text = sfnwog.MacroCoherencyK.X.ToString();
            label8.Text = sfnwog.MacroCoherencyK.Y.ToString();
            OnNetworkChanged?.Invoke(this, sfnwog);
        }
Esempio n. 4
0
    /// <summary>
    /// Processes the designer components into the network data structure.
    /// </summary>
    public void PreCalculate()
    {
        // Retrieve nodes from the scene.
        FloorNode[]     fNodes = transform.GetComponentsInChildren <FloorNode>();
        ClimbableNode[] cNodes = transform.GetComponentsInChildren <ClimbableNode>();

        // Convert the nodes into a smaller data structure.
        List <Path> floorPaths = new List <Path>();

        foreach (FloorNode fNode in fNodes)
        {
            floorPaths.Add(new Path(fNode.transform.position,
                                    (Vector2)fNode.transform.position + Vector2.right * fNode.Length));
        }
        List <Path> climbablePaths = new List <Path>();

        foreach (ClimbableNode cNode in cNodes)
        {
            climbablePaths.Add(new Path(cNode.transform.position,
                                        (Vector2)cNode.transform.position + Vector2.up * cNode.Length));
        }
        // Create a list to keep track of all of the junctions.
        List <Junction> junctionsAccumulator = new List <Junction>();

        // For each floor node-path from the scene:
        foreach (Path fPath in floorPaths)
        {
            // Check for connections with climbable node-paths:
            foreach (Path cPath in climbablePaths)
            {
                // Is there an x intersection?
                if (cPath.start.x >= fPath.start.x && cPath.start.x <= fPath.end.x)
                {
                    // Is there a y intersection?
                    if (fPath.start.y >= cPath.start.y && fPath.start.y <= cPath.end.y)
                    {
                        // Add the junction to both paths.
                        Junction junction = new Junction(fPath, cPath, cPath.start.x - fPath.start.x,
                                                         fPath.start.y - cPath.start.y);
                        fPath.junctions.Add(junction);
                        cPath.junctions.Add(junction);
                        junctionsAccumulator.Add(junction);
                    }
                }
            }
        }

        graphIndices = new Dictionary <Junction, int>();
        nodeGraph    = new NodeGraph();
        int insertionIndex = 0;

        foreach (Path path in floorPaths)
        {
            path.junctions.Sort();
            for (int i = 0; i < path.junctions.Count; i++)
            {
                nodeGraph.AddNode(new GraphNode(path.junctions[i].intersection));
                graphIndices.Add(path.junctions[i], insertionIndex);
                insertionIndex++;
            }
            for (int i = 0; i < path.junctions.Count - 1; i++)
            {
                GraphNode before = nodeGraph.Nodes[graphIndices[path.junctions[i]]];
                GraphNode after  = nodeGraph.Nodes[graphIndices[path.junctions[i + 1]]];
                before.AddLink(after);
                after.AddLink(before);
            }
        }
        foreach (Path path in climbablePaths)
        {
            path.junctions.Sort();
            for (int i = 0; i < path.junctions.Count - 1; i++)
            {
                GraphNode before = nodeGraph.Nodes[graphIndices[path.junctions[i]]];
                GraphNode after  = nodeGraph.Nodes[graphIndices[path.junctions[i + 1]]];
                before.AddLink(after);
                after.AddLink(before);
            }
        }

        // Combine and post paths and junctions.
        floorPaths.AddRange(climbablePaths);
        Paths     = floorPaths.ToArray();
        Junctions = junctionsAccumulator.ToArray();


        // Notify anyone that is listening for path changes.
        OnNetworkChanged?.Invoke();
    }
 /// <summary>
 /// Changes the network type to another network.
 /// </summary>
 /// <param name="networkType"> The new ethereum network type. </param>
 public void ChangeNetwork(NetworkType networkType)
 {
     this.networkType = networkType;
     OnNetworkChanged?.Invoke(networkType);
 }