コード例 #1
0
        // -------------------------------------------------        OnLoad
        private void OnLoad (object sender, EventArgs e)
        {
            font = new Font ("Times New Roman", 16, FontStyle .Bold | FontStyle .Italic);
            Rectangle rc = new Rectangle (20, 110, 140, 238);
            Point pt = new Point ((rc .Left + rc .Right) / 2, rc .Top - 96);
            Color clrHouse = Color .FromArgb (250, 250, 250);
            Color clrRoof = Color .Red;
            house = new SimpleHouse (17, font, 38, rc, pt, clrHouse, clrRoof);
            house .WindowColor = Color .Blue;
            house .DoorColor = Color .DarkRed;

            Rectangle rch = house .Area;
            cxLabel = rch .Right + rch .Width / 3;
            SizeF [] sizefLabel = new SizeF [cmnts .Length / 2];
            int nW_max_Bold = 0;
            for (int i = 0; i < cmnts .Length / 2; i++)
            {
                sizefLabel [i] = Auxi_Geometry .MeasureString (this, cmnts [i * 2], fontBold);
                nW_max_Bold = Math .Max (nW_max_Bold, (int) (sizefLabel [i] .Width));
            }
            nH_Bold = (int) (sizefLabel [0] .Height);
            cxComment = cxLabel + nW_max_Bold + 10;
            int nW_max = 0;
            for (int i = 0; i < cmnts .Length / 2; i++)
            {
                sizefLabel [i] = Auxi_Geometry .MeasureString (this, cmnts [i * 2 + 1], fontOrdinary);
                nW_max = Math .Max (nW_max, (int) (sizefLabel [i] .Width));
            }
            ClientSize = new Size (cxComment + nW_max + 16, rch .Bottom + 16);
        }
コード例 #2
0
ファイル: Form_HouseParams.cs プロジェクト: enildne/zest
        // -------------------------------------------------
        public Form_HouseParams (SimpleHouse houseSrc)
        {
            InitializeComponent ();
            Font = new Font ("Microsoft Sans Serif", (float) 7.8);

            house = houseSrc;
            Text = "Paint the house number " + house .Number .ToString ();

            int cxSpace = ClientRectangle .Width / 8;
            int cyLT = ClientRectangle .Height * 5 / 12;    // / 3;
            rcHouse = new Rectangle (cxSpace, cyLT, ClientRectangle .Width - 2 * cxSpace, ClientRectangle .Height / 2);
            ptTop = new Point ((rcHouse .Left + rcHouse .Right) / 2, 10);
            int roomSize = Math .Min (rcHouse .Height, rcHouse .Width / 2);
            int nW = roomSize / 2;
            int nH = roomSize / 2;
            rcWindow = new Rectangle (rcHouse .Right - roomSize + (roomSize - nW) / 2,
                                      rcHouse .Bottom - roomSize + roomSize / 6, nW, nW);
            nH = roomSize * 2 / 3;
            nW = nH / 2;
            rcDoor = new Rectangle (rcHouse .Left + (roomSize - nW) / 2, rcHouse .Bottom - nH, nW, nH);

            buttonRoof .Location = new Point (ptTop .X - buttonRoof .Width / 2, ptTop .Y + buttonRoof .Height);
            buttonHouse .Location = new Point (rcHouse .Left + 10, rcHouse .Top + 10);
            buttonDoor .Location = new Point (rcDoor .Right - buttonDoor .Width * 2 / 3, rcDoor .Bottom - buttonDoor .Height * 2 / 3);
            buttonWindow .Location = new Point (rcWindow .Right - buttonWindow .Width * 2 / 3, rcWindow .Bottom - buttonWindow .Height * 2 / 3);
            btnNumberColor .Location = new Point (ptTop .X + btnNumberColor .Width / 2, rcHouse .Top - (btnNumberColor .Height + 1));
            btnNumberFont .Location = new Point (btnNumberColor .Right + 6, btnNumberColor .Top);
        }
コード例 #3
0
ファイル: Form_Town.cs プロジェクト: enildne/zest
 // -------------------------------------------------        OnLoad
 private void OnLoad (object sender, EventArgs e)
 {
     RestoreFromRegistry ();
     if (town .Count == 0)
     {
         SimpleHouse house = new SimpleHouse (1, Font, 40, new Rectangle (150, 150, 100, 60));
         town .Insert (0, house);
     }
     RenewMover ();
 }
コード例 #4
0
ファイル: SimpleHouse.cs プロジェクト: enildne/zest
 // -------------------------------------------------        CopyView
 public void CopyView (SimpleHouse srcHouse)
 {
     CopyColors (srcHouse);
     Font = srcHouse .Font;
 }
コード例 #5
0
ファイル: SimpleHouse.cs プロジェクト: enildne/zest
 // -------------------------------------------------        CopyColors
 public void CopyColors (SimpleHouse srcHouse)
 {
     clrHouse = srcHouse .HouseColor;
     clrRoof = srcHouse .RoofColor;
     clrEdge = srcHouse .EdgeColor;
     clrWindow = srcHouse .WindowColor;
     clrNumber = srcHouse .NumberColor;
     clrDoor = srcHouse .DoorColor;
 }
コード例 #6
0
ファイル: Form_Town.cs プロジェクト: enildne/zest
        // =================================================        RestoreFromRegistry
        private void RestoreFromRegistry ()
        {
            string strkey = Form_Main .strRegKey + strAddRegKey;

            RegistryKey regkey = null;
            try
            {
                regkey = Registry .CurrentUser .OpenSubKey (strkey, true);
                if (regkey != null)
                {
                    int nHouses;
                    string [] strSizes = (string []) regkey .GetValue (nameSizes);
                    if (strSizes != null && strSizes .Length >= 3)
                    {
                        ClientSize = Auxi_Convert .IntoSize (strSizes, 0);
                        nHouses = Convert .ToInt32 (strSizes [2]);
                        if (nHouses > 0)
                        {
                            int [] nNum = new int [nHouses];
                            for (int i = 0; i < nHouses; i++)
                            {
                                nNum [i] = Convert .ToInt32 (strSizes [i + 3]);
                            }
                            for (int i = 0; i < nHouses; i++)
                            {
                                string nameHouse = "House_" + nNum [i] .ToString ();
                                string [] strHouse = (string []) regkey .GetValue (nameHouse);
                                if (strHouse != null && strHouse .Length >= 26)
                                {
                                    SimpleHouse house = new SimpleHouse (Convert .ToInt32 (strHouse [0]), 
                                                                         Auxi_Convert .IntoFont (strHouse, 20),
                                                                         Convert .ToInt32 (strHouse [7]), 
                                                                         Auxi_Convert .IntoRectangle (strHouse, 1),
                                                                         Auxi_Convert .IntoPoint (strHouse, 5),
                                                                         Auxi_Convert .IntoColor (strHouse, 8),
                                                                         Auxi_Convert .IntoColor (strHouse, 11));
                                    house .WindowColor = Auxi_Convert .IntoColor (strHouse, 14);
                                    house .DoorColor = Auxi_Convert .IntoColor (strHouse, 17);
                                    house .NumberColor = Auxi_Convert .IntoColor (strHouse, 23);

                                    town .Add (house);
                                }
                            }
                        }
                    }
                }
            }
            catch
            {
            }
            finally
            {
                if (regkey != null) regkey .Close ();
            }
        }
コード例 #7
0
ファイル: Form_Town.cs プロジェクト: enildne/zest
        // -------------------------------------------------		Click_miRead
        private void Click_miRead (object sender, EventArgs e)
        {
            OpenFileDialog dlg = new OpenFileDialog ();
            dlg .Filter = strFilter;
            if (DialogResult .OK == dlg .ShowDialog ())
            {
                FileStream fs;
                BinaryReader br = null;

                try
                {
                    fs = new FileStream (dlg .FileName, FileMode .Open, FileAccess .Read);
                    br = new BinaryReader (fs);

                    string str = br .ReadString ();
                    if (str == "NewTown")
                    {
                        town .Clear ();
                        int nHouse = br .ReadInt32 ();
                        for (int i = 0; i < nHouse; i++)
                        {
                            int nNum = br .ReadInt32 ();
                            int cxLeft = br .ReadInt32 ();
                            int cyTop = br .ReadInt32 ();
                            int nWidth = br .ReadInt32 ();
                            int nHeight = br .ReadInt32 ();
                            int ptX = br .ReadInt32 ();
                            int ptY = br .ReadInt32 ();
                            int nRoom = br .ReadInt32 ();
                            Color clrHouse = Color .FromArgb (br .ReadByte (), br .ReadByte (), br .ReadByte ());
                            Color clrRoof = Color .FromArgb (br .ReadByte (), br .ReadByte (), br .ReadByte ());
                            Color clrWindow = Color .FromArgb (br .ReadByte (), br .ReadByte (), br .ReadByte ());
                            Color clrDoor = Color .FromArgb (br .ReadByte (), br .ReadByte (), br .ReadByte ());
                            string fntname = br .ReadString ();
                            float fsize = (float) (br .ReadDouble ());
                            FontStyle style = (FontStyle) (br .ReadInt32 ());
                            Color clrNumber = Color .FromArgb (br .ReadByte (), br .ReadByte (), br .ReadByte ());

                            SimpleHouse house = new SimpleHouse (nNum, Font, nRoom, new Rectangle (cxLeft, cyTop, nWidth, nHeight),
                                                                            new Point (ptX, ptY), clrHouse, clrRoof);
                            house .WindowColor = clrWindow;
                            house .DoorColor = clrDoor;
                            house .NumberColor = clrNumber;
                            house .Font = new Font (fntname, fsize, style);

                            town .Insert (0, house);
                        }
                        RenewMover ();
                        Invalidate ();
                    }
                }
                finally
                {
                    br .Close ();
                }
            }
        }
コード例 #8
0
ファイル: Form_Town.cs プロジェクト: enildne/zest
 // -------------------------------------------------		Click_miDuplicate
 private void Click_miDuplicate (object sender, EventArgs e)
 {
     SimpleHouse src = town [iHouseTouched];
     Rectangle area = src .Area;
     Point topSrc = src .Top;
     Size sizeMove = new Size (20, 20);
     area .Offset (sizeMove .Width, sizeMove .Height);
     SimpleHouse newhouse = new SimpleHouse (BiggestNumber () + 1, Font, src .RoomSize, area, topSrc + sizeMove,
                                             src .HouseColor, src .RoofColor);
     newhouse .CopyView (src);
     town .Insert (0, newhouse);
     RenewMover ();
     Invalidate ();
 }
コード例 #9
0
ファイル: Form_Town.cs プロジェクト: enildne/zest
 // -------------------------------------------------		Click_btnNewHouse
 private void Click_btnNewHouse (object sender, EventArgs e)
 {
     Button btn = (Button) sender;
     int nNew = BiggestNumber () + 1;
     SimpleHouse newhouse = new SimpleHouse (nNew, Font, 16 + (nNew % 10) * 3, new Rectangle (btn .Left, btn .Bottom + 20, 100, 60));
     town .Insert (0, newhouse);
     RenewMover ();
     Invalidate ();
 }
コード例 #10
0
ファイル: Form_ManyMovers.cs プロジェクト: enildne/zest
        // -------------------------------------------------
        public Form_ManyMovers ()
        {
            InitializeComponent ();

            moverControls = new Mover (this);
            moverCircle = new Mover (this);
            moverSquare = new Mover (this);
            moverCirclesOnPanel = new Mover ();
            moverSquaresOnPanel = new Mover ();
            moverHouses = new Mover ();

            moverControls .Clear ();
            moverControls .Insert (0, panelCircles);    // , Resizing .NS
            moverControls .Insert (0, panelSquares);    // , Resizing .WE
            moverControls .Insert (0, panelHouses);     // , Resizing .Any
            moverControls .Insert (0, labelInfo);

            moverCircle .Clear ();
            moverSquare .Clear ();

            circles = new ColoredCircle [4] { new ColoredCircle (this, new Point (70, 60), false, size [0], clrs [0]), 
                                              new ColoredCircle (this, new Point (50, 80), false, size [1], clrs [1]), 
                                              new ColoredCircle (this, new Point (80, 110), false, size [2], clrs [2]), 
                                              new ColoredCircle (this, new Point (110, 130), false, size [3], clrs [3]) };
            foreach (ColoredCircle circle in circles)
            {
                moverCircle .Add (circle);
            }

            squares = new ColoredSquare [5] { new ColoredSquare (this, new Point (200, 50), size [0], clrs [0]),    
                                              new ColoredSquare (this, new Point (240, 70), size [1], clrs [1]),    
                                              new ColoredSquare (this, new Point (270, 90), size [2], clrs [2]),    
                                              new ColoredSquare (this, new Point (300, 120), size [3], clrs [3]),    
                                              new ColoredSquare (this, new Point (280, 150), size [4], clrs [4]) }; 
            foreach (ColoredSquare square in squares)
            {
                moverSquare .Add (square);
            }

            moverCirclesOnPanel .Clear ();
            circlesOnPanel = new ColoredCircle [4] {new ColoredCircle (this, new Point (30, 40), false, size [0], clrs [0]),       
                                                    new ColoredCircle (this, new Point (60, 65), false, size [1], clrs [1]),       
                                                    new ColoredCircle (this, new Point (90, 90), false, size [2], clrs [2]),       
                                                    new ColoredCircle (this, new Point (120, 115), false, size [3], clrs [3]) };   
            foreach (ColoredCircle circle in circlesOnPanel)
            {
                moverCirclesOnPanel .Add (circle);
            }

            moverSquaresOnPanel .Clear ();
            squaresOnPanel = new ColoredSquare [] { new ColoredSquare (this, new Point (30, 40), size [0], clrs [0]), 
                                                    new ColoredSquare (this, new Point (60, 65), size [1], clrs [1]),
                                                    new ColoredSquare (this, new Point (90, 90), size [2], clrs [2]) };
            foreach (ColoredSquare square in squaresOnPanel)
            {
                moverSquaresOnPanel .Add (square);
            }

            moverHouses .Clear ();
            Font fnt = new Font ("Times New Roman", 12, FontStyle .Bold | FontStyle .Italic);
            Rectangle rc = new Rectangle (30, 40, 80, 200);
            house4 = new SimpleHouse (4, fnt, 30, rc, new Point ((rc .Left + rc .Right) / 2, rc .Top - 30), Color .Yellow, Color .Brown);
            house4 .NumberColor = Color .White;
            
            rc = new Rectangle (160, 90, 110, 80);
            house17 = new SimpleHouse (17, fnt, 20, rc, new Point ((rc .Left + rc .Right) / 2, rc .Top - 70), Color .LightGreen, Color .Red);
            house17 .WindowColor = Color .Blue;
            moverHouses .Add (house4);
            moverHouses .Add (house17);

            //panelHouses .Set
        }