public static bool IsMiddle(PointViewModel P1, PointViewModel P2, double x) { if ((P1.PosX < P1.PosY ? P1.PosX : P1.PosY) < x && x < (P2.PosX > P2.PosY ? P2.PosX : P2.PosY)) { return(true); } else { return(false); } }
public static bool NotIntersectionConnectors(ConnectorViewModel m_c, PointViewModel m_p, List <ConnectorViewModel> m_lc, List <PointViewModel> m_lp) { foreach (ConnectorViewModel connector in m_lc) { if (App.GameMainViewModel.AlreadyConnector.Contains(connector.Id)) { continue; } if (connector.Id != m_c.Id && connector.PointId1 != m_p.Id && connector.PointId2 != m_p.Id) { if (IntersectionPoint(m_lp[m_c.PointId1], m_lp[m_c.PointId2], m_lp[connector.PointId1], m_lp[connector.PointId2])) { return(false); } } } return(true); }
public static void GetLevel() { _imgurl = "/Minim;component/Resources/LevelIcon/Red-Flower-icon.png"; _points = new ObservableCollection <PointViewModel>(); _connectors = new ObservableCollection <ConnectorViewModel>(); _correntWordIndex = new List <int>(); _ambigiousLetter = new List <int>(); _ambigiousConfusingLetter = new List <int>(); _correntWordIndex.AddRange(new List <int>() { 0, 1, 4, 3, 2, 5 }); _ambigiousLetter.AddRange(new List <int>() { }); PointViewModel viewmodel1 = new PointViewModel(); viewmodel1.Id = 0; viewmodel1.PosX = 136; viewmodel1.PosY = 548; viewmodel1.ImgIcon = new BitmapImage(new Uri("/Minim;component/Resources/LetterIcon/Letter-F-icon.png", UriKind.Relative)); _points.Add(viewmodel1); PointViewModel viewmodel2 = new PointViewModel(); viewmodel2.Id = 1; viewmodel2.PosX = 385; viewmodel2.PosY = 309; viewmodel2.ImgIcon = new BitmapImage(new Uri("/Minim;component/Resources/LetterIcon/Letter-L-icon.png", UriKind.Relative)); _points.Add(viewmodel2); PointViewModel viewmodel3 = new PointViewModel(); viewmodel3.Id = 2; viewmodel3.PosX = 304; viewmodel3.PosY = 521; viewmodel3.ImgIcon = new BitmapImage(new Uri("/Minim;component/Resources/LetterIcon/Letter-E-icon.png", UriKind.Relative)); _points.Add(viewmodel3); PointViewModel viewmodel4 = new PointViewModel(); viewmodel4.Id = 3; viewmodel4.PosX = 354; viewmodel4.PosY = 31; viewmodel4.ImgIcon = new BitmapImage(new Uri("/Minim;component/Resources/LetterIcon/Letter-W-icon.png", UriKind.Relative)); _points.Add(viewmodel4); PointViewModel viewmodel5 = new PointViewModel(); viewmodel5.Id = 4; viewmodel5.PosX = 162; viewmodel5.PosY = 54; viewmodel5.ImgIcon = new BitmapImage(new Uri("/Minim;component/Resources/LetterIcon/Letter-O-icon.png", UriKind.Relative)); _points.Add(viewmodel5); PointViewModel viewmodel6 = new PointViewModel(); viewmodel6.Id = 5; viewmodel6.PosX = 197; viewmodel6.PosY = 278; viewmodel6.ImgIcon = new BitmapImage(new Uri("/Minim;component/Resources/LetterIcon/Letter-R-icon.png", UriKind.Relative)); _points.Add(viewmodel6); ConnectorViewModel connector1 = new ConnectorViewModel(); connector1.PointId1 = 0; connector1.PointId2 = 1; connector1.Id = 0; _connectors.Add(connector1); ConnectorViewModel connector2 = new ConnectorViewModel(); connector2.PointId1 = 0; connector2.PointId2 = 3; connector2.Id = 1; _connectors.Add(connector2); ConnectorViewModel connector3 = new ConnectorViewModel(); connector3.PointId1 = 1; connector3.PointId2 = 2; connector3.Id = 2; _connectors.Add(connector3); ConnectorViewModel connector4 = new ConnectorViewModel(); connector4.PointId1 = 2; connector4.PointId2 = 3; connector4.Id = 3; _connectors.Add(connector4); ConnectorViewModel connector5 = new ConnectorViewModel(); connector5.PointId1 = 2; connector5.PointId2 = 4; connector5.Id = 4; _connectors.Add(connector5); ConnectorViewModel connector6 = new ConnectorViewModel(); connector6.PointId1 = 3; connector6.PointId2 = 5; connector6.Id = 5; _connectors.Add(connector6); ConnectorViewModel connector7 = new ConnectorViewModel(); connector7.PointId1 = 1; connector7.PointId2 = 4; connector7.Id = 6; _connectors.Add(connector7); ConnectorViewModel connector8 = new ConnectorViewModel(); connector8.PointId1 = 2; connector8.PointId2 = 5; connector8.Id = 7; _connectors.Add(connector8); }
public static void GetLevel() { _imgurl = "/Minim;component/Resources/LevelIcon/cloudy-day-icon.png"; _points = new ObservableCollection <PointViewModel>(); _connectors = new ObservableCollection <ConnectorViewModel>(); _correntWordIndex = new List <int>(); _ambigiousLetter = new List <int>(); _ambigiousConfusingLetter = new List <int>(); _correntWordIndex.AddRange(new List <int>() { 0, -1, 2, 3, 4, -1, 6 }); _ambigiousLetter.AddRange(new List <int>() { 1, 5 }); _ambigiousConfusingLetter.AddRange(new List <int>() { -1, -1 }); PointViewModel viewmodel1 = new PointViewModel(); viewmodel1.Id = 0; viewmodel1.PosX = 389; viewmodel1.PosY = 138; viewmodel1.ImgIcon = new BitmapImage(new Uri("/Minim;component/Resources/LetterIcon/Letter-W-icon.png", UriKind.Relative)); _points.Add(viewmodel1); PointViewModel viewmodel2 = new PointViewModel(); viewmodel2.Id = 1; viewmodel2.PosX = 115; viewmodel2.PosY = 308; viewmodel2.ImgIcon = new BitmapImage(new Uri("/Minim;component/Resources/LetterIcon/Letter-E-icon.png", UriKind.Relative)); _points.Add(viewmodel2); PointViewModel viewmodel3 = new PointViewModel(); viewmodel3.Id = 2; viewmodel3.PosX = 252; viewmodel3.PosY = 308; viewmodel3.ImgIcon = new BitmapImage(new Uri("/Minim;component/Resources/LetterIcon/Letter-A-icon.png", UriKind.Relative)); _points.Add(viewmodel3); PointViewModel viewmodel4 = new PointViewModel(); viewmodel4.Id = 3; viewmodel4.PosX = 115; viewmodel4.PosY = 478; viewmodel4.ImgIcon = new BitmapImage(new Uri("/Minim;component/Resources/LetterIcon/Letter-T-icon.png", UriKind.Relative)); _points.Add(viewmodel4); PointViewModel viewmodel5 = new PointViewModel(); viewmodel5.Id = 4; viewmodel5.PosX = 389; viewmodel5.PosY = 478; viewmodel5.ImgIcon = new BitmapImage(new Uri("/Minim;component/Resources/LetterIcon/Letter-H-icon.png", UriKind.Relative)); _points.Add(viewmodel5); PointViewModel viewmodel6 = new PointViewModel(); viewmodel6.Id = 5; viewmodel6.PosX = 389; viewmodel6.PosY = 308; viewmodel6.ImgIcon = new BitmapImage(new Uri("/Minim;component/Resources/LetterIcon/Letter-E-icon.png", UriKind.Relative)); _points.Add(viewmodel6); PointViewModel viewmodel7 = new PointViewModel(); viewmodel7.Id = 6; viewmodel7.PosX = 115; viewmodel7.PosY = 138; viewmodel7.ImgIcon = new BitmapImage(new Uri("/Minim;component/Resources/LetterIcon/Letter-R-icon.png", UriKind.Relative)); _points.Add(viewmodel7); ConnectorViewModel connector1 = new ConnectorViewModel(); connector1.PointId1 = 0; connector1.PointId2 = 1; connector1.Id = 0; _connectors.Add(connector1); ConnectorViewModel connector2 = new ConnectorViewModel(); connector2.PointId1 = 0; connector2.PointId2 = 3; connector2.Id = 1; _connectors.Add(connector2); ConnectorViewModel connector3 = new ConnectorViewModel(); connector3.PointId1 = 1; connector3.PointId2 = 2; connector3.Id = 2; _connectors.Add(connector3); ConnectorViewModel connector4 = new ConnectorViewModel(); connector4.PointId1 = 2; connector4.PointId2 = 3; connector4.Id = 3; _connectors.Add(connector4); ConnectorViewModel connector5 = new ConnectorViewModel(); connector5.PointId1 = 2; connector5.PointId2 = 4; connector5.Id = 4; _connectors.Add(connector5); ConnectorViewModel connector6 = new ConnectorViewModel(); connector6.PointId1 = 3; connector6.PointId2 = 5; connector6.Id = 5; _connectors.Add(connector6); ConnectorViewModel connector7 = new ConnectorViewModel(); connector7.PointId1 = 1; connector7.PointId2 = 4; connector7.Id = 6; _connectors.Add(connector7); ConnectorViewModel connector8 = new ConnectorViewModel(); connector8.PointId1 = 2; connector8.PointId2 = 5; connector8.Id = 7; _connectors.Add(connector8); ConnectorViewModel connector9 = new ConnectorViewModel(); connector9.PointId1 = 4; connector9.PointId2 = 6; connector9.Id = 8; _connectors.Add(connector9); ConnectorViewModel connector10 = new ConnectorViewModel(); connector10.PointId1 = 5; connector10.PointId2 = 6; connector10.Id = 9; _connectors.Add(connector10); }
void view_Tap(object sender, GestureEventArgs e) { PointView view = sender as PointView; PointViewModel viewmodel = view.DataContext as PointViewModel; //view.OnBoardAnimation.Stop(); if (GameConstants.CURRENT_ID >= App.GameMainViewModel.CorrectWordIndex.Count) { //IsOK = false; return; } //if (IsOK || GameConstants.CURRENT_ID == 0) { //IsOK = false; if (App.GameMainViewModel.AlreadyLetter.Contains(viewmodel.Id)) { //IsOK = false; return; } if (App.GameMainViewModel.CorrectWordIndex[GameConstants.CURRENT_ID] == viewmodel.Id || (App.GameMainViewModel.CorrectWordIndex[GameConstants.CURRENT_ID] < 0 && App.GameMainViewModel.AmbigiousLetter.Contains(viewmodel.Id) && App.GameMainViewModel.AmbigiousConfusingLetter[App.GameMainViewModel.AmbigiousLetter.IndexOf(viewmodel.Id)] == App.GameMainViewModel.CorrectWordIndex[GameConstants.CURRENT_ID])) { List <int> vertices = new List <int>(); List <PointViewModel> vertices_out = new List <PointViewModel>(); List <ConnectorViewModel> connectors_out = new List <ConnectorViewModel>(); List <PointViewModel> vertices_in = new List <PointViewModel>(); List <ConnectorViewModel> connectors_in = new List <ConnectorViewModel>(); vertices_in.AddRange(App.GameMainViewModel.Points); connectors_in.AddRange(App.GameMainViewModel.Connectors); if (MathNew.AddConnPoint(vertices_in, connectors_in, ref vertices_out, ref connectors_out, viewmodel)) { vertices.Add(viewmodel.Id); foreach (PointViewModel v in vertices_out) { vertices.Add(v.Id); } App.GameMainViewModel.AlreadyLetter.Add(vertices[0]); foreach (ConnectorViewModel v in connectors_out) { App.GameMainViewModel.AlreadyConnector.Add(v.Id); } this.Execute2(vertices, GameConstants.CURRENT_X, GameConstants.CURRENT_Y); GameConstants.CURRENT_ID++; GameConstants.CURRENT_X += GameConstants.NEXT_X; GameConstants.CURRENT_Y += GameConstants.NEXT_Y; } if (GameConstants.CURRENT_ID == App.GameMainViewModel.CorrectWordIndex.Count) { //Success this.SuccessAnimation.Begin(); this.SuccessAnimation.Completed += new System.EventHandler(SuccessAnimation_Completed); } } }
public static void GetLevel() { _imgurl = "/Minim;component/Resources/LevelIcon/suesscc.png"; _points = new ObservableCollection <PointViewModel>(); _connectors = new ObservableCollection <ConnectorViewModel>(); _correntWordIndex = new List <int>(); _ambigiousLetter = new List <int>(); _ambigiousConfusingLetter = new List <int>(); _correntWordIndex.AddRange(new List <int>() { -2, 1, -1, -1, 4, -2, -2 }); _ambigiousLetter.AddRange(new List <int>() { 0, 2, 3, 5, 6 }); _ambigiousConfusingLetter.AddRange(new List <int>() { -2, -1, -1, -2, -2 }); PointViewModel viewmodel1 = new PointViewModel(); viewmodel1.Id = 0; viewmodel1.PosX = 268; viewmodel1.PosY = 20; viewmodel1.ImgIcon = new BitmapImage(new Uri("/Minim;component/Resources/LetterIcon/Letter-S-icon.png", UriKind.Relative)); _points.Add(viewmodel1); PointViewModel viewmodel2 = new PointViewModel(); viewmodel2.Id = 1; viewmodel2.PosX = 403; viewmodel2.PosY = 0; viewmodel2.ImgIcon = new BitmapImage(new Uri("/Minim;component/Resources/LetterIcon/Letter-U-icon.png", UriKind.Relative)); _points.Add(viewmodel2); PointViewModel viewmodel3 = new PointViewModel(); viewmodel3.Id = 2; viewmodel3.PosX = 132; viewmodel3.PosY = 62; viewmodel3.ImgIcon = new BitmapImage(new Uri("/Minim;component/Resources/LetterIcon/Letter-C-icon.png", UriKind.Relative)); _points.Add(viewmodel3); PointViewModel viewmodel4 = new PointViewModel(); viewmodel4.Id = 3; viewmodel4.PosX = 405; viewmodel4.PosY = 470; viewmodel4.ImgIcon = new BitmapImage(new Uri("/Minim;component/Resources/LetterIcon/Letter-C-icon.png", UriKind.Relative)); _points.Add(viewmodel4); PointViewModel viewmodel5 = new PointViewModel(); viewmodel5.Id = 4; viewmodel5.PosX = 275; viewmodel5.PosY = 499; viewmodel5.ImgIcon = new BitmapImage(new Uri("/Minim;component/Resources/LetterIcon/Letter-E-icon.png", UriKind.Relative)); _points.Add(viewmodel5); PointViewModel viewmodel6 = new PointViewModel(); viewmodel6.Id = 5; viewmodel6.PosX = 149; viewmodel6.PosY = 499; viewmodel6.ImgIcon = new BitmapImage(new Uri("/Minim;component/Resources/LetterIcon/Letter-S-icon.png", UriKind.Relative)); _points.Add(viewmodel6); PointViewModel viewmodel7 = new PointViewModel(); viewmodel7.Id = 6; viewmodel7.PosX = 314; viewmodel7.PosY = 355; viewmodel7.ImgIcon = new BitmapImage(new Uri("/Minim;component/Resources/LetterIcon/Letter-S-icon.png", UriKind.Relative)); _points.Add(viewmodel7); ConnectorViewModel connector1 = new ConnectorViewModel(); connector1.PointId1 = 0; connector1.PointId2 = 1; connector1.Id = 0; _connectors.Add(connector1); ConnectorViewModel connector2 = new ConnectorViewModel(); connector2.PointId1 = 0; connector2.PointId2 = 3; connector2.Id = 1; _connectors.Add(connector2); ConnectorViewModel connector3 = new ConnectorViewModel(); connector3.PointId1 = 1; connector3.PointId2 = 2; connector3.Id = 2; _connectors.Add(connector3); ConnectorViewModel connector4 = new ConnectorViewModel(); connector4.PointId1 = 2; connector4.PointId2 = 3; connector4.Id = 3; _connectors.Add(connector4); ConnectorViewModel connector5 = new ConnectorViewModel(); connector5.PointId1 = 2; connector5.PointId2 = 4; connector5.Id = 4; _connectors.Add(connector5); ConnectorViewModel connector6 = new ConnectorViewModel(); connector6.PointId1 = 3; connector6.PointId2 = 5; connector6.Id = 5; _connectors.Add(connector6); ConnectorViewModel connector7 = new ConnectorViewModel(); connector7.PointId1 = 1; connector7.PointId2 = 4; connector7.Id = 6; _connectors.Add(connector7); ConnectorViewModel connector8 = new ConnectorViewModel(); connector8.PointId1 = 2; connector8.PointId2 = 5; connector8.Id = 7; _connectors.Add(connector8); ConnectorViewModel connector9 = new ConnectorViewModel(); connector9.PointId1 = 4; connector9.PointId2 = 6; connector9.Id = 8; _connectors.Add(connector9); ConnectorViewModel connector10 = new ConnectorViewModel(); connector10.PointId1 = 5; connector10.PointId2 = 6; connector10.Id = 9; _connectors.Add(connector10); }
public static void GetLevel() { _imgurl = "/Minim;component/Resources/LevelIcon/School.png"; _points = new ObservableCollection <PointViewModel>(); _connectors = new ObservableCollection <ConnectorViewModel>(); _correntWordIndex = new List <int>(); _ambigiousLetter = new List <int>(); _ambigiousConfusingLetter = new List <int>(); _correntWordIndex.AddRange(new List <int>() { 0, 1, 2, -1, -1, 5 }); _ambigiousLetter.AddRange(new List <int>() { 3, 4 }); _ambigiousConfusingLetter.AddRange(new List <int>() { -1, -1 }); PointViewModel viewmodel1 = new PointViewModel(); viewmodel1.Id = 0; viewmodel1.PosX = 389; viewmodel1.PosY = 174; viewmodel1.ImgIcon = new BitmapImage(new Uri("/Minim;component/Resources/LetterIcon/Letter-S-icon.png", UriKind.Relative)); _points.Add(viewmodel1); PointViewModel viewmodel2 = new PointViewModel(); viewmodel2.Id = 1; viewmodel2.PosX = 87; viewmodel2.PosY = 174; viewmodel2.ImgIcon = new BitmapImage(new Uri("/Minim;component/Resources/LetterIcon/Letter-C-icon.png", UriKind.Relative)); _points.Add(viewmodel2); PointViewModel viewmodel3 = new PointViewModel(); viewmodel3.Id = 2; viewmodel3.PosX = 362; viewmodel3.PosY = 425; viewmodel3.ImgIcon = new BitmapImage(new Uri("/Minim;component/Resources/LetterIcon/Letter-H-icon.png", UriKind.Relative)); _points.Add(viewmodel3); PointViewModel viewmodel4 = new PointViewModel(); viewmodel4.Id = 3; viewmodel4.PosX = 126; viewmodel4.PosY = 425; viewmodel4.ImgIcon = new BitmapImage(new Uri("/Minim;component/Resources/LetterIcon/Letter-O-icon.png", UriKind.Relative)); _points.Add(viewmodel4); PointViewModel viewmodel5 = new PointViewModel(); viewmodel5.Id = 4; viewmodel5.PosX = 288; viewmodel5.PosY = 174; viewmodel5.ImgIcon = new BitmapImage(new Uri("/Minim;component/Resources/LetterIcon/Letter-O-icon.png", UriKind.Relative)); _points.Add(viewmodel5); PointViewModel viewmodel6 = new PointViewModel(); viewmodel6.Id = 5; viewmodel6.PosX = 240; viewmodel6.PosY = 15; viewmodel6.ImgIcon = new BitmapImage(new Uri("/Minim;component/Resources/LetterIcon/Letter-L-icon.png", UriKind.Relative)); _points.Add(viewmodel6); ConnectorViewModel connector1 = new ConnectorViewModel(); connector1.PointId1 = 0; connector1.PointId2 = 1; connector1.Id = 0; _connectors.Add(connector1); ConnectorViewModel connector2 = new ConnectorViewModel(); connector2.PointId1 = 0; connector2.PointId2 = 3; connector2.Id = 1; _connectors.Add(connector2); ConnectorViewModel connector3 = new ConnectorViewModel(); connector3.PointId1 = 1; connector3.PointId2 = 2; connector3.Id = 2; _connectors.Add(connector3); ConnectorViewModel connector4 = new ConnectorViewModel(); connector4.PointId1 = 2; connector4.PointId2 = 3; connector4.Id = 3; _connectors.Add(connector4); ConnectorViewModel connector5 = new ConnectorViewModel(); connector5.PointId1 = 2; connector5.PointId2 = 4; connector5.Id = 4; _connectors.Add(connector5); ConnectorViewModel connector6 = new ConnectorViewModel(); connector6.PointId1 = 3; connector6.PointId2 = 5; connector6.Id = 5; _connectors.Add(connector6); ConnectorViewModel connector7 = new ConnectorViewModel(); connector7.PointId1 = 1; connector7.PointId2 = 4; connector7.Id = 6; _connectors.Add(connector7); ConnectorViewModel connector8 = new ConnectorViewModel(); connector8.PointId1 = 2; connector8.PointId2 = 5; connector8.Id = 7; _connectors.Add(connector8); }
public static bool IntersectionPoint(PointViewModel P1_a, PointViewModel P2_a, PointViewModel P1_b, PointViewModel P2_b) { //double A1, B1, C1, A2, B2, C2; //A1 = Y1.PosY - X1.PosY; //B1 = X1.PosX - Y1.PosX; //C1 = Y1.PosX * X1.PosY - X1.PosX * Y1.PosY; //A2 = Y2.PosY - X2.PosY; //B2 = X2.PosX - Y2.PosX; //C2 = Y2.PosX * X2.PosY - X2.PosX * Y2.PosY; //if (A1 == 0 && A2 == 0) { // if (B1 == 0 && B2 == 0) { // return true; // } else { // double tam1 = C1 / B1; // double tam2 = C2 / B2; // if (tam1 == tam2) // if (SoLon(DoDai(X2, X1), DoDai(X2, Y1)) / DoDai(X1, Y1) < 1) // return true; // else { // if (SoLon(DoDai(Y2, X1), DoDai(Y2, Y1)) / DoDai(X1, Y1) < 1) // return true; // else // return false; // } // else // return false; // } //} else { // double tam1, tam2; // tam1 = A1 * B2 - A2 * B1; // tam2 = B1 * C2 - B2 * C1; // if (tam1 != 0) { // //Cat // PointViewModel GD; // GD = new PointViewModel((-B2 * C1 + B1 * C2) / tam1, (A2 * C1 - A1 * C2) / tam1); // if ((SoLon(DoDai(GD, X1), DoDai(GD, Y1)) / DoDai(X1, Y1) <= 1) && (SoLon(DoDai(GD, X2), DoDai(GD, Y2)) / DoDai(X2, Y2) <= 1)) // return true; // else // return false; // } else { // if (tam2 == 0) // return false; //Song song // else { // //Trung // if (SoLon(DoDai(X2, X1), DoDai(X2, Y1)) / DoDai(X1, Y1) < 1) // return true; // else { // if (SoLon(DoDai(Y2, X1), DoDai(Y2, Y1)) / DoDai(X1, Y1) < 1) // return true; // else // return false; // } // } // } //} //} double A1 = P2_a.PosY - P1_a.PosY; double B1 = P1_a.PosX - P2_a.PosX; double C1 = A1 * P1_a.PosX + B1 * P1_a.PosY; double A2 = P2_b.PosY - P1_b.PosY; double B2 = P1_b.PosX - P2_b.PosX; double C2 = A2 * P1_b.PosX + B2 * P1_b.PosY; double det = A1 * B2 - A2 * B1; if (det == 0) { //Xet song song, khong trung, return false if (B1 * C2 != B2 * C1) { return(false); } else { //Xet trung phuong, giao, return true if (IsMiddle(new PointViewModel(P1_a.PosX, P2_a.PosX), new PointViewModel(P1_a.PosX, P2_a.PosX), P1_b.PosX) && IsMiddle(new PointViewModel(P1_a.PosY, P2_a.PosY), new PointViewModel(P1_a.PosY, P2_a.PosY), P1_b.PosY)) { return(true); } else { if (IsMiddle(new PointViewModel(P1_a.PosX, P2_a.PosX), new PointViewModel(P1_a.PosX, P2_a.PosX), P2_b.PosX) && IsMiddle(new PointViewModel(P1_a.PosY, P2_a.PosY), new PointViewModel(P1_a.PosY, P2_a.PosY), P2_b.PosY)) { return(true); } } if (IsMiddle(new PointViewModel(P1_b.PosX, P2_b.PosX), new PointViewModel(P1_b.PosX, P2_b.PosX), P1_a.PosX) && IsMiddle(new PointViewModel(P1_b.PosY, P2_b.PosY), new PointViewModel(P1_b.PosY, P2_b.PosY), P1_a.PosY)) { return(true); } else { if (IsMiddle(new PointViewModel(P1_b.PosX, P2_b.PosX), new PointViewModel(P1_b.PosX, P2_b.PosX), P2_a.PosX) && IsMiddle(new PointViewModel(P1_b.PosY, P2_b.PosY), new PointViewModel(P1_b.PosY, P2_b.PosY), P2_a.PosY)) { return(true); } } } //Xet trung phuong, khong giao, return false return(false); } else { double x = (B2 * C1 - B1 * C2) / det; double y = (A1 * C2 - A2 * C1) / det; if (IsMiddle(new PointViewModel(P1_a.PosX, P2_a.PosX), new PointViewModel(P1_a.PosX, P2_a.PosX), x) && IsMiddle(new PointViewModel(P1_a.PosY, P2_a.PosY), new PointViewModel(P1_a.PosY, P2_a.PosY), y)) { if (IsMiddle(new PointViewModel(P1_b.PosX, P2_b.PosX), new PointViewModel(P1_b.PosX, P2_b.PosX), x) && IsMiddle(new PointViewModel(P1_b.PosY, P2_b.PosY), new PointViewModel(P1_b.PosY, P2_b.PosY), y)) { return(true); } else { return(false); } } else { return(false); } } }
public static bool AddConnPoint(List <PointViewModel> m_lp, List <ConnectorViewModel> m_lc, ref List <PointViewModel> m_lsp, ref List <ConnectorViewModel> m_lsc, PointViewModel m_p) { //m_lsc = new List<ConnectorViewModel>(); //m_lsp = new List<PointViewModel>(); //for (int i = 0; i < m_lc.Count; i++) { // for (int j = i; j < m_lc.Count; j++) { // if (m_lc[i].PointId1 == m_p.Id && !IntersectionPoint(m_lp[m_lc[i].PointId2], m_p, m_lp[m_lc[j].PointId1], m_lp[m_lc[j].PointId2])) { // m_lsp.Add(m_lp[m_lc[i].PointId2]); // m_lsc.Add(m_lc[i]); // } else // if (m_lc[i].PointId2 == m_p.Id && !IntersectionPoint(m_lp[m_lc[i].PointId1], m_p, m_lp[m_lc[j].PointId1], m_lp[m_lc[j].PointId2])) { // m_lsp.Add(m_lp[m_lc[i].PointId1]); // m_lsc.Add(m_lc[i]); // } // } //} int count = 0; int countCorrect = 0; foreach (ConnectorViewModel connector in m_lc) { if (App.GameMainViewModel.AlreadyConnector.Contains(connector.Id)) { continue; } if ((connector.PointId1 == m_p.Id && connector.PointId2 != m_p.Id) || (connector.PointId1 != m_p.Id && connector.PointId2 == m_p.Id)) { countCorrect++; if (NotIntersectionConnectors(connector, m_p, m_lc, m_lp)) { count++; m_lsc.Add(connector); if (connector.PointId1 == m_p.Id) { m_lsp.Add(m_lp[connector.PointId2]); } if (connector.PointId2 == m_p.Id) { m_lsp.Add(m_lp[connector.PointId1]); } } } } if (count == countCorrect) { return(true); } else { m_lsp.Clear(); m_lsc.Clear(); return(false); } }
public static double DoDai(PointViewModel A, PointViewModel B) { double DoDai = Math.Sqrt((A.PosX - B.PosX) * (A.PosX - B.PosX) + (A.PosY - B.PosY) * (A.PosY - B.PosY)); return(DoDai); }