Example #1
0
        //List<AppSettings> FakeAppSettings = new List<AppSettings>();
        //NuMedicsGlobalContext ctx;

        //public UnitTest1()
        //{
        //    InitContext();
        //}

        //private void InitContext()
        //{
        //    var builder = new DbContextOptionsBuilder<NuMedicsGlobalContext>().UseInMemoryDatabase();
        //    var nCtx = new NuMedicsGlobalContext(builder.Options);

        //    var apps = Enumerable.Range(1, 3).Select(s => new AppSettings {
        //        ApplicationId = Guid.NewGuid(),
        //        Description = $"Description {s}",
        //        LastUpdatedByUser = Guid.NewGuid(),
        //        Name = $"Name {s}",
        //        Value = $"Value {s}"
        //    });

        //    nCtx.AppSettings.AddRange(apps);
        //    int added = nCtx.SaveChanges();
        //    ctx = nCtx;
        //}

        //[TestMethod]
        public void TestMethod1()
        {
            string expected = FakeCollection.First().Name;
            var    repo     = new AppSettingsRepo(testCtx);
            var    app      = repo.Get().First();

            Assert.AreEqual(expected, app.Name);
        }
Example #2
0
        /// <summary>
        /// setup
        /// </summary>
        protected override void SetUp()
        {
            // setup hotkey and notifiation icon
            base.SetUpHotKey(ModifierKeys.Control | ModifierKeys.Shift | ModifierKeys.Alt, Key.L);

            // create a context menu
            base.AddContextMenu("Show", (sender, e) => this.OnContextMenuShowClick());
            base.AddContextMenu("Import", (sender, e) => this.OnContextMenuImportClick());
            base.AddContextMenuSeparator();
            base.AddContextMenu("Exit", (sender, e) => this.OnContextMenuExitClick());

            // add event
            this.Loaded += (sender, e) => {
                // create SearchResultRenderer after BrowserControl is loaded
                var userMemoryDictionary = AppSettingsRepo.GetInstance().UseMemoryDicitonary;
                if (userMemoryDictionary)
                {
                    this.IsEnabled = false;
                    this.cBrowser.NavigateToString("<html><body><h4 style='text-align:center;'>now loading...</h4></body></html>");
                }
                this._renderer = new SearchResultRenderer(this.cBrowser, this.CompleteSearch);

                // set title
                FileVersionInfo versionInfo = FileVersionInfo.GetVersionInfo(System.Reflection.Assembly.GetExecutingAssembly().Location);
                this._windowTitle = $"{versionInfo.ProductName}({versionInfo.FileVersion})";
                this.ShowWindowTitle();

                // set up obserber
                this._copyObserver = new CopyObserver(this, this.ClipboardChanged);

                // set up timer
                this._timer          = new Timer(3000);
                this._timer.Elapsed += OnTimedEvent;

                // タスクトレイのアイコンが正しく表示されないようなので対症療法としてLoadでも設定
                base.SetupNofityIcon("SimpleTranslationLocal", new System.Drawing.Icon("app.ico"));
            };
            this.Closing += (sender, e) => {
                e.Cancel = true;
                if (this.ShowInTaskbar)
                {
                    base.SetWindowsState(true);
                }
            };
            this.Activated += (sender, e) => {
                this.cKeyword.Focus();
                this._isActivated = true;
            };
            this.Minimized += this.MainWindowMinimized;

            // set view model
            var model = new MainWindowViewModel();

            this.DataContext = model;
        }
Example #3
0
        public MainWindow()
        {
            InitializeComponent();

            // restore window(set in SetUp() is not working...)
            var settings = AppSettingsRepo.Init(Constants.SettingsFile);

            Util.SetWindowXPosition(this, settings.X);
            Util.SetWindowYPosition(this, settings.Y);
            this.Width   = settings.Width;
            this.Height  = settings.Height;
            this.Topmost = settings.Topmost;
        }
Example #4
0
        protected override void OnStartup(StartupEventArgs e)
        {
            hasHandle = mutex.WaitOne(0, false);
            if (!hasHandle)
            {
                MessageBox.Show("already launch");
                this.Shutdown();
                return;
            }
            base.OnStartup(e);

            var settings = AppSettingsRepo.Init(Constants.SettingsFile);

            settings.CreateDatabase(settings.DatabaseFile);
        }
Example #5
0
        /// <summary>
        /// Window Closed event
        /// </summary>
        private void MainWindowMinimized()
        {
            if (this._isActivated)
            {
                var setting = AppSettingsRepo.GetInstance();
                setting.X      = this.Left;
                setting.Y      = this.Top;
                setting.Height = this.Height;
                setting.Width  = this.Width;
                setting.Save();

                this._copyMode = CopyMode.None;
                this._copyObserver.Stop();
                this.ShowWindowTitle();
            }
        }
        protected override void SetContextData()
        {
            repo = new AppSettingsRepo(testCtx);

            var b = new Faker <AppSettings>()
                    .RuleFor(r => r.Name, f => f.Lorem.Word())
                    .RuleFor(r => r.Value, f => f.Lorem.Word())
                    .RuleFor(r => r.Description, f => f.Lorem.Paragraph())
                    .RuleFor(r => r.ApplicationId, f => f.Random.Uuid())
                    .RuleFor(r => r.LastUpdatedbyUser, f => f.Random.Uuid());

            var bs = b.Generate(3).OrderBy(o => o.AppSettingId).ThenBy(o => o.Name).ToList();

            testCtx.AppSettings.AddRange(bs);
            FakeCollection.AddRange(bs);
            int added = testCtx.SaveChanges();
        }
        void IImportServiceCallback.OnSuccess()
        {
            var settings = AppSettingsRepo.GetInstance();

            switch (this._dicType)
            {
            case Constants.DicType.Eijiro:
                settings.EijiroFile = EijiroFile;
                break;

            case Constants.DicType.Webster:
                settings.WebsterFile = WebsterFile;
                break;
            }
            settings.Save();
            this._owner.Dispatcher.Invoke((Action)(() => {
                Messages.ShowInfo(this._owner, Messages.InfoId.Info001);
            }));
        }
Example #8
0
        /// <summary>
        /// データベース選択クリック時の処理
        /// </summary>
        private void SelectDatabaseClick()
        {
            var dialog = new SaveFileDialog()
            {
                FileName        = "app.data",
                Filter          = "すべてのファイル|*.*|データベース ファイル|*.data",
                FilterIndex     = 2,
                OverwritePrompt = false
            };

            if (true == dialog.ShowDialog())
            {
                var filename = dialog.FileName;
                try {
                    var repo = AppSettingsRepo.GetInstance();
                    repo.SetDatabaseFile(filename);
                } catch (Exception ex) {
                    Message.ShowError(this._window, Message.ErrId.Err002, ex.Message);
                }
            }
            this.ShowDataByRecordedOn();
        }
Example #9
0
 public FrmAppSettings()
 {
     _repo = new AppSettingsRepo();
     InitializeComponent();
 }
Example #10
0
 /// <summary>
 /// アプリデータベース
 /// </summary>
 //public static readonly string DatabaseFile = AppSettingsRepo.GetInstance().DatabaseFile;
 public static string DatabaseFile()
 {
     return(AppSettingsRepo.GetInstance().DatabaseFile);
 }
Example #11
0
 public FrmConnection()
 {
     InitializeComponent();
     _repo           = new AppSettingsRepo();
     btnSave.Enabled = false;
 }