Exemplo n.º 1
0
        private void App_Startup(object sender, StartupEventArgs e)
        {
            if (!mutex.WaitOne(0, false))
            {
                MessageBox.Show("已经启动了一个MiniTwitter!", App.NAME, MessageBoxButton.OK, MessageBoxImage.Information);
                Shutdown();
                return;
            }
            LoadLanguage();
            var exeDirectory = Path.GetDirectoryName(Assembly.GetEntryAssembly().Location);

            KeyMapping.LoadFrom(exeDirectory);
            ThemeManager.LoadFrom(exeDirectory);

            if (KeyMapping.KeyMappings.Count == 0)
            {
                MessageBox.Show("键盘映射文件读取失败", App.NAME);
                Shutdown();
                return;
            }

            if (ThemeManager.Themes.Count == 0)
            {
                MessageBox.Show("主题文件读取失败", App.NAME);
                Shutdown();
                return;
            }

            // 設定を読み込む
            Settings.Load(directory);

            if (Settings.Default.Theme.IsNullOrEmpty() || !ThemeManager.Themes.ContainsValue(Settings.Default.Theme))
            {
                // デフォルトのテーマ
                Settings.Default.Theme = ThemeManager.GetTheme(0);
            }

            this.ApplyTheme(Settings.Default.Theme);

            AppDomain.CurrentDomain.UnhandledException += new UnhandledExceptionEventHandler(CurrentDomain_UnhandledException);

            if (Settings.Default.PlixiPassword.IsNullOrEmpty() || Settings.Default.PlixiUsername.IsNullOrEmpty())
            {
                Net.TwitterClient.googlHelper = new Google.UrlShorter.UrlShorter();
            }
            else
            {
                Net.TwitterClient.googlHelper = new Google.UrlShorter.UrlShorter("anonymous", "anonymous", Settings.Default.PlixiUsername, Settings.Default.PlixiPassword);
            }
            Net.TwitterClient.googlHelper.Key = google_key;

            MainWindow = new MainWindow();
            MainWindow.Show();
            //Log.Logger.Default.AddLogItem(new Log.LogItem("程序启动"));
        }
Exemplo n.º 2
0
        private void App_Startup(object sender, StartupEventArgs e)
        {
            //if (!mutex.WaitOne(0, false))
            //{
            //    if (e.Args.Length > 0 && e.Args[0] == "-refresh")
            //    {

            //    }
            //    else
            //    {
            //        MessageBox.Show("已经启动了一个MiniTwitter!", App.NAME, MessageBoxButton.OK, MessageBoxImage.Information);
            //    }
            //    Shutdown();
            //    return;
            //}
            LoadLanguage();
            var exeDirectory = Path.GetDirectoryName(Assembly.GetEntryAssembly().Location);
            var exePath = Assembly.GetEntryAssembly().Location;
            var iconDllPath = Path.Combine(exeDirectory, "MiniTwitterNativeIcon.dll");
            KeyMapping.LoadFrom(exeDirectory);
            ThemeManager.LoadFrom(exeDirectory);

            if (KeyMapping.KeyMappings.Count == 0)
            {
                MessageBox.Show("键盘映射文件读取失败", App.NAME);
                Shutdown();
                return;
            }

            if (ThemeManager.Themes.Count == 0)
            {
                MessageBox.Show("主题文件读取失败", App.NAME);
                Shutdown();
                return;
            }

            // 設定を読み込む
            Settings.Load(directory);

            MiniTwitter.Net.Twitter.User.SSLUserImage = Settings.Default.SSLUserImage;

            if (Settings.Default.Theme.IsNullOrEmpty() || !ThemeManager.Themes.ContainsValue(Settings.Default.Theme))
            {
                // デフォルトのテーマ
                Settings.Default.Theme = ThemeManager.GetTheme(0);
            }

            this.ApplyTheme(Settings.Default.Theme);

            var list = new System.Windows.Shell.JumpList();
            list.JumpItems.Add(new System.Windows.Shell.JumpTask()
            {
                ApplicationPath = exePath,
                CustomCategory = "操作",
                Title = "刷新",
                Arguments = "-refresh",
                Description = "刷新所有时间线",
                IconResourcePath = iconDllPath,
                IconResourceIndex = 1,
            });
            list.JumpItems.Add(new System.Windows.Shell.JumpTask()
            {
                ApplicationPath = exePath,
                CustomCategory = "操作",
                Title = "发送剪贴板上的文本",
                Arguments = "-update",
                Description = "如果剪贴板上有文本,则将其作为内容发送",
                IconResourcePath = iconDllPath,
                IconResourceIndex = 5,
            });
            list.JumpItems.Add(new System.Windows.Shell.JumpTask()
            {
                ApplicationPath = exePath,
                CustomCategory = "操作",
                Title = "发送剪贴板上的图片",
                Arguments = "-updatemedia",
                Description = "如果剪贴板上有图片,则将其连同输入框内容一并发送",
                IconResourcePath = iconDllPath,
                IconResourceIndex = 5,
            });
            list.JumpItems.Add(new System.Windows.Shell.JumpTask()
            {
                ApplicationPath = exePath,
                CustomCategory = "操作",
                Title = "打开设置",
                Arguments = "-settings",
                Description = "打开MiniTwitter Mod设置对话框",
                IconResourcePath = iconDllPath,
                IconResourceIndex = 2,
            });
            foreach (var theme in ThemeManager.Themes)
            {
                var jumpTask = new System.Windows.Shell.JumpTask();
                jumpTask.ApplicationPath = exePath;
                jumpTask.Arguments = string.Format("-theme \"{0}\"", theme.Key);
                jumpTask.Title = theme.Key;
                jumpTask.Description = string.Format("应用主题:{0}", theme.Key);
                jumpTask.IconResourcePath = iconDllPath;
                jumpTask.IconResourceIndex = 4;
                jumpTask.CustomCategory = "主题";
                list.JumpItems.Add(jumpTask);
            }
            System.Windows.Shell.JumpList.SetJumpList(this, list);

            AppDomain.CurrentDomain.UnhandledException += new UnhandledExceptionEventHandler(CurrentDomain_UnhandledException);

            if (Settings.Default.PlixiPassword.IsNullOrEmpty() || Settings.Default.PlixiUsername.IsNullOrEmpty())
            {
                Net.TwitterClient.googlHelper = new Google.UrlShortener.UrlShortener();
            }
            else
            {
                Net.TwitterClient.googlHelper = new Google.UrlShortener.UrlShortener("anonymous", "anonymous", Settings.Default.PlixiUsername, Settings.Default.PlixiPassword);
            }
            Net.TwitterClient.googlHelper.Key = google_key;

            MainWindow = new MainWindow();
            MainWindow.Show();
            //Log.Logger.Default.AddLogItem(new Log.LogItem("程序启动"));
        }