Exemplo n.º 1
0
        //SaveConfig
        public void SaveConfig()
        {
            //MessageBox.Show("hi");
            //Configuration.SetGameProcessId(CutBoardArgs.WzqGameProcess.Id);
            //Configuration.SetGameUiTitle(CutBoardArgs.WzqGameProcess.MainWindowTitle);
            //Configuration.SetGameUiSize(GameBoardBitmap.Size);

            System.Drawing.Point point = new System.Drawing.Point();
            point.X = Convert.ToInt32(drawingRectangle.GetValue(Canvas.LeftProperty));
            point.Y = Convert.ToInt32(drawingRectangle.GetValue(Canvas.TopProperty));
            //Configuration.SetGameBoardPoint(point);
            //Configuration.SetGameBoardInsideWidth((int)((drawingRectangle.Width+ drawingRectangle.Height)/2));
            //Configuration.Save();

            var config = Configuration as BaseConfiguration;

            config.GameProcessId        = CutBoardArgs.WzqGameProcess.Id;
            config.GameUiTitle          = CutBoardArgs.WzqGameProcess.MainWindowTitle;
            config.GameUiSize           = GameBoardBitmap.Size;
            config.GameBoardPoint       = point;
            config.GameBoardInsideWidth = (int)((drawingRectangle.Width + drawingRectangle.Height) / 2);
            config.Save();
            //Configuration.Save();

            Messenger.Default.Send(new CloseWindowArgs {
                DialogResult = true
            });
        }
Exemplo n.º 2
0
        //SaveConfig
        public void SaveConfig()
        {
            //MessageBox.Show("hi");
            Configuration.SetGameProcessId(CutBoardArgs.WzqGameProcess.Id);
            Configuration.SetGameUiTitle(CutBoardArgs.WzqGameProcess.MainWindowTitle);
            Configuration.SetGameUiSize(GameBoardBitmap.Size);

            System.Drawing.Point point = new System.Drawing.Point();
            point.X = Convert.ToInt32(drawingRectangle.GetValue(Canvas.LeftProperty));
            point.Y = Convert.ToInt32(drawingRectangle.GetValue(Canvas.TopProperty));
            Configuration.SetGameBoardPoint(point);
            Configuration.SetGameBoardInsideWidth((int)((drawingRectangle.Width + drawingRectangle.Height) / 2));
            Configuration.Save();
        }
Exemplo n.º 3
0
        //extendable
        private new void MouseUp()
        {
            if (currentSelection == null)//якщо рука пуста, то в неї береться пазл
            {
                //оце можна замінити точкою
                double x1 = (double)rSelection.GetValue(Canvas.LeftProperty);
                double y1 = (double)rSelection.GetValue(Canvas.TopProperty);
                double x2 = x1 + rSelection.Width;
                double y2 = y1 + rSelection.Height;

                int cellX1 = (int)(x1 / Width);
                int cellY1 = (int)(y1 / Height);
                int cellX2 = (int)(x2 / Width);
                int cellY2 = (int)(y2 / Height);

                var query = from p in pieces
                            where
                            (p.X >= cellX1) && (p.X <= cellX2) &&
                            (p.Y >= cellY1) && (p.Y <= cellY2)
                            select p;

                foreach (var currentPiece in query)
                {
                    currentSelection = currentPiece;

                    currentPiece.SetValue(Canvas.ZIndexProperty, 5000);
                    shadowPieces[currentPiece.Index].SetValue(Canvas.ZIndexProperty, 4999);
                    currentPiece.BitmapEffect = shadowEffect;

                    currentPiece.RenderTransform = stZoomed;
                    currentPiece.IsSelected      = true;
                    shadowPieces[currentPiece.Index].RenderTransform = stZoomed;
                }
                SetSelectionRectangle(-1, -1, -1, -1);
            }
            else//якщо ж непуста, то пазл ставться
            {
                var newX = Mouse.GetPosition(cnvPuzzle).X;
                var newY = Mouse.GetPosition(cnvPuzzle).Y;
                if (TrySetCurrentPiecePosition(newX, newY))
                {
                    currentSelection.BitmapEffect = null;
                    ScaleTransform st = new ScaleTransform()
                    {
                        ScaleX = 1.0, ScaleY = 1.0
                    };
                    currentSelection.RenderTransform = st;
                    currentSelection.IsSelected      = false;
                    shadowPieces[currentSelection.Index].RenderTransform = st;

                    SetCurrentPiecePosition(currentSelection, newX, newY);
                    ResetZIndexes();

                    currentSelection = null;

                    if (IsPuzzleCompleted())//кожен раз, коли відпускається рука з пазлом, перевіряється, чи пазл зібраний
                    {
                        allGood.Text       = "Complited";
                        allGood.Foreground = System.Windows.Media.Brushes.BlanchedAlmond;
                    }
                    else
                    {
                        allGood.Text       = "Not Complited";
                        allGood.Foreground = System.Windows.Media.Brushes.Black;
                    }
                }
            }
        }