// Form1がロードされたときに実行される private void Form1_Load(object sender, EventArgs e) { // バージョン名(AssemblyInformationalVersion属性)を取得 string appVersion = Application.ProductVersion; // 製品名(AssemblyProduct属性)を取得 string appProductName = Application.ProductName; // 会社名(AssemblyCompany属性)を取得 string appCompanyName = Application.CompanyName; mainAssembly = System.Reflection.Assembly.GetExecutingAssembly(); rm = new System.Resources.ResourceManager(mainAssembly.GetName().Name, mainAssembly); // コピーライト情報を取得 string appCopyright = "-"; object[] CopyrightArray = mainAssembly.GetCustomAttributes(typeof(AssemblyCopyrightAttribute), false); if ((CopyrightArray != null) && (CopyrightArray.Length > 0)) { appCopyright = ((AssemblyCopyrightAttribute)CopyrightArray[0]).Copyright; } // 詳細情報を取得 string appDescription = "-"; object[] DescriptionArray = mainAssembly.GetCustomAttributes( typeof(AssemblyDescriptionAttribute), false); if ((DescriptionArray != null) && (DescriptionArray.Length > 0)) { appDescription = ((AssemblyDescriptionAttribute)DescriptionArray[0]).Description; } // lblProductName.Text = appProductName; lblCopyright.Text = appCopyright; lblVersion.Text = "Version " + appVersion; version = "ImacocoNow/" + appVersion + " .NET Framework 4.0"; ImacocoNowManager.version = version; noPostPoint = new List<GPSPoint>(); // 使えるシリアルポートをリストアップする string[] ports = SerialPort.GetPortNames(); Array.Sort(ports); foreach (string port in ports) { if (cbSerial.Items.IndexOf(port) == -1) { cbSerial.Items.Add(port); } } // Location API をポートとしてリストアップ cbSerial.Items.Add("API"); rnd = new Random(); loadSettings(); SetStatusText(""); SetGPSText(); SetCounterText(); stLblImakoko.Text = ""; stLblNoPost.Text = ""; stLblSave.Text = ""; stLblGPSPost.Text = ""; cbIcon.Text = "三角形"; // ListViewコントロールのプロパティを設定 listView1.FullRowSelect = true; listView1.GridLines = true; listView1.View = View.Details; // 列(コラム)ヘッダの作成 ColumnHeader columnData = new ColumnHeader(); columnData.TextAlign = HorizontalAlignment.Right; columnData.Text = "距離(km)"; columnData.Width = 120; ColumnHeader columnName = new ColumnHeader(); columnName.Text = "ID"; columnName.Width = 180; ColumnHeader columnType = new ColumnHeader(); columnType.Text = "ニックネーム"; columnType.Width = 180; //ColumnHeader columnDetail = new ColumnHeader(); //columnDetail.Text = "移動"; //columnDetail.Width = 30; ColumnHeader[] colHeaderRegValue = { columnData, columnName, columnType /*, columnDetail*/ }; listView1.Columns.AddRange(colHeaderRegValue); listView1.SmallImageList = new ImageList(); for (int i = 0; i < 360; i++) { string resource = string.Format("PCGPS.Resources.dir-{0}.png", i); listView1.SmallImageList.Images.Add(new Bitmap(mainAssembly.GetManifestResourceStream(resource))); } // プラグインの読み込み try { pluginManager = new PluginManager(typeof(ImacocoNowPlugin)); Assembly myAssembly = Assembly.GetEntryAssembly(); string path = Path.GetDirectoryName(myAssembly.Location); pluginManager.SearchPlugin(path); pluginManager.SearchPlugin(path + @"\plugin"); cbPlugin.Items.Clear(); foreach (PluginBase p in pluginManager.LoadedPlugins) { ImacocoNowPlugin plugin = (ImacocoNowPlugin)p; cbPlugin.Items.Add(plugin.PluginName()); } if (cbPlugin.Items.Count > 0) { cbPlugin.SelectedIndex = 0; } } catch (Exception) { } Microsoft.Win32.SystemEvents.PowerModeChanged += new Microsoft.Win32.PowerModeChangedEventHandler(SystemEvents_PowerModeChanged); t = new Thread(this.ThreadEntry); t.IsBackground = true; t.Start(); t2 = new Thread(this.AutoPostThreadEntry); t2.IsBackground = true; t2.Start(); t3 = new Thread(this.AutoTwitThreadEntry); t3.IsBackground = true; t3.Start(); if (Properties.Settings.Default.SaveWindowLocation) { this.StartPosition = FormStartPosition.Manual; this.Location = Properties.Settings.Default.WindowLocation; } if (args != null) { bool connect = false; foreach (string s in args) { switch (s) { case "/ap": chkAutoPost.Checked = true; break; case "/at": chkAutoTwit.Checked = true; break; case "/connect": connect = true; break; default: break; } } if (connect) { btnCommOpenClose.PerformClick(); } } // // FLASHのスピードメータ用 // //tcpServer.RegisterTcpServerEvent(TcpServerEvent); tcpServerSpeed.Start(); // // FLASHのタクシーメータ用 // tcpServerTaxi.Start(); // // FLASHの位置計測用 // tcpServerPos.Start(); mPosServerTimer.Start(); //policyFileServer.RegisterTcpServerEvent(TcpServerEvent2); policyFileServer.Start(); mSpeedTimer.Interval = 5000; mSpeedTimer.Start(); mTaxiTimeFareTimer.Interval = 1000; mTaxiTimeFareTimer.Start(); // // タクシーメータ初期化用 // updateTaxiTime(); // // タクシー料金再設定 // mTaxiStatus = (TaxiStatus)Properties.Settings.Default.TaxiStatus; if (mTaxiStatus == TaxiStatus.Kuusha) { if (IsShinya()) { mTaxiDistance = totalDistance + TaxiHatsunoriMeter_Night; } else { mTaxiDistance = totalDistance + TaxiHatsunoriMeter; } } else { fare = Properties.Settings.Default.TaxiFare; if (fare == TaxiHatsunoriFare) { if (Properties.Settings.Default.TaxiRestDistance <= TaxiHatsunoriMeter) { mTaxiDistance = totalDistance + Properties.Settings.Default.TaxiRestDistance; } else { updateTaxiDistance(); } } else if (Properties.Settings.Default.TaxiRestDistance <= TaxiMeterPer90yen) { mTaxiDistance = totalDistance + Properties.Settings.Default.TaxiRestDistance; } else { updateTaxiDistance(); } switch (mTaxiStatus) { case TaxiStatus.Kuusha: mBtnKuusha.Checked = true; break; case TaxiStatus.Jissha: mBtnJissha.Checked = true; break; case TaxiStatus.Kosoku: mBtnKosoku.Checked = true; break; case TaxiStatus.Shiharai: mBtnShiharai.Checked = true; break; } } formLoaded = true; }