Beispiel #1
0
        void giver()
        {
            ResourceManager manager = new ResourceManager();
            manager.LoadLibrary(@"E:\Media");

            EventSchedule sched = new EventSchedule(32);
            sched.TicksPerSec = 1;

            //BasicEvent.Provider prov = new BasicEvent.Provider();
            SoundEvent.Provider prov1 = new SoundEvent.Provider("Chord", manager, "chord.wav");
            SoundEvent.Provider prov2 = new SoundEvent.Provider("Ding", manager, "ding.wav");
            /*RandomEventSelector rnd = new RandomEventSelector();
            rnd.Selection.Add(prov1);
            rnd.Selection.Add(prov2);
            SimultaneousEventProvider sim = new SimultaneousEventProvider();
            sim.Group.Add(prov1);
            sim.Group.Add(prov2);
            PeriodicEventProvider per = new PeriodicEventProvider();
            per.Period = 8;
            per.Variance = 0;
            per.Subordinate = sim;
             */

            _hub.SetChannel(this);
            _hub.Initialize(_this);

            var obs = new EventProviderActivator(AppID);
            obs.Provider = prov1;
            obs.Schedule = sched;
            var id = new TriggerID("Test", 1);
            bool result = _hub.Hub.ConnectObserver(id, obs);

            //sched.Model.Add(per);
            sched.Tick += new EventSchedule.TimeEvent(Ticker);
            sched.Start(false);

            //AutoResetEvent auto = new AutoResetEvent(false);
            //while (sched.IsRunning)
            //    auto.WaitOne(1000);

            Console.Write("Press any key...");
            Console.ReadLine();

            sched.Stop();
            _hub.Finish(_this);

            Console.WriteLine("Finished.");
            Console.ReadLine();

            return;
        }
Beispiel #2
0
 static void Ticker(EventSchedule sched, ulong newTimeCode)
 {
     Console.WriteLine("Time {0}:", newTimeCode);
     //if (newTimeCode >= _maxTime)
     //    sched.Stop();
 }
Beispiel #3
0
        void Form1_FormClosed(object sender, FormClosedEventArgs e)
        {
            _sched.Dispose();
            _sched = null;

            _manager.Stop();
        }
Beispiel #4
0
        public Form1()
        {
            InitializeComponent();

            _manager = new ResourceManager();
            ILibrary lib = _manager.LoadLibrary(@"E:\Media");
            _manager.Start();
            libraryView1.Resources = _manager;

            _sched = new EventSchedule(32);
            _sched.TicksPerSec = 2;

            BasicEvent.Provider prov1 = new BasicEvent.Provider("Chord");
            BasicEvent.Provider prov2 = new BasicEvent.Provider("Ding");
            snd3 = new SoundEvent.Provider("Sound1", _manager, "Media::sttng.wav");
            //SoundEvent.Provider prov1 = new SoundEvent.Provider("Chord", _manager, "chord.wav");
            //SoundEvent.Provider prov2 = new SoundEvent.Provider("Ding", _manager, "krkfunny.WAV");
            PeriodicEventProvider per1 = new PeriodicEventProvider("Period");
            //SimultaneousEventProvider sim2 = new SimultaneousEventProvider("Simul");
            _randEventSel.Selection.Add(prov1);
            _randEventSel.Selection.Add(prov2);

            //sim2.Group.Add(prov1);
            //sim2.Group.Add(prov2);

            per1.Subordinate = prov1;
            per1.Period = 4;

            per2.Subordinate = prov2;
            per2.Period = 5;

            del1.Subordinate = prov2;
            del1.Delay = 5;

            _colors[per1] = Color.Red;
            _colors[prov2] = Color.Orange;
            _colors[prov1] = Color.Green;

            _sched.Initialize();
            _sched.AddProvider(prov2);
            _sched.AddProvider(per1);
            //_sched.AddProvider(del1);
            _sched.AddProvider(per2);
            //_sched.AddProvider(prov2);

            scheduleView1.ColorProvider = this;
            scheduleView1.Schedule = _sched;
            scheduleView1.TokenMouseEnter += new ScheduleView.TokenMouseEvent(scheduleView1_TokenMouseEnter);
            scheduleView1.TokenMouseLeave += new ScheduleView.TokenMouseEvent(scheduleView1_TokenMouseLeave);
            scheduleView1.LeftColumnChanged += new ScheduleView.ViewValueChangeEvent(scheduleView1_LeftColumnChanged);
            scheduleView1.TopRowChanged += new ScheduleView.ViewValueChangeEvent(scheduleView1_TopRowChanged);

            eventTokenTile1.Token = new ProviderToken(prov1, this);

            providerTokenList1.AllowItemDrag = false;
            providerTokenList1.Items.Add(prov1);
            providerTokenList1.Items.Add(prov2);

            eventTokenTile2.MouseMove += new MouseEventHandler(eventTokenTile2_MouseMove);
            eventTokenTile2.MouseLeave += new EventHandler(eventTokenTile2_MouseLeave);
            eventTokenTile2.MouseUp += new MouseEventHandler(eventTokenTile2_MouseLeave);

            providerTokenButton1.TileClicked += new ProviderTokenButton.TileClickedEvent(providerTokenButton1_TileClicked);

            libraryView1.SelectionChanged += new LibraryView.ResourceEventHandler(libraryView1_SelectionChanged);

            this.Load += new EventHandler(Form1_Load);
            this.FormClosed += new FormClosedEventHandler(Form1_FormClosed);
        }
Beispiel #5
0
 private void _sched_Started(EventSchedule sched)
 {
     _curIndex = 0;
     invalidateView();
 }
Beispiel #6
0
        private void _sched_Tick(EventSchedule sched, ulong newTimeCode)
        {
            EventToken[] curTokens = GetInstantTokens((int)newTimeCode);
            for (int col = _curIndex; col < (int)newTimeCode; col++)
            {
                EventToken[] tokens = GetInstantTokens(col);
                for (int row = 0; row < tokens.Length; row++)
                {
                    EventToken token = tokens[row];
                    if (token != null && token.Event != null && (curTokens.Length <= row || curTokens[row] != token))
                        token.Finish();
                }
            }

            bool wasVisible = indexIsVisible(_curIndex);
            _curIndex = (int)newTimeCode;
            if (wasVisible && !indexIsVisible(_curIndex))
            {
                LeftColumn = Math.Min(_curIndex, ColumnCount - FullDisplayedColumnCount + 1);
            }
            else
            {
                invalidateView();
            }
        }
Beispiel #7
0
 private void _sched_ScheduleExtended(EventSchedule sched, ulong timeCode)
 {
     updateHistory(timeCode);
 }
Beispiel #8
0
 private void _sched_ScheduleChanged(EventSchedule sched, ulong timeCode)
 {
     updateHistory(timeCode);
     invalidateView();
 }
Beispiel #9
0
 private void _sched_Finished(EventSchedule sched)
 {
     _curIndex = -1;
     invalidateView();
 }
Beispiel #10
0
 public Scheduler(EventSchedule parent)
 {
     _parent = parent;
 }
Beispiel #11
0
        public void UpdateFuture(EventSchedule sched, ulong fromTime)
        {
            var future = sched.GetActualFuture(fromTime);

            acrossTime(fromTime, ColumnCount, (ref EventToken[,] block) =>
            {
                return (block != null);
            }, (ref EventToken[,] block, ulong t, int j) =>
            {
                for (int r = 0; r < block.GetLength(0); r++)
                {
                    if (block[r, j] != null && (!block[r, j].Event.Started || !block[r, j].Event.Active))
                    {
                        block[r, j] = null;
                    }
                }
            });

            acrossTime(fromTime, (ulong)future.Length, (ref EventToken[,] block) =>
            {
                if (block == null)
                    block = new EventToken[_rowCount, BlockWidth];
                return true;
            }, (ref EventToken[,] block, ulong t, int j) =>
            {
                foreach (var evt in future[(int)t])
                {
                    int r = findEmptyRow(ref block, j);
                    insertEvent(r, fromTime + t, evt);
                }
            });
        }