Ejemplo n.º 1
0
        public void AddMargin(GCConfigRatedMargin m)
        {
            if (Margins == null)
            {
                Margins = new List <GCConfigRatedMargin>();
            }

            Margins.Add(m);
            Modified = true;
        }
Ejemplo n.º 2
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="title">Name of the interval</param>
        /// <param name="offStart">Offset of the start (in seconds)</param>
        /// <param name="offEnd">Offset of the end (in seconds)</param>
        /// <param name="rating">Rating of this interval</param>
        public void AddMargin(string title, int offStart, int offEnd, double rating)
        {
            GCConfigRatedMargin m = new GCConfigRatedMargin();

            m.Title              = title;
            m.Rating             = rating;
            m.OffsetMinutesStart = offStart;
            m.OffsetMinutesEnd   = offEnd;

            AddMargin(m);
        }
Ejemplo n.º 3
0
        public void DeleteMargin(GCConfigRatedMargin SelectedSubevent)
        {
            if (Margins == null)
            {
                return;
            }
            int i = Margins.IndexOf(SelectedSubevent);

            if (i >= 0 && i < MarginsCount)
            {
                Margins.RemoveAt(i);
                Modified = true;
            }
        }
Ejemplo n.º 4
0
        /// <summary>
        /// Save configuration into file with given name
        /// </summary>
        /// <param name="fileName">Full path to file</param>
        public void Save(string fileName)
        {
            FileName = fileName;
            using (StreamWriter sw = new StreamWriter(fileName))
            {
                sw.WriteLine("3 {0}|{1}", useAcceptLimit, acceptLimit);
                sw.WriteLine("4 {0}|{1}", useMinPeriodLength, minPeriodLength);
                sw.WriteLine("5 {0}", GCFestivalBase.StringToSafe(Title));
                sw.WriteLine("6 {0}", GCFestivalBase.StringToSafe(Description));

                List <ParameterDescriptor> ar = this.ParameterDescriptions;
                foreach (ParameterDescriptor a in ar)
                {
                    if (a.Array != null)
                    {
                        for (int i = a.Min; i < a.Max; i++)
                        {
                            sw.WriteLine("1 {0}|{1}|{2}|{3}", a.Key, i, a.Array[i].Rating,
                                         GCFestivalBase.StringToSafe(a.Array[i].Note));
                            for (int k = 0; k < a.Array[i].MarginsCount; k++)
                            {
                                GCConfigRatedMargin m = a.Array[i].Margins[k];
                                sw.WriteLine("99 {0}|{1}|{2}|{3}|{4}", GCFestivalBase.StringToSafe(m.Title), m.Rating,
                                             m.OffsetMinutesStart, m.OffsetMinutesEnd, GCFestivalBase.StringToSafe(m.Note));
                            }
                            a.Array[i].Modified = false;
                        }
                    }
                    else if (a.Array2 != null)
                    {
                        for (int i = a.Min; i < a.Max; i++)
                        {
                            for (int j = a.Min2; j < a.Max2; j++)
                            {
                                sw.WriteLine("2 {0}|{1}|{2}|{3}|{4}", a.Key, i, j, a.Array2[i, j].Rating,
                                             GCFestivalBase.StringToSafe(a.Array2[i, j].Note));
                                for (int k = 0; k < a.Array2[i, j].MarginsCount; k++)
                                {
                                    GCConfigRatedMargin m = a.Array[i].Margins[k];
                                    sw.WriteLine("99 {0}|{1}|{2}|{3}|{4}", GCFestivalBase.StringToSafe(m.Title), m.Rating,
                                                 m.OffsetMinutesStart, m.OffsetMinutesEnd, GCFestivalBase.StringToSafe(m.Note));
                                }
                                a.Array2[i, j].Modified = false;
                            }
                        }
                    }
                }
            }
        }
Ejemplo n.º 5
0
        public List <GCConfigRatedMargin> CloneMargins()
        {
            if (Margins == null)
            {
                return(null);
            }
            List <GCConfigRatedMargin> list = new List <GCConfigRatedMargin>();

            foreach (GCConfigRatedMargin sm in Margins)
            {
                GCConfigRatedMargin target = new GCConfigRatedMargin();
                target.Note               = sm.Note;
                target.OffsetMinutesEnd   = sm.OffsetMinutesEnd;
                target.OffsetMinutesStart = sm.OffsetMinutesStart;
                target.Rating             = sm.Rating;
                target.Title              = sm.Title;
                list.Add(target);
            }

            return(list);
        }
Ejemplo n.º 6
0
        /// <summary>
        /// Loading configuration from file
        /// </summary>
        /// <param name="fileName"></param>
        public void Load(string fileName)
        {
            FileName = fileName;

            using (StreamReader sr = new StreamReader(fileName))
            {
                List <ParameterDescriptor> ar = this.ParameterDescriptions;
                ParameterDescriptor        a;
                GCConfigRatedEntry         lastEntry = null;
                int            idx, idx2;
                GCRichFileLine rf = new GCRichFileLine();
                while (rf.SetLine(sr.ReadLine()))
                {
                    a = GetArrayRef(ar, rf.GetField(0));
                    try
                    {
                        if (rf.TagInt == 1)
                        {
                            idx = rf.GetFieldInt(1);
                            a.Array[idx].Rating = rf.GetFieldDouble(2);
                            a.Array[idx].Note   = rf.GetField(3);
                            lastEntry           = a.Array[idx];
                        }
                        else if (rf.TagInt == 2)
                        {
                            idx  = rf.GetFieldInt(1);
                            idx2 = rf.GetFieldInt(2);
                            a.Array2[idx, idx2].Rating = rf.GetFieldDouble(3);
                            a.Array2[idx, idx2].Note   = rf.GetField(4);
                            lastEntry = a.Array2[idx, idx2];
                        }
                        else if (rf.TagInt == 3)
                        {
                            useAcceptLimit = bool.Parse(rf.GetField(0));
                            acceptLimit    = rf.GetFieldDouble(1);
                        }
                        else if (rf.TagInt == 4)
                        {
                            useMinPeriodLength = bool.Parse(rf.GetField(0));
                            minPeriodLength    = rf.GetFieldDouble(1);
                        }
                        else if (rf.TagInt == 5)
                        {
                            Title = GCFestivalBase.SafeToString(rf.GetField(0));
                        }
                        else if (rf.TagInt == 6)
                        {
                            Description = GCFestivalBase.SafeToString(rf.GetField(0));
                        }
                        else if (rf.TagInt == 99 && lastEntry != null)
                        {
                            GCConfigRatedMargin m = new GCConfigRatedMargin();
                            m.Title              = GCFestivalBase.SafeToString(rf.GetField(0));
                            m.Rating             = rf.GetFieldDouble(1);
                            m.OffsetMinutesStart = rf.GetFieldInt(2);
                            m.OffsetMinutesEnd   = rf.GetFieldInt(3);
                            m.Note = GCFestivalBase.SafeToString(rf.GetField(4));
                            lastEntry.AddMargin(m);
                        }
                    }
                    catch
                    {
                    }
                }
            }
        }