Link to home
Start Free TrialLog in
Avatar of VPry
VPry

asked on

MVVM design pattern in WPF & C#

I need to build a fairly simple WPF application using C#. Could somebody help me with a design using MVVM architecture?
Avatar of saragani
saragani

In MVVM you need that your UI will not contain and business logic, and have a class which is a ViewModel which will do all the business logic.

You need to set the dataconext of your UI to point the viewmodel you want.

MVVM stands for Model-View-ViewModel.
3 layes where the UI doesn't know much about the ViewModel and nothing about the model (there are some cases where we can have the UI know about some properties for the model), the Model doesn't know about the ViewModel, and the ViewModel doesn't know about the UI.


You should better start with a small application before you try to do something more complicated.
What kind of example would you like to build?
Avatar of VPry

ASKER

I would like to continue building my app that draws Polygons.
Right now code here draws only 1st Polygon and it's hardcoded. So, I want to use MVVM and draw the rest of the Polygons from coordinates saved in listPointsLine1 and listPointsLine2.

Here is XAML:
<Window x:Class="SliderScaleCanvas.MainWindow"
        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" ResizeMode="CanResize" SizeChanged="mainWindow_SizeChanged"
        Title="MainWindow" Height="600" Width="700" VerticalAlignment="Top" HorizontalAlignment="Left">

    <Window.Resources>
        <VisualBrush x:Key="DotFillBrush"     TileMode="Tile"     Viewport="0,0,10,10"     ViewportUnits="Absolute"     Viewbox="0,0,12,12"    ViewboxUnits="Absolute">
            <VisualBrush.Visual>
                <Ellipse         Fill="#00C0FF"         Width="10" Height="10" />
            </VisualBrush.Visual>
        </VisualBrush>
        <VisualBrush       x:Key="HatchBrush"       TileMode="Tile" Viewport="0,0,10,10"       ViewportUnits="Absolute" Viewbox="0,0,10,10"          ViewboxUnits="Absolute">
            <VisualBrush.Visual>
                <Canvas>
                    <Rectangle Fill="Azure" Width="10" Height="10" />
                    <Path Stroke="Purple" Data="M 0 0 l 10 10" />
                    <Path Stroke="Purple" Data="M 0 10 l 10 -10" />
                </Canvas>
            </VisualBrush.Visual>
        </VisualBrush>
    </Window.Resources>

    <Border BorderBrush="Black" BorderThickness="2" CornerRadius="0" Padding="5">
        
        <Grid Name="MainGrid" Background="lightyellow"  >
        <Grid.ColumnDefinitions>
            <ColumnDefinition Width="Auto" />
            <ColumnDefinition Width="Auto"/>
        </Grid.ColumnDefinitions>
        <Grid.RowDefinitions>
            <RowDefinition Height="*"/>
            <RowDefinition Height="Auto"/>
        </Grid.RowDefinitions>

        <Canvas x:Name="mainCanvas" Background="LightYellow" Margin="10" Grid.Row="0" Grid.Column="0" Grid.ColumnSpan="2">
            
            <Label Content="Canvas Size:" Height="28" Name="label1" />
            <Label Content="" Height="28" Name="lblWindowSize" Canvas.Left="70" Width="60" />
            <Label Content="px" Height="28" Name="lblPixels" Canvas.Left="120" Width="25" />

        </Canvas>

            <Slider Orientation="Horizontal" AutoToolTipPlacement="TopLeft" x:Name="sldSlider" VerticalAlignment="Bottom" Grid.Row="0" Grid.Column="0" Grid.RowSpan="2"
                 IsSnapToTickEnabled="True" Width="400" TickPlacement="BottomRight" Background="DimGray"  
                 TickFrequency="10" Maximum="100" ValueChanged="Slider_ValueChanged" Height="29" />
            
            <StackPanel x:Name="LayoutRoot" Background="LightGreen" Width="200" Grid.Row="1" Grid.Column="1">
            <StackPanel Name="stpSliderPosition" Orientation="Horizontal" Width="100">
                <TextBlock Margin="5,5,10,5">Slider</TextBlock>
                <TextBlock Margin="5,5,0,5" TextAlignment="Left" Width="30" Text="{Binding Path=Value, ElementName=sldSlider, Mode=OneWay}" />
                <TextBlock Margin="0,5">%</TextBlock>
            </StackPanel>
        </StackPanel>
       
       

    </Grid>
    </Border>

</Window> 

Code Behind -----------------------------------------------------------------------------------------------------------------------

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;
using Microsoft.Research.DynamicDataDisplay;

namespace SliderScaleCanvas
{
    /// <summary>
    /// Interaction logic for MainWindow.xaml
    /// </summary>
    public partial class MainWindow : Window
    {

        private Polygon Pol1;
        ImageBrush Pol1PatternBrush = new ImageBrush();

        List<Point> listPointsLine1 = new List<Point>(new Point[] { new Point(100,100) , new Point(200,150) , new Point(300,250), new Point( 400,200), new Point( 500,100), new Point( 600,150), new Point( 700,250), new Point( 800,200), new Point( 900,250), new Point( 1000,300) });
        List<Point> listPointsLine2 = new List<Point>(new Point[] { new Point( 100,150), new Point( 200,200), new Point( 300,300), new Point( 400,250), new Point( 500,150), new Point( 600,200), new Point( 700,300), new Point( 800,250), new Point( 900,300), new Point( 1000,350)});
                
        public MainWindow()
        {
            InitializeComponent();

            //mainCanvas.Width = Convert.ToInt32(MainWindow.ActualWidthProperty.ToString()) - 20;
            //mainCanvas.Height = Convert.ToInt32(MainWindow.ActualHeightProperty.ToString()) - 20;

            //////this.SizeChanged += new SizeChangedEventHandler(MainWindow_SizeChanged);
            //////this.mainCanvas.SizeChanged += new SizeChangedEventHandler(mainCanvas_SizeChanged);
                         
            Pol1 = new Polygon();
            Pol1PatternBrush.TileMode = TileMode.Tile;
            Pol1PatternBrush.Stretch = Stretch.None;
            Pol1PatternBrush.Viewport = new System.Windows.Rect(0, 0, 118, 36);
            Pol1PatternBrush.ViewportUnits = System.Windows.Media.BrushMappingMode.Absolute;
            Pol1PatternBrush.ImageSource = new BitmapImage(new Uri(@"Images\GasPattern.jpg", UriKind.Relative));
            Pol1.Fill = Pol1PatternBrush;

            Pol1.Points = new PointCollection();

            //mainCanvas.Children.Add(Pol1);
            Pol1.Fill = Pol1PatternBrush;
            mainCanvas.Children.Add(Pol1);

 
        }

        void mainWindow_SizeChanged(object sender, SizeChangedEventArgs e)
        {
           lblWindowSize.Content = e.NewSize.ToString();
        }

        private void Slider_ValueChanged(object sender, RoutedPropertyChangedEventArgs<double> e)
        {
            double value = e.NewValue;
           
            Pol1.Points.Clear();

            if (value == 0)
            {

            }

            if (value == 10)
            {
                // Test isert 2 new items in the middle of the List<Pooint>
                //listPointsLine1.Insert(1, new Point(200, 150));
                //listPointsLine1.Insert(2, new Point(200, 200)); 

                ////PointCollection myPointCollection1 = Pol1.Points;

                //// Test isert 2 new items in the middle of the List<Pooint>
                // for (int i = 0; i < listPointsLine1.Count; i++)
                //{
                //    ////myPointCollection1.Add(listPointsLine1[i]);
                //    Pol1.Points.Add(listPointsLine1[i]);
                //}
                //---------------------------------------------------------------

                // Draw inital polygon
                Pol1.Points.Add(listPointsLine1[0]);
                Pol1.Points.Add(listPointsLine1[1]);
                Pol1.Points.Add(listPointsLine2[1]);
                Pol1.Points.Add(listPointsLine2[0]);


                var result = (from val in listPointsLine1
                              where val.X <= 200
                              select val).ToList();


                Pol1.Points.Count.ToString();
                
             }
        }

    }    
}

Open in new window

I'll work on it tomorrow (I'm off to bed now). :-)
Avatar of VPry

ASKER

Meanwhile I will try to mess with this myself using that WpfExample1 you sent me earlier.

 Thank you Guru Saragani!  Looking forward to hear from you! :)))
Ok, MVVM means Binding.
Binding means that UI need to get pontificated about property changes. The way the UI does it with it's own properties is Dependency Properties, which is an class of Microsoft.

The way we are doing to do it in our classes would be INotifyPropertyChanged, which is an interface for notifying that something got changed.

To reduce the need to implement that interface over and over again. We will call this calls ViewModelBase:

    /// <summary>
    /// Provides common functionality for ViewModel classes
    /// </summary>
    /// 
    public abstract class ViewModelBase : INotifyPropertyChanged
    {
        public event PropertyChangedEventHandler PropertyChanged;

        protected void OnPropertyChanged(string propertyName)
        {
            PropertyChangedEventHandler handler = PropertyChanged;

            if (handler != null)
            {
                handler(this, new PropertyChangedEventArgs(propertyName));
            }
        }
    }

Open in new window



Now let's take a look on how to define a property in one of your classes...

Let's assume that the class is called MainViewModel... so:

public class MainViewModel : ViewModelBase
{
    private string _name;
   
    public string Name
    {
        get
        {
            return _name;
        }
        set
        {
            _name = value;
           OnPropertyChanged("Name");
        }
    }
}

The bold text is the most important thing... this is how we notify the UI that the property called Name got changed.


Now we need to define the DataContext of our UI.
There are several ways to do it. The easiest way is by:
1) this.DataContext = new MainViewModel();
Put this line after the InitializeCompenents();

This method is not alway good since on some cases we don't want the data context to be a new instance but an existing one.


That method is called View First... cause we have defined a View and then gave it a ViewModel/DataContext.


Another way is ViewModel First... which in this case we have a some kind of Content Presenter (or content control) which is bound to some ViewModel, and by defining a DataTemplate we tell out application what UI to show...
For example, we have a ListBox with items that derive from Animal
I would like to show a picture of a cow if the item is a cow, and play a movie of a walking dog in case the animal is a dog.
I forgot to mention that in your ViewModels you don't work with List, but with ObservableCollection, since this collection has a feature that can notify the UI that items were added, removed, or whole collection was cleared.
Hi, here is a little something which I hope will help you:

MainWindow XAML:

<Window x:Class="SliderScaleCanvas.MainWindow"
        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" ResizeMode="CanResize"
        xmlns:local="clr-namespace:SliderScaleCanvas"
        Title="MainWindow" Height="600" Width="700" VerticalAlignment="Top" HorizontalAlignment="Left" x:Name="mainWindow">

    <Window.Resources>
        <local:PointsCollectionConverter x:Key="pointsCollectionConverter" />
        
        <VisualBrush x:Key="DotFillBrush"     TileMode="Tile"     Viewport="0,0,10,10"     ViewportUnits="Absolute"     Viewbox="0,0,12,12"    ViewboxUnits="Absolute">
            <VisualBrush.Visual>
                <Ellipse         Fill="#00C0FF"         Width="10" Height="10" />
            </VisualBrush.Visual>
        </VisualBrush>
        <VisualBrush       x:Key="HatchBrush"       TileMode="Tile" Viewport="0,0,10,10"       ViewportUnits="Absolute" Viewbox="0,0,10,10"          ViewboxUnits="Absolute">
            <VisualBrush.Visual>
                <Canvas>
                    <Rectangle Fill="Azure" Width="10" Height="10" />
                    <Path Stroke="Purple" Data="M 0 0 l 10 10" />
                    <Path Stroke="Purple" Data="M 0 10 l 10 -10" />
                </Canvas>
            </VisualBrush.Visual>
        </VisualBrush>
    </Window.Resources>
    
    <Window.DataContext>
        <local:MainViewModel />
    </Window.DataContext>

    <Border BorderBrush="Black" BorderThickness="2" CornerRadius="0" Padding="5">

        <Grid Name="MainGrid" Background="lightyellow"  >
            <Grid.RowDefinitions>
                <RowDefinition Height="*"/>
                <RowDefinition Height="Auto"/>
            </Grid.RowDefinitions>

            <Canvas x:Name="mainCanvas" Background="LightYellow" Margin="10">

                <StackPanel Orientation="Horizontal">
                    <TextBlock Text="Canvas Size: " Name="label1" />
                    <TextBlock  Name="lblWindowSize">
                        <Run Text="{Binding ElementName=mainWindow, Path=ActualWidth, Mode=OneWay}" />
                        <Run Text=","/>
                        <Run Text="{Binding ElementName=mainWindow, Path=ActualHeight, Mode=OneWay}"/>
                    </TextBlock>
                    <TextBlock Text=" px" Name="lblPixels"  />
                </StackPanel>

                <Polygon Points="{Binding PolygonPoints, Converter={StaticResource pointsCollectionConverter}}">
                    <Polygon.Fill>
                        <ImageBrush TileMode="Tile" Viewport="0, 0, 20, 20" Stretch="None" ViewportUnits="Absolute" ImageSource="/SliderScaleCanvas;component/Images/GasPattern.jpg" />
                    </Polygon.Fill>
                </Polygon>
            </Canvas>

            <StackPanel Orientation="Horizontal" Grid.Row="1">
                <Slider Orientation="Horizontal" AutoToolTipPlacement="TopLeft" x:Name="sldSlider" VerticalAlignment="Bottom"
                 IsSnapToTickEnabled="True" Width="400" TickPlacement="BottomRight" Background="DimGray"  
                 TickFrequency="10" Maximum="100" Height="29" Value="{Binding RegionWidthPercentage}"/>

                <StackPanel x:Name="LayoutRoot" Background="LightGreen" Width="200">
                    <StackPanel Name="stpSliderPosition" Orientation="Horizontal" Width="100">
                        <TextBlock Margin="5,5,10,5">Slider</TextBlock>
                        <TextBlock Margin="5,5,0,5" TextAlignment="Left" Width="30" Text="{Binding Path=Value, ElementName=sldSlider, Mode=OneWay}" />
                        <TextBlock Margin="0,5">%</TextBlock>
                    </StackPanel>
                </StackPanel>
            </StackPanel>
        </Grid>
    </Border>
</Window> 

-------------------------------------------------------------------------------------------------------------------------

MainWindow.cs Code (No Code!!!!):

using System.Windows;

namespace SliderScaleCanvas
{
    /// <summary>
    /// Interaction logic for MainWindow.xaml
    /// </summary>
    public partial class MainWindow : Window
    {
        public MainWindow()
        {
            InitializeComponent();
        }
    }
}


---------------------------------------------------------------------------------

ViewModelBase.cs:

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.ComponentModel;

namespace SliderScaleCanvas
{
    /// <summary>
    /// Provides common functionality for ViewModel classes
    /// </summary>
    /// 
    public abstract class ViewModelBase : INotifyPropertyChanged
    {
        public event PropertyChangedEventHandler PropertyChanged;

        protected void OnPropertyChanged(string propertyName)
        {
            PropertyChangedEventHandler handler = PropertyChanged;

            if (handler != null)
            {
                handler(this, new PropertyChangedEventArgs(propertyName));
            }
        }
    }
}

----------------------------------------------------------------------------------------------------

MainViewModel.cs:

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Collections.ObjectModel;
using System.Windows;

namespace SliderScaleCanvas
{
    public class MainViewModel : ViewModelBase
    {
        private int _regionWidthPercentage = 0;
        private List<Point> points = new List<Point>();

        List<Point> listPointsLine1 = new List<Point>(new Point[] { new Point(100, 100), new Point(200, 150), new Point(300, 250), new Point(400, 200), new Point(500, 100), new Point(600, 150), new Point(700, 250), new Point(800, 200), new Point(900, 250), new Point(1000, 300) });
        List<Point> listPointsLine2 = new List<Point>(new Point[] { new Point(100, 150), new Point(200, 200), new Point(300, 300), new Point(400, 250), new Point(500, 150), new Point(600, 200), new Point(700, 300), new Point(800, 250), new Point(900, 300), new Point(1000, 350) });


        public MainViewModel()
        {
            

        }

        public int RegionWidthPercentage
        {
            get
            {
                return _regionWidthPercentage;
            }
            set
            {
                _regionWidthPercentage = value;
                OnPropertyChanged("RegionWidthPercentage");
                setPoints();
            }
        }


        private void setPoints()
        {
            points.Clear();

            var inBoundsPoitns = from val in listPointsLine1
                                 where val.X <= 10 * RegionWidthPercentage
                                 orderby val.X ascending
                                 select val;

            points.AddRange(inBoundsPoitns);

            inBoundsPoitns = from val in listPointsLine2
                             where val.X <= 10 * RegionWidthPercentage
                             orderby val.X descending
                             select val;

            points.AddRange(inBoundsPoitns);

            OnPropertyChanged("PolygonPoints");
        }
        

        public ReadOnlyCollection<Point> PolygonPoints
        {
            get
            {
                return new ReadOnlyCollection<Point>(points); 
            }
            set
            {
                points = new List<Point>(value);

                OnPropertyChanged("PolygonPoints");
            }
        }
    }
}

---------------------------------------------------------------------------------------------

PointsCollectionConverter.cs:

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows.Data;
using System.Windows.Media;
using System.Windows;

namespace SliderScaleCanvas
{
    public class PointsCollectionConverter : IValueConverter
    {
        public object Convert(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
        {
            IEnumerable<Point> enumerable = value as IEnumerable<Point>;
            PointCollection points = null;
            if (enumerable != null)
            {
                points = new PointCollection(enumerable);
            }
            return points;
        }

        public object ConvertBack(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
        {
            throw new NotSupportedException("ConvertBack should never be called");
        }
    }
}

Open in new window


Avatar of VPry

ASKER

Hi Saragani, I am getting many reference errors after I added these classes to my project. Could you zip working version of this solution and email to me? vadymgpr@yahoo.com Thank you!
Avatar of VPry

ASKER

Ignore my previous comment. I think I got it. Where is this image folder suppose to be in my project?

 ImageSource="/SliderScaleCanvas;component/Images/GasPattern.jpg"
ASKER CERTIFIED SOLUTION
Avatar of saragani
saragani

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of VPry

ASKER

Saragani, it’s AWESOME! I accept this as solution! :)))

What I would like to do next with this app is to read Points from SQL Server DB with WCF.

Do you have WCF experience? I am going to open a new question in WCF section to continue with this project. Also I need to come up with design for the DB Table to hold my Points data. May be you can help with this as well?

Thanks a lot! :)))
Avatar of VPry

ASKER

Excellent guidance and help from Saragani! Short and straight to the point.  Easy to understand and follow. Very nice! :)))
I know nothing about WCF
Sorry
Avatar of VPry

ASKER

Hi Saragani, I have created root folder Images in my old project with GasPattern.jpg file. I build solution without errors. But when I run it I get an exception. It can not locate this image path:

<ImageBrush TileMode="Tile" Viewport="0, 0, 20, 20" Stretch="None" ViewportUnits="Absolute" ImageSource="/SliderScaleCanvas;component/Images/GasPattern.jpg" />

Why?

The image must be defined (properties) as "never copy" and as a resource.
Avatar of VPry

ASKER

OK, Thanks!

Saragani, here is my new post regarding WCF for this project. Lets continue there if you can help me:

https://www.experts-exchange.com/questions/27046887/Access-SQL-Server-with-WCF-example.html
Avatar of VPry

ASKER

Hi Saragani, I sent you an email yesterday. Did you have a chance to look at what I sent? Thank you! :)))
I think I never got it
Let me check my spam
Not in spam either
Avatar of VPry

ASKER

Just resended again.
Avatar of VPry

ASKER

Did you get my email this time?
Still nothing, and I don't know WCF
Avatar of VPry

ASKER

It's not about WCF. Ok, I post it here:
Please take a look at my initial prototype app SquigglyLines (attached to my email).
 
As you see it outlines Polygon created by Points between 4 lines. The number of Lines may vary. But we assume that they are always one above another. Area between 2 points on the one line and 2 points on the other line is Polygon. Polygons are stacked one on the top of each other.
 
  I need my application to be smart enough to draw these Polygons properly. Initially I thought to use Array or List (like you suggested) to insert new Points in the middle of it because of how geometry class draws them.
 
If I add another Lines to your example:
 
List<Point> listPointsLine3 = new List<Point>(new Point[] { new Point(100, 300), new Point(200, 350), new Point(300, 450), new Point(400, 400), new Point(500, 300), new Point(600, 350), new Point(700, 450), new Point(800, 400), new Point(900, 450), new Point(1000, 500) });
 
List<Point> listPointsLine4 = new List<Point>(new Point[] { new Point(100, 550), new Point(200, 600), new Point(300, 700), new Point(400, 650), new Point(500, 550), new Point(600, 600), new Point(700, 700), new Point(800, 650), new Point(900, 700), new Point(1000, 750) });
 
........................
 
// 3rd Line Points
inBoundsPoitns = from val in listPointsLine3
where val.X <= 10 * RegionWidthPercentage
orderby val.X descending
select val;
 
points.AddRange(inBoundsPoitns);
 
// 4th Line Points
inBoundsPoitns = from val in listPointsLine4
where val.X <= 10 * RegionWidthPercentage
orderby val.X descending
select val;
 
points.AddRange(inBoundsPoitns);
 
 Polygons are drawn not correctly (not like in my hardcoded prototype).
 
...........................................
 
So, the pattern is:
 
Suppose we have 3 lines. Each line has 4 Points.
   Line1 = Points(1,2,3,4)
   Line2 = Points(5,6,7,8)
   Line3 = Points(9,10,11,12)
 
So we have 6 polygons between these points:
   
                           1---2---3---4
                           |   |   |   |
                           5---6---7---8
                           |   |   |   |
                           9--10--11--12
 
If I display 10% of the Canvas and Points 1,2,5,6,9,10 in it then:
 
   Polygon1 = Points(1,2,6,5)   <- Draw 1st top left Polygon
   Polygon2 = Points(5,6,10,9)  <- 2nd Polygon under 1st one
 
Next, 20% of the Canvas:
   
   Polygon1 = Points(1,2,  3,7   6,5)   <- Draw 1st top left Polygon
   (3 and 7 are new Points inserted in the middle of List<Points>)
 
   Polygon2 = Points(5,6,  7,11  10,9)  <- 2nd Polygon under 1st one
   (7 and 11 are new Points inserted in the middle of List<Points>)
 
and so on...
 
 Also, this XAML needs to be changed to allow more then one Polygon area and different ImageBrushes:
 
<Polygon Points="{Binding PolygonPoints, Converter={StaticResource pointsCollectionConverter}}">
<Polygon.Fill>
<ImageBrush TileMode="Tile" Viewport="0, 0, 20, 20" Stretch="None" ViewportUnits="Absolute" ImageSource="/SliderScaleCanvas;component/Images/GasPattern.jpg" />
</Polygon.Fill>
</Polygon>
 
What are your thoughts? It more tought then I thought :\  Thank you for all your help! :)))
Avatar of VPry

ASKER

Here is hardcoded prototype:
<Window x:Class="SquigglyLines.Window1" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    Title="Squiggly Lines Demo" Height="720" Width="960"
    WindowStyle="None" AllowsTransparency="True" WindowStartupLocation="CenterScreen"
    Background="Transparent" ResizeMode="CanMinimize">
    <Window.Resources>
        <LinearGradientBrush x:Key="WindowFrameBrush" StartPoint="0,0.5" EndPoint="1,0.5">
            <GradientStop Color="CadetBlue" Offset="0.4"/>
            <GradientStop Color="Gray" Offset="1"/>
        </LinearGradientBrush>

        <VisualBrush  x:Key="DotFillBrush" 
            TileMode="Tile" Viewport="0,0,10,10" ViewportUnits="Absolute" 
            Viewbox="0,0,12,12" ViewboxUnits="Absolute">
            <VisualBrush.Visual>
                <Ellipse         Fill="#00C0FF"         Width="10" Height="10" />
            </VisualBrush.Visual>
        </VisualBrush>
        <VisualBrush       x:Key="HatchBrush"       TileMode="Tile" Viewport="0,0,10,10"       ViewportUnits="Absolute" Viewbox="0,0,10,10"          ViewboxUnits="Absolute">
            <VisualBrush.Visual>
                <Canvas>
                    <Rectangle Fill="Azure" Width="10" Height="10" />
                    <Path Stroke="Purple" Data="M 0 0 l 10 10" />
                    <Path Stroke="Purple" Data="M 0 10 l 10 -10" />
                </Canvas>
            </VisualBrush.Visual>
        </VisualBrush>
    </Window.Resources>

    <Border Background="#50FFFFFF" CornerRadius="5" BorderBrush="{StaticResource WindowFrameBrush}" BorderThickness="2,0,2,2">
        <Grid>
            <Grid.RowDefinitions>
                <RowDefinition Height="30" />
                <RowDefinition/>
            </Grid.RowDefinitions>
            <Border Background="{StaticResource WindowFrameBrush}" HorizontalAlignment="Stretch" VerticalAlignment="Stretch"
              CornerRadius="5,5,0,0" Margin="-1,0,-1,0" MouseLeftButtonDown="DragWindow">
                <Grid>
                    <TextBlock Foreground="White" FontWeight="Bold" VerticalAlignment="Center" Margin="10,2,10,2"
            Text="{Binding RelativeSource={RelativeSource Mode=FindAncestor, AncestorType={x:Type Window}}, Path=Title}"/>
                    
                    <!--<Button Content="O" Name="MinMax" HorizontalAlignment="Right" VerticalAlignment="Center" Margin="0,0,25,0" FontSize="7"
                  Width="15" Height="15" Click="WindowMinMax" />-->
                    
                    <Button Content="X" HorizontalAlignment="Right" VerticalAlignment="Center" Margin="5" FontSize="7"
                  Width="15" Height="15" Padding="0" Command="ApplicationCommands.Close"/>
                </Grid>
            </Border>

            <!-- Begin Main Content-->
           
            <Grid VerticalAlignment="Center" HorizontalAlignment="Center" Margin="0, 35,0,0" >


                    <Canvas x:Name="mainCanvas" Background="Transparent" Height="670" Width="920" VerticalAlignment="Top" Margin="0,0,0,200">
                        <Canvas.LayoutTransform>
                            <ScaleTransform ScaleX="{Binding Path=Value, ElementName=zoomSlider}" 
                            ScaleY="{Binding Path=Value, ElementName=zoomSlider}"/>
                        </Canvas.LayoutTransform>

                    <!-- Begin Test Pattern Brushes
                        
                    <Rectangle Canvas.Top="20" Canvas.Left="20"   Width="80" Height="40"   Fill="{StaticResource DotFillBrush}"/>
                    <Rectangle Canvas.Top="20" Canvas.Left="120"   Width="80" Height="40"   Fill="{StaticResource HatchBrush}"/>
                    <TextBlock Canvas.Top="80" Canvas.Left="20"   Text="Hello" FontSize="80"   Foreground="{StaticResource DotFillBrush}"/>
                    <TextBlock Canvas.Top="80" Canvas.Left="220"   Text="World" FontSize="80"   Foreground="{StaticResource HatchBrush}"/>
                    
                    End Test Pattern Brushes -->
                        

                    <!-- Polygon Name="Blue" Points="   100, 100  200, 150  300, 250  400, 200  500, 100  600, 150  700, 250  800, 200  900, 250  1000, 300                              
                                                   1000, 350  900, 300  800, 250  700, 300  600, 200  500, 150  400, 250  300, 300  200, 200  100, 150 ">
                        <Polygon.Fill>
                            <SolidColorBrush Color="Blue"/>
                        </Polygon.Fill>
                    </Polygon -->


                    <!--<Polygon Name="Green"
                     Points="1000,350  900,300   800,250  700, 300   600, 200    500, 150    400, 250    300, 300    200, 200    100, 150    100, 300    200, 350    300, 450    400, 400    500, 300    600, 350    700, 450    800, 400    900, 450    1000, 500 ">
                        <Polygon.Fill>
                            <SolidColorBrush Color="Green"/>
                        </Polygon.Fill>
                    </Polygon>-->

                    <!--<Polygon Name="Brown" Points="100, 300  200, 350  300, 450  400, 400   
                                                      500, 300       600, 350       700, 450       800, 400    
                                                      900, 450       1000, 500       1000, 750       900, 700                              
                                                      800, 650       700, 700       600, 600       500, 550                              
                                                      400, 650       300, 700       200, 600       100, 550">
                        <Polygon.Fill>
                            <SolidColorBrush Color="Brown"/>
                        </Polygon.Fill>
                    </Polygon>-->
                        
                    <!-- Begin Canvas Border -->
                    <Line Stroke="Gray" StrokeThickness="2" Canvas.Bottom="0" Y1="670"></Line>
                    <Line Stroke="Gray" StrokeThickness="2" Canvas.Bottom="0" X1="920"></Line>
                    <Line Stroke="Gray" StrokeThickness="2" Canvas.Right="0" Y1="670"></Line>
                    <Line Stroke="Gray" StrokeThickness="2" Canvas.Right="0" X1="920"></Line>
                    <!-- End Canvas Border -->
                        
                 <Slider Orientation="Horizontal" AutoToolTipPlacement="TopLeft" Canvas.Bottom="0"
                 IsSnapToTickEnabled="True" Width="400" TickPlacement="BottomRight" Background="DimGray"  
                 TickFrequency="1" Maximum="9" ValueChanged="Slider_ValueChanged" Height="29" />
             </Canvas>
            </Grid>
            <!-- End Main Content -->
            
            
        </Grid>
    </Border>
</Window>
-----------------------------------------------------------------------------------------------------------------
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;


namespace SquigglyLines
{
    /// <summary>
    /// Interaction logic for Page1.xaml
    /// </summary>
    public partial class Window1 : Window
    {
        private Polygon Pol1;
        private Polygon Pol2;
        private Polygon Pol3;
        ImageBrush Pol1PatternBrush = new ImageBrush();
        ImageBrush Pol2PatternBrush = new ImageBrush();
        ImageBrush Pol3PatternBrush = new ImageBrush();

        public Window1()
        {
            InitializeComponent();
            this.Topmost = true;
            CommandBindings.Add(new CommandBinding(ApplicationCommands.Close,
               new ExecutedRoutedEventHandler(delegate(object sender, ExecutedRoutedEventArgs args) { this.Close(); })));
            
            // Done in XAML
            //WindowStartupLocation = System.Windows.WindowStartupLocation.CenterScreen;

            InitializeComponent();
            Pol1 = new Polygon();
            Pol2 = new Polygon();
            Pol3 = new Polygon();
            
            Pol1PatternBrush.TileMode = TileMode.Tile;
            Pol1PatternBrush.Stretch = Stretch.None;
            Pol1PatternBrush.Viewport = new System.Windows.Rect(0, 0, 118, 36);
            Pol1PatternBrush.ViewportUnits = System.Windows.Media.BrushMappingMode.Absolute;
            Pol1PatternBrush.ImageSource = new BitmapImage(new Uri(@"Images\GasPattern.jpg", UriKind.Relative));
            Pol1.Fill = Pol1PatternBrush;

            Pol2PatternBrush.TileMode = TileMode.Tile;
            Pol2PatternBrush.Stretch = Stretch.None;
            Pol2PatternBrush.Viewport = new System.Windows.Rect(0, 0, 118, 36);
            Pol2PatternBrush.ViewportUnits = System.Windows.Media.BrushMappingMode.Absolute;
            Pol2PatternBrush.ImageSource = new BitmapImage(new Uri(@"Images\SandStonePattern.jpg", UriKind.Relative));
            Pol2.Fill = Pol2PatternBrush;

            Pol3PatternBrush.TileMode = TileMode.Tile;
            Pol3PatternBrush.Stretch = Stretch.None;
            Pol3PatternBrush.Viewport = new System.Windows.Rect(0, 0, 118, 36);
            Pol3PatternBrush.ViewportUnits = System.Windows.Media.BrushMappingMode.Absolute;       
            Pol3PatternBrush.ImageSource = new BitmapImage(new Uri(@"Images\OilPattern.jpg", UriKind.Relative));
            Pol3.Fill = Pol3PatternBrush;

            //Viewport="0,0,300,300"
            //ViewportUnits="Absolute"
            //TileMode="Tile"
            //Stretch="None"
            //AlignmentX="Left"
            //AlignmentY="Top"  />

            
       
            Pol1.Opacity = 0.7;
            Pol2.Opacity = 0.7;
            Pol3.Opacity = 0.7;
            Pol1.Points = new PointCollection();
            Pol2.Points = new PointCollection();
            Pol3.Points = new PointCollection();

            mainCanvas.Children.Add(Pol1);
            mainCanvas.Children.Add(Pol2);
            mainCanvas.Children.Add(Pol3);

            // Move all polygons up & left 
            TranslateTransform translateTransform1 = new TranslateTransform(-300, -100);

            Pol1.RenderTransform = translateTransform1;
            Pol2.RenderTransform = translateTransform1;
            Pol3.RenderTransform = translateTransform1;

            // Make all polygons smaller
            ScaleTransform scaleTransform1 = new ScaleTransform(0.8, 0.8);

            Pol1.RenderTransform = scaleTransform1;
            Pol2.RenderTransform = scaleTransform1;
            Pol3.RenderTransform = scaleTransform1;

        }

        public void DragWindow(object sender, MouseButtonEventArgs args)
        {
            DragMove();
        }

        private void Slider_ValueChanged(object sender, RoutedPropertyChangedEventArgs<double> e)
        {

            double value = e.NewValue;
            Pol1.Points.Clear();
            Pol2.Points.Clear();
            Pol3.Points.Clear();

            if (value == 0)
            {

            }

            if (value == 1)
            {                
                // BLUE
                //p.Points = new PointCollection() { new Point(100, 100), new Point(200, 150), new Point(300, 250), new Point(400, 200), 
                //new Point(500, 100), new Point(600, 150), new Point(700, 250), new Point(800, 200), 
                //new Point(900, 250), new Point(1000, 300), new Point(1000, 350), new Point(900, 300), 
                //new Point(800, 250), new Point(700, 300), new Point(600, 200), new Point(500, 150), 
                //new Point(400, 250), new Point(300, 300), new Point(200, 200), new Point(100, 150) };

                System.Windows.Point Point1_1 = new System.Windows.Point(100, 100);
                System.Windows.Point Point1_2 = new System.Windows.Point(200, 150);
                System.Windows.Point Point1_3 = new System.Windows.Point(200, 200);
                System.Windows.Point Point1_4 = new System.Windows.Point(100, 150);

                PointCollection myPointCollection1 = Pol1.Points;

                myPointCollection1.Add(Point1_1);
                myPointCollection1.Add(Point1_2);
                myPointCollection1.Add(Point1_3);
                myPointCollection1.Add(Point1_4);

                // GREEN
                // 1.Points = new PointCollection() { new Point( 1000,350  900,300   800,250  700, 300   600, 200    500, 150    400, 250    300, 300    200, 200    100, 150    100, 300    200, 350    300, 450    400, 400    500, 300    600, 350    700, 450    800, 400    900, 450    1000, 500 "
                
                System.Windows.Point Point2_1 = new System.Windows.Point(100, 150);
                System.Windows.Point Point2_2 = new System.Windows.Point(200, 200);
                System.Windows.Point Point2_3 = new System.Windows.Point(200, 350);
                System.Windows.Point Point2_4 = new System.Windows.Point(100, 300);

                PointCollection myPointCollection2 = Pol2.Points;

                myPointCollection2.Add(Point2_1);
                myPointCollection2.Add(Point2_2);
                myPointCollection2.Add(Point2_3);
                myPointCollection2.Add(Point2_4);
                
                // BROWN
                //p2.Points = new PointCollection() { new Point(100, 300), new Point(200, 350), new Point(300, 450), new Point(400, 400), 
                //                                    new Point(500, 300), new Point(600, 350), new Point(700, 450), new Point(800, 400), 
                //                                    new Point(900, 450), new Point(1000, 500), new Point(1000, 750), new Point(900, 700), 
                //                                    new Point(800, 650), new Point(700, 700), new Point(600, 600), new Point(500, 550), 
                //                                    new Point(400, 650), new Point(300, 700), new Point(200, 600), new Point(100, 550) };

                System.Windows.Point Point3_1 = new System.Windows.Point(100, 300);
                System.Windows.Point Point3_2 = new System.Windows.Point(200, 350);
                System.Windows.Point Point3_3 = new System.Windows.Point(200, 600);
                System.Windows.Point Point3_4 = new System.Windows.Point(100, 550);

                PointCollection myPointCollection3 = Pol3.Points;

                myPointCollection3.Add(Point3_1);
                myPointCollection3.Add(Point3_2);
                myPointCollection3.Add(Point3_3);
                myPointCollection3.Add(Point3_4);

            }

            if (value == 2)
            {
                // BLUE
                System.Windows.Point Point1_1 = new System.Windows.Point(100, 100);
                System.Windows.Point Point1_2 = new System.Windows.Point(200, 150);
                System.Windows.Point Point1_3 = new System.Windows.Point(300, 250);
                System.Windows.Point Point1_4 = new System.Windows.Point(300, 300);
                System.Windows.Point Point1_5 = new System.Windows.Point(200, 200);
                System.Windows.Point Point1_6 = new System.Windows.Point(100, 150);

                PointCollection myPointCollection1 = Pol1.Points;

                myPointCollection1.Add(Point1_1);
                myPointCollection1.Add(Point1_2);
                myPointCollection1.Add(Point1_3);
                myPointCollection1.Add(Point1_4);
                myPointCollection1.Add(Point1_5);
                myPointCollection1.Add(Point1_6);

                // GREEN
                // 1.Points = new PointCollection() { new Point( 1000,350  900,300   800,250  700, 300   600, 200    500, 150    400, 250    300, 300    200, 200    100, 150    100, 300    200, 350    300, 450    400, 400    500, 300    600, 350    700, 450    800, 400    900, 450    1000, 500 "
                System.Windows.Point Point2_1 = new System.Windows.Point(100, 150);
                System.Windows.Point Point2_2 = new System.Windows.Point(200, 200);
                System.Windows.Point Point2_3 = new System.Windows.Point(300, 300);
                System.Windows.Point Point2_4 = new System.Windows.Point(300, 450);
                System.Windows.Point Point2_5 = new System.Windows.Point(200, 350);
                System.Windows.Point Point2_6 = new System.Windows.Point(100, 300);

                PointCollection myPointCollection2 = Pol2.Points;

                myPointCollection2.Add(Point2_1);
                myPointCollection2.Add(Point2_2);
                myPointCollection2.Add(Point2_3);
                myPointCollection2.Add(Point2_4);
                myPointCollection2.Add(Point2_5);
                myPointCollection2.Add(Point2_6);

                // BROWN
                System.Windows.Point Point3_1 = new System.Windows.Point(100, 300);
                System.Windows.Point Point3_2 = new System.Windows.Point(200, 350);
                System.Windows.Point Point3_3 = new System.Windows.Point(300, 450);
                System.Windows.Point Point3_4 = new System.Windows.Point(300, 700);
                System.Windows.Point Point3_5 = new System.Windows.Point(200, 600);
                System.Windows.Point Point3_6 = new System.Windows.Point(100, 550);

                PointCollection myPointCollection3 = Pol3.Points;

                myPointCollection3.Add(Point3_1);
                myPointCollection3.Add(Point3_2);
                myPointCollection3.Add(Point3_3);
                myPointCollection3.Add(Point3_4);
                myPointCollection3.Add(Point3_5);
                myPointCollection3.Add(Point3_6);
            }

            if (value == 3)
            {
                // BLUE
                System.Windows.Point Point1_1 = new System.Windows.Point(100, 100);
                System.Windows.Point Point1_2 = new System.Windows.Point(200, 150);
                System.Windows.Point Point1_3 = new System.Windows.Point(300, 250);
                System.Windows.Point Point1_4 = new System.Windows.Point(400, 200);
                System.Windows.Point Point1_5 = new System.Windows.Point(400, 250);
                System.Windows.Point Point1_6 = new System.Windows.Point(300, 300);
                System.Windows.Point Point1_7 = new System.Windows.Point(200, 200);
                System.Windows.Point Point1_8 = new System.Windows.Point(100, 150);

                PointCollection myPointCollection1 = Pol1.Points;

                myPointCollection1.Add(Point1_1);
                myPointCollection1.Add(Point1_2);
                myPointCollection1.Add(Point1_3);
                myPointCollection1.Add(Point1_4);
                myPointCollection1.Add(Point1_5);
                myPointCollection1.Add(Point1_6);
                myPointCollection1.Add(Point1_7);
                myPointCollection1.Add(Point1_8);

                // GREEN
                // 1.Points = new PointCollection() { new Point( 1000,350  900,300   800,250  700, 300   600, 200    500, 150    400, 250    300, 300    200, 200    100, 150    100, 300    200, 350    300, 450    400, 400    500, 300    600, 350    700, 450    800, 400    900, 450    1000, 500 "
                System.Windows.Point Point2_1 = new System.Windows.Point(100, 150);
                System.Windows.Point Point2_2 = new System.Windows.Point(200, 200);
                System.Windows.Point Point2_3 = new System.Windows.Point(300, 300);
                System.Windows.Point Point2_4 = new System.Windows.Point(400, 250);
                System.Windows.Point Point2_5 = new System.Windows.Point(400, 400);
                System.Windows.Point Point2_6 = new System.Windows.Point(300, 450);
                System.Windows.Point Point2_7 = new System.Windows.Point(200, 350);
                System.Windows.Point Point2_8 = new System.Windows.Point(100, 300);

                PointCollection myPointCollection2 = Pol2.Points;

                myPointCollection2.Add(Point2_1);
                myPointCollection2.Add(Point2_2);
                myPointCollection2.Add(Point2_3);
                myPointCollection2.Add(Point2_4);
                myPointCollection2.Add(Point2_5);
                myPointCollection2.Add(Point2_6);
                myPointCollection2.Add(Point2_7);
                myPointCollection2.Add(Point2_8);

                // BROWN
                System.Windows.Point Point3_1 = new System.Windows.Point(100, 300);
                System.Windows.Point Point3_2 = new System.Windows.Point(200, 350);
                System.Windows.Point Point3_3 = new System.Windows.Point(300, 450);
                System.Windows.Point Point3_4 = new System.Windows.Point(400, 400);
                System.Windows.Point Point3_5 = new System.Windows.Point(400, 650);
                System.Windows.Point Point3_6 = new System.Windows.Point(300, 700);
                System.Windows.Point Point3_7 = new System.Windows.Point(200, 600);
                System.Windows.Point Point3_8 = new System.Windows.Point(100, 550);

                PointCollection myPointCollection3 = Pol3.Points;

                myPointCollection3.Add(Point3_1);
                myPointCollection3.Add(Point3_2);
                myPointCollection3.Add(Point3_3);
                myPointCollection3.Add(Point3_4);
                myPointCollection3.Add(Point3_5);
                myPointCollection3.Add(Point3_6);
                myPointCollection3.Add(Point3_7);
                myPointCollection3.Add(Point3_8);
            }
            
            if (value == 4)
            {
                // BLUE
                System.Windows.Point Point1_1 = new System.Windows.Point(100, 100);
                System.Windows.Point Point1_2 = new System.Windows.Point(200, 150);
                System.Windows.Point Point1_3 = new System.Windows.Point(300, 250);
                System.Windows.Point Point1_4 = new System.Windows.Point(400, 200);
                System.Windows.Point Point1_5 = new System.Windows.Point(500, 100);
                System.Windows.Point Point1_6 = new System.Windows.Point(500, 150);
                System.Windows.Point Point1_7 = new System.Windows.Point(400, 250);
                System.Windows.Point Point1_8 = new System.Windows.Point(300, 300);
                System.Windows.Point Point1_9 = new System.Windows.Point(200, 200);
                System.Windows.Point Point1_10 = new System.Windows.Point(100, 150);

                PointCollection myPointCollection1 = Pol1.Points;

                myPointCollection1.Add(Point1_1);
                myPointCollection1.Add(Point1_2);
                myPointCollection1.Add(Point1_3);
                myPointCollection1.Add(Point1_4);
                myPointCollection1.Add(Point1_5);
                myPointCollection1.Add(Point1_6);
                myPointCollection1.Add(Point1_7);
                myPointCollection1.Add(Point1_8);
                myPointCollection1.Add(Point1_9);
                myPointCollection1.Add(Point1_10);

                // GREEN
                // 1.Points = new PointCollection() { new Point( 1000,350  900,300   800,250  700, 300   600, 200    500, 150    400, 250    300, 300    200, 200    100, 150    100, 300    200, 350    300, 450    400, 400    500, 300    600, 350    700, 450    800, 400    900, 450    1000, 500 "
                System.Windows.Point Point2_1 = new System.Windows.Point(100, 150);
                System.Windows.Point Point2_2 = new System.Windows.Point(200, 200);
                System.Windows.Point Point2_3 = new System.Windows.Point(300, 300);
                System.Windows.Point Point2_4 = new System.Windows.Point(400, 250);
                System.Windows.Point Point2_5 = new System.Windows.Point(500, 150);
                System.Windows.Point Point2_6 = new System.Windows.Point(500, 300);
                System.Windows.Point Point2_7 = new System.Windows.Point(400, 400);
                System.Windows.Point Point2_8 = new System.Windows.Point(300, 450);
                System.Windows.Point Point2_9 = new System.Windows.Point(200, 350);
                System.Windows.Point Point2_10 = new System.Windows.Point(100, 300);

                PointCollection myPointCollection2 = Pol2.Points;

                myPointCollection2.Add(Point2_1);
                myPointCollection2.Add(Point2_2);
                myPointCollection2.Add(Point2_3);
                myPointCollection2.Add(Point2_4);
                myPointCollection2.Add(Point2_5);
                myPointCollection2.Add(Point2_6);
                myPointCollection2.Add(Point2_7);
                myPointCollection2.Add(Point2_8);
                myPointCollection2.Add(Point2_9);
                myPointCollection2.Add(Point2_10);

                // BROWN
                System.Windows.Point Point3_1 = new System.Windows.Point(100, 300);
                System.Windows.Point Point3_2 = new System.Windows.Point(200, 350);
                System.Windows.Point Point3_3 = new System.Windows.Point(300, 450);
                System.Windows.Point Point3_4 = new System.Windows.Point(400, 400);
                System.Windows.Point Point3_5 = new System.Windows.Point(500, 300);
                System.Windows.Point Point3_6 = new System.Windows.Point(500, 550);
                System.Windows.Point Point3_7 = new System.Windows.Point(400, 650);
                System.Windows.Point Point3_8 = new System.Windows.Point(300, 700);
                System.Windows.Point Point3_9 = new System.Windows.Point(200, 600);
                System.Windows.Point Point3_10 = new System.Windows.Point(100, 550);

                PointCollection myPointCollection3 = Pol3.Points;

                myPointCollection3.Add(Point3_1);
                myPointCollection3.Add(Point3_2);
                myPointCollection3.Add(Point3_3);
                myPointCollection3.Add(Point3_4);
                myPointCollection3.Add(Point3_5);
                myPointCollection3.Add(Point3_6);
                myPointCollection3.Add(Point3_7);
                myPointCollection3.Add(Point3_8);
                myPointCollection3.Add(Point3_9);
                myPointCollection3.Add(Point3_10);
            }

            if (value == 5)
            {
                // BLUE
                System.Windows.Point Point1_1 = new System.Windows.Point(100, 100);
                System.Windows.Point Point1_2 = new System.Windows.Point(200, 150);
                System.Windows.Point Point1_3 = new System.Windows.Point(300, 250);
                System.Windows.Point Point1_4 = new System.Windows.Point(400, 200);
                System.Windows.Point Point1_5 = new System.Windows.Point(500, 100);
                System.Windows.Point Point1_6 = new System.Windows.Point(600, 150);
                System.Windows.Point Point1_7 = new System.Windows.Point(600, 200);
                System.Windows.Point Point1_8 = new System.Windows.Point(500, 150);
                System.Windows.Point Point1_9 = new System.Windows.Point(400, 250);
                System.Windows.Point Point1_10 = new System.Windows.Point(300, 300);
                System.Windows.Point Point1_11 = new System.Windows.Point(200, 200);
                System.Windows.Point Point1_12 = new System.Windows.Point(100, 150);

                PointCollection myPointCollection1 = Pol1.Points;

                myPointCollection1.Add(Point1_1);
                myPointCollection1.Add(Point1_2);
                myPointCollection1.Add(Point1_3);
                myPointCollection1.Add(Point1_4);
                myPointCollection1.Add(Point1_5);
                myPointCollection1.Add(Point1_6);
                myPointCollection1.Add(Point1_7);
                myPointCollection1.Add(Point1_8);
                myPointCollection1.Add(Point1_9);
                myPointCollection1.Add(Point1_10);
                myPointCollection1.Add(Point1_11);
                myPointCollection1.Add(Point1_12);

                // GREEN                
                System.Windows.Point Point2_1 = new System.Windows.Point(100, 150);
                System.Windows.Point Point2_2 = new System.Windows.Point(200, 200);
                System.Windows.Point Point2_3 = new System.Windows.Point(300, 300);
                System.Windows.Point Point2_4 = new System.Windows.Point(400, 250);
                System.Windows.Point Point2_5 = new System.Windows.Point(500, 150);
                System.Windows.Point Point2_6 = new System.Windows.Point(600, 200);
                System.Windows.Point Point2_7 = new System.Windows.Point(600, 350);
                System.Windows.Point Point2_8 = new System.Windows.Point(500, 300);
                System.Windows.Point Point2_9 = new System.Windows.Point(400, 400);
                System.Windows.Point Point2_10 = new System.Windows.Point(300, 450);
                System.Windows.Point Point2_11 = new System.Windows.Point(200, 350);
                System.Windows.Point Point2_12 = new System.Windows.Point(100, 300);

                PointCollection myPointCollection2 = Pol2.Points;

                myPointCollection2.Add(Point2_1);
                myPointCollection2.Add(Point2_2);
                myPointCollection2.Add(Point2_3);
                myPointCollection2.Add(Point2_4);
                myPointCollection2.Add(Point2_5);
                myPointCollection2.Add(Point2_6);
                myPointCollection2.Add(Point2_7);
                myPointCollection2.Add(Point2_8);
                myPointCollection2.Add(Point2_9);
                myPointCollection2.Add(Point2_10);
                myPointCollection2.Add(Point2_11);
                myPointCollection2.Add(Point2_12);

                // BROWN
                System.Windows.Point Point3_1 = new System.Windows.Point(100, 300);
                System.Windows.Point Point3_2 = new System.Windows.Point(200, 350);
                System.Windows.Point Point3_3 = new System.Windows.Point(300, 450);
                System.Windows.Point Point3_4 = new System.Windows.Point(400, 400);
                System.Windows.Point Point3_5 = new System.Windows.Point(500, 300);
                System.Windows.Point Point3_6 = new System.Windows.Point(600, 350);
                System.Windows.Point Point3_7 = new System.Windows.Point(600, 600);
                System.Windows.Point Point3_8 = new System.Windows.Point(500, 550);
                System.Windows.Point Point3_9 = new System.Windows.Point(400, 650);
                System.Windows.Point Point3_10 = new System.Windows.Point(300, 700);
                System.Windows.Point Point3_11 = new System.Windows.Point(200, 600);
                System.Windows.Point Point3_12 = new System.Windows.Point(100, 550);

                PointCollection myPointCollection3 = Pol3.Points;

                myPointCollection3.Add(Point3_1);
                myPointCollection3.Add(Point3_2);
                myPointCollection3.Add(Point3_3);
                myPointCollection3.Add(Point3_4);
                myPointCollection3.Add(Point3_5);
                myPointCollection3.Add(Point3_6);
                myPointCollection3.Add(Point3_7);
                myPointCollection3.Add(Point3_8);
                myPointCollection3.Add(Point3_9);
                myPointCollection3.Add(Point3_10);
                myPointCollection3.Add(Point3_11);
                myPointCollection3.Add(Point3_12);
            }

            if (value == 6)
            {
                // BLUE
                System.Windows.Point Point1_1 = new System.Windows.Point(100, 100);
                System.Windows.Point Point1_2 = new System.Windows.Point(200, 150);
                System.Windows.Point Point1_3 = new System.Windows.Point(300, 250);
                System.Windows.Point Point1_4 = new System.Windows.Point(400, 200);
                System.Windows.Point Point1_5 = new System.Windows.Point(500, 100);
                System.Windows.Point Point1_6 = new System.Windows.Point(600, 150);
                System.Windows.Point Point1_7 = new System.Windows.Point(700, 250);
                System.Windows.Point Point1_8 = new System.Windows.Point(700, 300);
                System.Windows.Point Point1_9 = new System.Windows.Point(600, 200);
                System.Windows.Point Point1_10 = new System.Windows.Point(500, 150);
                System.Windows.Point Point1_11 = new System.Windows.Point(400, 250);
                System.Windows.Point Point1_12 = new System.Windows.Point(300, 300);
                System.Windows.Point Point1_13 = new System.Windows.Point(200, 200);
                System.Windows.Point Point1_14 = new System.Windows.Point(100, 150);

                PointCollection myPointCollection1 = Pol1.Points;

                myPointCollection1.Add(Point1_1);
                myPointCollection1.Add(Point1_2);
                myPointCollection1.Add(Point1_3);
                myPointCollection1.Add(Point1_4);
                myPointCollection1.Add(Point1_5);
                myPointCollection1.Add(Point1_6);
                myPointCollection1.Add(Point1_7);
                myPointCollection1.Add(Point1_8);
                myPointCollection1.Add(Point1_9);
                myPointCollection1.Add(Point1_10);
                myPointCollection1.Add(Point1_11);
                myPointCollection1.Add(Point1_12);
                myPointCollection1.Add(Point1_13);
                myPointCollection1.Add(Point1_14);

                // GREEN                
                System.Windows.Point Point2_1 = new System.Windows.Point(100, 150);
                System.Windows.Point Point2_2 = new System.Windows.Point(200, 200);
                System.Windows.Point Point2_3 = new System.Windows.Point(300, 300);
                System.Windows.Point Point2_4 = new System.Windows.Point(400, 250);
                System.Windows.Point Point2_5 = new System.Windows.Point(500, 150);
                System.Windows.Point Point2_6 = new System.Windows.Point(600, 200);
                System.Windows.Point Point2_7 = new System.Windows.Point(700, 300);
                System.Windows.Point Point2_8 = new System.Windows.Point(700, 450);
                System.Windows.Point Point2_9 = new System.Windows.Point(600, 350);
                System.Windows.Point Point2_10 = new System.Windows.Point(500, 300);
                System.Windows.Point Point2_11 = new System.Windows.Point(400, 400);
                System.Windows.Point Point2_12 = new System.Windows.Point(300, 450);
                System.Windows.Point Point2_13 = new System.Windows.Point(200, 350);
                System.Windows.Point Point2_14 = new System.Windows.Point(100, 300);

                PointCollection myPointCollection2 = Pol2.Points;

                myPointCollection2.Add(Point2_1);
                myPointCollection2.Add(Point2_2);
                myPointCollection2.Add(Point2_3);
                myPointCollection2.Add(Point2_4);
                myPointCollection2.Add(Point2_5);
                myPointCollection2.Add(Point2_6);
                myPointCollection2.Add(Point2_7);
                myPointCollection2.Add(Point2_8);
                myPointCollection2.Add(Point2_9);
                myPointCollection2.Add(Point2_10);
                myPointCollection2.Add(Point2_11);
                myPointCollection2.Add(Point2_12);
                myPointCollection2.Add(Point2_13);
                myPointCollection2.Add(Point2_14);

                // BROWN
                System.Windows.Point Point3_1 = new System.Windows.Point(100, 300);
                System.Windows.Point Point3_2 = new System.Windows.Point(200, 350);
                System.Windows.Point Point3_3 = new System.Windows.Point(300, 450);
                System.Windows.Point Point3_4 = new System.Windows.Point(400, 400);
                System.Windows.Point Point3_5 = new System.Windows.Point(500, 300);
                System.Windows.Point Point3_6 = new System.Windows.Point(600, 350);
                System.Windows.Point Point3_7 = new System.Windows.Point(700, 450);
                System.Windows.Point Point3_8 = new System.Windows.Point(700, 700);
                System.Windows.Point Point3_9 = new System.Windows.Point(600, 600);
                System.Windows.Point Point3_10 = new System.Windows.Point(500, 550);
                System.Windows.Point Point3_11 = new System.Windows.Point(400, 650);
                System.Windows.Point Point3_12 = new System.Windows.Point(300, 700);
                System.Windows.Point Point3_13 = new System.Windows.Point(200, 600);
                System.Windows.Point Point3_14 = new System.Windows.Point(100, 550);

                PointCollection myPointCollection3 = Pol3.Points;

                myPointCollection3.Add(Point3_1);
                myPointCollection3.Add(Point3_2);
                myPointCollection3.Add(Point3_3);
                myPointCollection3.Add(Point3_4);
                myPointCollection3.Add(Point3_5);
                myPointCollection3.Add(Point3_6);
                myPointCollection3.Add(Point3_7);
                myPointCollection3.Add(Point3_8);
                myPointCollection3.Add(Point3_9);
                myPointCollection3.Add(Point3_10);
                myPointCollection3.Add(Point3_11);
                myPointCollection3.Add(Point3_12);
                myPointCollection3.Add(Point3_13);
                myPointCollection3.Add(Point3_14);
            }

            if (value == 7)
            {
                // BLUE
                System.Windows.Point Point1_1 = new System.Windows.Point(100, 100);
                System.Windows.Point Point1_2 = new System.Windows.Point(200, 150);
                System.Windows.Point Point1_3 = new System.Windows.Point(300, 250);
                System.Windows.Point Point1_4 = new System.Windows.Point(400, 200);
                System.Windows.Point Point1_5 = new System.Windows.Point(500, 100);
                System.Windows.Point Point1_6 = new System.Windows.Point(600, 150);
                System.Windows.Point Point1_7 = new System.Windows.Point(700, 250);

                System.Windows.Point Point1_8 = new System.Windows.Point(800, 200);
                System.Windows.Point Point1_9 = new System.Windows.Point(800, 250);

                System.Windows.Point Point1_10 = new System.Windows.Point(700, 300);
                System.Windows.Point Point1_11 = new System.Windows.Point(600, 200);
                System.Windows.Point Point1_12 = new System.Windows.Point(500, 150);
                System.Windows.Point Point1_13 = new System.Windows.Point(400, 250);
                System.Windows.Point Point1_14 = new System.Windows.Point(300, 300);
                System.Windows.Point Point1_15 = new System.Windows.Point(200, 200);
                System.Windows.Point Point1_16 = new System.Windows.Point(100, 150);

                PointCollection myPointCollection1 = Pol1.Points;

                myPointCollection1.Add(Point1_1);
                myPointCollection1.Add(Point1_2);
                myPointCollection1.Add(Point1_3);
                myPointCollection1.Add(Point1_4);
                myPointCollection1.Add(Point1_5);
                myPointCollection1.Add(Point1_6);
                myPointCollection1.Add(Point1_7);
                myPointCollection1.Add(Point1_8);
                myPointCollection1.Add(Point1_9);
                myPointCollection1.Add(Point1_10);
                myPointCollection1.Add(Point1_11);
                myPointCollection1.Add(Point1_12);
                myPointCollection1.Add(Point1_13);
                myPointCollection1.Add(Point1_14);
                myPointCollection1.Add(Point1_15);
                myPointCollection1.Add(Point1_16);

                // GREEN                
                System.Windows.Point Point2_1 = new System.Windows.Point(100, 150);
                System.Windows.Point Point2_2 = new System.Windows.Point(200, 200);
                System.Windows.Point Point2_3 = new System.Windows.Point(300, 300);
                System.Windows.Point Point2_4 = new System.Windows.Point(400, 250);
                System.Windows.Point Point2_5 = new System.Windows.Point(500, 150);
                System.Windows.Point Point2_6 = new System.Windows.Point(600, 200);
                System.Windows.Point Point2_7 = new System.Windows.Point(700, 300);

                System.Windows.Point Point2_8 = new System.Windows.Point(800, 250);
                System.Windows.Point Point2_9 = new System.Windows.Point(800, 400);

                System.Windows.Point Point2_10 = new System.Windows.Point(700, 450);
                System.Windows.Point Point2_11 = new System.Windows.Point(600, 350);
                System.Windows.Point Point2_12 = new System.Windows.Point(500, 300);
                System.Windows.Point Point2_13 = new System.Windows.Point(400, 400);
                System.Windows.Point Point2_14 = new System.Windows.Point(300, 450);
                System.Windows.Point Point2_15 = new System.Windows.Point(200, 350);
                System.Windows.Point Point2_16 = new System.Windows.Point(100, 300);

                PointCollection myPointCollection2 = Pol2.Points;

                myPointCollection2.Add(Point2_1);
                myPointCollection2.Add(Point2_2);
                myPointCollection2.Add(Point2_3);
                myPointCollection2.Add(Point2_4);
                myPointCollection2.Add(Point2_5);
                myPointCollection2.Add(Point2_6);
                myPointCollection2.Add(Point2_7);
                myPointCollection2.Add(Point2_8);
                myPointCollection2.Add(Point2_9);
                myPointCollection2.Add(Point2_10);
                myPointCollection2.Add(Point2_11);
                myPointCollection2.Add(Point2_12);
                myPointCollection2.Add(Point2_13);
                myPointCollection2.Add(Point2_14);
                myPointCollection2.Add(Point2_15);
                myPointCollection2.Add(Point2_16);

                // BROWN
                System.Windows.Point Point3_1 = new System.Windows.Point(100, 300);
                System.Windows.Point Point3_2 = new System.Windows.Point(200, 350);
                System.Windows.Point Point3_3 = new System.Windows.Point(300, 450);
                System.Windows.Point Point3_4 = new System.Windows.Point(400, 400);
                System.Windows.Point Point3_5 = new System.Windows.Point(500, 300);
                System.Windows.Point Point3_6 = new System.Windows.Point(600, 350);
                System.Windows.Point Point3_7 = new System.Windows.Point(700, 450);

                System.Windows.Point Point3_8 = new System.Windows.Point(800, 400);
                System.Windows.Point Point3_9 = new System.Windows.Point(800, 650);

                System.Windows.Point Point3_10 = new System.Windows.Point(700, 700);
                System.Windows.Point Point3_11 = new System.Windows.Point(600, 600);
                System.Windows.Point Point3_12 = new System.Windows.Point(500, 550);
                System.Windows.Point Point3_13 = new System.Windows.Point(400, 650);
                System.Windows.Point Point3_14 = new System.Windows.Point(300, 700);
                System.Windows.Point Point3_15 = new System.Windows.Point(200, 600);
                System.Windows.Point Point3_16 = new System.Windows.Point(100, 550);

                PointCollection myPointCollection3 = Pol3.Points;

                myPointCollection3.Add(Point3_1);
                myPointCollection3.Add(Point3_2);
                myPointCollection3.Add(Point3_3);
                myPointCollection3.Add(Point3_4);
                myPointCollection3.Add(Point3_5);
                myPointCollection3.Add(Point3_6);
                myPointCollection3.Add(Point3_7);
                myPointCollection3.Add(Point3_8);
                myPointCollection3.Add(Point3_9);
                myPointCollection3.Add(Point3_10);
                myPointCollection3.Add(Point3_11);
                myPointCollection3.Add(Point3_12);
                myPointCollection3.Add(Point3_13);
                myPointCollection3.Add(Point3_14);
                myPointCollection3.Add(Point3_15);
                myPointCollection3.Add(Point3_16);
            }

            if (value == 8)
            {
                // BLUE
                System.Windows.Point Point1_1 = new System.Windows.Point(100, 100);
                System.Windows.Point Point1_2 = new System.Windows.Point(200, 150);
                System.Windows.Point Point1_3 = new System.Windows.Point(300, 250);
                System.Windows.Point Point1_4 = new System.Windows.Point(400, 200);
                System.Windows.Point Point1_5 = new System.Windows.Point(500, 100);
                System.Windows.Point Point1_6 = new System.Windows.Point(600, 150);
                System.Windows.Point Point1_7 = new System.Windows.Point(700, 250);
                System.Windows.Point Point1_8 = new System.Windows.Point(800, 200);

                System.Windows.Point Point1_9 = new System.Windows.Point(900, 250);
                System.Windows.Point Point1_10 = new System.Windows.Point(900, 300);

                System.Windows.Point Point1_11 = new System.Windows.Point(800, 250);
                System.Windows.Point Point1_12 = new System.Windows.Point(700, 300);
                System.Windows.Point Point1_13 = new System.Windows.Point(600, 200);
                System.Windows.Point Point1_14 = new System.Windows.Point(500, 150);
                System.Windows.Point Point1_15 = new System.Windows.Point(400, 250);
                System.Windows.Point Point1_16 = new System.Windows.Point(300, 300);
                System.Windows.Point Point1_17 = new System.Windows.Point(200, 200);
                System.Windows.Point Point1_18 = new System.Windows.Point(100, 150);

                PointCollection myPointCollection1 = Pol1.Points;

                myPointCollection1.Add(Point1_1);
                myPointCollection1.Add(Point1_2);
                myPointCollection1.Add(Point1_3);
                myPointCollection1.Add(Point1_4);
                myPointCollection1.Add(Point1_5);
                myPointCollection1.Add(Point1_6);
                myPointCollection1.Add(Point1_7);
                myPointCollection1.Add(Point1_8);
                myPointCollection1.Add(Point1_9);
                myPointCollection1.Add(Point1_10);
                myPointCollection1.Add(Point1_11);
                myPointCollection1.Add(Point1_12);
                myPointCollection1.Add(Point1_13);
                myPointCollection1.Add(Point1_14);
                myPointCollection1.Add(Point1_15);
                myPointCollection1.Add(Point1_16);
                myPointCollection1.Add(Point1_17);
                myPointCollection1.Add(Point1_18);

                // GREEN                
                System.Windows.Point Point2_1 = new System.Windows.Point(100, 150);
                System.Windows.Point Point2_2 = new System.Windows.Point(200, 200);
                System.Windows.Point Point2_3 = new System.Windows.Point(300, 300);
                System.Windows.Point Point2_4 = new System.Windows.Point(400, 250);
                System.Windows.Point Point2_5 = new System.Windows.Point(500, 150);
                System.Windows.Point Point2_6 = new System.Windows.Point(600, 200);
                System.Windows.Point Point2_7 = new System.Windows.Point(700, 300);
                System.Windows.Point Point2_8 = new System.Windows.Point(800, 250);
                System.Windows.Point Point2_9 = new System.Windows.Point(900, 300);
                System.Windows.Point Point2_10 = new System.Windows.Point(900, 450);
                System.Windows.Point Point2_11 = new System.Windows.Point(800, 400);
                System.Windows.Point Point2_12 = new System.Windows.Point(700, 450);
                System.Windows.Point Point2_13 = new System.Windows.Point(600, 350);
                System.Windows.Point Point2_14 = new System.Windows.Point(500, 300);
                System.Windows.Point Point2_15 = new System.Windows.Point(400, 400);
                System.Windows.Point Point2_16 = new System.Windows.Point(300, 450);
                System.Windows.Point Point2_17 = new System.Windows.Point(200, 350);
                System.Windows.Point Point2_18 = new System.Windows.Point(100, 300);

                PointCollection myPointCollection2 = Pol2.Points;

                myPointCollection2.Add(Point2_1);
                myPointCollection2.Add(Point2_2);
                myPointCollection2.Add(Point2_3);
                myPointCollection2.Add(Point2_4);
                myPointCollection2.Add(Point2_5);
                myPointCollection2.Add(Point2_6);
                myPointCollection2.Add(Point2_7);
                myPointCollection2.Add(Point2_8);
                myPointCollection2.Add(Point2_9);
                myPointCollection2.Add(Point2_10);
                myPointCollection2.Add(Point2_11);
                myPointCollection2.Add(Point2_12);
                myPointCollection2.Add(Point2_13);
                myPointCollection2.Add(Point2_14);
                myPointCollection2.Add(Point2_15);
                myPointCollection2.Add(Point2_16);
                myPointCollection2.Add(Point2_17);
                myPointCollection2.Add(Point2_18);

                // BROWN
                System.Windows.Point Point3_1 = new System.Windows.Point(100, 300);
                System.Windows.Point Point3_2 = new System.Windows.Point(200, 350);
                System.Windows.Point Point3_3 = new System.Windows.Point(300, 450);
                System.Windows.Point Point3_4 = new System.Windows.Point(400, 400);
                System.Windows.Point Point3_5 = new System.Windows.Point(500, 300);
                System.Windows.Point Point3_6 = new System.Windows.Point(600, 350);
                System.Windows.Point Point3_7 = new System.Windows.Point(700, 450);
                System.Windows.Point Point3_8 = new System.Windows.Point(800, 400);
                System.Windows.Point Point3_9 = new System.Windows.Point(900, 450);
                System.Windows.Point Point3_10 = new System.Windows.Point(900, 700);
                System.Windows.Point Point3_11 = new System.Windows.Point(800, 650);
                System.Windows.Point Point3_12 = new System.Windows.Point(700, 700);
                System.Windows.Point Point3_13 = new System.Windows.Point(600, 600);
                System.Windows.Point Point3_14 = new System.Windows.Point(500, 550);
                System.Windows.Point Point3_15 = new System.Windows.Point(400, 650);
                System.Windows.Point Point3_16 = new System.Windows.Point(300, 700);
                System.Windows.Point Point3_17 = new System.Windows.Point(200, 600);
                System.Windows.Point Point3_18 = new System.Windows.Point(100, 550);

                PointCollection myPointCollection3 = Pol3.Points;

                myPointCollection3.Add(Point3_1);
                myPointCollection3.Add(Point3_2);
                myPointCollection3.Add(Point3_3);
                myPointCollection3.Add(Point3_4);
                myPointCollection3.Add(Point3_5);
                myPointCollection3.Add(Point3_6);
                myPointCollection3.Add(Point3_7);
                myPointCollection3.Add(Point3_8);
                myPointCollection3.Add(Point3_9);
                myPointCollection3.Add(Point3_10);
                myPointCollection3.Add(Point3_11);
                myPointCollection3.Add(Point3_12);
                myPointCollection3.Add(Point3_13);
                myPointCollection3.Add(Point3_14);
                myPointCollection3.Add(Point3_15);
                myPointCollection3.Add(Point3_16);
                myPointCollection3.Add(Point3_17);
                myPointCollection3.Add(Point3_18);
            }

            if (value == 9)
            {
                // BLUE
                System.Windows.Point Point1_1 = new System.Windows.Point(100, 100);
                System.Windows.Point Point1_2 = new System.Windows.Point(200, 150);
                System.Windows.Point Point1_3 = new System.Windows.Point(300, 250);
                System.Windows.Point Point1_4 = new System.Windows.Point(400, 200);
                System.Windows.Point Point1_5 = new System.Windows.Point(500, 100);
                System.Windows.Point Point1_6 = new System.Windows.Point(600, 150);
                System.Windows.Point Point1_7 = new System.Windows.Point(700, 250);
                System.Windows.Point Point1_8 = new System.Windows.Point(800, 200);
                System.Windows.Point Point1_9 = new System.Windows.Point(900, 250);
                System.Windows.Point Point1_10 = new System.Windows.Point(1000, 300);
                System.Windows.Point Point1_11 = new System.Windows.Point(1000, 350);
                System.Windows.Point Point1_12 = new System.Windows.Point(900, 300);
                System.Windows.Point Point1_13 = new System.Windows.Point(800, 250);
                System.Windows.Point Point1_14 = new System.Windows.Point(700, 300);
                System.Windows.Point Point1_15 = new System.Windows.Point(600, 200);
                System.Windows.Point Point1_16 = new System.Windows.Point(500, 150);
                System.Windows.Point Point1_17 = new System.Windows.Point(400, 250);
                System.Windows.Point Point1_18 = new System.Windows.Point(300, 300);
                System.Windows.Point Point1_19 = new System.Windows.Point(200, 200);
                System.Windows.Point Point1_20 = new System.Windows.Point(100, 150);

                PointCollection myPointCollection1 = Pol1.Points;

                myPointCollection1.Add(Point1_1);
                myPointCollection1.Add(Point1_2);
                myPointCollection1.Add(Point1_3);
                myPointCollection1.Add(Point1_4);
                myPointCollection1.Add(Point1_5);
                myPointCollection1.Add(Point1_6);
                myPointCollection1.Add(Point1_7);
                myPointCollection1.Add(Point1_8);
                myPointCollection1.Add(Point1_9);
                myPointCollection1.Add(Point1_10);
                myPointCollection1.Add(Point1_11);
                myPointCollection1.Add(Point1_12);
                myPointCollection1.Add(Point1_13);
                myPointCollection1.Add(Point1_14);
                myPointCollection1.Add(Point1_15);
                myPointCollection1.Add(Point1_16);
                myPointCollection1.Add(Point1_17);
                myPointCollection1.Add(Point1_18);
                myPointCollection1.Add(Point1_19);
                myPointCollection1.Add(Point1_20);

                // GREEN                
                System.Windows.Point Point2_1 = new System.Windows.Point(100, 150);
                System.Windows.Point Point2_2 = new System.Windows.Point(200, 200);
                System.Windows.Point Point2_3 = new System.Windows.Point(300, 300);
                System.Windows.Point Point2_4 = new System.Windows.Point(400, 250);
                System.Windows.Point Point2_5 = new System.Windows.Point(500, 150);
                System.Windows.Point Point2_6 = new System.Windows.Point(600, 200);
                System.Windows.Point Point2_7 = new System.Windows.Point(700, 300);
                System.Windows.Point Point2_8 = new System.Windows.Point(800, 250);
                System.Windows.Point Point2_9 = new System.Windows.Point(900, 300);
                System.Windows.Point Point2_10 = new System.Windows.Point(1000, 350);
                System.Windows.Point Point2_11 = new System.Windows.Point(1000, 500);
                System.Windows.Point Point2_12 = new System.Windows.Point(900, 450);
                System.Windows.Point Point2_13 = new System.Windows.Point(800, 400);
                System.Windows.Point Point2_14 = new System.Windows.Point(700, 450);
                System.Windows.Point Point2_15 = new System.Windows.Point(600, 350);
                System.Windows.Point Point2_16 = new System.Windows.Point(500, 300);
                System.Windows.Point Point2_17 = new System.Windows.Point(400, 400);
                System.Windows.Point Point2_18 = new System.Windows.Point(300, 450);
                System.Windows.Point Point2_19 = new System.Windows.Point(200, 350);
                System.Windows.Point Point2_20 = new System.Windows.Point(100, 300);

                PointCollection myPointCollection2 = Pol2.Points;

                myPointCollection2.Add(Point2_1);
                myPointCollection2.Add(Point2_2);
                myPointCollection2.Add(Point2_3);
                myPointCollection2.Add(Point2_4);
                myPointCollection2.Add(Point2_5);
                myPointCollection2.Add(Point2_6);
                myPointCollection2.Add(Point2_7);
                myPointCollection2.Add(Point2_8);
                myPointCollection2.Add(Point2_9);
                myPointCollection2.Add(Point2_10);
                myPointCollection2.Add(Point2_11);
                myPointCollection2.Add(Point2_12);
                myPointCollection2.Add(Point2_13);
                myPointCollection2.Add(Point2_14);
                myPointCollection2.Add(Point2_15);
                myPointCollection2.Add(Point2_16);
                myPointCollection2.Add(Point2_17);
                myPointCollection2.Add(Point2_18);
                myPointCollection2.Add(Point2_19);
                myPointCollection2.Add(Point2_20);

                // BROWN
                System.Windows.Point Point3_1 = new System.Windows.Point(100, 300);
                System.Windows.Point Point3_2 = new System.Windows.Point(200, 350);
                System.Windows.Point Point3_3 = new System.Windows.Point(300, 450);
                System.Windows.Point Point3_4 = new System.Windows.Point(400, 400);
                System.Windows.Point Point3_5 = new System.Windows.Point(500, 300);
                System.Windows.Point Point3_6 = new System.Windows.Point(600, 350);
                System.Windows.Point Point3_7 = new System.Windows.Point(700, 450);
                System.Windows.Point Point3_8 = new System.Windows.Point(800, 400);
                System.Windows.Point Point3_9 = new System.Windows.Point(900, 450);

                System.Windows.Point Point3_10 = new System.Windows.Point(1000, 500);
                System.Windows.Point Point3_11 = new System.Windows.Point(1000, 750);

                System.Windows.Point Point3_12 = new System.Windows.Point(900, 700);
                System.Windows.Point Point3_13 = new System.Windows.Point(800, 650);
                System.Windows.Point Point3_14 = new System.Windows.Point(700, 700);
                System.Windows.Point Point3_15 = new System.Windows.Point(600, 600);
                System.Windows.Point Point3_16 = new System.Windows.Point(500, 550);
                System.Windows.Point Point3_17 = new System.Windows.Point(400, 650);
                System.Windows.Point Point3_18 = new System.Windows.Point(300, 700);
                System.Windows.Point Point3_19 = new System.Windows.Point(200, 600);
                System.Windows.Point Point3_20 = new System.Windows.Point(100, 550);

                PointCollection myPointCollection3 = Pol3.Points;

                myPointCollection3.Add(Point3_1);
                myPointCollection3.Add(Point3_2);
                myPointCollection3.Add(Point3_3);
                myPointCollection3.Add(Point3_4);
                myPointCollection3.Add(Point3_5);
                myPointCollection3.Add(Point3_6);
                myPointCollection3.Add(Point3_7);
                myPointCollection3.Add(Point3_8);
                myPointCollection3.Add(Point3_9);
                myPointCollection3.Add(Point3_10);
                myPointCollection3.Add(Point3_11);
                myPointCollection3.Add(Point3_12);
                myPointCollection3.Add(Point3_13);
                myPointCollection3.Add(Point3_14);
                myPointCollection3.Add(Point3_15);
                myPointCollection3.Add(Point3_16);
                myPointCollection3.Add(Point3_17);
                myPointCollection3.Add(Point3_18);
                myPointCollection3.Add(Point3_19);
                myPointCollection3.Add(Point3_20);
            }

        }

     }
}

Open in new window

Avatar of VPry

ASKER

Do not worry about this code:
      // Move all polygons up & left 
            TranslateTransform translateTransform1 = new TranslateTransform(-300, -100);

            Pol1.RenderTransform = translateTransform1;
            Pol2.RenderTransform = translateTransform1;
            Pol3.RenderTransform = translateTransform1;

            // Make all polygons smaller
            ScaleTransform scaleTransform1 = new ScaleTransform(0.8, 0.8);

            Pol1.RenderTransform = scaleTransform1;
            Pol2.RenderTransform = scaleTransform1;
            Pol3.RenderTransform = scaleTransform1;

Open in new window


This is done only for my local demo to adjust to my monitor. Will not be in actual release.
I will take a look at it when I get back home :-)
Avatar of VPry

ASKER

Thank you Saragani! You not only a Guru, you are an Angel !!! :)))

This app is very important to me along with all this learning curve.

Meanwhile I am going to dig into WCF :\
Hi, what is the point of having 2 polygons while in drawing you see one?
(both polygons have 1 common line)

Lets take for example 2 squares, 1 above the other, they will look like 1 big square
Avatar of VPry

ASKER

Yes, you are right.
But each square represent a different slice of data. One Polygon is on top of the other and they have common border, common Points. But they can have different size (or same size, doesn’t matter) and should be painted in different colors. Same like multi-layered cake slice.
Avatar of VPry

ASKER

All polygons between two adjacent lines should be painted same color (pattern):
_____________________________________________
   RED
_____________________________________________
   BLUE
_____________________________________________
   GREEN
....................................................... and so on............

And what you are asking me is...?


How to have more that 1 polygon without having to define in hardcode Xaml a specific number of polygons?
Avatar of VPry

ASKER

Yes, how to have more that 1 polygon without having to define in hardcode Xaml a specific number of polygons?
And, how to modify your app so I can add more lines like:

List<Point> listPointsLine3 = new List<Point>(new Point[] { new Point(100, 300), new Point(200, 350), new Point(300, 450), new Point(400, 400), new Point(500, 300), new Point(600, 350), new Point(700, 450), new Point(800, 400), new Point(900, 450), new Point(1000, 500) });
 
List<Point> listPointsLine4 = new List<Point>(new Point[] { new Point(100, 550), new Point(200, 600), new Point(300, 700), new Point(400, 650), new Point(500, 550), new Point(600, 600), new Point(700, 700), new Point(800, 650), new Point(900, 700), new Point(1000, 750) });

???
 
Avatar of VPry

ASKER

The problem is that app not outlines Polygons correctly. Compare what my static demo draws and your app.
In 1 word: ItemsControl

In 31 words: a polygon viewmodel with a collection of points, while having your mainViewModel have a collection of polygonViewModel. Then the UI has an ItemsControl bound to that collection with Canvas as ItemsPanel.
Why isn't it outline it correctly?
What do you mean by outline?
Avatar of VPry

ASKER

OK, run my static sample. It drraws 3 areas of Polygons with different colors.
Now, add 2 new points to your app:

List<Point> listPointsLine3 = new List<Point>(new Point[] { new Point(100, 300), new Point(200, 350), new Point(300, 450), new Point(400, 400), new Point(500, 300), new Point(600, 350), new Point(700, 450), new Point(800, 400), new Point(900, 450), new Point(1000, 500) });
 
List<Point> listPointsLine4 = new List<Point>(new Point[] { new Point(100, 550), new Point(200, 600), new Point(300, 700), new Point(400, 650), new Point(500, 550), new Point(600, 600), new Point(700, 700), new Point(800, 650), new Point(900, 700), new Point(1000, 750) });fenter

Forget about different colors, just see how Polygons are drawn compared to my demo. Sequence of Points is incorrect.  If you have 4 Points which are form square then they should be drawn sequentially:
1,2,3,4. Right? If you draw them like 1,2,4,3 then you will get a wierd X shape Polygon.

                                       
             
Avatar of VPry

ASKER


          1-------------2      That's what you get drawing in sequence 1,2,4,3 instead of square.
           \               /
             \            /
               \         /
                 \      /
                   \   /
                    \ /
                    / \
                  /    \
                /       \
               /         \
              /           \
            4 ----------3
I've sent you a new sample project that demonstrates what you have requested.
Again, it is fairly easy...

If I would show you things that we do at work with WPF, I believe that yours and other peoples tongue  will fall to the ground... :-)
Avatar of VPry

ASKER

Saragani, your app works fine!

This was happening because I sorted  3rd Line Points descending instead of ascending. Needs to be:

    // 3rd Line Points
            inBoundsPoitns = from val in listPointsLine3
                             where val.X <= 10 * RegionWidthPercentage
                             orderby val.X ascending
                             select val;

            points.AddRange(inBoundsPoitns);

Sorry, my bad :\

Now, how to use different image brushes (patterns) for each area between adjacent lines:
_____________________________________________
   RED
_____________________________________________
   BLUE
_____________________________________________
   GREEN
....................................................... and so on............  ???

And just to be fair with EE comunity, although I don't need to publish the sources since the question was already answered and I already got my points... here is the sources:

MainWindow.XAML (based on the xaml I got from the author):

<Window x:Class="SliderScaleCanvas.MainWindow"
        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" ResizeMode="CanResize"
        xmlns:local="clr-namespace:SliderScaleCanvas"
        Title="MainWindow" Height="600" Width="700" VerticalAlignment="Top" HorizontalAlignment="Left" x:Name="mainWindow">

    <Window.Resources>
        <local:PointsCollectionConverter x:Key="pointsCollectionConverter" />
        
        <VisualBrush x:Key="DotFillBrush"     TileMode="Tile"     Viewport="0,0,10,10"     ViewportUnits="Absolute"     Viewbox="0,0,12,12"    ViewboxUnits="Absolute">
            <VisualBrush.Visual>
                <Ellipse         Fill="#00C0FF"         Width="10" Height="10" />
            </VisualBrush.Visual>
        </VisualBrush>
        <VisualBrush       x:Key="HatchBrush"       TileMode="Tile" Viewport="0,0,10,10"       ViewportUnits="Absolute" Viewbox="0,0,10,10"          ViewboxUnits="Absolute">
            <VisualBrush.Visual>
                <Canvas>
                    <Rectangle Fill="Azure" Width="10" Height="10" />
                    <Path Stroke="Purple" Data="M 0 0 l 10 10" />
                    <Path Stroke="Purple" Data="M 0 10 l 10 -10" />
                </Canvas>
            </VisualBrush.Visual>
        </VisualBrush>
        
        
        <DataTemplate DataType="{x:Type local:PolygonViewModel}">
            <Polygon Points="{Binding PolygonPoints, Converter={StaticResource pointsCollectionConverter}}">
                <Polygon.Fill>
                    <ImageBrush TileMode="Tile" Viewport="0, 0, 20, 20" Stretch="None" ViewportUnits="Absolute" ImageSource="{Binding FillImagePath}" />
                </Polygon.Fill>
            </Polygon>
        </DataTemplate>
    </Window.Resources>
    
    <Window.DataContext>
        <local:MainViewModel />
    </Window.DataContext>

    <Border BorderBrush="Black" BorderThickness="2" CornerRadius="0" Padding="5">

        <Grid Name="MainGrid" Background="lightyellow"  >
            <Grid.RowDefinitions>
                <RowDefinition Height="*"/>
                <RowDefinition Height="Auto"/>
            </Grid.RowDefinitions>

            <Canvas x:Name="mainCanvas" Background="LightYellow" Margin="10">

                <StackPanel Orientation="Horizontal">
                    <TextBlock Text="Canvas Size: " Name="label1" />
                    <TextBlock  Name="lblWindowSize">
                        <Run Text="{Binding ElementName=mainWindow, Path=ActualWidth, Mode=OneWay}" />
                        <Run Text=","/>
                        <Run Text="{Binding ElementName=mainWindow, Path=ActualHeight, Mode=OneWay}"/>
                    </TextBlock>
                    <TextBlock Text=" px" Name="lblPixels"  />
                </StackPanel>

                <ItemsControl HorizontalAlignment="Stretch" VerticalAlignment="Stretch" ItemsSource="{Binding Polygons}">
                    <ItemsControl.ItemsPanel>
                        <ItemsPanelTemplate>
                            <Canvas />
                        </ItemsPanelTemplate>
                    </ItemsControl.ItemsPanel>
                </ItemsControl>
            </Canvas>

            <StackPanel Orientation="Horizontal" Grid.Row="1">
                <Slider Orientation="Horizontal" AutoToolTipPlacement="TopLeft" x:Name="sldSlider" VerticalAlignment="Bottom"
                 IsSnapToTickEnabled="True" Width="400" TickPlacement="BottomRight" Background="DimGray"  
                 TickFrequency="10" Maximum="100" Height="29" Value="{Binding RegionWidthPercentage}"/>

                <StackPanel x:Name="LayoutRoot" Background="LightGreen" Width="200">
                    <StackPanel Name="stpSliderPosition" Orientation="Horizontal" Width="100">
                        <TextBlock Margin="5,5,10,5">Slider</TextBlock>
                        <TextBlock Margin="5,5,0,5" TextAlignment="Left" Width="30" Text="{Binding Path=Value, ElementName=sldSlider, Mode=OneWay}" />
                        <TextBlock Margin="0,5">%</TextBlock>
                    </StackPanel>
                </StackPanel>
            </StackPanel>
        </Grid>
    </Border>
</Window> 


---------------------------------------------------------------------------------

PolygonViewModel.cs:

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows;
using System.Collections.ObjectModel;

namespace SliderScaleCanvas
{
    public class PolygonViewModel : ViewModelBase
    {
        private List<Point> points = new List<Point>();
        private List<Point> _listPointsLine1;
        private List<Point> _listPointsLine2;
        private string _fillImagePath;

        public PolygonViewModel(List<Point> listPointsLine1, List<Point> listPointsLine2, string fillImagePath)
        {
            _listPointsLine1 = listPointsLine1;
            _listPointsLine2 = listPointsLine2;
            _fillImagePath = fillImagePath;
        }

        public ReadOnlyCollection<Point> PolygonPoints
        {
            get
            {
                return new ReadOnlyCollection<Point>(points);
            }
            set
            {
                points = new List<Point>(value);

                OnPropertyChanged("PolygonPoints");
            }
        }

        public string FillImagePath
        {
            get
            {
                return _fillImagePath;
            }
        }

        internal void SetPoints(int regionWidthPercentage)
        {
            points.Clear();

            var inBoundsPoitns = from val in _listPointsLine1
                                 where val.X <= 10 * regionWidthPercentage
                                 orderby val.X ascending
                                 select val;

            points.AddRange(inBoundsPoitns);

            inBoundsPoitns = from val in _listPointsLine2
                             where val.X <= 10 * regionWidthPercentage
                             orderby val.X descending
                             select val;

            points.AddRange(inBoundsPoitns);

            OnPropertyChanged("PolygonPoints");
        }
    }
}


------------------------------------------------------------------------------

MainViewModel.cs:

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Collections.ObjectModel;
using System.Windows;

namespace SliderScaleCanvas
{
    public class MainViewModel : ViewModelBase
    {
        private int _regionWidthPercentage = 0;
        private ObservableCollection<PolygonViewModel> _polygons = new ObservableCollection<PolygonViewModel>();
 
        public MainViewModel()
        {
            createPolygonsFromDB();
        }

        public int RegionWidthPercentage
        {
            get
            {
                return _regionWidthPercentage;
            }
            set
            {
                _regionWidthPercentage = value;
                OnPropertyChanged("RegionWidthPercentage");

                foreach (PolygonViewModel polygonViewModel in Polygons)
                {
                    polygonViewModel.SetPoints(RegionWidthPercentage);
                }
            }
        }

        public ObservableCollection<PolygonViewModel> Polygons
        {
            get
            {
                return _polygons;
            }
        }

        private void createPolygonsFromDB()
        {
            List<List<Point>> pointsFroDB = DbConnectionSimulation.GetPointsFromDB();

            if (pointsFroDB.Count >= 2)
            {
                List<Point> previosLines = pointsFroDB[0];
                for (int i = 1; i < pointsFroDB.Count; i++)
                {
                    PolygonViewModel polygon = new PolygonViewModel(previosLines, pointsFroDB[i], getFillImagePathByIndex(i - 1));
                    previosLines = pointsFroDB[i];
                    Polygons.Add(polygon);
                }
            }
        }

        private string getFillImagePathByIndex(int index)
        {
            switch (index)
            {
                case 0:
                    return "/SliderScaleCanvas;component/Images/GasPattern.jpg";
                case 1:
                    return "/SliderScaleCanvas;component/Images/BluePattern.jpg";
                case 2:
                    return "/SliderScaleCanvas;component/Images/GreenPattern.jpg";
                default:
                    return "/SliderScaleCanvas;component/Images/GasPattern.jpg";
            }
        }
    }
}


--------------------------------------------------------------------------------------------------

DbConnectionSimulator (just to simulate a data that we got from somewhere.... )

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows;

namespace SliderScaleCanvas
{
    public static class DbConnectionSimulation
    {
        private static List<Point> listPointsLine1 = new List<Point>(new Point[] { new Point(100, 100), new Point(200, 150), new Point(300, 250), new Point(400, 200), new Point(500, 100), new Point(600, 150), new Point(700, 250), new Point(800, 200), new Point(900, 250), new Point(1000, 300) });
        private static List<Point> listPointsLine2 = new List<Point>(new Point[] { new Point(100, 150), new Point(200, 200), new Point(300, 300), new Point(400, 250), new Point(500, 150), new Point(600, 200), new Point(700, 300), new Point(800, 250), new Point(900, 300), new Point(1000, 350) });
        private static List<Point> listPointsLine3 = new List<Point>(new Point[] { new Point(100, 300), new Point(200, 350), new Point(300, 450), new Point(400, 400), new Point(500, 300), new Point(600, 350), new Point(700, 450), new Point(800, 400), new Point(900, 450), new Point(1000, 500) });
        private static List<Point> listPointsLine4 = new List<Point>(new Point[] { new Point(100, 550), new Point(200, 600), new Point(300, 700), new Point(400, 650), new Point(500, 550), new Point(600, 600), new Point(700, 700), new Point(800, 650), new Point(900, 700), new Point(1000, 750) });

        public static List<List<Point>> GetPointsFromDB()
        {
            List<List<Point>> result = new List<List<Point>>();
            result.Add(listPointsLine1);
            result.Add(listPointsLine2);
            result.Add(listPointsLine3);
            result.Add(listPointsLine4);

            return result;
        }
    }
}


---------------------------------------------------------------------------------------

PointsCollectionConverter.cs:

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows;
using System.Collections.ObjectModel;

namespace SliderScaleCanvas
{
    public class PolygonViewModel : ViewModelBase
    {
        private List<Point> points = new List<Point>();
        private List<Point> _listPointsLine1;
        private List<Point> _listPointsLine2;
        private string _fillImagePath;

        public PolygonViewModel(List<Point> listPointsLine1, List<Point> listPointsLine2, string fillImagePath)
        {
            _listPointsLine1 = listPointsLine1;
            _listPointsLine2 = listPointsLine2;
            _fillImagePath = fillImagePath;
        }

        public ReadOnlyCollection<Point> PolygonPoints
        {
            get
            {
                return new ReadOnlyCollection<Point>(points);
            }
            set
            {
                points = new List<Point>(value);

                OnPropertyChanged("PolygonPoints");
            }
        }

        public string FillImagePath
        {
            get
            {
                return _fillImagePath;
            }
        }

        internal void SetPoints(int regionWidthPercentage)
        {
            points.Clear();

            var inBoundsPoitns = from val in _listPointsLine1
                                 where val.X <= 10 * regionWidthPercentage
                                 orderby val.X ascending
                                 select val;

            points.AddRange(inBoundsPoitns);

            inBoundsPoitns = from val in _listPointsLine2
                             where val.X <= 10 * regionWidthPercentage
                             orderby val.X descending
                             select val;

            points.AddRange(inBoundsPoitns);

            OnPropertyChanged("PolygonPoints");
        }
    }
}

Open in new window


My example shows how to have a different brush for each polygon. In my case I use the index I iterate in order to get an image (using switch).

I don't know your logic, but maybe the data that comes from the database should also contain the type of the data (so it will give it a color by type).

Or you can do like by, by index.
Avatar of VPry

ASKER

WOW! This is just freaking WOW! :)))
Avatar of VPry

ASKER

Thank you! This one ROCKS! :)))

If coordinates of my data expect X=0 and Y=0 to be at the left bottom corner of the Canvas. How to change Canvas coordinate system?

How to make my window tranparent but with chrome around? (I did it by using styles for my static demo, but may be you know better way?)
Avatar of VPry

ASKER

You said that you don't really know WCF. I thought WCF is the best way to get data from database.

How do you read your data?
Avatar of VPry

ASKER

I gotta leave now. I will bug you some more tomorrow if you don't mind :)))

I will start a new post so you will get credit for your time.

I am luck I found you here! :))) Thanks again!!! :)))
I'm not a DB expert in .Net...
However, in the place we work, we just started working with Entity Framework 4.

                <ItemsControl HorizontalAlignment="Stretch" VerticalAlignment="Stretch" ItemsSource="{Binding Polygons}">
                    <ItemsControl.ItemsPanel>
                        <ItemsPanelTemplate>
                            <Canvas>
[b]                                <Canvas.RenderTransform>
                                    <TransformGroup>
                                        <ScaleTransform ScaleY="-1"/>
                                        <TranslateTransform Y="{Binding RelativeSource={RelativeSource Mode=FindAncestor, AncestorType=Canvas,AncestorLevel=2}, Path=ActualHeight}" />
                                    </TransformGroup>
                                </Canvas.RenderTransform>[/b]
                            </Canvas>
                        </ItemsPanelTemplate>
                    </ItemsControl.ItemsPanel>
                </ItemsControl>

Open in new window

Oops ignore the Bold tags in the XAML
The following XAML will also work, and it is better:

<Window x:Class="SliderScaleCanvas.MainWindow"
        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" ResizeMode="CanResize"
        xmlns:local="clr-namespace:SliderScaleCanvas"
        Title="MainWindow" Height="600" Width="700" VerticalAlignment="Top" HorizontalAlignment="Left" x:Name="mainWindow">

    <Window.Resources>
        <local:PointsCollectionConverter x:Key="pointsCollectionConverter" />
        
        <VisualBrush x:Key="DotFillBrush"     TileMode="Tile"     Viewport="0,0,10,10"     ViewportUnits="Absolute"     Viewbox="0,0,12,12"    ViewboxUnits="Absolute">
            <VisualBrush.Visual>
                <Ellipse         Fill="#00C0FF"         Width="10" Height="10" />
            </VisualBrush.Visual>
        </VisualBrush>
        <VisualBrush       x:Key="HatchBrush"       TileMode="Tile" Viewport="0,0,10,10"       ViewportUnits="Absolute" Viewbox="0,0,10,10"          ViewboxUnits="Absolute">
            <VisualBrush.Visual>
                <Canvas>
                    <Rectangle Fill="Azure" Width="10" Height="10" />
                    <Path Stroke="Purple" Data="M 0 0 l 10 10" />
                    <Path Stroke="Purple" Data="M 0 10 l 10 -10" />
                </Canvas>
            </VisualBrush.Visual>
        </VisualBrush>
        
        
        <DataTemplate DataType="{x:Type local:PolygonViewModel}">
            <Polygon Points="{Binding PolygonPoints, Converter={StaticResource pointsCollectionConverter}}">
                <Polygon.Fill>
                    <ImageBrush TileMode="Tile" Viewport="0, 0, 20, 20" Stretch="None" ViewportUnits="Absolute" ImageSource="{Binding FillImagePath}" />
                </Polygon.Fill>
            </Polygon>
        </DataTemplate>
    </Window.Resources>
    
    <Window.DataContext>
        <local:MainViewModel />
    </Window.DataContext>

    <Border BorderBrush="Black" BorderThickness="2" CornerRadius="0" Padding="5">

        <Grid Name="MainGrid" Background="lightyellow"  >
            <Grid.RowDefinitions>
                <RowDefinition Height="*"/>
                <RowDefinition Height="Auto"/>
            </Grid.RowDefinitions>

            <Canvas x:Name="mainCanvas" Background="LightYellow" Margin="10">

                <StackPanel Orientation="Horizontal">
                    <TextBlock Text="Canvas Size: " Name="label1" />
                    <TextBlock  Name="lblWindowSize">
                        <Run Text="{Binding ElementName=mainWindow, Path=ActualWidth, Mode=OneWay}" />
                        <Run Text=","/>
                        <Run Text="{Binding ElementName=mainWindow, Path=ActualHeight, Mode=OneWay}"/>
                    </TextBlock>
                    <TextBlock Text=" px" Name="lblPixels"  />
                </StackPanel>
            </Canvas>

            <ItemsControl HorizontalAlignment="Stretch" VerticalAlignment="Stretch" ItemsSource="{Binding Polygons}">
                <ItemsControl.ItemsPanel>
                    <ItemsPanelTemplate>
                        <Canvas HorizontalAlignment="Stretch" VerticalAlignment="Stretch">
                            <Canvas.RenderTransform>
                                <TransformGroup>
                                    <ScaleTransform ScaleY="-1"/>
                                    <TranslateTransform Y="{Binding RelativeSource={RelativeSource Mode=FindAncestor, AncestorType=Canvas,AncestorLevel=1}, Path=ActualHeight}" />
                                </TransformGroup>
                            </Canvas.RenderTransform>
                        </Canvas>
                    </ItemsPanelTemplate>
                </ItemsControl.ItemsPanel>
            </ItemsControl>

            <StackPanel Orientation="Horizontal" Grid.Row="1">
                <Slider Orientation="Horizontal" AutoToolTipPlacement="TopLeft" x:Name="sldSlider" VerticalAlignment="Bottom"
                 IsSnapToTickEnabled="True" Width="400" TickPlacement="BottomRight" Background="DimGray"  
                 TickFrequency="10" Maximum="100" Height="29" Value="{Binding RegionWidthPercentage}"/>

                <StackPanel x:Name="LayoutRoot" Background="LightGreen" Width="200">
                    <StackPanel Name="stpSliderPosition" Orientation="Horizontal" Width="100">
                        <TextBlock Margin="5,5,10,5">Slider</TextBlock>
                        <TextBlock Margin="5,5,0,5" TextAlignment="Left" Width="30" Text="{Binding Path=Value, ElementName=sldSlider, Mode=OneWay}" />
                        <TextBlock Margin="0,5">%</TextBlock>
                    </StackPanel>
                </StackPanel>
            </StackPanel>
        </Grid>
    </Border>
</Window> 

Open in new window

Avatar of VPry

ASKER

Hi Saragani! Thank you for the flip Canvas coordinates example!

Man, I feel so dumb looking at your app :(  I still do not understend how some of it works :\\\  MVVM is very different from ASP.NET.

What about this my question:
                                 
                                   How to make Window tranparent but with chrome around?
                                   I've done it by using styles in my static demo, but may be you know the better way?
I don't know what exactly you mean since I haven't seen your original code, since on your post (https://www.experts-exchange.com/questions/27035490/Create-dynamic-polygons-from-coordinates-in-WPF.html) you did not post the window's XAML, just it's content.

What do you mean transparent but with chrome around?

Can you show me a print-screen of what you mean (maybe from your original program)?
Avatar of VPry

ASKER

Here is original demo with transparent Window:
<Window x:Class="SquigglyLines.Window1" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    Title="Squiggly Lines Demo" Height="720" Width="960"
    WindowStyle="None" AllowsTransparency="True" WindowStartupLocation="CenterScreen"
    Background="Transparent" ResizeMode="CanMinimize">
    <Window.Resources>
        <LinearGradientBrush x:Key="WindowFrameBrush" StartPoint="0,0.5" EndPoint="1,0.5">
            <GradientStop Color="CadetBlue" Offset="0.4"/>
            <GradientStop Color="Gray" Offset="1"/>
        </LinearGradientBrush>

        <VisualBrush  x:Key="DotFillBrush" 
            TileMode="Tile" Viewport="0,0,10,10" ViewportUnits="Absolute" 
            Viewbox="0,0,12,12" ViewboxUnits="Absolute">
            <VisualBrush.Visual>
                <Ellipse         Fill="#00C0FF"         Width="10" Height="10" />
            </VisualBrush.Visual>
        </VisualBrush>
        <VisualBrush       x:Key="HatchBrush"       TileMode="Tile" Viewport="0,0,10,10"       ViewportUnits="Absolute" Viewbox="0,0,10,10"          ViewboxUnits="Absolute">
            <VisualBrush.Visual>
                <Canvas>
                    <Rectangle Fill="Azure" Width="10" Height="10" />
                    <Path Stroke="Purple" Data="M 0 0 l 10 10" />
                    <Path Stroke="Purple" Data="M 0 10 l 10 -10" />
                </Canvas>
            </VisualBrush.Visual>
        </VisualBrush>
    </Window.Resources>

    <Border Background="#50FFFFFF" CornerRadius="5" BorderBrush="{StaticResource WindowFrameBrush}" BorderThickness="2,0,2,2">
        <Grid>
            <Grid.RowDefinitions>
                <RowDefinition Height="30" />
                <RowDefinition/>
            </Grid.RowDefinitions>
            <Border Background="{StaticResource WindowFrameBrush}" HorizontalAlignment="Stretch" VerticalAlignment="Stretch"
              CornerRadius="5,5,0,0" Margin="-1,0,-1,0" MouseLeftButtonDown="DragWindow">
                <Grid>
                    <TextBlock Foreground="White" FontWeight="Bold" VerticalAlignment="Center" Margin="10,2,10,2"
            Text="{Binding RelativeSource={RelativeSource Mode=FindAncestor, AncestorType={x:Type Window}}, Path=Title}"/>
                    
                    <!--<Button Content="O" Name="MinMax" HorizontalAlignment="Right" VerticalAlignment="Center" Margin="0,0,25,0" FontSize="7"
                  Width="15" Height="15" Click="WindowMinMax" />-->
                    
                    <Button Content="X" HorizontalAlignment="Right" VerticalAlignment="Center" Margin="5" FontSize="7"
                  Width="15" Height="15" Padding="0" Command="ApplicationCommands.Close"/>
                </Grid>
            </Border>

            <!-- Begin Main Content-->
           
            <Grid VerticalAlignment="Center" HorizontalAlignment="Center" Margin="0, 35,0,0" >


                    <Canvas x:Name="mainCanvas" Background="Transparent" Height="670" Width="920" VerticalAlignment="Top" Margin="0,0,0,200">
                        <Canvas.LayoutTransform>
                            <ScaleTransform ScaleX="{Binding Path=Value, ElementName=zoomSlider}" 
                            ScaleY="{Binding Path=Value, ElementName=zoomSlider}"/>
                        </Canvas.LayoutTransform>

                    <!-- Begin Test Pattern Brushes
                        
                    <Rectangle Canvas.Top="20" Canvas.Left="20"   Width="80" Height="40"   Fill="{StaticResource DotFillBrush}"/>
                    <Rectangle Canvas.Top="20" Canvas.Left="120"   Width="80" Height="40"   Fill="{StaticResource HatchBrush}"/>
                    <TextBlock Canvas.Top="80" Canvas.Left="20"   Text="Hello" FontSize="80"   Foreground="{StaticResource DotFillBrush}"/>
                    <TextBlock Canvas.Top="80" Canvas.Left="220"   Text="World" FontSize="80"   Foreground="{StaticResource HatchBrush}"/>
                    
                    End Test Pattern Brushes -->
                        

                    <!-- Polygon Name="Blue" Points="   100, 100  200, 150  300, 250  400, 200  500, 100  600, 150  700, 250  800, 200  900, 250  1000, 300                              
                                                   1000, 350  900, 300  800, 250  700, 300  600, 200  500, 150  400, 250  300, 300  200, 200  100, 150 ">
                        <Polygon.Fill>
                            <SolidColorBrush Color="Blue"/>
                        </Polygon.Fill>
                    </Polygon -->


                    <!--<Polygon Name="Green"
                     Points="1000,350  900,300   800,250  700, 300   600, 200    500, 150    400, 250    300, 300    200, 200    100, 150    100, 300    200, 350    300, 450    400, 400    500, 300    600, 350    700, 450    800, 400    900, 450    1000, 500 ">
                        <Polygon.Fill>
                            <SolidColorBrush Color="Green"/>
                        </Polygon.Fill>
                    </Polygon>-->

                    <!--<Polygon Name="Brown" Points="100, 300  200, 350  300, 450  400, 400   
                                                      500, 300       600, 350       700, 450       800, 400    
                                                      900, 450       1000, 500       1000, 750       900, 700                              
                                                      800, 650       700, 700       600, 600       500, 550                              
                                                      400, 650       300, 700       200, 600       100, 550">
                        <Polygon.Fill>
                            <SolidColorBrush Color="Brown"/>
                        </Polygon.Fill>
                    </Polygon>-->
                        
                    <!-- Begin Canvas Border -->
                    <Line Stroke="Gray" StrokeThickness="2" Canvas.Bottom="0" Y1="670"></Line>
                    <Line Stroke="Gray" StrokeThickness="2" Canvas.Bottom="0" X1="920"></Line>
                    <Line Stroke="Gray" StrokeThickness="2" Canvas.Right="0" Y1="670"></Line>
                    <Line Stroke="Gray" StrokeThickness="2" Canvas.Right="0" X1="920"></Line>
                    <!-- End Canvas Border -->
                        
                 <Slider Orientation="Horizontal" AutoToolTipPlacement="TopLeft" Canvas.Bottom="0"
                 IsSnapToTickEnabled="True" Width="400" TickPlacement="BottomRight" Background="DimGray"  
                 TickFrequency="1" Maximum="9" ValueChanged="Slider_ValueChanged" Height="29" />
             </Canvas>
            </Grid>
            <!-- End Main Content -->
            
            
        </Grid>
    </Border>
</Window>
-----------------------------------------------------------------------------------------------------------------------------------
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;


namespace SquigglyLines
{
    /// <summary>
    /// Interaction logic for Page1.xaml
    /// </summary>
    public partial class Window1 : Window
    {
        private Polygon Pol1;
        private Polygon Pol2;
        private Polygon Pol3;
        ImageBrush Pol1PatternBrush = new ImageBrush();
        ImageBrush Pol2PatternBrush = new ImageBrush();
        ImageBrush Pol3PatternBrush = new ImageBrush();

        public Window1()
        {
            InitializeComponent();
            this.Topmost = true;
            CommandBindings.Add(new CommandBinding(ApplicationCommands.Close,
               new ExecutedRoutedEventHandler(delegate(object sender, ExecutedRoutedEventArgs args) { this.Close(); })));
            
            // Done in XAML
            //WindowStartupLocation = System.Windows.WindowStartupLocation.CenterScreen;

            InitializeComponent();
            Pol1 = new Polygon();
            Pol2 = new Polygon();
            Pol3 = new Polygon();
            
            Pol1PatternBrush.TileMode = TileMode.Tile;
            Pol1PatternBrush.Stretch = Stretch.None;
            Pol1PatternBrush.Viewport = new System.Windows.Rect(0, 0, 118, 36);
            Pol1PatternBrush.ViewportUnits = System.Windows.Media.BrushMappingMode.Absolute;
            Pol1PatternBrush.ImageSource = new BitmapImage(new Uri(@"Images\GasPattern.jpg", UriKind.Relative));
            Pol1.Fill = Pol1PatternBrush;

            Pol2PatternBrush.TileMode = TileMode.Tile;
            Pol2PatternBrush.Stretch = Stretch.None;
            Pol2PatternBrush.Viewport = new System.Windows.Rect(0, 0, 118, 36);
            Pol2PatternBrush.ViewportUnits = System.Windows.Media.BrushMappingMode.Absolute;
            Pol2PatternBrush.ImageSource = new BitmapImage(new Uri(@"Images\SandStonePattern.jpg", UriKind.Relative));
            Pol2.Fill = Pol2PatternBrush;

            Pol3PatternBrush.TileMode = TileMode.Tile;
            Pol3PatternBrush.Stretch = Stretch.None;
            Pol3PatternBrush.Viewport = new System.Windows.Rect(0, 0, 118, 36);
            Pol3PatternBrush.ViewportUnits = System.Windows.Media.BrushMappingMode.Absolute;       
            Pol3PatternBrush.ImageSource = new BitmapImage(new Uri(@"Images\OilPattern.jpg", UriKind.Relative));
            Pol3.Fill = Pol3PatternBrush;

            //Viewport="0,0,300,300"
            //ViewportUnits="Absolute"
            //TileMode="Tile"
            //Stretch="None"
            //AlignmentX="Left"
            //AlignmentY="Top"  />

            
       
            Pol1.Opacity = 0.7;
            Pol2.Opacity = 0.7;
            Pol3.Opacity = 0.7;
            Pol1.Points = new PointCollection();
            Pol2.Points = new PointCollection();
            Pol3.Points = new PointCollection();

            mainCanvas.Children.Add(Pol1);
            mainCanvas.Children.Add(Pol2);
            mainCanvas.Children.Add(Pol3);

            // Move all polygons up & left 
            TranslateTransform translateTransform1 = new TranslateTransform(-300, -100);

            Pol1.RenderTransform = translateTransform1;
            Pol2.RenderTransform = translateTransform1;
            Pol3.RenderTransform = translateTransform1;

            // Make all polygons smaller
            ScaleTransform scaleTransform1 = new ScaleTransform(0.8, 0.8);

            Pol1.RenderTransform = scaleTransform1;
            Pol2.RenderTransform = scaleTransform1;
            Pol3.RenderTransform = scaleTransform1;

        }

        public void DragWindow(object sender, MouseButtonEventArgs args)
        {
            DragMove();
        }

        private void Slider_ValueChanged(object sender, RoutedPropertyChangedEventArgs<double> e)
        {

            double value = e.NewValue;
            Pol1.Points.Clear();
            Pol2.Points.Clear();
            Pol3.Points.Clear();

            if (value == 0)
            {

            }

            if (value == 1)
            {                
                // BLUE
                //p.Points = new PointCollection() { new Point(100, 100), new Point(200, 150), new Point(300, 250), new Point(400, 200), 
                //new Point(500, 100), new Point(600, 150), new Point(700, 250), new Point(800, 200), 
                //new Point(900, 250), new Point(1000, 300), new Point(1000, 350), new Point(900, 300), 
                //new Point(800, 250), new Point(700, 300), new Point(600, 200), new Point(500, 150), 
                //new Point(400, 250), new Point(300, 300), new Point(200, 200), new Point(100, 150) };

                System.Windows.Point Point1_1 = new System.Windows.Point(100, 100);
                System.Windows.Point Point1_2 = new System.Windows.Point(200, 150);
                System.Windows.Point Point1_3 = new System.Windows.Point(200, 200);
                System.Windows.Point Point1_4 = new System.Windows.Point(100, 150);

                PointCollection myPointCollection1 = Pol1.Points;

                myPointCollection1.Add(Point1_1);
                myPointCollection1.Add(Point1_2);
                myPointCollection1.Add(Point1_3);
                myPointCollection1.Add(Point1_4);

                // GREEN
                // 1.Points = new PointCollection() { new Point( 1000,350  900,300   800,250  700, 300   600, 200    500, 150    400, 250    300, 300    200, 200    100, 150    100, 300    200, 350    300, 450    400, 400    500, 300    600, 350    700, 450    800, 400    900, 450    1000, 500 "
                
                System.Windows.Point Point2_1 = new System.Windows.Point(100, 150);
                System.Windows.Point Point2_2 = new System.Windows.Point(200, 200);
                System.Windows.Point Point2_3 = new System.Windows.Point(200, 350);
                System.Windows.Point Point2_4 = new System.Windows.Point(100, 300);

                PointCollection myPointCollection2 = Pol2.Points;

                myPointCollection2.Add(Point2_1);
                myPointCollection2.Add(Point2_2);
                myPointCollection2.Add(Point2_3);
                myPointCollection2.Add(Point2_4);
                
                // BROWN
                //p2.Points = new PointCollection() { new Point(100, 300), new Point(200, 350), new Point(300, 450), new Point(400, 400), 
                //                                    new Point(500, 300), new Point(600, 350), new Point(700, 450), new Point(800, 400), 
                //                                    new Point(900, 450), new Point(1000, 500), new Point(1000, 750), new Point(900, 700), 
                //                                    new Point(800, 650), new Point(700, 700), new Point(600, 600), new Point(500, 550), 
                //                                    new Point(400, 650), new Point(300, 700), new Point(200, 600), new Point(100, 550) };

                System.Windows.Point Point3_1 = new System.Windows.Point(100, 300);
                System.Windows.Point Point3_2 = new System.Windows.Point(200, 350);
                System.Windows.Point Point3_3 = new System.Windows.Point(200, 600);
                System.Windows.Point Point3_4 = new System.Windows.Point(100, 550);

                PointCollection myPointCollection3 = Pol3.Points;

                myPointCollection3.Add(Point3_1);
                myPointCollection3.Add(Point3_2);
                myPointCollection3.Add(Point3_3);
                myPointCollection3.Add(Point3_4);

            }

            if (value == 2)
            {
                // BLUE
                System.Windows.Point Point1_1 = new System.Windows.Point(100, 100);
                System.Windows.Point Point1_2 = new System.Windows.Point(200, 150);
                System.Windows.Point Point1_3 = new System.Windows.Point(300, 250);
                System.Windows.Point Point1_4 = new System.Windows.Point(300, 300);
                System.Windows.Point Point1_5 = new System.Windows.Point(200, 200);
                System.Windows.Point Point1_6 = new System.Windows.Point(100, 150);

                PointCollection myPointCollection1 = Pol1.Points;

                myPointCollection1.Add(Point1_1);
                myPointCollection1.Add(Point1_2);
                myPointCollection1.Add(Point1_3);
                myPointCollection1.Add(Point1_4);
                myPointCollection1.Add(Point1_5);
                myPointCollection1.Add(Point1_6);

                // GREEN
                // 1.Points = new PointCollection() { new Point( 1000,350  900,300   800,250  700, 300   600, 200    500, 150    400, 250    300, 300    200, 200    100, 150    100, 300    200, 350    300, 450    400, 400    500, 300    600, 350    700, 450    800, 400    900, 450    1000, 500 "
                System.Windows.Point Point2_1 = new System.Windows.Point(100, 150);
                System.Windows.Point Point2_2 = new System.Windows.Point(200, 200);
                System.Windows.Point Point2_3 = new System.Windows.Point(300, 300);
                System.Windows.Point Point2_4 = new System.Windows.Point(300, 450);
                System.Windows.Point Point2_5 = new System.Windows.Point(200, 350);
                System.Windows.Point Point2_6 = new System.Windows.Point(100, 300);

                PointCollection myPointCollection2 = Pol2.Points;

                myPointCollection2.Add(Point2_1);
                myPointCollection2.Add(Point2_2);
                myPointCollection2.Add(Point2_3);
                myPointCollection2.Add(Point2_4);
                myPointCollection2.Add(Point2_5);
                myPointCollection2.Add(Point2_6);

                // BROWN
                System.Windows.Point Point3_1 = new System.Windows.Point(100, 300);
                System.Windows.Point Point3_2 = new System.Windows.Point(200, 350);
                System.Windows.Point Point3_3 = new System.Windows.Point(300, 450);
                System.Windows.Point Point3_4 = new System.Windows.Point(300, 700);
                System.Windows.Point Point3_5 = new System.Windows.Point(200, 600);
                System.Windows.Point Point3_6 = new System.Windows.Point(100, 550);

                PointCollection myPointCollection3 = Pol3.Points;

                myPointCollection3.Add(Point3_1);
                myPointCollection3.Add(Point3_2);
                myPointCollection3.Add(Point3_3);
                myPointCollection3.Add(Point3_4);
                myPointCollection3.Add(Point3_5);
                myPointCollection3.Add(Point3_6);
            }

            if (value == 3)
            {
                // BLUE
                System.Windows.Point Point1_1 = new System.Windows.Point(100, 100);
                System.Windows.Point Point1_2 = new System.Windows.Point(200, 150);
                System.Windows.Point Point1_3 = new System.Windows.Point(300, 250);
                System.Windows.Point Point1_4 = new System.Windows.Point(400, 200);
                System.Windows.Point Point1_5 = new System.Windows.Point(400, 250);
                System.Windows.Point Point1_6 = new System.Windows.Point(300, 300);
                System.Windows.Point Point1_7 = new System.Windows.Point(200, 200);
                System.Windows.Point Point1_8 = new System.Windows.Point(100, 150);

                PointCollection myPointCollection1 = Pol1.Points;

                myPointCollection1.Add(Point1_1);
                myPointCollection1.Add(Point1_2);
                myPointCollection1.Add(Point1_3);
                myPointCollection1.Add(Point1_4);
                myPointCollection1.Add(Point1_5);
                myPointCollection1.Add(Point1_6);
                myPointCollection1.Add(Point1_7);
                myPointCollection1.Add(Point1_8);

                // GREEN
                // 1.Points = new PointCollection() { new Point( 1000,350  900,300   800,250  700, 300   600, 200    500, 150    400, 250    300, 300    200, 200    100, 150    100, 300    200, 350    300, 450    400, 400    500, 300    600, 350    700, 450    800, 400    900, 450    1000, 500 "
                System.Windows.Point Point2_1 = new System.Windows.Point(100, 150);
                System.Windows.Point Point2_2 = new System.Windows.Point(200, 200);
                System.Windows.Point Point2_3 = new System.Windows.Point(300, 300);
                System.Windows.Point Point2_4 = new System.Windows.Point(400, 250);
                System.Windows.Point Point2_5 = new System.Windows.Point(400, 400);
                System.Windows.Point Point2_6 = new System.Windows.Point(300, 450);
                System.Windows.Point Point2_7 = new System.Windows.Point(200, 350);
                System.Windows.Point Point2_8 = new System.Windows.Point(100, 300);

                PointCollection myPointCollection2 = Pol2.Points;

                myPointCollection2.Add(Point2_1);
                myPointCollection2.Add(Point2_2);
                myPointCollection2.Add(Point2_3);
                myPointCollection2.Add(Point2_4);
                myPointCollection2.Add(Point2_5);
                myPointCollection2.Add(Point2_6);
                myPointCollection2.Add(Point2_7);
                myPointCollection2.Add(Point2_8);

                // BROWN
                System.Windows.Point Point3_1 = new System.Windows.Point(100, 300);
                System.Windows.Point Point3_2 = new System.Windows.Point(200, 350);
                System.Windows.Point Point3_3 = new System.Windows.Point(300, 450);
                System.Windows.Point Point3_4 = new System.Windows.Point(400, 400);
                System.Windows.Point Point3_5 = new System.Windows.Point(400, 650);
                System.Windows.Point Point3_6 = new System.Windows.Point(300, 700);
                System.Windows.Point Point3_7 = new System.Windows.Point(200, 600);
                System.Windows.Point Point3_8 = new System.Windows.Point(100, 550);

                PointCollection myPointCollection3 = Pol3.Points;

                myPointCollection3.Add(Point3_1);
                myPointCollection3.Add(Point3_2);
                myPointCollection3.Add(Point3_3);
                myPointCollection3.Add(Point3_4);
                myPointCollection3.Add(Point3_5);
                myPointCollection3.Add(Point3_6);
                myPointCollection3.Add(Point3_7);
                myPointCollection3.Add(Point3_8);
            }
            
            if (value == 4)
            {
                // BLUE
                System.Windows.Point Point1_1 = new System.Windows.Point(100, 100);
                System.Windows.Point Point1_2 = new System.Windows.Point(200, 150);
                System.Windows.Point Point1_3 = new System.Windows.Point(300, 250);
                System.Windows.Point Point1_4 = new System.Windows.Point(400, 200);
                System.Windows.Point Point1_5 = new System.Windows.Point(500, 100);
                System.Windows.Point Point1_6 = new System.Windows.Point(500, 150);
                System.Windows.Point Point1_7 = new System.Windows.Point(400, 250);
                System.Windows.Point Point1_8 = new System.Windows.Point(300, 300);
                System.Windows.Point Point1_9 = new System.Windows.Point(200, 200);
                System.Windows.Point Point1_10 = new System.Windows.Point(100, 150);

                PointCollection myPointCollection1 = Pol1.Points;

                myPointCollection1.Add(Point1_1);
                myPointCollection1.Add(Point1_2);
                myPointCollection1.Add(Point1_3);
                myPointCollection1.Add(Point1_4);
                myPointCollection1.Add(Point1_5);
                myPointCollection1.Add(Point1_6);
                myPointCollection1.Add(Point1_7);
                myPointCollection1.Add(Point1_8);
                myPointCollection1.Add(Point1_9);
                myPointCollection1.Add(Point1_10);

                // GREEN
                // 1.Points = new PointCollection() { new Point( 1000,350  900,300   800,250  700, 300   600, 200    500, 150    400, 250    300, 300    200, 200    100, 150    100, 300    200, 350    300, 450    400, 400    500, 300    600, 350    700, 450    800, 400    900, 450    1000, 500 "
                System.Windows.Point Point2_1 = new System.Windows.Point(100, 150);
                System.Windows.Point Point2_2 = new System.Windows.Point(200, 200);
                System.Windows.Point Point2_3 = new System.Windows.Point(300, 300);
                System.Windows.Point Point2_4 = new System.Windows.Point(400, 250);
                System.Windows.Point Point2_5 = new System.Windows.Point(500, 150);
                System.Windows.Point Point2_6 = new System.Windows.Point(500, 300);
                System.Windows.Point Point2_7 = new System.Windows.Point(400, 400);
                System.Windows.Point Point2_8 = new System.Windows.Point(300, 450);
                System.Windows.Point Point2_9 = new System.Windows.Point(200, 350);
                System.Windows.Point Point2_10 = new System.Windows.Point(100, 300);

                PointCollection myPointCollection2 = Pol2.Points;

                myPointCollection2.Add(Point2_1);
                myPointCollection2.Add(Point2_2);
                myPointCollection2.Add(Point2_3);
                myPointCollection2.Add(Point2_4);
                myPointCollection2.Add(Point2_5);
                myPointCollection2.Add(Point2_6);
                myPointCollection2.Add(Point2_7);
                myPointCollection2.Add(Point2_8);
                myPointCollection2.Add(Point2_9);
                myPointCollection2.Add(Point2_10);

                // BROWN
                System.Windows.Point Point3_1 = new System.Windows.Point(100, 300);
                System.Windows.Point Point3_2 = new System.Windows.Point(200, 350);
                System.Windows.Point Point3_3 = new System.Windows.Point(300, 450);
                System.Windows.Point Point3_4 = new System.Windows.Point(400, 400);
                System.Windows.Point Point3_5 = new System.Windows.Point(500, 300);
                System.Windows.Point Point3_6 = new System.Windows.Point(500, 550);
                System.Windows.Point Point3_7 = new System.Windows.Point(400, 650);
                System.Windows.Point Point3_8 = new System.Windows.Point(300, 700);
                System.Windows.Point Point3_9 = new System.Windows.Point(200, 600);
                System.Windows.Point Point3_10 = new System.Windows.Point(100, 550);

                PointCollection myPointCollection3 = Pol3.Points;

                myPointCollection3.Add(Point3_1);
                myPointCollection3.Add(Point3_2);
                myPointCollection3.Add(Point3_3);
                myPointCollection3.Add(Point3_4);
                myPointCollection3.Add(Point3_5);
                myPointCollection3.Add(Point3_6);
                myPointCollection3.Add(Point3_7);
                myPointCollection3.Add(Point3_8);
                myPointCollection3.Add(Point3_9);
                myPointCollection3.Add(Point3_10);
            }

            if (value == 5)
            {
                // BLUE
                System.Windows.Point Point1_1 = new System.Windows.Point(100, 100);
                System.Windows.Point Point1_2 = new System.Windows.Point(200, 150);
                System.Windows.Point Point1_3 = new System.Windows.Point(300, 250);
                System.Windows.Point Point1_4 = new System.Windows.Point(400, 200);
                System.Windows.Point Point1_5 = new System.Windows.Point(500, 100);
                System.Windows.Point Point1_6 = new System.Windows.Point(600, 150);
                System.Windows.Point Point1_7 = new System.Windows.Point(600, 200);
                System.Windows.Point Point1_8 = new System.Windows.Point(500, 150);
                System.Windows.Point Point1_9 = new System.Windows.Point(400, 250);
                System.Windows.Point Point1_10 = new System.Windows.Point(300, 300);
                System.Windows.Point Point1_11 = new System.Windows.Point(200, 200);
                System.Windows.Point Point1_12 = new System.Windows.Point(100, 150);

                PointCollection myPointCollection1 = Pol1.Points;

                myPointCollection1.Add(Point1_1);
                myPointCollection1.Add(Point1_2);
                myPointCollection1.Add(Point1_3);
                myPointCollection1.Add(Point1_4);
                myPointCollection1.Add(Point1_5);
                myPointCollection1.Add(Point1_6);
                myPointCollection1.Add(Point1_7);
                myPointCollection1.Add(Point1_8);
                myPointCollection1.Add(Point1_9);
                myPointCollection1.Add(Point1_10);
                myPointCollection1.Add(Point1_11);
                myPointCollection1.Add(Point1_12);

                // GREEN                
                System.Windows.Point Point2_1 = new System.Windows.Point(100, 150);
                System.Windows.Point Point2_2 = new System.Windows.Point(200, 200);
                System.Windows.Point Point2_3 = new System.Windows.Point(300, 300);
                System.Windows.Point Point2_4 = new System.Windows.Point(400, 250);
                System.Windows.Point Point2_5 = new System.Windows.Point(500, 150);
                System.Windows.Point Point2_6 = new System.Windows.Point(600, 200);
                System.Windows.Point Point2_7 = new System.Windows.Point(600, 350);
                System.Windows.Point Point2_8 = new System.Windows.Point(500, 300);
                System.Windows.Point Point2_9 = new System.Windows.Point(400, 400);
                System.Windows.Point Point2_10 = new System.Windows.Point(300, 450);
                System.Windows.Point Point2_11 = new System.Windows.Point(200, 350);
                System.Windows.Point Point2_12 = new System.Windows.Point(100, 300);

                PointCollection myPointCollection2 = Pol2.Points;

                myPointCollection2.Add(Point2_1);
                myPointCollection2.Add(Point2_2);
                myPointCollection2.Add(Point2_3);
                myPointCollection2.Add(Point2_4);
                myPointCollection2.Add(Point2_5);
                myPointCollection2.Add(Point2_6);
                myPointCollection2.Add(Point2_7);
                myPointCollection2.Add(Point2_8);
                myPointCollection2.Add(Point2_9);
                myPointCollection2.Add(Point2_10);
                myPointCollection2.Add(Point2_11);
                myPointCollection2.Add(Point2_12);

                // BROWN
                System.Windows.Point Point3_1 = new System.Windows.Point(100, 300);
                System.Windows.Point Point3_2 = new System.Windows.Point(200, 350);
                System.Windows.Point Point3_3 = new System.Windows.Point(300, 450);
                System.Windows.Point Point3_4 = new System.Windows.Point(400, 400);
                System.Windows.Point Point3_5 = new System.Windows.Point(500, 300);
                System.Windows.Point Point3_6 = new System.Windows.Point(600, 350);
                System.Windows.Point Point3_7 = new System.Windows.Point(600, 600);
                System.Windows.Point Point3_8 = new System.Windows.Point(500, 550);
                System.Windows.Point Point3_9 = new System.Windows.Point(400, 650);
                System.Windows.Point Point3_10 = new System.Windows.Point(300, 700);
                System.Windows.Point Point3_11 = new System.Windows.Point(200, 600);
                System.Windows.Point Point3_12 = new System.Windows.Point(100, 550);

                PointCollection myPointCollection3 = Pol3.Points;

                myPointCollection3.Add(Point3_1);
                myPointCollection3.Add(Point3_2);
                myPointCollection3.Add(Point3_3);
                myPointCollection3.Add(Point3_4);
                myPointCollection3.Add(Point3_5);
                myPointCollection3.Add(Point3_6);
                myPointCollection3.Add(Point3_7);
                myPointCollection3.Add(Point3_8);
                myPointCollection3.Add(Point3_9);
                myPointCollection3.Add(Point3_10);
                myPointCollection3.Add(Point3_11);
                myPointCollection3.Add(Point3_12);
            }

            if (value == 6)
            {
                // BLUE
                System.Windows.Point Point1_1 = new System.Windows.Point(100, 100);
                System.Windows.Point Point1_2 = new System.Windows.Point(200, 150);
                System.Windows.Point Point1_3 = new System.Windows.Point(300, 250);
                System.Windows.Point Point1_4 = new System.Windows.Point(400, 200);
                System.Windows.Point Point1_5 = new System.Windows.Point(500, 100);
                System.Windows.Point Point1_6 = new System.Windows.Point(600, 150);
                System.Windows.Point Point1_7 = new System.Windows.Point(700, 250);
                System.Windows.Point Point1_8 = new System.Windows.Point(700, 300);
                System.Windows.Point Point1_9 = new System.Windows.Point(600, 200);
                System.Windows.Point Point1_10 = new System.Windows.Point(500, 150);
                System.Windows.Point Point1_11 = new System.Windows.Point(400, 250);
                System.Windows.Point Point1_12 = new System.Windows.Point(300, 300);
                System.Windows.Point Point1_13 = new System.Windows.Point(200, 200);
                System.Windows.Point Point1_14 = new System.Windows.Point(100, 150);

                PointCollection myPointCollection1 = Pol1.Points;

                myPointCollection1.Add(Point1_1);
                myPointCollection1.Add(Point1_2);
                myPointCollection1.Add(Point1_3);
                myPointCollection1.Add(Point1_4);
                myPointCollection1.Add(Point1_5);
                myPointCollection1.Add(Point1_6);
                myPointCollection1.Add(Point1_7);
                myPointCollection1.Add(Point1_8);
                myPointCollection1.Add(Point1_9);
                myPointCollection1.Add(Point1_10);
                myPointCollection1.Add(Point1_11);
                myPointCollection1.Add(Point1_12);
                myPointCollection1.Add(Point1_13);
                myPointCollection1.Add(Point1_14);

                // GREEN                
                System.Windows.Point Point2_1 = new System.Windows.Point(100, 150);
                System.Windows.Point Point2_2 = new System.Windows.Point(200, 200);
                System.Windows.Point Point2_3 = new System.Windows.Point(300, 300);
                System.Windows.Point Point2_4 = new System.Windows.Point(400, 250);
                System.Windows.Point Point2_5 = new System.Windows.Point(500, 150);
                System.Windows.Point Point2_6 = new System.Windows.Point(600, 200);
                System.Windows.Point Point2_7 = new System.Windows.Point(700, 300);
                System.Windows.Point Point2_8 = new System.Windows.Point(700, 450);
                System.Windows.Point Point2_9 = new System.Windows.Point(600, 350);
                System.Windows.Point Point2_10 = new System.Windows.Point(500, 300);
                System.Windows.Point Point2_11 = new System.Windows.Point(400, 400);
                System.Windows.Point Point2_12 = new System.Windows.Point(300, 450);
                System.Windows.Point Point2_13 = new System.Windows.Point(200, 350);
                System.Windows.Point Point2_14 = new System.Windows.Point(100, 300);

                PointCollection myPointCollection2 = Pol2.Points;

                myPointCollection2.Add(Point2_1);
                myPointCollection2.Add(Point2_2);
                myPointCollection2.Add(Point2_3);
                myPointCollection2.Add(Point2_4);
                myPointCollection2.Add(Point2_5);
                myPointCollection2.Add(Point2_6);
                myPointCollection2.Add(Point2_7);
                myPointCollection2.Add(Point2_8);
                myPointCollection2.Add(Point2_9);
                myPointCollection2.Add(Point2_10);
                myPointCollection2.Add(Point2_11);
                myPointCollection2.Add(Point2_12);
                myPointCollection2.Add(Point2_13);
                myPointCollection2.Add(Point2_14);

                // BROWN
                System.Windows.Point Point3_1 = new System.Windows.Point(100, 300);
                System.Windows.Point Point3_2 = new System.Windows.Point(200, 350);
                System.Windows.Point Point3_3 = new System.Windows.Point(300, 450);
                System.Windows.Point Point3_4 = new System.Windows.Point(400, 400);
                System.Windows.Point Point3_5 = new System.Windows.Point(500, 300);
                System.Windows.Point Point3_6 = new System.Windows.Point(600, 350);
                System.Windows.Point Point3_7 = new System.Windows.Point(700, 450);
                System.Windows.Point Point3_8 = new System.Windows.Point(700, 700);
                System.Windows.Point Point3_9 = new System.Windows.Point(600, 600);
                System.Windows.Point Point3_10 = new System.Windows.Point(500, 550);
                System.Windows.Point Point3_11 = new System.Windows.Point(400, 650);
                System.Windows.Point Point3_12 = new System.Windows.Point(300, 700);
                System.Windows.Point Point3_13 = new System.Windows.Point(200, 600);
                System.Windows.Point Point3_14 = new System.Windows.Point(100, 550);

                PointCollection myPointCollection3 = Pol3.Points;

                myPointCollection3.Add(Point3_1);
                myPointCollection3.Add(Point3_2);
                myPointCollection3.Add(Point3_3);
                myPointCollection3.Add(Point3_4);
                myPointCollection3.Add(Point3_5);
                myPointCollection3.Add(Point3_6);
                myPointCollection3.Add(Point3_7);
                myPointCollection3.Add(Point3_8);
                myPointCollection3.Add(Point3_9);
                myPointCollection3.Add(Point3_10);
                myPointCollection3.Add(Point3_11);
                myPointCollection3.Add(Point3_12);
                myPointCollection3.Add(Point3_13);
                myPointCollection3.Add(Point3_14);
            }

            if (value == 7)
            {
                // BLUE
                System.Windows.Point Point1_1 = new System.Windows.Point(100, 100);
                System.Windows.Point Point1_2 = new System.Windows.Point(200, 150);
                System.Windows.Point Point1_3 = new System.Windows.Point(300, 250);
                System.Windows.Point Point1_4 = new System.Windows.Point(400, 200);
                System.Windows.Point Point1_5 = new System.Windows.Point(500, 100);
                System.Windows.Point Point1_6 = new System.Windows.Point(600, 150);
                System.Windows.Point Point1_7 = new System.Windows.Point(700, 250);

                System.Windows.Point Point1_8 = new System.Windows.Point(800, 200);
                System.Windows.Point Point1_9 = new System.Windows.Point(800, 250);

                System.Windows.Point Point1_10 = new System.Windows.Point(700, 300);
                System.Windows.Point Point1_11 = new System.Windows.Point(600, 200);
                System.Windows.Point Point1_12 = new System.Windows.Point(500, 150);
                System.Windows.Point Point1_13 = new System.Windows.Point(400, 250);
                System.Windows.Point Point1_14 = new System.Windows.Point(300, 300);
                System.Windows.Point Point1_15 = new System.Windows.Point(200, 200);
                System.Windows.Point Point1_16 = new System.Windows.Point(100, 150);

                PointCollection myPointCollection1 = Pol1.Points;

                myPointCollection1.Add(Point1_1);
                myPointCollection1.Add(Point1_2);
                myPointCollection1.Add(Point1_3);
                myPointCollection1.Add(Point1_4);
                myPointCollection1.Add(Point1_5);
                myPointCollection1.Add(Point1_6);
                myPointCollection1.Add(Point1_7);
                myPointCollection1.Add(Point1_8);
                myPointCollection1.Add(Point1_9);
                myPointCollection1.Add(Point1_10);
                myPointCollection1.Add(Point1_11);
                myPointCollection1.Add(Point1_12);
                myPointCollection1.Add(Point1_13);
                myPointCollection1.Add(Point1_14);
                myPointCollection1.Add(Point1_15);
                myPointCollection1.Add(Point1_16);

                // GREEN                
                System.Windows.Point Point2_1 = new System.Windows.Point(100, 150);
                System.Windows.Point Point2_2 = new System.Windows.Point(200, 200);
                System.Windows.Point Point2_3 = new System.Windows.Point(300, 300);
                System.Windows.Point Point2_4 = new System.Windows.Point(400, 250);
                System.Windows.Point Point2_5 = new System.Windows.Point(500, 150);
                System.Windows.Point Point2_6 = new System.Windows.Point(600, 200);
                System.Windows.Point Point2_7 = new System.Windows.Point(700, 300);

                System.Windows.Point Point2_8 = new System.Windows.Point(800, 250);
                System.Windows.Point Point2_9 = new System.Windows.Point(800, 400);

                System.Windows.Point Point2_10 = new System.Windows.Point(700, 450);
                System.Windows.Point Point2_11 = new System.Windows.Point(600, 350);
                System.Windows.Point Point2_12 = new System.Windows.Point(500, 300);
                System.Windows.Point Point2_13 = new System.Windows.Point(400, 400);
                System.Windows.Point Point2_14 = new System.Windows.Point(300, 450);
                System.Windows.Point Point2_15 = new System.Windows.Point(200, 350);
                System.Windows.Point Point2_16 = new System.Windows.Point(100, 300);

                PointCollection myPointCollection2 = Pol2.Points;

                myPointCollection2.Add(Point2_1);
                myPointCollection2.Add(Point2_2);
                myPointCollection2.Add(Point2_3);
                myPointCollection2.Add(Point2_4);
                myPointCollection2.Add(Point2_5);
                myPointCollection2.Add(Point2_6);
                myPointCollection2.Add(Point2_7);
                myPointCollection2.Add(Point2_8);
                myPointCollection2.Add(Point2_9);
                myPointCollection2.Add(Point2_10);
                myPointCollection2.Add(Point2_11);
                myPointCollection2.Add(Point2_12);
                myPointCollection2.Add(Point2_13);
                myPointCollection2.Add(Point2_14);
                myPointCollection2.Add(Point2_15);
                myPointCollection2.Add(Point2_16);

                // BROWN
                System.Windows.Point Point3_1 = new System.Windows.Point(100, 300);
                System.Windows.Point Point3_2 = new System.Windows.Point(200, 350);
                System.Windows.Point Point3_3 = new System.Windows.Point(300, 450);
                System.Windows.Point Point3_4 = new System.Windows.Point(400, 400);
                System.Windows.Point Point3_5 = new System.Windows.Point(500, 300);
                System.Windows.Point Point3_6 = new System.Windows.Point(600, 350);
                System.Windows.Point Point3_7 = new System.Windows.Point(700, 450);

                System.Windows.Point Point3_8 = new System.Windows.Point(800, 400);
                System.Windows.Point Point3_9 = new System.Windows.Point(800, 650);

                System.Windows.Point Point3_10 = new System.Windows.Point(700, 700);
                System.Windows.Point Point3_11 = new System.Windows.Point(600, 600);
                System.Windows.Point Point3_12 = new System.Windows.Point(500, 550);
                System.Windows.Point Point3_13 = new System.Windows.Point(400, 650);
                System.Windows.Point Point3_14 = new System.Windows.Point(300, 700);
                System.Windows.Point Point3_15 = new System.Windows.Point(200, 600);
                System.Windows.Point Point3_16 = new System.Windows.Point(100, 550);

                PointCollection myPointCollection3 = Pol3.Points;

                myPointCollection3.Add(Point3_1);
                myPointCollection3.Add(Point3_2);
                myPointCollection3.Add(Point3_3);
                myPointCollection3.Add(Point3_4);
                myPointCollection3.Add(Point3_5);
                myPointCollection3.Add(Point3_6);
                myPointCollection3.Add(Point3_7);
                myPointCollection3.Add(Point3_8);
                myPointCollection3.Add(Point3_9);
                myPointCollection3.Add(Point3_10);
                myPointCollection3.Add(Point3_11);
                myPointCollection3.Add(Point3_12);
                myPointCollection3.Add(Point3_13);
                myPointCollection3.Add(Point3_14);
                myPointCollection3.Add(Point3_15);
                myPointCollection3.Add(Point3_16);
            }

            if (value == 8)
            {
                // BLUE
                System.Windows.Point Point1_1 = new System.Windows.Point(100, 100);
                System.Windows.Point Point1_2 = new System.Windows.Point(200, 150);
                System.Windows.Point Point1_3 = new System.Windows.Point(300, 250);
                System.Windows.Point Point1_4 = new System.Windows.Point(400, 200);
                System.Windows.Point Point1_5 = new System.Windows.Point(500, 100);
                System.Windows.Point Point1_6 = new System.Windows.Point(600, 150);
                System.Windows.Point Point1_7 = new System.Windows.Point(700, 250);
                System.Windows.Point Point1_8 = new System.Windows.Point(800, 200);

                System.Windows.Point Point1_9 = new System.Windows.Point(900, 250);
                System.Windows.Point Point1_10 = new System.Windows.Point(900, 300);

                System.Windows.Point Point1_11 = new System.Windows.Point(800, 250);
                System.Windows.Point Point1_12 = new System.Windows.Point(700, 300);
                System.Windows.Point Point1_13 = new System.Windows.Point(600, 200);
                System.Windows.Point Point1_14 = new System.Windows.Point(500, 150);
                System.Windows.Point Point1_15 = new System.Windows.Point(400, 250);
                System.Windows.Point Point1_16 = new System.Windows.Point(300, 300);
                System.Windows.Point Point1_17 = new System.Windows.Point(200, 200);
                System.Windows.Point Point1_18 = new System.Windows.Point(100, 150);

                PointCollection myPointCollection1 = Pol1.Points;

                myPointCollection1.Add(Point1_1);
                myPointCollection1.Add(Point1_2);
                myPointCollection1.Add(Point1_3);
                myPointCollection1.Add(Point1_4);
                myPointCollection1.Add(Point1_5);
                myPointCollection1.Add(Point1_6);
                myPointCollection1.Add(Point1_7);
                myPointCollection1.Add(Point1_8);
                myPointCollection1.Add(Point1_9);
                myPointCollection1.Add(Point1_10);
                myPointCollection1.Add(Point1_11);
                myPointCollection1.Add(Point1_12);
                myPointCollection1.Add(Point1_13);
                myPointCollection1.Add(Point1_14);
                myPointCollection1.Add(Point1_15);
                myPointCollection1.Add(Point1_16);
                myPointCollection1.Add(Point1_17);
                myPointCollection1.Add(Point1_18);

                // GREEN                
                System.Windows.Point Point2_1 = new System.Windows.Point(100, 150);
                System.Windows.Point Point2_2 = new System.Windows.Point(200, 200);
                System.Windows.Point Point2_3 = new System.Windows.Point(300, 300);
                System.Windows.Point Point2_4 = new System.Windows.Point(400, 250);
                System.Windows.Point Point2_5 = new System.Windows.Point(500, 150);
                System.Windows.Point Point2_6 = new System.Windows.Point(600, 200);
                System.Windows.Point Point2_7 = new System.Windows.Point(700, 300);
                System.Windows.Point Point2_8 = new System.Windows.Point(800, 250);
                System.Windows.Point Point2_9 = new System.Windows.Point(900, 300);
                System.Windows.Point Point2_10 = new System.Windows.Point(900, 450);
                System.Windows.Point Point2_11 = new System.Windows.Point(800, 400);
                System.Windows.Point Point2_12 = new System.Windows.Point(700, 450);
                System.Windows.Point Point2_13 = new System.Windows.Point(600, 350);
                System.Windows.Point Point2_14 = new System.Windows.Point(500, 300);
                System.Windows.Point Point2_15 = new System.Windows.Point(400, 400);
                System.Windows.Point Point2_16 = new System.Windows.Point(300, 450);
                System.Windows.Point Point2_17 = new System.Windows.Point(200, 350);
                System.Windows.Point Point2_18 = new System.Windows.Point(100, 300);

                PointCollection myPointCollection2 = Pol2.Points;

                myPointCollection2.Add(Point2_1);
                myPointCollection2.Add(Point2_2);
                myPointCollection2.Add(Point2_3);
                myPointCollection2.Add(Point2_4);
                myPointCollection2.Add(Point2_5);
                myPointCollection2.Add(Point2_6);
                myPointCollection2.Add(Point2_7);
                myPointCollection2.Add(Point2_8);
                myPointCollection2.Add(Point2_9);
                myPointCollection2.Add(Point2_10);
                myPointCollection2.Add(Point2_11);
                myPointCollection2.Add(Point2_12);
                myPointCollection2.Add(Point2_13);
                myPointCollection2.Add(Point2_14);
                myPointCollection2.Add(Point2_15);
                myPointCollection2.Add(Point2_16);
                myPointCollection2.Add(Point2_17);
                myPointCollection2.Add(Point2_18);

                // BROWN
                System.Windows.Point Point3_1 = new System.Windows.Point(100, 300);
                System.Windows.Point Point3_2 = new System.Windows.Point(200, 350);
                System.Windows.Point Point3_3 = new System.Windows.Point(300, 450);
                System.Windows.Point Point3_4 = new System.Windows.Point(400, 400);
                System.Windows.Point Point3_5 = new System.Windows.Point(500, 300);
                System.Windows.Point Point3_6 = new System.Windows.Point(600, 350);
                System.Windows.Point Point3_7 = new System.Windows.Point(700, 450);
                System.Windows.Point Point3_8 = new System.Windows.Point(800, 400);
                System.Windows.Point Point3_9 = new System.Windows.Point(900, 450);
                System.Windows.Point Point3_10 = new System.Windows.Point(900, 700);
                System.Windows.Point Point3_11 = new System.Windows.Point(800, 650);
                System.Windows.Point Point3_12 = new System.Windows.Point(700, 700);
                System.Windows.Point Point3_13 = new System.Windows.Point(600, 600);
                System.Windows.Point Point3_14 = new System.Windows.Point(500, 550);
                System.Windows.Point Point3_15 = new System.Windows.Point(400, 650);
                System.Windows.Point Point3_16 = new System.Windows.Point(300, 700);
                System.Windows.Point Point3_17 = new System.Windows.Point(200, 600);
                System.Windows.Point Point3_18 = new System.Windows.Point(100, 550);

                PointCollection myPointCollection3 = Pol3.Points;

                myPointCollection3.Add(Point3_1);
                myPointCollection3.Add(Point3_2);
                myPointCollection3.Add(Point3_3);
                myPointCollection3.Add(Point3_4);
                myPointCollection3.Add(Point3_5);
                myPointCollection3.Add(Point3_6);
                myPointCollection3.Add(Point3_7);
                myPointCollection3.Add(Point3_8);
                myPointCollection3.Add(Point3_9);
                myPointCollection3.Add(Point3_10);
                myPointCollection3.Add(Point3_11);
                myPointCollection3.Add(Point3_12);
                myPointCollection3.Add(Point3_13);
                myPointCollection3.Add(Point3_14);
                myPointCollection3.Add(Point3_15);
                myPointCollection3.Add(Point3_16);
                myPointCollection3.Add(Point3_17);
                myPointCollection3.Add(Point3_18);
            }

            if (value == 9)
            {
                // BLUE
                System.Windows.Point Point1_1 = new System.Windows.Point(100, 100);
                System.Windows.Point Point1_2 = new System.Windows.Point(200, 150);
                System.Windows.Point Point1_3 = new System.Windows.Point(300, 250);
                System.Windows.Point Point1_4 = new System.Windows.Point(400, 200);
                System.Windows.Point Point1_5 = new System.Windows.Point(500, 100);
                System.Windows.Point Point1_6 = new System.Windows.Point(600, 150);
                System.Windows.Point Point1_7 = new System.Windows.Point(700, 250);
                System.Windows.Point Point1_8 = new System.Windows.Point(800, 200);
                System.Windows.Point Point1_9 = new System.Windows.Point(900, 250);
                System.Windows.Point Point1_10 = new System.Windows.Point(1000, 300);
                System.Windows.Point Point1_11 = new System.Windows.Point(1000, 350);
                System.Windows.Point Point1_12 = new System.Windows.Point(900, 300);
                System.Windows.Point Point1_13 = new System.Windows.Point(800, 250);
                System.Windows.Point Point1_14 = new System.Windows.Point(700, 300);
                System.Windows.Point Point1_15 = new System.Windows.Point(600, 200);
                System.Windows.Point Point1_16 = new System.Windows.Point(500, 150);
                System.Windows.Point Point1_17 = new System.Windows.Point(400, 250);
                System.Windows.Point Point1_18 = new System.Windows.Point(300, 300);
                System.Windows.Point Point1_19 = new System.Windows.Point(200, 200);
                System.Windows.Point Point1_20 = new System.Windows.Point(100, 150);

                PointCollection myPointCollection1 = Pol1.Points;

                myPointCollection1.Add(Point1_1);
                myPointCollection1.Add(Point1_2);
                myPointCollection1.Add(Point1_3);
                myPointCollection1.Add(Point1_4);
                myPointCollection1.Add(Point1_5);
                myPointCollection1.Add(Point1_6);
                myPointCollection1.Add(Point1_7);
                myPointCollection1.Add(Point1_8);
                myPointCollection1.Add(Point1_9);
                myPointCollection1.Add(Point1_10);
                myPointCollection1.Add(Point1_11);
                myPointCollection1.Add(Point1_12);
                myPointCollection1.Add(Point1_13);
                myPointCollection1.Add(Point1_14);
                myPointCollection1.Add(Point1_15);
                myPointCollection1.Add(Point1_16);
                myPointCollection1.Add(Point1_17);
                myPointCollection1.Add(Point1_18);
                myPointCollection1.Add(Point1_19);
                myPointCollection1.Add(Point1_20);

                // GREEN                
                System.Windows.Point Point2_1 = new System.Windows.Point(100, 150);
                System.Windows.Point Point2_2 = new System.Windows.Point(200, 200);
                System.Windows.Point Point2_3 = new System.Windows.Point(300, 300);
                System.Windows.Point Point2_4 = new System.Windows.Point(400, 250);
                System.Windows.Point Point2_5 = new System.Windows.Point(500, 150);
                System.Windows.Point Point2_6 = new System.Windows.Point(600, 200);
                System.Windows.Point Point2_7 = new System.Windows.Point(700, 300);
                System.Windows.Point Point2_8 = new System.Windows.Point(800, 250);
                System.Windows.Point Point2_9 = new System.Windows.Point(900, 300);
                System.Windows.Point Point2_10 = new System.Windows.Point(1000, 350);
                System.Windows.Point Point2_11 = new System.Windows.Point(1000, 500);
                System.Windows.Point Point2_12 = new System.Windows.Point(900, 450);
                System.Windows.Point Point2_13 = new System.Windows.Point(800, 400);
                System.Windows.Point Point2_14 = new System.Windows.Point(700, 450);
                System.Windows.Point Point2_15 = new System.Windows.Point(600, 350);
                System.Windows.Point Point2_16 = new System.Windows.Point(500, 300);
                System.Windows.Point Point2_17 = new System.Windows.Point(400, 400);
                System.Windows.Point Point2_18 = new System.Windows.Point(300, 450);
                System.Windows.Point Point2_19 = new System.Windows.Point(200, 350);
                System.Windows.Point Point2_20 = new System.Windows.Point(100, 300);

                PointCollection myPointCollection2 = Pol2.Points;

                myPointCollection2.Add(Point2_1);
                myPointCollection2.Add(Point2_2);
                myPointCollection2.Add(Point2_3);
                myPointCollection2.Add(Point2_4);
                myPointCollection2.Add(Point2_5);
                myPointCollection2.Add(Point2_6);
                myPointCollection2.Add(Point2_7);
                myPointCollection2.Add(Point2_8);
                myPointCollection2.Add(Point2_9);
                myPointCollection2.Add(Point2_10);
                myPointCollection2.Add(Point2_11);
                myPointCollection2.Add(Point2_12);
                myPointCollection2.Add(Point2_13);
                myPointCollection2.Add(Point2_14);
                myPointCollection2.Add(Point2_15);
                myPointCollection2.Add(Point2_16);
                myPointCollection2.Add(Point2_17);
                myPointCollection2.Add(Point2_18);
                myPointCollection2.Add(Point2_19);
                myPointCollection2.Add(Point2_20);

                // BROWN
                System.Windows.Point Point3_1 = new System.Windows.Point(100, 300);
                System.Windows.Point Point3_2 = new System.Windows.Point(200, 350);
                System.Windows.Point Point3_3 = new System.Windows.Point(300, 450);
                System.Windows.Point Point3_4 = new System.Windows.Point(400, 400);
                System.Windows.Point Point3_5 = new System.Windows.Point(500, 300);
                System.Windows.Point Point3_6 = new System.Windows.Point(600, 350);
                System.Windows.Point Point3_7 = new System.Windows.Point(700, 450);
                System.Windows.Point Point3_8 = new System.Windows.Point(800, 400);
                System.Windows.Point Point3_9 = new System.Windows.Point(900, 450);

                System.Windows.Point Point3_10 = new System.Windows.Point(1000, 500);
                System.Windows.Point Point3_11 = new System.Windows.Point(1000, 750);

                System.Windows.Point Point3_12 = new System.Windows.Point(900, 700);
                System.Windows.Point Point3_13 = new System.Windows.Point(800, 650);
                System.Windows.Point Point3_14 = new System.Windows.Point(700, 700);
                System.Windows.Point Point3_15 = new System.Windows.Point(600, 600);
                System.Windows.Point Point3_16 = new System.Windows.Point(500, 550);
                System.Windows.Point Point3_17 = new System.Windows.Point(400, 650);
                System.Windows.Point Point3_18 = new System.Windows.Point(300, 700);
                System.Windows.Point Point3_19 = new System.Windows.Point(200, 600);
                System.Windows.Point Point3_20 = new System.Windows.Point(100, 550);

                PointCollection myPointCollection3 = Pol3.Points;

                myPointCollection3.Add(Point3_1);
                myPointCollection3.Add(Point3_2);
                myPointCollection3.Add(Point3_3);
                myPointCollection3.Add(Point3_4);
                myPointCollection3.Add(Point3_5);
                myPointCollection3.Add(Point3_6);
                myPointCollection3.Add(Point3_7);
                myPointCollection3.Add(Point3_8);
                myPointCollection3.Add(Point3_9);
                myPointCollection3.Add(Point3_10);
                myPointCollection3.Add(Point3_11);
                myPointCollection3.Add(Point3_12);
                myPointCollection3.Add(Point3_13);
                myPointCollection3.Add(Point3_14);
                myPointCollection3.Add(Point3_15);
                myPointCollection3.Add(Point3_16);
                myPointCollection3.Add(Point3_17);
                myPointCollection3.Add(Point3_18);
                myPointCollection3.Add(Point3_19);
                myPointCollection3.Add(Point3_20);
            }

        }

     }
}

Open in new window

Unfortunately, you cannot have both Window Chrome and allowtransparency=true together.
Your way looks fine.

Avatar of VPry

ASKER

I only have close button "X" on my transparent chrome.

                How to add minimize and restore buttons? To make it look like browser window.
                What commands should I use for these buttons?

Thank you! :)
Avatar of VPry

ASKER

Man, you ROCK! :))) Thank you a lot! :)))
Avatar of VPry

ASKER

Hey Saragani,
Here is range slider example:

http://www.thejoyofcode.com/Creating_a_Range_Slider_in_WPF_and_other_cool_tips_and_tricks_for_UserControls_.aspx

What is your opinion? Is it a good solution or you know a better way to accomplish this?

I want to implement range slider in my app. If user wants to see the slice of the Canvas in the range between choosen percents:
                      |-----hidden--------| | polygons to show | |-----------------hidden-------------------|                            
                      0%                     30%                          60%                                                 100%

Thank you!
It looks like a good idea