Exemple #1
0
 public IEnumerable <FrameRollGenerator> GenerateAllFrames(FrameResult frameResult)
 {
     for (int i = 0; i < Consts.FrameCount; i++)
     {
         yield return(GenerateFrame(frameResult, i == Consts.FrameCount - 1));
     }
 }
Exemple #2
0
        private void LoadLog(string path, LoadProgressUpdate progressCallback)
        {
            // Caller must check that path is a valid file location.
            frames.Clear();

            try
            {
                progressCallback(0d);

                using (FileStream stream = new FileStream(path, FileMode.Open, FileAccess.Read))
                {
                    DataStream dataStream = new DataStream(stream);

                    while (stream.Position < stream.Length)
                    {
                        FrameResult result = FrameResult.Deserialize(dataStream);
                        frames.Add(result);

                        progressCallback((double)stream.Position / (double)stream.Length);
                    }
                }

                progressCallback(1d);
            }
            catch (Exception e)
            {
                MessageBox.Show(string.Format("Failed to load file {0} -> {1}", path, e.Message), "Profiler log viewer", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
Exemple #3
0
 private void SaveFrameResult()
 {
     if (Frame <= lastFrame)
     {
         _frames[Frame - 1] = new FrameResult(_currentFrameScores.ToArray());
     }
 }
 private void screen_OnMouseLeftUp(Point position)
 {
     if (this.screen.PeekUndoneWork().Kind == UndoneWorkKind.Frame)
     {
         this.Draging = false;
         if ((this.OKButtonEnabled && (this.OKButtonState == FrameButtonState.Pressed)) && StaticMethods.PointInRectangle(position, this.okbuttonRectangle))
         {
             this.screen.PlayNormalSound(this.OKSoundFile);
             this.OKButtonState = FrameButtonState.Selected;
             this.Result        = FrameResult.OK;
             if (this.frameContent.OKFunction != null)
             {
                 this.frameContent.OKFunction();
                 this.frameContent.OKFunction = null;
             }
             this.IsShowing = false;
         }
         if ((this.CancelButtonEnabled && (this.CancelButtonState == FrameButtonState.Pressed)) && StaticMethods.PointInRectangle(position, this.cancelbuttonRectangle))
         {
             this.screen.PlayNormalSound(this.CancelSoundFile);
             this.CancelButtonState = FrameButtonState.Selected;
             this.Result            = FrameResult.Cancel;
             this.IsShowing         = false;
         }
     }
 }
Exemple #5
0
 public void ShouldLimitNumberOfRollsPerGame(FrameResult frameResult)
 {
     foreach (int pinCount in _gameRollGenerator.GenerateAllRolls(frameResult))
     {
         _sut.Roll(pinCount);
     }
     Assert.Throws <BowlingException>(() => _sut.Roll(0));
 }
Exemple #6
0
        private void SelectFrame(int index)
        {
            selectedFrame   = frames.Count > index ? frames[index] : null;
            selectedIndex   = index;
            selectedSection = null;

            UpdateGUI();
        }
Exemple #7
0
 private void closeToolStripMenuItem_Click(object sender, EventArgs e)
 {
     frames.Clear();
     selectedIndex   = 0;
     selectedFrame   = null;
     selectedSection = null;
     UpdateGUI();
 }
Exemple #8
0
 private void screen_OnMouseRightUp(Point position)
 {
     if ((Session.MainGame.mainGameScreen.PeekUndoneWork().Kind == UndoneWorkKind.Frame) && (this.CancelButtonEnabled && this.frameContent.CanClose))
     {
         Session.MainGame.mainGameScreen.PlayNormalSound(this.CancelSoundFile);
         this.Result    = FrameResult.Cancel;
         this.IsShowing = false;
     }
 }
Exemple #9
0
        private List <int> RollGeneratedFrame(FrameResult frameResult)
        {
            var frameRolls = _gameRollGenerator.GenerateFrame(frameResult).GetRolls().ToList();

            foreach (int pinCount in frameRolls)
            {
                _sut.Roll(pinCount);
            }
            return(frameRolls);
        }
Exemple #10
0
        internal void Tick(TimeSpan elapsed)
        {
            CoroutineThread oldCurrent = t_currentThread;

            t_currentThread = this;

            _elapsedTime = elapsed;

            try
            {
                bool endLoop = false;
                while (!endLoop)
                {
                    IEnumerable next        = null;
                    FrameResult frameResult = RunFrame(_stack.Peek(), ref next);

                    switch (frameResult)
                    {
                    case FrameResult.Yield:
                        endLoop = true;
                        break;

                    case FrameResult.Pop:
                        IEnumerator oldTop = _stack.Pop();

                        (oldTop as IDisposable)?.Dispose();

                        if (_stack.Count == 0)
                        {
                            Dispose();
                            endLoop = true;
                        }
                        break;

                    case FrameResult.Push:
                        _stack.Push(next.GetEnumerator());
                        break;

                    default:
                        throw new ArgumentOutOfRangeException();
                    }
                }
            }
            catch (Exception ex)
            {
                Dispose(ex);
                throw;
            }
            finally
            {
                Debug.Assert(!_hasResult);
                t_currentThread = oldCurrent;
            }
        }
Exemple #11
0
 internal void DoOK()
 {
     if (this.OKButtonEnabled)
     {
         Session.MainGame.mainGameScreen.PlayNormalSound(this.OKSoundFile);
         this.Result = FrameResult.OK;
         if (this.frameContent.OKFunction != null)
         {
             this.frameContent.OKFunction();
             this.frameContent.OKFunction = null;
         }
         this.IsShowing = false;
     }
 }
Exemple #12
0
        public FrameRollGenerator GenerateFrame(FrameResult frameResult, bool isLast = false)
        {
            switch (frameResult)
            {
            case FrameResult.Normal:
                return(new NormalFrameRollGenerator(isLast, _random));

            case FrameResult.Spare:
                return(new SpareFrameRollGenerator(isLast, _random));

            case FrameResult.Strike:
                return(new StrikeFrameRollGenerator(isLast, _random));
            }
            throw new ArgumentOutOfRangeException("frameResult");
        }
 public void SetFrameContent(FrameContent frameContent, Point viewportSize)
 {
     this.Result                        = FrameResult.Cancel;
     this.frameContent                  = frameContent;
     this.frameContent.Function         = this.Function;
     this.TitleText.Text                = frameContent.GetCurrentTitle();
     frameContent.FramePosition         = StaticMethods.GetRectangleFitViewport(frameContent.DefaultFrameWidth, frameContent.DefaultFrameHeight, viewportSize);
     this.OKButtonPosition              = frameContent.OKButtonPosition;
     this.CancelButtonPosition          = frameContent.CancelButtonPosition;
     this.MapViewSelectorButtonPosition = frameContent.MapViewSelectorButtonPosition;
     this.SetPosition(frameContent.FramePosition);
     frameContent.ReCalculate();
     frameContent.InitializeMapViewSelectorButton();
     frameContent.OnItemClick += new FrameContent.ItemClick(this.frameContent_OnItemClick);
 }
        private void SetData(OSS oSS)
        {
            //проголосовано * из *
            spanAnswersCnt.TextColor = colorFromMobileSettings;
            var cntVotes = "за " + oSS.Questions.Where(_ => !string.IsNullOrWhiteSpace(_.Answer)).Count().ToString() + " / " + oSS.Questions.Count.ToString() + ".";

            spanAnswersCnt.Text = cntVotes;

            //ответы по штукам
            lCntYes.Text      = oSS.Questions.Where(_ => _.Answer == "0").Count().ToString();
            cntYes.Foreground = colorFromMobileSettings;
            lCntNo.Text       = oSS.Questions.Where(_ => _.Answer == "1").Count().ToString();
            cntNo.Foreground  = colorFromMobileSettings;

            lCntAbstained.Text      = oSS.Questions.Where(_ => _.Answer == "2").Count().ToString();
            cntAbstained.Foreground = colorFromMobileSettings;


            delimColored.BackgroundColor = colorFromMobileSettings;

            TotalArea.Text = " " + oSS.VoitingArea.ToString() + $" {AppResources.OSSInfoMeasurmentArea} = 100%";
            decimal round = 0;

            try
            {
                round = Math.Round(oSS.Accounts[0].Area / oSS.VoitingArea * 100, 3);
            }
            catch (Exception e)
            {
                Console.WriteLine(e);
            }
            Area.Text   = " " + oSS.Accounts[0].Area.ToString() + $" {AppResources.OSSInfoMeasurmentArea} = " + round + "%";
            dayEnd.Text = oSS.DateEnd.Split(' ')[0];
            var r1Date = oSS.ResultsReleaseDate.Split(' ')[0];
            var r1Time = oSS.ResultsReleaseDate.Split(' ')[1];

            dayEndPlus.Text = " " + AppResources.OSSText.Replace("{r1Date}", r1Date).Replace("{r1Time}", r1Time);
            Color hexColor = (Color)Application.Current.Resources["MainColor"];

            PancakeBot.SetAppThemeColor(PancakeView.BorderColorProperty, hexColor, Color.Transparent);
            FrameResult.SetAppThemeColor(Frame.BorderColorProperty, hexColor, Color.White);
            //IconViewTech.SetAppThemeColor(IconView.ForegroundProperty, hexColor, Color.White);
            //LabelTech.SetAppThemeColor(Label.TextColorProperty, hexColor, Color.White);
        }
Exemple #15
0
        private void screen_OnMouseLeftUp(Point position)
        {
            if (Session.MainGame.mainGameScreen.PeekUndoneWork().Kind == UndoneWorkKind.Frame)
            {
                this.Draging = false;
                if ((this.OKButtonEnabled && (this.OKButtonState == FrameButtonState.Pressed)) && StaticMethods.PointInRectangle(position, this.okbuttonRectangle))
                {
                    Session.MainGame.mainGameScreen.PlayNormalSound(this.OKSoundFile);
                    this.OKButtonState = FrameButtonState.Selected;
                    this.Result        = FrameResult.OK;
                    if (this.frameContent.OKFunction != null)
                    {
                        this.frameContent.OKFunction();
                        this.frameContent.OKFunction = null;
                    }
                    this.IsShowing = false;
                }
                if ((this.CancelButtonEnabled && (this.CancelButtonState == FrameButtonState.Pressed)) && StaticMethods.PointInRectangle(position, this.cancelbuttonRectangle))
                {
                    Session.MainGame.mainGameScreen.PlayNormalSound(this.CancelSoundFile);
                    this.CancelButtonState = FrameButtonState.Selected;
                    this.Result            = FrameResult.Cancel;
                    this.IsShowing         = false;
                }
                //if ((this.frameContent.MapViewSelectorButtonEnabled && StaticMethods.PointInRectangle(position, this.mapviewselectorButtonRectangle)) && (this.frameContent.MapViewSelectorFunction != null))
                //{
                //    this.frameContent.MapViewSelectorFunction();
                //}

                /* if ((this.SelectAllButtonEnabled && (this.SelectAllButtonState == FrameButtonState.Pressed)) && StaticMethods.PointInRectangle(position, this.selectallbuttonRectangle))
                 * {
                 *   Session.MainGame.mainGameScreen.PlayNormalSound(this.SelectAllSoundFile);
                 *   this.SelectAllButtonState = FrameButtonState.Selected;
                 *   this.Result = FrameResult.SelectAll;
                 *   if (this.frameContent.SelectAllFunction != null)
                 *   {
                 *       this.frameContent.SelectAllFunction();
                 *       this.frameContent.SelectAllFunction = null;
                 *   }
                 *   this.IsShowing = false;
                 * }*/
            }
        }
 internal void DoCancel()
 {
     this.screen.PlayNormalSound(this.CancelSoundFile);
     this.Result = FrameResult.Cancel;
     this.IsShowing = false;
 }
Exemple #17
0
 internal void DoCancel()
 {
     Session.MainGame.mainGameScreen.PlayNormalSound(this.CancelSoundFile);
     this.Result    = FrameResult.Cancel;
     this.IsShowing = false;
 }
        private void HandleFrameResult(FrameResult result)
        {
            switch (result)
            {
                case FrameResult.OK:
                    this.screenManager.HandleFrameFunction(this.Plugins.GameFramePlugin.Function);

                    
                    break;
                
            }
        }
Exemple #19
0
        public OSSTotalVotingResult(OSS oSS)
        {
            InitializeComponent();
            Analytics.TrackEvent("Общие результаты голосования ОСС");
            NavigationPage.SetHasNavigationBar(this, false);

            var profile = new TapGestureRecognizer();

            profile.Tapped += async(s, e) =>
            {
                if (Navigation.NavigationStack.FirstOrDefault(x => x is ProfilePage) == null)
                {
                    await Navigation.PushAsync(new ProfilePage());
                }
            };
            IconViewProfile.GestureRecognizers.Add(profile);


            var techSend = new TapGestureRecognizer();

            techSend.Tapped += async(s, e) => { await Navigation.PushAsync(new AppPage()); };
            LabelTech.GestureRecognizers.Add(techSend);
            var call = new TapGestureRecognizer();

            call.Tapped += async(s, e) =>
            {
                if (Settings.Person.Phone != null)
                {
                    IPhoneCallTask phoneDialer;
                    phoneDialer = CrossMessaging.Current.PhoneDialer;
                    if (phoneDialer.CanMakePhoneCall && !string.IsNullOrWhiteSpace(Settings.Person.companyPhone))
                    {
                        phoneDialer.MakePhoneCall(System.Text.RegularExpressions.Regex.Replace(Settings.Person.companyPhone, "[^+0-9]", ""));
                    }
                }
            };



            switch (Device.RuntimePlatform)
            {
            case Device.iOS:
                int statusBarHeight = DependencyService.Get <IStatusBar>().GetHeight();
                Pancake.Padding = new Thickness(0, statusBarHeight, 0, 0);

                //BackgroundColor = Color.White;
                break;

            default:
                break;
            }

            var dH = Xamarin.Essentials.DeviceDisplay.MainDisplayInfo.Height;

            if (dH < 1400)
            {
                titleLabel.FontSize = 18;
            }

            var backClick = new TapGestureRecognizer();

            backClick.Tapped += async(s, e) => { ClosePage(); };
            BackStackLayout.GestureRecognizers.Add(backClick);

            SetDecorations();

            SetData(oSS);
            Color hexColor = (Color)Application.Current.Resources["MainColor"];

            PancakeBot.SetAppThemeColor(PancakeView.BorderColorProperty, hexColor, Color.Transparent);
            FrameResult.SetAppThemeColor(Frame.BorderColorProperty, hexColor, Color.White);
            //LabelTech.SetAppThemeColor(Label.TextColorProperty, hexColor, Color.White);
            //IconViewTech.SetAppThemeColor(IconView.ForegroundProperty, hexColor, Color.White);

            BindingContext = this;
        }
 internal void DoCancel()
 {
     this.screen.PlayNormalSound(this.CancelSoundFile);
     this.Result    = FrameResult.Cancel;
     this.IsShowing = false;
 }
Exemple #21
0
        public override ReturnCode Execute(
            Interpreter interpreter,
            IClientData clientData,
            ArgumentList arguments,
            ref Result result
            )
        {
            ReturnCode code = ReturnCode.Ok;

            if (interpreter != null)
            {
                if (arguments != null)
                {
                    if (arguments.Count >= 3)
                    {
                        ICallFrame otherFrame = null;

                        FrameResult frameResult = interpreter.GetCallFrame(
                            arguments[1], ref otherFrame, ref result);

                        if (frameResult != FrameResult.Invalid)
                        {
                            int count = arguments.Count - ((int)frameResult + 1);

                            if ((count & 1) == 0)
                            {
                                lock (interpreter.SyncRoot) /* TRANSACTIONAL */
                                {
                                    ICallFrame localFrame = null;

                                    code = interpreter.GetVariableFrameViaResolvers(
                                        LookupFlags.Default, ref localFrame, ref result);

                                    if (code == ReturnCode.Ok)
                                    {
                                        int argumentIndex = ((int)frameResult + 1); // skip "upvar ?level?"

                                        for (; count > 0; count -= 2, argumentIndex += 2)
                                        {
                                            string otherName = arguments[argumentIndex];
                                            string localName = arguments[argumentIndex + 1];

                                            code = ScriptOps.LinkVariable(
                                                interpreter, localFrame, localName,
                                                otherFrame, otherName, ref result);

                                            if (code != ReturnCode.Ok)
                                            {
                                                break;
                                            }
                                        }
                                    }
                                }
                            }
                            else
                            {
                                result = "wrong # args: should be \"upvar ?level? otherVar localVar ?otherVar localVar ...?\"";
                                code   = ReturnCode.Error;
                            }
                        }
                        else
                        {
                            code = ReturnCode.Error;
                        }
                    }
                    else
                    {
                        result = "wrong # args: should be \"upvar ?level? otherVar localVar ?otherVar localVar ...?\"";
                        code   = ReturnCode.Error;
                    }
                }
                else
                {
                    result = "invalid argument list";
                    code   = ReturnCode.Error;
                }
            }
            else
            {
                result = "invalid interpreter";
                code   = ReturnCode.Error;
            }

            return(code);
        }
Exemple #22
0
 public IEnumerable <int> GenerateAllRolls(FrameResult frameResult)
 {
     return(GenerateAllFrames(frameResult).SelectMany(frame => frame.GetRolls()));
 }
Exemple #23
0
        ///////////////////////////////////////////////////////////////////////

        #region IExecute Members
        public override ReturnCode Execute(
            Interpreter interpreter,
            IClientData clientData,
            ArgumentList arguments,
            ref Result result
            )
        {
            if (interpreter == null)
            {
                result = "invalid interpreter";
                return(ReturnCode.Error);
            }

            if (arguments == null)
            {
                result = "invalid argument list";
                return(ReturnCode.Error);
            }

            if (arguments.Count < 2)
            {
                result = "wrong # args: should be \"uplevel ?level? arg ?arg ...?\"";
                return(ReturnCode.Error);
            }

            ReturnCode code;
            int        currentLevel = 0;

            code = interpreter.GetInfoLevel(
                CallFrameOps.InfoLevelSubCommand, ref currentLevel,
                ref result);

            if (code != ReturnCode.Ok)
            {
                return(code);
            }

            bool       mark         = false;
            bool       absolute     = false;
            bool       super        = false;
            int        level        = 0;
            ICallFrame currentFrame = null;
            ICallFrame otherFrame   = null;

            FrameResult frameResult = interpreter.GetCallFrame(
                arguments[1], ref mark, ref absolute, ref super,
                ref level, ref currentFrame, ref otherFrame,
                ref result);

            if (frameResult == FrameResult.Invalid)
            {
                return(ReturnCode.Error);
            }

            int argumentIndex = ((int)frameResult + 1);

            //
            // BUGFIX: The argument count needs to be checked again here.
            //
            if (argumentIndex >= arguments.Count)
            {
                result = "wrong # args: should be \"uplevel ?level? arg ?arg ...?\"";
                return(ReturnCode.Error);
            }

            if (mark)
            {
                code = CallFrameOps.MarkMatching(
                    interpreter.CallStack, interpreter.CurrentFrame,
                    absolute, level, CallFrameFlags.Variables,
                    CallFrameFlags.Invisible | CallFrameFlags.NoVariables,
                    CallFrameFlags.Invisible, false, false, true,
                    ref result);
            }

            if (code == ReturnCode.Ok)
            {
                try
                {
                    string name = StringList.MakeList("uplevel", arguments[1]);

                    ICallFrame newFrame = interpreter.NewUplevelCallFrame(
                        name, currentLevel, CallFrameFlags.None, mark,
                        currentFrame, otherFrame);

                    ICallFrame savedFrame = null;

                    interpreter.PushUplevelCallFrame(
                        currentFrame, newFrame, true, ref savedFrame);

                    if ((argumentIndex + 1) >= arguments.Count)
                    {
                        code = interpreter.EvaluateScript(
                            arguments[argumentIndex], ref result);
                    }
                    else
                    {
                        code = interpreter.EvaluateScript(
                            arguments, argumentIndex, ref result);
                    }

                    if (code == ReturnCode.Error)
                    {
                        Engine.AddErrorInformation(interpreter, result,
                                                   String.Format("{0}    (\"uplevel\" body line {1})",
                                                                 Environment.NewLine, Interpreter.GetErrorLine(interpreter)));
                    }

                    //
                    // NOTE: Pop the original call frame that we pushed above and
                    //       any intervening scope call frames that may be leftover
                    //       (i.e. they were not explicitly closed).
                    //
                    /* IGNORED */
                    interpreter.PopUplevelCallFrame(
                        currentFrame, newFrame, ref savedFrame);
                }
                finally
                {
                    if (mark)
                    {
                        //
                        // NOTE: We should not get an error at this point from
                        //       unmarking the call frames; however, if we do get
                        //       one, we need to complain loudly about it because
                        //       that means the interpreter state has probably been
                        //       corrupted somehow.
                        //
                        ReturnCode markCode;
                        Result     markResult = null;

                        markCode = CallFrameOps.MarkMatching(
                            interpreter.CallStack, interpreter.CurrentFrame,
                            absolute, level, CallFrameFlags.Variables,
                            CallFrameFlags.NoVariables, CallFrameFlags.Invisible,
                            false, false, false, ref markResult);

                        if (markCode != ReturnCode.Ok)
                        {
                            DebugOps.Complain(interpreter, markCode, markResult);
                        }
                    }
                }
            }

            return(code);
        }
 public void SetFrameContent(FrameContent frameContent, Point viewportSize)
 {
     this.Result = FrameResult.Cancel;
     this.frameContent = frameContent;
     this.frameContent.Function = this.Function;
     this.TitleText.Text = frameContent.GetCurrentTitle();
     frameContent.FramePosition = StaticMethods.GetRectangleFitViewport(frameContent.DefaultFrameWidth, frameContent.DefaultFrameHeight, viewportSize);
     this.OKButtonPosition = frameContent.OKButtonPosition;
     this.CancelButtonPosition = frameContent.CancelButtonPosition;
     this.MapViewSelectorButtonPosition = frameContent.MapViewSelectorButtonPosition;
     this.SetPosition(frameContent.FramePosition);
     frameContent.ReCalculate();
     frameContent.InitializeMapViewSelectorButton();
     frameContent.OnItemClick += new FrameContent.ItemClick(this.frameContent_OnItemClick);
 }
 private void screen_OnMouseRightUp(Point position)
 {
     if ((this.screen.PeekUndoneWork().Kind == UndoneWorkKind.Frame) && (this.CancelButtonEnabled && this.frameContent.CanClose))
     {
         this.screen.PlayNormalSound(this.CancelSoundFile);
         this.Result = FrameResult.Cancel;
         this.IsShowing = false;
     }
 }
 private void screen_OnMouseLeftUp(Point position)
 {
     if (this.screen.PeekUndoneWork().Kind == UndoneWorkKind.Frame)
     {
         this.Draging = false;
         if ((this.OKButtonEnabled && (this.OKButtonState == FrameButtonState.Pressed)) && StaticMethods.PointInRectangle(position, this.okbuttonRectangle))
         {
             this.screen.PlayNormalSound(this.OKSoundFile);
             this.OKButtonState = FrameButtonState.Selected;
             this.Result = FrameResult.OK;
             if (this.frameContent.OKFunction != null)
             {
                 this.frameContent.OKFunction();
                 this.frameContent.OKFunction = null;
             }
             this.IsShowing = false;
         }
         if ((this.CancelButtonEnabled && (this.CancelButtonState == FrameButtonState.Pressed)) && StaticMethods.PointInRectangle(position, this.cancelbuttonRectangle))
         {
             this.screen.PlayNormalSound(this.CancelSoundFile);
             this.CancelButtonState = FrameButtonState.Selected;
             this.Result = FrameResult.Cancel;
             this.IsShowing = false;
         }
         if ((this.frameContent.MapViewSelectorButtonEnabled && StaticMethods.PointInRectangle(position, this.mapviewselectorButtonRectangle)) && (this.frameContent.MapViewSelectorFunction != null))
         {
             this.frameContent.MapViewSelectorFunction();
         }
     }
 }
 internal void DoOK()
 {
     if (this.OKButtonEnabled)
     {
         this.screen.PlayNormalSound(this.OKSoundFile);
         this.Result = FrameResult.OK;
         if (this.frameContent.OKFunction != null)
         {
             this.frameContent.OKFunction();
             this.frameContent.OKFunction = null;
         }
         this.IsShowing = false;
     }
 }