public void Invalid_TimeBetweenSyncs_Hours()
        {
            var pc = new PluginConfig();

            var defaultValue = new SyncInterval(0, 10);
            var newValue     = new SyncInterval(-2, 0);

            Assert.AreEqual(defaultValue, pc.TimeBetweenSyncs);
            pc.ResetFlags();
            Assert.IsFalse(pc.ConfigChanged);

            pc.TimeBetweenSyncs = newValue;
            var c = pc.TimeBetweenSyncs;

            Assert.IsTrue(pc.ConfigChanged);
            Assert.AreEqual(0, pc.TimeBetweenSyncs.Hours);
            Assert.AreEqual(newValue.Minutes, pc.TimeBetweenSyncs.Minutes);

            var changedInput = "BeatSync.Configs.SyncInterval:Hours";

            Assert.IsTrue(c.InvalidInputFixed);
            Assert.AreEqual(changedInput, c.InvalidInputs.First());
            pc.ResetFlags();
            Assert.AreEqual(0, c.InvalidInputs.Length);
            Assert.IsFalse(c.InvalidInputFixed);
            Assert.IsFalse(pc.ConfigChanged);
        }
Esempio n. 2
0
 public void SaveConfiguration()
 {
     ConfigurationManager.SetValue(Resources.UILanguageKey, UILanguage);
     ConfigurationManager.SetValue(Resources.RestServiceUrlKey, RestServiceUrl);
     ConfigurationManager.SetValue(Resources.ProxyUserNameKey, Credentials.UserName);
     ConfigurationManager.SetValue(Resources.ProxyPasswordKey, Credentials.Password);
     ConfigurationManager.SetValue(Resources.ProxyDomainKey, Credentials.Domain);
     ConfigurationManager.SetValue(Resources.ProxyUseProxyKey, UseProxyServer.ToString());
     ConfigurationManager.SetValue(Resources.AutoSync, AutoSync.ToString());
     ConfigurationManager.SetValue(Resources.SyncHour, SyncHour);
     ConfigurationManager.SetValue(Resources.SyncInterval, SyncInterval.ToString());
     ConfigurationManager.Save();
 }
        public void Unchanged_TimeBetweenSyncs()
        {
            var c            = new PluginConfig();
            var defaultValue = new SyncInterval();
            var newValue     = new SyncInterval(0, 10);

            Assert.AreEqual(defaultValue, c.TimeBetweenSyncs);
            c.ResetConfigChanged();
            Assert.IsFalse(c.ConfigChanged);
            Assert.AreEqual(defaultValue, newValue);
            c.TimeBetweenSyncs = newValue;

            Assert.IsFalse(c.ConfigChanged);
            Assert.AreEqual(defaultValue, c.TimeBetweenSyncs);
        }
        public void Changed_TimeBetweenSyncs_Hours()
        {
            var c            = new PluginConfig();
            var defaultValue = new SyncInterval()
            {
                Hours = 0, Minutes = 10
            };
            var newValue = new SyncInterval()
            {
                Hours = 2, Minutes = 0
            };

            Assert.AreEqual(defaultValue, c.TimeBetweenSyncs);
            c.ResetConfigChanged();
            Assert.IsFalse(c.ConfigChanged);

            c.TimeBetweenSyncs = newValue;

            Assert.IsTrue(c.ConfigChanged);
            Assert.AreEqual(newValue, c.TimeBetweenSyncs);
        }
Esempio n. 5
0
        public override void BuildMesh(DirectX.DirectXCanvas canvas, ThreadScroll scroll)
        {
            SetBusy(true);
            UpdateDepth();

            // Build Mesh
            DirectX.ComplexDynamicMesh builder         = new ComplexDynamicMesh(canvas, DIPSplitCount);
            DirectX.ComplexDynamicMesh syncBuilder     = new ComplexDynamicMesh(canvas, DIPSplitCount);
            DirectX.ComplexDynamicMesh syncWorkBuilder = new ComplexDynamicMesh(canvas, DIPSplitCount);

            if (EventData.Sync != null && EventData.Sync != null)
            {
                SyncReason stallReason    = SyncReason.SyncReasonCount;
                long       stallFrom      = 0;
                int        frameSyncIndex = 0;

                for (int i = 0; i < EventData.Sync.Count; i++)
                {
                    SyncInterval sync = EventData.Sync[i];

                    Interval workInterval = scroll.TimeToUnit(sync);

                    //draw work
                    int coreColorIndex = (int)sync.Core;
                    coreColorIndex = coreColorIndex % WorkColors.Length;
                    Color WorkColor = WorkColors[coreColorIndex];
                    syncWorkBuilder.AddRect(new Rect(workInterval.Left, 0, workInterval.Right - workInterval.Left, SyncLineHeight / Height), WorkColor);

                    if (i == 0)
                    {
                        stallReason = sync.Reason;
                        stallFrom   = sync.Finish;
                        continue;
                    }

                    long workStart  = sync.Start;
                    long workFinish = sync.Finish;

                    while (frameSyncIndex < EventData.Events.Count && EventData.Events[frameSyncIndex].Finish < stallFrom)
                    {
                        ++frameSyncIndex;
                    }

                    //Ignoring all the waiting outside marked work to simplify the view
                    if (frameSyncIndex < EventData.Events.Count && EventData.Events[frameSyncIndex].Start <= workStart)
                    {
                        Durable  syncDurable  = new Durable(stallFrom, workStart);
                        Interval syncInterval = scroll.TimeToUnit(syncDurable);

                        double syncWidth = syncInterval.Right - syncInterval.Left;
                        if (syncWidth > 0)
                        {
                            // draw sleep
                            Color waitColor = IsUserInitiatedSync(stallReason) ? SynchronizationColorUser : SynchronizationColor;
                            syncBuilder.AddRect(new Rect(syncInterval.Left, 0, syncWidth, SyncLineHeight / Height), waitColor);
                        }
                    }

                    stallFrom   = workFinish;
                    stallReason = sync.Reason;
                }
            }

            foreach (EventFrame frame in EventData.Events)
            {
                Durable   interval = Group.Board.TimeSlice;
                EventTree tree     = GetTree(frame);
                foreach (EventNode node in tree.Children)
                {
                    BuildMeshNode(builder, scroll, node, 0);
                }
            }

            Blocks       = builder.Freeze(canvas.RenderDevice);
            SyncMesh     = syncBuilder.Freeze(canvas.RenderDevice);
            SyncWorkMesh = syncWorkBuilder.Freeze(canvas.RenderDevice);

            CallstackMeshPolys            = canvas.CreateMesh();
            CallstackMeshPolys.Projection = Mesh.ProjectionType.Pixel;

            CallstackMeshLines            = canvas.CreateMesh();
            CallstackMeshLines.Geometry   = Mesh.GeometryType.Lines;
            CallstackMeshLines.Projection = Mesh.ProjectionType.Pixel;

            SetBusy(false);
        }
Esempio n. 6
0
        public override void BuildMesh(DirectX.DirectXCanvas canvas, ThreadScroll scroll)
        {
            // Build Mesh
            DirectX.DynamicMesh builder     = canvas.CreateMesh();
            DirectX.DynamicMesh syncBuilder = canvas.CreateMesh();

            if (EventData.Sync != null && EventData.Sync.Intervals != null)
            {
                SyncReason stallReason = SyncReason.SyncReasonCount;
                long       stallFrom   = 0;
                for (int i = 0; i < EventData.Sync.Intervals.Count; i++)
                {
                    SyncInterval sync = EventData.Sync.Intervals[i];

                    Interval workInterval = scroll.TimeToUnit(sync);

                    // draw work
                    int coreColorIndex = (int)sync.Core;
                    coreColorIndex = coreColorIndex % WorkColors.Length;
                    Color WorkColor = WorkColors[coreColorIndex];
                    syncBuilder.AddRect(new Rect(workInterval.Left, RenderParams.BaseMargin / Height, workInterval.Right - workInterval.Left, SyncLineHeight / Height), WorkColor);

                    if (i == 0)
                    {
                        stallReason = sync.Reason;
                        stallFrom   = sync.Finish;
                        continue;
                    }

                    long     workStart    = sync.Start;
                    long     workFinish   = sync.Finish;
                    Interval syncInterval = scroll.TimeToUnit(new Durable(stallFrom, workStart));

                    double syncWidth = syncInterval.Right - syncInterval.Left;
                    if (syncWidth <= 0)
                    {
                        syncWidth = 0.1;
                    }

                    // draw sleep
                    Color waitColor = IsUserInitiatedSync(stallReason) ? SynchronizationColorUser : SynchronizationColor;
                    syncBuilder.AddRect(new Rect(syncInterval.Left, RenderParams.BaseMargin / Height, syncWidth, SyncLineHeight / Height), waitColor);

                    stallFrom   = workFinish;
                    stallReason = sync.Reason;
                }
            }

            foreach (EventFrame frame in EventData.Events)
            {
                Durable interval = Group.Board.TimeSlice;

                foreach (EventNode node in frame.CategoriesTree.Children)
                {
                    BuildMeshNode(builder, scroll, node, 0);
                }
            }

            Mesh     = builder.Freeze(canvas.RenderDevice);
            SyncMesh = syncBuilder.Freeze(canvas.RenderDevice);

            CallstackMeshPolys = canvas.CreateMesh();

            CallstackMeshLines          = canvas.CreateMesh();
            CallstackMeshLines.Geometry = Mesh.GeometryType.Lines;
        }
Esempio n. 7
0
        /// <summary>
        /// Saves the Settings
        /// </summary>
        public static void SaveSettings()
        {
            Logger.Debug("Saving IMDb+ options to file.");

            #region Scraper
            XmlWriter xmlWriter = new XmlWriter();
            if (!xmlWriter.Load(OptionsFile))
            {
                if (File.Exists(OptionsFile))
                {
                    try
                    {
                        File.Delete(OptionsFile);
                    }
                    catch (Exception e)
                    {
                        Logger.Error("Error deleting file: '{0}'", OptionsFile);
                        Logger.Error("Exception: {0}", e.Message);
                        return;
                    }
                }

                // create it
                Logger.Info("Creating new IMDb+ options file.");
                xmlWriter.CreateXmlConfigFile(OptionsFile);
                xmlWriter.Load(OptionsFile);
            }

            xmlWriter.SetOptionsEntry(cOriginalTitle, "01", OriginalTitle.ToString());
            xmlWriter.SetOptionsEntry(cForeignTitle, "02", ForeignTitle.ToString());
            xmlWriter.SetOptionsEntry(cForeignFirst, "03", ForeignFirst.ToString());
            xmlWriter.SetOptionsEntry(cUkRating, "04", UkRating.ToString());
            xmlWriter.SetOptionsEntry(cIMDbScore, "05", IMDbScore.ToString());
            xmlWriter.SetOptionsEntry(cIMDbMetaScore, "06", IMDbMetaScore.ToString());
            xmlWriter.SetOptionsEntry(cLongSummary, "07", LongSummary.ToString());
            xmlWriter.SetOptionsEntry(cRottenMeter, "08", RottenMeter.ToString());
            xmlWriter.SetOptionsEntry(cRottenAverage, "09", RottenAverage.ToString());
            xmlWriter.SetOptionsEntry(cRottenTopCritics, "10", RottenTopCritics.ToString());
            xmlWriter.SetOptionsEntry(cSpecialEdition, "11", SpecialEdition.ToString());
            xmlWriter.SetOptionsEntry(cRenameTitles, "12", RenameTitles.ToString());
            xmlWriter.SetOptionsEntry(cSingleScore, "13", SingleScore.ToString());
            xmlWriter.SetOptionsEntry(cMinIMDbVotes, "14", MinIMDbVotes.ToString());
            xmlWriter.SetOptionsEntry(cRefreshAllFields, "15", RefreshAllFields.ToString());
            xmlWriter.SetOptionsEntry(cOneWriterDirector, "16", OneWriterDirector.ToString());
            xmlWriter.SetOptionsEntry(cRemoveFirstRoman, "17", RemoveFirstRoman.ToString());
            xmlWriter.SetOptionsEntry(cFixMissingSummary, "18", FixMissingSummary.ToString());

            xmlWriter.SetOptionsEntry(cRatings, "94", Ratings);
            xmlWriter.SetOptionsEntry(cSecondaryEnglishTitle, "95", SecondaryEnglishTitle.ToString());
            xmlWriter.SetOptionsEntry(cSecondarySummary, "96", SecondarySummary.ToString());
            xmlWriter.SetOptionsEntry(cSecondaryDetails, "97", SecondaryDetails);
            xmlWriter.SetOptionsEntry(cCountryFilter, "98", CountryFilter);
            xmlWriter.SetOptionsEntry(cLanguageFilter, "99", LanguageFilter);

            // save file
            xmlWriter.Save(OptionsFile);
            #endregion

            #region Plugin
            using (Settings xmlwriter = new MPSettings())
            {
                xmlwriter.SetValue(cSection, cSyncInterval, SyncInterval.ToString());
                xmlwriter.SetValueAsBool(cSection, cSyncOnStartup, SyncOnStartup);
                xmlwriter.SetValue(cSection, cSyncLastDateTime, SyncLastDateTime.ToString());
                xmlwriter.SetValueAsBool(cSection, cDisableNotifications, DisableNotifications);
                xmlwriter.SetValue(cSection, cMoviesRefreshed, MoviesRefreshed.ToJSON());
            }
            Settings.SaveCache();
            #endregion
        }