Ejemplo n.º 1
0
        void RaiseUnitRequestedSetGroupsEvent()
        {
            var unitInfo     = (UnitStartInfo)DataContext;
            var newEventArgs = new UnitEventArgs(unitInfo, UnitRequestedSetGroupsEvent);

            RaiseEvent(newEventArgs);
        }
		void unitIcon_UnitRequestedSetGroups(object sender, UnitEventArgs e)
		{
            var source = (UnitIcon)e.Source;
			var selectedUnits = unitIcons.Where(i => i.IsSelected).ToList();
            if (!selectedUnits.Contains(source)) selectedUnits = new List<UnitIcon> { source };

			var groupsString = selectedUnits.Count() == 1 ? String.Join(",", e.UnitInfo.Groups) : String.Empty;
			groupsString = Utils.ShowStringDialog("Insert groups (separate multiple groups with commas).", groupsString);
			if (groupsString != null)
			{
				foreach (var unit in selectedUnits)
				{
					var unitStartInfo = (UnitStartInfo)unit.DataContext;
					unitStartInfo.Groups = new ObservableCollection<string>(groupsString.Split(','));
				}
			}
		}
		void unitIcon_UnitRequestedDelete(object sender, UnitEventArgs e)
		{
			var selectedUnits = unitIcons.Where(i => i.IsSelected).ToList();
			if (selectedUnits.Contains((UnitIcon)e.Source))
			{
				foreach (var unitIcon in selectedUnits)
				{
					var unit = (UnitStartInfo)unitIcon.DataContext;
					RemoveUnitIcon(unitIcon);
					action.Units.Remove(unit);
				}
			}
			else
			{
				var unitIcon = (UnitIcon)e.Source;
				var unit = (UnitStartInfo)unitIcon.DataContext;
				RemoveUnitIcon(unitIcon);
				action.Units.Remove(unit);
			}
		}