Guest User

Untitled

a guest
Jan 21st, 2018
103
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 3.92 KB | None | 0 0
  1. using System;
  2. using System.Collections.Generic;
  3. using System.ComponentModel;
  4. using System.Data;
  5. using System.Drawing;
  6. using System.Linq;
  7. using System.Text;
  8. using System.Windows.Forms;
  9. using System.Collections.ObjectModel;
  10.      
  11.      
  12.      
  13. namespace WindowsFormsApplication5
  14. {
  15.     public partial class Form1 : Form
  16.     {
  17.         Plot plot1, plot2;
  18.      
  19.         public Form1()
  20.         {
  21.             InitializeComponent();            
  22.         }
  23.      
  24.         struct SinWave
  25.         {
  26.             private int harm;
  27.             private double ampl;
  28.             private double phase;
  29.      
  30.      
  31.             public SinWave(int harm, double ampl, double phase)
  32.             {
  33.                 this.harm = harm;
  34.                 this.ampl = ampl;
  35.                 this.phase = phase;
  36.             }
  37.      
  38.      
  39.             public int Harm { get { return harm; } }
  40.             public double Ampl { get { return ampl; } }
  41.             public double Phase { get { return phase; } }
  42.      
  43.         }
  44.      
  45.            
  46.         struct Waveform
  47.         {
  48.             static IList<SinWave> MySin;
  49.             string name;
  50.             bool enable;
  51.             /*
  52.             public Waveform(int a)
  53.             {
  54.                 MySin = new Collection<SinWave>();
  55.                 name = "";
  56.                 enable = false;
  57.             }
  58.              * */
  59.             public Waveform(IList<SinWave> a)
  60.         {
  61.                   name = "";
  62.                   enable = true;
  63.         }
  64.      
  65.         }
  66.         struct Plot
  67.         {
  68.             public int x1;
  69.             public int y1;
  70.             public int x2; //refactor?
  71.             public int y2;
  72.             public double phase;
  73.             public double scaledamp;
  74.             public double periods;
  75.             public int gridx;
  76.             public int gridy;
  77.         }
  78.      
  79.      
  80.         private void WaveGraph_Paint_1(object sender, PaintEventArgs e)
  81.         {
  82.             plot1.x1 = 0;
  83.             plot1.x2 = WaveformGraph.Width - 1;
  84.             plot1.y1 = 0;
  85.             plot1.y2 = WaveformGraph.Height - 1;
  86.             Graphics g = e.Graphics;
  87.             g.DrawRectangle(new Pen(Color.Black), plot1.x1, plot1.y1, plot1.x2 - plot1.x1, plot1.y2 - plot1.y1);
  88.         }
  89.      
  90.         private void SinGraph_Paint(object sender, PaintEventArgs e)
  91.         {
  92.             plot2.x1 = 0;
  93.             plot2.x2 = WaveformGraph.Width - 1;
  94.             plot2.y1 = 0;
  95.             plot2.y2 = WaveformGraph.Height - 1;
  96.             Graphics g = e.Graphics;
  97.             g.DrawRectangle(new Pen(Color.Black), plot2.x1, plot2.y1, plot2.x2 - plot2.x1, plot2.y2 - plot2.y1);
  98.         }
  99.      
  100.         private void Form1_Load(object sender, EventArgs e)
  101.         {
  102.             //Waveform Arbitrary;
  103.             //Waveform Square;
  104.             //Waveform Triangle;
  105.             //Waveform Sawtoothleft;
  106.             //Waveform Sawtoothright;
  107.      
  108.             /*
  109.         IList<SinWave> Arbitrary = new Collection<SinWave>
  110.         (new[] {
  111.             new SinWave (1, 0, 0),
  112.             new SinWave (2, 0, 0),
  113.             new SinWave (3, 0, 0),
  114.             new SinWave (4, 0, 0),
  115.             new SinWave (5, 0, 0),
  116.             new SinWave (6, 0, 0),
  117.             new SinWave (7, 0, 0),
  118.             new SinWave (8, 0, 0),
  119.             new SinWave (9, 0, 0),
  120.             new SinWave (10, 0, 0),
  121.      
  122.             //bool enable;
  123.             //public Waveform(int a)
  124.         });
  125.              * */
  126.             Waveform Arbitrary = new Waveform
  127.         (new[] {
  128.             new SinWave (1, 0, 0),
  129.             new SinWave (2, 0, 0),
  130.             new SinWave (3, 0, 0),
  131.             new SinWave (4, 0, 0),
  132.             new SinWave (5, 0, 0),
  133.             new SinWave (6, 0, 0),
  134.             new SinWave (7, 0, 0),
  135.             new SinWave (8, 0, 0),
  136.             new SinWave (9, 0, 0),
  137.             new SinWave (10, 0, 0),
  138.      
  139.             //bool enable;
  140.             //public Waveform(int a)
  141.         });
  142.  
  143.             Arbitrary.name = "Arbitrary";
  144.      
  145.         }        
  146.     }
  147. }
Add Comment
Please, Sign In to add comment