G3514_And_note_日付指定表示

2025211

7:16

G3514_andoroid_and_note_date_display

 

説明

 

 

状態表示のテキストを追加します

 

 

 

 

 

テキスト部品を配置します

 

 

ドラッグアンドドロップで配置します

 

配置可能なポイントがタイトになっております、下記の表示でマウスを離すと配置が成功します

 

 

スクロールして終端に移動するとこのように追加されています

 

 

 

 

不明な点もたくさんありますが、配置はこれで良しとします

表示サイズは、いろいろ試して、Smallに決定しました

 

 

    <TextView

android:text="Large Text"

android:textAppearance="?android:attr/textAppearanceSmall"

android:layout_width="570.0dp"

android:layout_height="wrap_content"

android:layout_below="@id/button4"

android:id="@+id/textView1"

        />

 

案内メッセージが代入できるかテストします

 

 

public static TextView[] Txt_tbl = new TextView[3];

 

Txt_tbl[0] = (TextView)FindViewById(Resource.Id.textView1);

 

 

dsp_info() dsp_info_clr() を修正します

 

 

 

// 臨時のインフォメーション

private void dsp_info(string prm_msg)

{

Txt_tbl[0].Text = prm_msg;

}

 

// 臨時のインフォメーション 初期化

private void dsp_info_clr()

{

Txt_tbl[0].Text = "";

}

 

動作確認出来たら、テスト表示は消します

 

 

音声入力された日付を判定する関数を作成します

 

下記は修正された最新コードが存在します

 

// 先頭の日付入力を判定します

private bool date_input_chk(string prm_input, string[] prm_ans_tbl)

{

string[] fld_tbl = new string[30];

int tmp_dat;

int yy_all, mm, dd;

int dd_tbl_no = 2;

DateTime dt = DateTime.Now;

string msg_cst = "";

int msg_fld_sta = 3;

int cnt;

 

if (prm_ans_tbl.Length < 4)

{

msg2("date_input_chk()", "配列個数が不足しています", "");

return false;

}

 

yy_all = mm = dd = 0;

 

fld_tbl = prm_input.Split('', '', '');

if (fld_tbl.Length < 3)

{

// フリック入力にも対応します

fld_tbl = prm_input.Split('/');

if(fld_tbl.Length < 3) return false;

}

 

// 先頭が数値変換出来る

if (int.TryParse(fld_tbl[0], out tmp_dat) == false) return false;

if (1980 <= tmp_dat && tmp_dat <= 2199)

{

yy_all = tmp_dat;

if (int.TryParse(fld_tbl[1],out mm) == false) return false;

}

else

{

mm = tmp_dat;

// 年度の明示がない場合、本年度に限定する

yy_all = dt.Year;

dd_tbl_no = 1;

}

if (mm < 1 || 12 < mm) return false; // 月範囲エラー

 

if (int.TryParse(fld_tbl[dd_tbl_no],out dd) == false) return false;

if(dd < 1 || 31 < dd) return false;     // 日付範囲エラー

 

// 将来後方に続く文字列も扱う場合を考慮します

msg_fld_sta = dd_tbl_no + 1;

 

if(msg_fld_sta < fld_tbl.Length)

{

for (cnt = msg_fld_sta; cnt < fld_tbl.Length; cnt++)

msg_cst += fld_tbl[cnt].Trim();

}

 

prm_ans_tbl[0] = yy_all.ToString("D4");

prm_ans_tbl[1] = mm.ToString("D2");

prm_ans_tbl[2] = dd.ToString("D2");

prm_ans_tbl[3] = msg_cst;

 

return true;

}

 

 

「実行/保存」ボタン処理を変更します

 

 

// 日付が指定された場合の判定を追加します

if (date_input_chk(Edt_tbl[0].Text,fld_tbl) == true)

{

tmp_cst = fld_tbl[0] + "" + fld_tbl[1] + "" + fld_tbl[2] + "" + fld_tbl[3];

dsp_info(tmp_cst);

}

else

{

//  日付指定ではないので、通常の保存処理を実行します

edit_txt_sav();

 

}

 

心を落ち着けて、日にちを開けて考察しました

 

 

「実行/保存」ボタンの処理を変更します

 

 

 

// 実行保存ボタン処理

private void exe_save_but()

{

string[] fld_tbl = new string[10];

string msg_cst = "";

 

DateTime dt = DateTime.Now;

int today = (dt.Year * 365) + (dt.Month * 31) + dt.Day;

int inp_day,yy_all,mm,dd;

bool edit_clr_flg = true;

bool dsp_flg = false;

 

dsp_info_clr();

 

switch (Command_name)

{

case "音声変換":

// 日付が指定された場合の判定を追加します

if (date_input_chk(Edt_tbl[0].Text,fld_tbl) == true)

{

msg_cst = fld_tbl[0] + "" + fld_tbl[1] + "" + fld_tbl[2] + "" + fld_tbl[3];

yy_all = int.Parse(fld_tbl[0]);

mm = int.Parse(fld_tbl[1]);

dd = int.Parse(fld_tbl[2]);

inp_day = (yy_all * 365) + (mm * 31) + dd;

 

if (fld_tbl[3] != "")

{

// 日付の後方に文字列があり、予定登録と判定します

// 指示された日付が未来であることも判定します

if (today < inp_day)

{

// 後方のメッセージを指定された未来に更新します

edit_txt_sav(yy_all, mm, dd, fld_tbl[3]);

msg_cst += " 予定を保存しました";

dsp_info(msg_cst);

}

else dsp_flg = true;

}

else dsp_flg = true;

 

if(dsp_flg == true)

{

// 指示された日付のデータを表示します

command_name_set("過去未来表示");

dsp_note(yy_all, mm, dd);

msg_cst += " を表示しました";

dsp_info(msg_cst);

edit_clr_flg = false;

}

 

}

else

{

//  日付指定ではないので、通常の保存処理を実行します

edit_txt_sav(0, 0, 0, Edt_tbl[0].Text);

 

}

break;

}

if(edit_clr_flg == true) Edt_tbl[0].Text = "";

 

}

 

テキストファイルの保存処理を変更します

 

 

年度がゼロ指定されたら、本日処理とします

 

 

 

 

過去日付が指定されたら、中断します

 

 

本日と未来を判定します

 

 

// 音声テキストの日単位保持処理

private async void edit_txt_sav(int prm_yy_all,int prm_mm,int prm_dd,string prm_data)

{

string wrt_cst;

string fil_path;

string[] fld_tbl = new string[20];  // レコードの構成要素

int yy_all = prm_yy_all;

int mm = prm_mm;

int dd = prm_dd;

int th, tm, ts;

string flg_cst = "";

int today, inp_day;

 

Sys_cal_get();      //  システム日付取得

today = (Sys_yy_all * 365) + (Sys_mm * 31) + Sys_dd;

// 年度がゼロで指定された場合、本日として処理します

if (ymd_chk(yy_all, mm, dd) == false)

{

yy_all = Sys_yy_all;

mm = Sys_mm;

dd = Sys_dd;

}

 

// 過去日付が指定されたら中断します

inp_day = (yy_all*365) + (mm*31) + dd;

if(inp_day < today)

{

dsp_info("過去のデータは保存出来ません");

return;

}

 

// 本日と未来を判定します

if (today < inp_day)

{

th = tm = ts = 0;

flg_cst = "予定";

}

else

{

th = Sys_th;

tm = Sys_tm;

ts = Sys_ts;

}

 

fil_path = Get_fil_path(yy_all,mm,dd, "");

 

// ファイルを開く

System.Text.Encoding.GetEncoding("utf-8");

using (StreamWriter writer = new StreamWriter(fil_path, true))

{

fld_tbl[0] = yy_all.ToString("D4");        //

fld_tbl[1] = mm.ToString("D2");                //

fld_tbl[2] = dd.ToString("D2");                //

fld_tbl[3] = th.ToString("D2");                //

fld_tbl[4] = tm.ToString("D2");                //

fld_tbl[5] = ts.ToString("D2");     //

fld_tbl[6] = prm_data;                                // 登録データ

 

// 本日データのみGPS取得します

if(flg_cst == "") await get_GPS();

 

fld_tbl[7] = Gps_cst;

fld_tbl[8] = "";        //

fld_tbl[9] = "";        //

fld_tbl[10] = "";        //

fld_tbl[11] = flg_cst;        // フラグデータ

 

wrt_cst = txt_fil_rec_gene(fld_tbl);

 

writer.WriteLine(wrt_cst); // テキストを書き込む

writer.Flush();            // 書き込んだ内容をフラッシュする

}

Edt_tbl[0].Text = Voice_cst = "";

 

}

 

新しく日付範囲の検査関数を作ります

 

 

// 日付範囲を検査します

private bool ymd_chk(int prm_yy_all, int prm_mm, int prm_dd)

{

if (prm_yy_all < 1980 || 2199 < prm_yy_all) return false;

if(prm_mm < 1 || 12 < prm_mm) return false;

if(prm_dd < 1 || 31 < prm_dd) return false;

return true;

}

 

edit_txt_sav() 関数をすべて検索し、パラメータを追加します

 

 

 

 

 

today_dsp()関数を修正します

 

 

 

 

年度にゼロが指定されたら、本日処理にします

 

 

// ノートデータ表示

private void dsp_note(int prm_yy_all,int prm_mm,int prm_dd)

{

string fil_path;

string[] cut_tbl = new string[30];

string lin_cst = "";

int lin_no = 0;

int cnt;

bool find_flg;

int yy_all = prm_yy_all;

int mm = prm_mm;

int dd = prm_dd;

 

Sys_cal_get();      //  システム日付取得

// 年度がゼロで指定された場合、本日として処理します

if (ymd_chk(yy_all,mm,dd) == false)

{

yy_all = Sys_yy_all;

mm = Sys_mm;

dd = Sys_dd;

}

 

fil_path = Get_fil_path(yy_all, mm, dd, "");

 

if(System.IO.File.Exists(fil_path) == false) return;

 

Edt_tbl[0].Text = "";

Note_lin_cnt = 0;

// テキストファイル読み込み

System.Text.Encoding.GetEncoding("utf-8");

using (StreamReader red = new StreamReader(fil_path))

{

while (red.EndOfStream == false)

{

// 0     1   2   3   4   5  6    7    8   9   10  11

// yyyy  mm  dd  th  tm  ts msg  GPS  th  tm  ts  msg

lin_cst = red.ReadLine();

if (lin_cst == null) continue;

 

// 2025.02.06 THU (05:33) goma0099 -12577505-

// 書式不正のデータを無視します

if (rec_form_chk(lin_cst) == false) continue;

 

cut_tbl = lin_cst.Split(',');

 

++lin_no;

++Note_lin_cnt;

 

// 除外ワードの判定を追加します

find_flg = false;

for (cnt = 0; cnt < Exclu_key_cnt; cnt++)

{

// 先頭文字とキーワードが一致したら除外します

// 一致しない場合(-1) 一致しても先頭以外は1以上の整数になります

if (cut_tbl[6].IndexOf(Exclu_key_tbl[cnt], 0) == 0)

{

find_flg = true;

break;

}

}

 

if (find_flg == false) Edt_tbl[0].Text += lin_no.ToString() + "." + cut_tbl[6] + "\r\n";

}

}

 

}

 

対象箇所をすべて変更します

 

 

 

 

 

 

「取消し」ボタンのとき、案内表示をクリアします

 

 

2025131日以前のデータでレコード要素不一致が出ます

 

 

 

フリック入力で「2/20」のように日付を入力しての予定登録や日付指定の表示が出来ません

 

 

 

 

 

// 年度が省略されて月日だけの場合があります

if (fld_tbl.Length < 2)

{

// フリック入力にも対応します

// 区切り文字に、半角スペース、全角スペースを追加しました

// 予定入力の場合 2/20 歯科予約などのように入力しますが

// /」だけだと、日データが分割されず、データとして登録されます

fld_tbl = prm_input.Split('/',' ',' ');

if(fld_tbl.Length < 2) return false;

}

 

なにかのタイミングで、過去の一覧表示が、本日データとして登録されました

 

 

 

 

 

 

「コマンド」「コマンドモード」に役割が出来てしまってわかりにくいものになりました

 

 

過去日付表示のテスト

 

 

 

過去日を間違えて予定登録しようとした場合、無視されて一覧表示が出るだけですが

 

 

 

予定登録のテスト

 

 

 

未来日付を表示してみます