Exemple #1
0
        public override string GetHistory(int id)
        {
            KeyPoint key = keypoints[0];
            string   cmd = id + "," + this.effectName + "," + LightBallHelper.getFormatedTimeString(startTime) + "," + LightBallHelper.getFormatedTimeString(endTime) + "," + key.color.R + "," + key.color.G + "," + key.color.B + getParaCmd() + "\n";

            return(cmd);
        }
Exemple #2
0
 public EffectColorTransition(string[] strs)
     : base(LightBallHelper.getTimeSpanFromString(strs[2]), LightBallHelper.getTimeSpanFromString(strs[3]), EffectsNames.EffectColorTransition)
 {
     paraInit();
     autoGen = (strs[4] == "autoGen" ? true : false);
     loadPara(strs, 5);
 }
Exemple #3
0
 protected double[] getParas()
 {
     double[] paras = new double[para_len];
     for (int i = 0; i < para_len; i++)
     {
         paras[i] = LightBallHelper.getDoubleFromString(para_value[i]);
     }
     return(paras);
 }
Exemple #4
0
 public EffectBounce(string[] strs, EffectsNames name) : base(LightBallHelper.getTimeSpanFromString(strs[2]), LightBallHelper.getTimeSpanFromString(strs[3]), name)
 {
     paraInit();
     loadPara(strs, 7);
     this.Add(this.startTime, 0, 0,
              Color.FromArgb(LightBallHelper.getIntFromString(strs[4]),  // R
                             LightBallHelper.getIntFromString(strs[5]),  // G
                             LightBallHelper.getIntFromString(strs[6])), // B
              0, 0);                                                     // Bright Tran
 }
Exemple #5
0
 public override void LoadKeypoints(string[] strs)
 {
     this.Add(LightBallHelper.getTimeSpanFromString(strs[2]),            // Start_time
              LightBallHelper.getDoubleFromString(strs[3]),              // Duration
              LightBallHelper.getDoubleFromString(strs[4]),              // Duty
              Color.FromArgb(LightBallHelper.getIntFromString(strs[5]),  // R
                             LightBallHelper.getIntFromString(strs[6]),  // G
                             LightBallHelper.getIntFromString(strs[7])), // B
              0, 0);
 }
Exemple #6
0
        public override string GetTasks(int ballID)
        {
            string cmd   = "";
            double phase = LightBallHelper.getDoubleFromString(para_value[5]);

            keypoints.ForEach((key) =>
            {
                cmd += "{" + effectCmdName + "," + key.getBasicInfo(ballID * (int)phase) + ", 0x" + KeyPoint.get1HexFromInt((int)key.colorTransition) + ", 0x" + KeyPoint.get1HexFromInt(KeyPoint.getFormatedFloat(key.brightTransition)) + ", 0x00, 0x00},\n";
            });
            return(cmd);
        }
Exemple #7
0
        public override string GetHistory(int id)
        {
            string autoGenStr = (autoGen ? "autoGen" : "manGen");
            string cmd        = id + "," + this.effectName + "," + LightBallHelper.getFormatedTimeString(startTime) + "," + LightBallHelper.getFormatedTimeString(endTime) + "," + autoGenStr + getParaCmd() + "\n";

            keypoints.ForEach((key) =>
            {
                cmd += id + "," + this.effectName + "," + LightBallHelper.getFormatedTimeString(key.startTime) + "," + key.duration + "," + key.duty + "," + key.colorTransition + "," + key.brightTransition + "," + key.color.R + "," + key.color.G + "," + key.color.B + "\n";
            });
            return(cmd);
        }
Exemple #8
0
        public static void SaveHistory(string filename, List <Effects> effects)
        {
            string cmd    = "0," + LightBallHelper.getFormatedTimeString(globalStartingTime) + "," + numOfBall + "\n";
            int    cmd_id = 1;

            effects.ForEach((effect) =>
            {
                cmd += effect.GetHistory(cmd_id);
                cmd_id++;
            });
            cmd += cmd_id + ",End\n";
            StreamWriter sw = new StreamWriter(filename);

            sw.WriteLine(cmd);
            sw.Close();
        }
Exemple #9
0
        public override string GetTasks(int ballID)
        {
            double[] paras    = getParas();
            string[] startHex = KeyPoint.getHexFromTimeSpan(this.startTime.Subtract(globalStartingTime));
            int      dur      = (int)(endTime - startTime).TotalMilliseconds;

            string[] durHex = KeyPoint.get2HexFromInt(dur);
            double   phase  = LightBallHelper.getDoubleFromString(para_value[5]);
            Color    color  = HSLColor.offsetColor(this.keypoints[0].color, ballID * (int)phase, 0);

            string[] colorHex    = KeyPoint.getHexFromColor(color);
            string   colTranHex  = KeyPoint.get1HexFromInt((int)paras[3]);
            string   bounceCount = KeyPoint.get1HexFromInt((int)paras[4]);
            string   count       = KeyPoint.get1HexFromInt((int)paras[0]);
            string   duty        = KeyPoint.get1HexFromInt((int)paras[2]);
            string   cmd         = "{" + effectCmdName + ", " + String.Format("0x{0}, 0x{1}, 0x{2}, 0x{3}, 0x{4}, 0x{5}, 0x{6}, 0x{7}, 0x{8}, 0x{9}, 0x{10}, 0x{11}, 0x{12}", startHex[0], startHex[1], startHex[2], startHex[3], durHex[0], durHex[1], colorHex[0], colorHex[1], colorHex[2], colTranHex, bounceCount, count, duty) + "},\n";

            return(cmd);
        }
Exemple #10
0
        public static void RestoreHistory(string filename, out List <Effects> effects)
        {
            effects = new List <Effects>();
            StreamReader sr      = new StreamReader(filename);
            Effects      now_eff = null;
            string       line    = "";
            int          cmd_id  = -1;

            while ((line = sr.ReadLine()) != null)
            {
                string[] strs = line.Split(',');
                if (strs.Length <= 1)
                {
                    continue;
                }
                int id;
                if (int.TryParse(strs[0], out id))
                {
                    if (id == 0)
                    {
                        globalStartingTime = LightBallHelper.getTimeSpanFromString(strs[1]);
                        numOfBall          = LightBallHelper.getIntFromString(strs[2]);
                    }
                    else if (cmd_id != id)
                    {
                        if (now_eff != null)
                        {
                            effects.Add(now_eff);
                        }
                        EffectsNames effect = (EffectsNames)Enum.Parse(typeof(EffectsNames), strs[1]);
                        switch (effect)
                        {
                        case EffectsNames.EffectHSL:
                            now_eff = new EffectHSL(strs); break;

                        case EffectsNames.EffectColorTransition:
                            now_eff = new EffectColorTransition(strs); break;

                        case EffectsNames.EffectSparkAsync:
                            now_eff = new EffectSparkAsync(strs); break;

                        case EffectsNames.EffectSparkSync:
                            now_eff = new EffectSparkSync(strs); break;

                        case EffectsNames.EffectMeteorAsync:
                            now_eff = new EffectMeteorAsync(strs); break;

                        case EffectsNames.EffectMeteorSync:
                            now_eff = new EffectMeteorSync(strs); break;

                        case EffectsNames.EffectBounceAsync:
                            now_eff = new EffectBounceAsync(strs); break;

                        case EffectsNames.EffectBounceSync:
                            now_eff = new EffectBounceSync(strs); break;

                        default:
                            break;
                        }
                    }
                    else
                    {
                        now_eff.LoadKeypoints(strs);
                    }
                    cmd_id = id;
                }
            }
            sr.Close();
        }
Exemple #11
0
        public LightBallHelper()
        {
            InitializeComponent();
            labelNowTime.Text   = prefixNowTime;
            labelTotalTime.Text = prefixTotalTime;
            /* Waveform setup */
            waveFormRenderer = new WaveFormRenderer();
            standardSettings = new StandardWaveFormRendererSettings()
            {
                Name = "Standard"
            };

            BtnTopColour.BackColor    = standardSettings.TopPeakPen.Color;
            BtnBottomColour.BackColor = standardSettings.BottomPeakPen.Color;

            updownTopHeight.Value    = 80;
            updownBottomHeight.Value = 80;
            labelRendering.Visible   = false;
            timer1.Enabled           = false;
            Bitmap bitmap = new Bitmap(Resource1.indicator);

            pictureBoxIndicator.BackColor = Color.Transparent;
            pictureBoxIndicator.Location  = new Point(START_POS - 5, WAVE_LOC_Y - 5);
            pictureBoxIndicator.Image     = bitmap;

            UpdownOffset.Value = 50;

            comboBoxPeakCalculationStrategy.Items.Add("Max Rms Value");
            comboBoxPeakCalculationStrategy.Items.Add("Max Absolute Value");
            comboBoxPeakCalculationStrategy.Items.Add("Sampled Peaks");
            comboBoxPeakCalculationStrategy.Items.Add("Scaled Average");
            comboBoxPeakCalculationStrategy.SelectedIndex         = 0;
            comboBoxPeakCalculationStrategy.SelectedIndexChanged += (sender, args) => {
                if (!String.IsNullOrEmpty(fileName))
                {
                    RenderWaveform();
                }
            };

            /* Effects Setup */
            effectListObj = new List <Effects>();

            effectsOptions.Items.Add(Effects.EffectsNames.EffectHSL.ToString());
            effectsOptions.Items.Add(Effects.EffectsNames.EffectColorTransition.ToString());
            effectsOptions.Items.Add(Effects.EffectsNames.EffectSparkAsync.ToString());
            effectsOptions.Items.Add(Effects.EffectsNames.EffectSparkSync.ToString());
            effectsOptions.Items.Add(Effects.EffectsNames.EffectMeteorAsync.ToString());
            effectsOptions.Items.Add(Effects.EffectsNames.EffectMeteorSync.ToString());
            effectsOptions.Items.Add(Effects.EffectsNames.EffectBounceAsync.ToString());
            effectsOptions.Items.Add(Effects.EffectsNames.EffectBounceSync.ToString());
            keyColor = Color.AliceBlue;
            setColor(keyColor);
            textBoxGlobalStarting.Text = getFormatedTimeString(Effects.globalStartingTime);
            textBoxNumberOfBalls.Text  = Effects.numOfBall.ToString();

            // Setup Effect Attr Objects
            {
                effectAttrLabel[0] = this.labelEffectAttr0;
                effectAttrValue[0] = this.textBoxEffectAttr0;
                effectAttrUnit[0]  = this.unitEffectAttr0;
                effectAttrLabel[1] = this.labelEffectAttr1;
                effectAttrValue[1] = this.textBoxEffectAttr1;
                effectAttrUnit[1]  = this.unitEffectAttr1;
                effectAttrLabel[2] = this.labelEffectAttr2;
                effectAttrValue[2] = this.textBoxEffectAttr2;
                effectAttrUnit[2]  = this.unitEffectAttr2;
                effectAttrLabel[3] = this.labelEffectAttr3;
                effectAttrValue[3] = this.textBoxEffectAttr3;
                effectAttrUnit[3]  = this.unitEffectAttr3;
                effectAttrLabel[4] = this.labelEffectAttr4;
                effectAttrValue[4] = this.textBoxEffectAttr4;
                effectAttrUnit[4]  = this.unitEffectAttr4;
                effectAttrLabel[5] = this.labelEffectAttr5;
                effectAttrValue[5] = this.textBoxEffectAttr5;
                effectAttrUnit[5]  = this.unitEffectAttr5;
            }

            /* Configuration */
            textBoxGlobalStarting.Text = LightBallHelper.getFormatedTimeString(TimeSpan.Zero);
            textBoxEffectAttr5.Text    = "0";
        }