Ejemplo n.º 1
0
        static void Main()
        {
            AdbServer.Instance.StartServer(usrDir + @"\bin\adb.exe", true);
            LoadDefaultStorage();
            GlobalSave.Handle("Global", Repository);
            GlobalSave.Handle("Contents", Contents);
            GlobalSave.Handle("Logs", Logs);
            GlobalSetting = new SettingManager();
            GlobalSetting.LoadConfig(CONFIG_FILE);
            GlobalSave.Handle("Settings", GlobalSetting);
            AdbServer.Instance.StartServer(usrDir + @"\bin\adb.exe", false);
            Application.EnableVisualStyles();
            Application.ApplicationExit += Application_ApplicationExit;
            Application.SetUnhandledExceptionMode(UnhandledExceptionMode.CatchException);
            AppDomain.CurrentDomain.UnhandledException += CurrentDomain_UnhandledException;
            Application.ThreadException += Application_ThreadException;
            Application.SetCompatibleTextRenderingDefault(false);
            //RPCServer = new TcpServer((int)GlobalSetting.Get("RPCPort").Value);
            //RPCServer.DataArrived += RPCServer_DataArrived;
            ScreenPortBase = (int)GlobalSetting.Get("ScreenPortBase").Value;
            MonkeyPortBase = (int)GlobalSetting.Get("ManipulatePortBase").Value;
            // 全局错误处理器
            Events.Register("on_exception", new GlobalEventHandler((_sender, _name, _param) =>
            {
                var ex = _param as Exception;
                checkExcetion(ex);
            }));

            Logs.RegisterEntry("remote");
            // 自动保存设置, 每分钟
            Dispatcher.StartTicking((o) =>
            {
                SaveStorages();
            }, 1000 * 60);
            // free ports
            Repository.Temp["screen"] = new Hashtable();
            for (var i = 0; i < 3000; i++)
            {
                Repository.Temp[ScreenPortBase + i] = true;
                Repository.Temp[MonkeyPortBase + i] = true;
                Repository.Temp[LocationBase + i]   = true;
            }
            if (!UAC.Establish())
            {
                Dispatcher.BackgroundThread(() =>
                                            // 秘钥交换失败
                                            MessageBox.Show("无法与远程服务器取得联系.请稍后再试"));
                Thread.Sleep(3000);
                Process.GetCurrentProcess().Kill();
            }
            // 主题默认字体
            MaterialSkinManager.BaseFont = new System.Drawing.FontFamily("微软雅黑");
            var logFrm = new LoginForm();

            mainFrm = logFrm;
            Application.Run(logFrm);
        }
Ejemplo n.º 2
0
        private void Confirm_Click(object sender, RoutedEventArgs e)
        {
            Button btn = e.Source as Button;

            switch ((string)btn.Tag)
            {
            case "AddData":
                Managable settingItem = SettingManager.Get(SettingTitle.Text);
                bool      added       = settingItem.Add(float.Parse(CreateData.Text));
                PopUpdate();
                break;

            case "Confirm":
                string confirmVal = ChooseList.Text;
                if (origin != confirmVal && SettingTitle.Text != SettingManager.DPIWORDING)
                {
                    if (SettingTitle.Text == SettingManager.MARGINGWORDING)
                    {
                        arrangement.Remargin();
                    }
                    arrangement.Arrange();
                }
                SettingDialog.IsOpen = false;
                break;

            default:
                break;
            }
        }
Ejemplo n.º 3
0
        public Settings(MainWindow mw)
        {
            InitializeComponent();

            this._mw = mw; // legacy reference

            overlayModeCheckbox.IsChecked   = SettingManager.Get("overlayMode");
            audioPreviewsCheckbox.IsChecked = SettingManager.Get("audioPreviews");
            mirrorTextBox.Text            = SettingManager.Get("beatmapMirror");
            launchOsuCheckbox.IsChecked   = SettingManager.Get("launchOsu");
            officialDownloadBox.IsChecked = SettingManager.Get("useOfficialOsu");
            useTrayCheckbox.IsChecked     = SettingManager.Get("minimizeToTray");
            novidCheckbox.IsChecked       = SettingManager.Get("novidDownload");
            previewVolumeSlider.Value     = SettingManager.Get("previewVolume") * 100;

            if (SettingManager.Get("fallbackActualOsu"))
            {
                officialDownloadBox.IsChecked = true;
            }

            if ((bool)officialDownloadBox.IsChecked)
            {
                officialLoggedInAs.Visibility = Visibility.Visible;
                officialLoggedInAs.Content    = "Currently logged in as: " + Properties.Settings.Default.officialOsuUsername;
                if (SettingManager.Get("fallbackActualOsu"))
                {
                    officialLoggedInAs.Content += " (falling back to Bloodcat)";
                }
            }

            loaded = true;
        }
Ejemplo n.º 4
0
        public Settings(IEntity entity)
        {
            entityOn = entity;
            InitializeComponent();
            settingManager = new SettingManager();

            setting1    = settingManager.Get(1);
            stateOfData = setting1.State;

            setting2      = settingManager.Get(2);
            stateOfSearch = setting2.State;

            DurumlariKontrolET();

            Loaded += Settings_Loaded;
        }
Ejemplo n.º 5
0
        private void ChooseList_DropDownClosed(object sender, EventArgs e)
        {
            ComboBox  mCB         = sender as ComboBox;
            Managable settingItem = SettingManager.Get(SettingTitle.Text);

            settingItem.Select(mCB.SelectedIndex);
        }
Ejemplo n.º 6
0
        private void PopUpdate()
        {
            CreateData.Text = "";
            Managable settingItem = SettingManager.Get(SettingTitle.Text);

            ChooseList.ItemsSource   = settingItem.Get();
            ChooseList.SelectedIndex = settingItem.Current();
        }
Ejemplo n.º 7
0
        private void officialDownloadBox_Checked(object sender, RoutedEventArgs e)
        {
            if (!loaded)
            {
                return;
            }
            (new OsuLogin(this)).ShowDialog();

            if (SettingManager.Get("useOfficialOsu"))
            {
                (new OsuLoginCheck(_mw)).ShowDialog(); // hacky but reuse code
            }
        }
Ejemplo n.º 8
0
        private async void officialDownloadBox_Checked(object sender, RoutedEventArgs e)
        {
            if (!loaded)
            {
                return;
            }
            (new OsuLoginPop(this)).ShowDialog();

            if (SettingManager.Get("useOfficialOsu"))
            {
                await OsuCredsOnLaunch.TestCookies(); // shitty but reuse code
            }
        }
Ejemplo n.º 9
0
        private void Window_Closing(object sender, System.ComponentModel.CancelEventArgs e)
        {
            AudioManager.ForceStopPreview();

            // fade out
            if (SettingManager.Get("overlayMode"))
            {
                e.Cancel = true;                         // interrupt event to fadeclose
                var animate = new DoubleAnimation(SystemParameters.PrimaryScreenWidth, new Duration(TimeSpan.FromMilliseconds(150)));
                animate.Completed += (o, e1) => Close(); // close on done
                BeginAnimation(Window.LeftProperty, animate);
            }
        }
Ejemplo n.º 10
0
        private void Border_Drop(object sender, DragEventArgs e)
        {
            if (e.Data.GetDataPresent(DataFormats.FileDrop))
            {
                string[] files = (string[])e.Data.GetData(DataFormats.FileDrop);

                SettingManager settingManager = new SettingManager();
                Setting        setting        = settingManager.Get(1);
                bool           readOption     = setting.State;

                if (SeqEntity is Book)
                {
                    Business.Concrete.ExcelOptions <Book> excelOptions = new Business.Concrete.ExcelOptions <Book>();
                    List <Book> books = excelOptions.ReadExcel(files[0]);

                    if (readOption == true)
                    {
                        Frame frame = ((MainWindow)Application.Current.MainWindow).ConFrame;
                        frame.Navigate(new Pages.DetailBook(true, books));
                    }
                    else
                    {
                        foreach (var item in books)
                        {
                            bookManager.Add(item);
                        }
                        WorkingType();
                    }
                }
                else if (SeqEntity is Student)
                {
                    Business.Concrete.ExcelOptions <Student> excelOptions = new Business.Concrete.ExcelOptions <Student>();
                    List <Student> students = excelOptions.ReadExcel(files[0]);

                    if (readOption == true)
                    {
                        Frame frame = ((MainWindow)Application.Current.MainWindow).ConFrame;
                        frame.Navigate(new Pages.DetailStudent(true, students));
                    }
                    else
                    {
                        foreach (var item in students)
                        {
                            studentManager.Add(item);
                        }
                        WorkingType();
                    }
                }
            }
        }
Ejemplo n.º 11
0
        private void button_Click(object sender, RoutedEventArgs e)
        {
            string  url = $"https://osu.ppy.sh/beatmapsets/{set.Id}";
            Process proc;

            if (String.IsNullOrEmpty(SettingManager.Get("linkerDefaultBrowser")))
            {
                proc = Process.Start(url);
            }
            else
            {
                proc = Process.Start(new ProcessStartInfo(SettingManager.Get("linkerDefaultBrowser"), url));
            }

            WinTools.SetHandleForeground(proc.Handle);
        }
Ejemplo n.º 12
0
        public DirectDownload(MainWindow mw, BeatmapSet bs)
        {
            InitializeComponent();

            set = bs;
            _mw = mw;

            Title = $"{set.Artist} - {set.Title} <{set.Mapper}> :: NexDirect Download";
            previewImage.Source     = new BitmapImage(bs.PreviewImage);
            songInfoLabel.Content   = $"{set.Artist} - {set.Title}";
            mapperInfoLabel.Content = $"(mapped by {set.Mapper})";

            if (SettingManager.Get("overlayMode")) // overlay & only if osu! is open.
            {
                initOverlayMode();
            }
        }
Ejemplo n.º 13
0
        public static async Task TestCookies()
        {
            System.Net.CookieContainer cookies = null;
            try
            {
                cookies = await CookieStoreSerializer.DeserializeCookies(SettingManager.Get("officialOsuCookies"));
            }
            catch
            {
                // Corrupted cookie store, deleting corruption
                SettingManager.Set("officialOsuCookies", null);
                cookies = new System.Net.CookieContainer();
            }

            try
            {
                await Osu.CheckPassedLoginCookieElseUseNew(cookies, SettingManager.Get("officialOsuUsername"), SettingManager.Get("officialOsuPassword"));

                // store to parent & just persist them incase something new changed
                SettingManager.Set("officialOsuCookies", await CookieStoreSerializer.SerializeCookies(Osu.Cookies));
                return;
            }
            catch (Osu.InvalidPasswordException)
            {
                MessageBoxResult cookiePrompt = MessageBox.Show("There was an error logging in to your account. Maybe you have changed your password, etc... to update that click NO and visit settings.\nClick YES to retry connection, click NO to fall back to Bloodcat for this session.", "NexDirect - Error", MessageBoxButton.YesNo, MessageBoxImage.Warning);
                if (cookiePrompt == MessageBoxResult.Yes)
                {
                    await TestCookies();

                    return;
                }
                SettingManager.Set("useOfficialOsu", false, true);
                SettingManager.Set("fallbackActualOsu", true, true);
                return;
            }
            catch (Exception ex)
            {
                MessageBox.Show("There was an error connecting to osu! servers, falling back to Bloodcat for this session...\n\n" + ex.ToString());
                SettingManager.Set("useOfficialOsu", false, true);
                SettingManager.Set("fallbackActualOsu", true, true);
                return;
            }
        }
Ejemplo n.º 14
0
        private void officialDownloadBox_Unchecked(object sender, RoutedEventArgs e)
        {
            if (!loaded)
            {
                return;
            }

            if (SettingManager.Get("fallbackActualOsu"))
            {
                SettingManager.Set("fallbackActualOsu", false);
            }

            officialLoggedInAs.Visibility = Visibility.Hidden;

            SettingManager.Set("useOfficialOsu", false);
            SettingManager.Set("officialOsuCookies", null);
            SettingManager.Set("officialOsuUsername", "");
            SettingManager.Set("officialOsuPassword", "");
            MessageBox.Show("Disabled official osu! server downloads.");
        }
Ejemplo n.º 15
0
        public Settings(MainWindow mw)
        {
            InitializeComponent();

            this._mw = mw; // legacy reference

            overlayModeCheckbox.IsChecked   = SettingManager.Get("overlayMode");
            audioPreviewsCheckbox.IsChecked = SettingManager.Get("audioPreviews");
            mirrorTextBox.Text            = SettingManager.Get("beatmapMirror");
            launchOsuCheckbox.IsChecked   = SettingManager.Get("launchOsu");
            officialDownloadBox.IsChecked = SettingManager.Get("useOfficialOsu");
            useTrayCheckbox.IsChecked     = SettingManager.Get("minimizeToTray");
            novidCheckbox.IsChecked       = SettingManager.Get("novidDownload");
            previewVolumeSlider.Value     = SettingManager.Get("previewVolume") * 100;

            if (SettingManager.Get("fallbackActualOsu"))
            {
                officialDownloadBox.IsChecked = true;
            }

            if ((bool)officialDownloadBox.IsChecked)
            {
                officialLoggedInAs.Visibility = Visibility.Visible;
                officialLoggedInAs.Content    = "Currently logged in as: " + SettingManager.Get("officialOsuUsername");
                if (SettingManager.Get("fallbackActualOsu"))
                {
                    officialLoggedInAs.Content += " (falling back to Bloodcat)";
                }
            }

            buildDataLabel.Content = $"running NexDirect {(BuildMeta.IsDebug ? "debug" : "v" + WinTools.GetGitStyleVersion())} - built {BuildMeta.BuildDateTime.ToString()} ({BuildMeta.BuildBranch}#{BuildMeta.BuildCommit})";
            if (BuildMeta.IsDebug)
            {
                buildDataLabel.Foreground = new SolidColorBrush(Color.FromRgb(255, 0, 0));
            }

            loaded = true;
        }
Ejemplo n.º 16
0
        private void SearchBox_KeyDown(object sender, KeyEventArgs e)
        {
            TextBox textBox = sender as TextBox;

            SettingManager settingManager = new SettingManager();
            Setting        setting        = settingManager.Get(2);
            bool           durum          = setting.State;

            if (e.Key == Key.Enter)
            {
                if (durum == false)
                {
                    SequenceContent.Children.Clear();
                    if (SeqEntity is Book)
                    {
                        List <Book> books = bookManager.Search(textBox.Text);
                        foreach (Book item in books)
                        {
                            Button button = SeqBook.Get(item);
                            SequenceContent.Children.Add(button);
                        }
                    }
                    else if (SeqEntity is Student)
                    {
                        List <Student> books = studentManager.Search(textBox.Text);
                        foreach (Student item in books)
                        {
                            if (item.Identity == 0)
                            {
                                continue;
                            }
                            Button button = SeqStudent.Get(item);
                            SequenceContent.Children.Add(button);
                        }
                    }
                }
            }
        }
Ejemplo n.º 17
0
 private async void previewBtn_Click(object sender, RoutedEventArgs e)
 {
     previewPlayer = await Osu.PlayPreviewAudio(set, (float)SettingManager.Get("previewVolume"));
 }