/// <summary> /// Must specify the canvas to draw to on instantiation. /// /// The range and canvas ratio determine the units scaling and size of the display. /// Range is the max range of the radar in whatever unit the vessels are using. /// Canvas ratio is the percentage of the lowest dimension of the ratio to use as the radar pixel radius. /// That pixel radius will then be matched with the desired range in vessel units. /// /// </summary> /// <param name="radarCanvas"></param> /// <param name="range"></param> /// <param name="canvasRatio"></param> public RadarWidget(VesselPresenter presenter, Canvas radarCanvas, double range, double canvasRatio) { canvas = radarCanvas; Range = range; CanvasRatio = canvasRatio; currentVessels = null; vesselPresenter = presenter; vesselPresenter.AddUpdateAction(OnSimulationUpdate); canvas.SizeChanged += OnCanvasSizeChanged; CalculateCanvasProperties(); }
/// <summary> /// Instantiates the table widget. /// </summary> /// <param name="presenter">reference to the vessel presenter</param> /// <param name="tableContainer">container GUI element of the table</param> /// <param name="sortAscendingDisplay">icon to display in column header when sorting ascending</param> /// <param name="sortDescendingDisplay">icon to display in column header when sorting descending</param> public TableWidget(VesselPresenter presenter, ListView tableContainer, DataTemplate sortAscendingDisplay, DataTemplate sortDescendingDisplay) { Debug.Assert(presenter != null && tableContainer != null && sortAscendingDisplay != null && sortDescendingDisplay != null, "TableWidget : null arguments"); // Store arguments sortAscendingArrowDisplay = sortAscendingDisplay; sortDescendingArrowDisplay = sortDescendingDisplay; vesselPresenter = presenter; vesselListContainer = tableContainer; // Link the list view with the filtered vessels list. displayedVessels = new ObservableCollection <Vessel>(); vesselListContainer.ItemsSource = displayedVessels; // Register callback when a column header is clicked to do sorting. vesselListContainer.AddHandler(GridViewColumnHeader.ClickEvent, new RoutedEventHandler(OnColumnHeaderClick)); // Register callback when the simulation updates to refresh our list. vesselPresenter.AddUpdateAction(OnSimulationUpdate); // Register callback when item container status changes to be able to change style colors for alarms. vesselListContainer.ItemContainerGenerator.StatusChanged += new EventHandler(OnItemContainerStatusChanged); }