Exemplo n.º 1
0
        public PriceView(
            IServiceProvider serviceProvider,
            PriceViewModel viewModel,
            INativeBrowser nativeBrowser,
            INativeCursor cursor)
            : base(serviceProvider,
                   closeOnBlur: true)
        {
            this.viewModel     = viewModel;
            this.nativeBrowser = nativeBrowser;
            InitializeComponent();
            DataContext = viewModel;

            Loaded += OverlayWindow_Loaded;

            Show();
            Activate();

            if (GetMouseXPercent() > 0.5)
            {
                MoveWhenOpeningPreview = true;
                SetWindowPositionPercent(0.66 - GetWidthPercent(), 0.5 - (GetHeightPercent() / 2));
            }
            else
            {
                SetWindowPositionPercent(0.34, 0.5 - (GetHeightPercent() / 2));
            }

            if (viewModel.IsError)
            {
                Dispatcher.InvokeAsync(async() =>
                {
                    await Task.Delay(1500);
                    Close();
                });
            }

            viewModel.PropertyChanged += ViewModel_PropertyChanged;
        }
Exemplo n.º 2
0
        public PriceView(
            IServiceProvider serviceProvider,
            PriceViewModel viewModel,
            INativeBrowser nativeBrowser)
            : base("price", serviceProvider)
        {
            this.viewModel     = viewModel;
            this.nativeBrowser = nativeBrowser;
            InitializeComponent();
            DataContext = viewModel;

            Loaded += OverlayWindow_Loaded;

            Show();
            Activate();

            SetTopPercent(0.5, LocationSource.Center);
            if (GetMouseXPercent() > 0.5)
            {
                SetLeftPercent(0.654, LocationSource.End);
            }
            else
            {
                SetLeftPercent(0.346, LocationSource.Begin);
            }

            if (viewModel.IsError)
            {
                Dispatcher.InvokeAsync(async() =>
                {
                    await Task.Delay(1500);
                    Close();
                });
            }

            viewModel.PropertyChanged += ViewModel_PropertyChanged;
        }