Esempio n. 1
0
        /// <summary>
        /// The Test.
        /// </summary>
        /// <param name="testWindow">The testWindow<see cref="Window"/>.</param>
        protected override void Test(Window testWindow)
        {
            var urlReader  = new UrlReader();
            var settings   = new SettingsViewModel();
            var viewModelA = new UrlEditorViewModel(urlReader, settings)
            {
                IsVisible = true, FileName = "Youtube Video File Name", FileSize = "5 MB", Duration = "00:02:45"
            };
            var viewModelB = new UrlEditorViewModel(urlReader, settings)
            {
                IsVisible = true, FileName = "Youtube Video File Name", FileSize = "1.4 MB", Duration = "00:02:45", IsBusy = true
            };
            var stackPanel = new StackPanel();

            stackPanel.Children.Add(new UrlEditorView {
                DataContext = viewModelA
            });
            stackPanel.Children.Add(new UrlEditorView {
                DataContext = viewModelB
            });
            WindowFactory.CreateAndShow(stackPanel, testWindow);
        }
Esempio n. 2
0
        /// <summary>
        /// Executes this commmand.
        /// </summary>
        /// <remarks></remarks>
        public override void Execute()
        {
            // Verify all [Required] and [Import]ed properties have valid values.
            this.ValidateObject();

            var services             = CurrentElement.Parent.Parent.Parent.Parent.Service;
            var existingServiceNames = services.Select(e => e.InstanceName);
            var picker = WindowFactory.CreateDialog <ServicePicker>() as IServicePicker;

            picker.Elements = new ObservableCollection <string>(existingServiceNames);
            picker.Title    = "Add Subscriber...";

            using (new MouseCursor(Cursors.Arrow))
            {
                if (picker.ShowDialog().Value)
                {
                    foreach (var selectedElement in picker.SelectedItems)
                    {
                        var selectedService = default(IService);
                        if (existingServiceNames.Contains(selectedElement))
                        {
                            selectedService = services.FirstOrDefault(e => string.Equals(e.InstanceName, selectedElement, StringComparison.InvariantCultureIgnoreCase));
                        }
                        else
                        {
                            selectedService = CurrentElement.Parent.Parent.Parent.Parent.CreateService(selectedElement);
                        }

                        var component = selectedService.Components.CreateComponent(string.Format("{0}Processor", CurrentElement.InstanceName));
                        component.Subscribes.CreateSubscribedEventLink(CurrentElement.InstanceName, e => e.EventReference.Value = CurrentElement);
                    }
                }
            }
            // TODO: Implement command automation code
            //	TODO: Use tracer.Warning() to note expected and recoverable errors
            //	TODO: Use tracer.Verbose() to note internal execution logic decisions
            //	TODO: Use tracer.Info() to note key results of execution
            //	TODO: Raise exceptions for all other errors
        }
        public WinUsbConnectionService()
        {
            currentContext = SynchronizationContext.Current;
            add($"vid_{TreehopperUsb.Settings.Vid:x}&pid_{TreehopperUsb.Settings.Pid:x}");
            var wf = WindowFactory.Create();

            // We can only hear WM_DEVICECHANGE messages if we're an STA thread that's properly pumping windows messages.
            // There's no easy way to tell if the calling thread is pumping messages, so just check the apartment state, and assume people
            // aren't creating STA threads without a message pump.

            devNotifyThread = new Thread(() =>
            {
                mNotifyWindow = wf.CreateWindowEx(() => new UsbNotifyWindow(this), null);
                mNotifyWindow.Show();
                loop = new RealtimeEventLoop();
                loop.Run(mNotifyWindow);
            })
            {
                Name = "DevNotifyNativeWindow Thread"
            };
            devNotifyThread.Start();
        }
Esempio n. 4
0
        public WinAllScreen()
        {
            Title.Text = "Congratulation!";

            WinAllText    = new Label(FontLoader.Load("HeaderFont"), "You have passed all levels!", GlobalData.Theme["Silver"]);
            HighScoreText = new Label(FontLoader.Load("HeaderFont"), "High Score: " + GlobalData.Session.CurrentScore.ToString("N0"), GlobalData.Theme["Yellow"]);

            TextBox    = WindowFactory.CreateTextbox();
            SaveButton = WindowFactory.CreateButton("Back to menu");

            TextBox.Position = new Vector2()
            {
                X = GetControlXPosition(TextBox, 1, 1),
                Y = this.Position.Y + 210f,
            };

            SaveButton.Position = new Vector2()
            {
                X = GetControlXPosition(SaveButton, 1, 1),
                Y = this.Position.Y + 300f,
            };
        }
Esempio n. 5
0
        /// <summary>
        /// Executes this commmand.
        /// </summary>
        /// <remarks></remarks>
        public override void Execute()
        {
            // Verify all [Required] and [Import]ed properties have valid values.
            this.ValidateObject();

            CurrentService = CurrentElement.As <IService>();

            var commands     = CurrentService.Contract.Commands.Command;
            var commandNames = commands.Select(e => e.InstanceName).ToList();

            var viewModel = new ElementPickerViewModel(commandNames)
            {
                Title      = "Send Command",
                MasterName = "Command name"
            };

            var picker = WindowFactory.CreateDialog <ElementPicker>(viewModel);

            using (new MouseCursor(Cursors.Arrow))
            {
                if (picker.ShowDialog().GetValueOrDefault())
                {
                    var selectedElement = viewModel.SelectedItem;
                    if (!commandNames.Contains(selectedElement))
                    {
                        CurrentService.Contract.Commands.CreateCommand(selectedElement);
                    }
                }
            }
            // Make initial trace statement for this command
            //tracer.Info(
            //    "Executing ShowElementTypePicker on current element '{0}' with AProperty '{1}'", this.CurrentElement.InstanceName, this.ElementType);

            //	TODO: Use tracer.Warning() to note expected and recoverable errors
            //	TODO: Use tracer.Verbose() to note internal execution logic decisions
            //	TODO: Use tracer.Info() to note key results of execution
            //	TODO: Raise exceptions for all other errors
        }
        /// <summary>
        /// Executes this commmand.
        /// </summary>
        /// <remarks></remarks>
        public override void Execute()
        {
            // Verify all [Required] and [Import]ed properties have valid values.
            this.ValidateObject();

            var element    = CurrentElement.As <IAbstractEndpointComponents>();
            var components = CurrentElement.Root.As <IApplication>().Design.Services.Service.SelectMany(s => s.Components.Component)
                             .Except(element.AbstractComponentLinks.Select(cl => cl.ComponentReference.Value));
            var existingServiceNames = components.Select(e => String.Format("{0}.{1}", e.Parent.Parent.InstanceName, e.InstanceName)).ToList();

            var viewModel = new ComponentPickerViewModel(existingServiceNames)
            {
                Title = "Deploy components..."
            };

            var picker = WindowFactory.CreateDialog <ComponentPicker>(viewModel);

            var currentEndpoint = CurrentElement.Parent.As <IAbstractEndpoint>();

            using (new MouseCursor(Cursors.Arrow))
            {
                if (picker.ShowDialog().GetValueOrDefault())
                {
                    foreach (var selectedElement in viewModel.SelectedItems)
                    {
                        var selectedCompoenent = default(NServiceBusStudio.IComponent);
                        if (existingServiceNames.Contains(selectedElement))
                        {
                            selectedCompoenent = components.FirstOrDefault(e => String.Equals(String.Format("{0}.{1}", e.Parent.Parent.InstanceName, e.InstanceName), selectedElement, StringComparison.InvariantCultureIgnoreCase));
                        }

                        selectedCompoenent.DeployTo(currentEndpoint);
                        //var link = CurrentElement.As<IAbstractEndpointComponents>().CreateComponentLink(selectedCompoenent.InstanceName, e => e.ComponentReference.Value = selectedCompoenent);
                        //link.ComponentReference.Value.EndpointDefined(currentEndpoint);
                    }
                }
            }
        }
Esempio n. 7
0
 static int Main(string[] args)
 {
     try
     {
         ApplicationHelpers.SetupDefaultExceptionHandlers();
         var factory = WindowFactory.Create(hBgBrush: IntPtr.Zero);
         // Create the window without a dependency on WinApi.Windows.Controls
         using (
             var win = factory.CreateWindow(() => new MainWindow(), "Hello",
                                            constructionParams: new FrameWindowConstructionParams(),
                                            exStyles: WindowExStyles.WS_EX_APPWINDOW | WindowExStyles.WS_EX_NOREDIRECTIONBITMAP))
         {
             win.CenterToScreen();
             win.Show();
             return(new EventLoop().Run(win));
         }
     }
     catch (Exception ex)
     {
         MessageBoxHelpers.ShowError(ex);
         return(1);
     }
 }
Esempio n. 8
0
        protected virtual FrameworkElement CreateWindow(object vm)
        {
            Window w;

            if (WindowFactory != null)
            {
                w = (Window)WindowFactory.LoadContent();
            }
            else
            {
                w = new Window();
            }
            w.WindowStartupLocation = WindowStartupLocation;
            if (WindowStyle != null)
            {
                w.Style = WindowStyle;
            }
            if (WindowStyleSelector != null)
            {
                w.Style = WindowStyleSelector.SelectStyle(vm, w);
            }
            if (SetWindowOwner && !IsMainWindow && Application.Current != null)
            {
                w.Owner =
                    Application.Current.Windows.OfType <Window>().FirstOrDefault(x => x.IsActive)
                    ?? Application.Current.MainWindow;
            }
            if (!IsMainWindow && AssociatedObject is FrameworkElement)
            {
                ViewServiceBase.UpdateThemeName(w, (FrameworkElement)AssociatedObject);
            }
            if (IsMainWindow && Application.Current != null)
            {
                Application.Current.MainWindow = w;
            }
            return(w);
        }
Esempio n. 9
0
        public override void Execute()
        {
            using (new MouseCursor(Cursors.Arrow))
            {
                var picker  = WindowFactory.CreateDialog <UseCaseComponentPicker>();
                var usecase = this.CurrentElement.As <IUseCase>();
                var dialog  = picker as UseCaseComponentPicker;
                dialog.Title = "Add Command to Use Case";
                dialog.SetComponentLabel("Command Name:");
                var app = usecase.As <IProductElement>().Root.As <IApplication>();
                dialog.SetServices(app.Design.Services.Service);
                dialog.ServiceItemsFillFunction = svc => svc.Contract.Commands.Command.Select(c => c.InstanceName);
                if (picker.ShowDialog() == true)
                {
                    var svc = app.Design.Services.Service.FirstOrDefault(s => s.InstanceName == dialog.SelectedService);
                    if (svc == null)
                    {
                        svc = app.Design.Services.CreateService(dialog.SelectedService);
                    }
                    var command = svc.Contract.Commands.Command.FirstOrDefault(c => c.InstanceName == dialog.SelectedComponent);
                    if (command == null)
                    {
                        command = svc.Contract.Commands.CreateCommand(dialog.SelectedComponent,
                                                                      cmd => cmd.DoNotAutogenerateComponents = true,
                                                                      true);

                        var processorName      = Component.TryGetComponentName(command.InstanceName + "Handler", svc);
                        var processorComponent = svc.Components.CreateComponent(processorName);

                        processorComponent.Subscribe(command);
                        this.CurrentElement.As <IUseCase>().AddRelatedElement(processorComponent.As <IProductElement>());
                    }

                    this.CurrentElement.As <IUseCase>().AddRelatedElement(command.As <IProductElement>());
                }
            }
        }
        /// <summary>
        /// Executes this commmand.
        /// </summary>
        /// <remarks></remarks>
        public override void Execute()
        {
            // Verify all [Required] and [Import]ed properties have valid values.
            this.ValidateObject();

            var events = CurrentElement.Parent.Parent.Parent.Service.SelectMany(s => s.Contract.Events.Event);

            // Filter those events that already processed by the component
            events = events.Where(e => !CurrentElement.Subscribes.SubscribedEventLinks.Any(el => el.EventReference.Value == e));

            // Get event names
            var existingEventNames = events.Select(e => e.InstanceName).ToList();

            var viewModel = new EventReadOnlyPickerViewModel(existingEventNames);

            var picker = WindowFactory.CreateDialog <EventReadOnlyPicker>(viewModel);

            using (new MouseCursor(Cursors.Arrow))
            {
                if (picker.ShowDialog().GetValueOrDefault())
                {
                    foreach (var selectedElement in viewModel.SelectedItems)
                    {
                        var selectedEvent = events.FirstOrDefault(e => string.Equals(e.InstanceName, selectedElement, StringComparison.InvariantCultureIgnoreCase));
                        CurrentElement.Subscribes.CreateLink(selectedEvent);
                    }

                    SagaHelper.CheckAndPromptForSagaUpdate(CurrentElement, MessageBoxService, WindowFactory);
                }
            }

            // TODO: Implement command automation code
            //	TODO: Use tracer.Warning() to note expected and recoverable errors
            //	TODO: Use tracer.Verbose() to note internal execution logic decisions
            //	TODO: Use tracer.Info() to note key results of execution
            //	TODO: Raise exceptions for all other errors
        }
        /// <summary>
        /// Executes this commmand.
        /// </summary>
        /// <remarks></remarks>
        public override void Execute()
        {
            // Verify all [Required] and [Import]ed properties have valid values.
            this.ValidateObject();

            var events     = CurrentElement.Parent.Parent.Parent.Parent.Service.SelectMany(s => s.Contract.Events.Event);
            var eventNames = events.Select(e => e.InstanceName);
            var picker     = WindowFactory.CreateDialog <EventReadOnlyPicker>() as IElementPicker;

            picker.Elements = eventNames.Union(new string[] { AnyMessageSupport.TextForUI }).ToList();
            picker.Title    = "Process Messages…";

            using (new MouseCursor(Cursors.Arrow))
            {
                if (picker.ShowDialog().Value)
                {
                    var selectedElement = picker.SelectedItem;
                    var selectedEvent   = default(IEvent);
                    if (selectedElement == AnyMessageSupport.TextForUI)
                    {
                        CurrentElement.CreateSubscribedEventLink(AnyMessageSupport.TextForUI, p => p.EventReference.Value = null);
                    }
                    else if (eventNames.Contains(selectedElement))
                    {
                        selectedEvent = events.FirstOrDefault(e => string.Equals(e.InstanceName, selectedElement, StringComparison.InvariantCultureIgnoreCase));
                        CurrentElement.CreateSubscribedEventLink(selectedEvent.InstanceName, p => p.EventReference.Value = selectedEvent);
                    }
                }
            }

            // TODO: Implement command automation code
            //	TODO: Use tracer.Warning() to note expected and recoverable errors
            //	TODO: Use tracer.Verbose() to note internal execution logic decisions
            //	TODO: Use tracer.Info() to note key results of execution
            //	TODO: Raise exceptions for all other errors
        }
Esempio n. 12
0
        private void DisplayCategory(CategoryEditDTO categoryEditDTO)
        {
            CategoryEditViewModel viewModel = new CategoryEditViewModel(categoryEditDTO);
            CategoryEditView      view      = new CategoryEditView(viewModel);
            Window window = WindowFactory.CreateByContentsSize(view);

            viewModel.CategorySaveRequest += (s, e) =>
            {
                using (ICategoryController controller = factory.CreateCategoryController())
                {
                    ControllerMessage controllerMessage = controller.Update(e.Data);
                    if (controllerMessage.IsSuccess)
                    {
                        Notify();
                    }
                    else
                    {
                        MessageBox.Show(controllerMessage.Message);
                    }
                }
            };

            window.Show();
        }
Esempio n. 13
0
        public MessageBox(string title, string text)
        {
            background = TextureLoader.Load("MessageBox");

            Title.Text = title;

            text   = FontHelper.BreakTextIntoLines(text, 50, 3);
            prompt = new Label(defaultFont, text);

            YesButton = WindowFactory.CreateButton("Yes");
            NoButton  = WindowFactory.CreateButton("No");

            YesButton.Position = new Vector2()
            {
                X = GetControlXPosition(YesButton, 1, 2),
                Y = Position.Y + Height * 0.75f,
            };

            NoButton.Position = new Vector2()
            {
                X = GetControlXPosition(NoButton, 2, 2),
                Y = Position.Y + Height * 0.75f,
            };
        }
Esempio n. 14
0
 public Firefox(AutomationElement automationElement, WindowFactory windowFactory, InitializeOption option, WindowSession windowSession)
     : base(automationElement, windowFactory, option, windowSession)
 {
 }
Esempio n. 15
0
 public Firefox(AutomationElement automationElement, WindowFactory windowFactory, InitializeOption option, WindowSession windowSession) :
     base(automationElement, windowFactory, option, windowSession)
 {
 }
Esempio n. 16
0
        static int Main(string[] args)
        {
            AppDomain.CurrentDomain.AssemblyResolve += CurrentDomain_AssemblyResolve;

            {
                //new System.Drawing.android.android();

                var path = Assembly.GetExecutingAssembly().CodeBase?.ToString();
                var dir  = Path.GetDirectoryName(path).Replace("file:\\", "");
                Assembly.LoadFile(dir +
                                  Path.DirectorySeparatorChar +
                                  "System.Drawing.dll");
                Assembly.LoadFile(dir +
                                  Path.DirectorySeparatorChar +
                                  "System.Drawing.Common.dll");

                var file       = File.ReadAllText("SkiaTest.deps.json");
                var fileobject = JsonConvert.DeserializeObject(file) as JObject;
                var baditem    = ((JObject)fileobject["targets"][".NETCoreApp,Version=v6.0"]).Property("System.Drawing.Common/5.0.0");
                if (baditem != null)
                {
                    baditem.Remove();
                }
                baditem = ((JObject)fileobject["libraries"]).Property("System.Drawing.Common/5.0.0");
                if (baditem != null)
                {
                    baditem.Remove();
                }

                baditem = ((JObject)fileobject["libraries"]).Property("System.Windows.Extensions/5.0.0");
                if (baditem != null)
                {
                    baditem.Remove();
                }

                baditem = ((JObject)fileobject["targets"]).Property("System.Windows.Extensions/5.0.0");
                if (baditem != null)
                {
                    baditem.Remove();
                }

                File.WriteAllText("SkiaTest.deps.json", fileobject.ToString());
            }

            System.Text.Encoding.RegisterProvider(System.Text.CodePagesEncodingProvider.Instance);

            try
            {
                ApplicationHelpers.SetupDefaultExceptionHandlers();
                var factory = WindowFactory.Create(hBgBrush: IntPtr.Zero);
                using (var win = factory.CreateWindow(() => new SkiaWindow(), "Hello",
                                                      constructionParams: new FrameWindowConstructionParams()))
                {
                    win.SetSize(900, 540 + 30);
                    win.Show();
                    return(new EventLoop().Run(win));
                }
            }
            catch (Exception ex)
            {
                MessageBoxHelpers.ShowError(ex);
                return(1);
            }
        }
 public InternetExplorerWindow(AutomationElement automationElement, WindowFactory windowFactory, InitializeOption option, WindowSession windowSession)
     : base(automationElement, windowFactory, option, windowSession)
 {
 }
        public override void Execute()
        {
            // Verify all [Required] and [Import]ed properties have valid values.
            this.ValidateObject();

            var element   = CurrentElement.As <NServiceBusStudio.IComponent>();
            var endpoints = this.CurrentElement.Root.As <NServiceBusStudio.IApplication>().Design.Endpoints.GetAll();

            if (element.Subscribes.ProcessedCommandLinks.Any() &&
                this.CurrentElement.Root.As <NServiceBusStudio.IApplication>().Design.Endpoints.GetAll()
                .Count(ep => ep.EndpointComponents.AbstractComponentLinks.Any(cl => cl.ComponentReference.Value == element)) >= 1)
            {
                var error = String.Format("The command-processing component {0}.{1} is already deployed. Please, undeploy the component from the endpoint and try again.", element.Parent.Parent.InstanceName, element.InstanceName);
                System.Windows.MessageBox.Show(error, "ServiceMatrix - Processing Component already Deployed", System.Windows.MessageBoxButton.OK, System.Windows.MessageBoxImage.Error);
                return;
            }

            // Filter those endpoints that already have the component deploed
            endpoints = endpoints.Where(e => !e.EndpointComponents.AbstractComponentLinks.Any(cl => cl.ComponentReference.Value == element));

            // Get endpoint names
            var existingEndpointNames = endpoints.Select(e => String.Format("{0}", (e as IToolkitInterface).As <IProductElement>().InstanceName));
            var picker = WindowFactory.CreateDialog <EndpointPicker>() as IEndpointPicker;

            picker.Title         = "Deploy to...";
            picker.ComponentName = element.InstanceName + " component";

            picker.Elements = new ObservableCollection <string>(existingEndpointNames);

            using (new MouseCursor(Cursors.Arrow))
            {
                if (picker.ShowDialog().Value)
                {
                    // Add new endpoint
                    foreach (var selectedElement in picker.SelectedItems)
                    {
                        var selectedEndpoint = default(IAbstractEndpoint);
                        if (existingEndpointNames.Contains(selectedElement))
                        {
                            selectedEndpoint = endpoints.FirstOrDefault(e => String.Equals(String.Format("{0}", (e as IToolkitInterface).As <IProductElement>().InstanceName), selectedElement, StringComparison.InvariantCultureIgnoreCase));
                            element.DeployTo(selectedEndpoint);
                        }
                        else
                        {
                            var regexMatch   = System.Text.RegularExpressions.Regex.Match(selectedElement, "(?'name'[^\\[]*?)\\[(?'type'[^\\]]*?)\\]");
                            var selectedName = regexMatch.Groups["name"].Value.Trim();
                            var selectedType = regexMatch.Groups["type"].Value.Trim();

                            var app     = CurrentElement.Root.As <IApplication>();
                            var handler = default(System.EventHandler);
                            handler = new System.EventHandler((s, e) =>
                            {
                                element.DeployTo((IAbstractEndpoint)s);
                                app.OnInstantiatedEndpoint -= handler;
                            });
                            app.OnInstantiatedEndpoint += handler;

                            if (selectedType == "NServiceBus ASP.NET MVC")
                            {
                                selectedEndpoint = app.Design.Endpoints.CreateNServiceBusMVC(selectedName);
                            }
                            else if (selectedType == "NServiceBus ASP.NET Web Forms")
                            {
                                selectedEndpoint = app.Design.Endpoints.CreateNServiceBusWeb(selectedName);
                            }
                            else
                            {
                                selectedEndpoint = app.Design.Endpoints.CreateNServiceBusHost(selectedName);
                            }
                        }
                    }
                }
            }
        }
        /// <summary>
        /// Executes this commmand.
        /// </summary>
        /// <remarks></remarks>
        public override void Execute()
        {
            // Verify all [Required] and [Import]ed properties have valid values.
            this.ValidateObject();

            var currentComponent = CurrentElement.As <IComponent>();
            var service          = currentComponent.Parent.Parent;

            var viewModel = new ServiceAndCommandPickerViewModel(service);

            var picker = WindowFactory.CreateDialog <ServiceAndCommandPicker>(viewModel);

            using (new MouseCursor(Cursors.Arrow))
            {
                if (picker.ShowDialog().GetValueOrDefault())
                {
                    var selectedCommand = viewModel.SelectedCommand;

                    // Figure out if new or existing command
                    var newCommand = false;
                    var command    = service.Contract.Commands.Command.FirstOrDefault(x => x.InstanceName == selectedCommand);
                    if (command == null)
                    {
                        newCommand = true;
                        command    = service.Contract.Commands.CreateCommand(selectedCommand);
                    }

                    // Link command to current component
                    currentComponent.Publishes.CreateLink(command);

                    // Assign handler if command
                    if (newCommand)
                    {
                        if (viewModel.SelectedHandlerComponent == null)
                        {
                            service.Components.CreateComponent(command.InstanceName + "Handler", x => x.Subscribes.CreateLink(command));
                        }
                        else
                        {
                            var handlerComponent = viewModel.SelectedHandlerComponent;
                            handlerComponent.Subscribes.CreateLink(command);

                            SagaHelper.CheckAndPromptForSagaUpdate(handlerComponent, MessageBoxService, WindowFactory);
                        }
                    }

                    // Code Generation Guidance
                    if (currentComponent.UnfoldedCustomCode)
                    {
                        var userCode = (UserCodeChangeRequired)WindowFactory.CreateDialog <UserCodeChangeRequired>();
                        userCode.UriService = UriService;
                        userCode.Solution   = Solution;
                        userCode.Component  = currentComponent;
                        userCode.Code       = String.Format("var {0} = new {1}.{2}();\r\nBus.Send({0});",
                                                            command.CodeIdentifier.LowerCaseFirstCharacter(),
                                                            command.Parent.Namespace,
                                                            command.CodeIdentifier);

                        userCode.ShowDialog();
                    }
                }
            }
        }
Esempio n. 20
0
 public AppWindowInstance(IntPtr windowHandle)
 {
     this.Window     = WindowFactory.CreateWindowFromHandle(windowHandle);
     this.MenuHandle = User32Methods.GetSystemMenu(this.Window.Handle, false);
 }
        public override Window ModalWindow(SearchCriteria searchCriteria, InitializeOption option)
        {
            WindowFactory desktopWindowsFactory = WindowFactory.Desktop;

            return(desktopWindowsFactory.FindModalWindow(searchCriteria, option, automationElement, WindowSession.ModalWindowSession(option)));
        }
Esempio n. 22
0
 public static void Plugin()
 {
     WindowFactory.AddSpecializedWindowFactory(new InternetExplorerFactory());
 }
Esempio n. 23
0
        protected override void OnStartup(StartupEventArgs e)
        {
            IWindowFactory windowFactory = new WindowFactory();

            windowFactory.OpenMainWindow();
        }
Esempio n. 24
0
 public static void Plugin()
 {
     WindowFactory.AddSpecializedWindowFactory(new FirefoxFactory());
 }
Esempio n. 25
0
 private async void ShowAlert(object sender, RoutedEventArgs e)
 {
     await WindowFactory.Alert("Hello World!").Show();
 }
Esempio n. 26
0
        public override void Execute()
        {
            // Verify all [Required] and [Import]ed properties have valid values.
            this.ValidateObject();

            var element   = CurrentElement.As <IComponent>();
            var endpoints = CurrentElement.Root.As <IApplication>().Design.Endpoints.GetAll();

            if (element.Subscribes.ProcessedCommandLinks.Any() &&
                CurrentElement.Root.As <IApplication>().Design.Endpoints.GetAll()
                .Count(ep => ep.EndpointComponents.AbstractComponentLinks.Any(cl => cl.ComponentReference.Value == element)) >= 1)
            {
                var error = String.Format("The command-processing component {0}.{1} is already deployed. Please, undeploy the component from the endpoint and try again.", element.Parent.Parent.InstanceName, element.InstanceName);
                MessageBox.Show(error, "ServiceMatrix - Processing Component already Deployed", MessageBoxButton.OK, MessageBoxImage.Error);
                return;
            }

            // Filter those endpoints that already have the component deployed
            endpoints = endpoints.Where(e => !e.EndpointComponents.AbstractComponentLinks.Any(cl => cl.ComponentReference.Value == element));

            // Get endpoint names
            var existingEndpointNames = endpoints.Select(e => String.Format("{0}", e.As <IProductElement>().InstanceName)).ToList();

            var viewModel = new EndpointPickerViewModel(existingEndpointNames)
            {
                Title         = "Deploy to...",
                ComponentName = element.InstanceName + " component"
            };

            var picker = WindowFactory.CreateDialog <EndpointPicker>(viewModel);

            using (new MouseCursor(Cursors.Arrow))
            {
                if (picker.ShowDialog().GetValueOrDefault())
                {
                    // Add new endpoint
                    foreach (var selectedElement in viewModel.SelectedItems)
                    {
                        IAbstractEndpoint selectedEndpoint;
                        if (existingEndpointNames.Contains(selectedElement))
                        {
                            selectedEndpoint = endpoints.FirstOrDefault(e => String.Equals(String.Format("{0}", e.As <IProductElement>().InstanceName), selectedElement, StringComparison.InvariantCultureIgnoreCase));
                            element.DeployTo(selectedEndpoint);

                            if (selectedEndpoint is INServiceBusMVC)
                            {
                                const string recommendationMessage = "Would you like to broadcast this via SignalR?";
                                var          result = MessageBoxService.Show(recommendationMessage, "ServiceMatrix - SignalR Integration", MessageBoxButton.YesNo);

                                if (result == MessageBoxResult.Yes)
                                {
                                    var componentElement = element.As <IProductElement>();

                                    // Find the Broadcast via SignalR command to execute
                                    var commandToExecute = componentElement.AutomationExtensions.First(c => c.Name.Equals("OnBroadcastViaSignalRCommand"));
                                    commandToExecute.Execute();
                                }
                            }
                        }
                        else
                        {
                            var regexMatch   = Regex.Match(selectedElement, "(?'name'[^\\[]*?)\\[(?'type'[^\\]]*?)\\]");
                            var selectedName = regexMatch.Groups["name"].Value.Trim();
                            var selectedType = regexMatch.Groups["type"].Value.Trim();

                            var app     = CurrentElement.Root.As <IApplication>();
                            var handler = default(EventHandler);
                            handler = (s, e) =>
                            {
                                element.DeployTo((IAbstractEndpoint)s);
                                app.OnInstantiatedEndpoint -= handler;
                            };
                            app.OnInstantiatedEndpoint += handler;

                            if (selectedType == "NServiceBus ASP.NET MVC")
                            {
                                app.Design.Endpoints.CreateNServiceBusMVC(selectedName);

                                // TODO: Figure out the NullRef Exception
                                //const string recommendationMessage = "Would you like to broadcast this via SignalR?";
                                //var result = MessageBoxService.Show(recommendationMessage, "ServiceMatrix - SignalR Integration", MessageBoxButton.YesNo);

                                //if (result == MessageBoxResult.Yes)
                                //{
                                //    var componentElement = element.As<IProductElement>();

                                //    // Find the Broadcast via SignalR command to execute
                                //    var commandToExecute = componentElement.AutomationExtensions.First(c => c.Name.Equals("OnBroadcastViaSignalRCommand"));
                                //    commandToExecute.Execute();
                                //}
                            }
                            else
                            {
                                app.Design.Endpoints.CreateNServiceBusHost(selectedName);
                            }
                        }
                    }
                }
            }
        }
Esempio n. 27
0
 public static void provide(WindowFactory window)
 {
     window_ = window;
 }
Esempio n. 28
0
 public Win32Window(AutomationElement automationElement, WindowFactory windowFactory, InitializeOption option, WindowSession windowSession)
     : base(automationElement, option, windowSession)
 {
     this.windowFactory = windowFactory;
 }
        /// <summary>
        /// Executes this commmand.
        /// </summary>
        /// <remarks></remarks>
        public override void Execute()
        {
            this.CurrentComponent = this.CurrentElement.As <IComponent>();
            var createSenderComponent = false; // At Component Level, do not create sender

            if (this.CurrentComponent == null)
            {
                this.CurrentComponent = this.CurrentElement.Parent.As <IComponent>();
                createSenderComponent = true;
            }

            // Verify all [Required] and [Import]ed properties have valid values.
            this.ValidateObject();

            var commands     = CurrentComponent.Parent.Parent.Contract.Commands.Command;
            var commandNames = commands.Select(e => e.InstanceName);

            var picker = WindowFactory.CreateDialog <ElementPicker>() as IElementPicker;

            picker.Elements   = commandNames.ToList();
            picker.Title      = "Send Command";
            picker.MasterName = "Command name";

            using (new MouseCursor(Cursors.Arrow))
            {
                if (picker.ShowDialog().Value)
                {
                    var selectedElement = picker.SelectedItem;
                    var selectedCommand = default(ICommand);
                    if (commandNames.Contains(selectedElement))
                    {
                        selectedCommand = commands.FirstOrDefault(e => string.Equals(e.InstanceName, selectedElement, StringComparison.InvariantCultureIgnoreCase));
                    }
                    else
                    {
                        selectedCommand = CurrentComponent.Parent.Parent.Contract.Commands.CreateCommand(selectedElement, (c) => c.DoNotAutogenerateSenderComponent = !createSenderComponent);
                    }

                    CurrentComponent.Publishes.CreateLink(selectedCommand);

                    // Code Generation Guidance
                    if (CurrentComponent.UnfoldedCustomCode)
                    {
                        var userCode = WindowFactory.CreateDialog <UserCodeChangeRequired>() as UserCodeChangeRequired;
                        userCode.UriService = this.UriService;
                        userCode.Solution   = this.Solution;
                        userCode.Component  = CurrentComponent;
                        userCode.Code       = String.Format("var {0} = new {1}.{2}();\r\nBus.Send({0});",
                                                            selectedCommand.CodeIdentifier.LowerCaseFirstCharacter(),
                                                            selectedCommand.Parent.Namespace,
                                                            selectedCommand.CodeIdentifier);

                        userCode.ShowDialog();
                    }
                }
            }
            // Make initial trace statement for this command
            //tracer.Info(
            //    "Executing ShowElementTypePicker on current element '{0}' with AProperty '{1}'", this.CurrentElement.InstanceName, this.ElementType);

            //	TODO: Use tracer.Warning() to note expected and recoverable errors
            //	TODO: Use tracer.Verbose() to note internal execution logic decisions
            //	TODO: Use tracer.Info() to note key results of execution
            //	TODO: Raise exceptions for all other errors
        }
Esempio n. 30
0
 private void HomeEvent()
 {
     this.DialogResult             = false;
     WindowFactory.windowbackhome -= HomeEvent;
     WindowFactory.BackHome_Event();
 }
Esempio n. 31
0
        public static async void ShowLogin(object nothing)
        {
            var window = new MaterialWindow(new MaterialDialog
            {
                Title = "Please log in to continue",
                Form  = new MaterialForm
                {
                    new StringSchema
                    {
                        Name       = "Username",
                        Key        = "user",
                        IconKind   = PackIconKind.Account,
                        Validation = Validators.IsNotEmpty
                    },
                    new PasswordSchema
                    {
                        Name     = "Password",
                        Key      = "pass",
                        IconKind = PackIconKind.Key
                    },
                    new BooleanSchema
                    {
                        Name       = "Remember me",
                        IsCheckBox = true
                    }
                },
                PositiveAction   = "LOG IN",
                OnPositiveAction = async session =>
                {
                    // Simulate asynchronous work
                    await Task.Delay(2000);
                    var userCorrect     = (string)session["user"] == "test";
                    var passwordCorrect = (string)session["pass"] == "123456";
                    if (userCorrect && passwordCorrect)
                    {
                        session.Close(true);
                    }
                    else
                    {
                        if (!userCorrect)
                        {
                            session.Invalidate("user", "This username does not exist.");
                        }
                        else
                        {
                            session.Invalidate("pass", "Invalid password.");
                        }
                    }
                },
                ShowsProgressOnPositiveAction = true
            });

            var result = await window.Show();

            if (result == true)
            {
                var formData = window.Dialog.Form.GetValuesList();
                await WindowFactory.Alert($"Username: {formData[0]}\nPassword: {formData[1]}\nRemember me: {formData[2]}", "Positive").Show();
            }
            else
            {
                await WindowFactory.Alert("Dialog dismissed", "Negative").Show();
            }
        }