// Creates GraphicsArray wrapper private GraphicsArray CreateItem( // Fields of GraphicsArray table Guid GraphicsArrayId, bool WriteOn1, MemoryOnStart OnStart, int DataBitWidth, int BitsPerPixel, int Width, int Height, string Note // Fields of Circuit table ) { TableSnapshot <CircuitData> tableCircuit = (TableSnapshot <CircuitData>) this.CircuitProject.Table("Circuit"); CircuitData dataCircuit = new CircuitData() { CircuitId = GraphicsArrayId }; RowId rowIdCircuit = tableCircuit.Insert(ref dataCircuit); GraphicsArrayData dataGraphicsArray = new GraphicsArrayData() { GraphicsArrayId = GraphicsArrayId, WriteOn1 = WriteOn1, OnStart = OnStart, DataBitWidth = DataBitWidth, BitsPerPixel = BitsPerPixel, Width = Width, Height = Height, Note = Note, }; return(this.Create(this.Table.Insert(ref dataGraphicsArray), rowIdCircuit)); }
// Creates Memory wrapper private Memory CreateItem( // Fields of Memory table Guid MemoryId, bool Writable, bool WriteOn1, MemoryOnStart OnStart, int AddressBitWidth, int DataBitWidth, string Data, string Note // Fields of Circuit table ) { TableSnapshot <CircuitData> tableCircuit = (TableSnapshot <CircuitData>) this.CircuitProject.Table("Circuit"); CircuitData dataCircuit = new CircuitData() { CircuitId = MemoryId }; RowId rowIdCircuit = tableCircuit.Insert(ref dataCircuit); MemoryData dataMemory = new MemoryData() { MemoryId = MemoryId, Writable = Writable, WriteOn1 = WriteOn1, OnStart = OnStart, AddressBitWidth = AddressBitWidth, DataBitWidth = DataBitWidth, Data = Data, Note = Note, }; return(this.Create(this.Table.Insert(ref dataMemory), rowIdCircuit)); }
private void ButtonOkClick(object sender, RoutedEventArgs e) { try { int addressBitWidth = this.AddressBitWidth; int dataBitWidth = this.DataBitWidth; bool writeOn1 = this.Memory.Writable && ((EnumDescriptor <bool>) this.writeOn.SelectedItem).Value; MemoryOnStart memoryOnStart = ((EnumDescriptor <MemoryOnStart>) this.onStart.SelectedItem).Value; bool dualPort = this.checkBoxDualPort.IsChecked.Value; bool saveData = !this.Memory.Writable || memoryOnStart == MemoryOnStart.Data; if (!this.Memory.Writable) { memoryOnStart = MemoryOnStart.Random; // set to default value for ROM } string text = this.note.Text.Trim(); bool equal(byte[] a, byte[] b) { if (a.Length == b.Length) { for (int i = 0; i < a.Length; i++) { if (a[i] != b[i]) { return(false); } } return(true); } return(false); } if (this.Memory.AddressBitWidth != addressBitWidth || this.Memory.DataBitWidth != dataBitWidth || this.Memory.Note != text || this.Memory.WriteOn1 != writeOn1 || this.Memory.OnStart != memoryOnStart || this.Memory.DualPort != dualPort || (saveData && !equal(this.Memory.MemoryValue(), this.data)) ) { this.Memory.CircuitProject.InTransaction(() => { this.Memory.AddressBitWidth = addressBitWidth; this.Memory.DataBitWidth = dataBitWidth; this.Memory.WriteOn1 = writeOn1; this.Memory.OnStart = memoryOnStart; this.Memory.DualPort = dualPort; this.Memory.SetMemoryValue(saveData ? this.data : null); this.Memory.Note = text; if (this.Memory.Writable) { MemorySet.UpdateWritePinName(this.Memory); } }); } this.Close(); } catch (Exception exception) { App.Mainframe.ReportException(exception); } }
private void ButtonOkClick(object sender, RoutedEventArgs e) { try { if (0 < this.parsedWidth && 0 < this.parsedHeight) { bool writeOn = ((EnumDescriptor <bool>) this.writeOn.SelectedItem).Value; MemoryOnStart onStart = ((EnumDescriptor <MemoryOnStart>) this.onStart.SelectedItem).Value; int dataBitWidth = (int)this.dataBitWidth.SelectedItem; int bitsPerPixel = (int)this.bitsPerPixel.SelectedItem; int zoom = (int)this.zoom.SelectedItem; string note = this.note.Text.Trim(); if (this.graphicsArray.WriteOn1 != writeOn || this.graphicsArray.OnStart != onStart || this.graphicsArray.DataBitWidth != dataBitWidth || this.graphicsArray.BitsPerPixel != bitsPerPixel || this.graphicsArray.Width != this.parsedWidth || this.graphicsArray.Height != this.parsedHeight || this.graphicsArray.Zoom != zoom || this.graphicsArray.Note != note ) { this.graphicsArray.CircuitProject.InTransaction(() => { this.graphicsArray.WriteOn1 = writeOn; this.graphicsArray.OnStart = onStart; this.graphicsArray.DataBitWidth = dataBitWidth; this.graphicsArray.BitsPerPixel = bitsPerPixel; this.graphicsArray.Width = this.parsedWidth; this.graphicsArray.Height = this.parsedHeight; this.graphicsArray.Zoom = zoom; this.graphicsArray.Note = note; }); } } this.Close(); } catch (Exception exception) { App.Mainframe.ReportException(exception); } }
public static MemoryOnStart CheckOnStart(MemoryOnStart value) { return((MemoryOnStart.Random <= value && value <= MemoryOnStart.Ones) ? value : MemoryOnStart.Zeros); }