Base de code pour une application electron a base d'angular.

title-bar.component.ts 1.1KB

1234567891011121314151617181920212223242526272829303132333435363738394041
  1. import { Component, OnInit, ViewEncapsulation } from "@angular/core";
  2. import { ElectronService } from "ngx-electron";
  3. @Component({
  4. selector: "title-bar",
  5. templateUrl: "./title-bar.component.html",
  6. styleUrls: ["./title-bar.component.scss"],
  7. encapsulation: ViewEncapsulation.Native
  8. })
  9. export class TitleBarComponent implements OnInit {
  10. old: {
  11. position: number[];
  12. size: number[];
  13. };
  14. constructor(private _electron: ElectronService) {}
  15. ngOnInit() {}
  16. minimize() {
  17. this._electron.remote.getCurrentWindow().minimize();
  18. }
  19. maximize() {
  20. let currentWindow = this._electron.remote.getCurrentWindow();
  21. if (!currentWindow.isMaximized()) {
  22. this.old = {
  23. position : currentWindow.getPosition(),
  24. size : currentWindow.getSize()
  25. };
  26. currentWindow.maximize();
  27. }else if(this.old !== undefined){
  28. currentWindow.setPosition(this.old.position[0], this.old.position[1], true);
  29. currentWindow.setSize(this.old.size[0], this.old.size[1], true);
  30. }
  31. }
  32. close() {
  33. this._electron.remote.getCurrentWindow().close();
  34. }
  35. }