Exemplo n.º 1
0
        public void ReplaceSmartScript(SmartScript script)
        {
            ListViewItem lvi = Items[script.entryorguid.ToString()];

            if (lvi == null)
            {
                return;
            }

            lvi.SubItems.Clear();

            lvi.Name = script.entryorguid.ToString();
            lvi.Text = script.entryorguid.ToString();

            foreach (PropertyInfo propInfo in _pinfo.Where(p => !p.Name.Equals("entryorguid")))
            {
                if (_excludedProperties.Contains(propInfo.Name))
                {
                    continue;
                }

                lvi.SubItems.Add(propInfo.GetValue(script).ToString());
            }

            _smartScripts[_smartScripts.IndexOf(_smartScripts.Single(p => p.entryorguid == script.entryorguid))] = script;
        }
Exemplo n.º 2
0
        private SmartScript BuildSmartScript(DataRow row)
        {
            var smartScript = new SmartScript();

            smartScript.entryorguid      = row["entryorguid"] != DBNull.Value ? CustomConverter.ToInt32(row["entryorguid"]) : -1;
            smartScript.source_type      = row["source_type"] != DBNull.Value ? CustomConverter.ToInt32(row["source_type"]) : 0;
            smartScript.id               = row["id"] != DBNull.Value ? CustomConverter.ToInt32(row["id"]) : 0;
            smartScript.link             = row["link"] != DBNull.Value ? CustomConverter.ToInt32(row["link"]) : 0;
            smartScript.event_type       = row["event_type"] != DBNull.Value ? CustomConverter.ToInt32(row["event_type"]) : 0;
            smartScript.event_phase_mask = row["event_phase_mask"] != DBNull.Value ? CustomConverter.ToInt32(row["event_phase_mask"]) : 0;
            smartScript.event_chance     = row["event_chance"] != DBNull.Value ? CustomConverter.ToInt32(row["event_chance"]) : 0;
            smartScript.event_flags      = row["event_flags"] != DBNull.Value ? CustomConverter.ToInt32(row["event_flags"]) : 0;
            smartScript.event_param1     = row["event_param1"] != DBNull.Value ? CustomConverter.ToInt32(row["event_param1"]) : 0;
            smartScript.event_param2     = row["event_param2"] != DBNull.Value ? CustomConverter.ToInt32(row["event_param2"]) : 0;
            smartScript.event_param3     = row["event_param3"] != DBNull.Value ? CustomConverter.ToInt32(row["event_param3"]) : 0;
            smartScript.event_param4     = row["event_param4"] != DBNull.Value ? CustomConverter.ToInt32(row["event_param4"]) : 0;
            smartScript.action_type      = row["action_type"] != DBNull.Value ? CustomConverter.ToInt32(row["action_type"]) : 0;
            smartScript.action_param1    = row["action_param1"] != DBNull.Value ? CustomConverter.ToInt32(row["action_param1"]) : 0;
            smartScript.action_param2    = row["action_param2"] != DBNull.Value ? CustomConverter.ToInt32(row["action_param2"]) : 0;
            smartScript.action_param3    = row["action_param3"] != DBNull.Value ? CustomConverter.ToInt32(row["action_param3"]) : 0;
            smartScript.action_param4    = row["action_param4"] != DBNull.Value ? CustomConverter.ToInt32(row["action_param4"]) : 0;
            smartScript.action_param5    = row["action_param5"] != DBNull.Value ? CustomConverter.ToInt32(row["action_param5"]) : 0;
            smartScript.action_param6    = row["action_param6"] != DBNull.Value ? CustomConverter.ToInt32(row["action_param6"]) : 0;
            smartScript.target_type      = row["target_type"] != DBNull.Value ? CustomConverter.ToInt32(row["target_type"]) : 0;
            smartScript.target_param1    = row["target_param1"] != DBNull.Value ? CustomConverter.ToInt32(row["target_param1"]) : 0;
            smartScript.target_param2    = row["target_param2"] != DBNull.Value ? CustomConverter.ToInt32(row["target_param2"]) : 0;
            smartScript.target_param3    = row["target_param3"] != DBNull.Value ? CustomConverter.ToInt32(row["target_param3"]) : 0;
            smartScript.target_x         = row["target_x"] != DBNull.Value ? row["target_x"].ToString() : String.Empty;
            smartScript.target_y         = row["target_y"] != DBNull.Value ? row["target_y"].ToString() : String.Empty;
            smartScript.target_z         = row["target_z"] != DBNull.Value ? row["target_z"].ToString() : String.Empty;
            smartScript.target_o         = row["target_o"] != DBNull.Value ? row["target_o"].ToString() : String.Empty;
            smartScript.comment          = row["comment"] != DBNull.Value ? (string)row["comment"] : String.Empty;
            return(smartScript);
        }
Exemplo n.º 3
0
        public int AddSmartScript(SmartScript script, bool listViewOnly = false)
        {
            SmartScriptListViewItem lvi = new SmartScriptListViewItem(script.entryorguid.ToString());

            lvi.Script = script;
            lvi.Name   = script.entryorguid.ToString();

            foreach (PropertyInfo propInfo in _pinfo.Where(p => !p.Name.Equals("entryorguid")))
            {
                if (_excludedProperties.Contains(propInfo.Name))
                {
                    continue;
                }

                lvi.SubItems.Add(propInfo.GetValue(script).ToString());
            }

            if (!listViewOnly)
            {
                _smartScripts.Add(script);
            }

            ListViewItem newItem = Items.Add(lvi);

            HandleHighlightItems();
            return(newItem.Index);
        }
Exemplo n.º 4
0
 public EventAddedAction(SmartScript script, SmartEvent smartEvent, int index)
 {
     this.script     = script;
     this.smartEvent = smartEvent;
     this.index      = index;
     readable        = smartEvent.Readable;
 }
Exemplo n.º 5
0
        // Called when a quest status change
        public override void OnQuestStatusChange(Player player, Quest quest, QuestStatus oldStatus, QuestStatus newStatus)
        {
            SmartScript smartScript = new SmartScript();

            smartScript.OnInitialize(quest);
            switch (newStatus)
            {
            case QuestStatus.Incomplete:
                smartScript.ProcessEventsFor(SmartEvents.QuestAccepted, player);
                break;

            case QuestStatus.Complete:
                smartScript.ProcessEventsFor(SmartEvents.QuestCompletion, player);
                break;

            case QuestStatus.Failed:
                smartScript.ProcessEventsFor(SmartEvents.QuestFail, player);
                break;

            case QuestStatus.Rewarded:
                smartScript.ProcessEventsFor(SmartEvents.QuestRewarded, player);
                break;

            case QuestStatus.None:
            default:
                break;
            }
        }
Exemplo n.º 6
0
        public SmartScript Clone(SmartScript smartScript)
        {
            SmartScript newSmartScript = new SmartScript();

            newSmartScript.entryorguid      = smartScript.entryorguid;
            newSmartScript.source_type      = smartScript.source_type;
            newSmartScript.id               = smartScript.id;
            newSmartScript.link             = smartScript.link;
            newSmartScript.event_type       = smartScript.event_type;
            newSmartScript.event_phase_mask = smartScript.event_phase_mask;
            newSmartScript.event_chance     = smartScript.event_chance;
            newSmartScript.event_flags      = smartScript.event_flags;
            newSmartScript.event_param1     = smartScript.event_param1;
            newSmartScript.event_param2     = smartScript.event_param2;
            newSmartScript.event_param3     = smartScript.event_param3;
            newSmartScript.event_param4     = smartScript.event_param4;
            newSmartScript.action_type      = smartScript.action_type;
            newSmartScript.action_param1    = smartScript.action_param1;
            newSmartScript.action_param2    = smartScript.action_param2;
            newSmartScript.action_param3    = smartScript.action_param3;
            newSmartScript.action_param4    = smartScript.action_param4;
            newSmartScript.action_param5    = smartScript.action_param5;
            newSmartScript.action_param6    = smartScript.action_param6;
            newSmartScript.target_type      = smartScript.target_type;
            newSmartScript.target_param1    = smartScript.target_param1;
            newSmartScript.target_param2    = smartScript.target_param2;
            newSmartScript.target_param3    = smartScript.target_param3;
            newSmartScript.target_x         = smartScript.target_x;
            newSmartScript.target_y         = smartScript.target_y;
            newSmartScript.target_z         = smartScript.target_z;
            newSmartScript.target_o         = smartScript.target_o;
            newSmartScript.comment          = smartScript.comment;
            return(newSmartScript);
        }
Exemplo n.º 7
0
        public void AddScript(SmartScript script, bool listViewOnly = false, bool selectNewItem = false)
        {
            base.AddScript(script, listViewOnly, selectNewItem);

            if (Settings.Default.PhaseHighlighting && script.event_phase_mask != 0)
            {
                if (!_phaseColors.ContainsKey(script.event_phase_mask))
                {
                    if (_colors.Count == 0)
                    {
                        MessageBox.Show("There are not enough colors in the application because you are using too many different phasemasks.", "Not enough colors!", MessageBoxButtons.OK, MessageBoxIcon.Error);
                        return;
                    }

                    _phaseColors.Add(script.event_phase_mask, _colors.Pop());
                }

                _oListView.Refresh();
                ResizeColumns();
            }

            ListView.HideSelection = false;
            ListView.Focus();
            ListView.SelectObject(script);
            _oListView.Select();
            _oListView.SelectObject(script);
            _oListView.EnsureModelVisible(script);
        }
Exemplo n.º 8
0
        public override void OnSceneComplete(Player player, uint sceneInstanceID, SceneTemplate sceneTemplate)
        {
            SmartScript smartScript = new SmartScript();

            smartScript.OnInitialize(sceneTemplate);
            smartScript.ProcessEventsFor(SmartEvents.SceneComplete, player);
        }
Exemplo n.º 9
0
        public override void OnSceneTriggerEvent(Player player, uint sceneInstanceID, SceneTemplate sceneTemplate, string triggerName)
        {
            SmartScript smartScript = new SmartScript();

            smartScript.OnInitialize(sceneTemplate);
            smartScript.ProcessEventsFor(SmartEvents.SceneTrigger, player, 0, 0, false, null, null, triggerName);
        }
Exemplo n.º 10
0
        public SmartScript Clone()
        {
            SmartScript newSmartScript = new SmartScript();

            newSmartScript.entryorguid      = entryorguid;
            newSmartScript.source_type      = source_type;
            newSmartScript.id               = id;
            newSmartScript.link             = link;
            newSmartScript.event_type       = event_type;
            newSmartScript.event_phase_mask = event_phase_mask;
            newSmartScript.event_chance     = event_chance;
            newSmartScript.event_flags      = event_flags;
            newSmartScript.event_param1     = event_param1;
            newSmartScript.event_param2     = event_param2;
            newSmartScript.event_param3     = event_param3;
            newSmartScript.event_param4     = event_param4;
            newSmartScript.action_type      = action_type;
            newSmartScript.action_param1    = action_param1;
            newSmartScript.action_param2    = action_param2;
            newSmartScript.action_param3    = action_param3;
            newSmartScript.action_param4    = action_param4;
            newSmartScript.action_param5    = action_param5;
            newSmartScript.action_param6    = action_param6;
            newSmartScript.target_type      = target_type;
            newSmartScript.target_param1    = target_param1;
            newSmartScript.target_param2    = target_param2;
            newSmartScript.target_param3    = target_param3;
            newSmartScript.target_x         = target_x;
            newSmartScript.target_y         = target_y;
            newSmartScript.target_z         = target_z;
            newSmartScript.target_o         = target_o;
            newSmartScript.comment          = comment;
            return(newSmartScript);
        }
Exemplo n.º 11
0
        public int AddScript(SmartScript script, bool listViewOnly = false, bool selectNewItem = false)
        {
            int index = base.AddScript(script, listViewOnly, selectNewItem);

            ListViewItem newItem = Items[index];

            if (Settings.Default.PhaseHighlighting && script.event_phase_mask != 0)
            {
                if (!_phaseColors.ContainsKey(script.event_phase_mask))
                {
                    if (_colors.Count == 0)
                    {
                        MessageBox.Show("There are not enough colors in the application because you are using too many different phasemasks.", "Not enough colors!", MessageBoxButtons.OK, MessageBoxIcon.Error);
                        return(-1);
                    }

                    _phaseColors.Add(script.event_phase_mask, _colors.Pop());
                }

                newItem.BackColor = _phaseColors[script.event_phase_mask];
            }

            newItem.Selected = selectNewItem;
            Select();
            EnsureVisible(index);
            return(index);
        }
Exemplo n.º 12
0
 public SmartScript Clone()
 {
     SmartScript newSmartScript = new SmartScript();
     newSmartScript.entryorguid = entryorguid;
     newSmartScript.source_type = source_type;
     newSmartScript.id = id;
     newSmartScript.link = link;
     newSmartScript.event_type = event_type;
     newSmartScript.event_phase_mask = event_phase_mask;
     newSmartScript.event_chance = event_chance;
     newSmartScript.event_flags = event_flags;
     newSmartScript.event_param1 = event_param1;
     newSmartScript.event_param2 = event_param2;
     newSmartScript.event_param3 = event_param3;
     newSmartScript.event_param4 = event_param4;
     newSmartScript.action_type = action_type;
     newSmartScript.action_param1 = action_param1;
     newSmartScript.action_param2 = action_param2;
     newSmartScript.action_param3 = action_param3;
     newSmartScript.action_param4 = action_param4;
     newSmartScript.action_param5 = action_param5;
     newSmartScript.action_param6 = action_param6;
     newSmartScript.target_type = target_type;
     newSmartScript.target_param1 = target_param1;
     newSmartScript.target_param2 = target_param2;
     newSmartScript.target_param3 = target_param3;
     newSmartScript.target_x = target_x;
     newSmartScript.target_y = target_y;
     newSmartScript.target_z = target_z;
     newSmartScript.target_o = target_o;
     newSmartScript.comment = comment;
     return newSmartScript;
 }
Exemplo n.º 13
0
 public SmartScript Clone(SmartScript smartScript)
 {
     SmartScript newSmartScript = new SmartScript();
     newSmartScript.entryorguid = smartScript.entryorguid;
     newSmartScript.source_type = smartScript.source_type;
     newSmartScript.id = smartScript.id;
     newSmartScript.link = smartScript.link;
     newSmartScript.event_type = smartScript.event_type;
     newSmartScript.event_phase_mask = smartScript.event_phase_mask;
     newSmartScript.event_chance = smartScript.event_chance;
     newSmartScript.event_flags = smartScript.event_flags;
     newSmartScript.event_param1 = smartScript.event_param1;
     newSmartScript.event_param2 = smartScript.event_param2;
     newSmartScript.event_param3 = smartScript.event_param3;
     newSmartScript.event_param4 = smartScript.event_param4;
     newSmartScript.action_type = smartScript.action_type;
     newSmartScript.action_param1 = smartScript.action_param1;
     newSmartScript.action_param2 = smartScript.action_param2;
     newSmartScript.action_param3 = smartScript.action_param3;
     newSmartScript.action_param4 = smartScript.action_param4;
     newSmartScript.action_param5 = smartScript.action_param5;
     newSmartScript.action_param6 = smartScript.action_param6;
     newSmartScript.target_type = smartScript.target_type;
     newSmartScript.target_param1 = smartScript.target_param1;
     newSmartScript.target_param2 = smartScript.target_param2;
     newSmartScript.target_param3 = smartScript.target_param3;
     newSmartScript.target_x = smartScript.target_x;
     newSmartScript.target_y = smartScript.target_y;
     newSmartScript.target_z = smartScript.target_z;
     newSmartScript.target_o = smartScript.target_o;
     newSmartScript.comment = smartScript.comment;
     return newSmartScript;
 }
Exemplo n.º 14
0
        public void AddScript(SmartScript script, bool listViewOnly = false, bool selectNewItem = false)
        {
            base.AddScript(script, listViewOnly, selectNewItem);

            //TODO: Fix me
            //if (Settings.Default.PhaseHighlighting && script.event_phase_mask != 0)
            //{
            //    if (!_phaseColors.ContainsKey(script.event_phase_mask))
            //    {
            //        if (_colors.Count == 0)
            //        {
            //            MessageBox.Show("There are not enough colors in the application because you are using too many different phasemasks.", "Not enough colors!", MessageBoxButtons.OK, MessageBoxIcon.Error);
            //            return -1;
            //        }

            //        _phaseColors.Add(script.event_phase_mask, _colors.Pop());
            //    }

            //    newItem.BackColor = _phaseColors[script.event_phase_mask];
            //}

            ListView.SelectObject(script);
            _oListView.Select();
            _oListView.EnsureModelVisible(script);
        }
Exemplo n.º 15
0
 public EventAddedAction(SmartScript script, SmartEvent smartEvent, int index)
 {
     _script     = script;
     _smartEvent = smartEvent;
     _index      = index;
     _readable   = smartEvent.Readable;
 }
Exemplo n.º 16
0
        public void ReplaceSmartScript(SmartScript script)
        {
            SmartScriptListViewItem lvi = Items.Cast <SmartScriptListViewItem>().SingleOrDefault(p => p.Script == script);

            if (lvi == null)
            {
                return;
            }

            lvi.SubItems.Clear();
            lvi.Name = script.entryorguid.ToString();
            lvi.Text = script.entryorguid.ToString();

            foreach (PropertyInfo propInfo in _pinfo.Where(p => !p.Name.Equals("entryorguid")))
            {
                if (_excludedProperties.Contains(propInfo.Name))
                {
                    continue;
                }

                lvi.SubItems.Add(propInfo.GetValue(script).ToString());
            }

            _smartScripts[_smartScripts.IndexOf(lvi.Script)] = script;
            HandleHighlightItems();
        }
Exemplo n.º 17
0
        private void oListView_FormatRow(object sender, FormatRowEventArgs e)
        {
            SmartScript script = (SmartScript)e.Model;

            if (script != null && _phaseColors.ContainsKey(script.event_phase_mask))
            {
                e.Item.BackColor = _phaseColors[script.event_phase_mask];
            }
        }
Exemplo n.º 18
0
 // Called when a quest objective data change
 public override void OnQuestObjectiveChange(Player player, Quest quest, QuestObjective objective, int oldAmount, int newAmount)
 {
     if (player.IsQuestObjectiveComplete(objective))
     {
         SmartScript smartScript = new SmartScript();
         smartScript.OnInitialize(quest);
         smartScript.ProcessEventsFor(SmartEvents.QuestObjCompletion, player, objective.Id);
     }
 }
Exemplo n.º 19
0
        public void RemoveSmartScript(SmartScript script)
        {
            foreach (SmartScriptListViewItem item in Items.Cast <SmartScriptListViewItem>().Where(item => item.Script == script))
            {
                Items.Remove(item);
                break;
            }

            _smartScripts.Remove(script);
        }
        public SaiHistoryHandler(SmartScript script)
        {
            _script = script;
            _script.Events.CollectionChanged += Events_CollectionChanged;

            foreach (SmartEvent ev in _script.Events)
            {
                BindEvent(ev);
            }
        }
Exemplo n.º 21
0
        // Called when a quest objective data change
        public override void OnQuestObjectiveChange(Player player, Quest quest, QuestObjective objective, int oldAmount, int newAmount)
        {
            ushort slot = player.FindQuestSlot(quest.Id);

            if (slot < SharedConst.MaxQuestLogSize && player.IsQuestObjectiveComplete(slot, quest, objective))
            {
                SmartScript smartScript = new SmartScript();
                smartScript.OnInitialize(quest);
                smartScript.ProcessEventsFor(SmartEvents.QuestObjCompletion, player, objective.Id);
            }
        }
Exemplo n.º 22
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));
        }
Exemplo n.º 23
0
        public SaiHistoryHandler(SmartScript script)
        {
            _script = script;
            _script.Events.CollectionChanged += Events_CollectionChanged;
            _script.BulkEditingStarted       += OnBulkEditingStarted;
            _script.BulkEditingFinished      += OnBulkEditingFinished;

            foreach (SmartEvent ev in _script.Events)
            {
                BindEvent(ev);
            }
        }
Exemplo n.º 24
0
        public SaiHistoryHandler(SmartScript script, ISmartFactory smartFactory)
        {
            this.script       = script;
            this.smartFactory = smartFactory;
            this.script.Events.CollectionChanged += Events_CollectionChanged;
            this.script.BulkEditingStarted       += OnBulkEditingStarted;
            this.script.BulkEditingFinished      += OnBulkEditingFinished;

            foreach (SmartEvent ev in this.script.Events)
            {
                BindEvent(ev);
            }
        }
Exemplo n.º 25
0
        private void oListView_FormatRow(object sender, FormatRowEventArgs e)
        {
            if (!Settings.Default.PhaseHighlighting)
            {
                return;
            }

            SmartScript script = (SmartScript)e.Model;

            if (script != null && _phaseColors.ContainsKey(script.event_phase_mask))
            {
                e.Item.BackColor = _phaseColors[script.event_phase_mask];
            }
        }
Exemplo n.º 26
0
        public override bool OnTrigger(Player player, AreaTriggerRecord trigger, bool entered)
        {
            if (!player.IsAlive())
            {
                return(false);
            }

            Log.outDebug(LogFilter.ScriptsAi, "AreaTrigger {0} is using SmartTrigger script", trigger.Id);
            SmartScript script = new SmartScript();

            script.OnInitialize(trigger);
            script.ProcessEventsFor(SmartEvents.AreatriggerOntrigger, player, trigger.Id);
            return(true);
        }
        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 ExporterHelper(SmartScript script,
                       IDatabaseProvider databaseProvider,
                       ISmartScriptSolutionItem item,
                       ISmartScriptExporter scriptExporter,
                       ICurrentCoreVersion currentCoreVersion,
                       ISolutionItemNameRegistry nameProvider,
                       IConditionQueryGenerator conditionQueryGenerator)
 {
     this.script                  = script;
     this.databaseProvider        = databaseProvider;
     this.item                    = item;
     this.scriptExporter          = scriptExporter;
     this.currentCoreVersion      = currentCoreVersion;
     this.conditionQueryGenerator = conditionQueryGenerator;
     this.nameProvider            = nameProvider;
 }
        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();
                    }
                }
            });
        }
Exemplo n.º 30
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()
                }
            });
        public string GenerateSql(SmartScriptSolutionItem item)
        {
            EventRequestGenerateSqlArgs args = new EventRequestGenerateSqlArgs();

            args.Item = item;

            eventAggregator.GetEvent <EventRequestGenerateSql>().Publish(args);

            if (args.Sql != null)
            {
                return(args.Sql);
            }

            SmartScript script = new SmartScript(item, smartFactory.Value);

            script.Load(database.Value.GetScriptFor(item.Entry, item.SmartType));
            return(new SmartScriptExporter(script, smartFactory.Value).GetSql());
        }
Exemplo n.º 32
0
        public int AddSmartScript(SmartScript script, bool listViewOnly = false, bool selectNewItem = false)
        {
            SmartScriptListViewItem lvi = new SmartScriptListViewItem(script.entryorguid.ToString());

            lvi.Script = script;
            lvi.Name   = script.entryorguid.ToString();

            foreach (PropertyInfo propInfo in _pinfo.Where(p => !p.Name.Equals("entryorguid")))
            {
                if (_excludedProperties.Contains(propInfo.Name))
                {
                    continue;
                }

                lvi.SubItems.Add(propInfo.GetValue(script).ToString());
            }

            if (!listViewOnly)
            {
                _smartScripts.Add(script);
            }

            ListViewItem newItem = Items.Add(lvi);

            if (Settings.Default.PhaseHighlighting && script.event_phase_mask != 0)
            {
                if (!_phaseColors.ContainsKey(script.event_phase_mask))
                {
                    if (_colors.Count == 0)
                    {
                        MessageBox.Show("There are not enough colors in the application because you are using too many different phasemasks.", "Not enough colors!", MessageBoxButtons.OK, MessageBoxIcon.Error);
                        return(-1);
                    }

                    _phaseColors.Add(script.event_phase_mask, _colors.Pop());
                }

                newItem.BackColor = _phaseColors[script.event_phase_mask];
            }

            newItem.Selected = selectNewItem;
            return(newItem.Index);
        }