예제 #1
0
        public FloatingOverlayWindow(AppState appState, IApplicationServices applicationServices, IService service, Window mainWindow, MainViewModel mainViewModel)
        {
            InitializeComponent();
            SetInitialWindowPosition();
            __MainWindow = mainWindow;

            ViewModel = new FloatingOverlayWindowViewModel(appState, service, applicationServices, mainViewModel);
            ViewModel.PropertyChanged += ViewModelOnPropertyChanged;
            DataContext = this;//__ViewModel;
        }
        private void Initialize()
        {
            _timerHideWnd.Elapsed += OnTimerHideWindowEvent;

            this.Window.OnDoubleClick += () => { OnDoubleClick?.Invoke(); };
            this.Window.OnClick       += () => { OnClick?.Invoke(); };

            Window.IsVisible  = false;
            Window.AlphaValue = 0.9f;

            // set background colors
            Window.BackgroundColor = WindowBackgroundColor;

            FirewallStatusLabel.TextColor = TextStatusColor;
            VPNStatusLabel.TextColor      = TextStatusColor;
            PauseTimeLeftLabel.TextColor  = TextStatusColor;

            FirewallLabel.TextColor = TextLabelColor;
            VPNLabel.TextColor      = TextLabelColor;
            ResumeInLabel.TextColor = TextLabelColor;

            NSImage resumeBtnImage = NSImage.ImageNamed("iconPlayWhite");

            resumeBtnImage.Size = new CoreGraphics.CGSize(9, 12);
            ResumeBtn.Image     = resumeBtnImage;
            ResumeBtn.TitleTextAttributedString = AttributedString.Create(" " + __appServices.LocalizedString("Button_Resume"), NSColor.White, null, UIUtils.GetSystemFontOfSize(12f, NSFontWeight.Semibold));
            ResumeBtn.BackgroundColor           = NSColor.Black;
            ResumeBtn.IconLocation = CustomButton.IconLocationEnum.Right;
            ResumeBtn.CornerRadius = 7;

            // locationg UI elements on right place
            // (some elements are located not on rihght places (in order to easiest view in Xcode designer during developing))
            nfloat offset = FirewallLabel.Frame.Y - ResumeInLabel.Frame.Y;

            CoreGraphics.CGRect oldFrame = Window.Frame;
            Window.SetFrame(new CoreGraphics.CGRect(oldFrame.X, oldFrame.Y + offset, oldFrame.Width, oldFrame.Height - offset), false);

            // update data according to ViewModel (on property changed)
            __viewModel = new FloatingOverlayWindowViewModel(__AppState, __service, __appServices, __MainViewModel);
            __viewModel.PropertyChanged += _viewModel_PropertyChanged;
            __viewModel.Initialize();
            __MainViewModel.PropertyChanged += MainViewModel_PropertyChanged;

            EnsureUIConsistent();
        }