public NotePreviewViewModel(int id)
 {
     db = new DBContext(DBContext.DBConnectString);
     this.Note = (from n in this.db.Notes
                  where n.Id == id
                  select n).FirstOrDefault<Note>();
 }
Esempio n. 2
0
 public MainViewModel(string search, string search2)
 {
     this._filter = string.Empty;
     this.db = new DBContext(DBContext.DBConnectString);
     this.FavoriteNotes = new ObservableCollection<Note>();
     this.NotFavoriteNotes = new ObservableCollection<Note>();
     this.Read(true, search);
     this.Read(false, search2);
 }
Esempio n. 3
0
        /// <summary>
        /// Application 对象的构造函数。
        /// </summary>
        public App()
        {
            // 未捕获的异常的全局处理程序。
            UnhandledException += Application_UnhandledException;

            // 标准 XAML 初始化
            InitializeComponent();

            // 特定于电话的初始化
            InitializePhoneApplication();

            // 语言显示初始化
            InitializeLanguage();

            // 调试时显示图形分析信息。
            if (Debugger.IsAttached)
            {
                // 显示当前帧速率计数器。
                Application.Current.Host.Settings.EnableFrameRateCounter = true;

                // 显示在每个帧中重绘的应用程序区域。
                //Application.Current.Host.Settings.EnableRedrawRegions = true;

                // 启用非生产分析可视化模式,
                // 该模式显示递交给 GPU 的包含彩色重叠区的页面区域。
                //Application.Current.Host.Settings.EnableCacheVisualization = true;

                // 通过禁用以下对象阻止在调试过程中关闭屏幕
                // 应用程序的空闲检测。
                //  注意: 仅在调试模式下使用此设置。禁用用户空闲检测的应用程序在用户不使用电话时将继续运行
                // 并且消耗电池电量。
                PhoneApplicationService.Current.UserIdleDetectionMode = IdleDetectionMode.Disabled;
            }

            string language = AppSettingHelper.GetValueOrDefault(AppSettingHelper.LanguageKey, "zh-CN");
            CultureInfo cultureInfo = new CultureInfo(language);
            AppResources.Culture = cultureInfo;
            using (DBContext db = new DBContext(DBContext.DBConnectString))
            {
                if (db.DatabaseExists() == false)
                {
                    db.CreateDatabase();
                }
            }
        }
        public AddEditNoteViewModel(int id)
        {
            this.db = new DBContext(DBContext.DBConnectString);
            this.ListColor = new ListEnum<ColorModel>();
            this.ListViewModels = new List<ViewModelNewBase>();
            if (id == 0)
            {
                this.StateModel = StateModel.New;
                this.Note = new Note();
            }
            else if (id > 0)
            {
                this.StateModel = StateModel.Update;
                IQueryable<Note> source = from m in this.db.Notes where m.Id == id select m;
                if (source.Count<Note>() > 0)
                {
                    this.Note = source.First<Note>();
                    this.ListViewModels.Clear();
                    foreach (NoteDetail dett in this.Note.Body)
                    {
                        if (!string.IsNullOrEmpty(dett.Text))
                        {
                            TextViewModel item = new TextViewModel
                            {
                                CurrentText = dett.Text
                            };
                            this.ListViewModels.Add(item);
                        }
                        else
                        {
                            DrawViewModel draw = new DrawViewModel
                            {
                                CurrentList = dett.ListPageDraw
                            };
                            this.ListViewModels.Add(draw);
                        }
                    }

                    this.IndexColor = this.ListColor.Where<KeyValuePair<string, ColorModel>>(m => ((ColorModel)m.Value) == this.Note.Color)
                        .Select<KeyValuePair<string, ColorModel>, int>(m => this.ListColor.IndexOf(m)).First<int>();
                }
            }
        }