|
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows.Controls;
using System.Windows.Media;
using System.Windows;
namespace nPuzzel
{
class PuzzelPiece : Button
{
bool useImage = false;
public ImageBrush PieceBrush { get; set; }
public int PieceIndex { get; set; }
public Point location;
public bool UseImage
{
get { return useImage; }
set
{
useImage = value;
SetBackground();
}
}
public PuzzelPiece(int index, ImageBrush pieceBrush)
{
this.PieceBrush = pieceBrush;
this.PieceIndex = index;
SetBackground();
}
public Point Location
{
get { return location; }
set
{
this.location = value;
this.SetValue(Canvas.LeftProperty, location.X);
this.SetValue(Canvas.TopProperty, location.Y);
}
}
public void SetBackground()
{
if (IsEnabled)
{
if (UseImage)
{
this.Background = PieceBrush;
this.Content = "";
}
else
{
this.Background = Brushes.WhiteSmoke;
this.Content = PieceIndex + 1;
}
}
else
{
this.Background = Brushes.WhiteSmoke;
this.Content = "";
}
}
public void MakeEmpty()
{
this.Content = "";
this.Background = Brushes.WhiteSmoke;
this.IsEnabled = false;
}
public void MakeActive()
{
this.IsEnabled = true;
if (UseImage)
{
this.Background = PieceBrush;
this.Content = "";
}
else
{
this.Background = Brushes.WhiteSmoke;
this.Content = PieceIndex + 1;
}
}
}
}
|
By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.
If a file you wish to view isn't highlighted, and is a text file (not binary), please
let us know and we'll add colourisation support for it.
I am a full-stack developer. My skills include JavaScript, C#/.Net, MS Azure cloud etc. I love to work on complex programming tasks requiring deep analysis, planning and use of efficient algorithms and data structures.