Ejemplo n.º 1
0
        private void openProject()
        {
            if (this.isChanged)
            {
                MessageBoxResult ret = MessageBox.Show("当前项目已经被修改,在打开新项目前是否要保存当前修改?", "记忆工具", MessageBoxButton.YesNoCancel, MessageBoxImage.Question);
                if (ret == MessageBoxResult.Yes)
                {
                    if (!this.saveProject())
                    {
                        return;
                    }
                }
                else if (ret == MessageBoxResult.No)
                {
                }
                else if (ret == MessageBoxResult.Cancel)
                {
                    return;
                }
            }

            OpenFileDialog dlg = new OpenFileDialog();

            dlg.Filter = "记忆项目文件|*.mre";
            if (dlg.ShowDialog().Value)
            {
                this.memorizeEntry = MemorizeEntry.Load(dlg.FileName);
                this.DataContext   = this.memorizeEntry;
                this.projectFile   = dlg.FileName;

                if (this.memorizeEntry.Stages.Count > 0 &&
                    this.memorizeEntry.Stages[0] is MemorizeMathStage)
                {
                    MemorizeMathCreatorUserControl mathCreator = new MemorizeMathCreatorUserControl(this.memorizeEntry);
                    this.creatorStackPanel.Children.Clear();
                    this.creatorStackPanel.Children.Add(mathCreator);
                }
                else
                {
                    MemorizeCreatorUserControl generalCreator = new MemorizeCreatorUserControl(this.memorizeEntry);
                    this.creatorStackPanel.Children.Clear();
                    this.creatorStackPanel.Children.Add(generalCreator);
                }

                foreach (var item in UIHelper.MemorizeTypeItems)
                {
                    if (item.Type == this.memorizeEntry.SubType)
                    {
                        this.subTypeComboBox.SelectedItem = item;
                        break;
                    }
                }
            }
        }
Ejemplo n.º 2
0
        private void newProject()
        {
            if (this.isChanged)
            {
                MessageBoxResult ret = MessageBox.Show("当前项目已经被修改,在新建项目前是否要保存当前修改?", "记忆工具", MessageBoxButton.YesNoCancel, MessageBoxImage.Question);
                if (ret == MessageBoxResult.Yes)
                {
                    if (!this.saveProject())
                    {
                        return;
                    }
                }
                else if (ret == MessageBoxResult.No)
                {
                }
                else if (ret == MessageBoxResult.Cancel)
                {
                    return;
                }
            }

            NewWindow newWindow = new NewWindow();

            if (newWindow.ShowDialog().Value)
            {
                this.memorizeEntry = new MemorizeEntry();
                this.DataContext   = this.memorizeEntry;
                this.projectFile   = string.Empty;
                this.isChanged     = false;

                if (newWindow.Type == 0)
                {
                    MemorizeCreatorUserControl generalCreator = new MemorizeCreatorUserControl(this.memorizeEntry);
                    this.creatorStackPanel.Children.Clear();
                    this.creatorStackPanel.Children.Add(generalCreator);
                }
                else if (newWindow.Type == 1)
                {
                    MemorizeMathCreatorUserControl mathCreator = new MemorizeMathCreatorUserControl(this.memorizeEntry);
                    this.creatorStackPanel.Children.Clear();
                    this.creatorStackPanel.Children.Add(mathCreator);
                }
            }
        }