Esempio n. 1
0
        private void addPanel_importButton_Click(string title)
        {
            try {
                string            path = HKOpenFileDialog.selectFile(HKDialogFilter.Library);
                AttandanceLibrary lib  = FileSerilizeOpener <AttandanceLibrary> .open(path);

                AttandanceLibrary oldLib   = null;
                DJTUBinary        librarys = GlobalStation.shareInstance.librarys;
                librarys.isCustomize = false;
                if (librarys.containsLibrary(lib))
                {
                    handleOverwrite(lib, ref oldLib);
                }
                librarys.addLib(lib);
                GlobalStation.shareInstance.librarySave(delegate() {
                    initTableViewContent();
                    resize(null, null);
                }, delegate() {
                    if (oldLib != null)
                    {
                        librarys.addLib(oldLib);
                    }
                    librarys.removeLib(lib.UUID);
                });
            } catch (HKOpenFileDialog.CancelOpenFileException) { }
        }
        private void configureNameTextBox()
        {
            nameTextBox.textBox.BackColor = Helper.getColorByAddBri(Helper.ToColor(Helper.normalColor), -0.05f);
            nameTextBox.borderColor       = Helper.ToColor(Helper.deepColor);
            nameTextBox.resize(null, null);
            AttandanceLibrary lib = libHall.libraryRef;

            nameTextBox.text = lib.name;
            pswBox.text      = lib.password;
            remarkBox.text   = lib.remarks;
        }
Esempio n. 3
0
        private void addPanel_openButton_Click(string title)
        {
            try {
                string            path = HKOpenFileDialog.selectFile(HKDialogFilter.Library);
                AttandanceLibrary lib  = FileSerilizeOpener <AttandanceLibrary> .open(path);

                GlobalStation.shareInstance.librarys.isCustomize      = true;
                GlobalStation.shareInstance.librarys.customizeLibrary = CustomLibrary.createLibrary(lib, path);
                LibraryHallPanel hall = new LibraryHallPanel();
                hall.libraryUUID = lib.UUID;
                GlobalStation.shareInstance.entrance.showPanel(hall);
            }catch (HKOpenFileDialog.CancelOpenFileException) { }
        }
Esempio n. 4
0
        private void deleteTheCourseFromLibrary(string courseId)
        {
            AttandanceLibrary lib = libHall.libraryRef;

            if (lib.containsCourse(courseId))
            {
                Model.Course course = lib[courseId];
                lib.removeCourse(course);
                GlobalStation.shareInstance.librarySave(null, delegate() {
                    lib.addCourse(course);
                });
                libHall.contentInit();
            }
        }
Esempio n. 5
0
        private string confirm_libraryCreate(string name, string remarks, string password)
        {
            AttandanceLibrary lib = new AttandanceLibrary(name, remarks);

            lib.password = password;
            GlobalStation.shareInstance.librarys.addLib(lib);
            string UUID = lib.UUID;

            GlobalStation.shareInstance.librarySave(null, delegate() {
                GlobalStation.shareInstance.librarys.collections.Remove(lib);
                UUID = null;
            });
            return(UUID);
        }
Esempio n. 6
0
        private void exportButton_Click(object sender, EventArgs e)
        {
            try {
                GlobalStation.shareInstance.librarys.isCustomize = false;
                AttandanceLibrary lib  = GlobalStation.shareInstance.librarys[libraryUUID];
                string            path = HKSaveFileDialog.saveTo(HKDialogFilter.Library);
                FileSerializeStorage <AttandanceLibrary> .save(lib, path);

                HKConfirmForm.showConfirmForm("导出成功");
            } catch (HKSaveFileDialog.CancelSaveFileException) {
            } catch (FileSerializeStorage <AttandanceLibrary> .FileSaveException ex) {
                HKConfirmForm.showConfirmForm(ex.Message);
            }
        }
        private void deleteButton_Click(object sender, EventArgs e)
        {
            HKConfirmForm form = new HKConfirmForm();

            form.title = "确定要删除?";
            if (form.showConfirm() == true)
            {
                AttandanceLibrary lib = GlobalStation.shareInstance.librarys[libraryUUID];
                GlobalStation.shareInstance.librarys.removeLib(lib.UUID);
                GlobalStation.shareInstance.librarySave(delegate() {
                    backButton_Click(null, null);
                }, delegate() {
                    GlobalStation.shareInstance.librarys.addLib(lib);
                });
            }
        }
        private void overwriteOrCreateNew(AttandanceLibrary lib, Model.Course course)
        {
            HKConfirmForm form = new HKConfirmForm();

            form.title = "已存在该课程Id,是否覆盖?";
            if (form.showConfirm() == true)
            {
                lib.removeCourse(lib[course.id]);
                lib.addCourse(course);
            }
            else
            {
                course.id = Guid.NewGuid().ToString();
                lib.addCourse(course);
            }
        }
Esempio n. 9
0
        private void handleOverwrite(AttandanceLibrary lib, ref AttandanceLibrary oldLib)
        {
            DJTUBinary    librarys = GlobalStation.shareInstance.librarys;
            HKConfirmForm form     = new HKConfirmForm();

            form.title = "已存在相同的库,是否覆盖?";
            if (form.showConfirm() == true)
            {
                oldLib = librarys[lib.UUID];
                librarys.removeLib(lib.UUID);
            }
            else
            {
                lib.UUID = Guid.NewGuid().ToString();
            }
        }
Esempio n. 10
0
        private void showDeleteConfirmForm()
        {
            HKConfirmForm form = new HKConfirmForm();

            form.title = "确定要删除?";
            if (form.showConfirm() == true)
            {
                AttandanceLibrary lib = GlobalStation.shareInstance.librarys[libraryUUID];
                GlobalStation.shareInstance.librarys.removeLib(libraryUUID);
                GlobalStation.shareInstance.librarySave(null, delegate() {
                    GlobalStation.shareInstance.librarys.addLib(lib);
                });
                loginHall.initTableViewContent();
                loginHall.resize(null, null);
            }
        }
Esempio n. 11
0
        private void modifyInfo()
        {
            AttandanceLibrary lib = libHall.libraryRef;

            lib.name     = nameTextBox.text;
            lib.password = pswBox.text;
            if (!Helper.IsNullOrWhiteSpace(remarkBox.text))
            {
                lib.remarks = remarkBox.text;
            }
            else
            {
                lib.remarks = "作者什么都没留下";
            }
            GlobalStation.shareInstance.librarySave(delegate() {
                libHall.contentInit();
            }, null);
            Close();
        }
Esempio n. 12
0
        private void bar_deleteBtn_Click(object sender, EventArgs e)
        {
            AttandanceLibrary lib = GlobalStation.shareInstance.librarys[libraryUUID];

            Model.Course  course = courseRef;
            HKConfirmForm form   = new HKConfirmForm();

            form.title = string.Format("确定要删除课程《{0}》?", course.name);
            if (form.showConfirm() != true)
            {
                return;
            }
            if (lib.containsCourse(course.id))
            {
                lib.removeCourse(course);
            }
            GlobalStation.shareInstance.librarySave(delegate() {
                bar_backBtn_Click(null, null);
            }, delegate() {
                lib.addCourse(course);
            });
        }
        private void addPanel_importCourseBtn_Click(string title)
        {
            try {
                string       path   = HKOpenFileDialog.selectFile(HKDialogFilter.Course);
                Model.Course course = FileSerilizeOpener <Model.Course> .open(path);

                AttandanceLibrary lib = libraryRef;
                if (!lib.containsCourse(course.id))
                {
                    lib.addCourse(course);
                }
                else
                {
                    overwriteOrCreateNew(lib, course);
                }
                GlobalStation.shareInstance.librarySave(delegate() {
                    contentInit();
                }, null);
            }catch (HKOpenFileDialog.CancelOpenFileException e) {
                Console.WriteLine(e.Message);
            }catch (FileSerilizeOpener <Model.Course> .FileOpenException e) {
                HKConfirmForm.showConfirmForm(e.Message);
            }
        }