Пример #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));
        }
Пример #2
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);
            }
        }