Esempio n. 1
0
		private void UserControl_Initialized(object sender, System.EventArgs e)
		{
			double fieldSize = this.Width/(nrOfRowsCols+1);
			for(int i=0; i<nrOfRowsCols+1; i++) {
				Fields.RowDefinitions.Add(new RowDefinition());
				Fields.ColumnDefinitions.Add(new ColumnDefinition());
			}
			FieldLabel flabel = new FieldLabel();
			flabel.Width = fieldSize;
			flabel.Height = fieldSize;
			flabel.Text = "";
			Grid.SetRow(flabel, 0);
			Grid.SetColumn(flabel, 0);
			Fields.Children.Add(flabel);
			for(int i=1; i<nrOfRowsCols+1; i++) {
				FieldLabel label = new FieldLabel();
				char val = Convert.ToChar(64+i);
				label.Text = val.ToString();
				label.Width = fieldSize;
				label.Height = fieldSize;
				Grid.SetRow(label, i);
				Grid.SetColumn(label, 0);
				Fields.Children.Add(label);
			}
			for(int i=1; i<nrOfRowsCols+1; i++) {
				FieldLabel label = new FieldLabel();
				label.Text = i.ToString();
				label.Width = fieldSize;
				label.Height = fieldSize;
				Grid.SetRow(label, 0);
				Grid.SetColumn(label, i);
				Fields.Children.Add(label);
			}
            for(int i=1; i<nrOfRowsCols+1; i++) {
				for(int j=1; j<nrOfRowsCols+1; j++) {
					Field field = new Field(i, j);
                    fieldControl[i - 1, j - 1] = field;
					field.Width = fieldSize;
					field.Height = fieldSize;
					Grid.SetRow(field, i);
					Grid.SetColumn(field, j);
					Fields.Children.Add(field);
				}
			}
		}
Esempio n. 2
0
		public Playfield()
		{
			fieldControl = new Field[nrOfRowsCols, nrOfRowsCols];
			this.InitializeComponent();
		}
Esempio n. 3
0
 void System.Windows.Markup.IComponentConnector.Connect(int connectionId, object target) {
     switch (connectionId)
     {
     case 1:
     this.UserControl = ((BattleShip.Field)(target));
     
     #line 10 "..\..\..\..\UserControls\Field.xaml"
     this.UserControl.MouseEnter += new System.Windows.Input.MouseEventHandler(this.UserControl_MouseEnter);
     
     #line default
     #line hidden
     
     #line 10 "..\..\..\..\UserControls\Field.xaml"
     this.UserControl.MouseLeave += new System.Windows.Input.MouseEventHandler(this.UserControl_MouseLeave);
     
     #line default
     #line hidden
     return;
     case 2:
     this.FieldStates = ((System.Windows.VisualStateGroup)(target));
     return;
     case 3:
     this.Normal = ((System.Windows.VisualState)(target));
     return;
     case 4:
     this.MouseOver = ((System.Windows.VisualState)(target));
     return;
     case 5:
     this.Red = ((System.Windows.VisualState)(target));
     return;
     case 6:
     this.Green = ((System.Windows.VisualState)(target));
     return;
     case 7:
     this.LayoutRoot = ((System.Windows.Controls.Grid)(target));
     return;
     case 8:
     this.rectangle = ((System.Windows.Shapes.Rectangle)(target));
     return;
     }
     this._contentLoaded = true;
 }