Beispiel #1
0
        public static void Startup()
        {
            if (!Unlocked && mmApp.Configuration.ApplicationUpdates.AccessCount > 50)
            {
                timer          = new System.Timers.Timer(12 * 1000 * 60);
                timer.Elapsed += (s, ev) =>
                {
                    mmApp.Model?.Window?.Dispatcher?.Invoke(() =>
                    {
                        try
                        {
                            if (regDialog != null && regDialog.IsVisible)
                            {
                                return;
                            }

                            regDialog = new RegisterDialog
                            {
                                Owner = mmApp.Model.Window
                            };
                            regDialog.ShowDialog();
                        }
                        catch { }
                    });
                };
                timer.Start();
            }
        }
 public static void ShowRegisterDialog(Control parent)
 {
     using (var registerDialog = new RegisterDialog())
     {
         registerDialog.ShowDialog(parent);
     }
 }
Beispiel #3
0
        private void cCreateAccount_Click(object sender, RoutedEventArgs e)
        {
            //cAccounts.Foreground = Brushes.Wheat;
            RegisterDialog dlg = new RegisterDialog();

            dlg.Owner = this;
            dlg.ShowDialog();
        }
        protected override void OnClosing(CancelEventArgs e)
        {
            base.OnClosing(e);

            Hide();

            bool isNewVersion = CheckForNewVersion(false, false);

            mmApp.Configuration.ApplicationUpdates.AccessCount++;

            SaveSettings();

            if (!CloseAllTabs())
            {
                Show();
                e.Cancel = true;
                return;
            }

            if (mmApp.Configuration.UseSingleWindow)
            {
                PipeManager?.StopServer();

                if (App.Mutex != null)
                {
                    App.Mutex.Dispose();
                }
            }

            if (!isNewVersion &&
                mmApp.Configuration.ApplicationUpdates.AccessCount % 5 == 0 &&
                !UnlockKey.IsRegistered())
            {
                Hide();
                var rd = new RegisterDialog();
                rd.Owner = this;
                rd.ShowDialog();
            }

            mmApp.SendTelemetry("shutdown");

            e.Cancel = false;
        }
Beispiel #5
0
        /// <summary>
        /// dataGridのタイトルを選択した際の処理
        /// 全表示時:お気に入り登録の処理
        /// お気に入り表示時:お気に入り削除の処理
        /// </summary>
        /// <param name="dataGrid">本のタイトル情報</param>
        public void FavoriteOperation(DataGrid dataGrid)
        {
            // 選択されたセル(タイトル部分)からタイトル名のみを抽出する
            var cell = dataGrid.CurrentColumn.GetCellContent(dataGrid.CurrentItem) as TextBlock;

            if (cell == null)
            {
                return;
            }
            var cell_text = cell.Text;

            cell_text = cell_text.Trim(' ', '(', ')');
            if (cell_text != "")
            {
                var end   = cell_text[cell_text.Length - 1].ToString();
                var isNum = int.TryParse(end, out int num);
                while (isNum)
                {
                    cell_text = cell_text.Remove(cell_text.Length - 1, 1);
                    if (cell_text.Length <= 0)
                    {
                        cell_text = cell.Text;
                        break;
                    }
                    end   = cell_text[cell_text.Length - 1].ToString();
                    isNum = int.TryParse(end, out num);
                }
            }
            var title = cell_text.Trim(' ', '(', ')');

            /// お気に入り表示なら削除、全表示なら登録
            if (FavoriteView)
            {
                var  window = new DeleteDialog(title);
                bool?res    = window.ShowDialog();
                // 削除確認ダイアログで登録が押された場合のみtrueが返ってくる
                if (res == true)
                {
                    foreach (var data in _favoriteData)
                    {
                        if (data.Title == title)
                        {
                            DBManager.RemoveAt(data.Id);
                            _favoriteData.Remove(data);
                            SetData();
                            break;
                        }
                    }
                }
            }
            else
            {
                var  window = new RegisterDialog(title);
                bool?res    = window.ShowDialog();
                // 登録確認ダイアログで登録が押された場合のみtrueが返ってくる
                if (res == true)
                {
                    var favoriteTitles = _favoriteData.Select(x => x.Title);
                    if (!favoriteTitles.Contains(title))
                    {
                        var id = 0;
                        if (_favoriteData.Count == 0)
                        {
                            id = 1;
                        }
                        else
                        {
                            var lastId   = _favoriteData.Last().Id;
                            var checkNum = 1;
                            foreach (var f in _favoriteData)
                            {
                                if (f.Id != checkNum)
                                {
                                    id = checkNum;
                                    break;
                                }
                                else
                                {
                                    checkNum++;
                                }
                            }
                            if (id == 0)
                            {
                                id = lastId + 1;
                            }
                        }
                        var data = new Data()
                        {
                            Id    = id,
                            Title = title,
                        };
                        _favoriteData.Add(data);
                    }
                }
            }
        }