Exemplo n.º 1
0
    internal async void SelectFile()
    {
      
      Assembly asm = Assembly.GetEntryAssembly();
      string AsmFPath = asm.Location;
      string[] AsmFPathArr=AsmFPath.Split('\\');
      AsmFPath = AsmFPathArr[0];
      for (int i = 1; i < AsmFPathArr.Length - 1; i++) AsmFPath += ("\\" + AsmFPathArr[i]);
      
      //https://johobase.com/wpf-file-folder-common-dialog/
      var ofildig = new OpenFileDialog();
      ofildig.Filter = "CSVファイル (*.csv)|*.csv";
      if (ofildig.ShowDialog() == true)
      {
        List<string> FileContentList = new List<string>();
        string filec = string.Empty;
        try
        {
          using (StreamReader sr = new StreamReader(ofildig.OpenFile()))
          {
            filec = await sr.ReadToEndAsync();
          }
          try
          {
            if (filec != null && filec != string.Empty) foreach (string s in filec.Replace("\r", string.Empty).Split('\n')) FileContentList.Add(s);
            else UsefulFunc.MsgBxShow("文字列がnull or Empty", "Listing Error");
          }
          catch (Exception e)
          {
            UsefulFunc.MsgBxShow(e.ToString(), "Listing Error");
            return;
          }
        }
        catch (Exception e)
        {
          UsefulFunc.MsgBxShow(e.Message, "Error LimExpTIMSDisp");
        }
        CnvCSVtoClass(FileContentList);
      }
      else return;
#endif
    }
Exemplo n.º 2
0
        private void OnL3BClick(object sender, RoutedEventArgs e)
        {
#if WINDOWS_UWP
            try
            {
                if (ApplicationView.GetForCurrentView().IsFullScreenMode)
                {
                    ApplicationView.GetForCurrentView().ExitFullScreenMode();
                }
                else
                {
                    ApplicationView.GetForCurrentView().TryEnterFullScreenMode();
                }
            }
            catch (Exception ex)
            {
                UsefulFunc.MsgBxShow(ex.Message, "Displaying-Mode-Changing Failed");
            }
#elif WPF
            WindowState WinState = Application.Current.MainWindow.WindowState;
            WindowStyle WinStyle = Application.Current.MainWindow.WindowStyle;
            if (WinState == WindowState.Maximized)
            {
                if (WinStyle == WindowStyle.None)
                {
                    WinStyle = WindowStyle.SingleBorderWindow;
                    WinState = WindowState.Normal;
                }
                else
                {
                    WinStyle = WindowStyle.None;
                }
            }
            else
            {
                WinStyle = WindowStyle.None;
                WinState = WindowState.Maximized;
            }
#endif
        }
Exemplo n.º 3
0
    internal async void SelectFile(){
          //https://docs.microsoft.com/ja-jp/windows/uwp/files/quickstart-using-file-and-folder-pickers
      StorageFile TimeTableFile = null;
      var Picker = new FileOpenPicker()
      {
        ViewMode = PickerViewMode.List,
        SuggestedStartLocation = PickerLocationId.DocumentsLibrary,
      };
      Picker.FileTypeFilter.Add(".csv");
      TimeTableFile = await Picker.PickSingleFileAsync();
      if(TimeTableFile!=null){
      DecidedTTData = null;
      List<string> FileContentList = new List<string>();
      string filec = string.Empty;
      try
      {
        filec = await FileIO.ReadTextAsync(TTFile);
      }
      catch (Exception e)
      {
        
        UsefulFunc.MsgBxShow(e.ToString(), "File Read Error");
        return;
      }
      try
      {
        if (filec != null && filec != string.Empty) foreach (string s in filec.Replace("\r", string.Empty).Split('\n')) FileContentList.Add(s);
        else UsefulFunc.MsgBxShow("文字列がnull or Empty", "Listing Error");
      }
      catch (Exception e)
      {
        UsefulFunc.MsgBxShow(e.ToString(), "Listing Error");
        return;
      }

      CnvCSVtoClass(in FileContentList);
      }
}
Exemplo n.º 4
0
 private void OnL4BClick(object sender, RoutedEventArgs e) => UsefulFunc.MsgBxShow(Settings.LicenseString, "License");
Exemplo n.º 5
0
    private async void CnvCSVtoClass(List<string> FileContentList)
    {
      bool IsTimeTableEditing = false;
      bool IsOptDataEditing = false;
      TimeTableData TTD = new TimeTableData();
      TTList = new List<TimeTableData>();
      if (FileContentList == default || FileContentList == null)
      {
        UsefulFunc.MsgBxShow("ファイル内容の読み取りに失敗しました。", "Error");
        return;
      }
      foreach (string ContLine in FileContentList)
      {
        if (ContLine == null) continue;
        string Content = ContLine.Replace(" ", string.Empty);
        string[] RowData = ContLine.Split(',');
        if (RowData[0] == string.Empty) continue;//空行なら無視
        if (RowData[0].StartsWith("//")) continue;//"//"ならコメント
        if (RowData[0].StartsWith(";")) continue;//";"ならコメント
        if (RowData[0].StartsWith("#")) continue;//"#"ならコメント
        if (IsTimeTableEditing)
        {
          if (IsOptDataEditing)
          {
            switch (RowData[0])
            {
              case "TRTimeTableOPEOF":
                IsOptDataEditing = false;
                break;
              case "SlowPoint":
                try
                {
                  SlowPointData SPD = new SlowPointData() { LimitSpeed = double.Parse(RowData[1]) };
                  SPD.NoticeStartPoint = double.Parse(RowData[2]);
                  SPD.LimitStartPoint = double.Parse(RowData[3]);
                  SPD.EndPoint = double.Parse(RowData[4]);
                  TTD.SlowPointList.Add(SPD);
                }
                catch (Exception e)
                {
                  UsefulFunc.MsgBxShow("徐行警告機能の位置設定記述が正しくありません。\n" + e.Message, "SlowPoint Location Parsing Error");
                  DecidedTTData = null;
                  InsertedICInfo = null;
                  return;
                }
                break;
              case "AirSec":
                try
                {
                  TTD.AirSecList.Add(new SectionData()
                  {
                    NoticeStartPoint = double.Parse(RowData[1]),
                    EndPoint = double.Parse(RowData[2])
                  });
                }
                catch (Exception e)
                {
                  UsefulFunc.MsgBxShow("エアセクション警告機能の位置設定記述が正しくありません。\n" + e.Message, "AirSection Location Parsing Error");
                  DecidedTTData = null;
                  InsertedICInfo = null;
                }
                break;
              case "ACDCChange":
                try
                {
                  TTD.ACDCSecList.Add(new SectionData()
                  {
                    NoticeStartPoint = double.Parse(RowData[1]),
                    EndPoint = double.Parse(RowData[2])
                  });
                }
                catch (Exception e)
                {
                  UsefulFunc.MsgBxShow("交直切換警告機能の位置設定記述が正しくありません。\n" + e.Message, "AC-DC Section Location Parsing Error");
                  DecidedTTData = null;
                  InsertedICInfo = null;
                }
                break;
              case "ACACSec":
                try
                {
                  TTD.ACACSecList.Add(new SectionData()
                  {
                    NoticeStartPoint = double.Parse(RowData[1]),
                    EndPoint = double.Parse(RowData[2])
                  });
                }
                catch (Exception e)
                {
                  UsefulFunc.MsgBxShow("交交セクション警告機能の位置設定記述が正しくありません。\n" + e.Message, "AC-AC Section Location Parsing Error");
                  DecidedTTData = null;
                  InsertedICInfo = null;
                }
                break;
              case "RadioCH":
                try
                {
                  TTD.RCHChangePList.Add(new RadioCHChangingData()
                  {
                    ChangeTo = RowData[1],
                    ChangePoint = double.Parse(RowData[2])
                  });
                }
                catch (Exception e)
                {
                  UsefulFunc.MsgBxShow("無線チャンネル自動切換機能の設定記述が正しくありません。\n" + e.Message, "Radio Channel Changing Function Error");
                  DecidedTTData = null;
                  InsertedICInfo = null;
                }
                break;
              case "LineColorChange":
                try
                {
                  TTD.LineColorList.Add(new LineColorChangingData()
                  {
                    ColorTo = StrToSCB(RowData[1]),
                    StaID = int.Parse(RowData[2])
                  });
                }
                catch (Exception e)
                {
                  UsefulFunc.MsgBxShow("進行線色変更機能の設定記述が正しくありません。\n" + e.Message, "Line Color Changing Function Error");
                  DecidedTTData = null;
                  InsertedICInfo = null;
                }
                break;
            }
          }
          else
          {
            switch (RowData[0])
            {
              case "TRTimeTableOP100":
                IsOptDataEditing = true;
                break;
              case "TRTimeTableEOF":
                IsTimeTableEditing = false;
                TTList.Add(TTD);
                break;
              default://各駅設定
                StaInfo SI = new StaInfo();
                try
                {
                  int c = 0;
                  SI.StaName = RowData[c++];
                  try
                  {
                    SI.StaLocation = double.Parse(RowData[c++]);
                  }
                  catch (Exception e)
                  {
                    UsefulFunc.MsgBxShow("駅位置の設定記述が正しくありません。\n" + e.Message, "Station Location Parsing Error");
                    DecidedTTData = null;
                    InsertedICInfo = null;
                    return;
                  }
                  SI.RunMM = RowData[c++].ToNarrow();
                  SI.RunSS = RowData[c++].ToNarrow();
                  SI.ArrHH = RowData[c++].ToWide();
                  SI.ArrMM = RowData[c++].ToWide();
                  SI.ArrSS = RowData[c++].ToNarrow();
                  SI.ArrSymbol = RowData[c++];
                  SI.IsPass = RowData[c++] == "1";
                  SI.DepHH = RowData[c++].ToWide();
                  SI.DepMM = RowData[c++].ToWide();
                  SI.DepSS = RowData[c++].ToNarrow();
                  SI.DepSymbol = RowData[c++];
                  SI.TrackName = RowData[c++];
                  SI.RuninLim = RowData[c++].ToNarrow();
                  SI.RunoutLim = RowData[c++].ToNarrow();
                  int StaWorkIndex = c++;
                  if (RowData[StaWorkIndex] != string.Empty)
                  {
                    try
                    {
                      SI.StaWork = (StaWorkEnum)int.Parse(RowData[StaWorkIndex]);
                    }
                    catch (Exception e)
                    {
                      UsefulFunc.MsgBxShow("駅仕業の設定記述が正しくありません。\n" + e.Message, "StationWork Parsing Error");
                      DecidedTTData = null;
                      InsertedICInfo = null;
                      return;
                    }
                  }
                  SI.DispColor = StrToSCB(RowData[c++]);
                  if (SI.ArrSS == string.Empty) SI.ArrSS = "0";
                  if (SI.DepSS == string.Empty) SI.DepSS = "0";
                  TTD.TTList.Add(SI);
                }
                catch (Exception e)
                {
                  UsefulFunc.MsgBxShow("駅の設定記述が正しくありません。\n" + e.Message, "StationData Parsing Error");
                  DecidedTTData = null;
                  InsertedICInfo = null;
                  return;
                }

                break;
            }
          }
        }
        else
        {
          switch (RowData[0])
          {
            case "TRTimeTable100":
              if (RowData.Length >= 8)
              {
                TTD = new TimeTableData();
                TTD.TrainNum = RowData[1].ToWide();
                TTD.PTrainNum = RowData[2].ToWide();
                TTD.IsPassDefault = RowData[3] == "1";
                TTD.IsDirectionLeft = RowData[4] == "1";
                TTD.RadioNum = RowData[5] == string.Empty ? "-" : RowData[5].ToNarrow();
                TTD.LineColor = StrToSCB(RowData[6]);
                TTD.LastStation = RowData[7];
                IsTimeTableEditing = true;
                TTD.LineColorList.Add(new LineColorChangingData() { ColorTo = TTD.LineColor, StaID = 0 });
              }
              else
              {
                UsefulFunc.MsgBxShow("時刻表設定のヘッダー行形式が正しくありません。", "IC File Error");
                DecidedTTData = null;
                InsertedICInfo = null;
                return;
              }
              break;
            case "TRTimeTableIC100":
              if (RowData.Length >= 6)
              {
                InsertedICInfo = new ICSettingInfo();
                InsertedICInfo.OfficeName = RowData[1];
                InsertedICInfo.WorkNumber = RowData[2].ToWide();
                InsertedICInfo.EffectedDateYY = RowData[3].ToNarrow();
                InsertedICInfo.EffectedDateMM = RowData[4].ToNarrow();
                InsertedICInfo.EffectedDateDD = RowData[5].ToNarrow();
              }
              else
              {
                UsefulFunc.MsgBxShow("IC情報設定の形式が正しくありません。", "IC File Error");
                DecidedTTData = null;
                InsertedICInfo = null;
                return;
              }
              break;
          }
        }
      }
      if (IsTimeTableEditing || IsOptDataEditing)
      {
        UsefulFunc.MsgBxShow("行路ICカードファイルの設定が終了していません。\nEOF記述を追加してください。", "EOF Not Found Error");
        DecidedTTData = null;
        InsertedICInfo = null;
        return;
      }
      switch (TTList.Count)
      {
        case 0:
          DecidedTTData = null;
          break;
        case 1:
          TimeTablesPicked(0);
          break;
        default:
          await Task.Delay(100 * TTList.Count);
          ManyTTDataInput?.Invoke(null, null);
          break;
      }
    }