void WindowKeyDown(object sender, KeyEventArgs args) { ListView lv = (ListView)args.Source; ZoneGroup zg = (ZoneGroup)lv.DataContext; ZonePlayer zp = zg.Coordinator; switch (args.Key) { case Key.Delete: // have to make a copy since there will be a callback // each time the queue is modified QueueItem[] delete = new QueueItem[lv.SelectedItems.Count]; lv.SelectedItems.CopyTo(delete, 0); // reverse numeric sort on queue ID Array.Sort(delete, delegate(QueueItem a, QueueItem b) { return(Comparer <int> .Default.Compare(a.NumericId, b.NumericId) * -1); }); // deletes must be synchronous & in order to work properly ThreadPool.QueueUserWorkItem(delegate { foreach (QueueItem qi in delete) { zp.AVTransport.RemoveTrackFromQueue(qi.ItemId); } }); args.Handled = true; break; } }
public ActionResult AddZoneGroup(string ZoneGroupCode, string ZoneGroupName, string ZoneGroupAddress, string ZoneGroupRole, string ZoneGroupInitial) { if (!db.ZoneGroup.Any(m => m.ZoneGroupCode == ZoneGroupCode)) { SearchZoneGroupViewModel SearchZoneGroup = new SearchZoneGroupViewModel(); ZoneGroup ZoneGroupAssignment = new ZoneGroup(); ZoneGroupAssignment.ZoneGroupCode = ZoneGroupCode; ZoneGroupAssignment.ZoneGroupName = ZoneGroupName; ZoneGroupAssignment.ZoneGroupAddress = ZoneGroupAddress; ZoneGroupAssignment.ZoneGroupRole = ZoneGroupRole; ZoneGroupAssignment.ZoneGroupInitials = ZoneGroupInitial; db.ZoneGroup.Add(ZoneGroupAssignment); db.SaveChanges(); TempData["TransactionSuccess"] = "Add"; SL.LogInfo(User.Identity.Name, Request.RawUrl, "Admin Zone - Zone Group Added - from Terminal: " + ipaddress); return(RedirectToAction("ViewZoneGroup")); } else { TempData["TransactionSuccess"] = "Duplicate"; SL.LogInfo(User.Identity.Name, Request.RawUrl, "Admin Zone - Zone Group Duplicate - from Terminal: " + ipaddress); return(RedirectToAction("ViewZoneGroup")); } }
// TODO 1.2 // public uint PeaceTowerDefId { get; set; } public ZoneConflict(ZoneGroup owner) { _owner = owner; NumKills = new int[5]; NoKillMin = new int[5]; }
void MediaCommands_NextTrack(object sender, ExecutedRoutedEventArgs e) { SonosControl tc = (SonosControl)sender; ZoneGroup zg = (ZoneGroup)tc.DataContext; ZonePlayer zp = zg.Coordinator; zp.AVTransport.Next(); e.Handled = true; }
void MediaCommands_Select(object sender, ExecutedRoutedEventArgs e) { SonosControl tc = (SonosControl)sender; ZoneGroup zg = (ZoneGroup)tc.DataContext; ZonePlayer zp = zg.Coordinator; zp.RenderingControl.SetMute(Channel.Master, !zp.RenderingControl.Mute[Channel.Master]); e.Handled = true; }
void MediaCommands_CanPreviousTrack(object sender, CanExecuteRoutedEventArgs e) { SonosControl tc = (SonosControl)sender; ZoneGroup zg = (ZoneGroup)tc.DataContext; ZonePlayer zp = zg.Coordinator; e.CanExecute = zp.AVTransport.CurrentTrack > 0; e.Handled = true; }
void ListDoubleClick(object sender, MouseButtonEventArgs args) { ListView lv = (ListView)args.Source; ZoneGroup zg = (ZoneGroup)lv.DataContext; ZonePlayer zp = zg.Coordinator; // make sure it's playing off the queue before we select a queue track. might be a callback that can be // used instead of this explicit call, but this works for now. sort of hacky but it looks like the Sonos client // does the same thing... what can you do? :-( zp.AVTransport.SetAVTransportUri(zp.QueueUri, ""); // Sonos queues are 1 based, ListView index is 0 based zp.AVTransport.Seek(SeekMode.TRACK_NR, (lv.SelectedIndex + 1).ToString()); zp.AVTransport.Play(); }
public ActionResult UpdateZoneGroup(FormCollection frmcollection) { ZoneGroup zonegroupinfo = null; int ParsedIntID = int.Parse(frmcollection["ZoneGId"]); string zonegroupcode = frmcollection["ZoneGroupCode"].ToString(); zonegroupinfo = db.ZoneGroup.Find(ParsedIntID); string zoneCodeOrig = db.ZoneGroup.FirstOrDefault(m => m.ZoneGroupId == ParsedIntID).ZoneGroupCode; int newzonecodeId = 0; if (db.ZoneGroup.Any(m => m.ZoneGroupCode == zonegroupcode)) { newzonecodeId = db.ZoneGroup.FirstOrDefault(m => m.ZoneGroupCode == zonegroupcode).ZoneGroupId; } if ((db.ZoneGroup.Any(m => m.ZoneGroupCode == zonegroupcode) && newzonecodeId == ParsedIntID) || (!db.ZoneGroup.Any(m => m.ZoneGroupCode == zonegroupcode))) { if (zonegroupinfo != null) { zonegroupinfo.ZoneGroupCode = frmcollection["ZoneGroupCode"].ToString(); zonegroupinfo.ZoneGroupName = frmcollection["ZoneGroupName"].ToString(); zonegroupinfo.ZoneGroupAddress = frmcollection["ZoneGroupAddress"].ToString(); zonegroupinfo.ZoneGroupRole = frmcollection["ZoneGroupRole"].ToString(); zonegroupinfo.ZoneGroupInitials = frmcollection["ZoneGroupInitial"].ToString(); db.Entry(zonegroupinfo).State = System.Data.Entity.EntityState.Modified; SL.LogInfo(User.Identity.Name, Request.RawUrl, "Admin Zone - Zone Group Edited - from Terminal: " + ipaddress); db.SaveChanges(); TempData["TransactionSuccess"] = "Edit"; } } else { TempData["TransactionSuccess"] = "Duplicate"; } return(RedirectToAction("ViewZoneGroup")); }
public ActionResult ViewZoneGroup(FormCollection frm) { if (frm.Count == 0) { SearchZoneGroupViewModel SearchZoneGroupViewModels = new SearchZoneGroupViewModel(); SearchZoneGroupViewModels.ZoneGroupList = db.ZoneGroup.SqlQuery("Select * from ZoneGroups where ZoneGroupCode != '99'").ToList(); ViewBag.TransactionSuccess = TempData["TransactionSuccess"] as string; return(View(SearchZoneGroupViewModels)); } else if (frm.Count >= 1) { int parsedID = int.Parse(frm["ZoneGroupId"]); ZoneGroup zonegroup = db.ZoneGroup.Find(parsedID); db.ZoneGroup.Remove(zonegroup); SL.LogInfo(User.Identity.Name, Request.RawUrl, "Admin Zone -View Zone Group - Zone Group Updated - from Terminal: " + ipaddress); db.SaveChanges(); return(RedirectToAction("ViewZoneGroup")); } return(View()); }
public void Load() { _zones = new Dictionary <uint, Zone>(); _groups = new Dictionary <ushort, ZoneGroup>(); _conflicts = new Dictionary <ushort, ZoneConflict>(); _groupBannedTags = new Dictionary <uint, ZoneGroupBannedTag>(); _climateElem = new Dictionary <uint, ZoneClimateElem>(); _log.Info("Loading ZoneManager..."); using (var connection = SQLite.CreateConnection()) { using (var command = connection.CreateCommand()) { command.CommandText = "SELECT * FROM zones"; command.Prepare(); using (var reader = new SQLiteWrapperReader(command.ExecuteReader())) { while (reader.Read()) { var template = new Zone(); template.Id = reader.GetUInt32("id"); template.Name = (string)reader.GetValue("name"); template.ZoneKey = reader.GetUInt32("zone_key"); template.GroupId = reader.GetUInt32("group_id", 0); template.Closed = reader.GetBoolean("closed", true); template.FactionId = reader.GetUInt32("faction_id", 0); template.ZoneClimateId = reader.GetUInt32("zone_climate_id", 0); _zones.Add(template.ZoneKey, template); } } } _log.Info("Loaded {0} zones", _zones.Count); using (var command = connection.CreateCommand()) { command.CommandText = "SELECT * FROM zone_groups"; command.Prepare(); using (var reader = new SQLiteWrapperReader(command.ExecuteReader())) { while (reader.Read()) { var template = new ZoneGroup(); template.Id = reader.GetUInt16("id"); template.Name = (string)reader.GetValue("name"); template.X = reader.GetFloat("x"); template.Y = reader.GetFloat("y"); template.Width = reader.GetFloat("w"); template.Hight = reader.GetFloat("h"); template.TargetId = reader.GetUInt32("target_id"); template.FactionChatRegionId = reader.GetUInt32("faction_chat_region_id"); template.PirateDesperado = reader.GetBoolean("pirate_desperado", true); template.FishingSeaLootPackId = reader.GetUInt32("fishing_sea_loot_pack_id", 0); template.FishingLandLootPackId = reader.GetUInt32("fishing_land_loot_pack_id", 0); // TODO 1.2 // template.BuffId = reader.GetUInt32("buff_id", 0); _groups.Add(template.Id, template); } } } _log.Info("Loaded {0} groups", _groups.Count); using (var command = connection.CreateCommand()) { command.CommandText = "SELECT * FROM conflict_zones"; command.Prepare(); using (var reader = new SQLiteWrapperReader(command.ExecuteReader())) { while (reader.Read()) { var zoneGroupId = reader.GetUInt16("zone_group_id"); if (_groups.ContainsKey(zoneGroupId)) { var template = new ZoneConflict(_groups[zoneGroupId]); template.ZoneGroupId = zoneGroupId; for (var i = 0; i < 5; i++) { template.NumKills[i] = reader.GetInt32($"num_kills_{i}"); template.NoKillMin[i] = reader.GetInt32($"no_kill_min_{i}"); } template.ConflictMin = reader.GetInt32("conflict_min"); template.WarMin = reader.GetInt32("war_min"); template.PeaceMin = reader.GetInt32("peace_min"); template.PeaceProtectedFactionId = reader.GetUInt32("peace_protected_faction_id", 0); template.NuiaReturnPointId = reader.GetUInt32("nuia_return_point_id", 0); template.HariharaReturnPointId = reader.GetUInt32("harihara_return_point_id", 0); template.WarTowerDefId = reader.GetUInt32("war_tower_def_id", 0); // TODO 1.2 // template.PeaceTowerDefId = reader.GetUInt32("peace_tower_def_id", 0); _groups[zoneGroupId].Conflict = template; _conflicts.Add(zoneGroupId, template); } else { _log.Warn("ZoneGroupId: {1} doesn't exist for conflict", zoneGroupId); } } } } using (var command = connection.CreateCommand()) { command.CommandText = "SELECT * FROM zone_group_banned_tags"; command.Prepare(); using (var reader = new SQLiteWrapperReader(command.ExecuteReader())) { while (reader.Read()) { var template = new ZoneGroupBannedTag(); template.Id = reader.GetUInt32("id"); template.ZoneGroupId = reader.GetUInt32("zone_group_id"); template.TagId = reader.GetUInt32("tag_id"); // TODO 1.2 // template.BannedPeriodsId = reader.GetUInt32("banned_periods_id"); _groupBannedTags.Add(template.Id, template); } } } _log.Info("Loaded {0} group banned tags", _groupBannedTags.Count); using (var command = connection.CreateCommand()) { command.CommandText = "SELECT * FROM zone_climate_elems"; command.Prepare(); using (var reader = new SQLiteWrapperReader(command.ExecuteReader())) { while (reader.Read()) { var template = new ZoneClimateElem(); template.Id = reader.GetUInt32("id"); template.ZoneClimateId = reader.GetUInt32("zone_climate_id"); template.ClimateId = reader.GetUInt32("climate_id"); _climateElem.Add(template.Id, template); } } } _log.Info("Loaded {0} climate elems", _climateElem.Count); } }
private static ZoneGroup MakeZoneGroup(List<string> zoneGroupStrings) { ZoneGroup newZoneGroup = new ZoneGroup(); Regex semiColonRegex = new Regex(EPlusRegexString.semicolon); Regex nameRegex = new Regex(EPlusRegexString.Name); Regex zoneListNameRegex = new Regex(EPlusRegexString.zoneListName); Regex zoneListMultiplierRegex = new Regex(EPlusRegexString.zoneListMultiplier); try { foreach (string line in zoneGroupStrings) { Match nameMatch = nameRegex.Match(line); if (nameMatch.Success) { string purify = @"(?'ws'\s*)(?'goods'.*)(?'comma',)"; Regex purifyRegex = new Regex(purify); Match pure = purifyRegex.Match(nameMatch.Groups["1"].Value); if (pure.Success) { newZoneGroup.name = pure.Groups["goods"].Value; continue; } } //match the Zone List Name Match zoneListNameMatch = zoneListNameRegex.Match(line); if (zoneListNameMatch.Success) { string purify = @"(?'ws'\s*)(?'goods'.*)(?'comma',)"; Regex purifyRegex = new Regex(purify); Match pure = purifyRegex.Match(zoneListNameMatch.Groups["1"].Value); if (pure.Success) { newZoneGroup.zoneListName = pure.Groups["goods"].Value; continue; } } //match the Zone Multiplier Match zoneListMultiplierMatch = zoneListMultiplierRegex.Match(line); if (zoneListMultiplierMatch.Success) { string purify = @"(?'ws'\s*)(?'goods'.*)(?'semicolon';)"; Regex purifyRegex = new Regex(purify); Match pure = purifyRegex.Match(zoneListMultiplierMatch.Groups["1"].Value); if (pure.Success) { newZoneGroup.zoneListMultiplier = Convert.ToInt32(pure.Groups["goods"].Value); continue; } } } } catch (Exception e) { Console.WriteLine(e.ToString()); } return newZoneGroup; }