public SmartScript(SmartScriptSolutionItem item, IUnityContainer container)
 {
     EntryOrGuid = item.Entry;
     SourceType  = item.SmartType;
     _container  = container;
     Events      = new ObservableCollection <SmartEvent>();
 }
 public SmartScript(SmartScriptSolutionItem item, ISmartFactory smartFactory)
 {
     EntryOrGuid       = item.Entry;
     SourceType        = item.SmartType;
     Events            = new ObservableCollection <SmartEvent>();
     this.smartFactory = smartFactory;
 }
예제 #3
0
        internal void SetSolutionItem(SmartScriptSolutionItem item)
        {
            Debug.Assert(_item == null);
            _item = item;

            var lines = database.GetScriptFor(_item.Entry, _item.SmartType);

            script = new SmartScript(_item, smartFactory);
            script.Load(lines);

            history.AddHandler(new SaiHistoryHandler(script));
        }
        public SmartScriptEditorViewModel(SmartScriptSolutionItem item, IHistoryManager history, IDatabaseProvider database, IEventAggregator eventAggregator, ISmartDataManager smartDataManager, ISmartFactory smartFactory, IItemFromListProvider itemFromListProvider, ISmartTypeListProvider smartTypeListProvider, ISolutionItemNameRegistry itemNameRegistry)
        {
            _item                      = item;
            _history                   = history;
            this.database              = database;
            this.smartDataManager      = smartDataManager;
            this.smartFactory          = smartFactory;
            this.itemFromListProvider  = itemFromListProvider;
            this.smartTypeListProvider = smartTypeListProvider;
            this.itemNameRegistry      = itemNameRegistry;
            var lines = database.GetScriptFor(_item.Entry, _item.SmartType);

            script = new SmartScript(_item, smartFactory);
            script.Load(lines);

            EditEvent  = new DelegateCommand(EditEventCommand);
            EditAction = new DelegateCommand <SmartAction>(EditActionCommand);
            AddEvent   = new DelegateCommand(AddEventCommand);
            AddAction  = new DelegateCommand <SmartEvent>(AddActionCommand);

            SaveCommand = new DelegateCommand(SaveAllToDb);

            DeleteAction = new DelegateCommand <SmartAction>(DeleteActionCommand);
            DeleteEvent  = new DelegateCommand(DeleteEventCommand);

            _history.AddHandler(new SaiHistoryHandler(script));

            UndoCommand = new DelegateCommand(history.Undo, () => history.CanUndo);
            RedoCommand = new DelegateCommand(history.Redo, () => history.CanRedo);

            _history.PropertyChanged += (sender, args) =>
            {
                UndoCommand.RaiseCanExecuteChanged();
                RedoCommand.RaiseCanExecuteChanged();
            };

            eventAggregator.GetEvent <EventRequestGenerateSql>().Subscribe((args) =>
            {
                if (args.Item is SmartScriptSolutionItem)
                {
                    var itemm = args.Item as SmartScriptSolutionItem;
                    if (itemm.Entry == _item.Entry && itemm.SmartType == _item.SmartType)
                    {
                        args.Sql = new SmartScriptExporter(script, smartFactory).GetSql();
                    }
                }
            });
        }
        public SmartScriptEditorViewModel(SmartScriptSolutionItem item, IUnityContainer container, IHistoryManager history)
        {
            _item      = item;
            _container = container;
            _history   = history;

            var lines = _container.Resolve <IDatabaseProvider>().GetScriptFor(_item.Entry, _item.SmartType);

            script = new SmartScript(_item, _container);
            script.Load(lines);

            EditEvent  = new DelegateCommand(EditEventCommand);
            EditAction = new DelegateCommand <SmartAction>(EditActionCommand);
            AddEvent   = new DelegateCommand(AddEventCommand);
            AddAction  = new DelegateCommand <SmartEvent>(AddActionCommand);

            SaveCommand = new DelegateCommand(SaveAllToDb);

            DeleteAction = new DelegateCommand <SmartAction>(DeleteActionCommand);
            DeleteEvent  = new DelegateCommand(DeleteEventCommand);

            _history.AddHandler(new SaiHistoryHandler(script));

            UndoCommand = new DelegateCommand(history.Undo, () => history.CanUndo);
            RedoCommand = new DelegateCommand(history.Redo, () => history.CanRedo);

            _history.PropertyChanged += (sender, args) =>
            {
                UndoCommand.RaiseCanExecuteChanged();
                RedoCommand.RaiseCanExecuteChanged();
            };

            var ea = container.Resolve <IEventAggregator>();

            ea.GetEvent <EventRequestGenerateSql>().Subscribe((args) =>
            {
                if (args.Item is SmartScriptSolutionItem)
                {
                    var itemm = args.Item as SmartScriptSolutionItem;
                    if (itemm.Entry == _item.Entry && itemm.SmartType == _item.SmartType)
                    {
                        args.Sql = new SmartScriptExporter(script, _container).GetSql();
                    }
                }
            });
        }
예제 #6
0
        internal void SetSolutionItem(SmartScriptSolutionItem item)
        {
            Debug.Assert(_item == null);
            _item = item;
            Title = itemNameRegistry.GetName(item);

            var lines = database.GetScriptFor(_item.Entry, _item.SmartType);

            script = new SmartScript(_item, smartFactory);
            script.Load(lines);

            Together.Add(new CollectionContainer()
            {
                Collection = new List <NewActionViewModel>()
                {
                    new()
                }
            });
예제 #7
0
        public SmartScript(SmartScriptSolutionItem item,
                           ISmartFactory smartFactory,
                           ISmartDataManager smartDataManager,
                           IMessageBoxService messageBoxService)
        {
            this.smartFactory      = smartFactory;
            this.smartDataManager  = smartDataManager;
            this.messageBoxService = messageBoxService;
            EntryOrGuid            = item.Entry;
            SourceType             = item.SmartType;
            Events          = new ObservableCollection <SmartEvent>();
            selectionHelper = new SmartSelectionHelper(this);
            selectionHelper.ScriptSelectedChanged += CallScriptSelectedChanged;
            AllSmartObjectsFlat = selectionHelper.AllSmartObjectsFlat;

            Events.ToStream()
            .Subscribe((e) =>
            {
                if (e.Type == CollectionEventType.Add)
                {
                    e.Item.Parent = this;
                }
            });
        }