Пример #1
0
        public void modeBox_SelectedIndexChanged(object sender, EventArgs e)
        {
            if (this.InvokeRequired)
            {
                this.Invoke(new EventHandler(modeBox_SelectedIndexChanged), new object[] { sender, e });
            }
            else
            {
                if (!modeBoxBeingChanged)
                {
                    Storage.sequenceData.CurrentMode = modeBox.SelectedItem as SequenceMode;
                    if (Storage.sequenceData.CurrentMode != null)
                    {
                        string message = SequenceMode.applySequenceMode(Storage.sequenceData, Storage.sequenceData.CurrentMode);

                        updateTimestepEditorsAfterSequenceModeOrTimestepGroupChange();

                        //layoutTimestepEditors();
                        layoutTheRest();
                        if (message != null)
                        {
                            MessageBox.Show("Note when applying sequence mode. " + message + " To add these missing entries, click the Store button.");
                        }
                    }
                }
            }
        }
Пример #2
0
 /// <summary>
 /// Creates a new ImageQueue instance with the specified options
 /// </summary>
 /// <param name="folder">The base folder to draw images from</param>
 /// <param name="includeSubfolders">Flag indicating whether to include subfolders</param>
 /// <param name="sequenceMode">The sequence mode by which to traverse the list of files</param>
 /// <param name="limit">The limit of the number of files added to the queue</param>
 public ImageQueue(string folder, bool includeSubfolders, SequenceMode sequenceMode, int limit)
 {
     Folder            = folder;
     IncludeSubfolders = includeSubfolders;
     SequenceMode      = sequenceMode;
     Limit             = limit;
     LoadImageFiles();
     EnqueueTimer = new Timer(QueueNextCallback, null, 0, 100);
 }
        private void createMode_Click(object sender, EventArgs e)
        {
            SequenceMode newMode = SequenceMode.createSequenceMode(Storage.sequenceData);

            Storage.sequenceData.SequenceModes.Add(newMode);
            Storage.sequenceData.CurrentMode = newMode;
            newMode.ModeName = "New Mode";
            layoutTheRest();
        }
Пример #4
0
 public void storeMode_Click(object sender, EventArgs e)
 {
     if (Storage.sequenceData.CurrentMode != null)
     {
         SequenceMode newMode = SequenceMode.createSequenceMode(Storage.sequenceData.CurrentMode.ID, Storage.sequenceData);
         Storage.sequenceData.CurrentMode.ModeName        = modeTextBox.Text;
         Storage.sequenceData.CurrentMode.TimestepEntries = newMode.TimestepEntries;
         layoutTheRest();
     }
 }
Пример #5
0
        private void createMode_Click(object sender, EventArgs e)
        {
            int          id      = Storage.sequenceData.GenerateNewModeID();
            SequenceMode newMode = SequenceMode.createSequenceMode(id, Storage.sequenceData);

            Storage.sequenceData.SequenceModes.Add(newMode);
            //Add this mode to the dictionary of pulses
            Storage.sequenceData.NewPulses.Add(newMode, new HashSet <Pulse>());
            Storage.sequenceData.ModeReferences.Add(newMode, new HashSet <SequenceMode>());
            Storage.sequenceData.CurrentMode = newMode;
            newMode.ModeName = "Mode" + id;
            layoutTheRest();
        }
Пример #6
0
        public static ICompactor GetCompactor(SequenceMode sequenceMode)
        {
            switch (sequenceMode)
            {
            case SequenceMode.ByteModeOne:
            case SequenceMode.ByteModeTwo:
                return(new ByteModeCompactor());

            case SequenceMode.ByteModeThree:
                return(new CharacterModeCompactor());

            case SequenceMode.NumberMode:
                return(new NumberModeCompactor());

            default:
                return(new TextModeCompactor());
            }
        }
Пример #7
0
 private void addModeButton_Click(object sender, EventArgs e)
 {
     if (!updatingModes)
     {
         updatingModes = true;
         SequenceMode mode    = modesComboBox.SelectedItem as SequenceMode;
         ModeControl  newMode = new ModeControl(mode.ID);
         newMode.Mode         = mode;
         newMode.ListPosition = ListModes.Modes.Count;
         ListModes.Modes.Add(newMode);
         Button button = CreateButton(newMode);
         modesFlowPanel.Controls.Add(button);
         CreateDelayEditor(newMode);
         EnableAndDisableControls();
         modeListEditor_Click(sender, e);
         updatingModes = false;
     }
 }
Пример #8
0
		private void Distribute(SequenceMode sequenceMode)
		{
			List<TrackEvent> events = myVegas.Project.GetSelectedEvents();

			using (var undo = new UndoBlock("Distribute: " + sequenceMode.ToString()))
			{
				if (sequenceMode == SequenceMode.Reset)
				{
					foreach (TrackEvent ev in events)
					{
						if (ev.ActiveTake.Media.Markers.Count > 0)
							SetMetaTake(ev, 0);
					}
				}
				else if (sequenceMode == SequenceMode.First)
				{
					foreach (TrackEvent ev in events)
					{
						Marker mkCur = ev.FindCurrentMarker();
						if (mkCur == null)
							continue;
						List<Marker> siblings =
							ev.ActiveTake.Media.Markers.Cast<Marker>().Where(
								mk => mkCur.Label.ToLowerInvariant() == mk.Label.ToLowerInvariant()).ToList();
						if (siblings.Count <= 1 || mkCur == siblings[0])
							continue;
						SetMetaTake(ev, siblings[0]);
					}
				}

				else if (sequenceMode == SequenceMode.Sequential)
				{
					var used = new List<Marker>();

					foreach (TrackEvent ev in events)
					{
						Marker mkCur = ev.FindCurrentMarker();
						if (mkCur == null)
							continue;

						List<Marker> siblings =
							ev.ActiveTake.Media.Markers.Cast<Marker>().Where(
								mk => mkCur.Label.ToLowerInvariant() == mk.Label.ToLowerInvariant()).ToList();
						if (siblings.Count <= 1)
							continue;

						List<Marker> usedSiblings = used.FindAll(item => item.Label.ToLowerInvariant() == mkCur.Label.ToLowerInvariant());
						// reset when full
						if (usedSiblings.Count >= siblings.Count)
						{
							used.RemoveAll(item => item.Label.ToLowerInvariant() == mkCur.Label.ToLowerInvariant());
							usedSiblings.Clear();
						}

						bool done = false;
						Marker next = null;
						int curid = siblings.FindIndex(item => item.Position == mkCur.Position);
						int offset = 0;
						while (!done)
						{
							next = siblings[(curid + offset++) % siblings.Count];
							if (usedSiblings.Find(item => item.Position == next.Position) == null)
							{
								done = true;
							}
						}
						if (next != null)
						{
							SetMetaTake(ev, next);
							used.Add(next);
						}
					}
				}
				else if (sequenceMode == SequenceMode.Reverse)
				{
					List<int> seq =
						(from ev in events select ev.FindCurrentMarker() into curMk where curMk != null select curMk.Index).ToList();
					int i = seq.Count - 1;
					foreach (TrackEvent ev in events)
					{
						SetMetaTake(ev, seq[i--]);
					}
				}
				else if (sequenceMode == SequenceMode.Random)
				{
					var rnd = new Random();
					int last = 0;
					int next = 0;
					foreach (TrackEvent ev in events)
					{
						Marker mkCur = ev.FindCurrentMarker();
						if (mkCur == null)
							continue;
						List<Marker> siblings =
							ev.ActiveTake.Media.Markers.Cast<Marker>().Where(
								mk => mkCur.Label.ToLowerInvariant() == mk.Label.ToLowerInvariant()).ToList();
						while (next == last)
						{
							next = rnd.Next(0, ev.ActiveTake.Media.Markers.Count);
							if (siblings.Count > 1)
							{
								Marker trg = ev.ActiveTake.Media.Markers[next];
								if (mkCur.Label.ToLowerInvariant() != trg.Label.ToLowerInvariant())
								{
									next = last; // force the loop to run once more
								}
							}
							else // we have only one variation
							{
								next = -1;
								break;
							}
						}
						if (next > 0)
							SetMetaTake(ev, next);
						last = next;
					}
				}
				else if (sequenceMode == SequenceMode.Next)
				{
					foreach (TrackEvent ev in events)
					{
						Marker mkCur = ev.FindCurrentMarker();
						if (mkCur == null)
							continue;
						List<int> siblings = (from Marker mk in ev.ActiveTake.Media.Markers
											  where mkCur.Label != null && mkCur.Label.ToLowerInvariant() == mk.Label.ToLowerInvariant()
											  select mk.Index).ToList();
						int curMkSibID = siblings.IndexOf(mkCur.Index);
						int nextMkID = (curMkSibID + 1) % siblings.Count;
						Marker nextMk = ev.ActiveTake.Media.Markers[siblings[nextMkID]];
						SetMetaTake(ev, nextMk);
					}
				}
				else if (sequenceMode == SequenceMode.Prev)
				{
					foreach (TrackEvent ev in events)
					{
						Marker mkCur = ev.FindCurrentMarker();
						if (mkCur == null)
							continue;
						List<int> siblings = (from Marker mk in ev.ActiveTake.Media.Markers
											  where mkCur.Label != null && mkCur.Label.ToLowerInvariant() == mk.Label.ToLowerInvariant()
											  select mk.Index).ToList();
						int curMkSibID = siblings.IndexOf(mkCur.Index);
						int nextMkID = (curMkSibID - 1) % siblings.Count;
						if (nextMkID < 0)
							nextMkID += siblings.Count;
						Marker nextMk = ev.ActiveTake.Media.Markers[siblings[nextMkID]];
						SetMetaTake(ev, nextMk);
					}
				}
				else if (sequenceMode == SequenceMode.NextGroup || sequenceMode == SequenceMode.PrevGroup)
				{
					int groupJumpDirection = 1;
					if (sequenceMode == SequenceMode.PrevGroup)
					{
						groupJumpDirection = -1;
					}
					foreach (TrackEvent ev in events)
					{
						var groups = new List<string>();
						Marker mkCur = ev.FindCurrentMarker();

						if (mkCur == null)
							continue;
						foreach (MediaMarker mk in ev.ActiveTake.Media.Markers)
						{
							if (mk.Label != null && !groups.Contains(mk.Label.ToLowerInvariant()))
							{
								groups.Add(mk.Label.ToLowerInvariant());
							}
						}
						string grpNext = string.Empty;
						for (int i = 0; i < groups.Count; i++)
						{
							if (groups[i] == mkCur.Label.ToLowerInvariant())
							{
								grpNext = groups[(groups.Count + i + groupJumpDirection) % (groups.Count)];
								break;
							}
						}
						Marker mkNext =
							ev.ActiveTake.Media.Markers.FirstOrDefault(
								mk => mk.Label != null && mk.Label.ToLowerInvariant() == grpNext.ToLowerInvariant());
						if (mkNext == null)
							return;
						SetMetaTake(ev, mkNext);
					}
				}
			}
		}
Пример #9
0
        /// <summary>
        /// Used for thread safe changing of selected mode. Called from RunForm.
        /// </summary>
        /// <param name="mode"></param>
        public void setMode(SequenceMode mode)
        {
            Action setItem = () => modeBox.SelectedItem = mode;

            Invoke(setItem);
        }
Пример #10
0
 /// <summary>
 /// Allows methods in other classes to change the sequence mode.
 /// </summary>
 /// <param name="mode"></param>
 public void SelectMode(SequenceMode mode)
 {
     modeBox.SelectedItem = mode;
     modeBox_SelectedIndexChanged(new object(), new EventArgs());
 }
Пример #11
0
 public List <int> AddModeToCodeWords(List <int> codewords, SequenceMode sequenceMode)
 {
     codewords.Insert(0, (int)sequenceMode);
     return(codewords);
 }
Пример #12
0
        private void Distribute(SequenceMode sequenceMode)
        {
            List <TrackEvent> events = myVegas.Project.GetSelectedEvents();

            using (var undo = new UndoBlock("Distribute: " + sequenceMode.ToString()))
            {
                if (sequenceMode == SequenceMode.Reset)
                {
                    foreach (TrackEvent ev in events)
                    {
                        if (ev.ActiveTake.Media.Markers.Count > 0)
                        {
                            SetMetaTake(ev, 0);
                        }
                    }
                }
                else if (sequenceMode == SequenceMode.First)
                {
                    foreach (TrackEvent ev in events)
                    {
                        Marker mkCur = ev.FindCurrentMarker();
                        if (mkCur == null)
                        {
                            continue;
                        }
                        List <Marker> siblings =
                            ev.ActiveTake.Media.Markers.Cast <Marker>().Where(
                                mk => mkCur.Label.ToLowerInvariant() == mk.Label.ToLowerInvariant()).ToList();
                        if (siblings.Count <= 1 || mkCur == siblings[0])
                        {
                            continue;
                        }
                        SetMetaTake(ev, siblings[0]);
                    }
                }

                else if (sequenceMode == SequenceMode.Sequential)
                {
                    var used = new List <Marker>();

                    foreach (TrackEvent ev in events)
                    {
                        Marker mkCur = ev.FindCurrentMarker();
                        if (mkCur == null)
                        {
                            continue;
                        }

                        List <Marker> siblings =
                            ev.ActiveTake.Media.Markers.Cast <Marker>().Where(
                                mk => mkCur.Label.ToLowerInvariant() == mk.Label.ToLowerInvariant()).ToList();
                        if (siblings.Count <= 1)
                        {
                            continue;
                        }

                        List <Marker> usedSiblings = used.FindAll(item => item.Label.ToLowerInvariant() == mkCur.Label.ToLowerInvariant());
                        // reset when full
                        if (usedSiblings.Count >= siblings.Count)
                        {
                            used.RemoveAll(item => item.Label.ToLowerInvariant() == mkCur.Label.ToLowerInvariant());
                            usedSiblings.Clear();
                        }

                        bool   done   = false;
                        Marker next   = null;
                        int    curid  = siblings.FindIndex(item => item.Position == mkCur.Position);
                        int    offset = 0;
                        while (!done)
                        {
                            next = siblings[(curid + offset++) % siblings.Count];
                            if (usedSiblings.Find(item => item.Position == next.Position) == null)
                            {
                                done = true;
                            }
                        }
                        if (next != null)
                        {
                            SetMetaTake(ev, next);
                            used.Add(next);
                        }
                    }
                }
                else if (sequenceMode == SequenceMode.Reverse)
                {
                    List <int> seq =
                        (from ev in events select ev.FindCurrentMarker() into curMk where curMk != null select curMk.Index).ToList();
                    int i = seq.Count - 1;
                    foreach (TrackEvent ev in events)
                    {
                        SetMetaTake(ev, seq[i--]);
                    }
                }
                else if (sequenceMode == SequenceMode.Random)
                {
                    var rnd  = new Random();
                    int last = 0;
                    int next = 0;
                    foreach (TrackEvent ev in events)
                    {
                        Marker mkCur = ev.FindCurrentMarker();
                        if (mkCur == null)
                        {
                            continue;
                        }
                        List <Marker> siblings =
                            ev.ActiveTake.Media.Markers.Cast <Marker>().Where(
                                mk => mkCur.Label.ToLowerInvariant() == mk.Label.ToLowerInvariant()).ToList();
                        while (next == last)
                        {
                            next = rnd.Next(0, ev.ActiveTake.Media.Markers.Count);
                            if (siblings.Count > 1)
                            {
                                Marker trg = ev.ActiveTake.Media.Markers[next];
                                if (mkCur.Label.ToLowerInvariant() != trg.Label.ToLowerInvariant())
                                {
                                    next = last;                                     // force the loop to run once more
                                }
                            }
                            else                             // we have only one variation
                            {
                                next = -1;
                                break;
                            }
                        }
                        if (next > 0)
                        {
                            SetMetaTake(ev, next);
                        }
                        last = next;
                    }
                }
                else if (sequenceMode == SequenceMode.Next)
                {
                    foreach (TrackEvent ev in events)
                    {
                        Marker mkCur = ev.FindCurrentMarker();
                        if (mkCur == null)
                        {
                            continue;
                        }
                        List <int> siblings = (from Marker mk in ev.ActiveTake.Media.Markers
                                               where mkCur.Label != null && mkCur.Label.ToLowerInvariant() == mk.Label.ToLowerInvariant()
                                               select mk.Index).ToList();
                        int    curMkSibID = siblings.IndexOf(mkCur.Index);
                        int    nextMkID   = (curMkSibID + 1) % siblings.Count;
                        Marker nextMk     = ev.ActiveTake.Media.Markers[siblings[nextMkID]];
                        SetMetaTake(ev, nextMk);
                    }
                }
                else if (sequenceMode == SequenceMode.Prev)
                {
                    foreach (TrackEvent ev in events)
                    {
                        Marker mkCur = ev.FindCurrentMarker();
                        if (mkCur == null)
                        {
                            continue;
                        }
                        List <int> siblings = (from Marker mk in ev.ActiveTake.Media.Markers
                                               where mkCur.Label != null && mkCur.Label.ToLowerInvariant() == mk.Label.ToLowerInvariant()
                                               select mk.Index).ToList();
                        int curMkSibID = siblings.IndexOf(mkCur.Index);
                        int nextMkID   = (curMkSibID - 1) % siblings.Count;
                        if (nextMkID < 0)
                        {
                            nextMkID += siblings.Count;
                        }
                        Marker nextMk = ev.ActiveTake.Media.Markers[siblings[nextMkID]];
                        SetMetaTake(ev, nextMk);
                    }
                }
                else if (sequenceMode == SequenceMode.NextGroup || sequenceMode == SequenceMode.PrevGroup)
                {
                    int groupJumpDirection = 1;
                    if (sequenceMode == SequenceMode.PrevGroup)
                    {
                        groupJumpDirection = -1;
                    }
                    foreach (TrackEvent ev in events)
                    {
                        var    groups = new List <string>();
                        Marker mkCur  = ev.FindCurrentMarker();

                        if (mkCur == null)
                        {
                            continue;
                        }
                        foreach (MediaMarker mk in ev.ActiveTake.Media.Markers)
                        {
                            if (mk.Label != null && !groups.Contains(mk.Label.ToLowerInvariant()))
                            {
                                groups.Add(mk.Label.ToLowerInvariant());
                            }
                        }
                        string grpNext = string.Empty;
                        for (int i = 0; i < groups.Count; i++)
                        {
                            if (groups[i] == mkCur.Label.ToLowerInvariant())
                            {
                                grpNext = groups[(groups.Count + i + groupJumpDirection) % (groups.Count)];
                                break;
                            }
                        }
                        Marker mkNext =
                            ev.ActiveTake.Media.Markers.FirstOrDefault(
                                mk => mk.Label != null && mk.Label.ToLowerInvariant() == grpNext.ToLowerInvariant());
                        if (mkNext == null)
                        {
                            return;
                        }
                        SetMetaTake(ev, mkNext);
                    }
                }
            }
        }
Пример #13
0
 public Sequence(SequenceMode mode, string code)
 {
     _mode = mode;
     _code = code;
 }
        /// <summary>
        /// Run each mode in the list of modes selected by the user (in the combobox modeListsComboBox).
        /// </summary>
        private void runModeListButton_Click(object sender, EventArgs e)
        {
            //This method takes all of the modes in the selected ModeList and creates a new
            //sequence mode (megaMode) that contains all of the timesteps of the ModeList
            //with a delay timestep inserted between timesteps from different modes.
            //Once the current mode has been changed to megaMode, the "Run Iteration 0"
            //button is clicked to run megaMode, and then megaMode is deleted and the old
            //current mode restored to being the current mode.

            ModeList     selectedList = modeListsComboBox.SelectedItem as ModeList; //The selected list of modes
            SequenceMode megaMode     = new SequenceMode(-1);

            megaMode.ModeName = selectedList.Name;

            //To run megaMode we must set it to be the current mode, so we should first
            //save the current mode so that we can set it back after we have run megaMode
            SequenceMode currentMode = Storage.sequenceData.CurrentMode;

            Storage.sequenceData.CurrentMode = megaMode;
            MainClientForm.instance.sequencePage.setMode(megaMode);

            //New timesteps will be created for megaMode, so we will first store where we
            //started inserting them so that we can remove them after the method completes
            int stepToBeginRemovingAt = Storage.sequenceData.TimeSteps.Count;

            Dictionary <ModeControl, List <TimeStep> > stepsToAdd = new Dictionary <ModeControl, List <TimeStep> >();
            TimeStep newStep;

            //Run through each mode in the list, and for each one add all of its timesteps
            //to stepsTpAdd, as well as any delays between modes
            foreach (ModeControl con in selectedList.Modes)
            {
                stepsToAdd.Add(con, new List <TimeStep>());
                foreach (TimeStep step in Storage.sequenceData.TimeSteps)
                {
                    step.StepEnabled = false;
                    step.StepHidden  = true;
                    if (con.Mode.TimestepEntries.ContainsKey(step) && con.Mode.TimestepEntries[step].StepEnabled)
                    {
                        newStep             = new TimeStep(step);
                        newStep.StepEnabled = true;
                        newStep.StepHidden  = false;
                        megaMode.TimestepEntries.Add(newStep, new SequenceMode.ModeEntry(newStep.StepEnabled, newStep.StepHidden));
                        stepsToAdd[con].Add(newStep);
                    }
                }
                if (con.Delay.ParameterValue > 0)
                {
                    newStep = new TimeStep();
                    newStep.StepDuration = con.Delay;
                    newStep.StepEnabled  = true;
                    newStep.StepHidden   = false;
                    newStep.StepName     = "Delay";
                    megaMode.TimestepEntries.Add(newStep, new SequenceMode.ModeEntry(newStep.StepEnabled, newStep.StepHidden));
                    stepsToAdd[con].Add(newStep);
                }
            }

            //Now we add all of the timesteps in stepsToAdd to megaMode
            foreach (ModeControl con in selectedList.Modes)
            {
                Storage.sequenceData.TimeSteps.AddRange(stepsToAdd[con]);
            }

            //Set megaMode's timesteps to the Sequence page and then finally run it!
            MainClientForm.instance.sequencePage.storeMode_Click(sender, e);
            MainClientForm.instance.sequencePage.modeBox_SelectedIndexChanged(sender, e);
            MainClientForm.instance.RefreshSequenceDataToUI();
            button1_Click(sender, e);

            //Now that it has run remove megaMode and all of its timesteps and set the old
            //current mode back to its rightful place
            Storage.sequenceData.TimeSteps.RemoveRange(stepToBeginRemovingAt, Storage.sequenceData.TimeSteps.Count - stepToBeginRemovingAt);
            MainClientForm.instance.sequencePage.setMode(currentMode);
            Storage.sequenceData.CurrentMode = currentMode;
            MainClientForm.instance.sequencePage.modeBox_SelectedIndexChanged(sender, e);
            MainClientForm.instance.RefreshSequenceDataToUI();
        }