//constructor public Window_Component(DataPathModel data) { InitializeComponent(); Data = new ComponentViewModel(data); //Creates an instance for the ComponentViewModel this.DataContext = Data; //Sets the DataContext of the this Window to that of the ComponentViewModel //to allow for Binding of the VM properties to the XAML }
/// <summary> /// Automatically populates the Project File TreeView based on the data contained _dataPath /// </summary> public void LoadFileTree(DataPathModel data) { CustomTreeView.Items.Clear(); //Clears all items from the existing TreeView TreeViewData maintv = new TreeViewData(); if (data.Name != null) { TreeViewData tv = new TreeViewData(); maintv.Title = data.Name; //Adds the main tree named after the datapath name } if (data.Components != null) { //TreeViewData tv = new TreeViewData(); //tv.Title = "Components"; //Add section named components foreach (ComponentModel comp in data.Components) { TreeViewData tv1 = new TreeViewData(); tv1.Title = "cop" + comp.ID + ": " + comp.Name; //Add components as children to the section maintv.Items.Add(tv1); } //maintv.Items.Add(tv); } CustomTreeView.Items.Add(maintv); }
private void Btn_Datapath_Click(object sender, RoutedEventArgs e) { Window_Datapath window_Datapath = new Window_Datapath(); List <PointData> datapoints = new List <PointData>(); if (window_Datapath.ShowDialog() == true) { try { _dataPath = window_Datapath.GetDataPathModel; //Gets the DataPath Object from the Datapath menu and passes it to _datapath Btn_Component.IsEnabled = true; //Disables the Datapath button and enables the other buttons Btn_Signal.IsEnabled = false; Btn_Datapath.IsEnabled = false; Btn_Copy_Component.IsEnabled = false; GenerateDatapath(_dataPath); //DataPath Code Generation LoadFileTree(_dataPath); //Loads text into the Project file tree view using info in _dataPath LoadCodeTree(_dataPath); //Loads generated code file names into the tree view using the _newfolderPath Canvas canvas = new Canvas(); canvas = this.DrawingCanvas; datapoints = DrawDatapath(_dataPath, canvas); foreach (PointData data in datapoints) { DataPoints.Add(data); } } catch (Exception) { } } }
private void Btn_Datapath_Click(object sender, RoutedEventArgs e) { Window_Datapath window_Datapath = new Window_Datapath(); if (window_Datapath.ShowDialog() == true) { try { DataPath = window_Datapath.GetDataPathModel; Btn_Component.IsEnabled = true; Btn_Signal.IsEnabled = true; Btn_Datapath.IsEnabled = false; //Datapath File Generation GenerateDatapath(DataPath); LoadDataTree(); LoadFileTree(); ///////////////////////////////////Drawing code //RenderDatapath(DataPath); //////////////////////////////////// } catch (Exception) { } } }
public DataPathTemplate(DataPathModel data) { this.Name = data.Name; this.ArchName = data.ArchName; this.Ports = data.Ports; this.Components = data.Components; this.Signals = data.Signals; }
public bool SignalExist(SignalModel signal, DataPathModel data) { bool result = false; if (signal != null && data.Signals != null) { foreach (SignalModel sig in data.Signals) { bool name = false; bool SComp = false; bool SCompPort = false; bool TComp = false; bool TCompPort = false; if (signal.Name == sig.Name) { name = true; } if (signal.Source_Comp == sig.Source_Comp) { SComp = true; } if (signal.Source_port == sig.Source_port) { SCompPort = true; } if (signal.Target_Comp == sig.Target_Comp) { TComp = true; } if (signal.Target_port == sig.Target_port) { TCompPort = true; } if (signal.Name == null && sig.Name == null) { if (SComp && SCompPort && TComp && TCompPort) { result = true; } else { result = false; } } else if (name || (SComp && SCompPort && TComp && TCompPort)) { result = true; } } } return(result); }
public Window_Signal(DataPathModel _DataPath) { InitializeComponent(); Data = new SignalViewModel(_DataPath); this.DataContext = Data; ////Default setting of the view items //Bus_CB.IsChecked = false; //MSB_TB.IsReadOnly = true; //LSB_TB.IsReadOnly = true; }
/// <summary> /// Automatically populates the Generated Code File TreeView based on what is contained in the Generated Code Folder /// </summary> public void LoadCodeTree(DataPathModel data) { CodeTreeView.Items.Clear(); //Clears all items in the CodeTreeView List <string> PathNames = new List <string>(Directory.GetFiles(_newFolderPath)); //Gets all file names in the Generated Code Folder List <string> FileNames = new List <string>(); FileNames = PathtoName(PathNames); if (data.Name != null) { TreeViewData DataPathtv = new TreeViewData() { Title = "Datapath" }; foreach (string name in FileNames) { if (name == data.Name + ".txt") { TreeViewData tv = new TreeViewData() { Title = name }; DataPathtv.Items.Add(tv); } } TreeViewItem item = new TreeViewItem(); CodeTreeView.Items.Add(DataPathtv); } if (data.Components.Count > 0) { TreeViewData Componenttv = new TreeViewData() { Title = "Components" }; foreach (string name in FileNames) { if (name != data.Name + ".txt" && name.Substring(name.Length - 4) == ".txt") { TreeViewData tv = new TreeViewData() { Title = name }; Componenttv.Items.Add(tv); } } CodeTreeView.Items.Add(Componenttv); } }
public void GenerateComponents(DataPathModel Data) { if (Data.Components != null) { foreach (ComponentModel comp in Data.Components) { ComponentTemplate CompTemplate = new ComponentTemplate(comp); String CompText = CompTemplate.TransformText(); //File.WriteAllText(comp.Name + ".txt", CompText); File.WriteAllText(System.IO.Path.Combine(NewFolderPath, comp.Name + ".txt"), CompText); } } }
/// <summary> /// Generates VHDL Code using a DataPathModel and DataPathTemplate /// </summary> private void GenerateDatapath(DataPathModel Data) { try { if (Data != null && Data.Name != null) { DataPathTemplate DPTemplate = new DataPathTemplate(Data); //Creates an instance of the datapath templates using the Data passed into the function String DPText = DPTemplate.TransformText(); //Generates the code into a string using the DataPath Template file File.WriteAllText(System.IO.Path.Combine(_newFolderPath, Data.Name + ".txt"), DPText); //Combines the folder path and datapath name to create the code file and writes the string to it File.WriteAllText(System.IO.Path.Combine(_newFolderPath, Data.Name + ".vhd"), DPText); //Combines the folder path and datapath name to create the code file and writes the string to it } } catch (Exception) { } }
private List <string> GetNames(DataPathModel data) { List <string> names = new List <string>(); if (data.Components.Count > 0) { foreach (ComponentModel comp in data.Components) { if (!names.Exists(x => x == comp.Name)) { names.Add(comp.Name); } } } return(names); }
//private Point startPoint; //private Rectangle rect; //private bool _loaded; #endregion #region Main Code #region Window Methods public MainWindow() { InitializeComponent(); _dataPath = new DataPathModel(); _debugPath = (string)System.IO.Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location); //Path to the location of the executable CreateFolder(); //Path to the location of the executable moved one folder up _id = 1; Btn_Component.IsEnabled = false; Btn_Signal.IsEnabled = false; Btn_Datapath.IsEnabled = true; Btn_Copy_Component.IsEnabled = false; DataPoints = new List <PointData>(); _mainViewModel = new MainViewModel(); this.DataContext = _mainViewModel; //_loaded = false; }
private void GenerateDatapath(DataPathModel Data) { try { if (Data != null && Data.Name != null) { DataPathTemplate DPTemplate = new DataPathTemplate(Data); String DPText = DPTemplate.TransformText(); //string textpath = Data.Name + ".txt"; //string newpath = System.IO.Path.Combine(NewFolderPath, textpath); File.WriteAllText(System.IO.Path.Combine(NewFolderPath, Data.Name + ".txt"), DPText); //File.WriteAllText(Data.Name + ".txt", DPText); } } catch (Exception) { } }
/// <summary> /// Generates VHDL Code using the ComponentModel List in DataPathModel and ComponentTemplate /// </summary> public void GenerateComponents(DataPathModel Data) { if (Data.Components != null) { List <string> generated = new List <string>(); foreach (ComponentModel comp in Data.Components) //Cycles through all components in data that was passed into the function { if (!generated.Exists(x => x == comp.Name)) { ComponentTemplate CompTemplate = new ComponentTemplate(comp); //Creates an instance of the Component template using the comp passed into the function String CompText = CompTemplate.TransformText(); //Generates the code into a string using the Component Template file File.WriteAllText(System.IO.Path.Combine(_newFolderPath, comp.Name + ".txt"), CompText); //Combines the folder path and comp name to create the code file and writes the string to it File.WriteAllText(System.IO.Path.Combine(_newFolderPath, comp.Name + ".vhd"), CompText); //Combines the folder path and comp name to create the code file and writes the string to it generated.Add(comp.Name); } } } }
private void CopyComponent(string compname, DataPathModel data) { ComponentModel copycomp = new ComponentModel(); int id; if (data.Components.Count > 0) { ComponentModel tempcomp = new ComponentModel(); id = data.Components.Count + 1; tempcomp = data.Components.Find(x => x.Name == compname); copycomp.Name = tempcomp.Name; copycomp.ID = id.ToString(); copycomp.ArchName = tempcomp.ArchName; copycomp.Ports = tempcomp.Ports; Component = copycomp; } }
public ComponentViewModel(DataPathModel data) { _datapath = new DataPathModel(); _datapath = data; Component = new ComponentModel { Ports = new List <PortModel>() }; EditPortCommand = new EditCommand(EditPort); //command stuff DeletePortCommand = new DeleteCommand(DeletePort); ArchNameTxt = "Behavioural"; this._BitsEnable = false; ErrorCollection.Add("MsbTxt", null); ErrorCollection.Add("LsbTxt", null); }
public void DrawSignals(DataPathModel _data, Canvas _canvas, List <PointData> ConnectionPoints) { foreach (SignalModel signal in _data.Signals) { Point ConnectionStart = new Point(); Point ConnectionEnd = new Point(); ConnectionStart = ConnectionPoints.Find(x => x.ComponentID == signal.Source_Comp_ID && x.PortName == signal.Source_port).Point; ConnectionEnd = ConnectionPoints.Find(x => x.ComponentID == signal.Target_Comp_ID && x.PortName == signal.Target_port).Point; Line line = new Line() { X1 = ConnectionStart.X, Y1 = ConnectionStart.Y, X2 = ConnectionEnd.X, Y2 = ConnectionEnd.Y, Stroke = Brushes.DarkMagenta, StrokeThickness = 1 }; _canvas.Children.Add(line); } }
public SignalViewModel(DataPathModel _datapath) { _Datapath = _datapath; }
//constructor that accepts a DatapathModel object to be used in the combo Boxes public Window_Signal(DataPathModel _DataPath) { InitializeComponent(); _Data = new SignalViewModel(_DataPath); //creates an instance of the SignalViewModel and passes the datapath data from the window to the viewmodel this.DataContext = _Data; //Sets the Window DataContext to that of the SignalViewModel to allow for binding }
public CopyCompViewModel(DataPathModel data) { _data = data; }
public Window_CopyComp(DataPathModel data) { InitializeComponent(); model = new CopyCompViewModel(data); this.DataContext = model; }
public List <PointData> DrawComponents(DataPathModel _data, Canvas _canvas) { List <PointData> pointDatas = new List <PointData>(); Point[] StartPoints = new Point[6]; Point StartPoint = new Point(90, 30); StartPoints[0] = new Point(StartPoint.X + 100, StartPoint.Y + 100); for (int i = 1; i < 6; i++) { if (i < 3) { StartPoints[i] = new Point(StartPoints[i - 1].X + 380, StartPoints[i - 1].Y); } else { StartPoints[i] = new Point(StartPoints[i - 3].X, StartPoints[i - 3].Y + 300); } } for (int i = 0; i < _data.Components.Count; i++) { Rectangle Component = new Rectangle() { Stroke = Brushes.Blue, StrokeThickness = 2, Width = 220, Height = 150 }; Canvas.SetTop(Component, StartPoints[i].Y); Canvas.SetLeft(Component, StartPoints[i].X); _canvas.Children.Add(Component); TextBlock ComponentName = new TextBlock() { Text = "cop" + _data.Components[i].ID + ":" + _data.Components[i].Name, FontSize = 20 }; Point NamePoint = new Point(((Component.Width / 2) + StartPoints[i].X) - 50, StartPoints[i].Y - 30); Canvas.SetTop(ComponentName, NamePoint.Y); Canvas.SetLeft(ComponentName, NamePoint.X); _canvas.Children.Add(ComponentName); #region addtion of port labels int counterin = 1; int counterout = 1; foreach (PortModel port in _data.Components[i].Ports) { if (port.Direction == "in") { TextBlock PortName = new TextBlock() { Text = port.Name }; Point PortPoint = new Point(StartPoints[i].X + 5, StartPoints[i].Y + (counterin * 20)); Canvas.SetTop(PortName, PortPoint.Y); Canvas.SetLeft(PortName, PortPoint.X); PortPoint.X = StartPoints[i].X; PointData pointData = new PointData(_data.Components[i].ID, _data.Components[i].Name, port.Name, PortPoint); pointDatas.Add(pointData); _canvas.Children.Add(PortName); counterin++; } else { TextBlock PortName = new TextBlock() { Text = port.Name }; Point PortPoint = new Point(StartPoints[i].X + Component.Width - (PortName.Text.Length * 5) - 10, StartPoints[i].Y + (counterout * 20)); Canvas.SetTop(PortName, PortPoint.Y); Canvas.SetLeft(PortName, PortPoint.X); PortPoint.X = StartPoints[i].X + Component.Width; PointData pointData = new PointData(_data.Components[i].ID, _data.Components[i].Name, port.Name, PortPoint); pointDatas.Add(pointData); _canvas.Children.Add(PortName); counterout++; } } #endregion } return(pointDatas); }
public List <PointData> DrawDatapath(DataPathModel _data, Canvas _canvas) { List <PointData> pointDatas = new List <PointData>(); Point startpoint = new Point(90, 30); Rectangle Datapath = new Rectangle() { Stroke = Brushes.PaleVioletRed, StrokeThickness = 2, Width = _canvas.ActualWidth - startpoint.X * 2, Height = _canvas.ActualHeight - startpoint.Y * 2 }; Canvas.SetTop(Datapath, startpoint.Y); Canvas.SetLeft(Datapath, startpoint.X); _canvas.Children.Add(Datapath); TextBlock DatapathName = new TextBlock() { Text = _data.Name, FontSize = 20 }; Point NamePoint = new Point((Datapath.Width / 2) - 50, 2); Canvas.SetTop(DatapathName, NamePoint.Y); Canvas.SetLeft(DatapathName, NamePoint.X); _canvas.Children.Add(DatapathName); #region addtion of port labels int counterin = 1; int counterout = 1; foreach (PortModel port in _data.Ports) { if (port.Direction == "in") { TextBlock PortName = new TextBlock() { Text = port.Name }; Point PortPoint = new Point(startpoint.X - (PortName.Text.Length * 5) - 10, (startpoint.Y * counterin) + 20); Canvas.SetTop(PortName, PortPoint.Y); Canvas.SetLeft(PortName, PortPoint.X); PortPoint.X = startpoint.X; PointData pointData = new PointData(null, _data.Name, port.Name, PortPoint); pointDatas.Add(pointData); _canvas.Children.Add(PortName); counterin++; } else { Point PortPoint = new Point(startpoint.X + Datapath.Width, (startpoint.Y * counterout) + 20); Label PortName = new Label() { Content = port.Name }; Canvas.SetTop(PortName, PortPoint.Y); Canvas.SetLeft(PortName, PortPoint.X); PointData pointData = new PointData(null, _data.Name, port.Name, PortPoint); pointDatas.Add(pointData); _canvas.Children.Add(PortName); counterout++; } } #endregion return(pointDatas); }