示例#1
0
        public Dictionary <object, object> loadFrame(CreationFrame frame, int index)
        {
            Dictionary <object, object> result = new Dictionary <object, object>();
            Random random = new Random();
            bool   added  = false;

            Neuron neuron = frame.Neuron.Neuron;

            if (neurons.Find(k => k.Neuron == neuron) == null)
            {
                PointF         position = randomPoint(random);
                AnimatedNeuron an       = new AnimatedNeuron(neuron, position);
                CreatedNeuron  cn       = new CreatedNeuron(an);

                neurons.Add(an);
                result.Add(neuron, cn);
                added = true;
            }
            else
            {
                result.Add(neuron, true);
            }

            foreach (CreationData data in frame.Data)
            {
                if (data.Synapse.Changes.First <CreationData>() == data)
                {
                    AnimatedNeuron pre  = neurons.Find(k => data.Synapse.Pre == k.Neuron);
                    AnimatedNeuron post = neurons.Find(k => data.Synapse.Post == k.Neuron);

                    AnimatedSynapse synapse = synapses.Find(k => pre == k.Pre && post == k.Post);

                    if (synapse == null)
                    {
                        AnimatedSynapse syn = new AnimatedSynapse(pre, post, data.Synapse);
                        CreatedSynapse  cs  = new CreatedSynapse(syn);

                        synapses.Add(syn);
                        result.Add(syn.Synapse, cs);

                        if (syn.isDuplex())
                        {
                            result.Add(syn.Duplex, cs);
                        }
                    }
                    else
                    {
                        synapse.setDuplex(data.Synapse);
                    }
                }
            }

            if (added)
            {
                balance();
            }

            return(result);
        }
示例#2
0
        protected override void mouseMove(object sender, MouseEventArgs e)
        {
            if (shift != null)
            {
                base.mouseMove(sender, e);
                return;
            }

            if (active != null)
            {
                if (active.active(e.Location))
                {
                    return;
                }

                if (mapHistory.ContainsKey(active))
                {
                    mapHistory[active].hide();
                }

                active = null;
                time   = 0;
                return;
            }

            foreach (CreatedSynapse synapse in synapses)
            {
                AnimatedSynapse s = synapse.Synapse;

                if (s.active(e.Location, false))
                {
                    active = s.getState(false);
                    return;
                }

                if (s.isDuplex() && s.active(e.Location, true))
                {
                    active = s.getState(true);
                    return;
                }
            }
        }