protected override IEnumerable <MenuItemAction> GetMenuItems() { return(new List <MenuItemAction> { new MenuItemAction("Add Printer".Localize(), () => ConnectionWizard.Show()), new MenuItemAction("Add File To Queue".Localize(), importFile_Click), new MenuItemAction("Redeem Design Code".Localize(), () => RedeemDesignCode?.Invoke(this, null)), new MenuItemAction("Enter Share Code".Localize(), () => EnterShareCode?.Invoke(this, null)), new MenuItemAction("------------------------", null), new MenuItemAction("Exit".Localize(), () => { MatterControlApplication app = this.Parents <MatterControlApplication>().FirstOrDefault(); app.RestartOnClose = false; app.Close(); }) }); }
public static void OpenConnectionWindow(bool connectAfterSelection = false) { if (connectAfterSelection) { ActiveSliceSettings.ActivePrinterChanged.RegisterEvent(ConnectToActivePrinter, ref staticUnregisterEvents); } if (connectionWindow == null) { connectionWindow = new ConnectionWizard(); connectionWindow.Closed += new EventHandler(ConnectionWindow_Closed); } else { if (connectionWindow != null) { connectionWindow.BringToFront(); } } }
internal void ConnectToServer() { var names = new List <string>(); GetAllServers(names, treeView1.Nodes); var dialog = new ConnectionWizard(_serviceContainer, names.ToArray()); if (dialog.ShowDialog(this) != DialogResult.OK) { return; } var data = (ConnectionWizardData)dialog.WizardData; ServerTreeNode node; if (data.Mode == WorkingMode.Jexus) { node = ServerTreeNode.CreateJexusNode( _serviceContainer, data.Name, data.HostName, data.UserName + "|" + data.Password, data.CertificateHash, data.Server, isLocalhost: true); var path = Path.GetTempFileName(); var random = Guid.NewGuid().ToString(); File.WriteAllText(path, random); node.IsLocalhost = AsyncHelper.RunSync(() => ((JexusServerManager)node.ServerManager).LocalhostTestAsync(path, random)); data.Server.IsLocalhost = node.IsLocalhost; } else { node = ServerTreeNode.CreateIisExpressNode( _serviceContainer, data.Name, data.FileName, data.Server, ignoreInCache: false); } try { RegisterServer(node); // TODO: trigger the load in connection wizard to throw exception earlier. node.LoadServer(cmsApplicationPools, cmsSites, cmsSite); actSave.Enabled = true; } catch (Exception ex) { RollbarLocator.RollbarInstance.Error(ex); File.WriteAllText(DialogHelper.DebugLog, ex.ToString()); var last = ex; while (last is AggregateException) { last = last.InnerException; } var message = new StringBuilder(); message.AppendLine("Could not connect to the specified computer.") .AppendLine() .AppendFormat("Details: {0}", last?.Message); MessageBox.Show(message.ToString(), Text, MessageBoxButtons.OK, MessageBoxIcon.Error); } }
private async void actConnectServer_Execute(object sender, EventArgs e) { var names = new List <string>(); names.Add("Start Page"); foreach (var item in treeView1.Nodes) { var serverNode = item as ServerTreeNode; if (serverNode != null) { names.Add(serverNode.DisplayName); } } var dialog = new ConnectionWizard(_serviceContainer, names.ToArray()); if (dialog.ShowDialog() != DialogResult.OK) { return; } var data = (ConnectionWizardData)dialog.WizardData; ServerTreeNode node; if (data.Mode == WorkingMode.Jexus) { node = new ServerTreeNode( _serviceContainer, data.Name, data.HostName, data.UserName + "|" + data.Password, data.CertificateHash, data.Server, true, WorkingMode.Jexus, false); node.SetHandler(); var path = Path.GetTempFileName(); var random = Guid.NewGuid().ToString(); File.WriteAllText(path, random); node.IsLocalhost = await((JexusServerManager)node.ServerManager).LocalhostTestAsync(path, random); data.Server.IsLocalhost = node.IsLocalhost; } else { node = new ServerTreeNode( _serviceContainer, data.Name, data.FileName, string.Empty, null, data.Server, true, WorkingMode.IisExpress, false); } RegisterServer(node); await node.LoadServerAsync(cmsApplicationPools, cmsSites, cmsSite); actSave.Enabled = true; }
protected override void AddChildElements() { actionBarButtonFactory.invertImageLocation = false; actionBarButtonFactory.borderWidth = 1; if (ActiveTheme.Instance.IsDarkTheme) { actionBarButtonFactory.normalBorderColor = new RGBA_Bytes(77, 77, 77); } else { actionBarButtonFactory.normalBorderColor = new RGBA_Bytes(190, 190, 190); } actionBarButtonFactory.hoverBorderColor = new RGBA_Bytes(128, 128, 128); string connectString = "Connect".Localize().ToUpper(); connectPrinterButton = actionBarButtonFactory.Generate(connectString, "icon_power_32x32.png"); connectPrinterButton.ToolTipText = "Connect to the currently selected printer".Localize(); if (ApplicationController.Instance.WidescreenMode) { connectPrinterButton.Margin = new BorderDouble(0, 0, 3, 3); } else { connectPrinterButton.Margin = new BorderDouble(6, 0, 3, 3); } connectPrinterButton.VAnchor = VAnchor.ParentTop; connectPrinterButton.Cursor = Cursors.Hand; string disconnectString = "Disconnect".Localize().ToUpper(); disconnectPrinterButton = actionBarButtonFactory.Generate(disconnectString, "icon_power_32x32.png"); disconnectPrinterButton.ToolTipText = "Disconnect from current printer".Localize(); if (ApplicationController.Instance.WidescreenMode) { disconnectPrinterButton.Margin = new BorderDouble(0, 0, 3, 3); } else { disconnectPrinterButton.Margin = new BorderDouble(6, 0, 3, 3); } disconnectPrinterButton.VAnchor = VAnchor.ParentTop; disconnectPrinterButton.Cursor = Cursors.Hand; selectActivePrinterButton = new PrinterSelector(); selectActivePrinterButton.HAnchor = HAnchor.ParentLeftRight; selectActivePrinterButton.Cursor = Cursors.Hand; selectActivePrinterButton.AddPrinter += (s, e) => ConnectionWizard.Show(); if (ApplicationController.Instance.WidescreenMode) { selectActivePrinterButton.Margin = new BorderDouble(0, 6, 0, 3); } else { selectActivePrinterButton.Margin = new BorderDouble(0, 6, 6, 3); } string resetConnectionText = "Reset\nConnection".Localize().ToUpper(); resetConnectionButton = actionBarButtonFactory.Generate(resetConnectionText, "e_stop4.png"); if (ApplicationController.Instance.WidescreenMode) { resetConnectionButton.Margin = new BorderDouble(0, 0, 3, 3); } else { resetConnectionButton.Margin = new BorderDouble(6, 0, 3, 3); } // Bind connect button states to active printer state this.SetConnectionButtonVisibleState(); actionBarButtonFactory.invertImageLocation = true; this.AddChild(connectPrinterButton); this.AddChild(disconnectPrinterButton); FlowLayoutWidget printerSelectorAndEditButton = new FlowLayoutWidget() { HAnchor = HAnchor.ParentLeftRight, }; printerSelectorAndEditButton.AddChild(selectActivePrinterButton); Button editButton = TextImageButtonFactory.GetThemedEditButton(); editButton.VAnchor = VAnchor.ParentCenter; editButton.Click += EditButton_Click; printerSelectorAndEditButton.AddChild(editButton); this.AddChild(printerSelectorAndEditButton); this.AddChild(resetConnectionButton); //this.AddChild(CreateOptionsMenu()); }
static private void ConnectionWindow_Closed(object sender, EventArgs e) { connectionWindow = null; }
private void actConnectServer_Execute(object sender, EventArgs e) { var names = new List <string>(); names.Add("Start Page"); foreach (var item in treeView1.Nodes) { var serverNode = item as ServerTreeNode; if (serverNode != null) { names.Add(serverNode.DisplayName); } } var dialog = new ConnectionWizard(_serviceContainer, names.ToArray()); if (dialog.ShowDialog(this) != DialogResult.OK) { return; } var data = (ConnectionWizardData)dialog.WizardData; ServerTreeNode node; if (data.Mode == WorkingMode.Jexus) { node = new ServerTreeNode( _serviceContainer, data.Name, data.HostName, data.UserName + "|" + data.Password, data.CertificateHash, data.Server, true, WorkingMode.Jexus, false); node.SetHandler(); var path = Path.GetTempFileName(); var random = Guid.NewGuid().ToString(); File.WriteAllText(path, random); node.IsLocalhost = AsyncHelper.RunSync(() => ((JexusServerManager)node.ServerManager).LocalhostTestAsync(path, random)); data.Server.IsLocalhost = node.IsLocalhost; } else { node = new ServerTreeNode( _serviceContainer, data.Name, data.FileName, string.Empty, null, data.Server, true, WorkingMode.IisExpress, false); } try { RegisterServer(node); // TODO: trigger the load in connection wizard to throw exception earlier. node.LoadServer(cmsApplicationPools, cmsSites, cmsSite); actSave.Enabled = true; } catch (Exception ex) { File.WriteAllText(DialogHelper.DebugLog, ex.ToString()); var last = ex; while (last is AggregateException) { last = last.InnerException; } var message = new StringBuilder(); message.AppendLine("Could not connect to the specified computer.") .AppendLine() .AppendFormat("Details: {0}", last?.Message); MessageBox.Show(message.ToString(), Text, MessageBoxButtons.OK, MessageBoxIcon.Error); } }