├── Sources
├── LogicCircuit.UnitTest
│ ├── Usings.cs
│ ├── HDL
│ │ ├── HdlItem.cs
│ │ ├── HdlLexer.g4
│ │ ├── HdlJam.cs
│ │ ├── HdlParser.g4
│ │ ├── HdlErrorListener.cs
│ │ └── HdlIOPin.cs
│ ├── DataPersistent
│ │ ├── IntField.cs
│ │ └── RowIdTest.cs
│ ├── AssemblyInfo.cs
│ ├── VisualElementLoadTest.cs
│ ├── Properties
│ │ └── From2.0.0.6Conversion.CircuitProject
│ ├── SettingsTest.cs
│ └── TestHelper.cs
├── Setup
│ ├── Banner.bmp
│ ├── Dialog.bmp
│ └── Setup.wixproj
├── LogicCircuit
│ ├── Properties
│ │ ├── default.wav
│ │ ├── LogicCircuit.ico
│ │ ├── LogicCircuit.png
│ │ └── AssemblyInfo.cs
│ ├── GateShape.cs
│ ├── Function
│ │ ├── IFunctionClock.cs
│ │ ├── State.cs
│ │ ├── IFunctionMemory.cs
│ │ ├── IFunctionVisual.cs
│ │ ├── FunctionNot.cs
│ │ ├── FunctionRom.cs
│ │ ├── FunctionClock.cs
│ │ ├── FunctionTriStateGroup.cs
│ │ ├── FunctionTriState.cs
│ │ ├── FunctionRam.cs
│ │ ├── OneBitConst.cs
│ │ ├── FunctionXor.cs
│ │ ├── FunctionXorNot.cs
│ │ ├── FunctionLedMatrixIndividual.cs
│ │ └── Probe.cs
│ ├── DataPersistent
│ │ ├── SnapTableAction.cs
│ │ ├── RolledBackEventArgs.cs
│ │ ├── ITableSnapshot.cs
│ │ ├── VersionChangeEventArgs.cs
│ │ ├── ITableChange.cs
│ │ ├── ISnapTable.cs
│ │ ├── ISnapTableChange.cs
│ │ ├── RowIdPseudoField.cs
│ │ ├── SnapStoreException.cs
│ │ ├── IntArray.cs
│ │ ├── RowIdField.cs
│ │ └── RowId.cs
│ ├── CircuitProject
│ │ ├── LedMatrixType.cs
│ │ ├── LedMatrixCellShape.cs
│ │ ├── PinType.cs
│ │ ├── PinSide.cs
│ │ ├── MemoryOnStart.cs
│ │ ├── SensorType.cs
│ │ ├── Rotation.cs
│ │ ├── JamComparer.cs
│ │ ├── GateType.cs
│ │ ├── NamedItemSet.cs
│ │ ├── CircuitSymbolComparer.cs
│ │ ├── SensorPoint.cs
│ │ ├── PinComparer.cs
│ │ └── CollapsedCategory.cs
│ ├── CircuitShape.cs
│ ├── ColorPicker
│ │ ├── ColorPickerMode.cs
│ │ ├── HueToColorConverter.cs
│ │ └── ColorSlider.cs
│ ├── SymbolShapes
│ │ ├── MarkerLine.xaml
│ │ ├── DisplayBorder.xaml
│ │ ├── DisplayBackground.xaml
│ │ ├── Led.xaml
│ │ ├── LedMatrixRectCell.xaml
│ │ ├── MarkerRectangle.xaml
│ │ ├── Button.xaml
│ │ ├── LedMatrix.xaml
│ │ ├── ShapedNot.xaml
│ │ ├── LedMatrixRoundCell.xaml
│ │ ├── ShapedTriState2.xaml
│ │ ├── CircuitFlipFlop.xaml
│ │ ├── ShapedTriState1.xaml
│ │ ├── Clock.xaml
│ │ ├── GraphicsArray.xaml
│ │ ├── Rectangular.xaml
│ │ ├── TextNote.xaml
│ │ ├── Pin.xaml
│ │ ├── Probe.xaml
│ │ ├── Constant.xaml
│ │ ├── CircuitMux.xaml
│ │ ├── CircuitDemux.xaml
│ │ ├── ToggleLed.xaml
│ │ ├── Splitter.xaml
│ │ ├── CircuitAlu.xaml
│ │ ├── Sound.xaml
│ │ ├── SensorAuto.xaml
│ │ ├── SensorManual.xaml
│ │ ├── ShapedAnd.xaml
│ │ ├── ShapedOr.xaml
│ │ └── SevenSegment.xaml
│ ├── Schema
│ │ ├── Empty.xml
│ │ ├── ConvertFrom.2.0.0.11.xslt
│ │ ├── ConvertFrom.2.0.0.12.xslt
│ │ ├── ConvertFrom.2.0.0.13.xslt
│ │ ├── ConvertFrom.1.0.0.2.xslt
│ │ ├── ConvertFrom.2.0.0.1.xslt
│ │ ├── ConvertFrom.2.0.0.2.xslt
│ │ ├── ConvertFrom.2.0.0.4.xslt
│ │ ├── ConvertFrom.2.0.0.7.xslt
│ │ ├── ConvertFrom.2.0.0.8.xslt
│ │ ├── ConvertFrom.2.0.0.9.xslt
│ │ ├── ConvertFrom.2.0.0.6.xslt
│ │ ├── ConvertFrom.2.0.0.10.xslt
│ │ ├── ConvertFrom.2.0.0.3.xslt
│ │ ├── ConvertSettings.xslt
│ │ └── ConvertFrom.2.0.0.5.xslt
│ ├── Dialog
│ │ ├── DialogRAM.cs
│ │ ├── DialogROM.cs
│ │ ├── ControlKeyGesture.xaml
│ │ ├── DialogReport.xaml
│ │ ├── ControlFolderSelector.xaml
│ │ ├── IronPythonConsole.xaml
│ │ ├── DialogMemory.xaml.cs
│ │ ├── DialogReport.xaml.cs
│ │ ├── DialogProbeHistory.xaml
│ │ ├── ControlPinOrder.xaml
│ │ ├── DialogProject.xaml
│ │ ├── DialogSound.xaml
│ │ ├── DialogProbe.xaml
│ │ ├── ControlFolderSelector.xaml.cs
│ │ ├── DialogMemory.xaml
│ │ ├── DialogFind.xaml
│ │ ├── DialogHyperlink.xaml
│ │ ├── DialogUsage.xaml.cs
│ │ └── DialogProbe.xaml.cs
│ ├── ColorMethods.cs
│ ├── Icon
│ │ ├── Warning.xaml
│ │ ├── Error.xaml
│ │ ├── Info.xaml
│ │ ├── CircuitPower.xaml
│ │ ├── Question.xaml
│ │ ├── EditJustify.xaml
│ │ ├── EditTextCenter.xaml
│ │ ├── ColorFont.xaml
│ │ ├── EditRightJustify.xaml
│ │ ├── Delete.xaml
│ │ ├── FileSave.xaml
│ │ ├── FileClose.xaml
│ │ ├── EditBulletList.xaml
│ │ ├── CircuitPulse.xaml
│ │ ├── EditLeftJustify.xaml
│ │ ├── EditTextIndent.xaml
│ │ ├── EditIncreaseFontSize.xaml
│ │ ├── EditDecreaseFontSize.xaml
│ │ ├── EditCopy.xaml
│ │ ├── EditRotateRight.xaml
│ │ ├── F1Help.xaml
│ │ ├── CircuitTable.xaml
│ │ ├── EditTextOutdent.xaml
│ │ ├── EditPaste.xaml
│ │ ├── EditRotateLeft.xaml
│ │ ├── FileOpen.xaml
│ │ ├── Image.xaml
│ │ ├── CircuitProperty.xaml
│ │ ├── AlignLeft.xaml
│ │ ├── FileNew.xaml
│ │ ├── AlignTop.xaml
│ │ ├── AlignBottom.xaml
│ │ ├── AlignRight.xaml
│ │ ├── EditRedo.xaml
│ │ ├── AlignCenter.xaml
│ │ ├── EditUndo.xaml
│ │ ├── AlignMiddle.xaml
│ │ ├── CircuitProjectProperty.xaml
│ │ ├── Hyperlink.xaml
│ │ └── FileSaveAs.xaml
│ ├── VectorImageLoaderConverter.cs
│ ├── InverseBooleanConverter.cs
│ ├── Editor
│ │ ├── CircuitDescriptorComparer.cs
│ │ ├── WireDisplayControl.xaml
│ │ ├── Marker.cs
│ │ └── AreaMarker.cs
│ ├── RemoveAcceleratorConverter.cs
│ ├── EnumDescriptor.cs
│ ├── AutoWidthComboBox.cs
│ ├── DoubleAdderConverter.cs
│ ├── EnumToVisibilityConvertor.cs
│ ├── Settings
│ │ ├── SettingsEnumCache.cs
│ │ ├── SettingsBoolCache.cs
│ │ ├── SettingsDateTimeCache.cs
│ │ ├── SettingsIntegerCache.cs
│ │ ├── SettingsGridLengthCache.cs
│ │ ├── SettingsStringCache.cs
│ │ └── SettingsDoubleCache.cs
│ ├── EnumHelper.cs
│ ├── HDL
│ │ └── HdlTransformation.cs
│ ├── TruthTableFilterParser.g4
│ ├── TruthTableFilterLexer.g4
│ ├── OneToMany.cs
│ ├── GridPoint.cs
│ ├── HyperlinkNavigationCommand.cs
│ ├── ButtonControl.cs
│ ├── Conductor.cs
│ ├── DisplayCanvas.cs
│ └── CommandMenuItem.cs
├── Tools
│ ├── ItemWrapper.Generator
│ │ ├── ItemModifier.cs
│ │ ├── RealmType.cs
│ │ ├── AccessModifier.cs
│ │ ├── AssemblyInfo.cs
│ │ ├── Store.cs
│ │ ├── Error.cs
│ │ ├── GeneratorItem.tt
│ │ ├── GeneratorStore.tt
│ │ └── ToStringHelper.cs
│ ├── Directory.Build.props
│ ├── ExportResx
│ │ ├── Value.cs
│ │ └── ExportResx.csproj
│ └── FindUnusedResources
│ │ └── FindUnusedResources.csproj
├── .editorconfig
├── License.txt
├── ReleaseCheckList.txt
├── Directory.Build.props
├── LogicCircuit.slnx
├── ToDoList.txt
└── BuildSetup.cmd
└── README.md
/Sources/LogicCircuit.UnitTest/Usings.cs:
--------------------------------------------------------------------------------
1 | global using Microsoft.VisualStudio.TestTools.UnitTesting;
--------------------------------------------------------------------------------
/Sources/Setup/Banner.bmp:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/eugenelepekhin/LogicCircuit/HEAD/Sources/Setup/Banner.bmp
--------------------------------------------------------------------------------
/Sources/Setup/Dialog.bmp:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/eugenelepekhin/LogicCircuit/HEAD/Sources/Setup/Dialog.bmp
--------------------------------------------------------------------------------
/Sources/LogicCircuit/Properties/default.wav:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/eugenelepekhin/LogicCircuit/HEAD/Sources/LogicCircuit/Properties/default.wav
--------------------------------------------------------------------------------
/Sources/LogicCircuit/Properties/LogicCircuit.ico:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/eugenelepekhin/LogicCircuit/HEAD/Sources/LogicCircuit/Properties/LogicCircuit.ico
--------------------------------------------------------------------------------
/Sources/LogicCircuit/Properties/LogicCircuit.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/eugenelepekhin/LogicCircuit/HEAD/Sources/LogicCircuit/Properties/LogicCircuit.png
--------------------------------------------------------------------------------
/Sources/LogicCircuit/GateShape.cs:
--------------------------------------------------------------------------------
1 | using System;
2 |
3 | namespace LogicCircuit {
4 | public enum GateShape {
5 | Rectangular,
6 | Shaped
7 | }
8 | }
9 |
--------------------------------------------------------------------------------
/Sources/Tools/ItemWrapper.Generator/ItemModifier.cs:
--------------------------------------------------------------------------------
1 | namespace ItemWrapper.Generator {
2 | public enum ItemModifier {
3 | None,
4 | Abstract
5 | }
6 | }
7 |
--------------------------------------------------------------------------------
/Sources/LogicCircuit/Function/IFunctionClock.cs:
--------------------------------------------------------------------------------
1 | using System;
2 |
3 | namespace LogicCircuit {
4 | public interface IFunctionClock {
5 | bool Flip();
6 | }
7 | }
8 |
--------------------------------------------------------------------------------
/Sources/LogicCircuit/DataPersistent/SnapTableAction.cs:
--------------------------------------------------------------------------------
1 | namespace DataPersistent {
2 | public enum SnapTableAction {
3 | Insert,
4 | Delete,
5 | Update
6 | }
7 | }
8 |
--------------------------------------------------------------------------------
/Sources/Tools/ItemWrapper.Generator/RealmType.cs:
--------------------------------------------------------------------------------
1 | namespace ItemWrapper.Generator {
2 | public enum RealmType {
3 | None,
4 | Universe,
5 | Multiverse,
6 | }
7 | }
8 |
--------------------------------------------------------------------------------
/Sources/LogicCircuit/CircuitProject/LedMatrixType.cs:
--------------------------------------------------------------------------------
1 | using System;
2 |
3 | namespace LogicCircuit {
4 | public enum LedMatrixType {
5 | Individual,
6 | Selector
7 | }
8 | }
9 |
--------------------------------------------------------------------------------
/Sources/LogicCircuit/CircuitProject/LedMatrixCellShape.cs:
--------------------------------------------------------------------------------
1 | using System;
2 |
3 | namespace LogicCircuit {
4 | public enum LedMatrixCellShape {
5 | Round,
6 | Rectangle
7 | }
8 | }
9 |
--------------------------------------------------------------------------------
/Sources/LogicCircuit/CircuitProject/PinType.cs:
--------------------------------------------------------------------------------
1 | using System;
2 |
3 | namespace LogicCircuit {
4 | public enum PinType {
5 | None,
6 | Input,
7 | Output
8 | }
9 | }
10 |
--------------------------------------------------------------------------------
/Sources/LogicCircuit/CircuitProject/PinSide.cs:
--------------------------------------------------------------------------------
1 | using System;
2 |
3 | namespace LogicCircuit {
4 | public enum PinSide {
5 | Left,
6 | Top,
7 | Right,
8 | Bottom
9 | }
10 | }
11 |
--------------------------------------------------------------------------------
/Sources/LogicCircuit/CircuitShape.cs:
--------------------------------------------------------------------------------
1 | namespace LogicCircuit {
2 | public enum CircuitShape {
3 | Rectangular,
4 | Display,
5 | Mux,
6 | Demux,
7 | Alu,
8 | FlipFlop,
9 | }
10 | }
11 |
--------------------------------------------------------------------------------
/Sources/Tools/ItemWrapper.Generator/AccessModifier.cs:
--------------------------------------------------------------------------------
1 | namespace ItemWrapper.Generator {
2 | public enum AccessModifier {
3 | Public,
4 | Internal,
5 | Protected,
6 | Private,
7 | }
8 | }
9 |
--------------------------------------------------------------------------------
/Sources/LogicCircuit/ColorPicker/ColorPickerMode.cs:
--------------------------------------------------------------------------------
1 | using System;
2 |
3 | namespace LogicCircuit {
4 | public enum ColorPickerMode {
5 | Color,
6 | Foreground,
7 | Background
8 | }
9 | }
10 |
--------------------------------------------------------------------------------
/Sources/LogicCircuit/CircuitProject/MemoryOnStart.cs:
--------------------------------------------------------------------------------
1 | using System;
2 |
3 | namespace LogicCircuit {
4 | public enum MemoryOnStart {
5 | Random,
6 | Zeros,
7 | Ones,
8 | Data
9 | }
10 | }
11 |
--------------------------------------------------------------------------------
/Sources/LogicCircuit/CircuitProject/SensorType.cs:
--------------------------------------------------------------------------------
1 | namespace LogicCircuit {
2 | public enum SensorType {
3 | Series,
4 | Loop,
5 | Random,
6 | Manual,
7 | KeyCode,
8 | ASCII,
9 | Sequence,
10 | Clock,
11 | }
12 | }
13 |
--------------------------------------------------------------------------------
/Sources/LogicCircuit/Function/State.cs:
--------------------------------------------------------------------------------
1 | namespace LogicCircuit {
2 | [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Design", "CA1028:EnumStorageShouldBeInt32")]
3 | public enum State : byte {
4 | Off,
5 | On0,
6 | On1
7 | }
8 | }
9 |
--------------------------------------------------------------------------------
/Sources/LogicCircuit/SymbolShapes/MarkerLine.xaml:
--------------------------------------------------------------------------------
1 |
7 |
--------------------------------------------------------------------------------
/Sources/LogicCircuit/SymbolShapes/DisplayBorder.xaml:
--------------------------------------------------------------------------------
1 |
8 |
--------------------------------------------------------------------------------
/Sources/LogicCircuit/Function/IFunctionMemory.cs:
--------------------------------------------------------------------------------
1 | using System;
2 |
3 | namespace LogicCircuit {
4 | public interface IFunctionMemory {
5 | int AddressBitWidth { get; }
6 | int DataBitWidth { get; }
7 | int this[int index] { get; set; }
8 |
9 | }
10 | }
11 |
--------------------------------------------------------------------------------
/Sources/LogicCircuit/SymbolShapes/DisplayBackground.xaml:
--------------------------------------------------------------------------------
1 |
7 |
--------------------------------------------------------------------------------
/Sources/LogicCircuit/SymbolShapes/Led.xaml:
--------------------------------------------------------------------------------
1 |
6 |
--------------------------------------------------------------------------------
/Sources/LogicCircuit/SymbolShapes/LedMatrixRectCell.xaml:
--------------------------------------------------------------------------------
1 |
8 |
--------------------------------------------------------------------------------
/Sources/LogicCircuit/CircuitProject/Rotation.cs:
--------------------------------------------------------------------------------
1 | using System;
2 |
3 | namespace LogicCircuit {
4 | public enum Rotation {
5 | Up,
6 | Right,
7 | Down,
8 | Left
9 | }
10 |
11 | public interface IRotatable {
12 | Rotation Rotation { get; set; }
13 | }
14 | }
15 |
--------------------------------------------------------------------------------
/Sources/Tools/Directory.Build.props:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | $(ToolsFolder)
6 | false
7 |
8 |
9 |
10 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | # LogicCircuit
2 | **LogicCircuit** – is free, open source educational software for designing and simulating digital logic circuits.
3 | 
4 |
5 | ### How do I build it ###
6 |
7 | * Use Visual Studio.
8 | * Install Wix Toolset extension
9 |
--------------------------------------------------------------------------------
/Sources/LogicCircuit.UnitTest/HDL/HdlItem.cs:
--------------------------------------------------------------------------------
1 | // Ignore Spelling: Hdl
2 |
3 | namespace LogicCircuit.UnitTest.HDL {
4 | internal class HdlItem {
5 | public HdlContext HdlContext { get; }
6 |
7 | protected HdlItem(HdlContext hdlContext) {
8 | this.HdlContext = hdlContext;
9 | }
10 | }
11 | }
12 |
--------------------------------------------------------------------------------
/Sources/LogicCircuit/SymbolShapes/MarkerRectangle.xaml:
--------------------------------------------------------------------------------
1 |
8 |
--------------------------------------------------------------------------------
/Sources/LogicCircuit/Schema/Empty.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
--------------------------------------------------------------------------------
/Sources/LogicCircuit/Dialog/DialogRAM.cs:
--------------------------------------------------------------------------------
1 | using System;
2 |
3 | namespace LogicCircuit {
4 | public class DialogRam : DialogMemoryEditor {
5 | public DialogRam(Memory memory) : base(memory) {
6 | Tracer.Assert(memory.Writable);
7 | this.Title = Properties.Resources.RAMNotation;
8 | }
9 | }
10 | }
11 |
--------------------------------------------------------------------------------
/Sources/LogicCircuit/SymbolShapes/Button.xaml:
--------------------------------------------------------------------------------
1 |
8 |
--------------------------------------------------------------------------------
/Sources/LogicCircuit/SymbolShapes/LedMatrix.xaml:
--------------------------------------------------------------------------------
1 |
7 |
8 |
9 |
--------------------------------------------------------------------------------
/Sources/LogicCircuit/SymbolShapes/ShapedNot.xaml:
--------------------------------------------------------------------------------
1 |
5 |
6 |
7 |
--------------------------------------------------------------------------------
/Sources/LogicCircuit/Dialog/DialogROM.cs:
--------------------------------------------------------------------------------
1 | using System;
2 |
3 | namespace LogicCircuit {
4 | public class DialogRom : DialogMemoryEditor {
5 | public DialogRom(Memory memory) : base(memory) {
6 | Tracer.Assert(!memory.Writable);
7 | this.Title = Properties.Resources.ROMNotation;
8 | }
9 | }
10 | }
11 |
--------------------------------------------------------------------------------
/Sources/LogicCircuit/DataPersistent/RolledBackEventArgs.cs:
--------------------------------------------------------------------------------
1 | using System;
2 |
3 | namespace DataPersistent {
4 | public class RolledBackEventArgs : EventArgs {
5 |
6 | public int Version { get; private set; }
7 |
8 | public RolledBackEventArgs(int version) {
9 | this.Version = version;
10 | }
11 | }
12 | }
13 |
--------------------------------------------------------------------------------
/Sources/LogicCircuit/SymbolShapes/LedMatrixRoundCell.xaml:
--------------------------------------------------------------------------------
1 |
10 |
--------------------------------------------------------------------------------
/Sources/Tools/ExportResx/Value.cs:
--------------------------------------------------------------------------------
1 | namespace ExportResx {
2 | internal sealed class Value {
3 | public string Name { get; }
4 | public string Text { get; }
5 | public string Note { get; }
6 |
7 | public Value(string name, string text, string note) {
8 | this.Name = name;
9 | this.Text = text;
10 | this.Note = note;
11 | }
12 | }
13 | }
14 |
--------------------------------------------------------------------------------
/Sources/LogicCircuit/DataPersistent/ITableSnapshot.cs:
--------------------------------------------------------------------------------
1 | using System.Collections.Generic;
2 |
3 | namespace DataPersistent {
4 | public interface ITableSnapshot : IEnumerable {
5 | StoreSnapshot StoreSnapshot { get; }
6 | string Name { get; }
7 | IEnumerable Rows { get; }
8 | bool WasChanged(int fromVersion, int toVersion);
9 | bool WasAffected(int version);
10 | }
11 | }
12 |
--------------------------------------------------------------------------------
/Sources/LogicCircuit/Dialog/ControlKeyGesture.xaml:
--------------------------------------------------------------------------------
1 |
6 |
7 |
8 |
--------------------------------------------------------------------------------
/Sources/LogicCircuit/DataPersistent/VersionChangeEventArgs.cs:
--------------------------------------------------------------------------------
1 | using System;
2 |
3 | namespace DataPersistent {
4 | public class VersionChangeEventArgs : EventArgs {
5 | public int OldVersion { get; }
6 | public int NewVersion { get; }
7 |
8 | public VersionChangeEventArgs(int oldVersion, int newVersion) {
9 | this.OldVersion = oldVersion;
10 | this.NewVersion = newVersion;
11 | }
12 | }
13 | }
14 |
--------------------------------------------------------------------------------
/Sources/LogicCircuit/Function/IFunctionVisual.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Diagnostics.CodeAnalysis;
3 |
4 | namespace LogicCircuit {
5 | public interface IFunctionVisual {
6 | void TurnOn();
7 | [SuppressMessage("Microsoft.Naming", "CA1702:CompoundWordsShouldBeCasedCorrectly", MessageId = "TurnOff")]
8 | void TurnOff();
9 | void Redraw(bool force);
10 | bool Invalid { get; set; }
11 | }
12 | }
13 |
--------------------------------------------------------------------------------
/Sources/LogicCircuit/SymbolShapes/ShapedTriState2.xaml:
--------------------------------------------------------------------------------
1 |
5 |
6 |
7 |
8 |
--------------------------------------------------------------------------------
/Sources/LogicCircuit/SymbolShapes/CircuitFlipFlop.xaml:
--------------------------------------------------------------------------------
1 |
5 |
6 |
7 |
8 |
9 |
10 |
--------------------------------------------------------------------------------
/Sources/LogicCircuit/SymbolShapes/ShapedTriState1.xaml:
--------------------------------------------------------------------------------
1 |
5 |
6 |
7 |
8 |
--------------------------------------------------------------------------------
/Sources/LogicCircuit/SymbolShapes/Clock.xaml:
--------------------------------------------------------------------------------
1 |
6 |
9 |
10 |
--------------------------------------------------------------------------------
/Sources/LogicCircuit/ColorMethods.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Windows.Media;
3 |
4 | namespace LogicCircuit {
5 | public static class ColorMethods {
6 | public static int CompareTo(this Color color1, Color color2) {
7 | return color1.ToInt32() - color2.ToInt32();
8 | }
9 |
10 | public static int ToInt32(this Color color) {
11 | return (color.A << 24) | (color.R << 16) | (color.G << 8) | color.B;
12 | }
13 | }
14 | }
15 |
--------------------------------------------------------------------------------
/Sources/LogicCircuit/DataPersistent/ITableChange.cs:
--------------------------------------------------------------------------------
1 | namespace DataPersistent {
2 | internal interface ITableChange where TRecord:struct {
3 | SnapTableAction Action(RowId rowId);
4 | void GetNewData(RowId rowId, out TRecord data);
5 | void GetOldData(RowId rowId, out TRecord data);
6 | TField GetNewField(RowId rowId, IField field);
7 | TField GetOldField(RowId rowId, IField field);
8 | }
9 | }
10 |
--------------------------------------------------------------------------------
/Sources/LogicCircuit/CircuitProject/JamComparer.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Diagnostics;
4 |
5 | namespace LogicCircuit {
6 | internal sealed class JamComparer : IComparer {
7 | public static readonly IComparer Comparer = new JamComparer();
8 |
9 | public int Compare(Jam? x, Jam? y) {
10 | Debug.Assert(x != null && y != null);
11 | return PinComparer.Comparer.Compare(x.Pin, y.Pin);
12 | }
13 | }
14 | }
15 |
--------------------------------------------------------------------------------
/Sources/LogicCircuit/DataPersistent/ISnapTable.cs:
--------------------------------------------------------------------------------
1 | using System.Collections.Generic;
2 |
3 | namespace DataPersistent {
4 | internal interface ISnapTable {
5 | SnapStore SnapStore { get; }
6 | string Name { get; }
7 | void Rollback();
8 | void Revert(int version);
9 | ITableSnapshot CreateTableSnapshot(StoreSnapshot storeSnapshot);
10 | List Children { get; }
11 | bool IsUserTable { get; }
12 | bool WasChangedIn(int version);
13 | }
14 | }
15 |
--------------------------------------------------------------------------------
/Sources/LogicCircuit/SymbolShapes/GraphicsArray.xaml:
--------------------------------------------------------------------------------
1 |
9 |
10 |
11 |
--------------------------------------------------------------------------------
/Sources/LogicCircuit/SymbolShapes/Rectangular.xaml:
--------------------------------------------------------------------------------
1 |
8 |
9 |
10 |
--------------------------------------------------------------------------------
/Sources/Tools/ItemWrapper.Generator/AssemblyInfo.cs:
--------------------------------------------------------------------------------
1 | using System.Resources;
2 | using System.Runtime.InteropServices;
3 |
4 | [assembly: NeutralResourcesLanguageAttribute("en-US")]
5 |
6 | // Setting ComVisible to false makes the types in this assembly not visible
7 | // to COM components. If you need to access a type in this assembly from
8 | // COM, set the ComVisible attribute to true on that type.
9 | [assembly: ComVisible(false)]
10 | [assembly: CLSCompliant(false)]
11 |
--------------------------------------------------------------------------------
/Sources/LogicCircuit/DataPersistent/ISnapTableChange.cs:
--------------------------------------------------------------------------------
1 | namespace DataPersistent {
2 | internal interface ISnapTableChange where TRecord:struct {
3 | RowId RowId(int changeIndex);
4 | SnapTableAction Action(int changeIndex);
5 | void GetNewData(int changeIndex, out TRecord data);
6 | void GetOldData(int changeIndex, out TRecord data);
7 | TField GetNewField(int changeIndex, IField field);
8 | TField GetOldField(int changeIndex, IField field);
9 | }
10 | }
11 |
--------------------------------------------------------------------------------
/Sources/LogicCircuit/SymbolShapes/TextNote.xaml:
--------------------------------------------------------------------------------
1 |
15 |
--------------------------------------------------------------------------------
/Sources/LogicCircuit/CircuitProject/GateType.cs:
--------------------------------------------------------------------------------
1 | namespace LogicCircuit {
2 | public enum GateType {
3 | // Future extensions should add new types, not insert in the middle, unless old file conversion defined.
4 | Nop,
5 | Clock,
6 | Not,
7 | Or,
8 | And,
9 | Xor,
10 | Odd, // This one should not be used anymore
11 | Even, // This one should not be used anymore
12 | Led,
13 | Probe, // This one should not be used anymore
14 | TriState1, // This with controlling pin at the bottom
15 | TriState2 // This with controlling pin at the top
16 | }
17 | }
18 |
--------------------------------------------------------------------------------
/Sources/.editorconfig:
--------------------------------------------------------------------------------
1 | [*.cs]
2 |
3 | # CA1062: Validate arguments of public methods
4 | dotnet_diagnostic.CA1062.severity = none
5 |
6 | # CA1031: Do not catch general exception types
7 | dotnet_diagnostic.CA1031.severity = none
8 |
9 | # CA5394: Do not use insecure randomness
10 | dotnet_diagnostic.CA5394.severity = none
11 |
12 | # CA1515: Because an application's API isn't typically referenced from outside the assembly, types can be made internal
13 | dotnet_diagnostic.CA1515.severity = none
14 |
15 | # CA1056: URI properties should not be strings
16 | dotnet_diagnostic.CA1056.severity = none
17 |
--------------------------------------------------------------------------------
/Sources/LogicCircuit/Function/FunctionNot.cs:
--------------------------------------------------------------------------------
1 | using System;
2 |
3 | namespace LogicCircuit {
4 | public class FunctionNot : CircuitFunction {
5 | private readonly int param0;
6 |
7 | public FunctionNot(CircuitState circuitState, int parameter, int result) : base(circuitState, parameter, result) {
8 | this.param0 = parameter;
9 | }
10 | public override bool Evaluate() {
11 | return this.SetResult0(CircuitFunction.Not(this.CircuitState[this.param0]));
12 | }
13 |
14 | public override string ReportName { get { return Properties.Resources.GateNotName; } }
15 | }
16 | }
17 |
--------------------------------------------------------------------------------
/Sources/LogicCircuit/Icon/Warning.xaml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
--------------------------------------------------------------------------------
/Sources/LogicCircuit/SymbolShapes/Pin.xaml:
--------------------------------------------------------------------------------
1 |
8 |
9 |
10 |
--------------------------------------------------------------------------------
/Sources/LogicCircuit/SymbolShapes/Probe.xaml:
--------------------------------------------------------------------------------
1 |
8 |
9 |
10 |
--------------------------------------------------------------------------------
/Sources/License.txt:
--------------------------------------------------------------------------------
1 | Copyright 2025 LogicCircuit.org
2 |
3 | Licensed under the Apache License, Version 2.0 (the "License");
4 | you may not use this file except in compliance with the License.
5 | You may obtain a copy of the License at
6 |
7 | http://www.apache.org/licenses/LICENSE-2.0
8 |
9 | Unless required by applicable law or agreed to in writing, software
10 | distributed under the License is distributed on an "AS IS" BASIS,
11 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 | See the License for the specific language governing permissions and
13 | limitations under the License.
14 |
--------------------------------------------------------------------------------
/Sources/LogicCircuit/SymbolShapes/Constant.xaml:
--------------------------------------------------------------------------------
1 |
8 |
9 |
10 |
--------------------------------------------------------------------------------
/Sources/LogicCircuit/VectorImageLoaderConverter.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Globalization;
3 | using System.Windows.Data;
4 |
5 | namespace LogicCircuit {
6 | public class VectorImageLoaderConverter : IValueConverter {
7 | public object? Convert(object value, Type targetType, object parameter, CultureInfo culture) {
8 | if(parameter is string path) {
9 | return Symbol.Skin(path);
10 | }
11 | return null;
12 | }
13 |
14 | public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture) {
15 | throw new InvalidOperationException();
16 | }
17 | }
18 | }
19 |
--------------------------------------------------------------------------------
/Sources/Tools/ExportResx/ExportResx.csproj:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | Exe
5 | net7.0-windows
6 | enable
7 | enable
8 | true
9 |
10 | AllEnabledByDefault
11 | latest-all
12 |
13 | 1.0.0.0
14 | Utility Export Resx
15 | © LogicCircuit.org
16 |
17 |
18 |
19 |
--------------------------------------------------------------------------------
/Sources/LogicCircuit/Properties/AssemblyInfo.cs:
--------------------------------------------------------------------------------
1 | using System.Runtime.CompilerServices;
2 | using System.Windows;
3 |
4 | [assembly: InternalsVisibleTo("LogicCircuit.UnitTest")]
5 |
6 | [assembly: ThemeInfo(
7 | // where theme specific resource dictionaries are located
8 | // (used if a resource is not found in the page,
9 | // or application resource dictionaries)
10 | ResourceDictionaryLocation.None,
11 | // where the generic resource dictionary is located
12 | // (used if a resource is not found in the page,
13 | // app, or any theme specific resource dictionaries)
14 | ResourceDictionaryLocation.SourceAssembly
15 | )]
16 |
--------------------------------------------------------------------------------
/Sources/LogicCircuit/Dialog/DialogReport.xaml:
--------------------------------------------------------------------------------
1 |
10 |
11 |
12 |
13 |
14 |
--------------------------------------------------------------------------------
/Sources/LogicCircuit/Function/FunctionRom.cs:
--------------------------------------------------------------------------------
1 | using System;
2 |
3 | namespace LogicCircuit {
4 | public class FunctionRom : FunctionMemory {
5 | public FunctionRom(CircuitState circuitState, int[] address, int[] result, int[]? address2, int[]? result2, Memory memory) : base(
6 | circuitState, address, null, result, address2, result2, 0, memory
7 | ) {
8 | }
9 |
10 | public override bool Evaluate() {
11 | return this.Read();
12 | }
13 |
14 | public override string ReportName { get { return Properties.Resources.ReportMemoryName(Properties.Resources.ROMNotation, this.AddressBitWidth, this.DataBitWidth); } }
15 | }
16 | }
17 |
--------------------------------------------------------------------------------
/Sources/LogicCircuit/Icon/Error.xaml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
--------------------------------------------------------------------------------
/Sources/LogicCircuit/Icon/Info.xaml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
--------------------------------------------------------------------------------
/Sources/LogicCircuit/Dialog/ControlFolderSelector.xaml:
--------------------------------------------------------------------------------
1 |
7 |
8 |
9 |
10 |
11 |
12 |
--------------------------------------------------------------------------------
/Sources/LogicCircuit/SymbolShapes/CircuitMux.xaml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
--------------------------------------------------------------------------------
/Sources/LogicCircuit.UnitTest/DataPersistent/IntField.cs:
--------------------------------------------------------------------------------
1 | using DataPersistent;
2 |
3 | namespace LogicCircuit.UnitTest.DataPersistent {
4 | public class IntField : IField {
5 | public static readonly IntField Field = new IntField();
6 | public string Name => "Int";
7 | public int Order { get; set; }
8 | public int DefaultValue { get { return 0; } }
9 | public int GetValue(ref int record) => record;
10 | public void SetValue(ref int record, int value) => record = value;
11 | public int Compare(ref int data1, ref int data2) => Math.Sign((long)data1 - (long)data2);
12 | public int Compare(int x, int y) => Math.Sign((long)x - (long)y);
13 | }
14 | }
15 |
--------------------------------------------------------------------------------
/Sources/LogicCircuit/SymbolShapes/CircuitDemux.xaml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
--------------------------------------------------------------------------------
/Sources/LogicCircuit/Function/FunctionClock.cs:
--------------------------------------------------------------------------------
1 | using System;
2 |
3 | namespace LogicCircuit {
4 | public class FunctionClock : CircuitFunction, IFunctionClock {
5 | private bool state;
6 | public FunctionClock(CircuitState circuitState, int result) : base(circuitState, null, new int[] { result }) {
7 | this.state = false;
8 | }
9 | public bool Flip() {
10 | this.state = !this.state;
11 | return true;
12 | }
13 | public override bool Evaluate() {
14 | return this.SetResult0(CircuitFunction.FromBool(this.state));
15 | }
16 |
17 | public override string ReportName { get { return Properties.Resources.GateClockName; } }
18 | }
19 | }
20 |
--------------------------------------------------------------------------------
/Sources/LogicCircuit/InverseBooleanConverter.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Globalization;
3 | using System.Windows.Data;
4 |
5 | namespace LogicCircuit {
6 | [ValueConversion(typeof(bool), typeof(bool))]
7 | public class InverseBooleanConverter : IValueConverter {
8 |
9 | public object Convert(object value, Type targetType, object parameter, CultureInfo culture) {
10 | Tracer.Assert(targetType == typeof(bool));
11 | return !(bool)value;
12 | }
13 |
14 | public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture) {
15 | return this.Convert(value, targetType, parameter, culture);
16 | }
17 | }
18 | }
19 |
--------------------------------------------------------------------------------
/Sources/Tools/ItemWrapper.Generator/Store.cs:
--------------------------------------------------------------------------------
1 | namespace ItemWrapper.Generator {
2 | public class Store : List {
3 | public string Namespace { get; set; } = string.Empty;
4 | public string Name { get; set; } = string.Empty;
5 | public string PersistenceNamespace { get; set; } = string.Empty;
6 | public string PersistencePrefix { get; set; } = string.Empty;
7 |
8 | public Store() {
9 | }
10 |
11 | public void Validate() {
12 | foreach(Table table in this) {
13 | table.Validate(this);
14 | }
15 | }
16 |
17 | public Table? Find(string tableName) {
18 | return this.FirstOrDefault(t => t.Name == tableName);
19 | }
20 | }
21 | }
22 |
--------------------------------------------------------------------------------
/Sources/LogicCircuit/Function/FunctionTriStateGroup.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Diagnostics.CodeAnalysis;
3 |
4 | namespace LogicCircuit {
5 | [SuppressMessage("Microsoft.Naming", "CA1702:CompoundWordsShouldBeCasedCorrectly", MessageId = "TriState")]
6 | public class FunctionTriStateGroup : CircuitFunction {
7 | public FunctionTriStateGroup(CircuitState circuitState, int[] parameter, int result) : base(circuitState, parameter, result) {
8 | }
9 | public override bool Evaluate() {
10 | return this.SetResult0(this.TriStateGroup());
11 | }
12 |
13 | public override string ReportName { get { return Properties.Resources.TriStateGroupName; } }
14 | }
15 | }
16 |
--------------------------------------------------------------------------------
/Sources/LogicCircuit/SymbolShapes/ToggleLed.xaml:
--------------------------------------------------------------------------------
1 |
9 |
20 |
21 |
--------------------------------------------------------------------------------
/Sources/LogicCircuit/SymbolShapes/Splitter.xaml:
--------------------------------------------------------------------------------
1 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
--------------------------------------------------------------------------------
/Sources/LogicCircuit/Editor/CircuitDescriptorComparer.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Diagnostics;
4 |
5 | namespace LogicCircuit {
6 | internal sealed class CircuitDescriptorComparer : IComparer {
7 | public static readonly CircuitDescriptorComparer Comparer = new CircuitDescriptorComparer();
8 |
9 | public int Compare(IDescriptor? x, IDescriptor? y) {
10 | Debug.Assert(x != null && y != null);
11 | int r = StringComparer.Ordinal.Compare(x.Circuit.Category, y.Circuit.Category);
12 | if(r == 0) {
13 | return StringComparer.Ordinal.Compare(x.Circuit.Name, y.Circuit.Name);
14 | }
15 | return r;
16 | }
17 | }
18 | }
19 |
--------------------------------------------------------------------------------
/Sources/LogicCircuit/Function/FunctionTriState.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Diagnostics.CodeAnalysis;
3 |
4 | namespace LogicCircuit {
5 | [SuppressMessage("Microsoft.Naming", "CA1702:CompoundWordsShouldBeCasedCorrectly", MessageId = "TriState")]
6 | public class FunctionTriState : CircuitFunction {
7 | public FunctionTriState(CircuitState circuitState, int parameter, int enable, int result) : base(
8 | circuitState, new int[] { parameter, enable }, result
9 | ) {
10 | }
11 | public override bool Evaluate() {
12 | return this.SetResult0(this.ControlledState(State.On1));
13 | }
14 |
15 | public override string ReportName { get { return Properties.Resources.GateTriStateName; } }
16 | }
17 | }
18 |
--------------------------------------------------------------------------------
/Sources/LogicCircuit/RemoveAcceleratorConverter.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Windows.Data;
3 |
4 | namespace LogicCircuit {
5 | [ValueConversion(typeof(bool), typeof(bool))]
6 | public class RemoveAcceleratorConverter : IValueConverter {
7 | public object? Convert(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture) {
8 | if(value != null) {
9 | return value.ToString()!.Replace("_", string.Empty, StringComparison.Ordinal);
10 | }
11 | return null;
12 | }
13 |
14 | public object ConvertBack(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture) {
15 | throw new InvalidOperationException();
16 | }
17 | }
18 | }
19 |
--------------------------------------------------------------------------------
/Sources/LogicCircuit.UnitTest/HDL/HdlLexer.g4:
--------------------------------------------------------------------------------
1 | lexer grammar HdlLexer;
2 |
3 | @header {
4 | #pragma warning disable 3021
5 | }
6 |
7 | Chip: 'CHIP';
8 | Begin: '{';
9 | End: '}';
10 | Parts: 'PARTS:';
11 | In: 'IN';
12 | Out: 'OUT';
13 | Comma: ',';
14 | Semicolon: ';';
15 | Open: '(';
16 | Close: ')';
17 | Equal: '=';
18 | OpenBit: '[';
19 | CloseBit: ']';
20 | Elapse: '..';
21 |
22 | Identifier: Letter (Letter | DecDigit)*;
23 |
24 | DecNumber: '0' | (NonzeroDigit DecDigit*);
25 |
26 | fragment
27 | Letter: [a-zA-Z];
28 |
29 | fragment
30 | DecDigit: [0-9];
31 |
32 | fragment
33 | NonzeroDigit: [1-9];
34 |
35 | Whitespace: [ \t\u000C\r\n]+ -> skip;
36 |
37 | BlockComment: '/*' .*? '*/' -> skip;
38 | LineComment: '//' ~ [\r\n]* -> skip;
39 |
--------------------------------------------------------------------------------
/Sources/LogicCircuit/EnumDescriptor.cs:
--------------------------------------------------------------------------------
1 | using System;
2 |
3 | namespace LogicCircuit {
4 | ///
5 | /// Allow to show to user elements of enum as friendly text. Can be used in any ComboBox that allow selection of enum values.
6 | ///
7 | ///
8 | public class EnumDescriptor where T:struct {
9 | public T Value { get; private set; }
10 | public string Text { get; private set; }
11 |
12 | public EnumDescriptor(T value, string text) {
13 | Tracer.Assert(!(value is Enum) || EnumHelper.IsValid(value));
14 | this.Value = value;
15 | this.Text = text;
16 | }
17 |
18 | public override string ToString() {
19 | return this.Text;
20 | }
21 | }
22 | }
23 |
--------------------------------------------------------------------------------
/Sources/LogicCircuit/Schema/ConvertFrom.2.0.0.11.xslt:
--------------------------------------------------------------------------------
1 |
2 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
--------------------------------------------------------------------------------
/Sources/LogicCircuit/Schema/ConvertFrom.2.0.0.12.xslt:
--------------------------------------------------------------------------------
1 |
2 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
--------------------------------------------------------------------------------
/Sources/LogicCircuit/Schema/ConvertFrom.2.0.0.13.xslt:
--------------------------------------------------------------------------------
1 |
2 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
--------------------------------------------------------------------------------
/Sources/LogicCircuit/AutoWidthComboBox.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Windows;
3 | using System.Windows.Controls;
4 | using System.Windows.Controls.Primitives;
5 |
6 | namespace LogicCircuit {
7 | public class AutoWidthComboBox : ComboBox {
8 | public AutoWidthComboBox() {
9 | this.Loaded += (object sender, RoutedEventArgs e) => {
10 | if(this.GetTemplateChild("PART_Popup") is Popup popup) {
11 | UIElement child = popup.Child;
12 | child.Measure(new Size(double.PositiveInfinity, double.PositiveInfinity));
13 | this.MinWidth = Math.Max(this.MinWidth, child.DesiredSize.Width + ((this.GetTemplateChild("toggleButton") is FrameworkElement button) ? button.DesiredSize.Width : 20));
14 | }
15 | };
16 | }
17 | }
18 | }
19 |
--------------------------------------------------------------------------------
/Sources/Tools/ItemWrapper.Generator/Error.cs:
--------------------------------------------------------------------------------
1 | using System.Diagnostics.CodeAnalysis;
2 | using System.Globalization;
3 |
4 | namespace ItemWrapper.Generator {
5 | [SuppressMessage("Design", "CA1032:Implement standard exception constructors")]
6 | public class GeneratorException : Exception {
7 | public GeneratorException(string message) : base(message) { }
8 | public GeneratorException(string format, params object[] args) : this(string.Format(CultureInfo.InvariantCulture, format, args)) { }
9 | }
10 |
11 | [SuppressMessage("Design", "CA1032:Implement standard exception constructors")]
12 | public class UsageException : GeneratorException {
13 | public UsageException(string format, params object[] args) : base(format, args) { }
14 | }
15 | }
16 |
--------------------------------------------------------------------------------
/Sources/LogicCircuit/Icon/CircuitPower.xaml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
--------------------------------------------------------------------------------
/Sources/LogicCircuit/Function/FunctionRam.cs:
--------------------------------------------------------------------------------
1 | using System;
2 |
3 | namespace LogicCircuit {
4 | public class FunctionRam : FunctionMemory {
5 | public FunctionRam(CircuitState circuitState, int[] address, int[] inputData, int[] outputData, int[]? address2, int[]? outputData2, int write, Memory memory) : base(
6 | circuitState, address, inputData, outputData, address2, outputData2, write, memory
7 | ) {
8 | }
9 |
10 | public override bool Evaluate() {
11 | if(this.IsWriteAllowed()) {
12 | this.Write();
13 | }
14 | return this.Read();
15 | }
16 |
17 | public override string ReportName { get { return Properties.Resources.ReportMemoryName(Properties.Resources.RAMNotation, this.AddressBitWidth, this.DataBitWidth); } }
18 | }
19 | }
20 |
--------------------------------------------------------------------------------
/Sources/LogicCircuit/Schema/ConvertFrom.1.0.0.2.xslt:
--------------------------------------------------------------------------------
1 |
2 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
--------------------------------------------------------------------------------
/Sources/LogicCircuit/Schema/ConvertFrom.2.0.0.1.xslt:
--------------------------------------------------------------------------------
1 |
2 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
--------------------------------------------------------------------------------
/Sources/LogicCircuit/Schema/ConvertFrom.2.0.0.2.xslt:
--------------------------------------------------------------------------------
1 |
2 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
--------------------------------------------------------------------------------
/Sources/LogicCircuit/Schema/ConvertFrom.2.0.0.4.xslt:
--------------------------------------------------------------------------------
1 |
2 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
--------------------------------------------------------------------------------
/Sources/LogicCircuit/CircuitProject/NamedItemSet.cs:
--------------------------------------------------------------------------------
1 | using System;
2 |
3 | namespace LogicCircuit {
4 | public abstract class NamedItemSet {
5 | protected abstract bool Exists(string name);
6 | protected abstract bool Exists(string name, Circuit group);
7 |
8 | public string UniqueName(string prefix) {
9 | string uniqueName = prefix;
10 | int order = 1;
11 | while(this.Exists(uniqueName)) {
12 | uniqueName = prefix + order++;
13 | }
14 | return uniqueName;
15 | }
16 |
17 | public string UniqueName(string prefix, Circuit group) {
18 | string uniqueName = prefix;
19 | int order = 1;
20 | while(this.Exists(uniqueName, group)) {
21 | uniqueName = prefix + order++;
22 | }
23 | return uniqueName;
24 | }
25 | }
26 | }
27 |
--------------------------------------------------------------------------------
/Sources/LogicCircuit/Function/OneBitConst.cs:
--------------------------------------------------------------------------------
1 | using System;
2 |
3 | namespace LogicCircuit {
4 | public class OneBitConst : CircuitFunction {
5 | private State state;
6 | public State State { get { return this.state; } }
7 | public void SetState(State newState) {
8 | if(this.state != newState) {
9 | this.state = newState;
10 | this.CircuitState.MarkUpdated(this);
11 | }
12 | }
13 |
14 | public OneBitConst(CircuitState circuitState, State state, int result) : base(circuitState, null, new int[] { result }) {
15 | this.state = state;
16 | }
17 | public override bool Evaluate() {
18 | return this.SetResult0(this.state);
19 | }
20 |
21 | public override string ReportName { get { throw new InvalidOperationException(); } }
22 | }
23 | }
24 |
--------------------------------------------------------------------------------
/Sources/LogicCircuit/Icon/Question.xaml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
--------------------------------------------------------------------------------
/Sources/LogicCircuit/DoubleAdderConverter.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Globalization;
3 | using System.Windows.Data;
4 |
5 | namespace LogicCircuit {
6 | public class DoubleAdderConverter : IValueConverter {
7 | public object Convert(object value, Type targetType, object parameter, CultureInfo culture) {
8 | if(targetType == typeof(double) && value is double && parameter != null) {
9 | double delta;
10 | if(!double.TryParse(parameter.ToString(), out delta)) {
11 | delta = 0;
12 | }
13 | return Math.Max(0, (double)value + delta);
14 | }
15 | return value;
16 | }
17 |
18 | public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture) {
19 | throw new InvalidOperationException();
20 | }
21 | }
22 | }
23 |
--------------------------------------------------------------------------------
/Sources/LogicCircuit/Icon/EditJustify.xaml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
--------------------------------------------------------------------------------
/Sources/LogicCircuit/CircuitProject/CircuitSymbolComparer.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Diagnostics;
4 |
5 | namespace LogicCircuit {
6 | public class CircuitSymbolComparer : IComparer {
7 |
8 | private readonly bool yPrecedence;
9 |
10 | public CircuitSymbolComparer(bool yPrecedence) {
11 | this.yPrecedence = yPrecedence;
12 | }
13 |
14 | public int Compare(CircuitSymbol? x, CircuitSymbol? y) {
15 | Debug.Assert(x != null && y != null);
16 | if(this.yPrecedence) {
17 | int d = x.Y - y.Y;
18 | if(d == 0) {
19 | d = x.X - y.X;
20 | }
21 | return d;
22 | } else {
23 | int d = x.X - y.X;
24 | if(d == 0) {
25 | d = x.Y - y.Y;
26 | }
27 | return d;
28 | }
29 | }
30 | }
31 | }
32 |
--------------------------------------------------------------------------------
/Sources/LogicCircuit/SymbolShapes/CircuitAlu.xaml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
--------------------------------------------------------------------------------
/Sources/LogicCircuit/ColorPicker/HueToColorConverter.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Globalization;
3 | using System.Windows.Data;
4 | using System.Windows.Media;
5 |
6 | namespace LogicCircuit {
7 | [ValueConversion(typeof(double), typeof(Color))]
8 | public class HueToColorConverter : IValueConverter {
9 | public object? Convert(object value, Type targetType, object parameter, CultureInfo culture) {
10 | if(value != null && value is double && targetType == typeof(Color)) {
11 | return new HsvColor() { Hue = (double)value, Saturation = 1, Value = 1 }.ToRgb(255);
12 | }
13 | return null;
14 | }
15 |
16 | public object ConvertBack(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture) {
17 | throw new InvalidOperationException();
18 | }
19 | }
20 | }
21 |
--------------------------------------------------------------------------------
/Sources/LogicCircuit/SymbolShapes/Sound.xaml:
--------------------------------------------------------------------------------
1 |
8 |
9 |
10 |
11 |
12 |
13 |
--------------------------------------------------------------------------------
/Sources/LogicCircuit.UnitTest/HDL/HdlJam.cs:
--------------------------------------------------------------------------------
1 | // Ignore Spelling: Hdl
2 |
3 | namespace LogicCircuit.UnitTest.HDL {
4 | internal class HdlJam : HdlItem {
5 |
6 | public string Name { get; }
7 | public int First { get; }
8 | public int Last { get; }
9 | public bool IsBitRange { get; }
10 |
11 | public HdlJam(HdlContext hdlContext, string name) : base(hdlContext) {
12 | this.Name = name;
13 | }
14 |
15 | public HdlJam(HdlContext hdlContext, string name, int first, int last) : this(hdlContext, name) {
16 | this.First = first;
17 | this.Last = last;
18 | this.IsBitRange = true;
19 | }
20 |
21 | public override string ToString() {
22 | string range = this.IsBitRange ? $"[{this.First}{((this.First == this.Last) ? string.Empty : $"..{this.Last}")}]" : string.Empty;
23 | return $"{this.Name}{range}";
24 | }
25 | }
26 | }
27 |
--------------------------------------------------------------------------------
/Sources/Tools/FindUnusedResources/FindUnusedResources.csproj:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | Exe
5 | $(DotNetBaseVersion)
6 | enable
7 | enable
8 |
9 | AllEnabledByDefault
10 | latest-all
11 |
12 | 1.0.0.0
13 | Utility Find Unused Resources
14 | © LogicCircuit.org
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
--------------------------------------------------------------------------------
/Sources/ReleaseCheckList.txt:
--------------------------------------------------------------------------------
1 | 0. Update year in License.txt.
2 | 1. Set version in LogicCircuitVersion property in Directory.Build.props
3 | 2. Set Version in Setup project. Create two new GUIDs for two ProductCode for 32 and 64 bits.
4 | 3. Build Setup by running BuildSetup.cmd from "Developer Command Prompt"
5 | 4. Upload setup zips to downloads folder on the website and download and test them.
6 | 5. Prepare website - add what is new in download.html
7 | 6. Change version attribute in the root of Project.xml.
8 | 7. Fix links on the download .html page to download of the new sample files.
9 | 8. Add News item in Project.xml
10 | 9. Change version in LatestVersion.txt.
11 | 10. Review and update TranslationRequests.txt.
12 | 11. Add tags to repos (both logic circuit and web site)
13 | 12. Push repos to dev.azure and github
14 | 13. Publish web site
15 |
--------------------------------------------------------------------------------
/Sources/Directory.Build.props:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | 2.25.07.10
5 | $(MSBuildThisFileDirectory)Tools
6 | net10.0
7 | $(DotNetBaseVersion)-windows
8 |
9 |
10 |
11 | FileSystem
12 | <_TargetId>Folder
13 |
14 | win-x64
15 | true
16 | false
17 |
18 | $(MSBuildThisFileDirectory)BuildResults
19 |
20 |
21 |
22 |
--------------------------------------------------------------------------------
/Sources/LogicCircuit.UnitTest/HDL/HdlParser.g4:
--------------------------------------------------------------------------------
1 | parser grammar HdlParser;
2 |
3 | options {
4 | tokenVocab = HdlLexer;
5 | }
6 |
7 | @header {
8 | #pragma warning disable 3021
9 | }
10 |
11 | chip: Chip chipName Begin inputPins? outputPins? Parts parts End EOF;
12 |
13 | chipName: Identifier;
14 |
15 | inputPins: In pins;
16 |
17 | outputPins: Out pins;
18 |
19 | pins: ioPin (Comma ioPin)* Semicolon;
20 |
21 | ioPin: pinName (OpenBit DecNumber CloseBit)?;
22 |
23 | pinName: Identifier;
24 |
25 | parts: (part Semicolon)+;
26 |
27 | part: partName Open partConnections Close;
28 |
29 | partName: Identifier;
30 |
31 | partConnections: partConnection (Comma partConnection)*;
32 |
33 | partConnection: jam Equal pin;
34 |
35 | jam: jamName (OpenBit bits CloseBit)?;
36 |
37 | jamName: Identifier;
38 |
39 | bits: DecNumber (Elapse DecNumber)?;
40 |
41 | pin: jam;
42 |
--------------------------------------------------------------------------------
/Sources/LogicCircuit/Dialog/IronPythonConsole.xaml:
--------------------------------------------------------------------------------
1 |
13 |
14 |
15 |
--------------------------------------------------------------------------------
/Sources/LogicCircuit/Dialog/DialogMemory.xaml.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections;
3 | using System.Diagnostics.CodeAnalysis;
4 | using System.Globalization;
5 | using System.Windows;
6 |
7 | namespace LogicCircuit {
8 | ///
9 | /// Interaction logic for DialogMemory.xaml
10 | ///
11 | public partial class DialogMemory : Window {
12 |
13 | private SettingsWindowLocationCache? windowLocation;
14 | public SettingsWindowLocationCache WindowLocation { get { return this.windowLocation ?? (this.windowLocation = new SettingsWindowLocationCache(Settings.User, this)); } }
15 |
16 | public IFunctionMemory FunctionMemory { get; private set; }
17 |
18 | public DialogMemory(IFunctionMemory functionMemory) {
19 | this.FunctionMemory = functionMemory;
20 | this.DataContext = this;
21 | this.InitializeComponent();
22 | }
23 | }
24 | }
25 |
--------------------------------------------------------------------------------
/Sources/LogicCircuit.UnitTest/AssemblyInfo.cs:
--------------------------------------------------------------------------------
1 | using System.Runtime.InteropServices;
2 |
3 | // In SDK-style projects such as this one, several assembly attributes that were historically
4 | // defined in this file are now automatically added during build and populated with
5 | // values defined in project properties. For details of which attributes are included
6 | // and how to customise this process see: https://aka.ms/assembly-info-properties
7 |
8 | // Setting ComVisible to false makes the types in this assembly not visible to COM
9 | // components. If you need to access a type in this assembly from COM, set the ComVisible
10 | // attribute to true on that type.
11 | //[assembly: ComVisible(false)]
12 |
13 | // The following GUID is for the ID of the typelib if this project is exposed to COM.
14 | //[assembly: Guid("433a6259-4245-4b26-be5c-c940e68c8941")]
15 |
16 | [assembly: DoNotParallelize]
17 |
--------------------------------------------------------------------------------
/Sources/LogicCircuit/EnumToVisibilityConvertor.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Globalization;
3 | using System.Windows;
4 | using System.Windows.Data;
5 |
6 | namespace LogicCircuit {
7 | public class EnumToVisibilityConvertor : IValueConverter {
8 | public Visibility HiddenVisibility { get; set; }
9 |
10 | public EnumToVisibilityConvertor() {
11 | this.HiddenVisibility = Visibility.Collapsed;
12 | }
13 |
14 | public object Convert(object value, Type targetType, object parameter, CultureInfo culture) {
15 | Tracer.Assert(targetType == typeof(Visibility));
16 | if(value.Equals(parameter)) {
17 | return Visibility.Visible;
18 | }
19 | return this.HiddenVisibility;
20 | }
21 |
22 | public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture) {
23 | throw new NotSupportedException();
24 | }
25 | }
26 | }
27 |
--------------------------------------------------------------------------------
/Sources/LogicCircuit/Editor/WireDisplayControl.xaml:
--------------------------------------------------------------------------------
1 |
9 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
--------------------------------------------------------------------------------
/Sources/LogicCircuit/ColorPicker/ColorSlider.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Windows;
3 | using System.Windows.Controls;
4 | using System.Windows.Media;
5 |
6 | namespace LogicCircuit {
7 | public class ColorSlider : Slider {
8 | public static readonly DependencyProperty LeftColorProperty = DependencyProperty.Register("LeftColor", typeof(Color), typeof(ColorSlider));
9 | public Color LeftColor {
10 | get { return (Color)this.GetValue(ColorSlider.LeftColorProperty); }
11 | set { this.SetValue(ColorSlider.LeftColorProperty, value); }
12 | }
13 |
14 | public static readonly DependencyProperty RightColorProperty = DependencyProperty.Register("RightColor", typeof(Color), typeof(ColorSlider));
15 | public Color RightColor {
16 | get { return (Color)this.GetValue(ColorSlider.RightColorProperty); }
17 | set { this.SetValue(ColorSlider.RightColorProperty, value); }
18 | }
19 | }
20 | }
21 |
--------------------------------------------------------------------------------
/Sources/LogicCircuit/Settings/SettingsEnumCache.cs:
--------------------------------------------------------------------------------
1 | using System;
2 |
3 | namespace LogicCircuit {
4 | internal class SettingsEnumCache where T:struct {
5 | private readonly Settings settings;
6 | private readonly string key;
7 | private readonly T defaultValue;
8 |
9 | private T cache;
10 | public T Value {
11 | get { return this.cache; }
12 | set {
13 | T t = EnumHelper.IsValid(value) ? value : this.defaultValue;
14 | if(!this.cache.Equals(t)) {
15 | this.cache = t;
16 | this.settings[this.key] = this.cache.ToString();
17 | }
18 | }
19 | }
20 |
21 | public SettingsEnumCache(
22 | Settings settings,
23 | string key,
24 | T defaultValue
25 | ) {
26 | this.settings = settings;
27 | this.key = key;
28 | this.defaultValue = defaultValue;
29 | this.cache = EnumHelper.Parse(this.settings[this.key], this.defaultValue);
30 | }
31 | }
32 | }
33 |
--------------------------------------------------------------------------------
/Sources/LogicCircuit/Settings/SettingsBoolCache.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Globalization;
3 |
4 | namespace LogicCircuit {
5 | internal sealed class SettingsBoolCache {
6 | private readonly Settings settings;
7 | private readonly string key;
8 |
9 | private bool cache;
10 | public bool Value {
11 | get { return this.cache; }
12 | set {
13 | if(this.cache != value) {
14 | this.cache = value;
15 | this.settings[this.key] = this.cache.ToString(CultureInfo.InvariantCulture);
16 | }
17 | }
18 | }
19 |
20 | public SettingsBoolCache(
21 | Settings settings,
22 | string key,
23 | bool defaultValue
24 | ) {
25 | this.settings = settings;
26 | this.key = key;
27 | string? text = this.settings[this.key];
28 | if(string.IsNullOrEmpty(text) || !bool.TryParse(text, out this.cache)) {
29 | this.cache = defaultValue;
30 | }
31 | }
32 | }
33 | }
34 |
--------------------------------------------------------------------------------
/Sources/LogicCircuit/Editor/Marker.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Windows;
3 | using System.Windows.Controls;
4 |
5 | namespace LogicCircuit {
6 | partial class EditorDiagram {
7 | private abstract class Marker {
8 | public Symbol Symbol { get; private set; }
9 | public abstract FrameworkElement Glyph { get; }
10 |
11 | protected Marker(Symbol? symbol) {
12 | this.Symbol = symbol!;
13 | }
14 |
15 | public virtual Rect Bounds() {
16 | return this.Symbol.Bounds();
17 | }
18 |
19 | public virtual void Move(EditorDiagram editor, Point point) {
20 | editor.MoveSelection(point);
21 | }
22 |
23 | public virtual void Commit(EditorDiagram editor, Point point, bool withWires) {
24 | editor.CommitMove(point, withWires);
25 | }
26 |
27 | public virtual void CancelMove(Panel selectionLayer) {
28 | }
29 |
30 | public abstract void Refresh();
31 | }
32 | }
33 | }
34 |
--------------------------------------------------------------------------------
/Sources/LogicCircuit/Schema/ConvertFrom.2.0.0.7.xslt:
--------------------------------------------------------------------------------
1 |
2 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
--------------------------------------------------------------------------------
/Sources/LogicCircuit/SymbolShapes/SensorAuto.xaml:
--------------------------------------------------------------------------------
1 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
--------------------------------------------------------------------------------
/Sources/LogicCircuit/EnumHelper.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Linq;
3 |
4 | namespace LogicCircuit {
5 | internal static class EnumHelper {
6 | private static readonly char[] splitters = [',', ' '];
7 |
8 | public static T Parse(string? text, T defaultValue) where T:struct {
9 | T value;
10 | if(string.IsNullOrWhiteSpace(text) || !Enum.TryParse(text, true, out value) || !IsValid(value)) {
11 | return defaultValue;
12 | }
13 | return value;
14 | }
15 |
16 | public static bool IsValid(T value) where T:struct {
17 | string[] name = Enum.GetNames(typeof(T));
18 | string text = value.ToString()!;
19 | StringComparer comparer = StringComparer.OrdinalIgnoreCase;
20 | if(!name.Contains(text, comparer)) {
21 | string[] part = text.Split(EnumHelper.splitters, StringSplitOptions.RemoveEmptyEntries);
22 | return part.All(p => name.Contains(p, comparer));
23 | }
24 | return true;
25 | }
26 | }
27 | }
28 |
--------------------------------------------------------------------------------
/Sources/LogicCircuit/Icon/EditTextCenter.xaml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
--------------------------------------------------------------------------------
/Sources/LogicCircuit/Schema/ConvertFrom.2.0.0.8.xslt:
--------------------------------------------------------------------------------
1 |
2 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
--------------------------------------------------------------------------------
/Sources/Tools/ItemWrapper.Generator/GeneratorItem.tt:
--------------------------------------------------------------------------------
1 | <#@ template language="C#" debug="True" inherits="Transformation" #>
2 | using System;
3 | using System.Collections.Generic;
4 | using System.Collections.Specialized;
5 | using System.ComponentModel;
6 | using System.Diagnostics;
7 | using System.Globalization;
8 | using System.Linq;
9 | using System.Text;
10 | using <#=this.StoreNameSpace#>;
11 |
12 | // This file is generated by ItemWrapper.Generator. Do not modify this file as it will be regenerated
13 | namespace <#=this.Store.Namespace#> {
14 | <#=
15 | new GeneratorTableDefinition() {
16 | Generator = this.Generator
17 | }.TransformText()
18 | #>
19 | <#if(this.Generator.RealmType != RealmType.None) {#>
20 |
21 | <#=
22 | new GeneratorItemWrapper() {
23 | Generator = this.Generator
24 | }.TransformText()
25 | #>
26 |
27 | <#=
28 | new GeneratorSetWrapper() {
29 | Generator = this.Generator
30 | }.TransformText()
31 | #>
32 | <#}#>
33 | }
34 |
--------------------------------------------------------------------------------
/Sources/LogicCircuit/Function/FunctionXor.cs:
--------------------------------------------------------------------------------
1 | using System;
2 |
3 | namespace LogicCircuit {
4 | public abstract class FunctionXor : CircuitFunction {
5 | public static FunctionXor Create(CircuitState circuitState, int[] parameter, int result) {
6 | return new FunctionXorCommon(circuitState, parameter, result);
7 | }
8 |
9 | protected FunctionXor(CircuitState circuitState, int[] parameter, int result) : base(circuitState, parameter, result) {}
10 |
11 | public override string ReportName { get { return Properties.Resources.ReportGateName(Properties.Resources.GateXorName, this.ParameterCount); } }
12 |
13 | private sealed class FunctionXorCommon : FunctionXor {
14 | public FunctionXorCommon(CircuitState circuitState, int[] parameter, int result) : base(circuitState, parameter, result) {}
15 |
16 | public override bool Evaluate() {
17 | return this.SetResult0(CircuitFunction.FromBool((this.Count(State.On1) & 1) == 1));
18 | }
19 | }
20 | }
21 | }
22 |
--------------------------------------------------------------------------------
/Sources/LogicCircuit/HDL/HdlTransformation.cs:
--------------------------------------------------------------------------------
1 | // Ignore Spelling: Hdl
2 |
3 | using System.Collections.Generic;
4 | using System.Globalization;
5 | using System.Linq;
6 |
7 | namespace LogicCircuit {
8 | internal abstract class HdlTransformation : T4Transformation {
9 | public string Name { get; }
10 | public bool CommentPoints { get; set; }
11 | public IEnumerable InputPins { get; }
12 | public IEnumerable OutputPins { get; }
13 | public IEnumerable Parts { get; }
14 | public bool HasInputPins => this.InputPins.Any();
15 | public bool HasOutputPins => this.OutputPins.Any();
16 |
17 | protected HdlTransformation(string name, IEnumerable inputPins, IEnumerable outputPins, IEnumerable parts) {
18 | this.Name = name;
19 | this.InputPins = inputPins;
20 | this.OutputPins = outputPins;
21 | this.Parts = parts;
22 | this.ToStringHelper.FormatProvider = CultureInfo.InvariantCulture;
23 | }
24 | }
25 | }
26 |
--------------------------------------------------------------------------------
/Sources/LogicCircuit/Schema/ConvertFrom.2.0.0.9.xslt:
--------------------------------------------------------------------------------
1 |
2 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
--------------------------------------------------------------------------------
/Sources/LogicCircuit/Schema/ConvertFrom.2.0.0.6.xslt:
--------------------------------------------------------------------------------
1 |
2 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
--------------------------------------------------------------------------------
/Sources/LogicCircuit/Icon/ColorFont.xaml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
--------------------------------------------------------------------------------
/Sources/LogicCircuit/Function/FunctionXorNot.cs:
--------------------------------------------------------------------------------
1 | using System;
2 |
3 | namespace LogicCircuit {
4 | public abstract class FunctionXorNot : CircuitFunction {
5 | public static FunctionXorNot Create(CircuitState circuitState, int[] parameter, int result) {
6 | return new FunctionXorNotCommon(circuitState, parameter, result);
7 | }
8 |
9 | public override string ReportName { get { return Properties.Resources.ReportGateName(Properties.Resources.GateXorNotName, this.ParameterCount); } }
10 |
11 | protected FunctionXorNot(CircuitState circuitState, int[] parameter, int result) : base(circuitState, parameter, result) {}
12 |
13 | private sealed class FunctionXorNotCommon : FunctionXorNot {
14 | public FunctionXorNotCommon(CircuitState circuitState, int[] parameter, int result) : base(circuitState, parameter, result) {}
15 |
16 | public override bool Evaluate() {
17 | return this.SetResult0(CircuitFunction.FromBool((this.Count(State.On1) & 1) != 1));
18 | }
19 | }
20 | }
21 | }
22 |
--------------------------------------------------------------------------------
/Sources/LogicCircuit/Dialog/DialogReport.xaml.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Windows;
3 | using System.Windows.Documents;
4 |
5 | namespace LogicCircuit {
6 | ///
7 | /// Interaction logic for DialogReport.xaml
8 | ///
9 | public partial class DialogReport : Window {
10 |
11 | private SettingsWindowLocationCache? windowLocation;
12 | public SettingsWindowLocationCache WindowLocation { get { return this.windowLocation ?? (this.windowLocation = new SettingsWindowLocationCache(Settings.User, this)); } }
13 |
14 | public FlowDocument Document { get; private set; }
15 |
16 | public DialogReport(LogicalCircuit root) {
17 | this.Document = ReportBuilder.Build(root);
18 | this.DataContext = this;
19 | this.InitializeComponent();
20 | }
21 |
22 | protected override void OnKeyDown(System.Windows.Input.KeyEventArgs e) {
23 | base.OnKeyDown(e);
24 | if(e.Key == System.Windows.Input.Key.Escape) {
25 | this.Close();
26 | }
27 | }
28 | }
29 | }
30 |
--------------------------------------------------------------------------------
/Sources/LogicCircuit/Icon/EditRightJustify.xaml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
--------------------------------------------------------------------------------
/Sources/Tools/ItemWrapper.Generator/GeneratorStore.tt:
--------------------------------------------------------------------------------
1 | <#@ template language="C#" inherits="Transformation" #>
2 | using System;
3 | using System.Collections.Generic;
4 | using System.ComponentModel;
5 | using System.Diagnostics;
6 | using <#=this.StoreNameSpace#>;
7 |
8 | namespace <#=this.Store.Namespace#> {
9 |
10 | partial class <#=this.Store.Name#> : StoreSnapshot {
11 |
12 | <#foreach(Table table in this.Store) {#>
13 | private TableSnapshot<<#=table.Name#>Data> table<#=table.Name#>;
14 | <#}#>
15 |
16 | public <#=this.Store.Name#>() : base() {
17 | // Create all tables
18 | <#foreach(Table table in this.Store) {#>
19 | this.table<#=table.Name#> = <#=table.Name#>Data.CreateTable(this);
20 | <#}#>
21 |
22 | // Create foreign keys
23 | <#foreach(Table table in this.Store) {#>
24 | <#=table.Name#>Data.CreateForeignKeys(this);
25 | <#}#>
26 |
27 | this.FreezeShape();
28 |
29 | // Init the store
30 | this.Init();
31 | }
32 |
33 | partial void Init();
34 | }
35 | }
36 |
--------------------------------------------------------------------------------
/Sources/LogicCircuit/Icon/Delete.xaml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
--------------------------------------------------------------------------------
/Sources/LogicCircuit/Icon/FileSave.xaml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
--------------------------------------------------------------------------------
/Sources/LogicCircuit/Icon/FileClose.xaml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
--------------------------------------------------------------------------------
/Sources/LogicCircuit/Schema/ConvertFrom.2.0.0.10.xslt:
--------------------------------------------------------------------------------
1 |
2 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 | Display
23 |
24 |
25 |
26 |
27 |
--------------------------------------------------------------------------------
/Sources/LogicCircuit/Icon/EditBulletList.xaml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
--------------------------------------------------------------------------------
/Sources/LogicCircuit/Function/FunctionLedMatrixIndividual.cs:
--------------------------------------------------------------------------------
1 | using System.Collections.Generic;
2 |
3 | namespace LogicCircuit {
4 | public class FunctionLedMatrixIndividual : FunctionLedMatrix {
5 | private readonly int[] state;
6 |
7 | public FunctionLedMatrixIndividual(CircuitState circuitState, IEnumerable symbols, int[] parameter) : base(circuitState, symbols, parameter) {
8 | LedMatrix matrix = this.Matrix;
9 | this.state = new int[matrix.Rows * matrix.Columns];
10 | }
11 |
12 | public override void Redraw(bool force) {
13 | if(force) {
14 | for(int i = 0; i < this.state.Length; i++) {
15 | this.state[i] = -1;
16 | }
17 | }
18 | for(int i = 0; i < this.state.Length; i++) {
19 | int value = 0;
20 | for(int j = 0; j < this.BitPerLed; j++) {
21 | if(this[i * this.BitPerLed + j] == State.On1) {
22 | value |= 1 << j;
23 | }
24 | }
25 | if(this.state[i] != value) {
26 | this.state[i] = value;
27 | this.Fill(i, value);
28 | }
29 | }
30 | }
31 | }
32 | }
33 |
--------------------------------------------------------------------------------
/Sources/LogicCircuit/Icon/CircuitPulse.xaml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
--------------------------------------------------------------------------------
/Sources/LogicCircuit/Icon/EditLeftJustify.xaml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
--------------------------------------------------------------------------------
/Sources/LogicCircuit/Icon/EditTextIndent.xaml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
--------------------------------------------------------------------------------
/Sources/LogicCircuit.UnitTest/HDL/HdlErrorListener.cs:
--------------------------------------------------------------------------------
1 | // Ignore Spelling: Hdl
2 |
3 | using Antlr4.Runtime;
4 |
5 | namespace LogicCircuit.UnitTest.HDL {
6 | internal class HdlErrorListener : BaseErrorListener, IAntlrErrorListener {
7 | private readonly HdlContext context;
8 | private readonly string file;
9 |
10 | public HdlErrorListener(HdlContext context, string file) {
11 | this.context = context;
12 | this.file = file;
13 | }
14 |
15 | public override void SyntaxError(TextWriter output, IRecognizer recognizer, IToken offendingSymbol, int line, int charPositionInLine, string msg, RecognitionException e) {
16 | this.context.Error(this.Message(line, charPositionInLine + 1, msg));
17 | }
18 |
19 | public void SyntaxError(TextWriter output, IRecognizer recognizer, int offendingSymbol, int line, int charPositionInLine, string msg, RecognitionException e) {
20 | this.context.Error(this.Message(line, charPositionInLine + 1, msg));
21 | }
22 |
23 | private string Message(int line, int column, string message) => $"{this.file} ({line}, {column}): Syntax error: {message}";
24 | }
25 | }
26 |
--------------------------------------------------------------------------------
/Sources/LogicCircuit/DataPersistent/RowIdPseudoField.cs:
--------------------------------------------------------------------------------
1 | using System;
2 |
3 | namespace DataPersistent {
4 | partial class SnapTable {
5 | ///
6 | /// Pseudo field to use in .
7 | ///
8 | internal sealed class RowIdPseudoField : IField {
9 | public static readonly RowIdPseudoField Field = new RowIdPseudoField();
10 |
11 | public RowId DefaultValue => RowId.Empty;
12 |
13 | public RowId GetValue(ref TRecord record) {
14 | throw new InvalidOperationException();
15 | }
16 |
17 | public void SetValue(ref TRecord record, RowId value) {
18 | throw new InvalidOperationException();
19 | }
20 |
21 | public string Name => "RowIdPseudoField";
22 |
23 | public int Order {
24 | get => -1;
25 | set => throw new InvalidOperationException();
26 | }
27 |
28 | public int Compare(ref TRecord data1, ref TRecord data2) {
29 | throw new InvalidOperationException();
30 | }
31 |
32 | public int Compare(RowId x, RowId y) => x.CompareTo(y);
33 | }
34 | }
35 | }
36 |
--------------------------------------------------------------------------------
/Sources/LogicCircuit/Icon/EditIncreaseFontSize.xaml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
--------------------------------------------------------------------------------
/Sources/LogicCircuit/Icon/EditDecreaseFontSize.xaml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
--------------------------------------------------------------------------------
/Sources/LogicCircuit/Icon/EditCopy.xaml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
--------------------------------------------------------------------------------
/Sources/LogicCircuit/Settings/SettingsDateTimeCache.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Globalization;
3 |
4 | namespace LogicCircuit {
5 | internal sealed class SettingsDateTimeCache {
6 | private readonly Settings settings;
7 | private readonly string key;
8 |
9 | private DateTime cache;
10 | public DateTime Value {
11 | get { return this.cache; }
12 | set {
13 | if(this.cache != value) {
14 | this.cache = value;
15 | this.settings[this.key] = this.cache.ToString("s", CultureInfo.InvariantCulture);
16 | }
17 | }
18 | }
19 |
20 | public SettingsDateTimeCache(
21 | Settings settings,
22 | string key,
23 | DateTime defaultValue
24 | ) {
25 | this.settings = settings;
26 | this.key = key;
27 | string? text = this.settings[this.key];
28 | DateTime value;
29 | if( string.IsNullOrEmpty(text) ||
30 | !DateTime.TryParseExact(text, "s", CultureInfo.InvariantCulture,
31 | DateTimeStyles.AssumeUniversal | DateTimeStyles.NoCurrentDateDefault,
32 | out value
33 | )
34 | ) {
35 | value = defaultValue;
36 | }
37 | this.cache = value;
38 | }
39 | }
40 | }
41 |
--------------------------------------------------------------------------------
/Sources/LogicCircuit/Icon/EditRotateRight.xaml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
--------------------------------------------------------------------------------
/Sources/LogicCircuit/Icon/F1Help.xaml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
--------------------------------------------------------------------------------
/Sources/LogicCircuit.UnitTest/HDL/HdlIOPin.cs:
--------------------------------------------------------------------------------
1 | // Ignore Spelling: Hdl
2 |
3 | using System.Diagnostics;
4 |
5 | namespace LogicCircuit.UnitTest.HDL {
6 | internal class HdlIOPin : HdlItem {
7 | internal enum PinType {
8 | Input,
9 | Output,
10 | Internal,
11 | }
12 |
13 | public HdlChip Chip { get; }
14 | public string Name { get; }
15 | public int BitWidth { get; }
16 | public int Index { get; }
17 | public PinType Type { get; }
18 |
19 | public HdlIOPin(HdlContext hdlContext, HdlChip chip, string name, int bitWidth, PinType type) : base(hdlContext) {
20 | Debug.Assert(0 < bitWidth);
21 | this.Chip = chip;
22 | this.Name = name;
23 | this.BitWidth = bitWidth;
24 | this.Index = this.Chip.PinsCount;
25 | this.Type = type;
26 | }
27 |
28 | public HdlIOPin(HdlContext hdlContext, int index, string name, int bitWidth, PinType type) : base(hdlContext) {
29 | Debug.Assert(0 < bitWidth);
30 | this.Name = name;
31 | this.BitWidth = bitWidth;
32 | this.Index = index;
33 | this.Type = type;
34 | }
35 |
36 | public override string ToString() {
37 | return (1 != this.BitWidth) ? $"{this.Name}[{this.BitWidth}]" : this.Name;
38 | }
39 | }
40 | }
41 |
--------------------------------------------------------------------------------
/Sources/LogicCircuit/Icon/CircuitTable.xaml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
--------------------------------------------------------------------------------
/Sources/LogicCircuit/Icon/EditTextOutdent.xaml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
--------------------------------------------------------------------------------
/Sources/LogicCircuit/TruthTableFilterParser.g4:
--------------------------------------------------------------------------------
1 | parser grammar TruthTableFilterParser;
2 |
3 | options {
4 | tokenVocab = TruthTableFilterLexer;
5 | }
6 |
7 | filter: function* expr EOF;
8 |
9 | function: Identifier parameters? Colon expr;
10 |
11 | parameters: Open Identifier (Comma Identifier)* Close;
12 |
13 | expr: Open expr Close #ParenExpr
14 | | (Add | Not) expr #Unary
15 | | left=expr op=BitShift right=expr #Bin
16 | | left=expr op=BitAnd right=expr #Bin
17 | | left=expr op=BitXor right=expr #Bin
18 | | left=expr op=BitOr right=expr #Bin
19 | | left=expr op=Mul right=expr #Bin
20 | | left=expr op=Add right=expr #Bin
21 | | left=expr op=Compare right=expr #Bin
22 | | left=expr op=Equality right=expr #Bin
23 | | left=expr op=BoolAnd right=expr #Bin
24 | | left=expr op=BoolOr right=expr #Bin
25 | | NumberLiteral #Literal
26 | | Identifier #Variable // this case is variable or function call without parameters
27 | | String #Variable
28 | | functionCall #Call
29 | ;
30 |
31 | // This is syntax of function calls with parameters.
32 | // Functions calls without parameters are taken care in variable visitor
33 | functionCall: Identifier Open expr (Comma expr)* Close;
34 |
--------------------------------------------------------------------------------
/Sources/LogicCircuit.slnx:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
--------------------------------------------------------------------------------
/Sources/LogicCircuit/Dialog/DialogProbeHistory.xaml:
--------------------------------------------------------------------------------
1 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
21 |
24 |
25 |
26 |
--------------------------------------------------------------------------------
/Sources/LogicCircuit/Icon/EditPaste.xaml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
--------------------------------------------------------------------------------
/Sources/LogicCircuit/SymbolShapes/SensorManual.xaml:
--------------------------------------------------------------------------------
1 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
27 |
28 |
29 |
30 |
--------------------------------------------------------------------------------
/Sources/LogicCircuit/Dialog/ControlPinOrder.xaml:
--------------------------------------------------------------------------------
1 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
--------------------------------------------------------------------------------
/Sources/LogicCircuit/Icon/EditRotateLeft.xaml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
--------------------------------------------------------------------------------
/Sources/LogicCircuit/Icon/FileOpen.xaml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
--------------------------------------------------------------------------------
/Sources/LogicCircuit/DataPersistent/SnapStoreException.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Diagnostics.CodeAnalysis;
3 |
4 | namespace DataPersistent {
5 | [SuppressMessage("Microsoft.Design", "CA1032:ImplementStandardExceptionConstructors")]
6 | [SuppressMessage("Microsoft.Usage", "CA2237:MarkISerializableTypesWithSerializable")]
7 | public class SnapStoreException : Exception {
8 | public SnapStoreException(string message) : base(message) {
9 | }
10 | }
11 |
12 | [SuppressMessage("Microsoft.Design", "CA1032:ImplementStandardExceptionConstructors")]
13 | public class UniqueViolationException : SnapStoreException {
14 | public string ConstraintName { get; private set; }
15 | public UniqueViolationException(string name) : base(Properties.Resources.UniqueConstraintViolation(name)) {
16 | this.ConstraintName = name;
17 | }
18 | }
19 |
20 | [SuppressMessage("Microsoft.Design", "CA1032:ImplementStandardExceptionConstructors")]
21 | public class ForeignKeyViolationException : SnapStoreException {
22 | public string ConstraintName { get; private set; }
23 | public ForeignKeyViolationException(string name) : base(Properties.Resources.ForeignKeyViolation(name)) {
24 | this.ConstraintName = name;
25 | }
26 | }
27 | }
28 |
--------------------------------------------------------------------------------
/Sources/LogicCircuit/TruthTableFilterLexer.g4:
--------------------------------------------------------------------------------
1 | lexer grammar TruthTableFilterLexer;
2 |
3 | Open: '(';
4 | Close: ')';
5 | Colon: ':';
6 | Comma: ',';
7 |
8 | Add: [+-];
9 | Mul: [*/%];
10 | Not: [!~];
11 |
12 | BoolAnd: '&&';
13 | BoolOr: '||';
14 |
15 | BitAnd: '&';
16 | BitOr: '|';
17 | BitXor: '^';
18 | BitShift: '<<' | '>>';
19 |
20 | Equality: '==' | '=' | '!=' | '<>';
21 | Compare: '<' | '<=' | '>=' | '>';
22 |
23 | NumberLiteral: BinNumber | HexNumber | OctaNumber | DecNumber;
24 | String: '"' ('\\"' | .)*? '"';
25 |
26 | Identifier: Letter (Letter | DecDigit)*;
27 |
28 | fragment
29 | Letter: [_a-zA-Z];
30 |
31 | fragment
32 | BinNumber: ('0b' | '0B') BinDigit (NumberDecorator? BinDigit)*;
33 |
34 | fragment
35 | HexNumber: ('0x' | '0X') HexDigit (NumberDecorator? HexDigit)*;
36 |
37 | fragment
38 | OctaNumber: '0' (NumberDecorator? OctaDigit)*;
39 |
40 | fragment
41 | DecNumber: NonzeroDigit (NumberDecorator? DecDigit)*;
42 |
43 | fragment
44 | BinDigit: [01];
45 |
46 | fragment
47 | OctaDigit: [0-7];
48 |
49 | fragment
50 | HexDigit: [0-9a-fA-F];
51 |
52 | fragment
53 | DecDigit: [0-9];
54 |
55 | fragment
56 | NonzeroDigit: [1-9];
57 |
58 | fragment
59 | NumberDecorator: [_'];
60 |
61 | Whitespace: [ \t\u000C\r\n]+ -> skip;
62 | BlockComment: '/*' .*? '*/' -> skip;
63 |
--------------------------------------------------------------------------------
/Sources/ToDoList.txt:
--------------------------------------------------------------------------------
1 | ToDo list:
2 |
3 | smarter wires
4 | Tunnels
5 |
6 | hdl: convert to and logical circuit in it.
7 | FPGA
8 |
9 | Colors of symbols
10 |
11 | === Function Optimization Ideas ===
12 | Local optimizations.
13 | Local optimizations applicable to individual basic block, so the blocks without any extra receivers in the middle.
14 |
15 | Note that constant folding is not applicable as there no compile time constants in the logic circuit.
16 | Remove double NOTs if there is no another receiver between them.
17 | Remove or simplify functions receiving same parameter.
18 | Simplify Function followed by another function if there is no another receiver between them.
19 | Eliminate common sub expressions.
20 | Grouping up few primitive functions to complex one (dynamically built?) if there is no another receivers in the middle.
21 |
22 | Global optimizations.
23 |
24 |
25 | === Feature not implementing ===
26 | Power up root: to much hassle to start up the runtime.
27 | For example if user has circuit that is not on the execution tree. or when the execution tree has multiple of current circuits.
28 |
29 | Backward navigation on circuits
30 | It is already implemented ad Ctrl-Tab and Ctrl-Shift-Tab
31 | Keyboard device - can be built with displays feature
32 |
--------------------------------------------------------------------------------
/Sources/LogicCircuit/Settings/SettingsIntegerCache.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Globalization;
3 |
4 | namespace LogicCircuit {
5 | public class SettingsIntegerCache {
6 | private readonly Settings settings;
7 | private readonly string key;
8 | private readonly int minimum;
9 | private readonly int maximum;
10 |
11 | private int cache;
12 | public int Value {
13 | get { return this.cache; }
14 | set {
15 | int number = Math.Max(this.minimum, Math.Min(value, this.maximum));
16 | if(this.cache != number) {
17 | this.cache = number;
18 | this.settings[this.key] = this.cache.ToString(CultureInfo.InvariantCulture);
19 | }
20 | }
21 | }
22 |
23 | public SettingsIntegerCache(
24 | Settings settings,
25 | string key,
26 | int minimum,
27 | int maximum,
28 | int defaultValue
29 | ) {
30 | Tracer.Assert(minimum <= maximum);
31 | this.settings = settings;
32 | this.key = key;
33 | this.minimum = minimum;
34 | this.maximum = maximum;
35 | string? text = this.settings[this.key];
36 | int value;
37 | if(string.IsNullOrEmpty(text) || !int.TryParse(text, out value)) {
38 | value = defaultValue;
39 | }
40 | this.cache = Math.Max(this.minimum, Math.Min(value, this.maximum));
41 | }
42 | }
43 | }
44 |
--------------------------------------------------------------------------------
/Sources/LogicCircuit/OneToMany.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 |
4 | namespace LogicCircuit {
5 | public class OneToMany : Dictionary> where TOne : notnull where TMany : notnull {
6 | private readonly Func> createCollection;
7 | private readonly Func, TMany, bool> add;
8 |
9 | public OneToMany(bool uniqueCollection) {
10 | this.createCollection = uniqueCollection ? () => new HashSet() : () => new List();
11 | this.add = uniqueCollection ? (collection, item) => ((HashSet)collection).Add(item) : (collection, item) => { collection.Add(item); return true; };
12 | }
13 |
14 | public OneToMany() : this(false) {
15 | }
16 |
17 | public bool Add(TOne key, TMany value) {
18 | ICollection? list;
19 | if(!this.TryGetValue(key, out list)) {
20 | list = this.createCollection();
21 | this.Add(key, list);
22 | }
23 | return this.add(list, value);
24 | }
25 |
26 | public bool Remove(TOne key, TMany value) {
27 | ICollection? list;
28 | if(this.TryGetValue(key, out list)) {
29 | bool result = list.Remove(value);
30 | if(list.Count == 0) {
31 | this.Remove(key);
32 | }
33 | return result;
34 | }
35 | return false;
36 | }
37 | }
38 | }
39 |
--------------------------------------------------------------------------------
/Sources/LogicCircuit/GridPoint.cs:
--------------------------------------------------------------------------------
1 | using System;
2 |
3 | namespace LogicCircuit {
4 | public readonly struct GridPoint : IEquatable {
5 | public int X { get; }
6 | public int Y { get; }
7 |
8 | public GridPoint(int x, int y) : this() {
9 | this.X = x;
10 | this.Y = y;
11 | }
12 |
13 | public static bool operator ==(GridPoint point1, GridPoint point2) {
14 | return point1.X == point2.X && point1.Y == point2.Y;
15 | }
16 |
17 | public static bool operator !=(GridPoint point1, GridPoint point2) {
18 | return point1.X != point2.X || point1.Y != point2.Y;
19 | }
20 |
21 | public override bool Equals(object? obj) {
22 | if((obj == null) || !(obj is GridPoint)) {
23 | return false;
24 | }
25 | GridPoint point = (GridPoint)obj;
26 | return this == point;
27 | }
28 |
29 | public bool Equals(GridPoint other) => this == other;
30 |
31 | public override int GetHashCode() {
32 | return this.X ^ this.Y;
33 | }
34 |
35 | // This is used to display coordinates to user. Do not make it debug only.
36 | public override string ToString() {
37 | return Properties.Resources.GridPoint(this.X, this.Y);
38 | }
39 |
40 | public GridPoint Offset(int x, int y) {
41 | return new GridPoint(this.X + x, this.Y + y);
42 | }
43 | }
44 | }
45 |
--------------------------------------------------------------------------------
/Sources/LogicCircuit/CircuitProject/SensorPoint.cs:
--------------------------------------------------------------------------------
1 | using System;
2 |
3 | namespace LogicCircuit {
4 | public struct SensorPoint : IEquatable {
5 | public int Tick { get; private set; }
6 | public int Value { get; private set; }
7 |
8 | public SensorPoint(int tick, int value) : this() {
9 | this.Tick = tick;
10 | this.Value = value;
11 | }
12 |
13 | public static bool operator ==(SensorPoint point1, SensorPoint point2) {
14 | return point1.Tick == point2.Tick && point1.Value == point2.Value;
15 | }
16 |
17 | public static bool operator !=(SensorPoint point1, SensorPoint point2) {
18 | return point1.Tick != point2.Tick || point1.Value != point2.Value;
19 | }
20 |
21 | public override bool Equals(object? obj) {
22 | if((obj == null) || !(obj is SensorPoint)) {
23 | return false;
24 | }
25 | SensorPoint point = (SensorPoint)obj;
26 | return this == point;
27 | }
28 |
29 | public bool Equals(SensorPoint other) => this == other;
30 |
31 | public override int GetHashCode() {
32 | return this.Tick ^ this.Value;
33 | }
34 |
35 | #if DEBUG
36 | public override string ToString() {
37 | return string.Format(System.Globalization.CultureInfo.InvariantCulture, "{0:X}:{1:X}", this.Tick, this.Value);
38 | }
39 | #endif
40 | }
41 | }
42 |
--------------------------------------------------------------------------------
/Sources/LogicCircuit/DataPersistent/IntArray.cs:
--------------------------------------------------------------------------------
1 | using System;
2 |
3 | namespace DataPersistent {
4 | internal sealed class IntArray {
5 | public static readonly IField Field = new IntField();
6 |
7 | private sealed class IntField : IField {
8 | public string Name => "Int";
9 |
10 | public int Order { get; set; }
11 |
12 | public int DefaultValue => 0;
13 |
14 | public int GetValue(ref int record) => record;
15 |
16 | public void SetValue(ref int record, int value) => record = value;
17 |
18 | public int Compare(ref int data1, ref int data2) => Math.Sign((long)data1 - (long)data2);
19 |
20 | public int Compare(int x, int y) => Math.Sign((long)x - (long)y);
21 | }
22 |
23 | private readonly SnapTable table;
24 |
25 | public IntArray(SnapStore store, string name, int size) {
26 | this.table = new SnapTable(store, name, size, new IField[] { IntArray.Field }, false);
27 | }
28 |
29 | public int Length => this.table.LatestCount(); // Note! The length of the table is never changed.
30 |
31 | public int Value(int index, int version) => this.table.GetField(new RowId(index), IntArray.Field, version);
32 |
33 | public void SetValue(int index, int value) => this.table.SetField(new RowId(index), IntArray.Field, value);
34 | }
35 | }
36 |
--------------------------------------------------------------------------------
/Sources/LogicCircuit/Dialog/DialogProject.xaml:
--------------------------------------------------------------------------------
1 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
--------------------------------------------------------------------------------
/Sources/LogicCircuit/SymbolShapes/ShapedAnd.xaml:
--------------------------------------------------------------------------------
1 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
29 |
30 |
31 |
32 |
33 |
--------------------------------------------------------------------------------
/Sources/LogicCircuit/Dialog/DialogSound.xaml:
--------------------------------------------------------------------------------
1 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
--------------------------------------------------------------------------------
/Sources/LogicCircuit/HyperlinkNavigationCommand.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Diagnostics;
3 | using System.Diagnostics.CodeAnalysis;
4 | using System.Windows.Input;
5 |
6 | namespace LogicCircuit {
7 | [SuppressMessage("Microsoft.Performance", "CA1812:AvoidUninstantiatedInternalClasses")]
8 | internal sealed class HyperlinkNavigationCommand : ICommand {
9 |
10 | #pragma warning disable CS0067 // The event 'HyperlinkNavigationCommand.CanExecuteChanged' is never used
11 | public event EventHandler? CanExecuteChanged;
12 | #pragma warning restore CS0067 // The event 'HyperlinkNavigationCommand.CanExecuteChanged' is never used
13 |
14 | public bool CanExecute(object? parameter) {
15 | return true;
16 | }
17 |
18 | public void Execute(object? parameter) {
19 | try {
20 | Uri? uri = parameter as Uri;
21 | if(uri != null && !uri.IsFile && !uri.IsUnc &&
22 | (StringComparer.OrdinalIgnoreCase.Equals(uri.Scheme, Uri.UriSchemeHttp) || StringComparer.OrdinalIgnoreCase.Equals(uri.Scheme, Uri.UriSchemeHttps))
23 | ) {
24 | ProcessStartInfo psi = new ProcessStartInfo(uri.AbsoluteUri);
25 | psi.UseShellExecute = true;
26 | Process.Start(psi);
27 | }
28 | } catch(Exception exception) {
29 | App.Mainframe.ErrorMessage(Properties.Resources.ErrorUnsupportedUri, exception);
30 | }
31 | }
32 | }
33 | }
34 |
--------------------------------------------------------------------------------
/Sources/LogicCircuit/Icon/Image.xaml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
--------------------------------------------------------------------------------
/Sources/LogicCircuit/ButtonControl.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Windows;
3 | using System.Windows.Controls;
4 | using System.Windows.Input;
5 |
6 | namespace LogicCircuit {
7 | public class ButtonControl : Button {
8 | public Action? ButtonStateChanged { get; set; }
9 |
10 | public ButtonControl() : base() {
11 | //this.ButtonStateChanged = null;
12 | }
13 |
14 | protected override void OnMouseDown(MouseButtonEventArgs e) {
15 | if(this.ButtonStateChanged != null) {
16 | base.OnMouseDown(e);
17 | }
18 | }
19 | protected override void OnMouseUp(MouseButtonEventArgs e) {
20 | if(this.ButtonStateChanged != null) {
21 | base.OnMouseUp(e);
22 | }
23 | }
24 | protected override void OnMouseLeftButtonDown(MouseButtonEventArgs e) {
25 | if(this.ButtonStateChanged != null) {
26 | base.OnMouseLeftButtonDown(e);
27 | }
28 | }
29 | protected override void OnMouseLeftButtonUp(MouseButtonEventArgs e) {
30 | if(this.ButtonStateChanged != null) {
31 | base.OnMouseLeftButtonUp(e);
32 | }
33 | }
34 | protected override void OnIsPressedChanged(DependencyPropertyChangedEventArgs e) {
35 | Action? action = this.ButtonStateChanged;
36 | if(action != null) {
37 | base.OnIsPressedChanged(e);
38 |
39 | action((CircuitSymbol)this.DataContext, this.IsPressed);
40 | }
41 | }
42 | }
43 | }
44 |
--------------------------------------------------------------------------------
/Sources/LogicCircuit/CircuitProject/PinComparer.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Diagnostics;
4 | using System.Linq;
5 |
6 | namespace LogicCircuit {
7 | internal sealed class PinComparer : IComparer {
8 | public static readonly PinComparer Comparer = new PinComparer();
9 |
10 | public int Compare(BasePin? x, BasePin? y) {
11 | Debug.Assert(x != null && y != null);
12 | Tracer.Assert(x.GetType() == y.GetType());
13 | if(x is DevicePin dp1) {
14 | DevicePin dp2 = (DevicePin)y;
15 | return dp1.Order - dp2.Order;
16 | } else {
17 | Pin xp = (Pin)x;
18 | Pin yp = (Pin)y;
19 | int index = xp.Index - yp.Index;
20 | if(0 == index) {
21 | CircuitSymbolSet symbolSet = x.CircuitProject.CircuitSymbolSet;
22 | Tracer.Assert(symbolSet == y.CircuitProject.CircuitSymbolSet);
23 | CircuitSymbol? s1 = symbolSet.SelectByCircuit(x).FirstOrDefault();
24 | CircuitSymbol? s2 = symbolSet.SelectByCircuit(y).FirstOrDefault();
25 | if(s1 != null && s2 != null) {
26 | int d = s1.Y - s2.Y;
27 | if(d == 0) {
28 | d = s1.X - s2.X;
29 | if(d == 0) {
30 | return StringComparer.Ordinal.Compare(x.Name, y.Name);
31 | }
32 | }
33 | return d;
34 | }
35 | return StringComparer.Ordinal.Compare(x.Name, y.Name);
36 | }
37 | return index;
38 | }
39 | }
40 | }
41 | }
42 |
--------------------------------------------------------------------------------
/Sources/LogicCircuit/Dialog/DialogProbe.xaml:
--------------------------------------------------------------------------------
1 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
--------------------------------------------------------------------------------
/Sources/LogicCircuit/Conductor.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Linq;
4 |
5 | namespace LogicCircuit {
6 | public class Conductor {
7 |
8 | private readonly HashSet wire = new HashSet();
9 | private readonly Dictionary pointMap = new Dictionary();
10 |
11 | public void Add(Wire item) {
12 | if(this.wire.Add(item)) {
13 | void add(GridPoint point) {
14 | if(this.pointMap.TryGetValue(point, out int count)) {
15 | this.pointMap[point] = count + 1;
16 | } else {
17 | this.pointMap.Add(point, 1);
18 | }
19 | }
20 |
21 | add(item.Point1);
22 | add(item.Point2);
23 | }
24 | }
25 |
26 | public IEnumerable Wires { get { return this.wire; } }
27 | public IEnumerable Points { get { return this.pointMap.Keys; } }
28 |
29 | public bool Contains(GridPoint gridPoint) {
30 | return this.pointMap.ContainsKey(gridPoint);
31 | }
32 |
33 | public bool Contains(Wire symbol) {
34 | return this.wire.Contains(symbol);
35 | }
36 |
37 | public int JunctionCount(GridPoint point) {
38 | if(this.pointMap.TryGetValue(point, out int count)) {
39 | return count;
40 | }
41 | return 0;
42 | }
43 |
44 | public IEnumerable JunctionPoints(int minCount) => this.pointMap.Where(pair => minCount <= pair.Value).Select(pair => pair.Key);
45 | }
46 | }
47 |
--------------------------------------------------------------------------------
/Sources/LogicCircuit/Dialog/ControlFolderSelector.xaml.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Windows;
3 | using System.Windows.Controls;
4 |
5 | namespace LogicCircuit {
6 | ///
7 | /// Interaction logic for ControlFolderSelector.xaml
8 | ///
9 | public partial class ControlFolderSelector : UserControl {
10 | public static readonly DependencyProperty SelectedFolderProperty = DependencyProperty.Register(nameof(SelectedFolder), typeof(string), typeof(ControlFolderSelector));
11 | public string SelectedFolder {
12 | get => (string)this.GetValue(ControlFolderSelector.SelectedFolderProperty);
13 | set => this.SetValue(ControlFolderSelector.SelectedFolderProperty, value);
14 | }
15 |
16 | public LambdaUICommand CommandSelect { get; }
17 |
18 | public ControlFolderSelector() {
19 | this.CommandSelect = new LambdaUICommand(Properties.Resources.CommandEllipsis, o => this.Select());
20 | this.InitializeComponent();
21 | }
22 |
23 | protected override void OnGotFocus(RoutedEventArgs e) {
24 | this.textBoxSelectedFolder.Focus();
25 | }
26 |
27 | private void Select() {
28 | try {
29 | DialogSelectFolder dialog = new DialogSelectFolder();
30 | dialog.FileName = this.SelectedFolder;
31 | if(dialog.ShowDialog(Window.GetWindow(this))) {
32 | this.SelectedFolder = dialog.FileName;
33 | }
34 | } catch(Exception exception) {
35 | App.Mainframe.ReportException(exception);
36 | }
37 | }
38 | }
39 | }
40 |
--------------------------------------------------------------------------------
/Sources/LogicCircuit/Schema/ConvertFrom.2.0.0.3.xslt:
--------------------------------------------------------------------------------
1 |
2 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
29 |
30 |
31 |
32 |
33 |
--------------------------------------------------------------------------------
/Sources/LogicCircuit/CircuitProject/CollapsedCategory.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Diagnostics.CodeAnalysis;
4 | using System.Linq;
5 | using System.Xml;
6 |
7 | namespace LogicCircuit {
8 | public partial class CollapsedCategory {
9 | }
10 |
11 | [SuppressMessage("Microsoft.Naming", "CA1710:IdentifiersShouldHaveCorrectSuffix")]
12 | public sealed partial class CollapsedCategorySet {
13 | public bool IsCollapsed(string name) {
14 | return this.Find(name) != null;
15 | }
16 |
17 | public void SetCollapsed(string name, bool value) {
18 | CollapsedCategory? collapsed = this.Find(name);
19 | if(value && collapsed == null) {
20 | this.CircuitProject.InOmitTransaction(() => this.CreateItem(name));
21 | } else if(!value && collapsed != null) {
22 | this.CircuitProject.InOmitTransaction(() => collapsed.Delete());
23 | }
24 | }
25 |
26 | public void Purge() {
27 | HashSet category = new HashSet(this.CircuitProject.LogicalCircuitSet.Select(c => c.Category));
28 | List list = this.Where(c => !category.Contains(c.Name)).ToList();
29 | foreach(CollapsedCategory collapsed in list) {
30 | collapsed.Delete();
31 | }
32 | }
33 |
34 | public IRecordLoader CreateRecordLoader(XmlNameTable nameTable) {
35 | return new RecordLoader(nameTable, this.Table, rowId => this.Create(rowId));
36 | }
37 | }
38 | }
39 |
--------------------------------------------------------------------------------
/Sources/LogicCircuit/Schema/ConvertSettings.xslt:
--------------------------------------------------------------------------------
1 |
2 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 | Mainframe.Width
18 | Mainframe.Height
19 | Mainframe.WindowState
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
29 |
30 |
31 |
32 |
33 |
34 |
35 |
--------------------------------------------------------------------------------
/Sources/LogicCircuit/Settings/SettingsGridLengthCache.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Windows;
3 |
4 | namespace LogicCircuit {
5 | public class SettingsGridLengthCache {
6 | private readonly Settings settings;
7 | private readonly string key;
8 |
9 | private GridLength cache;
10 | public GridLength Value {
11 | get { return this.cache; }
12 | set {
13 | if(0.0001 <= Math.Abs(this.cache.Value - value.Value)) {
14 | this.cache = value;
15 | this.settings[this.key] = this.cache.ToString();
16 | }
17 | }
18 | }
19 |
20 | public SettingsGridLengthCache(
21 | Settings settings,
22 | string key,
23 | string defaultValue
24 | ) {
25 | this.settings = settings;
26 | this.key = key;
27 | string? text = this.settings[this.key];
28 | if(string.IsNullOrWhiteSpace(text)) {
29 | text = defaultValue;
30 | }
31 | GridLengthConverter converter = new GridLengthConverter();
32 | GridLength original = (GridLength)converter.ConvertFromInvariantString(defaultValue)!;
33 | bool success = false;
34 | try {
35 | this.cache = (GridLength)converter.ConvertFromInvariantString(text)!;
36 | if(this.cache.GridUnitType != original.GridUnitType) {
37 | this.cache = original;
38 | }
39 | success = true;
40 | } catch(NotSupportedException) {
41 | } catch(FormatException) {
42 | }
43 | if(!success) {
44 | this.cache = original;
45 | }
46 | }
47 | }
48 | }
49 |
--------------------------------------------------------------------------------
/Sources/LogicCircuit/Settings/SettingsStringCache.cs:
--------------------------------------------------------------------------------
1 | using System;
2 |
3 | namespace LogicCircuit {
4 | internal sealed class SettingsStringCache {
5 | private readonly Settings settings;
6 | private readonly string key;
7 | private readonly string[]? constraint;
8 | private readonly string defaultValue;
9 |
10 | private string cache;
11 | public string Value {
12 | get { return this.cache; }
13 | set {
14 | string text = this.Normalize(value);
15 | if(!StringComparer.Ordinal.Equals(this.cache, text)) {
16 | this.cache = text;
17 | this.settings[this.key] = this.cache;
18 | }
19 | }
20 | }
21 |
22 | public SettingsStringCache(
23 | Settings settings,
24 | string key,
25 | string? defaultValue,
26 | params string[] constraint
27 | ) {
28 | this.settings = settings;
29 | this.key = key;
30 | this.constraint = (constraint.Length == 0) ? null : constraint;
31 | this.defaultValue = string.Empty;
32 | this.defaultValue = this.Normalize(defaultValue);
33 | this.cache = this.Normalize(this.settings[this.key]);
34 | }
35 |
36 | private string Normalize(string? value) {
37 | string? text = string.IsNullOrEmpty(value) ? null : value.Trim();
38 | if(this.constraint != null) {
39 | if(Array.IndexOf(this.constraint, text) < 0) {
40 | text = null;
41 | }
42 | }
43 | return string.IsNullOrEmpty(text) ? this.defaultValue : text;
44 | }
45 | }
46 | }
47 |
--------------------------------------------------------------------------------
/Sources/LogicCircuit/Dialog/DialogMemory.xaml:
--------------------------------------------------------------------------------
1 |
11 |
12 |
13 |
14 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
29 |
30 |
31 |
32 |
--------------------------------------------------------------------------------
/Sources/LogicCircuit.UnitTest/VisualElementLoadTest.cs:
--------------------------------------------------------------------------------
1 | namespace LogicCircuit.UnitTest {
2 | ///
3 | /// Test of loading of projects with visual elements like 7 segment display.
4 | ///
5 | [STATestClass]
6 | public class VisualElementLoadTest {
7 | ///
8 | ///Gets or sets the test context which provides
9 | ///information about and functionality for the current test run.
10 | ///
11 | public TestContext TestContext { get; set; }
12 |
13 | ///
14 | /// A test for ProjectTester
15 | ///
16 | [STATestMethod]
17 | [DeploymentItem("Properties\\VisualElementLoadTest.CircuitProject")]
18 | public void VisualElementLoadProjectTesterTest() {
19 | ProjectTester tester = new ProjectTester(ProjectTester.LoadDeployedFile(this.TestContext, "VisualElementLoadTest.CircuitProject", null));
20 | Assert.HasCount(1, tester.Input);
21 | Assert.HasCount(1, tester.Output);
22 | Assert.IsTrue(tester.Input.All(f => f != null));
23 | Assert.IsTrue(tester.Output.All(f => f != null));
24 |
25 | Assert.IsTrue(tester.CircuitState.Evaluate(true));
26 | Assert.AreEqual(1, tester.Input[0].Value);
27 | Assert.AreEqual(2, tester.Output[0].Pack());
28 |
29 | tester.CircuitProject.InTransaction(() => tester.Input[0].Value = 0);
30 | Assert.IsTrue(tester.CircuitState.Evaluate(true));
31 | Assert.AreEqual(0, tester.Input[0].Value);
32 | Assert.AreEqual(1, tester.Output[0].Pack());
33 | }
34 | }
35 | }
36 |
--------------------------------------------------------------------------------
/Sources/LogicCircuit/SymbolShapes/ShapedOr.xaml:
--------------------------------------------------------------------------------
1 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
29 |
30 |
31 |
32 |
33 |
--------------------------------------------------------------------------------
/Sources/LogicCircuit/Icon/CircuitProperty.xaml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
--------------------------------------------------------------------------------
/Sources/LogicCircuit/SymbolShapes/SevenSegment.xaml:
--------------------------------------------------------------------------------
1 |
6 |
7 |
13 |
14 |
17 |
18 |
19 |
37 |
38 |
--------------------------------------------------------------------------------
/Sources/LogicCircuit.UnitTest/Properties/From2.0.0.6Conversion.CircuitProject:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | ec8e00a2-6fc9-408a-aefc-dc7ef94c4a41
5 | Test Circuit Project
6 | Project Description
7 | <xml>text</xml>
8 | 81b563d9-6a68-4505-949f-1a0a1d2c9c0f
9 |
10 |
11 | 81b563d9-6a68-4505-949f-1a0a1d2c9c0f
12 | Test Circuit
13 | TC
14 | Test Circuit description
15 | <xml>node</xml>
16 |
17 |
18 | e2877b61-6432-40f3-89e8-da421db42d2b
19 | 81b563d9-6a68-4505-949f-1a0a1d2c9c0f
20 | 1
21 | 1
22 | 21
23 | 4
24 | <FlowDocument PagePadding="5,0,5,0" AllowDrop="True" NumberSubstitution.CultureSource="User" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"><Paragraph>Test of conversion 2.0.0.6 projects</Paragraph><Paragraph>This renames Project and LogicalCircuit Description to Note</Paragraph></FlowDocument>
25 |
26 |
--------------------------------------------------------------------------------
/Sources/LogicCircuit/DisplayCanvas.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Diagnostics.CodeAnalysis;
4 | using System.Windows;
5 | using System.Windows.Controls;
6 |
7 | namespace LogicCircuit {
8 | public class DisplayCanvas : Canvas {
9 | private readonly Dictionary symbolMap = new Dictionary();
10 |
11 | [SuppressMessage("Microsoft.Performance", "CA1800:DoNotCastUnnecessarily")]
12 | public void AddDisplay(CircuitSymbol symbol, FrameworkElement glyph) {
13 | if(symbol.Circuit is LogicalCircuit) {
14 | Tracer.Assert(glyph is DisplayCanvas);
15 | this.symbolMap.Add(symbol, glyph);
16 | } else {
17 | Tracer.Assert(!(glyph is DisplayCanvas));
18 | FrameworkElement probeView = (FrameworkElement)glyph.FindName("ProbeView");
19 | Tracer.Assert(probeView);
20 | this.symbolMap.Add(symbol, probeView);
21 | }
22 | this.Children.Add(glyph);
23 | }
24 |
25 | public FrameworkElement DisplayOf(IList symbol) {
26 | FrameworkElement? glyph = null;
27 | int index = symbol.Count - 1;
28 | while(0 <= index && !this.symbolMap.TryGetValue(symbol[index], out glyph)) {
29 | index--;
30 | }
31 | Tracer.Assert(0 <= index && glyph != null);
32 |
33 | DisplayCanvas canvas = this;
34 | while(0 < index) {
35 | canvas = (DisplayCanvas)canvas.symbolMap[symbol[index]];
36 | index--;
37 | }
38 | return canvas.symbolMap[symbol[0]];
39 | }
40 | }
41 | }
42 |
--------------------------------------------------------------------------------
/Sources/LogicCircuit/Function/Probe.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Diagnostics;
3 | using System.Diagnostics.CodeAnalysis;
4 |
5 | namespace LogicCircuit {
6 | public abstract class Probe : CircuitFunction {
7 | private State[] state;
8 |
9 | protected Probe(CircuitState circuitState, int[] parameter) : base(circuitState, parameter, null) {
10 | this.Init(parameter != null ? parameter.Length : 0);
11 | Debug.Assert(this.state != null);
12 | }
13 | protected Probe(CircuitState circuitState, int parameter) : base(circuitState, new int[] { parameter }, null) {
14 | this.Init(1);
15 | Debug.Assert(this.state != null);
16 | }
17 | private void Init(int count) {
18 | if(0 < count) {
19 | this.state = new State[count];
20 | } else {
21 | this.state = Array.Empty();
22 | }
23 | }
24 |
25 | public string ToText() {
26 | return CircuitFunction.ToText(this.state, false);
27 | }
28 |
29 | [SuppressMessage("Microsoft.Design", "CA1024:UsePropertiesWhereAppropriate")]
30 | protected bool GetState() {
31 | return this.GetProbeState(this.state);
32 | }
33 |
34 | public int BitWidth { get { return this.state != null ? this.state.Length : 0; } }
35 | public State this[int index] { get { return this.state[index]; } }
36 |
37 | protected void CopyTo(State[] copy) {
38 | if(copy == null || copy.Length != this.state.Length) {
39 | throw new ArgumentOutOfRangeException(nameof(copy));
40 | }
41 | this.state.CopyTo(copy, 0);
42 | }
43 | }
44 | }
45 |
--------------------------------------------------------------------------------
/Sources/LogicCircuit/DataPersistent/RowIdField.cs:
--------------------------------------------------------------------------------
1 | namespace DataPersistent {
2 | ///
3 | /// Base class for fields of type RowId to be used as foreign keys to parents tables where pseudo primary key was created with MakeAutoUnique().
4 | ///
5 | ///
6 | public abstract class RowIdField : IField where TRecord: struct {
7 | ///
8 | /// Construct the field with provided name
9 | ///
10 | ///
11 | protected RowIdField(string name) {
12 | this.Name = name;
13 | }
14 |
15 | ///
16 | /// Gets default value of the field. This default value does not correspond to any real record in the parent table and so can be treated as NULL.
17 | ///
18 | public RowId DefaultValue => RowId.Empty;
19 |
20 | public abstract RowId GetValue(ref TRecord record);
21 | public abstract void SetValue(ref TRecord record, RowId value);
22 |
23 | public string Name { get; private set; }
24 |
25 | public int Order { get; set; }
26 |
27 | ///
28 | /// Provides a base definition of the comparison.
29 | ///
30 | ///
31 | ///
32 | ///
33 | public virtual int Compare(ref TRecord data1, ref TRecord data2) {
34 | return this.GetValue(ref data1).CompareTo(this.GetValue(ref data2));
35 | }
36 |
37 | public int Compare(RowId x, RowId y) => x.CompareTo(y);
38 | }
39 | }
40 |
--------------------------------------------------------------------------------
/Sources/LogicCircuit/Dialog/DialogFind.xaml:
--------------------------------------------------------------------------------
1 |
12 |
13 |
14 |
15 |
26 |
27 |
31 |
32 |
33 |
--------------------------------------------------------------------------------
/Sources/LogicCircuit/Icon/AlignLeft.xaml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 | 0.75
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
29 |
--------------------------------------------------------------------------------
/Sources/LogicCircuit/Icon/FileNew.xaml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
--------------------------------------------------------------------------------
/Sources/LogicCircuit.UnitTest/SettingsTest.cs:
--------------------------------------------------------------------------------
1 | namespace LogicCircuit.UnitTest {
2 | ///
3 | ///This is a test class for Settings and is intended
4 | ///to contain all Settings Unit Tests
5 | ///
6 | [TestClass()]
7 | public class SettingsTest {
8 | ///
9 | ///Gets or sets the test context which provides
10 | ///information about and functionality for the current test run.
11 | ///
12 | public TestContext TestContext { get; set; }
13 |
14 | private class TestSettings : Settings {
15 | public void SaveSettings(string file) {
16 | this.Save(file);
17 | }
18 | public void LoadSettings(string file) {
19 | this.Load(file);
20 | }
21 | }
22 |
23 | ///
24 | /// A test for Load/Save settings.
25 | ///
26 | [TestMethod()]
27 | public void SettingsLoadSaveTest() {
28 | string dir = Path.Combine(this.TestContext.TestRunDirectory, this.TestContext.TestName + DateTime.UtcNow.Ticks, "Settings Test Sub Directory");
29 | string file = Path.Combine(dir, "Settings Test File.xml");
30 |
31 | string key = "hello";
32 | string value = "world !";
33 |
34 | TestSettings s1 = new TestSettings();
35 | Assert.IsFalse(Directory.Exists(dir));
36 | s1.LoadSettings(file);
37 | s1[key] = value;
38 | s1.SaveSettings(file);
39 | Assert.IsTrue(File.Exists(file));
40 |
41 | TestSettings s2 = new TestSettings();
42 | s2.LoadSettings(file);
43 | Assert.AreEqual(value, s2[key]);
44 |
45 | File.Delete(file);
46 | }
47 | }
48 | }
49 |
--------------------------------------------------------------------------------
/Sources/LogicCircuit.UnitTest/TestHelper.cs:
--------------------------------------------------------------------------------
1 | using System.Reflection;
2 | using System.Windows;
3 |
4 | namespace LogicCircuit.UnitTest {
5 | [TestClass]
6 | public class TestHelper {
7 | private static object syncRoot = new object();
8 | public static Assembly LogicCircuitAssembly { get; private set; }
9 | public static App App { get; private set; }
10 |
11 | public static Random Random { get; private set; }
12 |
13 | [AssemblyInitialize]
14 | public static void InitTests(TestContext context) {
15 | int seed = Environment.TickCount & 0x7FFFFFFF; // Ensure a positive seed value
16 | context.WriteLine($"seed={seed}");
17 | TestHelper.Random = new Random(seed);
18 | if(TestHelper.App == null) {
19 | lock(TestHelper.syncRoot) {
20 | if(TestHelper.App == null) {
21 | Assembly assembly = typeof(CircuitMap).Assembly;
22 | TestHelper.LogicCircuitAssembly = assembly;
23 | var _resourceAssemblyField = typeof(Application).GetField("_resourceAssembly", BindingFlags.Static | BindingFlags.NonPublic);
24 | if (_resourceAssemblyField != null) {
25 | _resourceAssemblyField.SetValue(null, assembly);
26 | }
27 |
28 | var resourceAssemblyProperty = typeof(Application).GetProperty("ResourceAssembly", BindingFlags.Static | BindingFlags.NonPublic);
29 | if (resourceAssemblyProperty != null) {
30 | resourceAssemblyProperty.SetValue(null, assembly);
31 | }
32 |
33 | App app = new App();
34 | app.InitializeComponent();
35 | TestHelper.App = app;
36 | }
37 | }
38 | }
39 | }
40 | }
41 | }
42 |
--------------------------------------------------------------------------------
/Sources/LogicCircuit/Icon/AlignTop.xaml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 | 0.75
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
29 |
--------------------------------------------------------------------------------
/Sources/LogicCircuit/DataPersistent/RowId.cs:
--------------------------------------------------------------------------------
1 | using System;
2 |
3 | namespace DataPersistent {
4 | public readonly struct RowId : IComparable, IEquatable {
5 |
6 | internal static readonly RowId Empty = new RowId(-1);
7 |
8 | private readonly int rowId;
9 |
10 | internal RowId(int rowId) {
11 | this.rowId = rowId;
12 | }
13 |
14 | public override bool Equals(object? obj) {
15 | if(obj is RowId other) {
16 | return this.rowId == other.rowId;
17 | }
18 | return false;
19 | }
20 |
21 | public bool Equals(RowId other) => this.rowId == other.rowId;
22 |
23 | public override int GetHashCode() => this.rowId;
24 |
25 | public static bool operator ==(RowId left, RowId right) => left.rowId == right.rowId;
26 |
27 | public static bool operator !=(RowId left, RowId right) => left.rowId != right.rowId;
28 |
29 | public bool IsEmpty => this.rowId == -1;
30 |
31 | public int CompareTo(RowId other) => this.rowId - other.rowId;
32 |
33 | public static bool operator <(RowId left, RowId right) => left.rowId < right.rowId;
34 |
35 | public static bool operator >(RowId left, RowId right) => left.rowId > right.rowId;
36 |
37 | public static bool operator <=(RowId left, RowId right) => left.rowId <= right.rowId;
38 |
39 | public static bool operator >=(RowId left, RowId right) => left.rowId >= right.rowId;
40 |
41 | internal int Value => this.rowId;
42 |
43 | public override string ToString() => string.Format(System.Globalization.CultureInfo.InvariantCulture, "Row[{0}]", this.rowId);
44 | }
45 | }
46 |
--------------------------------------------------------------------------------
/Sources/LogicCircuit/Icon/AlignBottom.xaml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 | 0.75
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
29 |
--------------------------------------------------------------------------------
/Sources/LogicCircuit/Icon/AlignRight.xaml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 | 0.75
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
29 |
--------------------------------------------------------------------------------
/Sources/LogicCircuit/Icon/EditRedo.xaml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
--------------------------------------------------------------------------------
/Sources/LogicCircuit.UnitTest/DataPersistent/RowIdTest.cs:
--------------------------------------------------------------------------------
1 | using DataPersistent;
2 |
3 | namespace LogicCircuit.UnitTest.DataPersistent {
4 | [TestClass]
5 | public class RowIdTest {
6 | [TestMethod]
7 | public void ConstructorTest() {
8 | RowId id1 = new RowId();
9 | Assert.AreEqual(0, id1.Value);
10 |
11 | RowId id2 = new RowId(12);
12 | Assert.AreEqual(12, id2.Value);
13 |
14 | RowId id3 = new RowId(-160);
15 | Assert.AreEqual(-160, id3.Value);
16 |
17 | RowId id4 = new RowId(int.MaxValue);
18 | Assert.AreEqual(int.MaxValue, id4.Value);
19 |
20 | RowId id5 = new RowId(int.MinValue);
21 | Assert.AreEqual(int.MinValue, id5.Value);
22 | }
23 |
24 | [TestMethod()]
25 | public void EqualsTest() {
26 | RowId id1 = new RowId(12);
27 | RowId id2 = new RowId(12);
28 | RowId id3 = new RowId(11);
29 |
30 | Assert.IsTrue(id1.Equals(id1));
31 | Assert.IsTrue(id1.Equals(id2));
32 | Assert.IsTrue(id2.Equals(id1));
33 | Assert.IsFalse(id1.Equals(id1.Value));
34 | Assert.IsFalse(id1.Equals(id3));
35 | Assert.IsFalse(id3.Equals(id1));
36 |
37 | Assert.AreEqual(id1.Value, id1.GetHashCode());
38 | Assert.AreEqual(id2.Value, id2.GetHashCode());
39 | Assert.AreEqual(id3.Value, id3.GetHashCode());
40 |
41 | Assert.IsTrue(id1 == id2);
42 | Assert.IsTrue(id2 == id1);
43 | Assert.IsFalse(id1 != id2);
44 | Assert.IsFalse(id2 != id1);
45 |
46 | Assert.IsTrue(id1 != id3);
47 | Assert.IsTrue(id3 != id1);
48 | Assert.IsFalse(id1 == id3);
49 | Assert.IsFalse(id3 == id1);
50 | }
51 | }
52 | }
53 |
--------------------------------------------------------------------------------
/Sources/LogicCircuit/Icon/AlignCenter.xaml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 | 0.75
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
29 |
--------------------------------------------------------------------------------
/Sources/BuildSetup.cmd:
--------------------------------------------------------------------------------
1 | @echo off
2 |
3 | if "%VSCMD_VER%" == "" (
4 | echo This .CMD file must be run from "Developer Command Prompt for VS" or later
5 | exit /B
6 | )
7 |
8 | @echo on
9 |
10 | msbuild -r -p:Configuration=Release Tools\ItemWrapper.Generator\ItemWrapper.Generator.csproj
11 | @if "%ERRORLEVEL%" NEQ "0" (exit /B)
12 |
13 | rem Publish for 64 bits
14 | dotnet publish LogicCircuit\LogicCircuit.csproj --sc -c Release -r win-x64 -o LogicCircuit\bin\Release_64\Publish
15 | @if "%ERRORLEVEL%" NEQ "0" (exit /B)
16 |
17 | rem Publish for 32 bits
18 | dotnet publish LogicCircuit\LogicCircuit.csproj --sc -c Release -r win-x86 -o LogicCircuit\bin\Release_32\Publish
19 | @if "%ERRORLEVEL%" NEQ "0" (exit /B)
20 |
21 | rem Publish for arm 64
22 | dotnet publish LogicCircuit\LogicCircuit.csproj --sc -c Release -r win-arm64 -o LogicCircuit\bin\Release_arm64\Publish
23 | @if "%ERRORLEVEL%" NEQ "0" (exit /B)
24 |
25 | rem Buiding Setup
26 |
27 | msbuild -r -p:Configuration=Release;Platform=x64 Setup\Setup.wixproj
28 | @if "%ERRORLEVEL%" NEQ "0" (exit /B)
29 |
30 | msbuild -r -p:Configuration=Release;Platform=x86 Setup\Setup.wixproj
31 | @if "%ERRORLEVEL%" NEQ "0" (exit /B)
32 |
33 | msbuild -r -p:Configuration=Release;Platform=arm64 Setup\Setup.wixproj
34 | @if "%ERRORLEVEL%" NEQ "0" (exit /B)
35 |
36 | rem Buiding Setup Zip files
37 |
38 | msbuild -t:ZipSetup Setup -p:Platform=x64
39 | @if "%ERRORLEVEL%" NEQ "0" (exit /B)
40 |
41 | msbuild -t:ZipSetup Setup -p:Platform=x86
42 | @if "%ERRORLEVEL%" NEQ "0" (exit /B)
43 |
44 | msbuild -t:ZipSetup Setup -p:Platform=Arm64
45 | @if "%ERRORLEVEL%" NEQ "0" (exit /B)
46 |
--------------------------------------------------------------------------------
/Sources/LogicCircuit/Icon/EditUndo.xaml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
--------------------------------------------------------------------------------
/Sources/Tools/ItemWrapper.Generator/ToStringHelper.cs:
--------------------------------------------------------------------------------
1 | using System.Diagnostics.CodeAnalysis;
2 | using System.Globalization;
3 | using System.Reflection;
4 |
5 | namespace ItemWrapper.Generator {
6 | ///
7 | /// Utility class to produce culture-oriented representation of an object as a string.
8 | ///
9 | public class ToStringHelper {
10 | private IFormatProvider formatProvider = CultureInfo.InvariantCulture;
11 |
12 | ///
13 | /// Gets or sets format provider to be used by ToStringWithCulture method.
14 | ///
15 | public IFormatProvider FormatProvider {
16 | get { return this.formatProvider; }
17 | set { this.formatProvider = value ?? CultureInfo.InvariantCulture; }
18 | }
19 |
20 | ///
21 | /// This is called from the compile/run appdomain to convert objects within an expression block to a string
22 | ///
23 | ///
24 | ///
25 | public string ToStringWithCulture(object objectToConvert) {
26 | ArgumentNullException.ThrowIfNull(objectToConvert);
27 | Type type = objectToConvert.GetType();
28 | MethodInfo? method = type.GetMethod("ToString", new Type[] { typeof(IFormatProvider) });
29 | if(method != null) {
30 | return (string)method.Invoke(objectToConvert, new object[] { this.FormatProvider })!;
31 | } else {
32 | return objectToConvert.ToString()!;
33 | }
34 | }
35 |
36 | [SuppressMessage("Performance", "CA1822:Mark members as static")]
37 | public string ToStringWithCulture(string text) {
38 | return text;
39 | }
40 | }
41 | }
42 |
--------------------------------------------------------------------------------
/Sources/Setup/Setup.wixproj:
--------------------------------------------------------------------------------
1 |
2 |
3 | Release
4 | x64
5 | 3.7
6 | x64;x86;arm64
7 |
8 |
9 | x64
10 | bin\$(Configuration)_x64\
11 | obj\$(Configuration)_x64\
12 | LogicCircuitSetup_64
13 |
14 |
15 | x86
16 | bin\$(Configuration)_x86\
17 | obj\$(Configuration)_x86\
18 | LogicCircuitSetup_32
19 |
20 |
21 | arm64
22 | bin\$(Configuration)_arm64\
23 | obj\$(Configuration)_arm64\
24 | LogicCircuitSetup_arm64
25 |
26 |
27 |
28 |
29 |
30 |
31 |
32 |
33 |
34 |
--------------------------------------------------------------------------------
/Sources/LogicCircuit/Icon/AlignMiddle.xaml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 | 0.75
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
29 |
30 |
--------------------------------------------------------------------------------
/Sources/LogicCircuit/Schema/ConvertFrom.2.0.0.5.xslt:
--------------------------------------------------------------------------------
1 |
2 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
29 |
30 |
31 |
32 |
33 |
34 |
35 |
36 |
--------------------------------------------------------------------------------
/Sources/LogicCircuit/Dialog/DialogHyperlink.xaml:
--------------------------------------------------------------------------------
1 |
13 |
14 |
15 |
18 |
19 |
20 |
23 |
24 |
27 |
28 |
29 |
30 |
31 |
32 |
33 |
34 |
--------------------------------------------------------------------------------
/Sources/LogicCircuit/Icon/CircuitProjectProperty.xaml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
--------------------------------------------------------------------------------
/Sources/LogicCircuit/Settings/SettingsDoubleCache.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Globalization;
3 |
4 | namespace LogicCircuit {
5 | internal sealed class SettingsDoubleCache {
6 | private readonly Settings settings;
7 | private readonly string key;
8 | private readonly double minimum;
9 | private readonly double maximum;
10 | private readonly string format;
11 |
12 | private double cache;
13 | public double Value {
14 | get { return this.cache; }
15 | set {
16 | double number = Math.Max(this.minimum, Math.Min(value, this.maximum));
17 | if(this.cache != number) {
18 | this.cache = number;
19 | this.settings[this.key] = this.cache.ToString(this.format, CultureInfo.InvariantCulture);
20 | }
21 | }
22 | }
23 |
24 | public SettingsDoubleCache(
25 | Settings settings,
26 | string key,
27 | double minimum,
28 | double maximum,
29 | double defaultValue,
30 | bool persistInteger
31 | ) {
32 | Tracer.Assert(minimum <= maximum);
33 | this.settings = settings;
34 | this.key = key;
35 | this.minimum = minimum;
36 | this.maximum = maximum;
37 | string? text = this.settings[this.key];
38 | double value;
39 | if(string.IsNullOrEmpty(text) || !double.TryParse(text, out value)) {
40 | value = defaultValue;
41 | }
42 | this.cache = Math.Max(this.minimum, Math.Min(value, this.maximum));
43 | this.format = persistInteger ? "f0" : "g";
44 | }
45 |
46 | public SettingsDoubleCache(
47 | Settings settings,
48 | string key,
49 | double minimum,
50 | double maximum,
51 | double defaultValue
52 | ) : this(settings, key, minimum, maximum, defaultValue, false) {
53 | }
54 | }
55 | }
56 |
--------------------------------------------------------------------------------
/Sources/LogicCircuit/Dialog/DialogUsage.xaml.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Linq;
4 | using System.Windows;
5 | using System.Windows.Controls;
6 | using System.Windows.Input;
7 |
8 | namespace LogicCircuit {
9 | ///
10 | /// Interaction logic for DialogUsage.xaml
11 | ///
12 | public partial class DialogUsage : Window {
13 |
14 | private SettingsWindowLocationCache? windowLocation;
15 | public SettingsWindowLocationCache WindowLocation { get { return this.windowLocation ?? (this.windowLocation = new SettingsWindowLocationCache(Settings.User, this)); } }
16 | public LogicalCircuit LogicalCircuit { get; private set; }
17 | public IEnumerable Usage { get; private set; }
18 |
19 | public DialogUsage(LogicalCircuit logicalCircuit) {
20 | this.LogicalCircuit = logicalCircuit;
21 | this.Usage = new HashSet(this.LogicalCircuit.CircuitProject.CircuitSymbolSet.SelectByCircuit(this.LogicalCircuit).Select(s => s.LogicalCircuit)).ToList();
22 | this.DataContext = this;
23 | this.InitializeComponent();
24 | }
25 |
26 | private void ListBoxMouseDoubleClick(object sender, MouseButtonEventArgs e) {
27 | if(sender is ListBox listBox) {
28 | if(listBox.SelectedItem is LogicalCircuit selected) {
29 | Mainframe mainframe = (Mainframe)this.Owner;
30 | Editor? editor = mainframe.Editor;
31 | if(editor != null) {
32 | editor.OpenLogicalCircuit(selected);
33 | editor.Select(
34 | editor.CircuitProject.CircuitSymbolSet.SelectByCircuit(this.LogicalCircuit).Where(s => s.LogicalCircuit == selected)
35 | );
36 | }
37 | }
38 | }
39 | }
40 | }
41 | }
42 |
--------------------------------------------------------------------------------
/Sources/LogicCircuit/Dialog/DialogProbe.xaml.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Linq;
3 | using System.Windows;
4 |
5 | namespace LogicCircuit {
6 | ///
7 | /// Interaction logic for DialogProbe.xaml
8 | ///
9 | public partial class DialogProbe : Window {
10 | private SettingsWindowLocationCache? windowLocation;
11 | public SettingsWindowLocationCache WindowLocation { get { return this.windowLocation ?? (this.windowLocation = new SettingsWindowLocationCache(Settings.User, this)); } }
12 |
13 | private readonly CircuitProbe probe;
14 |
15 | public DialogProbe(CircuitProbe probe) {
16 | this.probe = probe;
17 | this.DataContext = this;
18 | this.InitializeComponent();
19 |
20 | this.name.Text = this.probe.DisplayName;
21 | this.side.SelectedItem = PinDescriptor.PinSideDescriptor(this.probe.PinSide);
22 | this.description.Text = this.probe.Note ?? string.Empty;
23 | }
24 |
25 | private void ButtonOkClick(object sender, RoutedEventArgs e) {
26 | try {
27 | string name = this.name.Text.Trim();
28 | PinSide pinSide = ((EnumDescriptor)this.side.SelectedItem).Value;
29 | string note = this.description.Text.Trim();
30 | if(this.probe.DisplayName != name ||
31 | this.probe.PinSide != pinSide ||
32 | this.probe.Note != note
33 | ) {
34 | this.probe.CircuitProject.InTransaction(() => {
35 | this.probe.Rename(name);
36 | this.probe.PinSide = pinSide;
37 | this.probe.Note = note;
38 | this.probe.Pins.First().PinSide = pinSide;
39 | });
40 | }
41 | this.Close();
42 | } catch(Exception exception) {
43 | App.Mainframe.ReportException(exception);
44 | }
45 | }
46 | }
47 | }
48 |
--------------------------------------------------------------------------------
/Sources/LogicCircuit/CommandMenuItem.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Windows;
3 | using System.Windows.Controls;
4 | using System.Windows.Input;
5 |
6 | namespace LogicCircuit {
7 | public class CommandMenuItem : MenuItem {
8 | private static void RemoveInputBinding(Window window, KeyGesture keyGesture) {
9 | foreach(InputBinding old in window.InputBindings) {
10 | if(old.Gesture is KeyGesture gesture && gesture.Key == keyGesture.Key && gesture.Modifiers == keyGesture.Modifiers) {
11 | window.InputBindings.Remove(old);
12 | break;
13 | }
14 | }
15 | }
16 |
17 | protected override void OnPropertyChanged(DependencyPropertyChangedEventArgs e) {
18 | base.OnPropertyChanged(e);
19 | try {
20 | if(e.Property == MenuItem.CommandProperty) {
21 | Window window = Window.GetWindow(this);
22 | if(window != null) {
23 | LambdaUICommand? command = this.Command as LambdaUICommand;
24 | if(command != null && command.KeyGesture != null) {
25 | CommandMenuItem.RemoveInputBinding(window, command.KeyGesture);
26 | window.InputBindings.Add(new InputBinding(command, command.KeyGesture));
27 | } else {
28 | command = e.OldValue as LambdaUICommand;
29 | if(command != null && command.KeyGesture != null) {
30 | CommandMenuItem.RemoveInputBinding(window, command.KeyGesture);
31 | }
32 | }
33 | }
34 | } else if(e.Property == MenuItem.IsVisibleProperty && this.IsVisible) {
35 | if(this.Command is LambdaUICommand command) {
36 | command.NotifyCanExecuteChanged();
37 | }
38 | }
39 | } catch(Exception exception) {
40 | App.Mainframe.ReportException(exception);
41 | }
42 | }
43 | }
44 | }
45 |
--------------------------------------------------------------------------------
/Sources/LogicCircuit/Editor/AreaMarker.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Windows;
3 | using System.Windows.Controls;
4 | using System.Windows.Shapes;
5 |
6 | namespace LogicCircuit {
7 | partial class EditorDiagram {
8 | private sealed class AreaMarker : Marker {
9 | private readonly Point point0;
10 | private readonly Rectangle markerGlyph;
11 |
12 | public override FrameworkElement Glyph { get { return this.markerGlyph; } }
13 |
14 | public AreaMarker(Point point) : base(null) {
15 | this.point0 = point;
16 | this.markerGlyph = Symbol.Skin(SymbolShape.MarkerRectangle);
17 | this.markerGlyph.DataContext = this;
18 | this.PositionGlyph(point);
19 | }
20 |
21 | public override Rect Bounds() {
22 | return new Rect(Canvas.GetLeft(this.markerGlyph), Canvas.GetTop(this.markerGlyph), this.markerGlyph.Width, this.markerGlyph.Height);
23 | }
24 |
25 | public override void Move(EditorDiagram editor, Point point) {
26 | this.PositionGlyph(point);
27 | }
28 |
29 | public override void Commit(EditorDiagram editor, Point point, bool withWires) {
30 | editor.Select(new Rect(this.point0, point));
31 | }
32 |
33 | private void PositionGlyph(Point point) {
34 | Rect rect = new Rect(this.point0, point);
35 | Canvas.SetLeft(this.markerGlyph, rect.X);
36 | Canvas.SetTop(this.markerGlyph, rect.Y);
37 | this.markerGlyph.Width = rect.Width;
38 | this.markerGlyph.Height = rect.Height;
39 | }
40 |
41 | public override void CancelMove(Panel selectionLayer) {
42 | selectionLayer.Children.Remove(this.Glyph);
43 | }
44 |
45 | public override void Refresh() {
46 | throw new InvalidOperationException();
47 | }
48 | }
49 | }
50 | }
51 |
--------------------------------------------------------------------------------
/Sources/LogicCircuit/Icon/Hyperlink.xaml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
--------------------------------------------------------------------------------
/Sources/LogicCircuit/Icon/FileSaveAs.xaml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
--------------------------------------------------------------------------------