private OrderSchemeClass GetOrderSheme() { var stantion = new Station(); var freePair = this.OrderSchemePairs.FirstOrDefault(s => s.IsFree); if (freePair == null) { var wave1 = GetRandomWave(0); var wave2 = GetRandomWave(wave1); var privateName1 = GetRandomPrivateName(0); var privateName2 = GetRandomPrivateName(privateName1); freePair = new OrderSchemePair(wave1, wave2, CircularName, CircularPrivateName, privateName1, privateName2); this.OrderSchemePairs.Add(freePair); } freePair.AddStation(stantion); return(freePair.GetOrderSchemeByStation(stantion)); }
private string getConnectionCondition(OrderSchemePair pair) { return("Подключение активно"); }
private void DrawPair(OrderSchemePair pair) { var panelHeight = 150; var stationFontSize = 10; var stationWidth = 100; StackPanel sp = new StackPanel() { Height = panelHeight, Orientation = Orientation.Horizontal, Margin = new Thickness(10) }; sp.SetValue(WidthProperty, list.Width); list.Items.Add(sp); Button station1 = new Button() { Content = getStationString(pair.Station1, pair.orderScheme1), FontSize = stationFontSize, Width = stationWidth }; TextBlock station1Chanel = new TextBlock() { Text = getStationChanelString(pair.Station1, pair.orderScheme1), FontSize = stationFontSize, Width = stationWidth }; sp.Children.Add(station1Chanel); sp.Children.Add(station1); Brush br = Brushes.DarkGray; Label connectConditionLabel = new Label() { HorizontalAlignment = HorizontalAlignment.Center }; if (pair.Station1 != null && pair.Station1.Signal != null && pair.Station2 != null && pair.Station2.Signal != null) { connectConditionLabel.Content = getConnectionCondition(pair); br = Brushes.LightGreen; } else { connectConditionLabel.Content = "Соединение отсутствует"; } Line line = new Line() { X1 = 0, X2 = 160, Y1 = 20, Y2 = 20, Width = 160, StrokeThickness = 10, Stroke = br, StrokeDashArray = { 0.5, 0.5 }, StrokeDashOffset = 1, StrokeMiterLimit = 1, StrokeDashCap = PenLineCap.Triangle }; StackPanel spToConnection = new StackPanel() { Height = panelHeight, Orientation = Orientation.Vertical }; spToConnection.Children.Add(connectConditionLabel); spToConnection.Children.Add(line); sp.Children.Add(spToConnection); string station2Content = "Пусто"; if (!pair.isStation2Empty) { station2Content = pair.orderScheme2.ИндивидуальныйПозывной.ToString(); } Button station2 = new Button() { Content = getStationString(pair.Station2, pair.orderScheme2), FontSize = stationFontSize, Width = stationWidth }; TextBlock station2Chanel = new TextBlock() { Text = getStationChanelString(pair.Station2, pair.orderScheme2), FontSize = stationFontSize, Width = stationWidth }; sp.Children.Add(station2); sp.Children.Add(station2Chanel); }