//////////////////////////////////////////////////////////////////////////
        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);
            }

            WAdEntity OrigObj = value as WAdEntity;

            FileAssignForm dlg = new FileAssignForm();

            dlg.Game       = Proxy.NativeObject.Game;
            dlg.ParentForm = Form.ActiveForm;
            dlg.Filter     = "Entities|*.entity";
            if (OrigObj != null && OrigObj.Filename != null)
            {
                dlg.Filename = OrigObj.Filename;
            }

            DialogResult Res = dlg.ShowDialog();

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

            case DialogResult.Abort:
                return(null);

            default:
                return(value);
            }
        }
Ejemplo n.º 2
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);
            }
        }
Ejemplo n.º 3
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);
            }

            WFont OrigFont = value as WFont;

            FileAssignForm dlg = new FileAssignForm();

            dlg.Game       = Proxy.NativeObject.Game;
            dlg.ParentForm = Form.ActiveForm;
            dlg.Filter     = "Fonts|*.font";
            if (OrigFont != null && OrigFont.Filename != null)
            {
                dlg.Filename = OrigFont.Filename;
            }

            DialogResult Res = dlg.ShowDialog();

            switch (Res)
            {
            case DialogResult.OK:
                try
                {
                    WFont NewFont = Proxy.NativeObject.Game.CreateFont(dlg.Filename);
                    if (NewFont != null)
                    {
                        return(NewFont);
                    }
                    else
                    {
                        return(value);
                    }
                }
                catch
                {
                    return(value);
                }

            case DialogResult.Abort:
                return(null);

            default:
                return(value);
            }
        }
        //////////////////////////////////////////////////////////////////////////
        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;
            }

            WAdEntity OrigObj = value as WAdEntity;

            FileAssignForm dlg = new FileAssignForm();
            dlg.Game = Proxy.NativeObject.Game;
            dlg.ParentForm = Form.ActiveForm;
            dlg.Filter = "Entities|*.entity";
            if (OrigObj != null && OrigObj.Filename != null)
                dlg.Filename = OrigObj.Filename;

            DialogResult Res = dlg.ShowDialog();

            switch (Res)
            {
                case DialogResult.OK:
                    try
                    {
                        WAdEntity NewObj = new WAdEntity(Proxy.NativeObject.Game);
                        if (!NewObj.LoadFromFile(dlg.Filename))
                        {
                            NewObj.Dispose();
                            return value;
                        }
                        else return NewObj;
                    }
                    catch
                    {
                        return value;
                    }
                case DialogResult.Abort:
                    return null;
                default:
                    return value;
            }
        }
        //////////////////////////////////////////////////////////////////////////
        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;
            }
        }
        //////////////////////////////////////////////////////////////////////////
        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;
            }

            WFont OrigFont = value as WFont;

            FileAssignForm dlg = new FileAssignForm();
            dlg.Game = Proxy.NativeObject.Game;
            dlg.ParentForm = Form.ActiveForm;
            dlg.Filter = "Fonts|*.font";
            if (OrigFont != null && OrigFont.Filename != null)
                dlg.Filename = OrigFont.Filename;

            DialogResult Res = dlg.ShowDialog();

            switch(Res)
            {
                case DialogResult.OK:
                    try
                    {
                        WFont NewFont = Proxy.NativeObject.Game.CreateFont(dlg.Filename);
                        if (NewFont != null) return NewFont;
                        else return value;
                    }
                    catch
                    {
                        return value;
                    }
                case DialogResult.Abort:
                    return null;
                default:
                    return value;
            }
        }