Example #1
0
        private Point OnLineMoved(_Line source, Point point1, Point point2)
        {
            if (!DesginCanvas.IsAutoAlign)
            {
                return(point1);
            }
            Point a = new Point(point1.X + source.Left, point1.Y + source.Top);
            Point b = new Point(point2.X + source.Left, point2.Y + source.Top);

            AlignCanvas.Clear();
            Point point = new Point(double.NaN, double.NaN);

            foreach (UIElement ui in DesginCanvas.Children)
            {
                if (DesginCanvas.SelectedControls.Contains(ui as _Control))
                {
                    continue;
                }
                if (ui is _Line)
                {
                    _Line line = ui as _Line;
                    point = AlignCanvas.MeasurePoint(a, b, new Point(line.Line.X1 + line.Left, line.Line.Y1 + line.Top), new Point(line.Line.X2 + line.Left, line.Line.Y2 + line.Top));
                    if (!double.IsNaN(point.X))
                    {
                        return(new Point(point.X - source.Left, point.Y - source.Top));
                    }
                }
                else if (ui is _Rectangle)
                {
                    _Control element = ui as _Control;
                    Point    a1      = new Point(element.Left, element.Top);
                    Point    b1      = new Point(element.Left + element.Width, element.Top);
                    Point    c1      = new Point(element.Left + element.Width, element.Top + element.Height);
                    Point    d1      = new Point(element.Left, element.Top + element.Height);
                    point = AlignCanvas.MeasurePoint(a, b, a1, b1);
                    if (!double.IsNaN(point.X))
                    {
                        return(new Point(point.X - source.Left, point.Y - source.Top));
                    }
                    else if (!double.IsNaN((point = AlignCanvas.MeasurePoint(a, b, b1, c1)).X))
                    {
                        return(new Point(point.X - source.Left, point.Y - source.Top));
                    }
                    else if (!double.IsNaN((point = AlignCanvas.MeasurePoint(a, b, c1, d1)).X))
                    {
                        return(new Point(point.X - source.Left, point.Y - source.Top));
                    }
                    else if (!double.IsNaN((point = AlignCanvas.MeasurePoint(a, b, d1, a1)).X))
                    {
                        return(new Point(point.X - source.Left, point.Y - source.Top));
                    }
                }
            }

            return(AlignCanvas.Orthogonal(point1, point2));
        }
Example #2
0
 public Move(_Line myLine, Cost c, int moveDistance)
 {
     this.myLine        = myLine;
     this.cost          = c.SummaryCost;
     this.areacost      = c.AreaCost;
     this.layoutcost    = c.LayoutCost;
     this.constaintCost = c.ConstaintCost;
     this.moveDistance  = moveDistance;
     Cost = c;
 }
Example #3
0
 public void OnLineMoving(_Line source, Point a, Point b)
 {
     if (!DesginCanvas.IsAutoAlign)
     {
         return;
     }
     a.X += source.Left;
     a.Y += source.Top;
     b.X += source.Left;
     b.Y += source.Top;
     LineAddingMode(source, a, b);
 }
Example #4
0
        private void OnLinePoint1Adding(_Line source, Point a)
        {
            if (!DesginCanvas.IsAutoAlign)
            {
                return;
            }
            List <Point> points = new List <Point>();

            foreach (UIElement ui in DesginCanvas.Children)
            {
                if (DesginCanvas.SelectedControls.Contains(ui as _Control))
                {
                    continue;
                }
                if (ui is _Line)
                {
                    _Line line  = ui as _Line;
                    Point point = AlignCanvas.MeasurePoint(a, new Point(line.Line.X1 + line.Left, line.Line.Y1 + line.Top), new Point(line.Line.X2 + line.Left, line.Line.Y2 + line.Top));
                    if (!double.IsNaN(point.X))
                    {
                        points.Add(point);
                    }
                }
                else if (ui is _Rectangle)
                {
                    _Control element = ui as _Control;
                    Point    a1      = new Point(element.Left, element.Top);
                    Point    b1      = new Point(element.Left + element.Width, element.Top);
                    Point    c1      = new Point(element.Left + element.Width, element.Top + element.Height);
                    Point    d1      = new Point(element.Left, element.Top + element.Height);
                    Point    point   = AlignCanvas.MeasurePoint(a, a1, b1);
                    if (!double.IsNaN(point.X))
                    {
                        points.Add(point);
                    }
                    else if (!double.IsNaN((point = AlignCanvas.MeasurePoint(a, b1, c1)).X))
                    {
                        points.Add(point);
                    }
                    else if (!double.IsNaN((point = AlignCanvas.MeasurePoint(a, c1, d1)).X))
                    {
                        points.Add(point);
                    }
                    else if (!double.IsNaN((point = AlignCanvas.MeasurePoint(a, d1, a1)).X))
                    {
                        points.Add(point);
                    }
                }
            }

            AlignCanvas.DrawAlignPoints(points);
        }
Example #5
0
        public void BeginAdd(_Line line)
        {
            _addLine        = line;
            this.Visibility = Visibility.Visible;

            this.PreviewMouseMove         -= AddLinePoint1Canvas_PreviewMouseMove;
            this.PreviewMouseLeftButtonUp -= AddLinePoint1Canvas_PreviewMouseLeftButtonUp;
            this.PreviewMouseMove         -= AddLinePoint2Canvas_PreviewMouseMove;
            this.PreviewMouseLeftButtonUp -= AddLinePoint2Canvas_PreviewMouseLeftButtonUp;

            this.PreviewMouseMove         += AddLinePoint1Canvas_PreviewMouseMove;
            this.PreviewMouseLeftButtonUp += AddLinePoint1Canvas_PreviewMouseLeftButtonUp;
        }
Example #6
0
        public override void React(_Line line)
        {
            switch (line.Index)
            {
            case 1:
                logowanie.nazwa = Console.ReadLine();
                break;

            case 2:
                logowanie.haslo = Console.ReadLine();
                break;

            case 3:
                if (!logowanie.IsAnyNullOrEmpty())
                {
                    var logowania = BazaDanych.Rekordy <Logowanie>();
                    foreach (var log in logowania)
                    {
                        if (log.nazwa == logowanie.nazwa && log.haslo == logowanie.haslo && sklep.asortyment.Count > 0)
                        {
                            var kasjer = new Kasjer();
                            kasjer.idlogowania      = log.id;
                            kasjer.data_rozpoczecia = DateTime.Now;
                            kasjer.data_zakonczenia = DateTime.Now;
                            kasjer = BazaDanych.Wstaw(kasjer);
                            MWS.DisplayAdapter.Display(new Kasa(sklep, log, kasjer));
                        }
                    }
                }
                break;

            case 4:
                MWS.DisplayAdapter.Display(new Rejestracja(sklep));
                break;

            case 5:
                MWS.DisplayAdapter.Display(new Statystyki(sklep));
                break;

            case 6:
                MWS.DisplayAdapter.Display(new Asortyment(sklep));
                break;

            case 7:
                MWS.DisplayAdapter.Display(new Sklepy());
                break;
            }
            MWS.DisplayAdapter.Display(new Zaloguj(sklep, logowanie));
        }
Example #7
0
        public void MoveEveryLineInNormal()
        {
            m = ModelConfigurations.InitNormalModel();
            _Line        l     = null;
            List <_Line> lines = m.AllLinesFlat();

            for (var i = 0; i < lines.Count; i++)
            {
                l = lines[i];
                m.MoveLine(10, l);
                m.MoveLine(-10, l);
                m.MoveLine(-10, l);
                m.MoveLine(10, l);
            }
        }
Example #8
0
 public override void React(_Line line)
 {
     if (line.Index > 0 && line.Index < sklepy.Count + 1)
     {
         MWS.DisplayAdapter.Display(new Zaloguj(sklepy[line.Index - 1]));
     }
     else if (line.Index == Contents.Count - 3)
     {
         MWS.DisplayAdapter.Display(new DodajSklep());
     }
     else if (line.Index == Contents.Count - 2)
     {
         MWS.DisplayAdapter.Display(new Home());
     }
 }
Example #9
0
 public override void React(_Line line)
 {
     if (line.Index <= BazaDanych.Rekordy <Produkt>().Count + 1)
     {
         BazaDanych.Wstaw(sklep, BazaDanych.Rekordy <Produkt>()[line.Index - 2]);
         MWS.DisplayAdapter.Display(new Rynek(sklep));
     }
     else if (line.Index == Contents.Count - 3)
     {
         MWS.DisplayAdapter.Display(new Zamawianie(sklep));
     }
     else if (line.Index == Contents.Count - 2)
     {
         MWS.DisplayAdapter.Display(new Asortyment(sklep));
     }
 }
Example #10
0
 public override void React(_Line line)
 {
     if (line.Index <= sklep.asortyment.Count + 1)
     {
         BazaDanych.Usun(sklep, sklep.asortyment[line.Index - 2]);
         MWS.DisplayAdapter.Display(new Asortyment(sklep));
     }
     else if (line.Index == Contents.Count - 3)
     {
         MWS.DisplayAdapter.Display(new Rynek(sklep));
     }
     else if (line.Index == Contents.Count - 2)
     {
         MWS.DisplayAdapter.Display(new Zaloguj(sklep));
     }
 }
Example #11
0
        public override void React(_Line line)
        {
            switch (line.Index)
            {
            case 2:
                var klient = new Klient
                {
                    data_wejscia = DateTime.Now,
                    idkasjera    = kasjer.id
                };
                klienci_kolejka.Add(klient);
                break;

            case 3:
                if (klienci_kolejka.Count != 0)
                {
                    MWS.DisplayAdapter.Display(new Koszyk(sklep, logowanie, kasjer, klienci_kolejka, produkty_skasowane));
                }
                break;

            case 4:
                if (klienci_kolejka.Count != 0 && produkty_skasowane.Count != 0)
                {
                    klienci_kolejka[0].data_obsluzenia = DateTime.Now;
                    klienci_kolejka[0].idkasjera       = kasjer.id;
                    klienci_kolejka[0] = BazaDanych.Wstaw(klienci_kolejka[0]);
                    foreach (var produkt in produkty_skasowane)
                    {
                        BazaDanych.Wstaw(klienci_kolejka[0], produkt);
                    }
                    klienci_kolejka.Remove(klienci_kolejka[0]);
                    produkty_skasowane = new List <Produkt>(99);
                }
                break;

            case 5:
                if (klienci_kolejka.Count == 0)
                {
                    kasjer.data_zakonczenia = DateTime.Now;
                    BazaDanych.Zmien(kasjer, kasjer);
                    MWS.DisplayAdapter.Display(new Zaloguj(sklep));
                }
                break;
            }
            MWS.DisplayAdapter.Display(new Kasa(sklep, logowanie, kasjer, klienci_kolejka, produkty_skasowane));
        }
Example #12
0
        public static void FindNextValidLine(_Line currentline, int direction)
        {
            int lineChecked = currentline.Index;

            do
            {
                if (lineChecked + direction < 0)
                {
                    if (CurrentPage.Contents[CurrentPage.Contents.Count - 1] is ActiveLine)
                    {
                        CurrentLine = CurrentPage.Contents[CurrentPage.Contents.Count - 1];
                        (CurrentLine as ActiveLine).Toggle();
                        Refresh(CurrentPage);
                        break;
                    }
                    else
                    {
                        lineChecked = CurrentPage.Contents.Count;
                    }
                }
                else if (lineChecked + direction == CurrentPage.Contents.Count)
                {
                    if (CurrentPage.Contents[0] is ActiveLine)
                    {
                        CurrentLine = CurrentPage.Contents[0];
                        (CurrentLine as ActiveLine).Toggle();
                        Refresh(CurrentPage);
                        break;
                    }
                    else
                    {
                        lineChecked = -1;
                    }
                }
                else if (CurrentPage.Contents[lineChecked + direction] is ActiveLine)
                {
                    CurrentLine = CurrentPage.Contents[lineChecked + direction];
                    (CurrentLine as ActiveLine).Toggle();
                    Refresh(CurrentPage);
                    break;
                }
                lineChecked += direction;
            }while (true);
        }
Example #13
0
        //[Attribute a=1]
        public void MoveLineInAllModel()
        {
            List <_Model> contents = new List <_Model>();

            foreach (string filename in Directory.GetFiles(@"C:\Users\Master\Desktop\Models"))
            {
                MessageBox.Show(filename);
                if (!filename.EndsWith("json"))
                {
                    continue;
                }
                try
                {
                    string json = File.ReadAllText(filename);
                    MessageBox.Show(json);
                    _Model account = JsonConvert.DeserializeObject <_Model>(json);
                    contents.Add(account);
                }
                catch (Exception e)
                {
                    MessageBox.Show(e.Message + "\n" + e.StackTrace);
                }
            }

            MessageBox.Show(contents.Count.ToString());
            foreach (_Model m in contents)
            {
                _Model       mcopy = m.DeepCopy();
                List <_Line> lines = mcopy.AllLinesFlat();
                for (var i = 0; i < lines.Count; i++)
                {
                    _Line l = lines[i];
                    mcopy.MoveLine(10, l);
                    mcopy.MoveLine(-10, l);
                    mcopy.MoveLine(-10, l);
                    mcopy.MoveLine(10, l);
                }
            }
            //m = LoadModelFromJsonString();
            //Line l = Find200200400200Line();
            //m.MoveLine(10, l);
            //Assert m.IsInInvalidState.Equals(false);
        }
Example #14
0
        public override void React(_Line line)
        {
            switch (line.Index)
            {
            case 1:
                if (Konfigurator.CheckConnection())
                {
                    MWS.DisplayAdapter.Display(new Sklepy());
                }
                break;

            case 2:
                if (!Konfigurator.CheckConnection())
                {
                    Konfigurator.InstallDatabase();
                }
                MWS.DisplayAdapter.Display(new Home());
                break;
            }
        }
Example #15
0
        private void CalculateMoveCosts()
        {
            List <_Line> allLinesFlat = Model.AllLinesFlat();

            for (int index = 0; index < allLinesFlat.Count; index++)
            {
                _Line  myLine    = allLinesFlat.ElementAt(index);
                _Model tempModel = Model.DeepCopy(myLine, out _Line newMyLine);
                tempModel.MoveLine(baseMoveDistance, newMyLine);
                if (tempModel.IsInInvalidState)
                {
                    continue;
                }

                Cost costsnew = CostCalculationService.CalculateCostNew(tempModel);

                lock (locker)
                {
                    Actions.Add(new Move(myLine, costsnew, baseMoveDistance));
                }
            }

            for (int index = 0; index < allLinesFlat.Count; index++)
            {
                _Line  myLine    = allLinesFlat.ElementAt(index);
                _Model tempModel = Model.DeepCopy(myLine, out _Line newMyLine);
                tempModel.MoveLine(-baseMoveDistance, newMyLine);
                if (tempModel.IsInInvalidState)
                {
                    continue;
                }

                Cost costsnew = CostCalculationService.CalculateCostNew(tempModel);

                lock (locker)
                {
                    Actions.Add(new Move(myLine, costsnew, -baseMoveDistance));
                }
            }
        }
Example #16
0
        public static _Model InitSimplestModel()
        {
            _Model m     = new _Model();
            _Point p1    = new _Point(100, 100);
            _Point p2    = new _Point(400, 100);
            _Point p3    = new _Point(400, 400);
            _Point p4    = new _Point(100, 400);
            _Line  line1 = new _Line(p1, p2);
            _Line  line2 = new _Line(p2, p3);
            _Line  line3 = new _Line(p3, p4);
            _Line  line4 = new _Line(p4, p1);
            _Room  _Room = new _Room {
                Name = "FirstRoom", Number = 1, type = _RoomType.LivingRoom, isStartRoom = true
            };

            _Room.Lines = (new List <_Line>()
            {
                line1, line2, line3, line4
            });
            m.rooms.Add(_Room);
            foreach (var room in m.rooms)
            {
                room.CanGetBoundarySorted();
            }

            List <_Point> boundaries = new List <_Point>()
            {
                new _Point(0, 0), new _Point(0, 450), new _Point(450, 450), new _Point(450, 0)
            };

            m.OutlinePolygonPoints = boundaries;
            List <System.Windows.Point> convertedPointsForPolygon = boundaries.Select(i => new System.Windows.Point(i.X, i.Y)).ToList();

            m.AvailableOutlinePolygon = new Polygon()
            {
                Points = new PointCollection(convertedPointsForPolygon)
            };
            return(m);
        }
Example #17
0
 public Move(_Line myLine, int moveDistance)
 {
     this.myLine       = myLine;
     this.moveDistance = moveDistance;
 }
Example #18
0
 public LineAndCost(_Line l, double d, int i)
 {
     line  = l.ToString();
     cost  = d;
     index = i;
 }
Example #19
0
        public static _Model InitTestModel()
        {
            _Model m = new _Model();

            _Point a1 = new _Point(0, 0);
            _Point a2 = new _Point(0, 100);
            _Point a3 = new _Point(0, 200);
            _Point a4 = new _Point(0, 300);

            _Point a5 = new _Point(100, 0);
            _Point a6 = new _Point(100, 100);
            _Point a7 = new _Point(100, 200);
            _Point a8 = new _Point(100, 300);

            _Point a9  = new _Point(200, 0);
            _Point a10 = new _Point(200, 100);
            _Point a11 = new _Point(200, 200);
            _Point a12 = new _Point(200, 300);

            _Point a13 = new _Point(300, 0);
            _Point a14 = new _Point(300, 100);
            _Point a15 = new _Point(300, 200);
            _Point a16 = new _Point(300, 300);



            _Line l12 = new _Line(a1, a2);
            _Line l23 = new _Line(a2, a3);
            _Line l34 = new _Line(a3, a4);

            _Line l56 = new _Line(a5, a6);
            _Line l67 = new _Line(a6, a7);
            _Line l78 = new _Line(a7, a8);

            _Line l910  = new _Line(a9, a10);
            _Line l1011 = new _Line(a10, a11);
            _Line l1112 = new _Line(a11, a12);

            _Line l1314 = new _Line(a13, a14);
            _Line l1415 = new _Line(a14, a15);
            _Line l1516 = new _Line(a15, a16);


            _Line l15  = new _Line(a1, a5);
            _Line l59  = new _Line(a5, a9);
            _Line l913 = new _Line(a9, a13);

            _Line l26  = new _Line(a2, a6);
            _Line l610 = new _Line(a6, a10);

            l610.Name = "key";
            _Line l1014 = new _Line(a10, a14);

            _Line l37   = new _Line(a3, a7);
            _Line l711  = new _Line(a7, a11);
            _Line l1115 = new _Line(a11, a15);

            _Line l48   = new _Line(a4, a8);
            _Line l812  = new _Line(a8, a12);
            _Line l1216 = new _Line(a12, a16);

            _Room first = new _Room {
                Name = "FirstRoom", Number = 1, type = _RoomType.Kitchen
            };
            _Room second = new _Room {
                Name = "SecondRoom", Number = 1, type = _RoomType.LivingRoom
            };
            _Room third = new _Room {
                Name = "ThirdRoom", Number = 1, type = _RoomType.CorridorRoom
            };
            _Room fourth = new _Room {
                Name = "FourthRoom", Number = 1, type = _RoomType.RestRoom
            };
            _Room fifth = new _Room {
                Name = "fifthRoom", Number = 1, type = _RoomType.BedRoom
            };
            _Room sixth = new _Room {
                Name = "sixthRoom", Number = 1, type = _RoomType.BedRoom
            };
            _Room seventh = new _Room {
                Name = "seventhRoom", Number = 1, type = _RoomType.BedRoom
            };
            _Room eight = new _Room {
                Name = "eightRoom", Number = 1, type = _RoomType.BedRoom
            };
            _Room nineth = new _Room {
                Name = "ninethRoom", Number = 1, type = _RoomType.BedRoom
            };;

            second.isStartRoom = true;


            first.Lines   = (new List <_Line>()
            {
                l12, l26, l56, l15
            });
            second.Lines  = (new List <_Line>()
            {
                l23, l37, l67, l26
            });
            third.Lines   = (new List <_Line>()
            {
                l34, l48, l78, l37
            });
            fourth.Lines  = (new List <_Line>()
            {
                l56, l610, l910, l59
            });
            fifth.Lines   = (new List <_Line>()
            {
                l67, l711, l1011, l610
            });
            sixth.Lines   = (new List <_Line>()
            {
                l78, l812, l1112, l711
            });
            seventh.Lines = (new List <_Line>()
            {
                l910, l1014, l1314, l913
            });
            eight.Lines   = (new List <_Line>()
            {
                l1011, l1115, l1415, l1014
            });
            nineth.Lines  = (new List <_Line>()
            {
                l1112, l1216, l1115, l1516
            });


            m.rooms.Add(first);
            m.rooms.Add(second);
            m.rooms.Add(third);
            m.rooms.Add(fourth);
            m.rooms.Add(fifth);
            m.rooms.Add(sixth);
            m.rooms.Add(seventh);
            m.rooms.Add(eight);
            m.rooms.Add(nineth);

            foreach (var room in m.rooms)
            {
                room.CanGetBoundarySorted();
            }

            return(m);
        }
Example #20
0
        public static _Model InitTwoLevelModel()
        {
            _Model m = new _Model();

            _Point a1 = new _Point(0, 0);
            _Point a2 = new _Point(0, 100);
            _Point a3 = new _Point(0, 200);
            _Point a4 = new _Point(0, 300);

            _Point a5 = new _Point(100, 0);
            _Point a6 = new _Point(100, 100);
            _Point a7 = new _Point(100, 200);
            _Point a8 = new _Point(100, 300);

            _Point a9  = new _Point(200, 0);
            _Point a10 = new _Point(200, 100);
            _Point a11 = new _Point(200, 200);
            _Point a12 = new _Point(200, 300);

            _Point a13 = new _Point(300, 0);
            _Point a14 = new _Point(300, 100);
            _Point a15 = new _Point(300, 200);
            _Point a16 = new _Point(300, 300);



            _Line l12 = new _Line(a1, a2);
            _Line l23 = new _Line(a2, a3);
            _Line l34 = new _Line(a3, a4);

            _Line l56 = new _Line(a5, a6);
            _Line l67 = new _Line(a6, a7);
            _Line l78 = new _Line(a7, a8);

            _Line l910  = new _Line(a9, a10);
            _Line l1011 = new _Line(a10, a11);
            _Line l1112 = new _Line(a11, a12);

            _Line l1314 = new _Line(a13, a14);
            _Line l1415 = new _Line(a14, a15);
            _Line l1516 = new _Line(a15, a16);


            _Line l15  = new _Line(a1, a5);
            _Line l59  = new _Line(a5, a9);
            _Line l913 = new _Line(a9, a13);

            _Line l26  = new _Line(a2, a6);
            _Line l610 = new _Line(a6, a10);

            l610.Name = "key";
            _Line l1014 = new _Line(a10, a14);

            _Line l37   = new _Line(a3, a7);
            _Line l711  = new _Line(a7, a11);
            _Line l1115 = new _Line(a11, a15);

            _Line l48   = new _Line(a4, a8);
            _Line l812  = new _Line(a8, a12);
            _Line l1216 = new _Line(a12, a16);

            _Room first = new _Room {
                Name = "FirstRoom", Number = 1, type = _RoomType.Kitchen
            };
            _Room second = new _Room {
                Name = "SecondRoom", Number = 2, type = _RoomType.LivingRoom
            };
            _Room third = new _Room {
                Name = "ThirdRoom", Number = 3, type = _RoomType.CorridorRoom
            };
            _Room fourth = new _Room {
                Name = "FourthRoom", Number = 4, type = _RoomType.DiningRoom
            };
            _Room fifth = new _Room {
                Name = "FifthRoom", Number = 5, type = _RoomType.StairCase
            };
            _Room sixth = new _Room {
                Name = "SixthRoom", Number = 6, type = _RoomType.RestRoom
            };
            _Room seventh = new _Room {
                Name = "SeventhRoom", Number = 7, type = _RoomType.BedRoom
            };
            _Room eight = new _Room {
                Name = "EightRoom", Number = 8, type = _RoomType.BedRoom
            };
            _Room nineth = new _Room {
                Name = "NinethRoom", Number = 9, type = _RoomType.BedRoom
            };;

            second.isStartRoom = true;


            first.Lines   = (new List <_Line>()
            {
                l12, l26, l56, l15
            });
            second.Lines  = (new List <_Line>()
            {
                l23, l37, l67, l26
            });
            third.Lines   = (new List <_Line>()
            {
                l34, l48, l78, l37
            });
            fourth.Lines  = (new List <_Line>()
            {
                l56, l610, l910, l59
            });
            fifth.Lines   = (new List <_Line>()
            {
                l67, l711, l1011, l610
            });
            sixth.Lines   = (new List <_Line>()
            {
                l78, l812, l1112, l711
            });
            seventh.Lines = (new List <_Line>()
            {
                l910, l1014, l1314, l913
            });
            eight.Lines   = (new List <_Line>()
            {
                l1011, l1115, l1415, l1014
            });
            nineth.Lines  = (new List <_Line>()
            {
                l1112, l1216, l1115, l1516
            });


            m.rooms.Add(first);
            m.rooms.Add(second);
            m.rooms.Add(third);
            m.rooms.Add(fourth);
            m.rooms.Add(fifth);
            m.rooms.Add(sixth);
            m.rooms.Add(seventh);
            m.rooms.Add(eight);
            m.rooms.Add(nineth);

            foreach (var room in m.rooms)
            {
                room.CanGetBoundarySorted();
            }

            List <_Point> boundaries = new List <_Point>()
            {
                new _Point(-10, -10), new _Point(-10, 600), new _Point(400, 600), new _Point(400, -10)
            };

            m.OutlinePolygonPoints = boundaries;
            List <System.Windows.Point> convertedPointsForPolygon = boundaries.Select(i => new System.Windows.Point(i.X, i.Y)).ToList();

            m.AvailableOutlinePolygon = new Polygon()
            {
                Points = new PointCollection(convertedPointsForPolygon)
            };

            return(m);
        }
Example #21
0
        public static _Model InitNormalModel()
        {
            _Model m  = new _Model();
            _Point a1 = new _Point(0, 0);
            _Point a2 = new _Point(200, 0);
            _Point a3 = new _Point(200, 200);
            _Point a4 = new _Point(0, 200);

            _Point a5 = new _Point(200, 400);
            _Point a6 = new _Point(0, 400);
            _Point a7 = new _Point(400, 0);
            _Point a8 = new _Point(400, 200);
            _Point a9 = new _Point(400, 400);

            _Line l12 = new _Line(a1, a2);
            _Line l23 = new _Line(a2, a3);
            _Line l34 = new _Line(a3, a4);
            _Line l41 = new _Line(a4, a1);

            _Line l35 = new _Line(a3, a5);
            _Line l56 = new _Line(a5, a6);
            _Line l64 = new _Line(a6, a4);

            _Line l27 = new _Line(a2, a7);
            _Line l78 = new _Line(a7, a8);
            _Line l83 = new _Line(a8, a3);

            _Line l89 = new _Line(a8, a9);
            _Line l95 = new _Line(a9, a5);


            _Room first = new _Room {
                Name = "FirstRoom", Number = 1, type = _RoomType.Kitchen
            };
            _Room second = new _Room {
                Name = "SecondRoom", Number = 2, type = _RoomType.LivingRoom
            };
            _Room third = new _Room {
                Name = "ThirdRoom", Number = 3, type = _RoomType.BedRoom
            };
            _Room fourth = new _Room {
                Name = "FourthRoom", Number = 4, type = _RoomType.RestRoom
            };

            first.Lines  = (new List <_Line>()
            {
                l12, l23, l34, l41
            });
            second.Lines = (new List <_Line>()
            {
                l35, l56, l64, l34
            });
            third.Lines  = (new List <_Line>()
            {
                l23, l27, l78, l83
            });
            fourth.Lines = (new List <_Line>()
            {
                l83, l89, l95, l35
            });

            m.rooms.Add(first);
            m.rooms.Add(second);
            m.rooms.Add(third);
            m.rooms.Add(fourth);
            foreach (var room in m.rooms)
            {
                room.CanGetBoundarySorted();
            }
            return(m);
        }
Example #22
0
 public override void React(_Line line)
 {
     MWS.DisplayAdapter.Display(new Zaloguj(sklep));
 }
Example #23
0
        private void Paint()
        {
            isPainting = true;
            testcanvas.Children.Clear();

            try
            {
                if (model.AvailableOutlinePolygon != null)
                {
                    Polygon p = model.AvailableOutlinePolygon;
                    p.Fill    = Brushes.White;
                    p.Opacity = 0.1;
                    p.ToolTip = "Available space";

                    testcanvas.Children.Add(p);
                }
            }
            catch (Exception e)
            {
                Logger.WriteLog(e);
            }


            foreach (_Room room in Rooms)
            {
                try
                {
                    List <_Point> boundaries = room.GetPoints();
                    if (!boundaries.Any())
                    {
                        continue;
                    }
                    //List<PointF> convertedPoints = boundaries.Select(i => new PointF((float) i.X, (float) i.Y)).ToList();
                    List <Point> convertedPointsForPolygon = boundaries.Select(i => new Point(i.X, i.Y)).ToList();
                    //System.Drawing.PointF center = Utils.GetCentroid(convertedPoints);
                    Polygon p = new Polygon();
                    p.Points  = new PointCollection(convertedPointsForPolygon);
                    p.Fill    = new SolidColorBrush(room.type.fillColor.ToMediaColor());
                    p.Opacity = 0.25;
                    p.ToolTip = room.ToString();

                    testcanvas.Children.Add(p);
                }
                catch (Exception e)
                {
                    Logger.WriteLog(e);
                }
            }
            var   allLinesFlat = model.AllLinesFlat();
            Brush greyBrush    = new SolidColorBrush(Color.FromArgb(100, 255, 255, 255));
            Brush redBrush     = Brushes.Red;
            Brush yellowBrush  = Brushes.Yellow;

            greyBrush.Opacity = 0.5;
            for (var i = 0; i < allLinesFlat.Count; i++)
            {
                _Line     line  = allLinesFlat[i];
                ShapeLine _line = new ShapeLine();
                if (line.HasDoor)
                {
                    ShapeLine _line2 = new ShapeLine();
                    _Point    n      = line.GetNV(true);
                    _line2.Stroke             = redBrush;
                    _line2.X1                 = (line.StartPoint.X + line.EndPoint.X) / 2;
                    _line2.X2                 = (line.StartPoint.X + line.EndPoint.X) / 2 + n.X * 10;
                    _line2.Y1                 = (line.StartPoint.Y + line.EndPoint.Y) / 2;
                    _line2.Y2                 = (line.StartPoint.Y + line.EndPoint.Y) / 2 + n.Y * 10;
                    _line2.StrokeEndLineCap   = PenLineCap.Triangle;
                    _line2.StrokeStartLineCap = PenLineCap.Round;
                    _line2.StrokeThickness    = 10;
                    _line2.ToolTip            = line.ToString();
                    testcanvas.Children.Add(_line2);
                }

                _line.Stroke = selectedLineIndices.Contains(i) ? yellowBrush : greyBrush;

                _line.X1 = line.StartPoint.X;
                _line.X2 = line.EndPoint.X;
                _line.Y1 = line.StartPoint.Y;
                _line.Y2 = line.EndPoint.Y;
                _line.StrokeEndLineCap   = PenLineCap.Triangle;
                _line.StrokeStartLineCap = PenLineCap.Round;
                _line.StrokeThickness    = 5;
                _line.ToolTip            = line.ToString();
                testcanvas.Children.Add(_line);
            }

            List <_Point> allPointsFlat   = model.AllPointsFlat();
            var           solidColorBrush = new SolidColorBrush(Color.FromArgb(90, 255, 0, 0));

            solidColorBrush.Opacity = 0.5;
            var GreenBrush = Brushes.GreenYellow;

            for (var i = 0; i < allPointsFlat.Count; i++)
            {
                _Point    point = allPointsFlat[i];
                ShapeLine _line = new ShapeLine();

                _line.Stroke = i.Equals(SelectedPointIndex) ? GreenBrush : solidColorBrush;

                _line.X1 = point.X;
                _line.X2 = point.X + 1;
                _line.Y1 = point.Y;
                _line.Y2 = point.Y + 1;
                _line.StrokeStartLineCap = PenLineCap.Round;
                _line.StrokeEndLineCap   = PenLineCap.Triangle;
                _line.StrokeThickness    = 10;
                _line.ToolTip            = point.ToString();
                testcanvas.Children.Add(_line);
            }

            isPainting = false;
        }
Example #24
0
 public Split(int splitPercentage, _Line lineGridSelectedItem)
 {
     split  = splitPercentage;
     myLine = lineGridSelectedItem;
 }
Example #25
0
 public LineAdorner(_Line line)
     : base(line)
 {
     _line = line;
 }
Example #26
0
 public Move(_Line myLine, double cost, int moveDistance)
 {
     this.myLine       = myLine;
     this.cost         = cost;
     this.moveDistance = moveDistance;
 }
Example #27
0
 public virtual void React(_Line line)
 {
 }