Ejemplo n.º 1
0
 public Core(Canvas Mycanvas_, ProgressBar progress_, TextBlock progressTextBlock_)
 {
     Mycanvas          = Mycanvas_;
     progress          = progress_;
     progressTextBlock = progressTextBlock_;
     IsRuning          = false;
     m_SyncContext     = SynchronizationContext.Current;
     suspensionWindow  = new SuspensionWindow(this);
     StringArr         = new List <string>();
     StringArr.Add("电阻");
     StringArr.Add("电容");
     StringArr.Add("导线");
     StringArr.Add("电感");
     StringArr.Add("电阻表");
     StringArr.Add("电压表");
     StringArr.Add("地");
     StringArr.Add("红色探针");
     StringArr.Add("黑色探针");
     StringArr.Add("直流电源");
     StringArr.Add("交流电源");
     Mycanvas.MouseLeftButtonDown += Mycanvas_MouseLeftButtonDown;
     Mycanvas.MouseUp             += Mycanvas_MouseUp;
     Mycanvas.MouseMove           += Mycanvas_MouseMove;
     Mycanvas.MouseRightButtonUp  += Mycanvas_MouseRightButtonUp;
     Mycanvas.KeyDown             += MainWindow_KeyDown;
     //定义面板上的鼠标操作
     elecCompSet = new ElecCompSet();
     SyncProgess(100, "无任务");             //用这个函数异步更新ProgressBar的值
     mycondition    = new condition();
     myOscilloscope = new oscilloscope(); //示波器,只有一个实例
 }
Ejemplo n.º 2
0
        public MainWindow()
        {
            InitializeComponent();
            ImageArr = new List <Image>();
            //MessageBox.Show("" + Environment.CurrentDirectory);
            for (int i = 0; i < 2; i++)
            {
                Image image = new Image();
                image.Width  = 200;
                image.Height = 150;

                /*image.Source = new BitmapImage(new Uri("C:\\Users" +
                 *  "\\37754\\Pictures\\doge.jpg"));*/
                image.Source = new BitmapImage(new Uri(Environment.CurrentDirectory
                                                       + "\\doge.jpg"));
                ImageArr.Add(image);
            }
            this.elecCompList.ItemsSource       = ImageArr;
            this.elecCompList.MouseDoubleClick += ElecCompList_MouseDoubleClick;
            //UpdateList();
            this.Mycanvas.MouseDown += Mycanvas_MouseDown;
            this.Mycanvas.MouseUp   += Mycanvas_MouseUp;
            this.Mycanvas.MouseMove += Mycanvas_MouseMove;
            elecCompSet              = new ElecCompSet();
            //elecCompSet.AddCompAndShow(new Resistance(), Mycanvas);
            //elecCompSet.AddCompAndShow(new Capacity(), Mycanvas);
            //resistance2.Move(100, 200);
            this.KeyDown += MainWindow_KeyDown;
        }
Ejemplo n.º 3
0
        //读取
        public static void Read(ElecCompSet elecCompSet, Canvas Mycanvas)
        {
            OpenFileDialog fd = new OpenFileDialog();

            fd.Filter       = "circ files (*.circ)|*.circ";
            fd.ShowReadOnly = true;
            if (!fd.ShowDialog().Value)
            {
                return;
            }
            String openingFileName = fd.FileName;

            //MessageBox.Show(openingFileName);
            using (FileStream fsRead = new FileStream(openingFileName, FileMode.Open))
            {
                int    fsLen  = (int)fsRead.Length;
                byte[] heByte = new byte[fsLen];
                int    r      = fsRead.Read(heByte, 0, heByte.Length);
                string myStr  = Encoding.UTF8.GetString(heByte);
                Console.WriteLine(myStr);
                string[] Strsp = myStr.Split('\n');
                for (int i = 0; i < Strsp.Length - 1; i++)
                {
                    Console.WriteLine("(" + i + "):" + Strsp[i]);
                    String[] singleSp = Strsp[i].Split(' ');
                    if (singleSp.Length != 5)
                    {
                        MessageBox.Show("Record Wrong!");
                    }
                    for (int j = 0; j < singleSp.Length; j++)
                    {
                        Console.WriteLine("    (" + j + "):" + singleSp[j]);
                    }
                    int Comp = int.Parse(singleSp[0]);

                    int RotateState = int.Parse(singleSp[1]);
                    int X           = int.Parse(singleSp[2]);
                    int Y           = int.Parse(singleSp[3]);

                    ElecComp x = elecCompSet.AddFromRecord(Comp, Mycanvas);
                    x.Move(X, Y);
                    for (int j = 0; j < RotateState; j++)
                    {
                        x.RotateLeft();
                    }
                    x.HandleAttr(singleSp[4]);
                }
            }
        }
Ejemplo n.º 4
0
        public MainWindow()
        {
            IsRuning = false;
            InitializeComponent();
            m_SyncContext    = SynchronizationContext.Current;
            suspensionWindow = new SuspensionWindow(this);

            /*ImageArr = new List<Image>();
             * //MessageBox.Show("" + Environment.CurrentDirectory);
             * for (int i=0; i<4; i++)
             * {
             *  Image image = new Image();
             *  image.Width = 200;
             *  image.Height = 150;
             *  /*image.Source = new BitmapImage(new Uri("C:\\Users" +
             *      "\\37754\\Pictures\\doge.jpg"));
             *  image.Source = new BitmapImage(new Uri(Environment.CurrentDirectory
             + "\\doge.jpg"));
             +  ImageArr.Add(image);
             + }*/
            StringArr = new List <string>();
            StringArr.Add("电阻");
            StringArr.Add("电容");
            StringArr.Add("导线");
            StringArr.Add("电感");
            StringArr.Add("电阻表");
            StringArr.Add("电压表");
            StringArr.Add("地");
            StringArr.Add("红色探针");
            StringArr.Add("蓝色探针");
            this.elecCompList.ItemsSource = StringArr;
            //this.elecCompList.ItemsSource = ImageArr;
            this.elecCompList.MouseDoubleClick += ElecCompList_MouseDoubleClick;
            //UpdateList();
            this.Mycanvas.MouseLeftButtonDown += Mycanvas_MouseLeftButtonDown;
            this.Mycanvas.MouseUp             += Mycanvas_MouseUp;
            this.Mycanvas.MouseMove           += Mycanvas_MouseMove;
            this.Mycanvas.MouseRightButtonUp  += Mycanvas_MouseRightButtonUp;
            elecCompSet = new ElecCompSet();
            //elecCompSet.AddCompAndShow(new Resistance(), Mycanvas);
            //elecCompSet.AddCompAndShow(new Capacity(), Mycanvas);
            //resistance2.Move(100, 200);
            this.KeyDown += MainWindow_KeyDown;
            InitTest();
            this.start_button.Click += Start_button_Click;
            SyncProgess(100, "无任务"); //用这个函数异步更新ProgressBar的值
            myOscilloscope = new oscilloscope();
        }
Ejemplo n.º 5
0
        //保存
        public static void Save(ElecCompSet elecCompSet)
        {
            SaveCircDialog saveCircDialog = new SaveCircDialog();

            saveCircDialog.ShowDialog();
            //@m 这句话是用来提示完成 保存的,可进行修改
            MessageBox.Show("Saving!");
            String SaveingStr = "";

            SaveingStr += elecCompSet.PrintSavingAll();
            byte[] myByte = System.Text.Encoding.UTF8.GetBytes(SaveingStr);

            using (FileStream fsWrite = new FileStream(@"D:\1.circ" /*@d 这是默认路径,默认文件名,可修改*/, FileMode.Create))
            {
                fsWrite.Write(myByte, 0, myByte.Length);
            };
        }