private static ConsoleText GetItemConsoleText(IRoomObject roomObject) { return(roomObject switch { ISankaraStone _ => new ConsoleText("S", ConsoleColor.DarkYellow), IDisappearingTrap _ => new ConsoleText("@"), IBoobyTrap _ => new ConsoleText("Ο"), IKey key => new ConsoleText("K", key.Color), IPressurePlate _ => new ConsoleText("T"), IPortal _ => new ConsoleText("Π", ConsoleColor.Magenta), IConveyorBelt conveyorBelt => new ConsoleText( Util.ConvertDirectionConveyorBeltIcon(conveyorBelt.Direction)), _ => new ConsoleText("?") });
public IRoomObject[] Find(Find type) { var ids = Game.js.Invoke <string[]>($"{_ref}.findIds", (int)type); var output = new IRoomObject[ids.Length]; for (int i = 0; i < ids.Length; i++) { switch (type) { case ScreepsSharp.Core.Find.constructionSites: output[i] = new ConstructionSite(ids[i], _js); continue; case ScreepsSharp.Core.Find.structures: case ScreepsSharp.Core.Find.myStructures: output[i] = FromId(ids[i]); continue; case ScreepsSharp.Core.Find.mySpawns: output[i] = new Spawn(ids[i], _js); continue; case ScreepsSharp.Core.Find.sources: output[i] = new Source(ids[i], _js); continue; case ScreepsSharp.Core.Find.creeps: case ScreepsSharp.Core.Find.myCreeps: case ScreepsSharp.Core.Find.hostileCreeps: output[i] = new Creep(ids[i], _js); continue; default: throw new NotImplementedException(type.ToString()); } } return(output); }
public ItemViewModel(IRoomObject roomObject) { _roomObject = roomObject; }
private void RoomCanvas_MouseUp(object sender, MouseButtonEventArgs e) { switch (mChosenButton) { case 0: { //Add wall rectangle System.Windows.Point position = e.GetPosition(RoomCanvas); AddMarker(position); Point leftTop = new Point((position.X-mXDrawOffset)/pixelPerMeter, (position.Y-mYDrawOffset)/pixelPerMeter); RoomCanvas.MouseUp -= RoomCanvas_MouseUp; MouseButtonEventHandler roomCanvasRectDraw = null; roomCanvasRectDraw=(sndr, earg) => { mMarkers.Remove(mMarkers.Last()); RoomCanvas.MouseUp-=roomCanvasRectDraw; RoomCanvas.MouseUp += RoomCanvas_MouseUp; position = earg.GetPosition(RoomCanvas); Point bottomRight = new Point((position.X - mXDrawOffset) / pixelPerMeter, (position.Y - mYDrawOffset) / pixelPerMeter); if (Geometry.Distance(leftTop, bottomRight) < 0.25) { mMarkers.Clear(); DrawRoom(); return; } Point topRight = new Point(bottomRight.X,leftTop.Y); Point bottomLeft = new Point(leftTop.X,bottomRight.Y); mUndoElements.Add(mRoom.AddWall(new Wall(leftTop,topRight,Wall.MaterialPreset.OakWood))); mUndoElements.Add(mRoom.AddWall(new Wall(topRight, bottomRight, Wall.MaterialPreset.OakWood))); mUndoElements.Add(mRoom.AddWall(new Wall(bottomRight, bottomLeft, Wall.MaterialPreset.OakWood))); mUndoElements.Add(mRoom.AddWall(new Wall(leftTop, bottomLeft, Wall.MaterialPreset.OakWood))); UndoMenuItem.IsEnabled = true; DrawRoom(); }; mCanvasMousehandlers.Add(roomCanvasRectDraw); RoomCanvas.MouseUp += roomCanvasRectDraw; break; } case 1: { //Add wall System.Windows.Point position = e.GetPosition(RoomCanvas); AddMarker(position); Point first = new Point((position.X-mXDrawOffset) / pixelPerMeter, (position.Y - mYDrawOffset) / pixelPerMeter); //Magneting foreach (Wall wall in mRoom.Walls) { if (Geometry.Distance(wall.Start, first) < closeDistance) { first = wall.Start; break; } if (Geometry.Distance(wall.End, first) < closeDistance) { first = wall.End; break; } } RoomCanvas.MouseUp -= RoomCanvas_MouseUp; MouseButtonEventHandler roomCanvasLineDraw = null; roomCanvasLineDraw = (sndr, earg) => { mMarkers.Remove(mMarkers.Last()); RoomCanvas.MouseUp -= roomCanvasLineDraw; RoomCanvas.MouseUp+=RoomCanvas_MouseUp; position = earg.GetPosition(RoomCanvas); Point second = new Point((position.X-mXDrawOffset) / pixelPerMeter, (position.Y - mYDrawOffset) / pixelPerMeter); if (Geometry.Distance(first, second) < closeDistance) { mMarkers.Clear(); DrawRoom(); return; } //Magneting foreach (Wall wall in mRoom.Walls) { if (Geometry.Distance(wall.Start, second) < closeDistance) { second = wall.Start; break; } if (Geometry.Distance(wall.End, second) < closeDistance) { second = wall.End; break; } } mUndoElements.Add(mRoom.AddWall(new Wall(first,second,Wall.MaterialPreset.OakWood))); UndoMenuItem.IsEnabled = true; DrawRoom(); }; mCanvasMousehandlers.Add(roomCanvasLineDraw); RoomCanvas.MouseUp += roomCanvasLineDraw; break; } case 2: { //Add source System.Windows.Point position = e.GetPosition(RoomCanvas); SoundPoint point = new SoundPoint((position.X-mXDrawOffset)/pixelPerMeter, (position.Y-mYDrawOffset)/pixelPerMeter); if (mBaseSound != null) { point.Sound = mBaseSound; } mUndoElements.Add(point); mRoom.AddSource(point); break; } case 3: { //Add listener System.Windows.Point position = e.GetPosition(RoomCanvas); ListenerPoint point = new ListenerPoint((position.X-mXDrawOffset) / pixelPerMeter, (position.Y-mYDrawOffset) / pixelPerMeter); mUndoElements.Add(point); mRoom.AddListener(point); break; } case 4: { break; } default: { //Select element System.Windows.Point position = e.GetPosition(RoomCanvas); Point point = new Point((position.X-mXDrawOffset) / pixelPerMeter, (position.Y-mYDrawOffset) / pixelPerMeter); mSelectedRoomObject = SelectObject(point); if (mSelectedRoomObject == null) { ((TextBlock) PropsPanel.Children[0]).Text = "Properties"; PropsPanel.Children.RemoveRange(1,PropsPanel.Children.Count-1); mSelectedRoomObject = null; DrawRoom(); return; } if (mSelectedRoomObject is Wall) { Wall wall = mSelectedRoomObject as Wall; UpdateWallProps(wall); } else if (mSelectedRoomObject is ListenerPoint) { ListenerPoint listener = mSelectedRoomObject as ListenerPoint; UpdateListenerProps(listener); } else if (mSelectedRoomObject is SoundPoint) { SoundPoint source = mSelectedRoomObject as SoundPoint; UpdateSourceProps(source); } break; } } DrawRoom(); }
public Result Attack(IRoomObject target) { return((Result)_js.InvokeById <int>(id, "_attack", target.id)); }
public void AddRoomObject(IRoomObject roomObject) { RoomObjects.Add(roomObject); }
protected BoobyTrap(IRoomObject decorator, int damage) : base( new DamageEntityObjectDecorator(decorator, damage)) { }
public PushEntityObjectDecorator(IRoomObject decorator, Direction direction) : base(decorator) { _direction = direction; }
public Wearable(IRoomObject decorator, IRoom room) : base(decorator) { _room = room; }
private void ApplyRoomPresetButton_Click(object sender, RoutedEventArgs e) { Room.RoomPreset preset; if (!Enum.TryParse(RoomPresetBox.SelectedItem.ToString(), out preset)) return; mRoom = Room.CreatePresetRoom(preset); mXDrawOffset = 0; mYDrawOffset = 0; ((TextBlock)PropsPanel.Children[0]).Text = "Properties"; PropsPanel.Children.RemoveRange(1, PropsPanel.Children.Count - 1); mSelectedRoomObject = null; mMarkers.Clear(); foreach (MouseButtonEventHandler handler in mCanvasMousehandlers) { RoomCanvas.MouseUp -= handler; } RoomCanvas.MouseUp -= RoomCanvas_MouseUp; RoomCanvas.MouseUp += RoomCanvas_MouseUp; DrawRoom(); }
private void UpdateListenerProps(ListenerPoint listener) { PropsPanel.Children.Clear(); TextBlock name = new TextBlock { FontSize = 20, Text = "LISTENER", TextAlignment = TextAlignment.Center, Width = rightPanelWidth }; PropsPanel.Children.Add(name); TextBlock location = new TextBlock { FontSize = 14, Text = "Location", Width = rightPanelWidth, TextAlignment = TextAlignment.Center }; PropsPanel.Children.Add(location); StackPanel locationPanel = new StackPanel { Orientation = Orientation.Horizontal, Width = rightPanelWidth }; TextBlock xblock = new TextBlock { FontSize = 10, Text = "X: ", Margin = new Thickness(5, 5, 5, 0) }; locationPanel.Children.Add(xblock); TextBox xbox = new TextBox{ FontSize = 10, Text = listener.X + "", Width = numFieldWidth, TextAlignment = TextAlignment.Left }; locationPanel.Children.Add(xbox); TextBlock yblock = new TextBlock { FontSize = 10, Text = "Y: ", Margin = new Thickness(5, 5, 5, 0) }; locationPanel.Children.Add(yblock); TextBox ybox = new TextBox{ FontSize = 10, Text = listener.Y + "", Width = numFieldWidth, TextAlignment = TextAlignment.Left }; locationPanel.Children.Add(ybox); PropsPanel.Children.Add(locationPanel); StackPanel altitudePanel = new StackPanel {Orientation = Orientation.Horizontal, Width = rightPanelWidth}; TextBlock altitudeBlock = new TextBlock{FontSize = 10, Text = "Altitude: ",Margin = new Thickness(5,5,5,0)}; TextBox altitudeBox = new TextBox { FontSize = 10, Text = listener.Altitude + "", Width = numFieldWidth, TextAlignment = TextAlignment.Left, Margin = new Thickness(5, 5, 5, 0) }; altitudePanel.Children.Add(altitudeBlock); altitudePanel.Children.Add(altitudeBox); PropsPanel.Children.Add(altitudePanel); StackPanel channelPanel = new StackPanel {Orientation = Orientation.Horizontal, Width = rightPanelWidth}; TextBlock channelBlock = new TextBlock{FontSize = 14, Text = "Channel",Margin = new Thickness(5,5,5,0)}; ComboBox channelBox = new ComboBox{Margin = new Thickness(5,5,5,5)}; channelBox.ItemsSource = Enum.GetValues(typeof(Sound.Channel)); channelBox.SelectedItem = listener.Channel; channelPanel.Children.Add(channelBlock); channelPanel.Children.Add(channelBox); PropsPanel.Children.Add(channelPanel); CheckBox directional = new CheckBox{Width = rightPanelWidth, Content = "Directional", IsChecked = listener.Directional}; PropsPanel.Children.Add(directional); TextBox xdirbox = null; TextBox ydirbox = null; if (listener.Directional) { TextBlock direction = new TextBlock { FontSize = 14, Text = "Direction vector", Width = rightPanelWidth, TextAlignment = TextAlignment.Center }; PropsPanel.Children.Add(direction); StackPanel directionPanel = new StackPanel { Orientation = Orientation.Horizontal, Width = rightPanelWidth }; TextBlock xdirblock = new TextBlock { FontSize = 10, Text = "X: ", Margin = new Thickness(5, 5, 5, 0) }; directionPanel.Children.Add(xdirblock); xdirbox = new TextBox { FontSize = 10, Text = listener.DirectionX + "", Width = numFieldWidth, TextAlignment = TextAlignment.Left }; directionPanel.Children.Add(xdirbox); TextBlock ydirblock = new TextBlock { FontSize = 10, Text = "Y: ", Margin = new Thickness(5, 5, 5, 0) }; directionPanel.Children.Add(ydirblock); ydirbox = new TextBox { FontSize = 10, Text = listener.DirectionY + "", Width = numFieldWidth, TextAlignment = TextAlignment.Left }; directionPanel.Children.Add(ydirbox); PropsPanel.Children.Add(directionPanel); } channelBox.SelectionChanged += (sender, args) => { if (listener.Channel != (Sound.Channel)channelBox.SelectedItem && mRoom.Listeners.Any(x => x.Channel == (Sound.Channel)channelBox.SelectedItem)) { ListenerPoint another = mRoom.Listeners.Find(x => x.Channel == (Sound.Channel) channelBox.SelectedItem); another.Channel = listener.Channel; } listener.Channel = (Sound.Channel) channelBox.SelectedItem; }; directional.Checked += delegate { for (int i = 0; i < mRoom.Listeners.Count; i++) { if (mRoom.Listeners[i] == listener) { mRoom.Listeners[i]=new ListenerPoint(listener,new Line(0,0,1,1),ListenerPoint.Cardioid ); mSelectedRoomObject = mRoom.Listeners[i]; DrawRoom(); UpdateListenerProps(mRoom.Listeners[i]); return; } } }; directional.Unchecked += delegate { for (int i = 0; i < mRoom.Listeners.Count; i++) { if (mRoom.Listeners[i] == listener) { mRoom.Listeners[i] = new ListenerPoint(listener); mSelectedRoomObject = mRoom.Listeners[i]; DrawRoom(); UpdateListenerProps(mRoom.Listeners[i]); } } }; xbox.TextChanged += delegate { double newValue; if (!double.TryParse(xbox.Text, out newValue)) return; for (int i = 0; i < mRoom.Listeners.Count; i++) { if (mRoom.Listeners[i] == (ListenerPoint)mSelectedRoomObject) { mRoom.Listeners[i].X = newValue; DrawRoom(); return; } } }; xbox.LostFocus += delegate { var listenerPoint = mSelectedRoomObject as ListenerPoint; if (listenerPoint != null) xbox.Text = listenerPoint.X+""; }; ybox.TextChanged += delegate { double newValue; if (!double.TryParse(ybox.Text, out newValue)) return; for (int i = 0; i < mRoom.Listeners.Count; i++) { if (mRoom.Listeners[i] == (ListenerPoint)mSelectedRoomObject) { mRoom.Listeners[i].Y = newValue; DrawRoom(); return; } } }; ybox.LostFocus += delegate { var listenerPoint = mSelectedRoomObject as ListenerPoint; if (listenerPoint != null) ybox.Text = listenerPoint.Y + ""; }; altitudeBox.TextChanged += delegate { double newValue; if (!double.TryParse(altitudeBox.Text, out newValue)) return; for (int i = 0; i < mRoom.Listeners.Count; i++) { if (mRoom.Listeners[i] == (ListenerPoint)mSelectedRoomObject) { mRoom.Listeners[i].Altitude = newValue; DrawRoom(); return; } } }; altitudeBox.LostFocus += delegate { var listenerPoint = mSelectedRoomObject as ListenerPoint; if (listenerPoint != null) altitudeBox.Text = listenerPoint.Altitude + ""; }; if (xdirbox != null) { xdirbox.TextChanged += delegate { double newValue; if (!double.TryParse(xdirbox.Text, out newValue)) return; for (int i = 0; i < mRoom.Listeners.Count; i++) { if (mRoom.Listeners[i] == (ListenerPoint) mSelectedRoomObject) { mRoom.Listeners[i].DirectionX = newValue; DrawRoom(); return; } } }; xdirbox.LostFocus += delegate { var listenerPoint = mSelectedRoomObject as ListenerPoint; if (listenerPoint != null) xdirbox.Text = listenerPoint.DirectionX + ""; }; } if (ydirbox != null) { ydirbox.TextChanged += delegate { double newValue; if (!double.TryParse(ydirbox.Text, out newValue)) return; for (int i = 0; i < mRoom.Listeners.Count; i++) { if (mRoom.Listeners[i] == (ListenerPoint)mSelectedRoomObject) { mRoom.Listeners[i].DirectionY = newValue; DrawRoom(); return; } } }; ydirbox.LostFocus += delegate { var listenerPoint = mSelectedRoomObject as ListenerPoint; if (listenerPoint != null) ydirbox.Text = listenerPoint.DirectionY + ""; }; } Button deleteButton = new Button { Content = "Delete listener", HorizontalAlignment = HorizontalAlignment.Center, Margin = new Thickness(10, 10, 10, 10) }; PropsPanel.Children.Add(deleteButton); deleteButton.Click += delegate { ((TextBlock)PropsPanel.Children[0]).Text = "Properties"; PropsPanel.Children.RemoveRange(1, PropsPanel.Children.Count - 1); mRoom.RemoveListener(mSelectedRoomObject as ListenerPoint); mSelectedRoomObject = null; DrawRoom(); }; }
private void ToolButtonToggled(object sender, RoutedEventArgs e) { ((TextBlock) PropsPanel.Children[0]).Text = "Properties"; PropsPanel.Children.RemoveRange(1, PropsPanel.Children.Count - 1); mSelectedRoomObject = null; int chosen = -1; mMarkers.Clear(); DrawRoom(); foreach (MouseButtonEventHandler handler in mCanvasMousehandlers) { RoomCanvas.MouseUp -= handler; } if (RectButton.IsEnabled) { RoomCanvas.MouseUp -= RoomCanvas_MouseUp; RoomCanvas.MouseUp += RoomCanvas_MouseUp; } for (int i = 0; i < buttonNumber; i++) { if (mToolButtons[i] == sender) { chosen = i; } else { mToolButtons[i].IsChecked = false; } mChosenButton = chosen; } }
public OnlyForPlayObjectDecorator(IRoomObject decorator) : base(decorator) { }
public DamageEntityObjectDecorator(IRoomObject decorator, int damage) : base(decorator) { _damage = damage; }
public Result Repair(IRoomObject target) { return((Result)_js.InvokeById <int>(id, "_repair", target.id)); }
private void UpdateProps(IRoomObject obj) { if (obj is Wall) { UpdateWallProps((Wall)obj); } else if (obj is ListenerPoint) { UpdateListenerProps((ListenerPoint) obj); } else if(obj is SoundPoint) { UpdateSourceProps((SoundPoint)obj); } }
private void UpdateSourceProps(SoundPoint source) { PropsPanel.Children.Clear(); TextBlock name = new TextBlock { FontSize = 20, Text = "SOURCE", TextAlignment = TextAlignment.Center, Width = rightPanelWidth }; PropsPanel.Children.Add(name); TextBlock location = new TextBlock { FontSize = 14, Text = "Location", Width = rightPanelWidth, TextAlignment = TextAlignment.Center }; PropsPanel.Children.Add(location); StackPanel locationPanel = new StackPanel { Orientation = Orientation.Horizontal, Width = rightPanelWidth }; TextBlock xblock = new TextBlock { FontSize = 10, Text = "X: ", Margin = new Thickness(5, 5, 5, 0) }; locationPanel.Children.Add(xblock); TextBox xbox = new TextBox { FontSize = 10, Text = source.X + "", Width = numFieldWidth, TextAlignment = TextAlignment.Left }; locationPanel.Children.Add(xbox); TextBlock yblock = new TextBlock { FontSize = 10, Text = "Y: ", Margin = new Thickness(5, 5, 5, 0) }; locationPanel.Children.Add(yblock); TextBox ybox = new TextBox { FontSize = 10, Text = source.Y + "", Width = numFieldWidth, TextAlignment = TextAlignment.Left }; locationPanel.Children.Add(ybox); PropsPanel.Children.Add(locationPanel); StackPanel altitudePanel = new StackPanel { Orientation = Orientation.Horizontal, Width = rightPanelWidth }; TextBlock altitudeBlock = new TextBlock { FontSize = 10, Text = "Altitude: ", Margin = new Thickness(5, 5, 5, 0) }; TextBox altitudeBox = new TextBox { FontSize = 10, Text = source.Altitude + "", Width = numFieldWidth, TextAlignment = TextAlignment.Left, Margin = new Thickness(5, 5, 5, 0) }; altitudePanel.Children.Add(altitudeBlock); altitudePanel.Children.Add(altitudeBox); PropsPanel.Children.Add(altitudePanel); Button deleteButton = new Button { Content = "Delete source", HorizontalAlignment = HorizontalAlignment.Center, Margin = new Thickness(10, 10, 10, 10) }; PropsPanel.Children.Add(deleteButton); xbox.TextChanged += delegate { double newValue; if (!double.TryParse(xbox.Text, out newValue)) return; for (int i = 0; i < mRoom.Sources.Count; i++) { if (mRoom.Sources[i] == (SoundPoint)mSelectedRoomObject) { mRoom.Sources[i].X = newValue; DrawRoom(); return; } } }; xbox.LostFocus += delegate { var sourcePoint = mSelectedRoomObject as SoundPoint; if (sourcePoint != null) xbox.Text = sourcePoint.X + ""; }; ybox.TextChanged += delegate { double newValue; if (!double.TryParse(ybox.Text, out newValue)) return; for (int i = 0; i < mRoom.Sources.Count; i++) { if (mRoom.Sources[i] == (SoundPoint)mSelectedRoomObject) { mRoom.Sources[i].Y = newValue; DrawRoom(); return; } } }; ybox.LostFocus += delegate { var sourcePoint = mSelectedRoomObject as SoundPoint; if (sourcePoint != null) ybox.Text = sourcePoint.Y + ""; }; altitudeBox.TextChanged += delegate { double newValue; if (!double.TryParse(altitudeBox.Text, out newValue)) return; for (int i = 0; i < mRoom.Sources.Count; i++) { if (mRoom.Sources[i] == (SoundPoint)mSelectedRoomObject) { mRoom.Sources[i].Altitude = newValue; DrawRoom(); return; } } }; altitudeBox.LostFocus += delegate { var sourcePoint = mSelectedRoomObject as SoundPoint; if (sourcePoint != null) altitudeBox.Text = sourcePoint.Altitude + ""; }; deleteButton.Click += delegate { ((TextBlock)PropsPanel.Children[0]).Text = "Properties"; PropsPanel.Children.RemoveRange(1, PropsPanel.Children.Count - 1); mRoom.RemoveSource(mSelectedRoomObject as SoundPoint); mSelectedRoomObject = null; DrawRoom(); }; }
public TeleportEntityObjectDecorator(IRoomObject decorator, ILocation destination) : base(decorator) { _destination = destination; }
private void UpdateWallProps(Wall wall) { PropsPanel.Children.Clear(); TextBlock name = new TextBlock { FontSize = 20, Text = "WALL", TextAlignment = TextAlignment.Center, Width = rightPanelWidth }; PropsPanel.Children.Add(name); TextBlock material = new TextBlock { FontSize = 14, Text = "Material", Width = rightPanelWidth, TextAlignment = TextAlignment.Center }; PropsPanel.Children.Add(material); ComboBox materialBox = new ComboBox {Width = 180}; //materialBox.Items.Add(Wall.MaterialPreset.Brick); //materialBox.Items.Add(Wall.MaterialPreset.Glass); //materialBox.Items.Add(Wall.MaterialPreset.Granite); //materialBox.Items.Add(Wall.MaterialPreset.OakWood); //materialBox.Items.Add(Wall.MaterialPreset.Rubber); //materialBox.Items.Add(Wall.MaterialPreset.None); materialBox.ItemsSource = Enum.GetValues(typeof (Wall.MaterialPreset)); materialBox.SelectedItem = wall.MatPreset; PropsPanel.Children.Add(materialBox); TextBlock matParams = new TextBlock { FontSize = 14, Text = "Material paramaters", Width = rightPanelWidth, TextAlignment = TextAlignment.Center }; PropsPanel.Children.Add(matParams); TextBlock density = new TextBlock { FontSize = 10, Text = "Density", Width = rightPanelWidth, TextAlignment = TextAlignment.Left }; PropsPanel.Children.Add(density); TextBox densityBox = new TextBox { FontSize = 10, Text = wall.WallMaterial.Density + "", Width = rightPanelWidth, TextAlignment = TextAlignment.Left }; PropsPanel.Children.Add(densityBox); TextBlock soundspeed = new TextBlock { FontSize = 10, Text = "Speed of sound", Width = rightPanelWidth, TextAlignment = TextAlignment.Left }; PropsPanel.Children.Add(soundspeed); TextBox soundspeedBox = new TextBox { FontSize = 10, Text = wall.WallMaterial.SoundSpeed + "", Width = rightPanelWidth, TextAlignment = TextAlignment.Left }; PropsPanel.Children.Add(soundspeedBox); TextBlock location = new TextBlock { FontSize = 14, Text = "Location", Width = rightPanelWidth, TextAlignment = TextAlignment.Center }; PropsPanel.Children.Add(location); TextBlock beginning = new TextBlock { FontSize = 10, Text = "First point", Width = rightPanelWidth, TextAlignment = TextAlignment.Left }; PropsPanel.Children.Add(beginning); StackPanel firstPanel = new StackPanel{Orientation = Orientation.Horizontal, Width = rightPanelWidth}; TextBlock xbegblock = new TextBlock{FontSize = 10, Text = "X: ",Margin = new Thickness(5,5,5,0)}; firstPanel.Children.Add(xbegblock); TextBox xbegbox = new TextBox{ FontSize = 10, Text = wall.Start.X+"",Width=numFieldWidth,TextAlignment = TextAlignment.Left}; firstPanel.Children.Add(xbegbox); TextBlock ybegblock = new TextBlock { FontSize = 10, Text = "Y: ", Margin = new Thickness(5, 5, 5, 0) }; firstPanel.Children.Add(ybegblock); TextBox ybegbox = new TextBox { FontSize = 10, Text = wall.Start.Y + "", Width = numFieldWidth, TextAlignment = TextAlignment.Left }; firstPanel.Children.Add(ybegbox); PropsPanel.Children.Add(firstPanel); TextBlock ending = new TextBlock { FontSize = 10, Text = "Second point", Width = rightPanelWidth, TextAlignment = TextAlignment.Left }; PropsPanel.Children.Add(ending); StackPanel secondPanel = new StackPanel { Orientation = Orientation.Horizontal, Width = rightPanelWidth }; TextBlock xendblock = new TextBlock { FontSize = 10, Text = "X: ", Margin = new Thickness(5, 5, 5, 0) }; secondPanel.Children.Add(xendblock); TextBox xendbox = new TextBox { FontSize = 10, Text = wall.End.X + "", Width = numFieldWidth, TextAlignment = TextAlignment.Left }; secondPanel.Children.Add(xendbox); TextBlock yendblock = new TextBlock { FontSize = 10, Text = "Y: ", Margin = new Thickness(5, 5, 5, 0) }; secondPanel.Children.Add(yendblock); TextBox yendbox = new TextBox{ FontSize = 10, Text = wall.End.Y + "", Width = numFieldWidth, TextAlignment = TextAlignment.Left }; secondPanel.Children.Add(yendbox); PropsPanel.Children.Add(secondPanel); TextBlock filtering = new TextBlock { FontSize = 14, Text = "Level of filtering by frequency", Width = rightPanelWidth, TextAlignment = TextAlignment.Center }; PropsPanel.Children.Add(filtering); StackPanel freqPanel = new StackPanel{Orientation = Orientation.Horizontal,Width = rightPanelWidth}; TextBlock lowBlock = new TextBlock {FontSize = 10, Text = "LOW: ", Margin = new Thickness(5, 5, 5, 0)}; TextBox lowBox = new TextBox{FontSize = 10,Text = wall.WallMaterial.Low+"",Width = numFieldWidth,TextAlignment = TextAlignment.Left}; freqPanel.Children.Add(lowBlock); freqPanel.Children.Add(lowBox); TextBlock medBlock = new TextBlock { FontSize = 10, Text = "MED: ", Margin = new Thickness(5, 5, 5, 0) }; TextBox medBox = new TextBox { FontSize = 10, Text = wall.WallMaterial.Medium + "", Width = numFieldWidth, TextAlignment = TextAlignment.Left }; freqPanel.Children.Add(medBlock); freqPanel.Children.Add(medBox); TextBlock highBlock = new TextBlock { FontSize = 10, Text = "HIGH: ", Margin = new Thickness(5, 5, 5, 0) }; TextBox highBox = new TextBox { FontSize = 10, Text = wall.WallMaterial.High + "", Width = numFieldWidth, TextAlignment = TextAlignment.Left }; freqPanel.Children.Add(highBlock); freqPanel.Children.Add(highBox); PropsPanel.Children.Add(freqPanel); Button deleteButton = new Button{Content = "Delete wall", HorizontalAlignment = HorizontalAlignment.Center,Margin = new Thickness(10,10,10,10)}; PropsPanel.Children.Add(deleteButton); deleteButton.Click += delegate { ((TextBlock) PropsPanel.Children[0]).Text = "Properties"; PropsPanel.Children.RemoveRange(1, PropsPanel.Children.Count - 1); mRoom.RemoveWall(mSelectedRoomObject as Wall); mSelectedRoomObject = null; DrawRoom(); }; materialBox.SelectionChanged += delegate { for (int i = 0; i < mRoom.Walls.Count; i++) { if (mRoom.Walls[i] == wall) { if ((Wall.MaterialPreset) materialBox.SelectedItem == Wall.MaterialPreset.None) { mRoom.Walls[i].MatPreset = Wall.MaterialPreset.None; return; } mRoom.Walls[i] = new Wall(wall.Start, wall.End, (Wall.MaterialPreset) materialBox.Items[materialBox.SelectedIndex]); mSelectedRoomObject = mRoom.Walls[i]; UpdateWallProps(mSelectedRoomObject as Wall); } } }; densityBox.TextChanged += delegate { double newValue; if (!double.TryParse(densityBox.Text, out newValue) || newValue<0) return; wall.WallMaterial.Density = newValue; wall.MatPreset = Wall.MaterialPreset.None; materialBox.SelectedItem = Wall.MaterialPreset.None; }; densityBox.LostFocus += delegate { var wall1 = mSelectedRoomObject as Wall; if (wall1 != null) densityBox.Text = wall1.WallMaterial.Density+""; }; soundspeedBox.TextChanged += delegate { double newValue; if (!double.TryParse(soundspeedBox.Text, out newValue) || newValue<0) return; wall.WallMaterial.SoundSpeed = newValue; wall.MatPreset = Wall.MaterialPreset.None; materialBox.SelectedItem = Wall.MaterialPreset.None; }; soundspeedBox.LostFocus += delegate { var wall1 = mSelectedRoomObject as Wall; if (wall1 != null) soundspeedBox.Text = wall1.WallMaterial.SoundSpeed + ""; }; lowBox.TextChanged += delegate { double newValue; if (!double.TryParse(lowBox.Text, out newValue) || newValue > 1 || newValue < 0) return; wall.WallMaterial.Low = newValue; wall.MatPreset = Wall.MaterialPreset.None; materialBox.SelectedItem = Wall.MaterialPreset.None; }; lowBox.LostFocus += delegate { var wall1 = mSelectedRoomObject as Wall; if (wall1 != null) lowBox.Text = wall1.WallMaterial.Low + ""; }; medBox.TextChanged += delegate { double newValue; if (!double.TryParse(medBox.Text, out newValue) || newValue > 1 || newValue < 0) return; wall.WallMaterial.Medium = newValue; wall.MatPreset = Wall.MaterialPreset.None; materialBox.SelectedItem = Wall.MaterialPreset.None; }; medBox.LostFocus += delegate { var wall1 = mSelectedRoomObject as Wall; if (wall1 != null) medBox.Text = wall1.WallMaterial.Medium + ""; }; highBox.TextChanged += delegate { double newValue; if (!double.TryParse(highBox.Text, out newValue) || newValue > 1 || newValue < 0) return; wall.WallMaterial.High = newValue; wall.MatPreset = Wall.MaterialPreset.None; materialBox.SelectedItem = Wall.MaterialPreset.None; }; highBox.LostFocus += delegate { var wall1 = mSelectedRoomObject as Wall; if (wall1 != null) highBox.Text = wall1.WallMaterial.High + ""; }; xbegbox.TextChanged += delegate { double newValue; if (!double.TryParse(xbegbox.Text, out newValue)) return; ((Wall) mSelectedRoomObject).Start.X = newValue; DrawRoom(); }; xbegbox.LostFocus += delegate { var wall1 = mSelectedRoomObject as Wall; if (wall1 != null) xbegbox.Text = wall1.Start.X+""; }; ybegbox.TextChanged += delegate { double newValue; if (!double.TryParse(ybegbox.Text, out newValue)) return; ((Wall) mSelectedRoomObject).Start.Y = newValue; DrawRoom(); }; ybegbox.LostFocus += delegate { var wall1 = mSelectedRoomObject as Wall; if (wall1 != null) ybegbox.Text = wall1.Start.Y + ""; }; xendbox.TextChanged += delegate { double newValue; if (!double.TryParse(xendbox.Text, out newValue)) return; ((Wall) mSelectedRoomObject).End.X = newValue; DrawRoom(); }; xendbox.LostFocus += delegate { var wall1 = mSelectedRoomObject as Wall; if (wall1 != null) xendbox.Text = wall1.End.X + ""; }; yendbox.TextChanged += delegate { double newValue; if (!double.TryParse(yendbox.Text, out newValue)) return; ((Wall) mSelectedRoomObject).End.Y = newValue; DrawRoom(); }; yendbox.LostFocus += delegate { var wall1 = mSelectedRoomObject as Wall; if (wall1 != null) yendbox.Text = wall1.End.Y + ""; }; }
protected BaseRoomObjectDecorator(IRoomObject decorator) : base(decorator.X, decorator.Y) { _decorator = decorator; }
private void ClearMenuItem_Click(object sender, RoutedEventArgs e) { ((TextBlock) PropsPanel.Children[0]).Text = "Properties"; PropsPanel.Children.RemoveRange(1, PropsPanel.Children.Count - 1); mRoom = new Room(); mRoom.CeilingHeight = 2; mRoom.CeilingMaterial = Wall.Material.Brick; mRoom.FloorMaterial = Wall.Material.Brick; mSelectedRoomObject = null; mMarkers.Clear(); foreach (MouseButtonEventHandler handler in mCanvasMousehandlers) { RoomCanvas.MouseUp -= handler; } RoomCanvas.MouseUp -= RoomCanvas_MouseUp; RoomCanvas.MouseUp += RoomCanvas_MouseUp; DrawRoom(); }
public ToggleDoorObjectDecorator(IRoomObject decorator, IEnumerable <IConnection> connections) : base(decorator) { _connections = connections; }
private void RecordButton_Click(object sender, RoutedEventArgs e) { if (!mRoom.IsValid()) { MessageBox.Show(this, "Room is invalid, check status bar for further instructions"); return; } try { mReflectionWorker = new BackgroundWorker(); mReflectionWorker.WorkerSupportsCancellation = true; RecordButton.IsEnabled = false; for (int i = 0; i < buttonNumber - 1; i++) { mToolButtons[i].IsChecked = false; mToolButtons[i].IsEnabled = false; } RoomOpenMenuItem.IsEnabled = false; SoundOpenMenuItem.IsEnabled = false; UndoMenuItem.IsEnabled = false; RedoMenuItem.IsEnabled = false; ClearMenuItem.IsEnabled = false; PropsAccItem.IsEnabled = false; PresetsAccItem.IsEnabled = false; CeilingHeightBox.IsEnabled = false; FloorMaterialBox.IsEnabled = false; RefVolumeSlider.IsEnabled = false; RefDepthSlider.IsEnabled = false; CeilingMaterialBox.IsEnabled = false; PlayButton.IsEnabled = false; CancelButton.IsEnabled = true; RoomCanvas.MouseUp -= RoomCanvas_MouseUp; ((TextBlock)PropsPanel.Children[0]).Text = "Properties"; PropsPanel.Children.RemoveRange(1, PropsPanel.Children.Count - 1); mSelectedRoomObject = null; DrawRoom(); SoundProgressBar.Visibility = Visibility.Visible; SoundProgressBar.Value = 0; SoundProgressBar.Maximum = mRoom.Sources.Count*mRoom.Listeners.Count*(mRoom.Walls.Count*2+1)+2; mReflectionWorker.WorkerReportsProgress = true; int num = 0; EventHandler reporter= delegate { mReflectionWorker.ReportProgress(num++); }; mRoom.CalculationProgress += reporter; mReflectionWorker.DoWork += delegate { try { mRoom.CalculateSound(mReflectedVolume); } catch (Exception ex) { Dispatcher.Invoke((Action) delegate { if (CancelButton.IsEnabled) { MessageBox.Show(this, "Error occurred during recording process: " + ex.Message); throw ex; } }); } }; mReflectionWorker.RunWorkerCompleted += delegate { if (!CancelButton.IsEnabled) return; CancelButton.IsEnabled = false; mResultSound = mRoom.GetSoundFromListeners(); mResultSound.AdjustVolume(0.75); if (!mReflectionWorker.CancellationPending) { SoundSaveMenuItem.IsEnabled = true; PlayButton.IsEnabled = true; } RecordButton.IsEnabled = true; mRoom.CalculationProgress -= reporter; SoundProgressBar.Visibility = Visibility.Hidden; for (int i = 0; i<buttonNumber-1;i++) { mToolButtons[i].IsEnabled = true; } RoomOpenMenuItem.IsEnabled = true; SoundOpenMenuItem.IsEnabled = true; UndoMenuItem.IsEnabled = true; RedoMenuItem.IsEnabled = true; ClearMenuItem.IsEnabled = true; PropsAccItem.IsEnabled = true; PresetsAccItem.IsEnabled = true; CeilingHeightBox.IsEnabled = true; FloorMaterialBox.IsEnabled = true; RefVolumeSlider.IsEnabled = true; RefDepthSlider.IsEnabled = true; CeilingMaterialBox.IsEnabled = true; RoomCanvas.MouseUp+=RoomCanvas_MouseUp; StatusBlock.Foreground=Brushes.DarkGreen; StatusBlock.Text = mReflectionWorker.CancellationPending?"Recording cancelled":"Recording successfully finished"; }; mReflectionWorker.ProgressChanged += (obj,args)=> { SoundProgressBar.Value++; }; mReflectionWorker.RunWorkerAsync(); } catch (Exception exception) { MessageBox.Show(this, "Error occurred during recording process: " + exception.Message); } }
public void RemoveRoomObject(IRoomObject roomObject) { RoomObjects.Remove(roomObject); }
public Result MoveTo(IRoomObject target, int reusePath = 5, bool serializeMemory = true, bool noPathFinding = false) { return (Result)_js.InvokeById<int>(id, "_moveTo", target.id); }