// pociatocne nastavenia public void Configure(PuzzleGameData data, Form1 form) { #region Pociatocne nastavenia - rozmiestnenia, velkosti, vztahy medzi controls, events handlers this.data = data; //Je potrebny zdrojovy obrazok v gamedata!! this.parentPanel = (form.Controls["panel4"] as Panel); //Je potrebne nastavit pred zavolanim Configure(), kto je komu rodicom this.parentPictBox = (this.Parent as PictureBox); this.parentPictBox.Location = new Point(0 - data.SourcePicture.Width, 0 - data.SourcePicture.Height); this.parentPictBox.Size = new Size(data.SourcePicture.Width + this.parentPanel.Size.Width, data.SourcePicture.Height + this.parentPanel.Size.Height); this.parentPictBox.BringToFront(); // this.Location = new Point(data.SourcePicture.Width, data.SourcePicture.Height); //pozicia gridlayer kvoli posunu picturebox-u this.Size = new Size(this.parentPanel.Size.Width, this.parentPanel.Height); //velkost gridlayer podla velkosti zobrazovaniecho panelu(panel4) this.BackColor = Color.Transparent; this.BringToFront(); this.Anchor = AnchorStyles.None; this.Anchor = (AnchorStyles.Left | AnchorStyles.Top | AnchorStyles.Bottom | AnchorStyles.Right); this.Controls.Add(widthBox); this.Controls.Add(heightBox); this.Controls.Add(dimensionBox); this.MouseDown += this.customGridLayer_MouseDown; this.MouseUp += this.customGridLayer_MouseUp; this.MouseMove += this.customGridLayer_MouseMove; this.parentPictBox.ClientSizeChanged += customclientSizeChanged_ParentPictureBox; // this.parentPictBox.Image = PictureEditor.ImageScale(GridRatioFromSourceImageResolution, data.SourcePicture); this.parentPictBox.Padding = new Padding(data.SourcePicture.Width + (int)((this.parentPanel.Width - this.parentPictBox.Image.Size.Width) / 2), data.SourcePicture.Height + (int)((this.parentPanel.Height - this.parentPictBox.Image.Size.Height) / 2), 0, 0); TextBoxesVisible = false; //==================================================================================================================================== #endregion #region Nastavenie Grid // //Prednastavenia pred vytvorenim Grid okrazka // backGroundImageForGrid = PictureEditor.ColouredBackGroundImage(Color.Black, this.Size); //Color.RoyalBlue backGroundImageForGrid = PictureEditor.ImageOpacity(0.60F, backGroundImageForGrid); pieceDimensions = new Size(100, 100); gridDimensions = new Size((int)((data.SourcePicture.Width * 0.7) / pieceDimensions.Width), (int)((data.SourcePicture.Height * 0.7) / pieceDimensions.Height)); // //Nastavenie vygenerovaneho grid obrazka // this.SetGridImage(GridRatioFromSourceImageResolution); ////this.Refresh(); // //Nastavenie textboxov // widthBox.TextChanged += this.whenTextBox1_Changed; widthBox.MouseEnter += this.whenTextBox1_MouseEnter; widthBox.MouseLeave += this.whenTextBox1_MouseLeave; heightBox.TextChanged += this.whenTextBox2_Changed; heightBox.MouseEnter += this.whenTextBox2_MouseEnter; heightBox.MouseLeave += this.whenTextBox2_MouseLeave; dimensionBox.TextChanged += this.whenTextBox3_Changed; dimensionBox.MouseEnter += this.whenTextBox3_MouseEnter; dimensionBox.MouseLeave += this.whenTextBox3_MouseLeave; //widthBox.Text = "Width"; //heightBox.Text = "Height"; //dimensionBox.Text = "Size"; var textBoxes = this.Controls.OfType <TextBox>().ToArray(); foreach (var textBox in textBoxes) { textBox.BackColor = Color.FromArgb(64, 64, 64); textBox.BorderStyle = BorderStyle.FixedSingle; textBox.ForeColor = Color.White; textBox.Size = new Size(50, 20); //textBox.Refresh(); } // //do textboxov vyplnime pociatocne hodnoty rozmerov grid, a velkost kuska puzzle, zalohujeme text, ktory v nich bol // textbox1_BackupText = (gridDimensions.Width).ToString(); widthBox.Text = "Šírka"; textbox2_BackupText = (gridDimensions.Height).ToString(); heightBox.Text = "Dĺžka"; textbox3_BackupText = (pieceDimensions.Width).ToString(); dimensionBox.Text = "Rozmer"; // //TextBox-y umiestnime do stredu // TextBoxesInTheMiddle(MiddlePoint_Grid); // //TextBox-y budu viditelne // TextBoxesVisible = true; this.Refresh(); // // Vzhlad kurzora // //Pri vybere obrazka sa vzhlad kurzoru zmeni na posovny kurzor, sipky styrmi smermi this.Cursor = Cursors.SizeAll; // // Zistime ako su od seba posunuta mriezka a obrazok a prevedieme to do skutocneho rozdielu, ak by bol obrazok nescalovany // Pri zmene velkosti okna totiz nesmie dojst k posunu mriezky vzhladom k obrazku, mriezka by mohla vyjst mimo obrazok // originalCornersDiff = OriginalCornersDiff; #endregion }