private void BreakClick(object sender, RoutedEventArgs e) { if (!(ConnectionList.SelectedItems.Count > 1)) { var union = (ConnectionUnion)ConnectionList.SelectedItem; if (union.Chanels.Count > 1) { var tempunionlist = new List <ConnectionUnion>(); foreach (var chanel in union.Chanels) { var tempunion = new ConnectionUnion(chanel.ConnectionName); tempunion.Chanels.Add(chanel); tempunion.ConnectionType = ConnectionType.Global; tempunionlist.Add(tempunion); } Connections.Remove(union); foreach (var tempUnion in tempunionlist) { Connections.Add(tempUnion); } ConnectionList.ItemsSource = null; ConnectionList.ItemsSource = Connections; } } }
private void MergeClick(object sender, RoutedEventArgs e) { var selected = ConnectionList.SelectedItems; var unions = new List <ConnectionUnion>(); var tempnames = new List <string>(); foreach (ConnectionUnion item in selected) { unions.Add(item); tempnames.Add(item.Name); } if (unions.Count != 1) { var predictedname = TextAnalysis.GetCommonInListOfStrings(tempnames); var tempunion = new ConnectionUnion("new"); var dialog = new Popups.PopupDialog("Введите имя для нового массива.", predictedname); if (dialog.ShowDialog() == true) { tempunion.Name = dialog.ResponseText; } var tempchanellist = new List <Chanel>(); foreach (var union in unions) { foreach (var chanel in union.Chanels) { tempchanellist.Add(chanel); } Connections.Remove(union); } tempunion.Chanels = tempchanellist.OrderBy(x => x.ConnectionName, new AlphanumComparatorFast()).ToList(); Connections.Add(tempunion); ConnectionList.ItemsSource = null; ConnectionList.ItemsSource = Connections; var selectedindex = ConnectionList.SelectedIndex; SelectedUnion.ItemsSource = null; if (selectedindex != -1) { SelectedUnion.ItemsSource = Connections.ElementAt(selectedindex).Chanels; ConnectionList.SelectedIndex = selectedindex; } else { var lastindex = Connections.Count - 1; SelectedUnion.ItemsSource = Connections.ElementAt(lastindex).Chanels; ConnectionList.SelectedIndex = lastindex; } } }
private void BreakChanelFromList(object sender, RoutedEventArgs e) { var selectedchanels = SelectedUnion.SelectedItems; var selectedunion = (ConnectionUnion)ConnectionList.SelectedItem; if (selectedunion.Chanels.Count > 1) { var tempchanellist = new List <Chanel>(); foreach (Chanel item in selectedchanels) { tempchanellist.Add(item); } foreach (var chanel in tempchanellist) { selectedunion.Chanels.Remove(chanel); var tempunion = new ConnectionUnion(chanel.ConnectionName); tempunion.Chanels.Add(chanel); Connections.Add(tempunion); } if (selectedunion.Chanels.Count == 0) { Connections.Remove(selectedunion); } ConnectionList.ItemsSource = null; ConnectionList.ItemsSource = Connections; var selectedindex = ConnectionList.SelectedIndex; SelectedUnion.ItemsSource = null; if (selectedindex != -1) { SelectedUnion.ItemsSource = Connections.ElementAt(selectedindex).Chanels; } else { var lastindex = Connections.Count - 1; SelectedUnion.ItemsSource = Connections.ElementAt(lastindex).Chanels; } } }
public EttFunctions(ConnectionUnion union) { _union = union; InitializationCode = new List <string>(); WorkingRutines = new List <string>(); switch (_union.ConnectionType) { case ConnectionType.Bus: switch (_union.Direction) { case Direction.In: CreateGetBusFunction(); WorkingRutines.AddRange(_getBusFunction.Code); break; case Direction.Out: CreateSetBusFunction(); WorkingRutines.AddRange(_setBusFunction.Code); break; case Direction.Bidir: CreateGetBusFunction(); CreateSetBusFunction(); WorkingRutines.AddRange(_getBusFunction.Code); WorkingRutines.AddRange(_setBusFunction.Code); break; } InitBus(); break; case ConnectionType.Array: switch (_union.Direction) { case Direction.In: CreateGetPinFromArrayFunction(); WorkingRutines.AddRange(_getPinFromArrayFunction.Code); break; case Direction.Out: CreateSetPinInArrayFunction(); CreateClearPinArrayFunction(); WorkingRutines.AddRange(_setPinInArrayFunction.Code); WorkingRutines.AddRange(_clearPinArrayFunction.Code); break; case Direction.Bidir: CreateGetPinFromArrayFunction(); CreateSetPinInArrayFunction(); CreateClearPinArrayFunction(); WorkingRutines.AddRange(_getPinFromArrayFunction.Code); WorkingRutines.AddRange(_setPinInArrayFunction.Code); WorkingRutines.AddRange(_clearPinArrayFunction.Code); break; } InitArray(); break; case ConnectionType.Global: CreateSingleChanel(); InitSingleChanel(); WorkingRutines.Add(_singleChanelInit); break; } }
private string OlegObjectCreator(ConnectionUnion union) { string templine = null; switch (union.ConnectionType) { case ConnectionType.Global: templine = "pin " + union.Name + "(" + union.Chanels.ElementAt(0).ChanelName.Replace("CH", "").Replace(" ", "") + ","; if (union.Direction == Direction.Out) { templine += "OUT, "; if (union.InitialState == InitialState.Low) { templine += "LO"; } else { templine += "HI"; } } else { templine += "INP, LO"; } templine += ");"; break; case ConnectionType.Array: templine = "pins " + union.Name + "("; if (union.Direction == Direction.Out) { templine += "OUT, "; if (union.InitialState == InitialState.Low) { templine += "LO, "; } else { templine += "HI, "; } } else { templine += "INP, LO, "; } templine += union.Chanels.Count + ",\n\t"; var counter = 1; foreach (var chanel in union.Chanels) { templine += chanel.ChanelName.Replace("CH ", ""); if (counter != union.Chanels.Count) { templine += ", "; if (counter % 10 == 0) { templine += "\n \t"; } } else { templine += "\n);\n"; } counter++; } break; case ConnectionType.Bus: templine = "port " + union.Name + "("; if (union.Direction == Direction.Out) { templine += "OUT, "; if (union.InitialState == InitialState.Low) { templine += "LO, "; } else { templine += "HI, "; } } else { templine += "INP, LO, "; } templine += union.Chanels.Count + ",\n\t"; var counter2 = 1; foreach (var chanel in union.Chanels) { templine += chanel.ChanelName.Replace("CH ", ""); if (counter2 != union.Chanels.Count) { templine += ", "; if (counter2 % 10 == 0) { templine += "\n \t"; } } else { templine += "\n);\n"; } counter2++; } break; } return(templine); }