public ChocolateyService(IRunSync powerShell, ISourceService sourceService)
 {
     _powershell = powerShell;
     _sourceService = sourceService;
     _powershell.OutputChanged += InvokeOutputChanged;
     _powershell.RunFinished += OnRunFinished;
 }
Example #2
0
 private static void PopulatePredictions(IRun run, TimeSpan? currentTime, int segmentIndex, IList<TimeSpan?> predictions, bool simpleCalculation, bool useCurrentRun, TimingMethod method)
 {
     if (currentTime != null)
     {
         PopulatePrediction(predictions, currentTime + run[segmentIndex].BestSegmentTime[method], segmentIndex + 1);
         if (!simpleCalculation)
         {
             foreach (var nullSegment in run[segmentIndex].SegmentHistory.Where(x => !x.Value[method].HasValue))
             {
                 Time segmentTime;
                 if (segmentIndex == 0 
                     || !run[segmentIndex - 1].SegmentHistory.TryGetValue(nullSegment.Key, out segmentTime)
                     || segmentTime[method] != null)
                 {
                     var prediction = TrackBranch(run, currentTime, segmentIndex + 1, nullSegment.Key, method);
                     PopulatePrediction(predictions, prediction.Time[method], prediction.Index);
                 }
             }
         }
         if (useCurrentRun)
         {
             var currentRunPrediction = TrackCurrentRun(run, currentTime, segmentIndex, method);
             PopulatePrediction(predictions, currentRunPrediction.Time[method], currentRunPrediction.Index);
         }
         var personalBestRunPrediction = TrackPersonalBestRun(run, currentTime, segmentIndex, method);
         PopulatePrediction(predictions, personalBestRunPrediction.Time[method], personalBestRunPrediction.Index);
     }
 }
Example #3
0
        public string ImportAsComparison(IRun run, Form form = null)
        {
            var splitDialog = new OpenFileDialog();

            var result = splitDialog.ShowDialog();
            if (result == DialogResult.OK)
            {
                var filePath = splitDialog.FileName;

                using (var stream = File.OpenRead(filePath))
                {
                    var runFactory = new StandardFormatsRunFactory();
                    var comparisonGeneratorsFactory = new StandardComparisonGeneratorsFactory();

                    runFactory.Stream = stream;
                    runFactory.FilePath = filePath;

                    var imported = runFactory.Create(comparisonGeneratorsFactory);

                    var comparisonName = Path.GetFileNameWithoutExtension(splitDialog.FileName);
                    result = InputBox.Show(form, "Enter Comparison Name", "Name:", ref comparisonName);
                    if (result != DialogResult.Cancel)
                        return run.AddComparisonWithNameInput(imported, comparisonName, form);
                }
            }
            return null;
        }
Example #4
0
 /// <summary>
 /// Gets or sets the RunVertex associated with the given IRun
 /// </summary>
 /// <param name="key">
 /// The IRun whose value to get or set.
 /// </param>
 public RunVertex this[IRun key]
 {
     get
     {
         return (RunVertex) this.Dictionary[key];
     }
 }
 public FailedLoadingRunInvoker(IRun generator, Exception exception)
     : base(generator)
 {
     if (exception == null)
         throw new ArgumentNullException("exception");
     this.exception = exception;
 }
Example #6
0
 private static void PopulatePredictions(IRun run, TimeSpan? currentTime, int segmentIndex, IList<TimeSpan?> predictions, bool useCurrentRun, TimingMethod method)
 {
     if (currentTime != null)
     {
         PopulatePrediction(predictions, currentTime + run[segmentIndex].BestSegmentTime[method], segmentIndex + 1);
         foreach (var segment in run[segmentIndex].SegmentHistory)
         {
             Time segmentTime;
             if (segmentIndex == 0 
                 || !run[segmentIndex - 1].SegmentHistory.TryGetValue(segment.Key, out segmentTime) 
                 || segmentTime[method] != null)
             {
                 var prediction = SumOfSegmentsHelper.TrackBranch(run, currentTime, segmentIndex, segment.Key, method);
                 PopulatePrediction(predictions, prediction.Time[method], prediction.Index);
             }
         }
         if (useCurrentRun)
         {
             var currentRunPrediction = SumOfSegmentsHelper.TrackCurrentRun(run, currentTime, segmentIndex, method);
             PopulatePrediction(predictions, currentRunPrediction.Time[method], currentRunPrediction.Index);
         }
         var personalBestRunPrediction = SumOfSegmentsHelper.TrackPersonalBestRun(run, currentTime, segmentIndex, method);
         PopulatePrediction(predictions, personalBestRunPrediction.Time[method], personalBestRunPrediction.Index);
     }
 }
Example #7
0
 private static void PopulatePredictions(IRun run, TimeSpan? currentTime, int segmentIndex, IList<TimeSpan?> predictions, bool simpleCalculation, bool useCurrentRun, TimingMethod method)
 {
     if (currentTime != null)
     {
         PopulatePrediction(predictions, currentTime + run[segmentIndex].BestSegmentTime[method], segmentIndex + 1);
         if (!simpleCalculation)
         {
             foreach (var nullSegment in run[segmentIndex].SegmentHistory.Where(x => !x.Time[method].HasValue))
             {
                 var segmentTime = segmentIndex > 0 ? run[segmentIndex - 1].SegmentHistory.FirstOrDefault(x => x.Index == nullSegment.Index) : null;
                 if (segmentTime == null || segmentTime.Time[method] != null)
                 {
                     var prediction = SumOfSegmentsHelper.TrackBranch(run, currentTime, segmentIndex + 1, nullSegment.Index, method);
                     PopulatePrediction(predictions, prediction.Time[method], prediction.Index);
                 }
             }
         }
         if (useCurrentRun)
         {
             var currentRunPrediction = SumOfSegmentsHelper.TrackCurrentRun(run, currentTime, segmentIndex, method);
             PopulatePrediction(predictions, currentRunPrediction.Time[method], currentRunPrediction.Index);
         }
         var personalBestRunPrediction = SumOfSegmentsHelper.TrackPersonalBestRun(run, currentTime, segmentIndex, method);
         PopulatePrediction(predictions, personalBestRunPrediction.Time[method], personalBestRunPrediction.Index);
     }
 }
        public virtual bool SubmitRun(
            IRun run,
            string username, string password, 
            Func<Image> screenShotFunction = null,
            bool attachSplits = false,
            TimingMethod method = TimingMethod.RealTime,
            string gameId = "", string categoryId = "",
            string version = "", string comment = "",
            string video = "",
            params string[] additionalParams)
        {
            try
            {
                if (attachSplits)
                    comment += " " + SplitsIO.Instance.Share(run, screenShotFunction);
                if (gameId == string.Empty)
                    gameId = GetGameIdByName(run.GameName);
                if (categoryId == string.Empty)
                    categoryId = GetCategoryIdByName(gameId, run.CategoryName);
                var json = ASUP.SubmitRun(run, username, password, gameId, categoryId, version, comment, video, additionalParams);
                return json.result == "success";
            }
            catch (Exception e)
            {
                Log.Error(e);

                return false;
            }
        }
 public PackageVersionService(IRunAsync powershell, ISourceService sourceService)
 {
     _powershellAsync = powershell;
     _sourceService = sourceService;
     _powershellAsync.OutputChanged += VersionHandler;
     _powershellAsync.RunFinished += RunFinished;
 }
        public void Save(IRun run, Stream stream)
        {
            var regularTimeFormatter = new RegularTimeFormatter(TimeAccuracy.Hundredths);
            var shortTimeFormatter = new ShortTimeFormatter();

            var writer = new StreamWriter(stream);

            if (!string.IsNullOrEmpty(run.GameName))
            {
                writer.Write(Escape(run.GameName));

                if (!string.IsNullOrEmpty(run.CategoryName))
                    writer.Write(" - ");
            }

            writer.Write(Escape(run.CategoryName));
            writer.Write(',');
            writer.WriteLine(Escape(run.AttemptCount.ToString()));

            foreach (var segment in run)
            {
                writer.Write(Escape(segment.Name));
                writer.Write(',');
                writer.Write(Escape(regularTimeFormatter.Format(segment.PersonalBestSplitTime.RealTime)));
                writer.Write(',');
                writer.WriteLine(Escape(shortTimeFormatter.Format(segment.BestSegmentTime.RealTime)));
            }

            writer.Flush();
        }
 public PackageService(IRun powershell, ISourceService sourceService)
 {
     _powershellAsync = new RunAsync();
     _sourceService = sourceService;
     _powershellAsync.OutputChanged += OutputChanged;
     _powershellAsync.RunFinished += RunFinished;
 }
Example #12
0
 private static void ParseAttemptHistory(Version version, XmlElement parent, IRun run)
 {
     if (version >= new Version(1, 5, 0))
     {
         var attemptHistory = parent["AttemptHistory"];
         foreach (var attemptNode in attemptHistory.GetElementsByTagName("Attempt"))
         {
             var attempt = Attempt.ParseXml(attemptNode as XmlElement);
             run.AttemptHistory.Add(attempt);
         }
     }
     else if (version >= new Version(1, 4, 1))
     {
         var runHistory = parent["RunHistory"];
         foreach (var runHistoryNode in runHistory.GetElementsByTagName("Time"))
         {
             var indexedTime = IndexedTimeHelper.ParseXml(runHistoryNode as XmlElement);
             var attempt = new Attempt(indexedTime.Index, indexedTime.Time, null, null);
             run.AttemptHistory.Add(attempt);
         }
     }
     else
     {
         var runHistory = parent["RunHistory"];
         foreach (var runHistoryNode in runHistory.GetElementsByTagName("Time"))
         {
             var indexedTime = IndexedTimeHelper.ParseXmlOld(runHistoryNode as XmlElement);
             var attempt = new Attempt(indexedTime.Index, indexedTime.Time, null, null);
             run.AttemptHistory.Add(attempt);
         }
     }
 }
 public MethodFailedLoadingRunInvoker(IRun generator, Exception exception, MethodInfo method)
     :base(generator,exception)
 {
     if (method == null)
         throw new ArgumentNullException("method");
     this.method = method;
 }
 public ChocolateyService(IRun powerShell, ISourceService sourceService)
 {
     _powershell = new RunSync();
     _sourceService = sourceService;
     _powershell.OutputChanged += OutPutChangedHandler;
     _powershell.RunFinished += RunFinishedHandler;
 }
 public AvailablePackagesService(IRunAsync powershell, ISourceService sourceService)
 {
     _lines = new List<string>();
     _sourceService = sourceService;
     _powershellAsync = powershell;
     _powershellAsync.OutputChanged += OutputChanged;
     _powershellAsync.RunFinished += RunFinished;
 }
Example #16
0
		/// <summary>
		/// Default constructor - initializes all fields to default values
		/// </summary>
		public MethodRunInvoker(IRun generator, MethodInfo method)
			:base(generator)
		{
			if (method==null)
				throw new ArgumentNullException("method");
			
			this.method = method;
		}
Example #17
0
 public DelegateRunInvoker(IRun generator, Delegate test, Object[] parameters)
     :base(generator)
 {
     if (test == null)
         throw new ArgumentNullException("test");
     this.test = test;
     this.parameters = parameters;
 }
 private static string GetStringValue(string name, IRun r) {
   IItem item;
   r.Results.TryGetValue(name, out item);
   if (item != null)
     return item.ToString();
   r.Parameters.TryGetValue(name, out item);
   return item != null ? item.ToString() : "<none>";
 }
Example #19
0
 /// <summary>
 /// Adds an element with the specified key and value to this RunVertexDictionary.
 /// </summary>
 /// <param name="key">
 /// The IRun key of the element to add.
 /// </param>
 /// <param name="value">
 /// The RunVertex value of the element to add.
 /// </param>
 public void Add(IRun key, RunVertex value)
 {
     if (key == null)
         throw new ArgumentNullException("key");
     if (value == null)
         throw new ArgumentNullException("value");
     this.Dictionary.Add(key, value);
 }
 public PackageService(IRunAsync powershell, ISourceService sourceService, ICommandExecuter commandExecuter)
 {
     _powershellAsync = powershell;
     _sourceService = sourceService;
     _commandExecuter = commandExecuter;
     _powershellAsync.OutputChanged += OnLineChanged;
     _powershellAsync.RunFinished += OnRunFinished;
 }
 public PackagesService(IRunAsync powershell, ISourceService sourceService)
 {
     _lines = new List<string>();
     _sourceService = sourceService;
     _libDirHelper = new ChocolateyLibDirHelper();
     _powershellAsync = powershell;
     _powershellAsync.OutputChanged += OutputChanged;
     _powershellAsync.RunFinished += RunFinished;
 }
 public IEnumerable<IComparisonGenerator> GetAllGenerators(IRun run)
 {
     yield return new BestSegmentsComparisonGenerator(run);
     yield return new BestSplitTimesComparisonGenerator(run);
     yield return new AverageSegmentsComparisonGenerator(run);
     yield return new WorstSegmentsComparisonGenerator(run);
     yield return new PercentileComparisonGenerator(run);
     yield return new NoneComparisonGenerator(run);
 }
 /// <summary>
 /// Creates the execution logic
 /// </summary>
 /// <remarks>
 /// See summary.
 /// </remarks>
 /// <returns>A <see cref="IRun"/> instance that represent the type
 /// test logic.
 /// </returns>
 /// <include file="MbUnit.Framework.doc.xml" path="doc/examples/example[@name='GraphicsBitmap']"/>
 public override IRun GetRun()
 {
     lock(typeof(TestSuiteFixtureAttribute))
     {
         if (testSuiteRun == null)
             testSuiteRun = new TestSuiteRun();
         return testSuiteRun;
     }
 }
 /// <summary>
 /// Creates the execution logic
 /// </summary>
 /// <remarks>
 /// See summary.
 /// </remarks>
 /// <returns>A <see cref="IRun"/> instance that represent the type
 /// test logic.
 /// </returns>
 /// <include file="MbUnit.Framework.doc.xml" path="doc/examples/example[@name='GraphicsBitmap']"/>
 public override IRun GetRun()
 {
     lock (syncRoot)
     {
         if (runs == null)
             runs = new TestFixtureRun();
         return runs;
     }
 }
Example #25
0
 public RecentSplitsFile(string path, IRun run)
     : this(path)
 {
     if (run != null)
     {
         GameName = run.GameName;
         CategoryName = run.GetExtendedCategoryName();
     }
 }
Example #26
0
 public string ImportAsComparison(IRun run, Form form = null)
 {
     string url = null;
     string name = null;
     if (DialogResult.OK == InputBox.Show(form, "Import Comparison from URL", "Name:", "URL:", ref name, ref url))
     {
         var imported = LoadRunFromURL(url, form);
         return run.AddComparisonWithNameInput(imported, name, form);
     }
     return null;
 }
Example #27
0
 public static string AddComparisonWithNameInput(this IRun target, 
     IRun comparisonRun, string name, Form form = null)
 {
     while (!AddComparisonFromRun(target, comparisonRun, name, form))
     {
         var result = InputBox.Show(form, "Enter Comparison Name", "Name:", ref name);
         if (result == DialogResult.Cancel)
             return null;
     }
     return name;
 }
Example #28
0
        public void Save(IRun run, Stream stream)
        {
            var obj = (IRun)run.Clone();
            foreach (var segment in obj)
            {
                segment.SplitTime = default(Time);
            }

            var formatter = new BinaryFormatter();
            formatter.Serialize(stream, obj);
        }
Example #29
0
 private void dataGridView_RowHeaderMouseDoubleClick(object sender, DataGridViewCellMouseEventArgs e)
 {
     if (e.RowIndex >= 0)
     {
         IRun         run  = Content.ElementAt(runToRowMapping.ToList().IndexOf(e.RowIndex));
         IContentView view = MainFormManager.MainForm.ShowContent(run);
         if (view != null)
         {
             view.ReadOnly = this.ReadOnly;
             view.Locked   = this.Locked;
         }
     }
 }
 private void DataGridView_RowHeaderMouseDoubleClick(object sender, DataGridViewCellMouseEventArgs e)
 {
     if (e.RowIndex >= 0)
     {
         IRun         run  = runs[stringConvertibleMatrixView.GetRowIndex(e.RowIndex)];
         IContentView view = MainFormManager.MainForm.ShowContent(run);
         if (view != null)
         {
             view.ReadOnly = this.ReadOnly;
             view.Locked   = this.Locked;
         }
     }
 }
Example #31
0
        public void Save(IRun run, Stream stream)
        {
            var workbook            = new Workbook();
            var splitTimesSheet     = workbook.Sheets.AddSheet("Splits");
            var attemptHistorySheet = workbook.Sheets.AddSheet("Attempt History");
            var segmentHistorySheet = workbook.Sheets.AddSheet("Segment History");

            FillSplitTimesSheet(splitTimesSheet, run);
            FillAttemptHistorySheet(attemptHistorySheet, run);
            FillSegmentHistorySheet(segmentHistorySheet, run);

            workbook.SaveToStream(stream, Codaxy.Xlio.IO.XlsxFileWriterOptions.AutoFit);
        }
Example #32
0
 public static TimeSpan? CalculateSumOfBest(IRun run, int startIndex, int endIndex, IList<TimeSpan?> predictions, bool simpleCalculation = false, bool useCurrentRun = true, TimingMethod method = TimingMethod.RealTime)
 {
     int segmentIndex = 0;
     TimeSpan? currentTime = TimeSpan.Zero;
     predictions[startIndex] = TimeSpan.Zero;
     foreach (var segment in run.Skip(startIndex).Take(endIndex - startIndex + 1))
     {
         currentTime = predictions[segmentIndex];
         PopulatePredictions(run, currentTime, segmentIndex, predictions, simpleCalculation, useCurrentRun, method);
         segmentIndex++;
     }
     return predictions[endIndex + 1];
 }
Example #33
0
 public static string AddComparisonWithNameInput(this IRun target,
                                                 IRun comparisonRun, string name, Form form = null)
 {
     while (!AddComparisonFromRun(target, comparisonRun, name, form))
     {
         var result = InputBox.Show(form, "Enter Comparison Name", "Name:", ref name);
         if (result == DialogResult.Cancel)
         {
             return(null);
         }
     }
     return(name);
 }
        private void UpdateListViewItemImage(ListViewItem listViewItem)
        {
            if (listViewItem == null)
            {
                throw new ArgumentNullException();
            }
            IRun item = listViewItem.Tag as IRun;
            int  i    = listViewItem.ImageIndex;

            itemsListView.SmallImageList.Images[i] = item == null ? HeuristicLab.Common.Resources.VSImageLibrary.Nothing : item.ItemImage;
            listViewItem.ImageIndex = -1;
            listViewItem.ImageIndex = i;
        }
Example #35
0
 public static void ClearTimes(this IRun run)
 {
     run.ClearHistory();
     run.CustomComparisons.Clear();
     run.CustomComparisons.Add(Model.Run.PersonalBestComparisonName);
     foreach (var segment in run)
     {
         segment.Comparisons.Clear();
         segment.BestSegmentTime = default(Time);
     }
     run.AttemptCount   = 0;
     run.Metadata.RunID = null;
 }
Example #36
0
        private IEnumerable <int> GetIndexOfRun(IRun run)
        {
            int i = 0;

            foreach (IRun actualRun in Content)
            {
                if (actualRun == run)
                {
                    yield return(i);
                }
                i++;
            }
        }
Example #37
0
        public void Save(IRun run, Stream stream)
        {
            var workbook = new Workbook();
            var splitTimesSheet = workbook.Sheets.AddSheet("Splits");
            var attemptHistorySheet = workbook.Sheets.AddSheet("Attempt History");
            var segmentHistorySheet = workbook.Sheets.AddSheet("Segment History");

            FillSplitTimesSheet(splitTimesSheet, run);
            FillAttemptHistorySheet(attemptHistorySheet, run);
            FillSegmentHistorySheet(segmentHistorySheet, run);

            workbook.SaveToStream(stream, Codaxy.Xlio.IO.XlsxFileWriterOptions.AutoFit);
        }
Example #38
0
        public void Save(IRun run, Stream stream, OngoingRun ongoingRun)
        {
            var obj = (IRun)run.Clone();

            foreach (var segment in obj)
            {
                segment.SplitTime  = default(Time);
                segment.DeathCount = -1;
            }

            var formatter = new BinaryFormatter();

            formatter.Serialize(stream, obj);
        }
Example #39
0
        private int LastIndexWithTime(IRun run, string user, TimingMethod method)
        {
            var lastIndex      = -1;
            var comparisonName = "[Race] " + user;

            for (int i = 0; i < run.Count; i++)
            {
                if (run[i].Comparisons[comparisonName][method] != null)
                {
                    lastIndex = i;
                }
            }
            return(lastIndex);
        }
Example #40
0
        public IEnumerable <IComparisonGenerator> GetAllGenerators(IRun run)
        {
            yield return(new BestSegmentsComparisonGenerator(run));

            yield return(new BestSplitTimesComparisonGenerator(run));

            yield return(new AverageSegmentsComparisonGenerator(run));

            yield return(new WorstSegmentsComparisonGenerator(run));

            yield return(new PercentileComparisonGenerator(run));

            yield return(new NoneComparisonGenerator(run));
        }
Example #41
0
        public bool SubmitRun(IRun run, string username, string password, Func <Image> screenShotFunction = null, bool attachSplits = false, TimingMethod method = TimingMethod.RealTime, string gameId = "", string categoryId = "", string version = "", string comment = "", string video = "", params string[] additionalParams)
        {
            var accessToken = LoginAnonymous();

            var titleBuilder = new StringBuilder();

            titleBuilder.Append("Splits");

            var gameNameEmpty = String.IsNullOrEmpty(run.GameName);
            var categoryEmpty = String.IsNullOrEmpty(run.CategoryName);

            if (!gameNameEmpty || !categoryEmpty)
            {
                titleBuilder.Append(": ");
                titleBuilder.Append(run.GameName);

                if (!categoryEmpty)
                {
                    if (!gameNameEmpty)
                    {
                        titleBuilder.Append(" - ");
                    }
                    titleBuilder.Append(run.CategoryName);
                }
            }

            var shareData = CreateShare(accessToken, titleBuilder.ToString());
            var shareName = (String)shareData.sharename;

            var fileData = CreateFile(accessToken, shareName, titleBuilder + ".lss");
            var postUrl  = (String)fileData.upload.posturl;

            UploadRun(run, postUrl);

            if (screenShotFunction != null)
            {
                fileData = CreateFile(accessToken, shareName, "Screenshot.png");
                postUrl  = (String)fileData.upload.posturl;

                var image = screenShotFunction();
                UploadImage(image, postUrl);
            }

            var url = (String)shareData.getturl;

            Process.Start(url);
            Clipboard.SetText(url);

            return(true);
        }
            public void UpdateSplits(IRun splits)
            {
                Sections = new List <Section>();
                for (int splitIndex = splits.Count() - 1; splitIndex >= 0; splitIndex--)
                {
                    int sectionIndex = splitIndex;
                    while ((splitIndex > 0) && (splits[splitIndex - 1].Name.StartsWith("-")))
                    {
                        splitIndex--;
                    }

                    Sections.Insert(0, new Section(splitIndex, sectionIndex));
                }
            }
 public SplitsComponent(LiveSplitState state)
 {
     CurrentState                 = state;
     Settings                     = new SplitsSettings(state);
     InternalComponent            = new ComponentRendererComponent();
     ShadowImages                 = new Dictionary <Image, Image>();
     visualSplitCount             = Settings.VisualSplitCount;
     Settings.SplitLayoutChanged += Settings_SplitLayoutChanged;
     ScrollOffset                 = 0;
     RebuildVisualSplits();
     sectionList = new SectionList();
     previousRun = state.Run;
     sectionList.UpdateSplits(state.Run);
 }
Example #44
0
        protected int InternalRun(IRun run = null)
        {
            var program = Environment.ExpandEnvironmentVariables(this._program);
            var args    = Environment.ExpandEnvironmentVariables(this._args);

            var executable = new Executable("cmd", $"/c \"{program} {args}\"", streamOutput: true);

            run?.Start();
            var statusCode = executable.Run(StaticLogger.WriteLine, StaticLogger.WriteErrorLine);

            run?.End();

            return(statusCode);
        }
Example #45
0
        public static DateTime?FindPersonalBestAttemptDate(IRun run)
        {
            var runTime = run.Last().PersonalBestSplitTime;

            var attempt = run.AttemptHistory.FirstOrDefault(x =>
                                                            x.Time.GameTime == runTime.GameTime &&
                                                            x.Time.RealTime == runTime.RealTime);

            if (attempt.Ended.HasValue)
            {
                return(attempt.Ended.Value.Time);
            }
            return(null);
        }
Example #46
0
        public static TimeSpan?CalculateSumOfWorst(IRun run, int startIndex, int endIndex, IList <TimeSpan?> predictions, bool useCurrentRun = true, TimingMethod method = TimingMethod.RealTime)
        {
            int      segmentIndex = 0;
            TimeSpan?currentTime  = TimeSpan.Zero;

            predictions[startIndex] = TimeSpan.Zero;
            foreach (var segment in run.Skip(startIndex).Take(endIndex - startIndex + 1))
            {
                currentTime = predictions[segmentIndex];
                PopulatePredictions(run, currentTime, segmentIndex, predictions, useCurrentRun, method);
                segmentIndex++;
            }
            return(predictions[endIndex + 1]);
        }
Example #47
0
        private static void ImportSegmentHistory(this IRun run, TimingMethod method, int index)
        {
            var prevTime = TimeSpan.Zero;

            foreach (var segment in run)
            {
                //Import the PB splits into the history
                segment.SegmentHistory.Add(index, new Time(method, segment.PersonalBestSplitTime[method] - prevTime));
                if (segment.PersonalBestSplitTime[method].HasValue)
                {
                    prevTime = segment.PersonalBestSplitTime[method].Value;
                }
            }
        }
Example #48
0
        /// <summary>
        /// Close the connection and dispose of resources. On close callback is performed with the lock active.
        /// </summary>
        protected virtual void Close(IRun onClose, bool takeLock)
        {
            // early out if not open
            if (State.Is(ConnectionState.Closed))
            {
                if (onClose != null)
                {
                    onClose.Run();
                }
                return;
            }

            if (takeLock)
            {
                // defer execution
                if (onClose != null)
                {
                    // get the lock
                    if (!(takeLock = _locker.TryTake))
                    {
                        _locker.TryLock(new ActionSet <IRun, bool>(Close, onClose, false));
                        return;
                    }
                }
                else
                {
                    // get lock
                    _locker.Take();
                }
            }

            // set flags
            State = ConnectionState.Closed;

            // close connection
            CloseConnection();

            // run on close
            if (onClose != null)
            {
                onClose.Run();
            }

            // unlock
            if (takeLock)
            {
                _locker.Release();
            }
        }
Example #49
0
        public TestCaseRunInvoker(
            IRun run,
            ITestSuite testSuite,
            ITestCase testCase,
            MethodInfo setUp,
            MethodInfo tearDown
            )
            : base(run)
        {
            this.testSuite = testSuite;
            this.testCase  = testCase;

            this.setUp    = setUp;
            this.tearDown = tearDown;
        }
Example #50
0
        private double?GetValue(IRun run, string columnName)
        {
            if (run == null || string.IsNullOrEmpty(columnName))
            {
                return(null);
            }

            if (Enum.IsDefined(typeof(AxisDimension), columnName))
            {
                AxisDimension axisDimension = (AxisDimension)Enum.Parse(typeof(AxisDimension), columnName);
                return(GetValue(run, axisDimension));
            }
            else
            {
                int   columnIndex = Matrix.ColumnNames.ToList().IndexOf(columnName);
                IItem value       = Content.GetValue(run, columnIndex);
                if (value == null)
                {
                    return(null);
                }

                DoubleValue   doubleValue   = value as DoubleValue;
                IntValue      intValue      = value as IntValue;
                TimeSpanValue timeSpanValue = value as TimeSpanValue;
                double?       ret           = null;
                if (doubleValue != null)
                {
                    if (!double.IsNaN(doubleValue.Value) && !double.IsInfinity(doubleValue.Value))
                    {
                        ret = doubleValue.Value;
                    }
                }
                else if (intValue != null)
                {
                    ret = intValue.Value;
                }
                else if (timeSpanValue != null)
                {
                    ret = timeSpanValue.Value.TotalSeconds;
                }
                else
                {
                    ret = GetCategoricalValue(columnIndex, value.ToString());
                }

                return(ret);
            }
        }
Example #51
0
        public static int GetMinSegmentHistoryIndex(this IRun run)
        {
            var minIndex = 1;

            foreach (var segment in run)
            {
                foreach (var history in segment.SegmentHistory)
                {
                    if (history.Index < minIndex)
                    {
                        minIndex = history.Index;
                    }
                }
            }
            return(minIndex);
        }
Example #52
0
        public ITableCell CreateTableMergeCell(IRun run, TableCellPropertiesModel cellModel)
        {
            if (run == null)
            {
                throw new ArgumentNullException("run must not be null");
            }
            if (cellModel == null)
            {
                throw new ArgumentNullException("cellModel must not be null");
            }

            return(CreateTableMergeCell(new List <IRun>()
            {
                run
            }, cellModel));
        }
Example #53
0
 private void itemsListView_DoubleClick(object sender, EventArgs e)
 {
     if (itemsListView.SelectedItems.Count == 1)
     {
         IRun item = itemsListView.SelectedItems[0].Tag as IRun;
         if (item != null)
         {
             IContentView view = MainFormManager.MainForm.ShowContent(item);
             if (view != null)
             {
                 view.ReadOnly = ReadOnly;
                 view.Locked   = Locked;
             }
         }
     }
 }
Example #54
0
        public static string GetExtendedFileName(this IRun run, bool useExtendedCategoryName = true)
        {
            var extendedName = run.GetExtendedName(useExtendedCategoryName);

            var stringBuilder = new StringBuilder();

            foreach (var c in extendedName)
            {
                if (c != '\\' && c != '/' && c != ':' && c != '*' && c != '?' && c != '"' && c != '<' && c != '>' && c != '|')
                {
                    stringBuilder.Append(c);
                }
            }

            return(stringBuilder.ToString());
        }
Example #55
0
 private static void RemoveDuplicates(IRun run, TimingMethod method)
 {
     for (var index = 0; index < run.Count; index++)
     {
         var history = run[index].SegmentHistory.Select(x => x.Value[method]).Where(x => x != null).ToList();
         for (var runIndex = run[index].SegmentHistory.GetMinIndex(); runIndex <= 0; runIndex++)
         {
             //Remove elements in the imported Segment History if they're duplicates of the real Segment History
             Time element;
             if (run[index].SegmentHistory.TryGetValue(runIndex, out element) && history.Count(x => x.Equals(element[method])) > 1)
             {
                 run[index].SegmentHistory.Remove(runIndex);
             }
         }
     }
 }
Example #56
0
        public static void Save(this IRun run, string path, string fileName = "")
        {
            if (fileName.Equals(""))
            {
                fileName = $"run_{run.RunInfo.Guid.ToString().ToLower()}.json";
            }
            run.RunInfo.FileName = fileName;
            Paths.Create(path);
            var fullRunPath = Path.Combine(path, fileName);

            using (var file = File.CreateText(fullRunPath))
            {
                var serializer = new JsonSerializer();
                serializer.Serialize(file, run);
            }
        }
        private string BuildTooltip(IRun run)
        {
            string tooltip;

            tooltip = run.Name + System.Environment.NewLine;

            string xString    = GetTooltipValue(run, (string)xAxisComboBox.SelectedItem);
            string yString    = GetTooltipValue(run, (string)yAxisComboBox.SelectedItem);
            string sizeString = GetTooltipValue(run, (string)sizeComboBox.SelectedItem);

            tooltip += xAxisComboBox.SelectedItem + " : " + xString + Environment.NewLine;
            tooltip += yAxisComboBox.SelectedItem + " : " + yString + Environment.NewLine;
            tooltip += sizeComboBox.SelectedItem + " : " + sizeString + Environment.NewLine;

            return(tooltip);
        }
        public string ImportAsComparison(IRun run, Form form = null)
        {
            var dialog = new BrowseSplitsIODialog(true);
            var result = dialog.ShowDialog(form);
            var name   = dialog.RunName;

            if (result == DialogResult.OK)
            {
                result = InputBox.Show(form, "Enter Comparison Name", "Name:", ref name);
            }
            if (result == DialogResult.OK)
            {
                return(run.AddComparisonWithNameInput(dialog.Run, name, form));
            }
            return(null);
        }
Example #59
0
 private void UpdateRun(IRun run)
 {
     foreach (ListViewItem listViewItem in GetListViewItemsForItem(run))
     {
         if (run.Visible)
         {
             listViewItem.Font      = new Font(listViewItem.Font, FontStyle.Regular);
             listViewItem.ForeColor = run.Color;
         }
         else
         {
             listViewItem.Font      = new Font(listViewItem.Font, FontStyle.Italic);
             listViewItem.ForeColor = Color.LightGray;
         }
     }
 }
Example #60
0
        public ITableCell CreateTableCell(IRun cellContent, TableCellPropertiesModel cellModel)
        {
            if (cellContent == null)
            {
                throw new ArgumentNullException("cellContent must not be null");
            }
            if (cellModel == null)
            {
                throw new ArgumentNullException("cellModel must not be null");
            }

            return(CreateTableCell(new List <IRun>()
            {
                cellContent
            }, cellModel));
        }