private void OnReproducePatternButtonClick(object sender, RoutedEventArgs e)
        {
            Pattern pattern = new Pattern(UI.SelectedPattern.Name, UI.Window.MultiStagesEditor.GetStages());

            if (pattern.Stages == null || pattern.Stages.Length <= 0)
            {
                MessageBox.Show("The selected pattern doesn't have any stages, can't reproduce.", "Empty pattern", MessageBoxButton.OK, MessageBoxImage.Warning);
                return;
            }

            new PatternPlayerWindow(pattern).ShowDialog();
        }
        public PatternPlayerWindow(Pattern pattern)
        {
            if (pattern.Stages == null || pattern.Stages.Length <= 0)
                throw new ArgumentException("The Stages array is null or empty.", nameof(pattern));

            Pattern = pattern;


            InitializeComponent();

            Title = "Reproducing " + Pattern.Name;

            currentStage = Pattern.Stages[0];
            currentStageIndex = 0;
            
            RenderStage();

            int timeMs = unchecked((int)currentStage.Milliseconds);
            timeMs = Math.Max(timeMs, 1); // if milliseconds equals 0, it freezes the window, it needs to be at least 1 ms

            timer = new DispatcherTimer(new TimeSpan(0, 0, 0, 0, timeMs), DispatcherPriority.Normal, OnTimerTick, Dispatcher);
            timer.Start();
        }
Esempio n. 3
0
 public PatternWrapper(string name, Pattern.Stage[] stages)
 {
     this.pattern = new Pattern(name, stages);
 }
Esempio n. 4
0
 public PatternWrapper(Pattern pattern)
 {
     this.pattern = pattern;
 }
Esempio n. 5
0
        public static void SaveTo(string fileName, Pattern[] patterns)
        {
            string xmlText = "";
            using (StringWriter writer = new StringWriter())
            {
                XmlSerializer s = new XmlSerializer(typeof(Pattern[]));
                s.Serialize(writer, patterns);
                xmlText = writer.ToString().Replace("\"?>", "\"?>" + Environment.NewLine + PatternXMLExplanationText); // add the explanation comment after the XML declaration
            }

            using (StreamWriter writer = new StreamWriter(fileName, false))
            {
                writer.Write(xmlText);
            }
        }
 public StageEditor AddStageEditor(Pattern.Stage stage)
 {
     StageEditor editor = AddStageEditor();
     editor.Stage = stage;
     return editor;
 }