示例#1
0
        public PeerState(Peer pIn)
        {
            // TODO: convert the Peer into a PeerState
            try
            {
                if (pIn == null) return;
                if (pIn.owner != null) ownerName = pIn.owner.Name;
                onOff = pIn.OnOff;

                effectorName = pIn.InputEffector.GetType().ToString();
                foreach (double d in pIn.InputEffector.Parameters)
                {
                    parameters.Add(d);
                }

                relationNames = new List<string>();
                foreach (Relation r in pIn.Relations)
                {
                    relationNames.Add(r.GetType().ToString());
                    foreach (double d in r.Parameters)
                    {
                        parameters.Add(d);
                    }
                }

                targetName = pIn.Target.GetType().ToString();
                targetState = pIn.Target.State;
            }
            catch (Exception e)
            {
                BuzzGUI.Common.DebugConsole.WriteLine("failed to save:" + e.Message);
            }
        }
 public SelectionWindow(Peer pin)
 {
     peer = pin;
     InitializeComponent();
     // choose machine param and track
     foreach (IMachine m in BuzzGUI.Common.Global.Buzz.Song.Machines)
     {
         //  get machine and name
         TreeViewItem mach = new TreeViewItem() { Header = m.Name, Tag = m };
         IEnumerable<IParameter> ps = m.AllParameters();
         for (int i = 0; i < ps.Count(); i++)
         {
             // get param and name
             IParameter p = ps.ElementAt(i);
             TreeViewItem param = new TreeViewItem() { Header = p.Name, Tag = p };
             for (int j = 0; j < p.Group.TrackCount; j++)
             {
                 TreeViewItem track = new TreeViewItem() { Header = j.ToString() };
                 track.Tag = "track " + j.ToString();
                 // add tracks
                 param.Items.Add(track);
             }
             // add params
             mach.Items.Add(param);
         }
         //add machine
         treeView1.Items.Add(mach);
     }
 }
        public selectRelation(Peer pIn, List<Relation> rIn)
        {
            InitializeComponent();

            peer = pIn;
            relations = rIn;

            foreach (Relation r in relations)
            {
                comboBox1.Items.Add(r.GetType().Name);
            }
        }
        public selectEffector(Peer pIn, List<Effector> eIn)
        {
            InitializeComponent();

            peer = pIn;
            effectors = eIn;

            foreach (Effector e in effectors)
            {
                comboBox1.Items.Add(e.GetType().Name);
            }
        }
示例#5
0
        public selectTarget(Peer pIn, List<PPTarget> tIn)
        {
            InitializeComponent();

            peer = pIn;
            targets = tIn;

            foreach (PPTarget t in targets)
            {
                comboBox1.Items.Add(t.GetType().Name);
            }
        }
示例#6
0
 public PeerVM(Peer pin, PPTrackVM tin)
 {
     p = pin;
     t = tin;
     Effector = cleanName(pin.InputEffector.ToString());
     Target = cleanName(pin.Target.ToString());
     Relations = new List<string>();
     foreach (Relation r in pin.Relations)
     {
         Relations.Add(cleanName(r.ToString()));
     }
     if (PropertyChanged != null) PropertyChanged(this, new PropertyChangedEventArgs("PeerVM"));
 }
示例#7
0
        public Peer newPeer(IMachine m)
        {
            // make a straight relation
            Relations.StraightRelation sr = new MT_Peer_Pressure.Relations.StraightRelation();
            // make the relations list
            List<Relation> lr = new List<Relation>();
            lr.Add(sr);

            // make null effector and target
            Effectors.NullEffector ne = new MT_Peer_Pressure.Effectors.NullEffector();
            Targets.NullTarget nt = new MT_Peer_Pressure.Targets.NullTarget();

            // make the peer
            Peer p = new Peer(m, ne, lr, nt);

            // add peer
            Peers.Add(p);

            // if we are getting a request from self
            if (m == host.Machine)
            {
                // add track
                PPTrackVM t = new PPTrackVM();
                t.peerIndex = Peers.Count();
                tracks.Add(t);
            }

            return p;
        }
示例#8
0
 void peerRemoved(object sender, Peer peer, EventArgs e)
 {
     GUIPeers.Remove(GUIPeers.First(pr => pr.p == peer));
     if (PropertyChanged != null) PropertyChanged(this, new PropertyChangedEventArgs("GUIPeers"));
 }
示例#9
0
        void peerAdded(object sender, Peer peer, PPTrackVM track, EventArgs e)
        {
            PeerVM pvm = new PeerVM(peer, track);
            if (pvm == null)
            {
                throw new Exception("bad pvm");
            }
            GUIPeers.Add(pvm);

            if (PropertyChanged != null) PropertyChanged(this, new PropertyChangedEventArgs("GUIPeers"));
        }
示例#10
0
        public Peer toPeer()
        {
            // search for the owner machine
            IMachine ma = (IMachine)Global.Buzz.Song.Machines.Select(m => m.Name == ownerName);
                // if it doesnt exist return null
            if (ma == null) return null;

            // search for the module types
            // create new modules
            // if any dont exist return null
            Effector ef = (Effector)PeerPressure.effectors.Select(e => e.GetType().ToString() == effectorName);
            if (ef == null) return null;

            List<Relation> rels = new List<Relation>();
            foreach (string s in relationNames)
            {
                rels.Add((Relation)PeerPressure.relations.Select(r => r.GetType().ToString() == s));
                if (rels.Last() == null) return null;
            }

            PPTarget ppt = (PPTarget)((PPTarget)PeerPressure.targets.Select(t => t.GetType().ToString() == targetName)).Clone();
            if (ppt == null) return null;

            // fill the parameters
            int i;
            for (i = 0; i < ef.Parameters.Count(); i++)
            {
                ef.Parameters[i] = parameters[i];
            }
            for (int j = 0; j < rels.Count(); j++)
            {
                for (int k = 0; k < rels[j].Parameters.Count(); k++)
                {
                    rels[j].Parameters[k] = parameters[i++];
                }
            }

            // create empty peer with correct owner
            // add the modules
            Peer ret = new Peer(ma, ef, rels, ppt);
            return ret;
        }