예제 #1
0
        public void BeforeEach()
        {
            couch = new Couch("localhost", 5984);

            // use my own routines -- even though I would be using my own code as a testing predicate,
            // bugs would still cause obvious failures, and I would only have to use a small slice of my code

            SallyFixture = new Person {Name = "Sally Acorn", Id = "sally", DocumentType = "Person"};
            HayekFixture = new Person {Name = "Frederich Hayek", DocumentType = "Person"}; // hayek gets a generated Id

            PersonFixtures = new List<Person>() {
                SallyFixture,
                HayekFixture
            };
            couch.EnsureDatabaseDeleted(TEST_DATABASE).Wait();
            couch.EnsureDatabaseDeleted(CREATION_TEST_DATABASE).Wait();
            couch.CreateDatabase(TEST_DATABASE).Wait();

            var dbOpenTask = couch.OpenDatabase(TEST_DATABASE);
            dbOpenTask.Wait();
            TestDatabase = dbOpenTask.Result;

            foreach (var personFixture in PersonFixtures) {
                TestDatabase.CreateDocument<Person>(personFixture).Wait();
            }
        }
예제 #2
0
        public Action <IEnvelope> Handle(AddMenuItem message)
        {
            try
            {
                var newItem = new MenuItem();
                using (var context = Context.CreateFor(newItem))
                {
                    newItem.Id          = message.Id;
                    newItem.Name        = message.Name;
                    newItem.Description = message.Description;

                    Couch.Save(newItem.Id, MementoProvider.GetMemento(newItem));

                    context.PublishOnCommit <MenuItemAdded>(x =>
                    {
                        x.ActorId     = message.Id.ToString();
                        x.Name        = message.Name;
                        x.Description = message.Description;
                    });

                    return(x => x.Acknowledge());
                }
            }
            catch (Exception ex)
            {
                return(x => x.Reject(ex.ToString()));
            }
        }
예제 #3
0
        public void Store(IMemento <Order> actor)
        {
            var id  = KeyAccessor.GetId(actor.Retrieve());
            var old = Couch.Get <OrderMemento>(id) as CouchDocument;

            if (old != null)
            {
                (actor as CouchDocument).DocumentRevision = old.DocumentRevision;
            }
            Couch.Persist(id, actor);
        }
예제 #4
0
    // Repartit au hasard une liste de bodypart dans un couch
    private Couch Split(Cushion allParts)
    {
        Couch tmp = new Couch();

        for (int i = 0; i < GameManager.maxBodyParts; i++)     //Pour chaque type de bodypart
        {
            for (int j = 0; j < allParts.parts[i].amount; j++) //Pour chaque bodypart de ce type
            {
                int ran = Random.Range(0, GameManager.maxCushions);
                tmp.cushions[ran].parts[i].amount++;  //Ajouter le même bodypart a un coussin random du resultat
            }
        }

        return(tmp);
    }
예제 #5
0
    public void UpdatePlayCouch()
    {
        //int partAmount = settings.players.Select(x => x.ToCushion().amountOfParts).ToList().Sum();
        int        partAmount = gm.maxParts.amountOfParts;
        Difficulty dif        = settings.difficulty;


        playCouch = Split(RandomBody((int)(partAmount * dif.minParts), (int)(partAmount * dif.maxParts)));
        List <string> textsList = playCouch.Display();

        for (int i = 0; i < texts.Count; i++)
        {
            texts[i].text = textsList[i];
        }
    }
예제 #6
0
        public Action <IEnvelope> Handle(CreateOrder message)
        {
            try
            {
                var order = new Order();
                using (var context = Context.CreateFor(order))
                {
                    order.Id           = message.Id;
                    order.CustomerName = message.CustomerName;
                    order.ItemIds      = message.Items.Select(s => new OrderItem()
                    {
                        ItemId = s.ItemId, Qty = s.Qty
                    }).ToList();

                    Couch.Save(order.Id, MementoProvider.GetMemento(order));

                    OrderAgent.RegisterActor(order.Id, order);

                    context.PublishOnCommit <OrderCreated>(x =>
                    {
                        x.ActorId      = message.Id.ToString();
                        x.Id           = message.Id;
                        x.CustomerName = message.CustomerName;
                        x.Items        = message.Items.Select(s => new OrderItemCreated()
                        {
                            ItemId      = s.ItemId,
                            Qty         = s.Qty,
                            Description = s.Description
                        }).ToList();
                    });

                    return(x => x.Acknowledge());
                }
            }
            catch (Exception ex)
            {
                return(x => x.Reject(ex.ToString()));
            }
        }
예제 #7
0
 public void Init(Couch couch, Fountain fountain)
 {
     this.couch    = couch;
     this.fountain = fountain;
 }
예제 #8
0
        private void ButtonLungs_Click(object sender, RoutedEventArgs e)
        {
            bool rc = _scol.BuildSortedSlicesArray();

            if (!rc)
            {
                System.Windows.MessageBox.Show("There are skips in CTs!");
                return;
            }

            CTSliceInfo[] slices = _scol.Slices;

            // Step 1: find the couch
            int sr = SelectStartSlice(slices);

            CTSliceInfo ct = slices[sr];

            int sc       = Couch.DetectCouchInOneSlice(ct.HounsfieldPixelBuffer, ct.RowCount, ct.ColumnCount);
            int scBefore = Couch.DetectCouchInOneSlice(slices[sr + 10].HounsfieldPixelBuffer, slices[sr + 10].RowCount, slices[sr + 10].ColumnCount);
            int scAfter  = Couch.DetectCouchInOneSlice(slices[sr - 10].HounsfieldPixelBuffer, slices[sr - 10].RowCount, slices[sr - 10].ColumnCount);

            sc = Math.Max(Math.Max(sc, scBefore), scAfter);

            // Step 2: Gaussian blur

            GaussBlur gb = new GaussBlur((float)ct.PixelSpacing_X, (float)ct.PixelSpacing_X, 5);

            for (int k = 0; k != slices.Length; ++k)
            {
                ct          = slices[k];
                short[,] bm = CTSliceHelpers.Apply(ct, gb);
                ct.HounsfieldPixelBuffer = bm;
            }

            // Step 3: clear below the couch
            for (int k = 0; k != slices.Length; ++k)
            {
                ct = slices[k];

                short[,] hb = ct.HounsfieldPixelBuffer;

                for (int r = ct.RowCount - 1; r > sc; --r)
                {
                    for (int c = 0; c != ct.ColumnCount; ++c)
                    {
                        hb[r, c] = -1024;
                    }
                }
            }

            // Step 4: gray level thresholding
            for (int k = 0; k != slices.Length; ++k)
            {
                ct = slices[k];

                Couch.GLThresholding(ct, sc, -499, 0, -499);
            }

            // Step 5: Flool fill
            for (int k = 0; k != slices.Length; ++k)
            {
                ct = slices[k];

                short[,] ret = Couch.FloodFill(ct.HounsfieldPixelBuffer, ct.RowCount, ct.ColumnCount,
                                               3, 3, -499, 0);
                ct.HounsfieldPixelBuffer = ret;
            }

            // Step 6: Contours via Moore Neighbour
            for (int k = slices.Length - 1; k >= slices.Length - 2; --k)
            {
                ct = slices[k];
                int nr = ct.RowCount;
                int nc = ct.ColumnCount;

                int    z  = ct.SliceLoc;
                double zz = ct.UpperLeft_Z;

                short[,] bm = ct.HounsfieldPixelBuffer;

                bool[,] image = new bool[nr, nc];

                for (int r = 0; r != nr; ++r)
                {
                    for (int c = 0; c != nc; ++c)
                    {
                        image[r, c] = false;
                        if (bm[r, c] < 0)
                        {
                            image[r, c] = true;
                        }
                    }
                }

                System.Drawing.Point[] contour = MooreContour.Trace(image, nr, nc);


                foreach (var pt in contour)
                {
                    int r = pt.Y;
                    int c = pt.X;

                    bm[r, c] = 500;
                }
            }
        }
예제 #9
0
파일: Master.cs 프로젝트: jennder/luxo
 public void TriggerCouch()
 {
     Couch.SetTrigger("next");
 }
예제 #10
0
        public void PlaceObject()
        {
            Object temp;

            switch (ObjectListBox.SelectedItem.ToString())
            {
            case "Key":
                temp = new Key();
                PlacedObjectListBox.Items.Add(temp);
                break;

            case "Ammo":
                temp = new Ammo();
                PlacedObjectListBox.Items.Add(temp);
                break;

            case "Health":
                temp = new Health();
                PlacedObjectListBox.Items.Add(temp);
                break;

            case "Adrenaline":
                temp = new Adrenaline();
                PlacedObjectListBox.Items.Add(temp);
                break;

            case "Barrel":
                temp = new Barrel();
                PlacedObjectListBox.Items.Add(temp);
                break;

            case "Pipe":
                temp = new Pipe();
                PlacedObjectListBox.Items.Add(temp);
                break;

            case "Couch":
                temp = new Couch();
                PlacedObjectListBox.Items.Add(temp);
                break;

            case "Wardrobe":
                temp = new Wardrobe();
                PlacedObjectListBox.Items.Add(temp);
                break;

            case "Lamp":
                temp = new Lamp();
                PlacedObjectListBox.Items.Add(temp);
                break;

            case "Desk":
                temp = new Desk();
                PlacedObjectListBox.Items.Add(temp);
                break;

            case "Tree":
                temp = new Tree();
                PlacedObjectListBox.Items.Add(temp);
                break;

            case "China":
                temp = new China();
                PlacedObjectListBox.Items.Add(temp);
                break;

            case "Table":
                temp = new Table();
                PlacedObjectListBox.Items.Add(temp);
                break;

            case "Chair":
                temp = new Chair();
                PlacedObjectListBox.Items.Add(temp);
                break;

            case "Pistol":
                temp = new Pistol();
                PlacedObjectListBox.Items.Add(temp);
                break;

            case "Door":
                temp = new Door();
                PlacedObjectListBox.Items.Add(temp);
                break;

            case "Assault Rifle":
                temp = new AssaultRifle();
                PlacedObjectListBox.Items.Add(temp);
                break;

            case "Shotgun":
                temp = new Shotgun();
                PlacedObjectListBox.Items.Add(temp);
                break;

            case "Rocket Launcher":
                temp = new RocketLauncher();
                PlacedObjectListBox.Items.Add(temp);
                break;

            case "Laser Cannon":
                temp = new LaserCannon();
                PlacedObjectListBox.Items.Add(temp);
                break;

            case "Player":
                temp = new Player();
                PlacedObjectListBox.Items.Add(temp);
                break;

            case "Enemy":
                temp = new Enemy();
                PlacedObjectListBox.Items.Add(temp);
                break;

            case "Civilian":
                temp = new Civilian();
                PlacedObjectListBox.Items.Add(temp);
                break;

            case "Boss":
                temp = new Boss();
                PlacedObjectListBox.Items.Add(temp);
                break;

            case "Cop":
                temp = new Cop();
                PlacedObjectListBox.Items.Add(temp);
                break;
            }
            ;
        }
예제 #11
0
 IMemento <Order> IActorStore <Order> .Get <TKey>(TKey id)
 {
     return(Couch.Get <OrderMemento>(id.ToString()));
 }