Esempio n. 1
0
        public override object EditValue(ITypeDescriptorContext context,
                                         IServiceProvider provider, object value)
        {
            IWindowsFormsEditorService svc = provider.GetService(typeof(IWindowsFormsEditorService)) as IWindowsFormsEditorService;
            string str = value as string;
            var    obj = context.Instance as IEditableEnvironment;

            if (svc != null && obj != null)
            {
                using (var dialog = new ImageSelectForm(obj.Environment.Project))
                {
                    dialog.SelectedImage = str;
                    if (svc.ShowDialog(dialog) == DialogResult.OK)
                    {
                        return(dialog.SelectedImage);
                    }
                }
            }
            return(value);
        }
Esempio n. 2
0
        public void ShowSelectImageForm()
        {
            if (_LastSelected != null)
            {
                var grid = (KeyFrameGrid)_LastSelected;

                var action = _Parent.CurrentAction;
                if (action == null)
                {
                    return;
                }

                var frame = action.Segments[grid.Segment].Frames[grid.Frame];

                var dialog = new ImageSelectForm(_Parent.Project)
                {
                    SelectedImage = frame.ImageID,
                };
                if (dialog.ShowDialog() == DialogResult.OK)
                {
                    frame.ImageID = dialog.SelectedImage;
                    RefreshList();
                }
            }
            else
            {
                var dialog = new ImageSelectForm(_Parent.Project)
                {
                    SelectedImage = null,
                };
                if (dialog.ShowDialog() == DialogResult.OK)
                {
                    //create a new frame
                    var action = _Parent.CurrentAction;
                    if (action == null)
                    {
                        return;
                    }

                    if (action.Segments.Count == 0)
                    {
                        action.Segments.Add(new Pat.AnimationSegment()
                        {
                            Frames = new List <Pat.Frame>(),
                        });
                    }
                    var segment = action.Segments.Last();

                    int duration = 1;
                    if (segment.Frames.Count > 0)
                    {
                        duration = segment.Frames.Last().Duration;
                    }

                    var frame = new Pat.Frame()
                    {
                        Duration    = duration,
                        ImageID     = dialog.SelectedImage,
                        AttackBoxes = new List <Pat.Box>(),
                        HitBoxes    = new List <Pat.Box>(),
                        Points      = new List <Pat.FramePoint>(),
                        ScaleX      = 100,
                        ScaleY      = 100,
                    };
                    segment.Frames.Add(frame);

                    //ensure after refreshing, the new frame is selected
                    _LastSelected = new KeyFrameGrid(null, 0, 0, 0, 0, frame);

                    RefreshList();
                }
            }
        }