private void Button_ConnectionSettingSave_Click(object sender, RoutedEventArgs e) { try { if (this.DCS.DataConnectionCount > 0) { Microsoft.Win32.SaveFileDialog dlg = new Microsoft.Win32.SaveFileDialog(); dlg.FileName = "connectionsetting.dcs"; // Default file name dlg.DefaultExt = ".dcs"; // Default file extension dlg.Filter = "DataConnectionSetting (.dcs)|*.dcs"; // Filter files by extension dlg.CheckFileExists = false; dlg.CheckPathExists = false; // Show open file dialog box Nullable <bool> result = dlg.ShowDialog(); string file; // Process open file dialog box results if (result == true) { // Open document file = dlg.FileName; } else { throw new Exception("保存を中止しました."); } FileStream fs = new FileStream(file, FileMode.Create); StreamWriter sw = new StreamWriter(fs); sw.WriteLine(this.DCS.DataConnectionCount); for (int i = 0; i < this.DCS.DataConnectionCount; i++) { DATA_CONNECTION.MyDataConnection MDC = this.DCS.get_SelectedDataConnection(i); sw.WriteLine(MDC.SENDER.remotePort + "," + MDC.RECEIVER.remotePort); } sw.Close(); fs.Close(); debugwindow.DebugLog = "[DataConnectionSever]設定を保存しました.ファイル名:" + file; while (true) { myDialog dialog = new myDialog("ファイルに設定情報を書き込みました."); if (dialog.ShowDialog() == true) { break; } } } } catch (Exception ex) { while (true) { myDialog dialog = new myDialog(ex.Message); if (dialog.ShowDialog() == true) { break; } } } }
private bool serch_connection(MyDataConnection obj) { if (obj.SENDER == this.sender && obj.RECEIVER == this.receiver) { obj.Disconnect(); return(true); } else { return(false); } }
private void ConnectionSettingSaveFast() { try { string file = System.IO.Path.GetDirectoryName(System.Reflection.Assembly.GetExecutingAssembly().Location) + @"\default.dcs"; FileStream fs = new FileStream(file, FileMode.Create); StreamWriter sw = new StreamWriter(fs); sw.WriteLine(this.DCS.DataConnectionCount); for (int i = 0; i < this.DCS.DataConnectionCount; i++) { DATA_CONNECTION.MyDataConnection MDC = this.DCS.get_SelectedDataConnection(i); sw.WriteLine(MDC.SENDER.remotePort + "," + MDC.RECEIVER.remotePort); } sw.Close(); fs.Close(); debugwindow.DebugLog = "[DataConnectionSever]設定を保存しました.ファイル名:" + file; } catch (Exception ex) { debugwindow.DebugLog = "[" + this.ToString() + "]" + ex.Message; } }
private void LISTBOX_DATA_CONNECTION_selectionchanged(object sender, SelectionChangedEventArgs e) { try { if (this.DCS.DataConnectionCount > 0 && LISTBOX_DATA_CONNECTION.SelectedIndex >= 0) { DATA_CONNECTION.MyDataConnection MDC = this.DCS.get_SelectedDataConnection(this.LISTBOX_DATA_CONNECTION.SelectedIndex); this.sender_port.Text = MDC.SENDER.ID.ToString(); this.receiver_port.Text = MDC.RECEIVER.ID.ToString(); } } catch (Exception ex) { while (true) { myDialog dialog = new myDialog(ex.Message); if (dialog.ShowDialog() == true) { break; } } } }
private bool serch_connection(MyDataConnection obj) { if (obj.SENDER == this.sender && obj.RECEIVER == this.receiver) { obj.Disconnect(); return true; } else { return false; } }
private bool allconnections(MyDataConnection obj) { obj.Disconnect(); return true; }
private bool allconnections(MyDataConnection obj) { obj.Disconnect(); return(true); }