Пример #1
0
        public override void Execute(object parameter)
        {
            var typeName = (string)parameter;
            var sel      = SelectionService.First(x => x is Model);
            var parent   = sel ?? Game.Workspace;

            ScriptService.NewInstance(typeName, parent);
        }
        public void OnObjectMouseDown(ObjectEntry entry, MouseButtonEventArgs args)
        {
            try
            {
                if (args.ClickCount == 2)
                {
                    switch (_mode)
                    {
                    case Mode.None:
                        break;

                    case Mode.Objects:
                        var inst = ScriptService.NewInstance(entry.Name, SelectionService.First() ?? Game.Workspace);
                        if (SelectInsertedObject)
                        {
                            SelectionService.Service.Select(inst, true);

                            ExplorerItem explorerItem;             // expand parent
                            if (ExplorerViewModel.ExplorerItems[inst.Parent].TryGetTarget(out explorerItem))
                            {
                                explorerItem.IsExpanded = true;
                            }
                        }
                        break;

                    case Mode.Expressions:
                        break;

                    case Mode.Snippets:
                        break;

                    default:
                        throw new ArgumentOutOfRangeException();
                    }
                }
            }
            catch (Exception e)
            {
                MessageBox.Show(e.Message, DisplayName);
            }
        }