Inheritance: MonoBehaviour
Example #1
0
 public void Frame_total_should_sum_rolls()
 {
     var frame = new Frame();
     frame.Roll('1');
     frame.Roll('1');
     Assert.AreEqual(2, frame.Score);
 }
Example #2
0
 internal ErrorResponse(Frame frame) 
     : base(frame)
 {
     int errorCode = Reader.ReadInt32();
     string message = Reader.ReadString();
     Output = OutputError.CreateOutputError(errorCode, message, Reader);
 }
Example #3
0
        internal ResultResponse(Frame frame) : base(frame)
        {
            //Handle result flags
            if ((frame.Header.Flags & FrameHeader.HeaderFlag.Warning) != 0)
            {
                Warnings = Reader.ReadStringList();
            }
            if ((frame.Header.Flags &FrameHeader.HeaderFlag.CustomPayload) != 0)
            {
                CustomPayload = Reader.ReadBytesMap();
            }

            Kind = (ResultResponseKind) Reader.ReadInt32();
            switch (Kind)
            {
                case ResultResponseKind.Void:
                    Output = new OutputVoid(TraceId);
                    break;
                case ResultResponseKind.Rows:
                    Output = new OutputRows(frame.Header.Version, Reader, TraceId);
                    break;
                case ResultResponseKind.SetKeyspace:
                    Output = new OutputSetKeyspace(Reader.ReadString());
                    break;
                case ResultResponseKind.Prepared:
                    Output = new OutputPrepared(frame.Header.Version, Reader);
                    break;
                case ResultResponseKind.SchemaChange:
                    Output = new OutputSchemaChange(Reader, TraceId);
                    break;
                default:
                    throw new DriverInternalError("Unknown ResultResponseKind Type");
            }
        }
Example #4
0
 public void spare_should_close_frame()
 {
     var frame = new Frame();
     frame.Roll('1');
     frame.Roll('/');
     Assert.AreEqual(false, frame.IsOpen);
 }
Example #5
0
    public static void AddPage(TabControl tabControl, string tapName, Page page, bool maxSize = true)
    {
        if (maxSize)
        {
            page.Width = double.NaN;
            page.Height = double.NaN;
            page.HorizontalAlignment = System.Windows.HorizontalAlignment.Stretch;
            page.VerticalAlignment = System.Windows.VerticalAlignment.Stretch;
        }

        Frame frame = new Frame();
        if (maxSize)
        {
            frame.Width = double.NaN;
            frame.Height = double.NaN;
            frame.HorizontalAlignment = System.Windows.HorizontalAlignment.Stretch;
            frame.VerticalAlignment = System.Windows.VerticalAlignment.Stretch;
        }

        frame.Content = page;
        TabItem tabItem = new TabItem();
        tabItem.Header = tapName;
        tabItem.Content = frame;
        tabControl.Items.Add(tabItem);
    }
Example #6
0
 public FramedStream( Stream baseStream )
 {
     myStream = baseStream;
     myBaseFrame = new Frame( 0, myStream.Length );
     myFrameStack = new Stack<Frame>();
     Position = 0;
 }
Example #7
0
        public void Init(Frame frame)
        {
            mFrame = frame;

            mFrame.Changed += new Action<Frame, EventArgs>(mWindow_Changed);

            foreach (var screen in Screen.AllScreens) {
                monitorPulldown.Items.Add(screen);
                if (screen.DeviceName.Equals(frame.Monitor.DeviceName))
                    monitorPulldown.SelectedItem = screen;
            }

            if (frame.Output != null) {
                Control panel = frame.Output.ControlPanel;
                panel.Dock = DockStyle.Fill;

                TabPage tab = new TabPage();
                tab.Name = "outputTab";
                tab.Text = "Output";
                tab.Controls.Add(panel);

                mainTab.Controls.Add(tab);
            }

            mWindow_Changed(frame, null);
        }
Example #8
0
        protected internal Sprite(GridPointMatrix matrix, Frame frame)
        {
            id = Guid.NewGuid().ToString();
            parentGrid = matrix;
            animator = new Animator(this);
            movement = new Movement(this);
            pauseAnimation = false;
            pauseMovement = false;
            horizAlign = HorizontalAlignment.Center;
            vertAlign = VerticalAlignment.Bottom;
            nudgeX = 0;
            nudgeY = 0;
            CurrentFrame = frame;

            if ((Sprites.SizeNewSpritesToParentGrid) && (parentGrid != null))
                renderSize = new Size(parentGrid.GridPointWidth, parentGrid.GridPointHeight);
            else
                renderSize = CurrentFrame.Tilesheet.TileSize;

            zOrder = 1;

            if (parentGrid != null)
                parentGrid.RefreshQueue.AddPixelRangeToRefreshQueue(this.DrawLocation, true);

            Sprites._spriteList.Add(this);
            CreateChildSprites();
        }
Example #9
0
    public override void OnFrame(Controller controller)
    {
        // Get the most recent frame and report some basic information
        Frame frame = controller.Frame();

        if (!frame.Hands.IsEmpty)
        {
            if ((DateTime.Now - checkedTime) > new TimeSpan(0, 0, 0, 0, 500))
            {
                // 500ミリ秒ごとに前回位置との差分を求める
                // 移動量がしきい値を超えていたらイベントとして認識するする
                if (this.checkedFrame != null)
                {
                    Vector diff = frame.Hands[0].Translation(this.checkedFrame);
                    //SafeWriteLine("X移動量: " + diff.x);
                    if (diff.x > 150)
                    {
                        SafeWriteLine("右フリックしました! :" + diff.x);
                    }
                    if (diff.x < -150)
                    {
                        SafeWriteLine("左フリックしました! :" + diff.x);
                    }
                }
                this.checkedTime = DateTime.Now;
                this.checkedFrame = frame;
            }
        }
    }
Example #10
0
    // Update is called once per frame
    void Update()
    {
        frame = lp.CurrentFrame;
        if (frame.Hands.Count > 0) {
            if (frame.Hands.Leftmost.IsLeft) {
                righty = frame.Hands.Leftmost;
                rfingers = right.fingers;
            }
        }

        if (right.isActiveAndEnabled) {
            if (Vector3.Distance (right.GetPalmPosition (), rfingers [0].GetTipPosition ()) > trigger &&
                Vector3.Distance (right.GetPalmPosition (), rfingers [1].GetTipPosition ()) > trigger &&
                Vector3.Distance (right.GetPalmPosition (), rfingers [2].GetTipPosition ()) < trigger &&
                Vector3.Distance (right.GetPalmPosition (), rfingers [3].GetTipPosition ()) < trigger &&
                Vector3.Distance (right.GetPalmPosition (), rfingers [4].GetTipPosition ()) < trigger ) {
                Debug.Log ("rockgod!!");
                rockgod = true;
            } else {
                rockgod = false;
            }
            if (rockgod) {
                line.enabled = true;
                Ray ray = new Ray (rfingers [1].GetTipPosition (), rfingers[1].GetBoneDirection(2));
        //				Ray ray1 = new Ray (rfingers [4].GetTipPosition (), rfingers [4].GetBoneDirection ());

                line.SetPosition (0, ray.origin);
                line.SetPosition (1, ray.GetPoint (100));
            } else {
                line.enabled = false;
            }
        }
    }
Example #11
0
 protected override void OnViewChanged(Frame sourceFrame) {
     base.OnViewChanged(sourceFrame);
     var xafApplication = Application as IAfterViewShown;
     if ((xafApplication != null) && (View != null)) {
         xafApplication.OnAfterViewShown(this, sourceFrame);
     }
 }
Example #12
0
        public override object Evaluate(Frame environment)
        {
            if (environment == null)
            {
                throw new ArgumentNullException("Environment can not be null.");
            }
            List<double> paramValues = new List<double>();
            foreach (String param in Parameters)
            {
                String binding = environment.FindBindingValue(param).ToString();
                if (binding == null)
                {
                    throw new Exception("can't find binding");
                }
                double number;
                if (double.TryParse(binding, out number))
                {
                    paramValues.Add(number);
                }
            }
            if (paramValues.Count < 2)
            {
                throw new Exception("Illegal number of arguments, need at least 2.");
            }

            return CompareValues(paramValues[0], paramValues[1]);
        }
Example #13
0
    void UpdateGrabStatus(Frame frame)
    {
        ExtendedHand collidingHand = null;

        if (latestCollision != null)
        {
            if (leftHand.BelongsToCollision(latestCollision))
            {
                collidingHand = leftHand;
            }
            else if (rightHand.BelongsToCollision(latestCollision))
            {
                collidingHand = rightHand;
            }

            if (collidingHand != null && 
                collidingHand.tracking &&
                collidingHand.grabbedObject == null && 
                collidingHand.GetLeapHand(frame).GrabStrength >= 0.6)
            {
                GetGrabbed(collidingHand, latestCollision.gameObject);
            }

            latestCollision = null;
        }
    }
 public void SecondThrow()
 {
     frame = new Frame(game);
     frame.Throw(5);
     frame.Throw(3);
     Assert.AreEqual(8, game.Score());
 }
 private static void CheckSingleHandGestures(Frame frame, Action<IEnumerable<Result>> fireNewMotions)
 {
     var grabbedHands = frame.Hands.Where(hand => hand.GrabStrength > 0.7);
     var pinchedHands = frame.Hands.Where(hand => hand.PinchStrength > 0.7);
     var results = grabbedHands.Select(FromHand);
     fireNewMotions(results.Concat(pinchedHands.Select(FromHand)));
 }
        /// <summary>
        /// Invoked when the application is launched normally by the end user.  Other entry points
        /// will be used when the application is launched to open a specific file, to display
        /// search results, and so forth.
        /// </summary>
        /// <param name="args">Details about the launch request and process.</param>
        protected override void OnLaunched(LaunchActivatedEventArgs args)
        {
            var rootFrame = Window.Current.Content as Frame;

            // Do not repeat app initialization when the Window already has content,
            // just ensure that the window is active
            if (rootFrame == null)
            {
                // Create a Frame to act as the navigation context and navigate to the first page
                rootFrame = new Frame();

                if (args.PreviousExecutionState == ApplicationExecutionState.Terminated)
                {
                    //TODO: Load state from previously suspended application
                }

                // Place the frame in the current Window
                Window.Current.Content = rootFrame;
            }

            if (rootFrame.Content == null)
            {
                // When the navigation stack isn't restored navigate to the first page,
                // configuring the new page by passing required information as a navigation
                // parameter
                if (!rootFrame.Navigate(typeof (MainPage), args.Arguments))
                {
                    throw new Exception("Failed to create initial page");
                }
            }
            // Ensure the current window is active
            Window.Current.Activate();
        }
Example #17
0
        public ChatBox()
        {
            Size = new Point(100, 100);

            Input = new TextBox();
            Input.Size = new Point(100, 35);
            Input.Dock = DockStyle.Bottom;
            Input.TextCommit += Input_OnTextCommit;
            Elements.Add(Input);

            Scrollbar = new ScrollBar();
            Scrollbar.Dock = DockStyle.Right;
            Scrollbar.Size = new Point(25, 25);
            Elements.Add(Scrollbar);

            Frame = new Frame();
            Frame.Dock = DockStyle.Fill;
            Frame.Scissor = true;
            Elements.Add(Frame);

            Output = new Label();
            Output.BBCodeEnabled = true;
            Output.TextWrap = true;
            Output.AutoSize = Squid.AutoSize.Vertical;
            Output.Text = "Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat, sed diam voluptua. At vero eos et accusam et justo duo dolores et ea rebum. Stet clita kasd gubergren, no sea takimata sanctus est Lorem ipsum dolor sit amet. Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat, sed diam voluptua. At vero eos et accusam et justo duo dolores et ea rebum. Stet clita kasd gubergren, no sea takimata sanctus est Lorem ipsum dolor sit amet.";
            Output.Style = "multiline";
            Frame.Controls.Add(Output);
        }
 private void NewFrameAvailable(Frame frame)
 {
     if (NewFrame != null)
     {
         NewFrame(frame);
     }
     try
     {
         _frameBuffer.Add(frame);
         if (frame.Hands.Count > 0)
         {
             var physicsCmd = new PhysicCommand();
             foreach (var hand in frame.Hands)
             {
                 var parts = CreateHand(hand, hand.IsLeft ? JointType.HAND_LEFT : JointType.HAND_RIGHT);
                 foreach (var bodyPart in parts)
                 {
                     physicsCmd.AddCollider(bodyPart);
                 }
             }
             FireNewCommand(physicsCmd);
         }
     }
     catch (Exception e)
     {
         Console.WriteLine(e.Message);
     }
 }
    public Hand makeHand(ref LEAP_HAND hand, Frame owningFrame)
    {
      Arm newArm = makeArm(ref hand.arm);

      Hand newHand = new Hand(
        (int)owningFrame.Id,
        (int)hand.id,
        hand.confidence,
        hand.grab_strength,
        hand.grab_angle,
        hand.pinch_strength,
        hand.pinch_distance,
        hand.palm.width,
        hand.type == eLeapHandType.eLeapHandType_Left,
        hand.visible_time,
        newArm,
        new List<Finger>(5),
        new Vector(hand.palm.position.x, hand.palm.position.y, hand.palm.position.z),
        new Vector(hand.palm.stabilized_position.x, hand.palm.stabilized_position.y, hand.palm.stabilized_position.z),
        new Vector(hand.palm.velocity.x, hand.palm.velocity.y, hand.palm.velocity.z),
        new Vector(hand.palm.normal.x, hand.palm.normal.y, hand.palm.normal.z),
        new Vector(hand.palm.direction.x, hand.palm.direction.y, hand.palm.direction.z),
        newArm.NextJoint //wrist position
      );
      newHand.Fingers.Insert(0, makeFinger(owningFrame, ref hand, ref hand.thumb, Finger.FingerType.TYPE_THUMB));
      newHand.Fingers.Insert(1, makeFinger(owningFrame, ref hand, ref hand.index, Finger.FingerType.TYPE_INDEX));
      newHand.Fingers.Insert(2, makeFinger(owningFrame, ref hand, ref hand.middle, Finger.FingerType.TYPE_MIDDLE));
      newHand.Fingers.Insert(3, makeFinger(owningFrame, ref hand, ref hand.ring, Finger.FingerType.TYPE_RING));
      newHand.Fingers.Insert(4, makeFinger(owningFrame, ref hand, ref hand.pinky, Finger.FingerType.TYPE_PINKY));

      return newHand;
    }
Example #20
0
        public object Evaluate(Frame environment, Expression expression)
        {
            if (expression.GetRest().Count < 2)
            {
                throw new Exception("Invalid let definition");
            }
            Expression definitionList = expression.GetRest()[0];
            List<string> paramNames = new List<string>(definitionList.GetRest().Count + 1);
            Dictionary<string, Procedure> bindings = new Dictionary<string, Procedure>(paramNames.Capacity);

            Expression firstDefinition = definitionList.GetFirst();
            AddDefinition(environment, paramNames, bindings, firstDefinition);
            foreach (Expression definition in definitionList.GetRest())
            {
                AddDefinition(environment, paramNames, bindings, definition);
            }

            List<Expression> body = new List<Expression>(expression.GetRest().Count - 1);
            for (int i = 1; i < expression.GetRest().Count; i++)
            {
                body.Add(expression.GetRest()[i]);
            }

            Lambda block = new Lambda(environment, paramNames, body);

            Frame child = new Frame(bindings, environment, environment, block,true,null);

            return child.Evaluate(block.Body);
        }
Example #21
0
        private void AddDefinition(Frame environment, List<string> paramNames, Dictionary<string, Procedure> bindings, Expression definition)
        {
            if (definition != null)
            {
                string name = definition.GetFirst().ToString();
                paramNames.Add(name);

                if (definition.GetRest().Count == 0)
                {
                    throw new Exception("Let: expression missing for " + name);
                }

                //TODO clean up the constructor and property
                Frame valueEnv = new Frame(new Dictionary<string, Procedure>(0), environment, null, new Identity(environment, null), false, "let-value");

                object value = valueEnv.Evaluate(definition.GetRest()[0],true);
                if (value is Procedure)
                {
                    bindings.Add(name, (Procedure)value);
                }
                else
                {
                    bindings.Add(name, new Identity(environment, value));
                }
            }
        }
Example #22
0
        /// <summary>
        /// Loads an animated graphics. The descriptor file for the animation must be
        /// in the "animations" folder.
        /// </summary>
        /// <param name="animationName">The name of the animation.</param>
        /// <param name="game"></param>
        public AnimatedGraphics(string animationName, Game game)
        {
            PropertyReader props = game.loader.GetPropertyReader().Select("animations/" + animationName + ".xml");
            foreach (PropertyReader group in props.SelectAll("group")) {
                Animation current = new Animation();
                string[] animName = group.GetString("name").Split('.');
                string type = animName[0];
                Sprite.Dir dir = (Sprite.Dir)Enum.Parse(typeof(Sprite.Dir), animName[1], true);
                AnimationType animType = new AnimationType(type, dir);
                List<Frame> frames = new List<Frame>();
                foreach (PropertyReader frameProp in group.SelectAll("frame")) {
                    Frame frame = new Frame();
                    frame.id = frameProp.GetInt("sheetid");
                    frame.time = frameProp.GetInt("time");
                    frames.Add(frame);
                }
                current.frames = frames.ToArray();
                animations.Add(animType, current);
                if (this.currentAnimation == null) {
                    this.currentAnimation = current;
                    this.currentType = animType;
                }
            }
            LoadSpriteSheet(props.GetString("sheet"), game);

            if (currentAnimation == null) {
                throw new Game.SettingsException(string.Format("Animation descriptor file \"{0}.xml\" does not contain animation!", animationName));
            }
            this.frame = 0;
            CalculateRows();
        }
        static void Main(string[] args)
        {
            float[] frame1origin = new float[] { 0, 0, 0 };
             float[] frame1XDirection = new float[] { 1, 0, 0 };
             float[] frame1YDirection = new float[] { 0, 1, 0 };
             Console.WriteLine(frame1YDirection[0] + " " + frame1YDirection[1] + " " + frame1YDirection[2]);
             float[] frame1ZDirection = new float[] { 0, 0, 1 };
             Frame frame1 = new Frame(frame1origin, frame1XDirection, frame1YDirection, frame1ZDirection);
             Console.WriteLine("\nWriting frame1.vtp...");
             // adjust path
             frame1.Write(@"c:\vtk\vtkdata-5.8.0\Data\frame1.vtp");

             float[] frame2origin = new float[] { 0, 0, 0 };
             float[] frame2XDirection = new float[] { .707f, .707f, 0 };
             float[] frame2YDirection = new float[] { -.707f, .707f, 0 };
             float[] frame2ZDirection = new float[] { 0, 0, 1 };
             Frame frame2 = new Frame(frame2origin, frame2XDirection, frame2YDirection, frame2ZDirection);
             Console.WriteLine("\nWriting frame2.vtp...");
             // adjust path
             frame2.Write(@"c:\vtk\vtkdata-5.8.0\Data\frame2.vtp");

             vtkTransform transform = vtkTransform.New();
             AlignFrames(frame2, frame1, ref transform); // Brings frame2 to frame1

             Console.WriteLine("\nWriting transformed.vtp...");
             // adjust path
             frame2.ApplyTransform(ref transform, @"c:\vtk\vtkdata-5.8.0\Data\transformed.vtp");

             Console.WriteLine("\nPress any key to continue...");
             Console.ReadKey();
        }
Example #24
0
    protected void OnButtonClicked(object sender, EventArgs e)
    {
        if (sender == button1)
        {

            Gtk.FileChooserDialog dialog = new Gtk.FileChooserDialog ("Choose item...", this, FileChooserAction.Open, "Cancel",  ResponseType.Cancel, "Insert Spacer",  ResponseType.None, "Add", ResponseType.Accept);

            Gtk.Alignment align = new Alignment (1, 0, 0, 1);
            Gtk.Frame frame = new Frame ("Position");
            Gtk.HBox hbox = new HBox (false, 4);

            RadioButton rbRight;
            rbRight = new RadioButton ("Right");
            hbox.PackEnd(rbRight, false, false, 1);
            hbox.PackEnd(new RadioButton (rbRight, "Left"), false, false, 1);

            frame.Add (hbox);
            align.Add (frame);
            align.ShowAll ();
            dialog.ExtraWidget = align;

            ResponseType response = (ResponseType)dialog.Run ();
            if (response == ResponseType.Accept) {
                RunCommand ("defaults write com.apple.dock " + GetAlign(dialog.ExtraWidget) + " -array-add '<dict><key>tile-data</key><dict><key>file-data</key><dict><key>_CFURLString</key><string>" + dialog.Filename + "</string><key>_CFURLStringType</key><integer>0</integer></dict></dict></dict>' && /bin/sleep 1 &&/usr/bin/killall Dock");
            } else if (response == ResponseType.None) {
                RunCommand ("defaults write com.apple.dock " + GetAlign(dialog.ExtraWidget) + " -array-add '{tile-data={}; tile-type=\"spacer-tile\";}' && /bin/sleep 1 &&/usr/bin/killall Dock");
            }
            dialog.Destroy ();

        }
    }
Example #25
0
        public override void Draw(GameTime gameTime, Frame frame)
        {
            var ir = new ImperativeRenderer(frame, Materials);
            ir.AutoIncrementLayer = true;

            ir.Clear(color: ClearColor);

            var rect1 = new Rectangle(0, 0, 32, 32);
            var rect2 = new Rectangle(1, 1, 30, 30);

            var drawSet = (Action<Rectangle, float>)((r, y) => {
                DrawRow(ref ir, 0f, y + 0f, SamplerState.PointClamp, r);
                DrawRow(ref ir, 0.5f, y + 1 + 64f, SamplerState.PointClamp, r);
                DrawRow(ref ir, 0f, (y + 3 + 128) + 0.5f, SamplerState.PointClamp, r);

                DrawRow(ref ir, 0f, y + 5 + 192f, SamplerState.LinearClamp, r);
                DrawRow(ref ir, 0.5f, y + 7 + 256f, SamplerState.LinearClamp, r);
                DrawRow(ref ir, 0f, (y + 9 + 320) + 0.5f, SamplerState.LinearClamp, r);
            });

            drawSet(rect1, 0f);

            drawSet(rect2, (70f*6));

            var cornerSamplers = SamplerState.LinearClamp;
            ir.Draw(TestTexture, new Vector2(Graphics.PreferredBackBufferWidth - 1, Graphics.PreferredBackBufferHeight - 1), origin: new Vector2(1, 1), samplerState: cornerSamplers);
            ir.Draw(TestTexture, new Vector2(0, Graphics.PreferredBackBufferHeight - 1), origin: new Vector2(0, 1), samplerState: cornerSamplers);
            ir.Draw(TestTexture, new Vector2(Graphics.PreferredBackBufferWidth - 1, 0), origin: new Vector2(1, 0), samplerState: cornerSamplers);
        }
Example #26
0
        public bool Update(Frame frame)
        {
            // List of Ids for current Leap Gestures
            var currentIds = _CurrentGestures.Where(g => g is VyroLeapGesture).Select(g => ((VyroLeapGesture)g).LeapGestureId).ToList();
            // Find any new Leap Gestures
            var newLeapGestures = frame.Gestures().Where(ge => !currentIds.Contains(ge.Id));

            // Update current gestures dispatching activated ones and removing the invalid/complete ones
            var item = _CurrentGestures.First;
            while (item != null)
            {
                var next = item.Next;
                var state = item.Value.Update(frame);
                if (state == VyroGestureState.DiscreteComplete || state == VyroGestureState.IterationComplete)
                    _Dispatcher.Dispatch(item.Value);
                if (state == VyroGestureState.Invalid || state == VyroGestureState.DiscreteComplete || state == VyroGestureState.ContinuousComplete)
                    _CurrentGestures.Remove(item);
                item = next;
            }

            // Add new Leap Gestures
            foreach (var g in newLeapGestures)
                _CurrentGestures.AddLast(VyroLeapGesture.CreateFromLeapGesture(g));

            return true;
        }
Example #27
0
        public object Evaluate(Frame environment, Expression expression)
        {
            List<Expression> operands = expression.GetRest();
            if (operands.Count < 1)
            {
                throw new Exception("Invalid number of cond arguments");
            }
            Frame evalFrame = new Frame(new Dictionary<string, Procedure>(0), environment,environment, null, true, null);
            foreach (Expression expr in operands)
            {
                if (expr.GetFirst().ToString() == "else")
                {
                    return evalFrame.Evaluate(expr.GetRest()[0], true);
                }
                object result = evalFrame.Evaluate(expr.GetFirst());
                bool resultValue = false;
                if (!bool.TryParse(result.ToString(), out resultValue))
                {
                    throw new Exception("Cond clause not a predicate.");
                }
                if (resultValue)
                {
                    object exprResult = string.Empty;

                    for (int i = 0; i < expr.GetRest().Count;i++ )
                    {
                        exprResult = evalFrame.Evaluate(expr.GetRest()[i]);
                    }
                    return exprResult;
                }
            }
            return string.Empty;
        }
Example #28
0
 /// <summary>
 /// 添加一帧
 /// </summary>
 public void AddFrame(Frame Frame)
 {
     lock(_locker)
     {
         _frames.Enqueue(Frame);
     }
 }
Example #29
0
 public void spare_should_leave_frame_open_for_scoring()
 {
     var frame = new Frame();
     frame.Roll('1');
     frame.Roll('/');
     Assert.AreEqual(true, frame.StillScoring);
 }
Example #30
0
        public object Evaluate(Frame environment, Expression expression)
        {
            List<Expression> operands = expression.GetRest();
            if (operands.Count < 2)
            {
                throw new Exception("Invalid number of If arguments");
            }

            Frame evalFrame = new Frame(new Dictionary<string, Procedure>(), environment, environment, null, true, null);
            object result = evalFrame.Evaluate(operands[0]);
            bool resultValue = false;
            if (!bool.TryParse(result.ToString(), out resultValue))
            {
                 throw new Exception("If clause not a predicate.");
            }
            if (resultValue)
            {
                return evalFrame.Evaluate(operands[1],true);
            }
            else
            {
                if (operands.Count > 2)
                {
                    return evalFrame.Evaluate(operands[2], true);
                }
                else
                {
                    return string.Empty;
                }
            }
        }
Example #31
0
 private void BackgroundRemoval_Click(object sender, RoutedEventArgs e)
 {
     Frame.Navigate(typeof(BackgroundRemovalPage));
 }
Example #32
0
        internal Transport(Reactor.IDuplexable <Reactor.Buffer> duplexable)
        {
            this.duplexable = duplexable;

            this.duplexable.OnData += (buffer) =>
            {
                //-------------------------------------------------
                // WEB SOCKET FRAME PARSER
                //-------------------------------------------------

                var data = buffer.ToArray();

                //-------------------------------------------------
                // if we have any leftovers...join to data..
                //-------------------------------------------------

                if (this.unprocessed != null)
                {
                    data = ByteData.Join(this.unprocessed, data);

                    this.unprocessed = null;
                }

                //-------------------------------------------------
                // read in first frame...
                //-------------------------------------------------

                try
                {
                    var frame = Frame.Parse(data, true);

                    this.AcceptFrame(frame);

                    data = ByteData.Unshift(data, (int)frame.FrameLength);
                }
                catch
                {
                    // todo: catch multiple failed exceptions... or fix Frame.Parse

                    this.unprocessed = data;

                    return;
                }

                //-----------------------------------------------
                // read in additional frames...
                //-----------------------------------------------

                while (data.Length > 0)
                {
                    try
                    {
                        var frame = Frame.Parse(data, true);

                        this.AcceptFrame(frame);

                        data = ByteData.Unshift(data, (int)frame.FrameLength);
                    }
                    catch
                    {
                        // todo: catch multiple failed exceptions... or fix Frame.Parse

                        this.unprocessed = data;

                        return;
                    }
                }
            };

            this.duplexable.OnEnd += () =>
            {
                if (this.OnClose != null)
                {
                    this.OnClose();
                }
            };

            var readable = duplexable as IReadable <Reactor.Buffer>;

            readable.OnError += (exception) =>
            {
                if (this.OnError != null)
                {
                    this.OnError(exception);
                }
            };

            var writeable = duplexable as IWriteable <Reactor.Buffer>;

            writeable.OnError += (exception) => {
                if (this.OnError != null)
                {
                    this.OnError(exception);
                }
            };

            if (this.OnOpen != null)
            {
                this.OnOpen();
            }
        }
 private void Back_Click(object sender, RoutedEventArgs e)
 {
     if (Frame.CanGoBack)
         Frame.GoBack();
 }
Example #34
0
 void WriteFrameProperties(Frame node)
 {
     WriteWidgetProperties(node);
     WriteProperty("RenderTarget", (int)node.RenderTarget, 0);
 }
Example #35
0
 private void StackPanel_PointerPressed(object sender, PointerRoutedEventArgs e)
 {
     Frame.Navigate(typeof(UserMenu));
 }
Example #36
0
 private void Gestures_Click(object sender, RoutedEventArgs e)
 {
     Frame.Navigate(typeof(GesturesPage));
 }
Example #37
0
 private void Angle_Click(object sender, RoutedEventArgs e)
 {
     Frame.Navigate(typeof(AnglePage));
 }
Example #38
0
 protected override void OnActivated()
 {
     base.OnActivated();
     bool IsAdministrative = (SecuritySystem.CurrentUser as User).IsAdministrative;
     Frame.GetController<DeleteObjectsViewController>().Active["OnlyActiveForAdmin"] = IsAdministrative;
 }
Example #39
0
        private async void NavigationHelper_LoadState(object sender, LoadStateEventArgs e)
        {
            int Id   = (int)e.NavigationParameter;
            var Item = await RestaurantPageSource.GetRestaurantAsync(Id);

            this.ProgressRing.IsActive = false;

            if (Item == null)
            {
                if (Frame.CanGoBack)
                {
                    Frame.GoBack();

                    await ShowErrorAsync();
                }
                else
                {
                    if (!Frame.Navigate(typeof(MainPage), "FoodLook 2"))
                    {
                        throw new Exception();
                    }
                    Frame.BackStack.Clear();

                    await ShowErrorAsync();
                }
            }
            else
            {
                this.DefaultViewModel[Restaurant] = Item;
                this.DefaultViewModel[Label]      = Item.Label;

                LikeButtonToggle();
                FavoriteButtonToggle();

                this.RestaurantPageCommandBar.Visibility = Visibility.Visible;

                if (Item.Website == null)
                {
                    this.WebsiteBlock.Visibility = Visibility.Collapsed;
                }
                if (Item.Email == null)
                {
                    this.EmailBlock.Visibility = Visibility.Collapsed;
                }
                if (Item.Facebook == null)
                {
                    this.FacebookBlock.Visibility = Visibility.Collapsed;
                }
                if (Item.Instagram == null)
                {
                    this.InstagramBlock.Visibility = Visibility.Collapsed;
                }
                if (!Item.Parking)
                {
                    this.ParkingImage.Opacity = 0.4;
                }
                if (!Item.PaymentCards)
                {
                    this.PaymentCardsImage.Opacity = 0.4;
                }
                if (!Item.LiveMusic)
                {
                    this.LiveMusicImage.Opacity = 0.4;
                }
                if (Item.Telephone == null)
                {
                    this.PhoneButton.Visibility = Visibility.Collapsed;
                }

                this.RestaurantPagePivot.Visibility = Visibility.Visible;
            }
        }
Example #40
0
 private void Camera_Click(object sender, RoutedEventArgs e)
 {
     Frame.Navigate(typeof(CameraPage));
 }
Example #41
0
 /// <summary>
 /// Encodes the specified frame to the underlying bitstream.
 /// </summary>
 /// <param name="frame">A <see cref="Frame"/> containing video data to encode.</param>
 public override void EncodeFrame(Frame frame)
 {
     throw new NotImplementedException();
 }
Example #42
0
 private void Simconnect_OnRecvEventFrame(SimConnect sender, SIMCONNECT_RECV_EVENT_FRAME data)
 {
     logger.LogTrace("Frame: {simSpeed} {frameRate}", data.fSimSpeed, data.fFrameRate);
     Frame?.Invoke(this, new EventArgs());
 }
 private void NightMode_Click(object sender, RoutedEventArgs e)
 {
     Frame.Navigate(typeof(SettingsNightModePage));
 }
 private void AppBarButton_Click_Home(object sender, RoutedEventArgs e)
 {
     Frame.Navigate(typeof(MainPage));
 }
 /// <summary>
 /// Initializes the specified the application into a container.
 /// </summary>
 /// <param name="theApp">The application.</param>
 /// <param name="navFrame">The frame to use for page navigation.</param>
 public static void Initialize(MXApplication theApp, Frame navFrame)
 {
     InitializeContainer(new MXWindowsContainer(theApp));
     Instance.ThreadedLoad = false;
     NavigationFrame       = navFrame;
 }
 private void Themes_Click(object sender, RoutedEventArgs e)
 {
     Frame.Navigate(typeof(SettingsThemesPage));
 }
Example #47
0
 //返回
 private void appbar_buttonCancel_Click(object sender, RoutedEventArgs e)
 {
     Frame.GoBack();
 }
 private void Wallpaper_Click(object sender, RoutedEventArgs e)
 {
     Frame.Navigate(typeof(SettingsBackgroundsPage));
 }
 protected NinjectMvxWindowsSetup(Frame rootFrame, string suspensionManagerSessionStateKey = null) : base(rootFrame, suspensionManagerSessionStateKey)
 {
 }
Example #50
0
 // 点击回退按钮,回退到主页
 private void Back_Click(object sender, RoutedEventArgs e)
 {
     Frame.Navigate(typeof(MainPage));
 }
 private void ChangePhoneNumber_Click(object sender, RoutedEventArgs e)
 {
     Frame.Navigate(typeof(SettingsPhoneIntroPage));
 }
        private void Button_Click(object sender, RoutedEventArgs e)
        {
            Frame rootFrame = Window.Current.Content as Frame;

            rootFrame.Navigate(typeof(SecondPage), null, new SuppressNavigationTransitionInfo());
        }
Example #53
0
        /// <summary>
        /// Invoked when the application is launched normally by the end user.  Other entry points
        /// will be used when the application is launched to open a specific file, to display
        /// search results, and so forth.
        /// </summary>
        /// <param name="e">Details about the launch request and process.</param>
        protected async override void OnLaunched(LaunchActivatedEventArgs e)
        {
#if DEBUG
            if (System.Diagnostics.Debugger.IsAttached)
            {
                this.DebugSettings.EnableFrameRateCounter = true;
            }
#endif

            Frame rootFrame = Window.Current.Content as Frame;

            // Do not repeat app initialization when the Window already has content,
            // just ensure that the window is active
            if (rootFrame == null)
            {
                // Create a Frame to act as the navigation context and navigate to the first page
                rootFrame = new Frame();

                //Associate the frame with a SuspensionManager key
                SuspensionManager.RegisterFrame(rootFrame, "AppFrame");

                // TODO: change this value to a cache size that is appropriate for your application
                rootFrame.CacheSize = 1;

                if (e.PreviousExecutionState == ApplicationExecutionState.Terminated)
                {
                    // Restore the saved session state only when appropriate
                    try
                    {
                        await SuspensionManager.RestoreAsync();
                    }
                    catch (SuspensionManagerException)
                    {
                        // Something went wrong restoring state.
                        // Assume there is no state and continue
                    }
                }

                // Place the frame in the current Window
                Window.Current.Content = rootFrame;
            }

            if (rootFrame.Content == null)
            {
#if WINDOWS_PHONE_APP
                // Removes the turnstile navigation for startup.
                if (rootFrame.ContentTransitions != null)
                {
                    this.transitions = new TransitionCollection();
                    foreach (var c in rootFrame.ContentTransitions)
                    {
                        this.transitions.Add(c);
                    }
                }

                rootFrame.ContentTransitions = null;
                rootFrame.Navigated         += this.RootFrame_FirstNavigated;
#endif

                // When the navigation stack isn't restored navigate to the first page,
                // configuring the new page by passing required information as a navigation
                // parameter
                if (!rootFrame.Navigate(typeof(MainPage), e.Arguments))
                {
                    throw new Exception("Failed to create initial page");
                }
            }

            // Ensure the current window is active
            Window.Current.Activate();
        }
        private static void SaveFrameNavigationState(Frame frame)
        {
            var frameState = SessionStateForFrame(frame);

            frameState["Navigation"] = frame.GetNavigationState();
        }
Example #55
0
 void IVisualElementRenderer.SetElement(VisualElement element) =>
 Element = (element as Frame) ?? throw new ArgumentException("Element must be of type Frame.");
 private void ClearCache_Click(object sender, RoutedEventArgs e)
 {
     Frame.Navigate(typeof(SettingsStoragePage));
 }
 private void FrameOnDisposing(object sender, EventArgs e)
 {
     Frame.Disposing -= FrameOnDisposing;
     Frame.GetController <LogicRuleViewController>(controller => controller.LogicRuleExecutor.LogicRuleExecute -= LogicRuleExecutorOnLogicRuleExecute);
 }
Example #58
0
 private void ArchivedStickers_Click(object sender, RoutedEventArgs e)
 {
     Frame.Navigate(typeof(SettingsMasksArchivedPage));
 }
 protected override void OnFrameAssigned()
 {
     base.OnFrameAssigned();
     Frame.GetController <LogicRuleViewController>(controller => controller.LogicRuleExecutor.LogicRuleExecute += LogicRuleExecutorOnLogicRuleExecute);
     Frame.Disposing += FrameOnDisposing;
 }
Example #60
0
 private void btnAddUser_Click(object sender, RoutedEventArgs e)
 {
     Frame.Navigate(typeof(Register));
 }