示例#1
0
        public ClassOption()
        {
            InitializeComponent();

            schedule      = UserData.scheduleClasses[ShareData.num];
            textBox1.Text = schedule.getName();

            //資料一覧の読み込み
            for (int i = 0; i < schedule.DocumentSize(); i++)
            {
                checkedListBox1.Items.Add(schedule.getDocument(i).getDocumentName(),
                                          schedule.getDocument(i).getOpen());
            }

            //時間一覧の読み込み
            for (int i = 0; i < schedule.TimeSize(); i++)
            {
                TimeClass time = schedule.getTime(i);
                string    text = "";
                for (int j = 0; j < ShareData.dayofWeek.Length; j++)
                {
                    if (time.getDay()[j])
                    {
                        text += ShareData.dayofWeek[j];
                    }
                }
                text += " " + time.getBeginTime().ToShortTimeString() + "~" + time.getEndTime().ToShortTimeString() + " " + time.getRoomName();
                checkedListBox2.Items.Add(text);
            }
        }
        private async void timer1_Tick(object sender, EventArgs e)
        {
            //講義時間が近づいたら通知するシステム
            for (int i = 0; i < UserData.scheduleClasses.Count; i++)
            {
                ScheduleClass schedule = UserData.scheduleClasses[i];
                for (int j = 0; j < schedule.TimeSize(); j++)
                {
                    TimeClass time        = schedule.getTime(j);
                    DateTime  beginTime   = time.getBeginTime();
                    DateTime  endTime     = time.getEndTime();
                    TimeSpan  beginSpan   = beginTime.TimeOfDay;
                    TimeSpan  endSpan     = endTime.TimeOfDay;
                    TimeSpan  fromSpan    = DateTime.Now.TimeOfDay - beginSpan;
                    TimeSpan  toSpan      = DateTime.Now.TimeOfDay - endSpan;
                    double    beginSecond = fromSpan.TotalSeconds;
                    double    endSecond   = toSpan.TotalSeconds;
                    bool[]    day         = time.getDay();
                    //Console.WriteLine((DateTime.Now.TimeOfDay - beginSpan).TotalSeconds + "秒前");
                    //10分前になったら もちろん曜日も考慮
                    if (beginSecond > -600 && beginSecond < -599 && day[(int)DateTime.Now.DayOfWeek])
                    {
                        notifyIcon1.BalloonTipIcon  = ToolTipIcon.Info;
                        notifyIcon1.BalloonTipTitle = "まもなく「" + schedule.getName() + "」";
                        notifyIcon1.BalloonTipText  = time.getRoomName() + "\n" + time.getBeginTime().ToShortTimeString() + "~";
                        notifyIcon1.ShowBalloonTip(5000);
                    }

                    //授業前後は出席していないことにする(実施されていないので当然である)
                    if (beginSecond < -10 && endSecond > 0)
                    {
                        time.setClass(false);
                        UserData.scheduleClasses[i].renewTime(time, j);
                    }

                    //スケジュール実行中の時間帯はこのタイマーを切る
                    if (beginSecond > -10 && endSecond < 0 && day[(int)DateTime.Now.DayOfWeek])
                    {
                        timer1.Enabled = false;
                        label3.Visible = true;
                        timer2.Enabled = true;
                    }
                }
            }
        }
示例#3
0
        private void SubFormClosed(object sender, EventArgs e)
        {
            checkedListBox2.Items.Clear();
            //時間一覧の読み込み
            for (int i = 0; i < schedule.TimeSize(); i++)
            {
                TimeClass time = schedule.getTime(i);
                string    text = "";
                for (int j = 0; j < ShareData.dayofWeek.Length; j++)
                {
                    if (time.getDay()[j])
                    {
                        text += ShareData.dayofWeek[j];
                    }
                }
                text += " " + time.getBeginTime().ToShortTimeString() + "~" + time.getEndTime().ToShortTimeString() + " " + time.getRoomName();
                checkedListBox2.Items.Add(text);
            }

            this.Enabled = true;
        }
示例#4
0
        private void button1_Click(object sender, EventArgs e)
        {
            //リストに同じ名前のものがあるか確認する
            for (int i = 0; i < UserData.scheduleClasses.Count; i++)
            {
                if (UserData.scheduleClasses[i].getName() == textBox1.Text)
                {
                    MessageBox.Show("すでに登録されている名前を新しく登録することはできません", "エラー", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    return;
                }
            }


            //新規フォルダ作成
            System.IO.DirectoryInfo di = System.IO.Directory.CreateDirectory(Environment.CurrentDirectory + "\\" + textBox1.Text);

            //ScheduleClass作成
            ScheduleClass schedule = new ScheduleClass();
            TimeClass     time     = new TimeClass();

            schedule.setName(textBox1.Text);
            time.setRoomName(listView2.SelectedItems[0].Text);
            int type = 0;

            if (!radioButton1.Checked)
            {
                type = 1;
            }
            time.setType(type);

            if (type == 0)
            {
                //リストから情環とか選んだものからBeginTimeとEndTimeを取得する
                Console.WriteLine("これが現実だ!" + listView1.SelectedItems[0].Text);
                time.setTimeTable(listView1.SelectedItems[0].Text);
                for (int i = 0; i < ShareData.timeTables.Count; i++)
                {
                    Console.WriteLine(ShareData.timeTables[i].getName());
                    if (listView1.SelectedItems[0].Text == ShareData.timeTables[i].getName())
                    {
                        time.setBeginTime(ShareData.timeTables[i].getBeginTime());
                        time.setEndTime(ShareData.timeTables[i].getEndTime());
                        break;
                    }
                }
            }
            else
            {
                time.setBeginTime(dateTimePicker1.Value);
                time.setEndTime(dateTimePicker2.Value);
            }

            bool[] day = new bool[7];
            day[0] = checkBox1.Checked;
            day[1] = checkBox2.Checked;
            day[2] = checkBox3.Checked;
            day[3] = checkBox4.Checked;
            day[4] = checkBox5.Checked;
            day[5] = checkBox6.Checked;
            day[6] = checkBox7.Checked;
            time.setDay(day);

            schedule.addTime(time);
            UserData.scheduleClasses.Add(schedule);

            this.Close();
        }
示例#5
0
        private void button1_Click(object sender, EventArgs e)
        {
            //ここからサーバー通信
            WebRequest  req = WebRequest.Create(url + "user_id=" + textBox1.Text + "&password="******"UTF-8"));
                String       result = reader.ReadToEnd();
                if (result.Contains("エラー"))
                {
                    MessageBox.Show("入力内容が違います!\nそれかUNIPAメンテナンス",
                                    "エラー",
                                    MessageBoxButtons.OK,
                                    MessageBoxIcon.Error);
                }
                //エラーでないなら時間割取得成功!JSONが返ってきているはず
                else
                {
                    var json = (dynamic)JsonConvert.DeserializeObject(result);
                    int num  = 0;
                    //string[] dayofWeek = new string[] { "sun", "mon", "tue", "wed", "thu", "fri", "sat" };
                    //曜日ずつforeach
                    foreach (var day in json)
                    {
                        //Console.WriteLine(day.ToString());
                        foreach (var time in day)
                        {
                            //時限ずつforeach
                            foreach (var element in time)
                            {
                                string TimeName = element["TimeName"];
                                string Name     = element["Name"];

                                TimeClass timeClass = new TimeClass();
                                TimeClass unipa     = new TimeClass();
                                timeClass.setType(1);
                                //TimeTableの特定
                                for (int i = 0; i < ShareData.timeTables.Count; i++)
                                {
                                    TimeTable timeTable = ShareData.timeTables[i];
                                    //もし"J1限"といった文字列が同じだったら
                                    if (TimeName == timeTable.getUnipaName())
                                    {
                                        unipa.setTimeTable(TimeName);
                                        unipa.setBeginTime(timeTable.getBeginTime());
                                        unipa.setEndTime(timeTable.getEndTime());
                                        Console.WriteLine(TimeName + "を登録");
                                        break;
                                    }
                                }


                                //もしないときこうなります
                                if (UserData.scheduleClasses.Count == 0)
                                {
                                    ScheduleClass schedule = new ScheduleClass();

                                    schedule.setName(Name);
                                    timeClass.setTimeTable(TimeName);
                                    timeClass.setBeginTime(unipa.getBeginTime());
                                    timeClass.setEndTime(unipa.getEndTime());
                                    timeClass.setOneDay(true, num);
                                    schedule.addTime(timeClass);
                                    UserData.scheduleClasses.Add(schedule);
                                    Console.WriteLine("はじめましての追加" + schedule.getName() + ShareData.dayofWeek[num]);
                                    //新規フォルダ作成
                                    System.IO.DirectoryInfo di = System.IO.Directory.CreateDirectory(Environment.CurrentDirectory + "\\" + schedule.getName());
                                    continue;
                                }
                                //すでにスケジュールが入っている場合
                                else
                                {
                                    for (int i = 0; i < UserData.scheduleClasses.Count; i++)
                                    {
                                        ScheduleClass schedule = UserData.scheduleClasses[i];
                                        if (Name == schedule.getName())
                                        {
                                            //開始時間と終了時間が同じなら曜日のみ追加
                                            for (int j = 0; j < schedule.TimeSize(); j++)
                                            {
                                                timeClass = schedule.getTime(j);
                                                //時限が同じだったら"J1限"といった文字列が同じだったらということ
                                                if (timeClass.getTimeTable() == TimeName)
                                                {
                                                    //曜日の登録
                                                    timeClass.setOneDay(true, num);
                                                    UserData.scheduleClasses[i].renewTime(timeClass, j);
                                                    Console.WriteLine("おきかえました" + UserData.scheduleClasses[i].getName() + ShareData.dayofWeek[num]);
                                                    break;
                                                }
                                                else if (j == schedule.TimeSize() - 1)
                                                {
                                                    TimeClass newTime = new TimeClass();
                                                    newTime.setTimeTable(TimeName);
                                                    newTime.setOneDay(true, num);
                                                    newTime.setBeginTime(unipa.getBeginTime());
                                                    newTime.setEndTime(unipa.getEndTime());
                                                    UserData.scheduleClasses[i].addTime(newTime);
                                                    Console.WriteLine(schedule.getName() + "のタイムを追加");
                                                }
                                            }
                                            break;
                                        }
                                        //その授業のスケジュールが追加されていない場合
                                        else if (i == UserData.scheduleClasses.Count - 1)
                                        {
                                            Console.WriteLine("スケジュールの新規追加");
                                            ScheduleClass newSchedule = new ScheduleClass();
                                            TimeClass     newTime     = new TimeClass();
                                            newSchedule.setName(Name);
                                            newTime.setOneDay(true, num);
                                            newTime.setTimeTable(TimeName);
                                            newTime.setBeginTime(unipa.getBeginTime());
                                            newTime.setEndTime(unipa.getEndTime());
                                            newSchedule.addTime(newTime);
                                            UserData.scheduleClasses.Add(newSchedule);
                                            System.IO.DirectoryInfo di = System.IO.Directory.CreateDirectory(Environment.CurrentDirectory + "\\" + newSchedule.getName());
                                        }
                                    }
                                }
                            }
                        }
                        num++;
                    }
                    //最後にできたという表示をしてウィンドウを閉じる
                    DialogResult message = MessageBox.Show("UNIPAから時間割を追加しました!",
                                                           "正常終了",
                                                           MessageBoxButtons.OK,
                                                           MessageBoxIcon.Information);
                    if (message == DialogResult.Yes)
                    {
                        this.Close();
                    }
                }
                stm.Close();
            }
            rsp.Close();
        }
        //4.1秒ごとにWifi測る(現在位置部屋特定)
        //このタイマーは授業中のみ実施
        private async void timer2_Tick(object sender, EventArgs e)
        {
            WifiInfo wifiInfo = new WifiInfo();

            foreach (BssNetworkPack network in NativeWifi.EnumerateBssNetworks())
            {
                wifiInfo.setSSID(network.Ssid.ToString());
                wifiInfo.setBSSID(network.Bssid.ToString().ToLower());
                wifiInfo.setRSSI(network.SignalStrength);
            }

            string rssi = WifiRSSI.SVMList(wifiInfo);

            Console.WriteLine(rssi);

            //ここからサーバー通信
            WebClient           wc = new WebClient();
            NameValueCollection ps = new NameValueCollection();

            ps.Add("rssi", rssi);
            byte[] resData = wc.UploadValues(url, ps);
            wc.Dispose();

            string resText = System.Text.Encoding.UTF8.GetString(resData);

            Console.WriteLine(resText);
            resText = resText.Trim();
            resText = WifiRSSI.RoomConv(resText);
            //label2.Text = resText;
            isRoom = resText;

            int num = 0;

            for (int i = 0; i < UserData.scheduleClasses.Count; i++)
            {
                ScheduleClass schedule = UserData.scheduleClasses[i];
                for (int j = 0; j < schedule.TimeSize(); j++)
                {
                    TimeClass time        = schedule.getTime(j);
                    DateTime  beginTime   = time.getBeginTime();
                    DateTime  endTime     = time.getEndTime();
                    TimeSpan  beginSpan   = beginTime.TimeOfDay;
                    TimeSpan  endSpan     = endTime.TimeOfDay;
                    TimeSpan  fromSpan    = DateTime.Now.TimeOfDay - beginSpan;
                    TimeSpan  toSpan      = DateTime.Now.TimeOfDay - endSpan;
                    double    beginSecond = fromSpan.TotalSeconds;
                    double    endSecond   = toSpan.TotalSeconds;
                    bool[]    day         = time.getDay();
                    //実行中である
                    if (beginSecond > 0 && endSecond < 0 && day[(int)DateTime.Now.DayOfWeek])
                    {
                        num++;

                        label1.Text = "現在";
                        label3.Text = UserData.scheduleClasses[i].getName();
                        //部屋にいるか?
                        if (isRoom == time.getRoomName())
                        {
                            label4.Visible = true;
                            //講義資料自動オープンをするよ
                            for (int k = 0; k < UserData.scheduleClasses[i].DocumentSize(); k++)
                            {
                                DocumentClass document = UserData.scheduleClasses[i].getDocument(k);
                                if (document.getOpen() && !time.getClass())
                                {
                                    //"C:\test\1.txt"を関連付けられたアプリケーションで開く
                                    System.Diagnostics.Process p =
                                        System.Diagnostics.Process.Start(Environment.CurrentDirectory + "\\" + UserData.scheduleClasses[i].getName() + "\\" + document.getDocumentName());

                                    if (k == UserData.scheduleClasses[i].DocumentSize() - 1)
                                    {
                                        time.setClass(true);
                                        UserData.scheduleClasses[i].renewTime(time, j);
                                    }
                                    //この辺に出席を送信する処理入れたい

                                    Console.WriteLine(document.getDocumentName() + " 開いた");
                                }
                                await Task.Delay(1000);
                            }
                        }
                    }
                }
            }
            //実行中のものがないときタイマー2を切ってタイマー1をオンにする
            if (num == 0)
            {
                timer1.Enabled = true;
                label3.Visible = false;
                label4.Visible = false;
                timer2.Enabled = false;
            }

            //更新
            RefreshAsync();
        }
 public void renewTime(TimeClass timeClass, int num)
 {
     timeClasses[num] = timeClass;
 }
 public void addTime(TimeClass timeClass)
 {
     timeClasses.Add(timeClass);
 }
示例#9
0
        public TimeOption()
        {
            InitializeComponent();

            //ShareData.TimeNumを見て、-1かそうでないかを判断
            if (ShareData.timeNum != -1)
            {
                timeClass             = UserData.scheduleClasses[ShareData.num].getTime(ShareData.timeNum);
                dateTimePicker1.Value = timeClass.getBeginTime();
                dateTimePicker2.Value = timeClass.getEndTime();
            }
            else
            {
                dateTimePicker2.Value = DateTime.Parse("23:59");
            }


            //部屋を追加処理
            for (int i = 0; i < ShareData.rooms.Count; i++)
            {
                listView2.Items.Add(ShareData.rooms[i].getRoomName());
            }
            for (int i = 0; i < listView2.Items.Count; i++)
            {
                Console.WriteLine(ShareData.rooms[i].getRoomName());
                if (timeClass.getRoomName() == ShareData.rooms[i].getRoomName())
                {
                    listView2.Items[i].Selected = true;
                }
            }

            //時間割を追加処理
            for (int i = 0; i < ShareData.timeTables.Count; i++)
            {
                listView1.Items.Add(ShareData.timeTables[i].getName());
            }
            if (timeClass.getType() == 0)
            {
                radioButton1.Checked = true;
                for (int i = 0; i < listView1.Items.Count; i++)
                {
                    if (timeClass.getTimeTable() == ShareData.timeTables[i].getName())
                    {
                        listView1.Items[i].Selected = true;
                    }
                }
            }
            else
            {
                radioButton2.Checked = true;
            }


            bool[] day = timeClass.getDay();
            checkBox1.Checked = day[0];
            checkBox2.Checked = day[1];
            checkBox3.Checked = day[2];
            checkBox4.Checked = day[3];
            checkBox5.Checked = day[4];
            checkBox6.Checked = day[5];
            checkBox7.Checked = day[6];
        }