Example #1
0
        //////////////////////////////////////////////////////////////////////////
        public override object EditValue(ITypeDescriptorContext context, IServiceProvider provider, object value)
        {
            if (context == null)
            {
                return(value);
            }
            NativePropProxy Proxy = context.Instance as NativePropProxy;

            if (Proxy == null || Proxy.NativeObject == null)
            {
                SystemSounds.Asterisk.Play();
                return(value);
            }

            WSprite OrigSprite = value as WSprite;

            FileAssignForm dlg = new FileAssignForm();

            dlg.Game       = Proxy.NativeObject.Game;
            dlg.ParentForm = Form.ActiveForm;
            dlg.Filter     = "Sprites|*.sprite;*.png;*.bmp;*.jpg;*.tga";
            if (OrigSprite != null && OrigSprite.Filename != null)
            {
                dlg.Filename = OrigSprite.Filename;
            }

            DialogResult Res = dlg.ShowDialog();

            switch (Res)
            {
            case DialogResult.OK:
                try
                {
                    WSprite NewSprite = new WSprite(Proxy.NativeObject.Game);
                    if (!NewSprite.LoadFromFile(dlg.Filename))
                    {
                        NewSprite.Dispose();
                        return(value);
                    }
                    else
                    {
                        return(NewSprite);
                    }
                }
                catch
                {
                    return(value);
                }

            case DialogResult.Abort:
                return(null);

            default:
                return(value);
            }
        }
Example #2
0
 private void OnFormClosed(object sender, FormClosedEventArgs e)
 {
     if (Game != null)
     {
         Canvas.Release();
         Sprite.Dispose();
         Entity.Dispose();
         Win.Dispose();
         Game.Dispose();
         Game = null;
     }
 }
        //////////////////////////////////////////////////////////////////////////
        public override object EditValue(ITypeDescriptorContext context, IServiceProvider provider, object value)
        {
            if (context == null) return value;
            NativePropProxy Proxy = context.Instance as NativePropProxy;
            if (Proxy == null || Proxy.NativeObject == null)
            {
                SystemSounds.Asterisk.Play();
                return value;
            }

            WSprite OrigSprite = value as WSprite;

            FileAssignForm dlg = new FileAssignForm();
            dlg.Game = Proxy.NativeObject.Game;
            dlg.ParentForm = Form.ActiveForm;
            dlg.Filter = "Sprites|*.sprite;*.png;*.bmp;*.jpg;*.tga";
            if (OrigSprite != null && OrigSprite.Filename != null)
                dlg.Filename = OrigSprite.Filename;

            DialogResult Res = dlg.ShowDialog();

            switch (Res)
            {
                case DialogResult.OK:
                    try
                    {
                        WSprite NewSprite = new WSprite(Proxy.NativeObject.Game);
                        if (!NewSprite.LoadFromFile(dlg.Filename))
                        {
                            NewSprite.Dispose();
                            return value;
                        }
                        else return NewSprite;
                    }
                    catch
                    {
                        return value;
                    }
                case DialogResult.Abort:
                    return null;
                default:
                    return value;
            }
        }