private void Reload() { context.ItemsSource = WindowsHost .GetList() .OrderBy(it => it.Domain) .Select(it => new ListViewItemViewModel { Id = it.Domain, Title = it.Domain.ToUpper(), Tooltip = it.Domain, SubTitle = it.IpAddress, SubTooltip = it.IpAddress, Icons = new List <IconButton> { new IconButton { Icon = "delete-btn", Context = it, Command = new DelegateCommand <HostRecord>(record => { if (MessageBoxResult.Yes == MessageBox.Show(Data.Language.Hardcoded.GetValue("Are you sure you want to delete this item?"), Data.Language.Hardcoded.GetValue("Confirm"), MessageBoxButton.YesNo, MessageBoxImage.Asterisk)) { WindowsHost.Delete(record.Domain); this.Redirect(new HostPage()); } }) } } }); DataContext = context; }
public void EnsureLocalBinding() { if (!AppSettings.IsOnlineServer) { var allbindings = GlobalDb.Bindings.All(); foreach (var item in allbindings) { var domain = GlobalDb.Domains.Get(item.DomainId); if (domain != null) { string fullname = domain.DomainName; if (!string.IsNullOrEmpty(item.SubDomain)) { fullname = item.SubDomain + "." + fullname; } WindowsHost.AddOrUpdate(fullname, "127.0.0.1"); } } // TEMP. remove all thetheme.com binding. var alldomains = Kooboo.Data.Hosts.WindowsHost.GetList(); foreach (var item in alldomains) { if (!string.IsNullOrEmpty(item.Domain) && item.Domain.ToLower().EndsWith("thetheme.com")) { Data.Hosts.WindowsHost.Delete(item.Domain); } } } WindowsHost.AddOrUpdate(AppSettings.DefaultLocalHost, "127.0.0.1"); WindowsHost.AddOrUpdate(AppSettings.StartHost, "127.0.0.1"); }
public CreateHostPage() { InitializeComponent(); back.Content = Data.Language.Hardcoded.GetValue("back"); save.Content = Data.Language.Hardcoded.GetValue("save"); hostViewModel = new NewHostViewModel { Title = Data.Language.Hardcoded.GetValue("+ New host"), From = _parent, AddCommand = new DelegateCommand <NewHostViewModel>(vm => { if (!vm.IsValid()) { MessageBox.Show(vm.Error); return; } if (vm.Domain == vm.DomainPlaceholder) { MessageBox.Show(Data.Language.Hardcoded.GetValue("Domain is required")); return; } else if (vm.IP == vm.IpPlaceholder) { MessageBox.Show(Data.Language.Hardcoded.GetValue("IP is required")); return; } WindowsHost.AddOrUpdate(vm.Domain, vm.IP); this.Redirect(new HostPage()); }) }; DataContext = hostViewModel; }
public static void Main(string[] args) { WindowsHost windowsHost = ( WindowsHost )ConsoleApplication.LoadFromXaml("Examples.MainMenu.windows-host.xml", null); DataContext dataContext = new DataContext( ); Window mainWindow = ( Window )ConsoleApplication.LoadFromXaml( "Examples.MainMenu.main.xml", dataContext); windowsHost.Show(mainWindow); // Example of direct subscribing to Click event List <Control> menuItems = VisualTreeHelper.FindAllChilds(windowsHost.MainMenu, control => control is MenuItem); foreach (Control menuItem in menuItems) { MenuItem item = (( MenuItem )menuItem); if (item.Title == "Go") { item.Click += (sender, eventArgs) => { MessageBox.Show("", "", result => { // }); }; } } ConsoleApplication.Instance.Run(windowsHost); }
static void DomainInitializer(string[] args) { Console.WriteLine("Initializing the installer in the Install AppDomain"); Parser.Args commandLineArguments = Parser.ParseArgs(args); var arguments = new HostArguments(commandLineArguments); string endpointName = string.Empty; if (arguments.EndpointName != null) { endpointName = arguments.EndpointName.Value; } string[] scannedAssemblies = null; if (arguments.ScannedAssemblies != null) { scannedAssemblies = arguments.ScannedAssemblies.Value.Split(';').ToArray(); } if (arguments.Username != null) { MsmqUtilities.AccountToBeAssignedQueuePermissions(arguments.Username.Value); } host = new WindowsHost(Type.GetType(arguments.EndpointConfigurationType.Value, true), args, endpointName, commandLineArguments.Install, (arguments.InstallInfrastructure != null), scannedAssemblies); }
public static void Main(string[] args) { WindowsHost windowsHost = new WindowsHost( ); Window mainWindow = ( Window )ConsoleApplication.LoadFromXaml("Examples.AsyncUiUpdate.main.xml", null); windowsHost.Show(mainWindow); TextBlock textBlock = mainWindow.FindChildByName <TextBlock>("text"); Thread thread = new Thread(() => { int i = 1; for ( ;;) { ConsoleApplication.Instance.Post(new Action(() => { textBlock.Text = i.ToString(); })); Thread.Sleep(1000); i++; } }); thread.IsBackground = true; thread.Start(); mainWindow.FindChildByName <Button>("btnMaximize").OnClick += (sender, eventArgs) => { ConsoleApplication.Instance.Maximize(); }; mainWindow.FindChildByName <Button>("btnRestore").OnClick += (sender, eventArgs) => { ConsoleApplication.Instance.Restore(); }; ConsoleApplication.Instance.Run(windowsHost); }
public static void Main(string[] args) { WindowsHost windowsHost = new WindowsHost( ); Window mainWindow = ( Window )ConsoleApplication.LoadFromXaml("Examples.TabControl.main.xml", null); windowsHost.Show(mainWindow); ConsoleApplication.Instance.Run(windowsHost); }
public bool AddOrUpdate(Domain Domain) { string localip = "127.0.0.1"; WindowsHost.AddOrUpdate(Domain.DomainName, localip); this.domainstore.AddOrUpdate(Domain); return(true); }
public static void Main() { using ( var host = new WindowsHost<MainWindow>() ) {$if$ ($showTips$ == true) // TODO: register and/or configure tasks to execute during start up // the ShowShellViewTask is automatically registered. if you do not // have additional start up logic, then there is nothing to do here.$endif$ host.Run( new App() ); } }
public static void Main(string[] args) { DataContext dataContext = new DataContext(); WindowsHost windowsHost = (WindowsHost)ConsoleApplication.LoadFromXaml( "Examples.Commands.windows-host.xml", dataContext); Window mainWindow = (Window)ConsoleApplication.LoadFromXaml( "Examples.Commands.main.xml", dataContext); windowsHost.Show(mainWindow); ConsoleApplication.Instance.Run(windowsHost); }
static void Main(string[] args) { WindowsHost host = new WindowsHost(); Window Loginwindow = (Window)ConsoleApplication.LoadFromXaml("HackIt.Console.Windows.LoginWindow.xml", null); var cb = Loginwindow.FindChildByName <ComboBox>("cb"); host.ShowModal(Loginwindow); ConsoleApplication.Instance.Run(host); }
private void AskForRestart() { var query = "A restart is required. Restart now? You may need to re-run the current script after the restart to complete your installation."; if (!_interactionHandler.GetYesNoResponse(query)) { return; } WindowsHost.Restart(5); _interactionHandler.ExitWithSuccess("Exiting for reboot"); }
public static void Main(string[] args) { WindowsHost windowsHost = new WindowsHost( ); Window mainWindow = ( Window )ConsoleApplication.LoadFromXaml("Examples.CheckBoxes.main.xml", null); windowsHost.Show(mainWindow); CheckBox checkBox = mainWindow.FindChildByName <CheckBox>("checkbox"); checkBox.OnClick += (sender, eventArgs) => { eventArgs.Handled = true; }; ConsoleApplication.Instance.Run(windowsHost); }
public static void Main(string[] args) { Context context = new Context(); WindowsHost windowsHost = (WindowsHost)ConsoleApplication.LoadFromXaml( "Examples.TreeView.windows-host.xml", null); Window mainWindow = (Window)ConsoleApplication.LoadFromXaml( "Examples.TreeView.main.xml", context); windowsHost.Show(mainWindow); ConsoleFramework.Controls.TreeView tree = mainWindow.FindChildByName <ConsoleFramework.Controls.TreeView>("tree"); // todo : придумать способ для того, чтобы обходиться без такого костыля context.Items = tree.Items; ConsoleApplication.Instance.Run(windowsHost); }
public override void Delete(Guid id) { base.Delete(id); var find = LocalCache.GetValueOrDefault(id); if (find != null) { LocalCache.Remove(id); if (!AppSettings.IsOnlineServer) { WindowsHost.Delete(find.FullName); } } }
static void DomainInitializer(string[] args) { Console.WriteLine("Initializing the installer in the Install AppDomain"); var arguments = new HostArguments(args); string endpointName = null; if (arguments.EndpointName != null) { endpointName = arguments.EndpointName; } username = arguments.Username; host = new WindowsHost(Type.GetType(arguments.EndpointConfigurationType, true), args, endpointName, arguments.Install, arguments.ScannedAssemblies); }
static void DomainInitializer(string[] args) { Console.WriteLine("Initializing the installer in the Install AppDomain"); Parser.Args commandLineArguments = Parser.ParseArgs(args); var arguments = new HostArguments(commandLineArguments); string endpointName = string.Empty; if (arguments.EndpointName != null) endpointName = arguments.EndpointName.Value; string[] scannedAssemblies = null; if (arguments.ScannedAssemblies != null) scannedAssemblies = arguments.ScannedAssemblies.Value.Split(';').ToArray(); host = new WindowsHost(Type.GetType(arguments.EndpointConfigurationType.Value, true), args[0].Split(';').ToArray(), endpointName, commandLineArguments.Install, (arguments.InstallInfrastructure != null), scannedAssemblies); }
public static void Main( string[ ] args ) { WindowsHost windowsHost = new WindowsHost( ); Window mainWindow = ( Window ) ConsoleApplication.LoadFromXaml( "Examples.RadioButtons.main.xml", null ); windowsHost.Show( mainWindow ); var button = mainWindow.FindChildByName<Button>("btn"); button.OnClick += (sender, eventArgs) => { var radioGroup = mainWindow.FindChildByName<RadioGroup>("radio"); if (radioGroup.SelectedItem == null) MessageBox.Show("", "Not selected yet", result => { }); else MessageBox.Show("", radioGroup.SelectedItem.Caption, result => { }); }; ConsoleApplication.Instance.Run( windowsHost ); }
public override bool AddOrUpdate(Binding value) { var ok = base.AddOrUpdate(value); if (ok) { lock (writelock) { LocalCache[value.Id] = value; if (!AppSettings.IsOnlineServer) { var fullname = value.FullName; WindowsHost.AddOrUpdate(fullname, "127.0.0.1"); } } } return(ok); }
public void AddOrUpdate(string rootDomain, string subDomain, Guid webSiteId, Guid organizationId, bool defaultbinding = false, int port = 0) { Guid domainid = default(Guid); if (!string.IsNullOrEmpty(rootDomain)) { domainid = IDGenerator.GetDomainId(rootDomain); } if (!AppSettings.IsOnlineServer && domainid != default(Guid)) { var domain = GlobalDb.Domains.Get(domainid); if (domain == null) { WindowsHost.AddOrUpdate(rootDomain, "127.0.0.1"); GlobalDb.Domains.AddOrUpdate(new Domain() { DomainName = rootDomain, OrganizationId = organizationId }); } } Binding binding = new Binding { DomainId = domainid, OrganizationId = organizationId, SubDomain = string.IsNullOrEmpty(subDomain) ? null : subDomain.ToLower(), WebSiteId = webSiteId, DefaultPortBinding = defaultbinding, Port = port }; var old = this.Get(binding.Id); if (old != null) { throw new Exception("binding already exists"); } else { AddOrUpdate(binding); } }
public void Init( Action <IServiceCollection> configureServices, Action <ILoggingBuilder> configureLogging, HostType hostType) { if (configureServices == null) { throw new ArgumentNullException(nameof(configureServices)); } if (configureLogging == null) { throw new ArgumentNullException(nameof(configureLogging)); } IHostBuilder builder; switch (hostType) { case HostType.Default: builder = Host.CreateDefaultBuilder(); break; case HostType.WindowsLimited: builder = WindowsHost.CreateWindowsBuilder(); break; default: throw new InvalidOperationException("invalid host type"); } s_host = builder.ConfigureServices((context, services) => { configureServices(services); }) .ConfigureLogging(logging => { configureLogging(logging); }).Build(); }
public bool Delete(Domain Domain) { try { var records = WindowsHost.GetList().Where(it => it.Domain.EndsWith(Domain.DomainName)); foreach (var item in records) { WindowsHost.Delete(item.Domain); var domainid = IDGenerator.GetDomainId(item.Domain); this.domainstore.Delete(domainid); } var id = IDGenerator.GetDomainId(Domain.DomainName); this.domainstore.Delete(id); return(true); } catch (Exception) { return(false); } }
public void EnsureLocalBinding() { if (!AppSettings.IsOnlineServer) { var allbindings = GlobalDb.Bindings.All(); foreach (var item in allbindings) { var domain = GlobalDb.Domains.Get(item.DomainId); if (domain != null) { string fullname = domain.DomainName; if (!string.IsNullOrEmpty(item.SubDomain)) { fullname = item.SubDomain + "." + fullname; } WindowsHost.AddOrUpdate(fullname, "127.0.0.1"); } } } WindowsHost.AddOrUpdate(AppSettings.DefaultLocalHost, "127.0.0.1"); WindowsHost.AddOrUpdate(AppSettings.StartHost, "127.0.0.1"); }
public static void Main(string[] args) { WindowsHost windowsHost = ( WindowsHost )ConsoleApplication.LoadFromXaml("Examples.MainMenu.windows-host.xml", null); Window mainWindow = ( Window )ConsoleApplication.LoadFromXaml("Examples.MainMenu.main.xml", null); windowsHost.Show(mainWindow); CheckBox checkBox = mainWindow.FindChildByName <CheckBox>("checkbox"); checkBox.OnClick += (sender, eventArgs) => { eventArgs.Handled = true; }; List <Control> menuItems = VisualTreeHelper.FindAllChilds(windowsHost.MainMenu, control => control is MenuItem); foreach (Control menuItem in menuItems) { (( MenuItem )menuItem).Click += (sender, eventArgs) => { MessageBox.Show("", "", result => { // }); }; } ConsoleApplication.Instance.Run(windowsHost); }
static void Main(string[] args) { //When choosing types for variables that are part of the DOM API, //You will want to use var when it's possible and dynamic when it's not. Console.WriteLine("Starting"); WindowsHost windowsHost = new WindowsHost( ); Window window = new Window( ); Panel panel = new Panel( ) { Margin = new Thickness(1), HorizontalAlignment = HorizontalAlignment.Stretch }; panel.XChildren.Add(new TextBlock( ) { Text = "Press the button", Margin = new Thickness(0, 0, 0, 1), HorizontalAlignment = HorizontalAlignment.Center }); Button button = new Button( ) { Caption = "Button", HorizontalAlignment = HorizontalAlignment.Center }; panel.XChildren.Add(button); button.OnClick += (sender, eventArgs) => { MessageBox.Show("Info", "Button pressed !", result => { }); }; window.Content = panel; window.Title = "Hello, Web !"; windowsHost.Show(window); runWindows(windowsHost); // ConsoleApplication.Instance.Run( windowsHost ); }
private static void Main(string[] args) { // Control window = ConsoleApplication.LoadFromXaml( "ConsoleFramework.Layout.xml", null ); //// window.FindChildByName< TextBlock >( "text" ).MouseDown += ( sender, eventArgs ) => { //// window.FindChildByName< TextBlock >( "text" ).Text = "F"; //// eventArgs.Handled = true; //// }; //// window.MouseDown += ( sender, eventArgs ) => { //// window.Width = window.ActualWidth + 3; //// window.Invalidate( ); //// }; // ConsoleApplication.Instance.Run( window ); // return; var assembly = Assembly.GetExecutingAssembly(); var resourceName = "Examples.GridTest.xml"; Window createdFromXaml; using (Stream stream = assembly.GetManifestResourceStream(resourceName)) using (StreamReader reader = new StreamReader(stream)) { string result = reader.ReadToEnd(); MyDataContext dataContext = new MyDataContext( ); dataContext.Str = "Введите заголовок"; createdFromXaml = XamlParser.CreateFromXaml <Window>(result, dataContext, new List <string>() { "clr-namespace:Xaml;assembly=Xaml", "clr-namespace:ConsoleFramework.Xaml;assembly=ConsoleFramework", "clr-namespace:ConsoleFramework.Controls;assembly=ConsoleFramework", }); } // ConsoleApplication.Instance.Run(createdFromXaml); // return; using (ConsoleApplication application = ConsoleApplication.Instance) { Panel panel = new Panel(); panel.Name = "panel1"; panel.HorizontalAlignment = HorizontalAlignment.Center; panel.VerticalAlignment = VerticalAlignment.Stretch; panel.XChildren.Add(new TextBlock() { Name = "label1", Text = "Label1", Margin = new Thickness(1, 2, 1, 0) //,Visibility = Visibility.Collapsed }); panel.XChildren.Add(new TextBlock() { Name = "label2", Text = "Label2_____", HorizontalAlignment = HorizontalAlignment.Right }); TextBox textBox = new TextBox() { MaxWidth = 10, Margin = new Thickness(1), HorizontalAlignment = HorizontalAlignment.Center, Size = 15 }; Button button = new Button() { Name = "button1", Caption = "Button!", Margin = new Thickness(1), HorizontalAlignment = HorizontalAlignment.Center }; button.OnClick += (sender, eventArgs) => { Debug.WriteLine("Click"); MessageBox.Show("Окно сообщения", "Внимание ! Тестовое сообщение", delegate(MessageBoxResult result) { }); Control label = panel.FindDirectChildByName("label1"); if (label.Visibility == Visibility.Visible) { label.Visibility = Visibility.Collapsed; } else if (label.Visibility == Visibility.Collapsed) { label.Visibility = Visibility.Hidden; } else { label.Visibility = Visibility.Visible; } label.Invalidate(); }; ComboBox comboBox = new ComboBox( ) { // Width = 14 //HorizontalAlignment = HorizontalAlignment.Stretch }; comboBox.Items.Add("Сделать одно"); comboBox.Items.Add("Сделать второе"); comboBox.Items.Add("Ничего не делать"); ListBox listbox = new ListBox( ); listbox.Items.Add("First item"); listbox.Items.Add("second item1!!!!!!1fff"); listbox.HorizontalAlignment = HorizontalAlignment.Stretch; //listbox.Width = 10; panel.XChildren.Add(comboBox); panel.XChildren.Add(button); panel.XChildren.Add(textBox); panel.XChildren.Add(listbox); //application.Run(panel); WindowsHost windowsHost = new WindowsHost() { Name = "WindowsHost" }; Window window1 = new Window { X = 5, Y = 4, //MinHeight = 100, //MaxWidth = 30, //Width = 10, Height = 20, Name = "Window1", Title = "Window1", Content = panel }; GroupBox groupBox = new GroupBox( ); groupBox.Title = "Группа"; ScrollViewer scrollViewer = new ScrollViewer( ); ListBox listBox = new ListBox( ); listBox.Items.Add("Длинный элемент"); listBox.Items.Add("Длинный элемент 2"); listBox.Items.Add("Длинный элемент 3"); listBox.Items.Add("Длинный элемент 4"); listBox.Items.Add("Длинный элемент 5"); listBox.Items.Add("Длинный элемент 6"); listBox.Items.Add("Длинный элемент 700"); listBox.HorizontalAlignment = HorizontalAlignment.Stretch; listBox.VerticalAlignment = VerticalAlignment.Stretch; scrollViewer.Content = listBox; // scrollViewer.HorizontalAlignment = HorizontalAlignment.Stretch; scrollViewer.VerticalAlignment = VerticalAlignment.Stretch; scrollViewer.HorizontalScrollEnabled = false; groupBox.Content = scrollViewer; groupBox.HorizontalAlignment = HorizontalAlignment.Stretch; windowsHost.Show(new Window() { X = 30, Y = 6, //MinHeight = 10, //MinWidth = 10, Name = "LongTitleWindow", Title = "Очень длинное название окна", Content = groupBox }); windowsHost.Show(window1); windowsHost.Show(createdFromXaml); //textBox.SetFocus(); todo : научиться задавать фокусный элемент до добавления в визуальное дерево //application.TerminalSizeChanged += ( sender, eventArgs ) => { // application.CanvasSize = new Size(eventArgs.Width, eventArgs.Height); // application.RootElementRect = new Rect(new Size(eventArgs.Width, eventArgs.Height)); // }; //windowsHost.Width = 80; //windowsHost.Height = 20; application.Run(windowsHost); //, new Size(80, 30), Rect.Empty); } }
static void Main(string[] args) { Logger.Disabled = false; ThreadPool.SetMaxThreads(3, 3); var cfg = ConverterConfigFactory.Get(); ConverterConfigFactory.Save(cfg); dbconrtoller = new ArcController(cfg.ArcFileName) { AllowMessageLogging = cfg.AllowMessageLogging, SavePeriod = cfg.SavePeriod, MaxDataLimit = cfg.MaxLimit, Hyst = cfg.Hyst }; //dbconrtoller.Start(); var cts = new CancellationTokenSource(); var wCts = new CancellationTokenSource(); var connnectionWfqydb = StreamSourceFactory.GetStreamSourceConfig(cfg.WFQYDBConnection).Get(); var wFQYDBServer = new WFQYDBServer( connnectionWfqydb, new byte[] { 1, 0, 0, 0 }, wCts.Token) { UpdatePeriod = new TimeSpan(0, 0, cfg.PeriodSec), CanA0 = cfg?.AllowedCommands.Contains <byte>(0xA0) ?? false, CanA1 = cfg?.AllowedCommands.Contains <byte>(0xA1) ?? false, CanA2 = cfg?.AllowedCommands.Contains <byte>(0xA2) ?? false, CanA3 = cfg?.AllowedCommands.Contains <byte>(0xA3) ?? false, }; wFQYDBServer.PropertyChanged += WFQYDBServer_PropertyChanged; var modbusSvr = new ModbusSvr( cfg.ModbusSlaveTcpPort, cfg.ModbusSlaveRtuOverTcpPort, wFQYDBServer) { ArcController = dbconrtoller, //UpdatePeriod = new TimeSpan(cfg.PeriodSec * 10_000_000) }; modbusSvr.Start(); System.Threading.ThreadPool.GetMaxThreads(out int workerTh, out int completionTh); Logger.Info($"workerTh: {workerTh} completionTh: {completionTh}"); if (args.Contains("TUI")) { Logger.Disabled = true; MainViewModel mvm = new MainViewModel(); //mvm.ConnnectionWfqydb = connnectionWfqydb; mvm.WFQYDBServer = wFQYDBServer; mvm.ModbusSvr = modbusSvr; Window window = (Window)ConsoleApplication .LoadFromXaml("WfqydbModbusGateway.View.MainWin.xml", mvm); WindowsHost windowsHost = new WindowsHost { Name = "temp" }; windowsHost.Show(window); ConsoleApplication.Instance.Run(windowsHost); } else { int i = 0; while (!cts.Token.IsCancellationRequested) { Thread.Sleep(200); //if (wFQYDBServer.NeedToRestart) //{ // // restart services // Logger.Warn("Restarting services"); // wCts.Cancel(); // wCts = new CancellationTokenSource(); // wFQYDBServer.PropertyChanged -= WFQYDBServer_PropertyChanged; // wFQYDBServer = new WFQYDBServer(connnectionWfqydb, new byte[] { 1, 0, 0, 0 }, cts.Token); // modbusSvr.WfqydbServer = wFQYDBServer; // GC.Collect(); // wFQYDBServer.PropertyChanged += WFQYDBServer_PropertyChanged; //} } wCts.Cancel(); //Task.Delay(1000, cts.Token).Wait(); } cts.Dispose(); wCts.Dispose(); dbconrtoller.Stop(); }//Main
static void DomainInitializer(string[] args) { Console.WriteLine("Initializing the installer in the Install AppDomain"); host = new WindowsHost( Type.GetType(args[1],true), args[0].Split(';').ToArray(), args[2]); }
public static void Main(string[] args) { Window window = (Window)ConsoleApplication.LoadFromXaml("TuiExperCF.Views.Win2.xml", context); window.KeyUp += WindowsHost_KeyUp; WindowsHost wh = new WindowsHost { Name = "temp" }; wh.Show(window); ConsoleApplication.Instance.Run(wh); return; using (ConsoleApplication application = ConsoleApplication.Instance) { Panel panel = new Panel(); panel.Name = "panel1"; panel.HorizontalAlignment = HorizontalAlignment.Center; panel.VerticalAlignment = VerticalAlignment.Stretch; panel.XChildren.Add(new TextBlock() { Name = "label1", Text = "Label1", Margin = new Thickness(1, 2, 1, 0) //,Visibility = Visibility.Collapsed }); panel.XChildren.Add(new TextBlock() { Name = "label2", Text = "Label2_____", HorizontalAlignment = HorizontalAlignment.Right }); TextBox textBox = new TextBox() { MaxWidth = 10, Margin = new Thickness(1), HorizontalAlignment = HorizontalAlignment.Center, Size = 15, Text = "{Binding Path=MyProperty}", }; Button button = new Button() { Name = "button1", Caption = "Button!", Margin = new Thickness(1), HorizontalAlignment = HorizontalAlignment.Center }; button.OnClick += (sender, eventArgs) => { Debug.WriteLine("Click"); MessageBox.Show("Окно сообщения", "Внимание ! Тестовое сообщение", delegate(MessageBoxResult result) { }); Control label = panel.FindDirectChildByName("label1"); if (label.Visibility == Visibility.Visible) { label.Visibility = Visibility.Collapsed; } else if (label.Visibility == Visibility.Collapsed) { label.Visibility = Visibility.Hidden; } else { label.Visibility = Visibility.Visible; } label.Invalidate(); }; ComboBox comboBox = new ComboBox() { // Width = 14 //HorizontalAlignment = HorizontalAlignment.Stretch }; comboBox.Items.Add("Сделать одно"); comboBox.Items.Add("Сделать второе"); comboBox.Items.Add("Ничего не делать"); ListBox listbox = new ListBox(); listbox.Items.Add("First item"); listbox.Items.Add("second item1!!!!!!1fff"); listbox.HorizontalAlignment = HorizontalAlignment.Stretch; //listbox.Width = 10; panel.XChildren.Add(comboBox); panel.XChildren.Add(button); panel.XChildren.Add(textBox); panel.XChildren.Add(listbox); //application.Run(panel); WindowsHost windowsHost = new WindowsHost() { Name = "WindowsHost" }; Window window1 = new Window { X = 5, Y = 4, //MinHeight = 100, //MaxWidth = 30, //Width = 10, Height = 20, Name = "Window1", Title = "Window1", Content = panel }; GroupBox groupBox = new GroupBox(); groupBox.Title = "Группа"; ScrollViewer scrollViewer = new ScrollViewer(); ListBox listBox = new ListBox(); for (int i = 0; i < 30; i++) { listBox.Items.Add(string.Format("Длинный элемент {0}", i)); } // listBox.Items.Add( "Длинный элемент" ); // listBox.Items.Add("Длинный элемент 2"); // listBox.Items.Add("Длинный элемент 3"); // listBox.Items.Add("Длинный элемент 4"); // listBox.Items.Add("Длинный элемент 5"); // listBox.Items.Add("Длинный элемент 6"); // listBox.Items.Add("Длинный элемент 700"); listBox.HorizontalAlignment = HorizontalAlignment.Stretch; listBox.VerticalAlignment = VerticalAlignment.Stretch; scrollViewer.Content = listBox; // scrollViewer.HorizontalAlignment = HorizontalAlignment.Stretch; scrollViewer.VerticalAlignment = VerticalAlignment.Stretch; scrollViewer.HorizontalScrollEnabled = true; groupBox.Content = scrollViewer; ComboBox combo = new ComboBox(); combo.ShownItemsCount = 10; for (int i = 0; i < 30; i++) { combo.Items.Add(string.Format("Длинный элемент {0}", i)); } // groupBox.Content = combo; groupBox.HorizontalAlignment = HorizontalAlignment.Stretch; windowsHost.Show(new Window() { X = 30, Y = 6, //MinHeight = 10, //MinWidth = 10, Height = 14, Name = "LongTitleWindow", Title = "Очень длинное название окна", Content = groupBox, DataContext = context, }); windowsHost.Show(window1); //windowsHost.Show(createdFromXaml); //textBox.SetFocus(); todo : научиться задавать фокусный элемент до добавления в визуальное дерево //application.TerminalSizeChanged += ( sender, eventArgs ) => { // application.CanvasSize = new Size(eventArgs.Width, eventArgs.Height); // application.RootElementRect = new Rect(new Size(eventArgs.Width, eventArgs.Height)); // }; //windowsHost.Width = 80; //windowsHost.Height = 20; application.Run(windowsHost);//, new Size(80, 30), Rect.Empty); windowsHost.KeyUp += WindowsHost_KeyUp; } }
static void DomainInitializer(string[] args) { Console.WriteLine("Initializing the installer in the Install AppDomain"); host = new WindowsHost(Type.GetType(args[1], true), args[0].Split(';').ToArray(), args[2]); }