<?xml version="1.0" encoding="UTF-8"?>
<feed xml:lang="en-US" xmlns="http://www.w3.org/2005/Atom">
  <id>tag:www.refactormycode.com,2007:users1521</id>
  <link type="application/atom+xml" href="http://www.refactormycode.com/users/1521" rel="self"/>
  <title>emptyiness12z.blogspot.com</title>
  <updated>Wed Jun 10 14:07:47 -0700 2009</updated>
  <entry>
    <id>tag:www.refactormycode.com,2007:Refactor161939</id>
    <published>2009-06-10T14:07:47-07:00</published>
    <title>[C#] On Asp.Net Dropdown list</title>
    <content type="html">&lt;p&gt;It's webforms.&lt;/p&gt;

&lt;pre&gt;&lt;/pre&gt;</content>
    <author>
      <name>emptyiness12z.blogspot.com</name>
      <email></email>
    </author>
    <link type="text/html" href="http://www.refactormycode.com/codes/904-asp-net-dropdown-list/refactors/161939" rel="alternate"/>
  </entry>
  <entry>
    <id>tag:www.refactormycode.com,2007:Code904</id>
    <published>2009-06-08T19:06:17-07:00</published>
    <updated>2009-06-15T14:49:35-07:00</updated>
    <title>[C#] Asp.Net Dropdown list</title>
    <content type="html">&lt;p&gt;I know there's a better way to do this.&lt;/p&gt;

&lt;pre&gt;&amp;lt;select id=&amp;quot;&amp;lt;%Response.Write(QuantityId); %&amp;gt;&amp;quot; onmousewheel=&amp;quot;return(false);&amp;quot; name=&amp;quot;&amp;lt;%Response.Write(QuantityId); %&amp;gt;&amp;quot;
	onchange=&amp;quot;javascript:&amp;lt;%Response.Write(ChangeHandler); %&amp;gt;&amp;quot;&amp;gt;
	&amp;lt;%
		for (int i = CanRemove ? 0 : 1; i &amp;lt;= 9; ++i)
		{
			string select = &amp;quot;&amp;quot;;
			if (StartQuantity == i) {select = &amp;quot;selected=\&amp;quot;selected\&amp;quot;&amp;quot;;}
			Response.Write(string.Format(&amp;quot;\n&amp;lt;option value=\&amp;quot;{0}\&amp;quot; {1} &amp;gt;{0}&amp;lt;/option&amp;gt;&amp;quot;, i,select));			
		}
	%&amp;gt;
&amp;lt;/select&amp;gt;&lt;/pre&gt;</content>
    <author>
      <name>emptyiness12z.blogspot.com</name>
      <email>no-email@refactormycode.com</email>
    </author>
    <link type="text/html" href="http://www.refactormycode.com/codes/904-asp-net-dropdown-list" rel="alternate"/>
  </entry>
  <entry>
    <id>tag:www.refactormycode.com,2007:Refactor159622</id>
    <published>2009-05-28T13:40:16-07:00</published>
    <title>[C#] On Square Class</title>
    <content type="html">&lt;p&gt;It's part of a Nurikabe solver.  RoomType generates a change event because A) changing the roomtype may cause the display to change and B) changing the roomtype causes some revalidation to occur (checking if the square has gained/lost association with other squares, checking for a subset of rule violations).&lt;/p&gt;

&lt;p&gt;The Neighbors/FullNeighbors array store the neighbors of the square (FullNeighbors includes the square itself).  It is initialized elsewhere...which may be inappropriate, itself.&lt;/p&gt;

&lt;p&gt;There is a temptation to replace it with a struct just containing X/Y coordinates and hashcode (LayoutKind.Explicit to make it overlap the coordinates), and roomtype, but such a refactoring would be a hassle.&lt;/p&gt;

&lt;pre&gt;&lt;/pre&gt;</content>
    <author>
      <name>emptyiness12z.blogspot.com</name>
      <email></email>
    </author>
    <link type="text/html" href="http://www.refactormycode.com/codes/883-square-class/refactors/159622" rel="alternate"/>
  </entry>
  <entry>
    <id>tag:www.refactormycode.com,2007:Code883</id>
    <published>2009-05-24T09:48:06-07:00</published>
    <updated>2009-05-28T13:40:16-07:00</updated>
    <title>[C#] Square Class</title>
    <content type="html">&lt;p&gt;A messy class that has grown random features :/&lt;/p&gt;

&lt;pre&gt;using System;
using System.Collections.Generic;
using System.Text;

namespace NuriProg.Model
{
    public enum SquareType : byte
    {
        Wall = 1,
        Room = 2,
        Unknown = 4
    }

    public delegate void SquareChanged(Square sender);
    

    public sealed class Square
    {
        private readonly int hashcode;
        public override int GetHashCode()
        {
            return hashcode;
        }

        public event SquareChanged Change;
        private Model parent;
        public NuriProg.View.GridSquare View {get; set;}
        public int RemainingRoomSize { get; set; }

        public Square Owner{get;set;}

        private HashSet&amp;lt;Square&amp;gt; groupMembers;
        public HashSet&amp;lt;Square&amp;gt; GroupMembers
        {
            get
            {
                return Owner.groupMembers;                
            }
            set
            {
                groupMembers = value;
            }
        }


        public bool IsSharedRoom { get; set; }
        public bool Guess { get; set; }
        public int Level { get; set; }
        public Square[] Neighbors { get; set; }
        public Square[] FullNeighbors { get; set; }
        public byte X { get; private set; }
        public byte Y { get; private set; }
        public short RoomSize {get;private set;}
        

        private SquareType roomType;
        public SquareType RoomType
        {
            get { return roomType; }
            set
            {
                roomType = value;
                Level = parent.Level;
                if (Change!=null) Change(this);
            }
        }

        public Square(short size, byte x, byte y, Model parent)
        {
            RemainingRoomSize = 0;
            IsSharedRoom = false;
            Owner = null;
            this.parent = parent;
            Guess = false;
            Level = 0;
            X = x;
            Y = y;
            this.hashcode = x + y * parent.Width;
            if (size &amp;gt; 0)
            {
                RoomSize = size;
                RemainingRoomSize = size;
                roomType = SquareType.Room;
                Owner = this;
                groupMembers = new HashSet&amp;lt;Square&amp;gt;();
                groupMembers.Add(this);
            }
            else
            {
                RoomSize = 0;
                roomType = SquareType.Unknown;
            }
        }
    }
}
&lt;/pre&gt;</content>
    <author>
      <name>emptyiness12z.blogspot.com</name>
      <email>no-email@refactormycode.com</email>
    </author>
    <link type="text/html" href="http://www.refactormycode.com/codes/883-square-class" rel="alternate"/>
  </entry>
</feed>

