Пример #1
0
        public SetupPrinterView(TextImageButtonFactory textImageButtonFactory)
            : base("Printer Profile")
        {
            this.textImageButtonFactory = textImageButtonFactory;

            var buttonContainer = new FlowLayoutWidget()
            {
                HAnchor = HAnchor.ParentLeftRight,
                Margin  = new BorderDouble(0, 14)
            };

            mainContainer.AddChild(buttonContainer);

            var printerSelectorAndEditButton = new FlowLayoutWidget()
            {
                HAnchor = HAnchor.ParentLeftRight,
            };

            buttonContainer.AddChild(printerSelectorAndEditButton);

            var printerSelector = new PrinterSelector();

            printerSelector.AddPrinter += (s, e) => WizardPage.WizardWindow.ChangeToSetupPrinterForm(true);
            printerSelectorAndEditButton.AddChild(printerSelector);

            var editButton = TextImageButtonFactory.GetThemedEditButton();

            editButton.ToolTipText = "Edit Selected Setting".Localize();
            editButton.VAnchor     = VAnchor.ParentCenter;
            editButton.Click      += UiNavigation.OpenEditPrinterWizard_Click;
            printerSelectorAndEditButton.AddChild(editButton);

            disconnectButton         = textImageButtonFactory.Generate("Disconnect");
            disconnectButton.Margin  = new BorderDouble(left: 12);
            disconnectButton.VAnchor = VAnchor.ParentCenter;
            disconnectButton.Click  += (sender, e) =>
            {
                PrinterConnectionAndCommunication.Instance.Disable();
                UiThread.RunOnIdle(WizardPage.WizardWindow.ChangeToPage <SetupOptionsPage>);
            };
            buttonContainer.AddChild(disconnectButton);

            connectionStatus = new TextWidget("Status:", pointSize: 12, textColor: ActiveTheme.Instance.PrimaryTextColor)
            {
                HAnchor = HAnchor.ParentLeftRight
            };
            mainContainer.AddChild(connectionStatus);

            PrinterConnectionAndCommunication.Instance.CommunicationStateChanged.RegisterEvent(updateConnectedState, ref unregisterEvents);
            updateConnectedState(null, null);
        }