Exemplo n.º 1
0
        static void Main()
        {
            string strURI = "ATSAM";
            CA     pCA    = new CA(strURI);
            CCL    pCCL   = new CCL();

            //MAPCommonLayer.SA pSA = new MAPCommonLayer.SA(strURI);
            if (CA.Status == Macro.ErrorCode.ecNone)
            {
                RemotingConfiguration.RegisterWellKnownClientType(typeof(BusinessFacadeLayer.BFL), "http://" + CA.ServerIPAddress + ":" + CA.PortNumber + "/" + strURI + "URI");
                try
                {
                    ABFL pBFL = new BusinessFacadeLayer.BFL();
                    pBFL.InitializeLifetimeService();
                    ServerSupplier serverSupplier = new ServerSupplier(pBFL);
                }
                catch
                {
                    CCL.pMB.Show(pCCL.GetResourceString("ecServerConnection"), pCCL.GetResourceString("strErrorTitle"), MessageBoxIcon.Stop, MessageBoxButtons.OK);
                    Application.Exit();
                    return;
                }
            }
            else
            {
                CCL.pMB.Show(pCCL.GetResourceString("ecClientConnection"), pCCL.GetResourceString("strErrorTitle"), MessageBoxIcon.Stop, MessageBoxButtons.OK);
                Application.Exit();
                return;
            }
            Application.EnableVisualStyles();
            Application.SetCompatibleTextRenderingDefault(false);
            Application.Run(new frmMain());
        }
Exemplo n.º 2
0
        public List <int> this[string strNum]   //used to do indexing
        {
            get
            {
                List <int> indexes = new List <int>(Count());

                indexes.Add(CCL.BinarySearch(new CreditCard("", strNum, "", "", "")));


                return(indexes);
            }
        }
        public void Process_SixEntitiesTest()
        {
            //Arrange
            IConnectedComponentLabeling target = new CCL();
            Bitmap input = new Bitmap(AppDomain.CurrentDomain.BaseDirectory + @"\Six.bmp");

            //Act
            var images = target.Process(input);

            foreach (var image in images)
            {
                image.Value.Save(savePath + image.Key + ".bmp");
            }

            //Assert
            Assert.AreEqual(6, images.Count);
        }
Exemplo n.º 4
0
        public Dictionary <string, Structure> SetCCL(Bitmap img)
        {
            Bitmap temp = null;
            CCL    ccl  = null;
            Bitmap bmp  = (Bitmap)img.Clone();

            try
            {
                ToolsImages.Structures.Matrix regionMatrix = null;
                SetList regionSets      = null;
                Vector  finalRegionSets = null;


                regionSets = new SetList();

                // temp = (Bitmap)img;
                //  Bitmap bmap = (Bitmap)temp.Clone();

                ccl = new CCL(bmp);

                ccl.DebutLabel();

                ccl.MarqueRegionAller(out regionSets);
                regionMatrix = ccl.MergeRegions(ccl.regionMatrix, regionSets, out finalRegionSets);

                ccl.MiseAJourRegion();

                Dictionary <string, Structure> rr = ccl.PositionRectangle();
                //  bmap.Dispose();

                return(rr);
            }
            catch (Exception err)
            {
                Console.WriteLine(err.Message);
                return(null);
            }
            finally
            {
                ccl.Img.Dispose();
                bmp.Dispose();
                ccl = null;
                //  temp.Dispose();
            }
        }
Exemplo n.º 5
0
 public ConnectedComponentLabelingTest()
 {
     _baseDirectory  = Directory.GetParent(AppDomain.CurrentDomain.BaseDirectory).Parent.FullName;
     _inputDirectory = Path.Combine(_baseDirectory, "Input");
     _connectedComponentLabelling = new CCL();
 }
Exemplo n.º 6
0
        public void Generate()
        {
            var length = this.cells.Length;

            for (int i = 0; i < length; i++)
            {
                this.cells[i] = rand.NextDouble() > 0.55 ? WALL : NONE;
            }

            // Execute 4/5 rule:
            var a = this.cells;
            var b = new int[length];

            for (int _ = 0; _ < this.iterations; _++)
            {
                for (int i = 0; i < length; i++)
                {
                    var numberOfNeighborsAreWall = CountNeighnors(a, i, WALL);
                    var isWall = a[i] == WALL;
                    b[i] = ((isWall && numberOfNeighborsAreWall >= 4) || (!isWall && numberOfNeighborsAreWall >= 5)) ? WALL : NONE;
                }
                var c = a; a = b; b = c;
            }
            this.cells = a;

            // Wall in edges:
            var last = (this.size - 1) * this.size;

            for (int x = 0; x < this.size; x++)
            {
                this.cells[x]        = WALL;
                this.cells[last + x] = WALL;

                this.cells[x * this.size] = WALL;
                this.cells[x * this.size + this.size - 1] = WALL;
            }

            // CCL, find rooms:
            int largest;

            this.rooms = CCL.ccl(this.cells, this.size, out largest);

            if (rand.NextDouble() > 0.1f)
            {
                var tmp = this.groundFrames[largest % this.groundFrames.Length];
                this.groundFrames[largest % this.groundFrames.Length] = this.groundFrames[0];
                this.groundFrames[0] = tmp;
            }


            var dress = new short[] {
                517, 518, 519,
                523, 524, 525,
                527, 528,
            };


            for (int i = 0; i < length; i++)
            {
                if (this.groundFrames[this.rooms[i] % 4] == FrameGrass)
                {
                    var isNone = a[i] == NONE;
                    var numberOfNeighborsAreNone = CountNeighnors(this.cells, i, NONE);
                    if (isNone && numberOfNeighborsAreNone >= 5 && rand.NextDouble() > 0.85)
                    {
                        this.cells[i] = dress[rand.Next(dress.Length)];
                    }
                }
                if (a[i] == NONE && this.rooms[i] == largest)
                {
                    this.spawnTile = i;
                    if (this.exitTile < 0)
                    {
                        this.exitTile = i;
                    }
                }
            }


            this.Populate(this.Parent);
        }