private void FrmMain_Load(object sender, EventArgs e) { #region 判断系统是否已启动 System.Diagnostics.Process[] myProcesses = System.Diagnostics.Process.GetProcessesByName(Application.ProductName); //获取指定的进程名 if (myProcesses.Length > 1) //如果可以获取到知道的进程名则说明已经启动 { MessageBox.Show("程序已启动!"); Application.Exit(); //关闭系统 } #endregion CommonMethods.ReadConfig(); autoOutXlsToolStripMenuItem.Checked = Model.Global.AutoOut; if (autoOutXlsToolStripMenuItem.Checked) { autoOutXlsToolStripMenuItem.BackColor = Color.Green; } if (Global.SavePath == "") { Global.SavePath = Application.StartupPath + @"\Data\"; } Global.DateFilePath = Global.SavePath + DateTime.Now.Date.ToString("yyyy") + @"\" + DateTime.Now.Date.ToString("yyyyMM") + @"\"; ReadValue.ConnnectPlc1(); ReadValue.ConnnectPlc2(); this.Width = Screen.PrimaryScreen.Bounds.Width; this.Height = Screen.PrimaryScreen.Bounds.Height; this.StartPosition = FormStartPosition.CenterScreen; 检测界面ToolStripMenuItem_Click(null, null); timer.Interval = 500; timer.Tick += Timer_Tick; timer.Start(); ReadValue.StartRead1(); ReadValue.StartRead2(); }
public TestViewModel(IEventAggregator eventAggregator, IWindowManager windowManager) { //初始化 _windowManager = windowManager; _eventAggregator = eventAggregator; _connectStatusEvent = new ConnectStatusEvent("离线!", "离线!"); Workrec1 = new Workrec(); Workrec2 = new Workrec(); Holerec1 = new Holerec(); Holerec2 = new Holerec(); Point1 = new Models.Point(); Point2 = new Models.Point(); ActualPoint1 = new ActualPoint(); ActualPoint2 = new ActualPoint(); StartTime = DateTime.Now.AddDays(-5); CanRedo2 = CanStop1 = CanRedo1 = CanStop2 = Working1 = Working2 = SubWorking1 = SubWorking2 = false; CanStart1 = CanStart2 = true; ReadValue.ConnnectPlc1(); InitalChart(); // 默认情况下开始画面曲线数据刷新 IsReading = IsWorking1 = true; Read1(); FreshCurve(); }