Пример #1
0
        private void pgProperties_PropertyValueChanged(object o, PropertyValueChangedEventArgs e)
        {
            if (Globals.WorkingFrames != null)
            {
                FramesProperties fp = pgProperties.SelectedObject as FramesProperties;
                if (e.ChangedItem.Label == "Height")
                {
                    if (e.ChangedItem.Parent.Label == "Dimensions")
                    {
                        if (fp.FGP.Dimensions.Height < 1)
                        {
                            Size s = fp.FGP.dimensions;
                            s.Height          = 1;
                            fp.FGP.Dimensions = s;
                            MessageBox.Show("Dimensions cannot be less than 1!", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                            pgProperties.Refresh();
                        }
                        else
                        {
                            Image img = Globals.WorkingFrames.Img != null ? Globals.WorkingFrames.Img : Globals.WorkingFrames.AltImg;
                            if (img != null)
                            {
                                // check for grid being larger than img
                                if ((img.Width < fp.FGP.Size.Width * fp.FGP.Dimensions.Width) || (img.Height < fp.FGP.Size.Height * fp.FGP.Dimensions.Height))
                                {
                                    int           ow = img.Width / fp.FGP.Dimensions.Width;
                                    int           oh = img.Height / fp.FGP.Dimensions.Height;
                                    StringBuilder sb = new StringBuilder();
                                    sb.Append("The given dimension values result in frames that won't appear for the image used! To avoid errors in-game with the image used, use size values of ");
                                    sb.Append(ow);
                                    sb.Append('x');
                                    sb.Append(oh);
                                    sb.Append(" for the new dimension values. Do you want the size values adjusted for you?");
                                    DialogResult dr = MessageBox.Show(sb.ToString(), "Warning!", MessageBoxButtons.YesNo, MessageBoxIcon.Warning);
                                    if (dr == DialogResult.Yes)
                                    {
                                        Size sz = fp.FGP.Size;
                                        sz.Width    = ow;
                                        sz.Height   = oh;
                                        fp.FGP.Size = sz;
                                        pgProperties.Refresh();
                                    }
                                }
                            }
                        }
                    }
                    else if (e.ChangedItem.Parent.Label == "Size")
                    {
                        if (fp.FGP.Size.Height < 1)
                        {
                            Size s = fp.FGP.size;
                            s.Height    = 1;
                            fp.FGP.Size = s;
                            MessageBox.Show("Size cannot be less than 1!", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                            pgProperties.Refresh();
                        }
                        else
                        {
                            Image img = Globals.WorkingFrames.Img != null ? Globals.WorkingFrames.Img : Globals.WorkingFrames.AltImg;
                            if (img != null)
                            {
                                // check for grid being larger than img
                                if ((img.Width < fp.FGP.Size.Width * fp.FGP.Dimensions.Width) || (img.Height < fp.FGP.Size.Height * fp.FGP.Dimensions.Height))
                                {
                                    int           ow = img.Width / fp.FGP.Dimensions.Width;
                                    int           oh = img.Height / fp.FGP.Dimensions.Height;
                                    StringBuilder sb = new StringBuilder();
                                    sb.Append("The given size values are too large for the image used at the current dimensions! To avoid errors in-game with the image used, use size values of ");
                                    sb.Append(ow);
                                    sb.Append('x');
                                    sb.Append(oh);
                                    sb.Append(" for the current dimension values. Do you want the size values adjusted for you?");
                                    DialogResult dr = MessageBox.Show(sb.ToString(), "Warning!", MessageBoxButtons.YesNo, MessageBoxIcon.Warning);
                                    if (dr == DialogResult.Yes)
                                    {
                                        Size sz = fp.FGP.Size;
                                        sz.Width    = ow;
                                        sz.Height   = oh;
                                        fp.FGP.Size = sz;
                                        pgProperties.Refresh();
                                    }
                                }
                            }
                        }
                    }
                }
                else if (e.ChangedItem.Label == "Width")
                {
                    if (e.ChangedItem.Parent.Label == "Dimensions")
                    {
                        if (fp.FGP.Dimensions.Width < 1)
                        {
                            Size s = fp.FGP.dimensions;
                            s.Width           = 1;
                            fp.FGP.Dimensions = s;
                            MessageBox.Show("Dimensions cannot be less than 1!", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                            pgProperties.Refresh();
                        }
                        else
                        {
                            Image img = Globals.WorkingFrames.Img != null ? Globals.WorkingFrames.Img : Globals.WorkingFrames.AltImg;
                            if (img != null)
                            {
                                // check for grid being larger than img
                                if ((img.Width < fp.FGP.Size.Width * fp.FGP.Dimensions.Width) || (img.Height < fp.FGP.Size.Height * fp.FGP.Dimensions.Height))
                                {
                                    int           ow = img.Width / fp.FGP.Dimensions.Width;
                                    int           oh = img.Height / fp.FGP.Dimensions.Height;
                                    StringBuilder sb = new StringBuilder();
                                    sb.Append("The given dimension values result in frames that won't appear for the image used! To avoid errors in-game with the image used, use size values of ");
                                    sb.Append(ow);
                                    sb.Append('x');
                                    sb.Append(oh);
                                    sb.Append(" for the new dimension values. Do you want the size values adjusted for you?");
                                    DialogResult dr = MessageBox.Show(sb.ToString(), "Warning!", MessageBoxButtons.YesNo, MessageBoxIcon.Warning);
                                    if (dr == DialogResult.Yes)
                                    {
                                        Size sz = fp.FGP.Size;
                                        sz.Width    = ow;
                                        sz.Height   = oh;
                                        fp.FGP.Size = sz;
                                        pgProperties.Refresh();
                                    }
                                }
                            }
                        }
                    }
                    else if (e.ChangedItem.Parent.Label == "Size")
                    {
                        if (fp.FGP.Size.Width < 1)
                        {
                            Size s = fp.FGP.size;
                            s.Width     = 1;
                            fp.FGP.Size = s;
                            MessageBox.Show("Size cannot be less than 1!", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                            pgProperties.Refresh();
                        }
                        else
                        {
                            Image img = Globals.WorkingFrames.Img != null ? Globals.WorkingFrames.Img : Globals.WorkingFrames.AltImg;
                            if (img != null)
                            {
                                // check for grid being larger than img
                                if ((img.Width < fp.FGP.Size.Width * fp.FGP.Dimensions.Width) || (img.Height < fp.FGP.Size.Height * fp.FGP.Dimensions.Height))
                                {
                                    int           ow = img.Width / fp.FGP.Dimensions.Width;
                                    int           oh = img.Height / fp.FGP.Dimensions.Height;
                                    StringBuilder sb = new StringBuilder();
                                    sb.Append("The given size values are too large for the image used at the current dimensions! To avoid errors in-game with the image used, use size values of ");
                                    sb.Append(ow);
                                    sb.Append('x');
                                    sb.Append(oh);
                                    sb.Append(" for the current dimension values. Do you want the size values adjusted for you?");
                                    DialogResult dr = MessageBox.Show(sb.ToString(), "Warning!", MessageBoxButtons.YesNo, MessageBoxIcon.Warning);
                                    if (dr == DialogResult.Yes)
                                    {
                                        Size sz = fp.FGP.Size;
                                        sz.Width    = ow;
                                        sz.Height   = oh;
                                        fp.FGP.Size = sz;
                                        pgProperties.Refresh();
                                    }
                                }
                            }
                        }
                    }
                }
            }

            pnlFramesEditor.Invalidate();
        }
Пример #2
0
 public FrameGridProperty(FramesProperties fp)
 {
     FP = fp;
 }