Ejemplo n.º 1
0
        // Enables JumpTask.
        public static void EnableJumpTask(Window window, string name)
        {
            JumpList jumpList = JumpList.GetJumpList(Application.Current);

            if (jumpList != null)
            {
                string exePath = Assembly.GetExecutingAssembly().Location;

                JumpTask jumpTask = new JumpTask();
                jumpTask.ApplicationPath  = exePath;
                jumpTask.WorkingDirectory = Path.GetDirectoryName(exePath);
                jumpTask.IconResourcePath = exePath;
                // jumpTask.IconResourceIndex = 0;
                jumpTask.Arguments = JumpTaskArgument;
                jumpTask.Title     = name;
                jumpList.JumpItems.Add(jumpTask);

                jumpList.Apply();
            }

            // Register window message processing hook for main application window.
            HwndSource source = HwndSource.FromHwnd(new WindowInteropHelper(window).Handle);

            source.AddHook(new HwndSourceHook(WndProc));
        }
Ejemplo n.º 2
0
        // Enables JumpTask.
        public static void EnableJumpTask(Window window, string name)
        {
            JumpList jumpList = JumpList.GetJumpList(Application.Current);
            if (jumpList != null)
            {
                string exePath = Assembly.GetExecutingAssembly().Location;

                JumpTask jumpTask = new JumpTask();
                jumpTask.ApplicationPath = exePath;
                jumpTask.WorkingDirectory = Path.GetDirectoryName(exePath);
                jumpTask.IconResourcePath = exePath;
                // jumpTask.IconResourceIndex = 0;
                jumpTask.Arguments = JumpTaskArgument;
                jumpTask.Title = name;
                jumpList.JumpItems.Add(jumpTask);

                jumpList.Apply();
            }

            // Register window message processing hook for main application window.
            HwndSource source = HwndSource.FromHwnd(new WindowInteropHelper(window).Handle);
            source.AddHook(new HwndSourceHook(WndProc));
        }
Ejemplo n.º 3
0
            public void InsertFile(string filepath, int max)
            {
                _Parent.InsertFile(filepath, max);

                // now we add it to the shell's jump list
                var jtask = new System.Windows.Shell.JumpTask()
                {
                    Title = System.IO.Path.GetFileName(filepath),

                    ApplicationPath = System.Reflection.Assembly.GetEntryAssembly().Location
                };

                jtask.IconResourcePath = jtask.ApplicationPath;

                if (filepath.ContainsWhiteSpaces())
                {
                    filepath = filepath.Wrap('"');
                }

                jtask.Arguments = filepath;

                System.Windows.Shell.JumpList.AddToRecentCategory(jtask);
            }
Ejemplo n.º 4
0
        /// <summary>
        /// 新規プロジェクト
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void CreateNewProject(object sender, EventArgs e)
        {
            OpenFileDialog ofd = new OpenFileDialog();

            ofd.FileName         = "MC2D.exe";
            ofd.InitialDirectory = @"C:\";
            ofd.Filter           = "MC2D実行ファイル(*.exe)|MC2D.exe";
            ofd.Title            = "MC2D.exeを選択してください";
            ofd.RestoreDirectory = true;
            ofd.CheckFileExists  = true;
            ofd.CheckPathExists  = true;

            var ret = ofd.ShowDialog();

            //ダイアログを表示する
            if (ret == DialogResult.OK)
            {
                if (ofd.SafeFileName != "MC2D.exe")
                {
                    MessageBox.Show("MC2D.exeファイルではありません。", "警告", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                    return;
                }
            }
            else
            {
                return;
            }
            m_dirPathMC2D = System.IO.Path.GetDirectoryName(ofd.FileName);

            if (!m_com.CheckMediaDirs(m_dirPathMC2D))
            {
                MessageBox.Show("メディアディレクトリが不正です。", "エラー", MessageBoxButtons.OK, MessageBoxIcon.Error);
                return;
            }

            try
            {
                System.Windows.Shell.JumpList jumpList = new System.Windows.Shell.JumpList();
                // JumpTaskオブジェクトを生成し、JumpListオブジェクトに格納する
                var jumpTask = new System.Windows.Shell.JumpTask()
                {
                    CustomCategory = "最近使ったプロジェクト",
                    Title          = ofd.FileName,
                    Arguments      = "/project=" + ofd.FileName,
                };
                jumpList.JumpItems.Add(jumpTask);

                // Applyメソッドを呼び出して、Windowsに通知する
                jumpList.Apply();

                m_com.Config.AddRecentProject(ofd.FileName);
                m_com.Config.Save();
                //
                m_com.D2Stage.Clear();
                m_com.D2Stage.WriteFile(m_dirPathMC2D);

                // 初期パネル
                DockingPanelBeginningLayout();
                DockingPanelLayoutSave();

                NewProjecCreatedEvent(this, new NewProjectCreatedEventArgs(m_dirPathMC2D));
                D2StageFileOpenedEvent(this, new D2StageFileOpenedEventArgs(m_com.D2Stage));
                ProjectOpenedEvent(this, new ProjectOpenedEventArgs());
            }
            catch (System.NullReferenceException ex)
            {
                Console.WriteLine(ex);
            }
        }
Ejemplo n.º 5
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("程序启动"));
        }