本文整理汇总了C#中Circuit.Serialize方法的典型用法代码示例。如果您正苦于以下问题:C# Circuit.Serialize方法的具体用法?C# Circuit.Serialize怎么用?C# Circuit.Serialize使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Circuit
的用法示例。
在下文中一共展示了Circuit.Serialize方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: LiveSimulation
public LiveSimulation(Circuit.Schematic Simulate, Audio.Device Device, Audio.Channel[] Inputs, Audio.Channel[] Outputs)
{
try
{
InitializeComponent();
// Make a clone of the schematic so we can mess with it.
Circuit.Schematic clone = Circuit.Schematic.Deserialize(Simulate.Serialize(), Log);
clone.Elements.ItemAdded += OnElementAdded;
clone.Elements.ItemRemoved += OnElementRemoved;
Schematic = new SimulationSchematic(clone);
Schematic.SelectionChanged += OnProbeSelected;
// Build the circuit from the schematic.
circuit = Schematic.Schematic.Build(Log);
// Create the input and output controls.
IEnumerable<Circuit.Component> components = circuit.Components;
// Create audio input channels.
for (int i = 0; i < Inputs.Length; ++i)
InputChannels.Add(new InputChannel(i) { Name = Inputs[i].Name });
ComputerAlgebra.Expression speakers = 0;
foreach (Circuit.Component i in components)
{
Circuit.Symbol S = i.Tag as Circuit.Symbol;
if (S == null)
continue;
SymbolControl tag = (SymbolControl)S.Tag;
if (tag == null)
continue;
// Create potentiometers.
Circuit.IPotControl c = i as Circuit.IPotControl;
if (c != null)
{
PotControl pot = new PotControl()
{
Width = 80,
Height = 80,
Opacity = 0.5,
FontSize = 15,
FontWeight = FontWeights.Bold,
};
Schematic.overlays.Children.Add(pot);
Canvas.SetLeft(pot, Canvas.GetLeft(tag) - pot.Width / 2 + tag.Width / 2);
Canvas.SetTop(pot, Canvas.GetTop(tag) - pot.Height / 2 + tag.Height / 2);
pot.Value = c.PotValue;
pot.ValueChanged += x => { c.PotValue = x; UpdateSimulation(false); };
pot.MouseEnter += (o, e) => pot.Opacity = 0.95;
pot.MouseLeave += (o, e) => pot.Opacity = 0.5;
}
// Create Buttons.
Circuit.IButtonControl b = i as Circuit.IButtonControl;
if (b != null)
{
Button button = new Button()
{
Width = tag.Width,
Height = tag.Height,
Opacity = 0.5,
Background = Brushes.White,
};
Schematic.overlays.Children.Add(button);
Canvas.SetLeft(button, Canvas.GetLeft(tag));
Canvas.SetTop(button, Canvas.GetTop(tag));
button.Click += (o, e) =>
{
// Click all the buttons in the group.
foreach (Circuit.IButtonControl j in components.OfType<Circuit.IButtonControl>().Where(x => x.Group == b.Group))
j.Click();
UpdateSimulation(true);
};
button.MouseEnter += (o, e) => button.Opacity = 0.95;
button.MouseLeave += (o, e) => button.Opacity = 0.5;
}
Circuit.Speaker output = i as Circuit.Speaker;
if (output != null)
speakers += output.V;
// Create input controls.
Circuit.Input input = i as Circuit.Input;
if (input != null)
{
tag.ShowText = false;
ComboBox combo = new ComboBox()
{
Width = 80,
Height = 24,
Opacity = 0.5,
//.........这里部分代码省略.........