/// <summary> /// Initialize Phiddle to run. This means creating all UI compontents and make /// the service provider ready to serve. /// </summary> public void Initialize() { lastPos = SKPoint.Empty; // Setup services InitializeServices(Services); ServiceProvider = Services.BuildServiceProvider(); screenService = ServiceProvider.GetRequiredService <IScreenService>(); logService = ServiceProvider.GetRequiredService <ILogService>(); appSettingsService = ServiceProvider.GetRequiredService <SettingsService <AppSettings> >(); appStateService = ServiceProvider.GetRequiredService <SettingsService <AppState> >(); // Actions appActions = InitializeActions(); // Screen var s = screenService.Dimensions(); // Tools appTools = new AppTools(s, appStateService.Settings, appSettingsService.Settings); helpLines = new HelpLines(s, appStateService.Settings, appSettingsService.Settings.PaintHelpLines); WindowsSizeFactor = appSettingsService.Settings.WindowSizeFactor; WindowZoomFactor = appSettingsService.Settings.WindowZoomFactor; // Windows windowApp = new Window(SKPoint.Empty, ToolWindowSize, appSettingsService.Settings.WindowApp); windowInfo = new WindowTextInfo(SKPoint.Empty, InfoWindowSize, appSettingsService.Settings.WindowInfo); windowZoom = new WindowZoom(SKPoint.Empty, ZoomWindowSize, appSettingsService.Settings.WindowZoom) { CrosshairVisible = !helpLines.Visible } ; // Calculate initial locations of windows with relative positions #if DEBUG var wm = appSettingsService.Settings.WindowMargin + windowApp.PaintBorder.StrokeWidth; #else var wm = appSettingsService.Settings.WindowMargin; #endif var zx = s.Right - windowZoom.Bounds.Width - wm * 2; var zy = s.Bottom - windowZoom.Bounds.Height - wm * 2; ZoomWindowLocation = new SKPoint(zx, zy); var ix = s.Right - windowInfo.Bounds.Width - wm * 2; var iy = s.Bottom - windowInfo.Bounds.Height - windowZoom.Bounds.Height - wm * 4; InfoWindowLocation = new SKPoint(ix, iy); // Setup refresh timer timer = new Timer(50) { AutoReset = true }; timer.Elapsed += new ElapsedEventHandler(TimerElapsed); logService.Debug("Initialize", $"Core initialized with refresh rate = {1000 / timer.Interval:0} FPS"); }
private void InitializePhiddleForm() { screen = new ScreenServiceForms() { PhiddleForm = this }; StartPosition = FormStartPosition.Manual; var bounds = screen.Dimensions().ToDrawingRect(); Size = bounds.Size; Location = bounds.Location; }