static void Main(string[] args) { var Os = "mac"; IGuiFactory factory = null; if (Os.Equals("win")) { factory = new WinFactory.WinFactory(); } else if (Os.Equals("mac")) { factory = new MacFactory.MacFactory(); } else { throw new Exception("invalid Os"); } var app = new Application(factory); app.Run(); Console.ReadKey(); }
private static void BuildInterface(IGuiFactory factory) { IGrid grid = factory.GenerateGrid(); for (int i = 0; i < 3; i++) { IButton btn = factory.GenerateButton(); btn.Content = $"Button{i+1}"; grid.AddButton(btn); ITextBox txtBox = factory.GenerateTextBox(); txtBox.Content = $"TextBox{i + 1}"; grid.AddTextBox(txtBox); } grid.GetButtons().First().ButtonPressed(); foreach (var elem in grid.GetButtons()) { elem.ButtonPressed(); elem.DrawContent(); } foreach (var elem in grid.GetTextBoxes()) { elem.DrawContent(); } }
public void ClientMethod(IGuiFactory guiFactory) { var button = guiFactory.CreateButton(); var checkBox = guiFactory.CreateCheckBox(); System.Console.WriteLine(button.Paint()); }
public override void ShowSystemWindow(SystemWindow systemWindow) { bool firstWindow = false; if (factoryToUse == null) { if (systemWindow.UseOpenGL) { factoryToUse = new WindowsFormsOpenGLFactory(); } else { factoryToUse = new WindowsFormsBitmapFactory(); } firstWindow = true; // When our top most window closes reset this so we can make a window in the future. systemWindow.Closed += (sender, e) => { factoryToUse = null; }; } AbstractOsMappingWidget osMappingWindow = factoryToUse.CreateSurface(systemWindow); osMappingWindow.Caption = systemWindow.Title; osMappingWindow.AddChild(systemWindow); osMappingWindow.MinimumSize = systemWindow.MinimumSize; systemWindow.AbstractOsMappingWidget = osMappingWindow; if (pendingSetInitialDesktopPosition) { pendingSetInitialDesktopPosition = false; systemWindow.DesktopPosition = InitialDesktopPosition; } systemWindow.AnchorAll(); systemWindow.TitleChanged += new EventHandler(TitelChangedEventHandler); // and make sure the title is correct right now TitelChangedEventHandler(systemWindow, null); if (firstWindow) { osMappingWindow.Run(); } else { if (systemWindow.IsModal) { osMappingWindow.ShowModal(); } else { osMappingWindow.Show(); osMappingWindow.BringToFront(); } } }
public void ClientMethod(IGuiFactory factory) { var productA = factory.CreateButton(); var productB = factory.CreateCheckBox(); Console.WriteLine(productB.CreateCheckBox()); Console.WriteLine(productB.AnotherUsefulFunctionB(productA)); }
public ClientGameEngine(IGuiFactory guiFactory) { _splashScreen = guiFactory.CreateSplashScreen(); _splashScreen.Show(); _mainWindow = guiFactory.CreateMainWindow(); _mainWindow.Show(); }
public static void SetFactory(IGuiFactory factoryToUse) { if (OsMappingWidgetFactory.factoryToUse != null) { throw new NotSupportedException("You can only set the graphics target one time in an application."); } OsMappingWidgetFactory.factoryToUse = factoryToUse; }
public GameEngine(IGuiFactory uiFactory) { IGuiSplashscreen splash = uiFactory.CreateSplashscreen(); splash.Show("Loading...", TimeSpan.FromSeconds(5)); IGuiMainWindow window = uiFactory.CreateMainWindow(WindowStyle.NoFrame); window.Show(); }
private void InitFactory() { Console.WriteLine("Input 'w' for Windows render, 'm' - for Mac render"); ConsoleKeyInfo?key = this.userInput?.Invoke(); if (!key.HasValue) { throw new NotImplementedException(); } Factory = key.Value.KeyChar switch { 'w' => new WinFactory(), 'm' => new MacFactory(), _ => throw new NotImplementedException() }; } }
public void Initialize() { string env = "Windows"; if (env == "Windows") { _guiFactory = new WindowsFactory(); } else if (env == "Web") { _guiFactory = new WebFactory(); } else { throw new Exception("Unknown enviorment"); } }
private static void print(EOsType type) { IGuiFactory factory = null; switch (type) { case EOsType.Window: factory = new WindowGuiFactory(); break; case EOsType.Mac: factory = new MacGuiFactory(); break; } IButton button = factory.createButton(); IText text = factory.createText(); button.click_Button(); text.text_Description(); }
public Application(IGuiFactory factory) { button = factory.CreateButton(); checkbox = factory.CreateCheckbox(); }
public Application(IGuiFactory factory) { _factory = factory; }
public Application(IGuiFactory factory) { var button = factory.CreateButton(); button.Paint(); }
public Application(IGuiFactory factory) { this.factory = factory; }
public void TestAbstractFactory(IGuiFactory guiFactory) { Assert.That(guiFactory.CreateButton(), Is.InstanceOf <IButton>()); Assert.That(guiFactory.CreateContextMenu(), Is.InstanceOf <IContextMenu>()); Assert.That(guiFactory.CreateWindow(), Is.InstanceOf <IWindow>()); }
public AbstractFactoryConfiguration(IGuiFactory factory) { this._guiFactory = factory; }
public Application(IGuiFactory factory) { IButton button = factory.CreateButton(); button.Paint(); }
public Application(IGuiFactory abstractFactory) { _abstractFactory = abstractFactory; }
public Application(IGuiFactory guiFactory) { this._factory = guiFactory; }