/// <summary>
        /// 全ゴーストの顔画像の取得・変換を行う (キャッシュ処理も行う)
        /// </summary>
        /// <returns>ゴーストフォルダパスをキー、顔画像 (Bitmap) を値とするDictionary</returns>
        public virtual Bitmap GetFaceImage(ExplorerGhost ghost, ExplorerShell shell, Size faceSize)
        {
            var cacheDir = Util.GetCacheDirPath();

            // キャッシュフォルダが存在しなければ作成
            if (!Directory.Exists(cacheDir))
            {
                Directory.CreateDirectory(cacheDir);
            }

            try
            {
                Bitmap face      = null;
                var    cachePath = Path.Combine(cacheDir, string.Format("{0}_face.png", Path.GetFileName(ghost.DirPath)));

                // 顔画像のキャッシュがあり、更新日時がシェルの更新日以降なら、キャッシュを使用
                if (File.Exists(cachePath) && File.GetLastWriteTime(cachePath) >= shell.LastModified)
                {
                    face = new Bitmap(cachePath);
                }
                else
                {
                    // キャッシュがない場合、サーフェス0から顔画像を生成 (サーフェスを読み込めている場合のみ)
                    if (shell.SakuraSurfaceModel != null)
                    {
                        using (var faceImg = shell.DrawFaceImage(shell.SakuraSurfaceModel, faceSize.Width, faceSize.Height))
                        {
                            face = faceImg.ToBitmap();
                        }

                        if (face != null)
                        {
                            // 顔画像のキャッシュを保存
                            face.Save(cachePath);
                        }
                    }
                }

                // 画像を返す
                return(face);
            }
            catch (InvalidDescriptException ex)
            {
                MessageBox.Show(string.Format("{0} の explorer2\\descript.txt に不正な記述があります。\n{1}", ghost.Name, ex.Message),
                                "エラー",
                                MessageBoxButtons.OK,
                                MessageBoxIcon.Warning);

                Debug.WriteLine(ex.ToString());
                return(null);
            }
            catch (Exception ex)
            {
                Debug.WriteLine(ex.ToString());
                return(null);
            }
        }
        internal void BuildObjectGraph(Action shutdown)
        {
            const int FIVE_SECONDS   = 5000;
            const int THIRTY_SECONDS = 30000;

            var args          = Environment.GetCommandLineArgs();
            var nativeMethods = new NativeMethods();

            logger     = new Logger();
            systemInfo = new SystemInfo();

            InitializeConfiguration();
            InitializeLogging();
            InitializeText();

            var messageBox     = new MessageBox(text);
            var desktopFactory = new DesktopFactory(ModuleLogger(nameof(DesktopFactory)));
            var explorerShell  = new ExplorerShell(ModuleLogger(nameof(ExplorerShell)), nativeMethods);
            var processFactory = new ProcessFactory(ModuleLogger(nameof(ProcessFactory)));
            var proxyFactory   = new ProxyFactory(new ProxyObjectFactory(), logger);
            var runtimeHost    = new RuntimeHost(appConfig.RuntimeAddress, new HostObjectFactory(), ModuleLogger(nameof(RuntimeHost)), FIVE_SECONDS);
            var serviceProxy   = new ServiceProxy(appConfig.ServiceAddress, new ProxyObjectFactory(), ModuleLogger(nameof(ServiceProxy)));
            var sessionContext = new SessionContext();
            var uiFactory      = new UserInterfaceFactory(text);

            var bootstrapOperations = new Queue <IOperation>();
            var sessionOperations   = new Queue <IRepeatableOperation>();

            bootstrapOperations.Enqueue(new I18nOperation(logger, text, textResource));
            bootstrapOperations.Enqueue(new CommunicationHostOperation(runtimeHost, logger));

            sessionOperations.Enqueue(new SessionInitializationOperation(configuration, logger, runtimeHost, sessionContext));
            sessionOperations.Enqueue(new ConfigurationOperation(args, configuration, new HashAlgorithm(), logger, sessionContext));
            sessionOperations.Enqueue(new ClientTerminationOperation(logger, processFactory, proxyFactory, runtimeHost, sessionContext, THIRTY_SECONDS));
            sessionOperations.Enqueue(new KioskModeTerminationOperation(desktopFactory, explorerShell, logger, processFactory, sessionContext));
            sessionOperations.Enqueue(new ServiceOperation(logger, runtimeHost, serviceProxy, sessionContext, THIRTY_SECONDS));
            sessionOperations.Enqueue(new KioskModeOperation(desktopFactory, explorerShell, logger, processFactory, sessionContext));
            sessionOperations.Enqueue(new ClientOperation(logger, processFactory, proxyFactory, runtimeHost, sessionContext, THIRTY_SECONDS));
            sessionOperations.Enqueue(new SessionActivationOperation(logger, sessionContext));

            var bootstrapSequence = new OperationSequence(logger, bootstrapOperations);
            var sessionSequence   = new RepeatableOperationSequence(logger, sessionOperations);

            RuntimeController = new RuntimeController(
                appConfig,
                logger,
                messageBox,
                bootstrapSequence,
                sessionSequence,
                runtimeHost,
                serviceProxy,
                sessionContext,
                shutdown,
                text,
                uiFactory);
        }
        /// <summary>
        /// シェル情報の一括読み込み
        /// </summary>
        public virtual void Load(int sakuraSurfaceId, int keroSurfaceId)
        {
            // 既存の値はクリア
            ListItems.Clear();

            // シェルフォルダを列挙
            foreach (var subDir in Directory.GetDirectories(Path.Combine(GhostDirPath, "shell")))
            {
                // 隠しフォルダの場合はスキップ
                var dirInfo = new DirectoryInfo(subDir);
                if ((dirInfo.Attributes & FileAttributes.Hidden) == FileAttributes.Hidden)
                {
                    continue;
                }

                var descriptPath = Path.Combine(subDir, "descript.txt");
                // descript.txt が存在しないならスキップ
                if (!File.Exists(descriptPath))
                {
                    continue;
                }

                var item = new ListItem()
                {
                    DirPath = subDir
                };
                try
                {
                    // シェルを読み込み
                    item.Shell = ExplorerShell.Load(subDir, sakuraSurfaceId, keroSurfaceId);
                    item.Name  = item.Shell.Name;
                }
                catch (UnhandlableShellException ex)
                {
                    // 処理不可能なシェル
                    item.ErrorMessage = ex.FriendlyMessage;
                }

                // シェルの読み込みに失敗した場合、Descript.txtのみ読み込み、名前の取得を試みる
                if (item.Shell == null)
                {
                    var descript = DescriptText.Load(descriptPath);
                    item.Name = descript.Get("name");
                }

                ListItems.Add(item);
            }

            // 最後に名前+フォルダパス順でソート
            ListItems = ListItems.OrderBy(s => Tuple.Create(s.Name, s.DirPath)).ToList();
        }
        /// <summary>
        /// 対象ゴーストのシェル情報読み込み
        /// </summary>
        public virtual ExplorerShell LoadShell(ExplorerGhost ghost)
        {
            // シェルが1つも存在しない場合はエラーとする
            if (ghost.CurrentShellRelDirPath == null)
            {
                throw new ShellNotFoundException(string.Format(@"有効なシェルが1つも存在しません。", ghost.DefaultShellDirName));
            }

            var shellDir = Path.Combine(ghost.DirPath, ghost.CurrentShellRelDirPath);

            // descript.txtが存在しない場合はエラーとする
            if (!ExplorerShell.IsShellDir(shellDir))
            {
                throw new ShellDescriptNotFoundException("シェルフォルダの中に descript.txt が存在しません。");
            }

            return(ExplorerShell.Load(shellDir, ghost.SakuraDefaultSurfaceId, ghost.KeroDefaultSurfaceId));
        }
        /// <summary>
        /// サーフェス画像を取得 (element, MAYUNAの合成も行う。またキャッシュがあればキャッシュから取得)
        /// </summary>
        /// <returns>サーフェス画像を取得できた場合はその画像。取得に失敗した場合はnull</returns>
        protected virtual Bitmap DrawSurfaceInternal(ExplorerGhost ghost, ExplorerShell shell, Shell.SurfaceModel surfaceModel, int surfaceId)
        {
            var cacheDir = Util.GetCacheDirPath();

            if (surfaceModel == null)
            {
                return(null);
            }

            // キャッシュフォルダが存在しなければ作成
            if (!Directory.Exists(cacheDir))
            {
                Directory.CreateDirectory(cacheDir);
            }

            // 立ち絵画像のキャッシュがあり、更新日時がシェルの更新日以降なら、キャッシュを使用
            var cachePath = Path.Combine(cacheDir, string.Format("{0}_s{1}.png", Path.GetFileName(ghost.DirPath), surfaceId));

            if (File.Exists(cachePath) && File.GetLastWriteTime(cachePath) >= shell.LastModified)
            {
                return(new Bitmap(cachePath));
            }
            else
            {
                // 立ち絵サーフェス画像を生成
                var surface = shell.DrawSurface(surfaceModel);

                // キャッシュとして保存
                surface.Write(cachePath);

                // サーフェス画像をBitmap形式に変換
                var surfaceBmp = surface.ToBitmap();

                // 元画像を即時破棄
                surface.Dispose();

                // サーフェス画像をBitmap形式に変換して返す
                return(surfaceBmp);
            }
        }
        internal void BuildObjectGraph(Action shutdown)
        {
            ValidateCommandLineArguments();

            InitializeLogging();
            InitializeText();

            context       = new ClientContext();
            uiFactory     = BuildUserInterfaceFactory();
            actionCenter  = uiFactory.CreateActionCenter();
            messageBox    = BuildMessageBox();
            nativeMethods = new NativeMethods();
            runtimeProxy  = new RuntimeProxy(runtimeHostUri, new ProxyObjectFactory(), ModuleLogger(nameof(RuntimeProxy)), Interlocutor.Client);
            systemInfo    = new SystemInfo();
            taskbar       = uiFactory.CreateTaskbar(ModuleLogger("Taskbar"));
            taskview      = uiFactory.CreateTaskview();

            var processFactory     = new ProcessFactory(ModuleLogger(nameof(ProcessFactory)));
            var applicationMonitor = new ApplicationMonitor(TWO_SECONDS, ModuleLogger(nameof(ApplicationMonitor)), nativeMethods, processFactory);
            var applicationFactory = new ApplicationFactory(applicationMonitor, ModuleLogger(nameof(ApplicationFactory)), nativeMethods, processFactory);
            var displayMonitor     = new DisplayMonitor(ModuleLogger(nameof(DisplayMonitor)), nativeMethods, systemInfo);
            var explorerShell      = new ExplorerShell(ModuleLogger(nameof(ExplorerShell)), nativeMethods);
            var fileSystemDialog   = BuildFileSystemDialog();
            var hashAlgorithm      = new HashAlgorithm();
            var splashScreen       = uiFactory.CreateSplashScreen();

            var operations = new Queue <IOperation>();

            operations.Enqueue(new I18nOperation(logger, text));
            operations.Enqueue(new RuntimeConnectionOperation(context, logger, runtimeProxy, authenticationToken));
            operations.Enqueue(new ConfigurationOperation(context, logger, runtimeProxy));
            operations.Enqueue(new DelegateOperation(UpdateAppConfig));
            operations.Enqueue(new LazyInitializationOperation(BuildClientHostOperation));
            operations.Enqueue(new ClientHostDisconnectionOperation(context, logger, FIVE_SECONDS));
            operations.Enqueue(new LazyInitializationOperation(BuildKeyboardInterceptorOperation));
            operations.Enqueue(new LazyInitializationOperation(BuildMouseInterceptorOperation));
            operations.Enqueue(new ApplicationOperation(context, applicationFactory, applicationMonitor, logger, text));
            operations.Enqueue(new DisplayMonitorOperation(context, displayMonitor, logger, taskbar));
            operations.Enqueue(new LazyInitializationOperation(BuildShellOperation));
            operations.Enqueue(new LazyInitializationOperation(BuildBrowserOperation));
            operations.Enqueue(new ClipboardOperation(context, logger, nativeMethods));

            var sequence = new OperationSequence(logger, operations);

            ClientController = new ClientController(
                actionCenter,
                applicationMonitor,
                context,
                displayMonitor,
                explorerShell,
                fileSystemDialog,
                hashAlgorithm,
                logger,
                messageBox,
                sequence,
                runtimeProxy,
                shutdown,
                splashScreen,
                taskbar,
                text,
                uiFactory);
        }
        internal void BuildObjectGraph(Action shutdown)
        {
            const int FIVE_SECONDS   = 5000;
            const int THIRTY_SECONDS = 30000;

            logger     = new Logger();
            systemInfo = new SystemInfo();

            InitializeConfiguration();
            InitializeLogging();
            InitializeText();

            var args                  = Environment.GetCommandLineArgs();
            var messageBox            = new MessageBoxFactory(text);
            var nativeMethods         = new NativeMethods();
            var uiFactory             = new UserInterfaceFactory(text);
            var desktopFactory        = new DesktopFactory(ModuleLogger(nameof(DesktopFactory)));
            var explorerShell         = new ExplorerShell(ModuleLogger(nameof(ExplorerShell)), nativeMethods);
            var fileSystem            = new FileSystem();
            var processFactory        = new ProcessFactory(ModuleLogger(nameof(ProcessFactory)));
            var proxyFactory          = new ProxyFactory(new ProxyObjectFactory(), ModuleLogger(nameof(ProxyFactory)));
            var remoteSessionDetector = new RemoteSessionDetector(ModuleLogger(nameof(RemoteSessionDetector)));
            var runtimeHost           = new RuntimeHost(appConfig.RuntimeAddress, new HostObjectFactory(), ModuleLogger(nameof(RuntimeHost)), FIVE_SECONDS);
            var runtimeWindow         = uiFactory.CreateRuntimeWindow(appConfig);
            var server                = new ServerProxy(appConfig, ModuleLogger(nameof(ServerProxy)));
            var serviceProxy          = new ServiceProxy(appConfig.ServiceAddress, new ProxyObjectFactory(), ModuleLogger(nameof(ServiceProxy)), Interlocutor.Runtime);
            var sessionContext        = new SessionContext();
            var splashScreen          = uiFactory.CreateSplashScreen(appConfig);
            var userInfo              = new UserInfo(ModuleLogger(nameof(UserInfo)));
            var vmDetector            = new VirtualMachineDetector(ModuleLogger(nameof(VirtualMachineDetector)), systemInfo);

            var bootstrapOperations = new Queue <IOperation>();
            var sessionOperations   = new Queue <IRepeatableOperation>();

            bootstrapOperations.Enqueue(new I18nOperation(logger, text));
            bootstrapOperations.Enqueue(new CommunicationHostOperation(runtimeHost, logger));

            sessionOperations.Enqueue(new SessionInitializationOperation(configuration, fileSystem, logger, runtimeHost, sessionContext));
            sessionOperations.Enqueue(new ConfigurationOperation(args, configuration, new FileSystem(), new HashAlgorithm(), logger, sessionContext));
            sessionOperations.Enqueue(new DisclaimerOperation(logger, sessionContext));
            sessionOperations.Enqueue(new ServerOperation(args, configuration, fileSystem, logger, sessionContext, server));
            sessionOperations.Enqueue(new RemoteSessionOperation(remoteSessionDetector, logger, sessionContext));
            sessionOperations.Enqueue(new VirtualMachineOperation(vmDetector, logger, sessionContext));
            sessionOperations.Enqueue(new ServiceOperation(logger, runtimeHost, serviceProxy, sessionContext, THIRTY_SECONDS, userInfo));
            sessionOperations.Enqueue(new ClientTerminationOperation(logger, processFactory, proxyFactory, runtimeHost, sessionContext, THIRTY_SECONDS));
            sessionOperations.Enqueue(new ProctoringWorkaroundOperation(logger, sessionContext));
            sessionOperations.Enqueue(new KioskModeOperation(desktopFactory, explorerShell, logger, processFactory, sessionContext));
            sessionOperations.Enqueue(new ClientOperation(logger, processFactory, proxyFactory, runtimeHost, sessionContext, THIRTY_SECONDS));
            sessionOperations.Enqueue(new SessionActivationOperation(logger, sessionContext));

            var bootstrapSequence = new OperationSequence(logger, bootstrapOperations);
            var sessionSequence   = new RepeatableOperationSequence(logger, sessionOperations);

            RuntimeController = new RuntimeController(
                appConfig,
                logger,
                messageBox,
                bootstrapSequence,
                sessionSequence,
                runtimeHost,
                runtimeWindow,
                serviceProxy,
                sessionContext,
                shutdown,
                splashScreen,
                text,
                uiFactory);
        }
Esempio n. 8
0
 private void _resetFilter(ExplorerShell shell) {
    _classes = shell.LoadedClasses.ToArray();
 }
Esempio n. 9
0
 private bool _restoreFilter(ExplorerShell shell) {
    if (Matches(DiagramSnapshotScope.Filter)) {
       return shell.Select(_classes);
    } else {
       return false;
    }
 }
Esempio n. 10
0
 private void _captureFilter(ExplorerShell shell) {
    _classes = shell.SelectedClasses.ToArray();
 }
Esempio n. 11
0
 /// <summary>
 /// kero側サーフェス画像を取得  (element, MAYUNAの合成も行う。またキャッシュがあればキャッシュから取得)
 /// </summary>
 /// <returns>サーフェス画像を取得できた場合はその画像。取得に失敗した場合はnull</returns>
 public virtual Bitmap DrawKeroSurface(ExplorerGhost ghost, ExplorerShell shell)
 {
     return(DrawSurfaceInternal(ghost, shell, shell.KeroSurfaceModel, shell.KeroSurfaceId));
 }
Esempio n. 12
0
 /// <summary>
 /// kero側サーフェス画像を取得  (element, MAYUNAの合成も行う。またキャッシュがあればキャッシュから取得)
 /// </summary>
 /// <returns>サーフェス画像を取得できた場合はその画像。取得に失敗した場合はnull</returns>
 public virtual Bitmap DrawKeroSurface(ExplorerShell targetShell)
 {
     return(DrawSurfaceInternal(targetShell, targetShell.KeroSurfaceModel, targetShell.KeroSurfaceId));
 }
Esempio n. 13
0
        internal void BuildObjectGraph(Action shutdown)
        {
            ValidateCommandLineArguments();

            configuration = new ClientConfiguration();
            logger        = new Logger();
            nativeMethods = new NativeMethods();
            systemInfo    = new SystemInfo();

            InitializeLogging();
            InitializeText();

            actionCenter         = BuildActionCenter();
            messageBox           = BuildMessageBox();
            processMonitor       = new ProcessMonitor(new ModuleLogger(logger, nameof(ProcessMonitor)), nativeMethods);
            uiFactory            = BuildUserInterfaceFactory();
            runtimeProxy         = new RuntimeProxy(runtimeHostUri, new ProxyObjectFactory(), new ModuleLogger(logger, nameof(RuntimeProxy)), Interlocutor.Client);
            taskbar              = BuildTaskbar();
            terminationActivator = new TerminationActivator(new ModuleLogger(logger, nameof(TerminationActivator)));
            windowMonitor        = new WindowMonitor(new ModuleLogger(logger, nameof(WindowMonitor)), nativeMethods);

            var displayMonitor = new DisplayMonitor(new ModuleLogger(logger, nameof(DisplayMonitor)), nativeMethods, systemInfo);
            var explorerShell  = new ExplorerShell(new ModuleLogger(logger, nameof(ExplorerShell)), nativeMethods);
            var hashAlgorithm  = new HashAlgorithm();

            var operations = new Queue <IOperation>();

            operations.Enqueue(new I18nOperation(logger, text, textResource));
            operations.Enqueue(new RuntimeConnectionOperation(logger, runtimeProxy, authenticationToken));
            operations.Enqueue(new ConfigurationOperation(configuration, logger, runtimeProxy));
            operations.Enqueue(new DelegateOperation(UpdateAppConfig));
            operations.Enqueue(new LazyInitializationOperation(BuildClientHostOperation));
            operations.Enqueue(new LazyInitializationOperation(BuildClientHostDisconnectionOperation));
            operations.Enqueue(new LazyInitializationOperation(BuildKeyboardInterceptorOperation));
            operations.Enqueue(new LazyInitializationOperation(BuildMouseInterceptorOperation));
            operations.Enqueue(new LazyInitializationOperation(BuildWindowMonitorOperation));
            operations.Enqueue(new LazyInitializationOperation(BuildProcessMonitorOperation));
            operations.Enqueue(new DisplayMonitorOperation(displayMonitor, logger, taskbar));
            operations.Enqueue(new LazyInitializationOperation(BuildShellOperation));
            operations.Enqueue(new LazyInitializationOperation(BuildBrowserOperation));
            operations.Enqueue(new ClipboardOperation(logger, nativeMethods));
            operations.Enqueue(new DelegateOperation(UpdateClientControllerDependencies));

            var sequence = new OperationSequence(logger, operations);

            ClientController = new ClientController(
                actionCenter,
                displayMonitor,
                explorerShell,
                hashAlgorithm,
                logger,
                messageBox,
                sequence,
                processMonitor,
                runtimeProxy,
                shutdown,
                taskbar,
                terminationActivator,
                text,
                uiFactory,
                windowMonitor);
        }