Beispiel #1
0
        public CircuitProbe Create(string name)
        {
            Guid         id    = Guid.NewGuid();
            CircuitProbe probe = this.CreateItem(id, string.IsNullOrWhiteSpace(name) ? id.ToString() : this.UniqueName(name.Trim()), CircuitProbeData.NoteField.Field.DefaultValue);

            this.CircuitProject.DevicePinSet.Create(probe, PinType.Input, 1);
            return(probe);
        }
        public DialogProbe(CircuitProbe probe)
        {
            this.probe       = probe;
            this.DataContext = this;
            this.InitializeComponent();

            this.name.Text        = this.probe.DisplayName;
            this.description.Text = this.probe.Note;
        }
Beispiel #3
0
        private CircuitProbe Register(RowId rowId)
        {
            CircuitData data = new CircuitData()
            {
                CircuitId = this.Table.GetField(rowId, CircuitProbeData.CircuitProbeIdField.Field)
            };
            CircuitProbe probe = this.Create(rowId, this.CircuitProject.CircuitTable.Insert(ref data));

            this.CircuitProject.DevicePinSet.Create(probe, PinType.Input, 1);
            return(probe);
        }
Beispiel #4
0
        public CircuitProbe Copy(CircuitProbe other)
        {
            CircuitProbeData data;

            other.CircuitProject.CircuitProbeSet.Table.GetData(other.CircuitProbeRowId, out data);
            if (this.FindByCircuitProbeId(data.CircuitProbeId) != null)
            {
                data.CircuitProbeId = Guid.NewGuid();
                if (!other.HasName)
                {
                    data.Name = data.CircuitProbeId.ToString();
                }
            }
            data.Name         = this.UniqueName(data.Name);
            data.CircuitProbe = null;
            return(this.Register(this.Table.Insert(ref data)));
        }
Beispiel #5
0
        protected override void Edit(Symbol symbol)
        {
            CircuitSymbol circuitSymbol = symbol as CircuitSymbol;

            if (circuitSymbol != null)
            {
                if (this.InEditMode)
                {
                    LogicalCircuit lc = circuitSymbol.Circuit as LogicalCircuit;
                    if (lc != null)
                    {
                        this.OpenLogicalCircuit(lc);
                        return;
                    }
                    CircuitProbe cp = circuitSymbol.Circuit as CircuitProbe;
                    if (cp != null)
                    {
                        this.Edit(cp);
                        return;
                    }
                    CircuitButton cb = circuitSymbol.Circuit as CircuitButton;
                    if (cb != null)
                    {
                        this.Edit(cb);
                        return;
                    }
                    Constant ct = circuitSymbol.Circuit as Constant;
                    if (ct != null)
                    {
                        this.Edit(ct);
                        return;
                    }
                    Sensor sr = circuitSymbol.Circuit as Sensor;
                    if (sr != null)
                    {
                        this.Edit(sr);
                        return;
                    }
                    Memory m = circuitSymbol.Circuit as Memory;
                    if (m != null)
                    {
                        this.Edit(m);
                        return;
                    }
                    Pin pin = circuitSymbol.Circuit as Pin;
                    if (pin != null)
                    {
                        this.Edit(pin);
                        return;
                    }
                    LedMatrix ledMatrix = circuitSymbol.Circuit as LedMatrix;
                    if (ledMatrix != null)
                    {
                        this.Edit(ledMatrix);
                        return;
                    }
                    Sound sound = circuitSymbol.Circuit as Sound;
                    if (sound != null)
                    {
                        this.Edit(sound);
                        return;
                    }
                    GraphicsArray graphicsArray = circuitSymbol.Circuit as GraphicsArray;
                    if (graphicsArray != null)
                    {
                        this.Edit(graphicsArray);
                        return;
                    }
                }
                else if (this.CircuitRunner != null && this.CircuitRunner.VisibleMap != null)
                {
                    CircuitMap map = this.CircuitRunner.VisibleMap.Child(circuitSymbol);
                    if (map != null)
                    {
                        this.OpenLogicalCircuit(map);
                        return;
                    }
                    if (circuitSymbol.Circuit is CircuitProbe)
                    {
                        FunctionProbe functionProbe = this.CircuitRunner.VisibleMap.FunctionProbe(circuitSymbol);
                        if (functionProbe != null)
                        {
                            this.Mainframe.ShowDialog(new DialogProbeHistory(functionProbe));
                        }
                        return;
                    }
                    if ((circuitSymbol.Circuit is Memory) || (circuitSymbol.Circuit is GraphicsArray))
                    {
                        IFunctionMemory functionMemory = this.CircuitRunner.VisibleMap.FunctionMemory(circuitSymbol);
                        if (functionMemory != null)
                        {
                            this.Mainframe.ShowDialog(new DialogMemory(functionMemory));
                        }
                        return;
                    }
                    if (circuitSymbol.Circuit is Constant)
                    {
                        if (this.CircuitRunner.Root.First() == this.CircuitRunner.VisibleMap)
                        {
                            FunctionConstant functionConstant = this.CircuitRunner.VisibleMap.FunctionConstant(circuitSymbol);
                            if (functionConstant != null)
                            {
                                this.CircuitProject.InOmitTransaction(() => functionConstant.Value++);
                            }
                        }
                        else
                        {
                            this.Mainframe.Status = Properties.Resources.MessageNotRootConstant(this.CircuitRunner.Root.First().Circuit.Name);
                        }
                    }
                }
            }
            else if (this.InEditMode)
            {
                TextNote textNote = symbol as TextNote;
                if (textNote != null)
                {
                    this.Edit(textNote);
                }
            }
        }
Beispiel #6
0
 private void Edit(CircuitProbe probe)
 {
     this.Mainframe.ShowDialog(new DialogProbe(probe));
 }