private void OnViewResponseHeadersButtonClick(NEventArgs args) { // get the response form the button tag (see UpdateRequestListBoxItem) and display its headers object[] array = (object[])args.TargetNode.Tag; NHttpRequest request = (NHttpRequest)array[0]; NHttpResponse response = (NHttpResponse)array[1]; // create a top level window, setup as a dialog NTopLevelWindow window = NApplication.CreateTopLevelWindow(); window.SetupDialogWindow(request.Uri.ToString(), true); // create a list box for the headers NListBox listBox = new NListBox(); window.Content = listBox; // fill with header fields INIterator <NHttpHeaderField> it = response.HeaderFields.GetIterator(); while (it.MoveNext()) { listBox.Items.Add(new NListBoxItem(it.Current.ToString())); } // open the window window.Open(); }
private void OnOpenXAutoSizeWindowButtonClick(NEventArgs arg) { NTopLevelWindow window = new NTopLevelWindow(); window.Modal = true; // allow the user to resize the Y window dimension window.AllowYResize = true; // bind the window Width to the desired width of the window NBindingFx bindingFx = new NBindingFx(window, NTopLevelWindow.DesiredWidthProperty); bindingFx.Guard = true; window.SetFx(NTopLevelWindow.WidthProperty, bindingFx); // create a wrap flow panel with Y direction NWrapFlowPanel wrapPanel = new NWrapFlowPanel(); wrapPanel.Direction = ENHVDirection.TopToBottom; window.Content = wrapPanel; for (int i = 0; i < 10; i++) { wrapPanel.Add(new NButton("Button" + i)); } // open the window OwnerWindow.Windows.Add(window); window.Open(); }
private void OnOpenYAutoSizeWindowButtonClick(NEventArgs arg) { NTopLevelWindow window = new NTopLevelWindow(); window.Modal = true; // allow the user to resize the X window dimension window.AllowXResize = true; // bind the window Height to the desired height of the window NBindingFx bindingFx = new NBindingFx(window, NTopLevelWindow.DesiredHeightProperty); bindingFx.Guard = true; window.SetFx(NTopLevelWindow.HeightProperty, bindingFx); // create a wrap flow panel (by default flows from left to right) NWrapFlowPanel wrapPanel = new NWrapFlowPanel(); window.Content = wrapPanel; for (int i = 0; i < 10; i++) { wrapPanel.Add(new NButton("Button" + i)); } // open the window OwnerWindow.Windows.Add(window); window.Open(); }
private void OnShowDialogButtonClick(NEventArgs arg1) { NStackPanel stack = new NStackPanel(); stack.Margins = new NMargins(10); stack.VerticalSpacing = 10; NButton openButton = new NButton("Open File..."); openButton.Content.HorizontalPlacement = ENHorizontalPlacement.Center; openButton.Click += new Function <NEventArgs>(OnOpenButtonClick); stack.Add(openButton); NButton saveButton = new NButton("Save to File..."); saveButton.Content.HorizontalPlacement = ENHorizontalPlacement.Center; saveButton.Click += new Function <NEventArgs>(OnSaveButtonClick); stack.Add(saveButton); NButtonStrip closeButtonStrip = new NButtonStrip(); closeButtonStrip.InitCloseButtonStrip(); stack.Add(closeButtonStrip); // create a dialog that is owned by this widget window NTopLevelWindow dialog = NApplication.CreateTopLevelWindow(); dialog.SetupDialogWindow("Show File Dialogs", false); dialog.Content = stack; dialog.Open(); }
private void OnAddAttributeButtonClick(NEventArgs arg) { NTopLevelWindow dialog = NApplication.CreateTopLevelWindow(); dialog.SetupDialogWindow("Enter attribute's name and value", false); NTableFlowPanel table = new NTableFlowPanel(); table.Direction = ENHVDirection.LeftToRight; table.ColFillMode = ENStackFillMode.Last; table.ColFitMode = ENStackFitMode.Last; table.MaxOrdinal = 2; NLabel nameLabel = new NLabel("Name:"); table.Add(nameLabel); NTextBox nameTextBox = new NTextBox(); table.Add(nameTextBox); NLabel valueLabel = new NLabel("Value:"); table.Add(valueLabel); NTextBox valueTextBox = new NTextBox(); table.Add(valueTextBox); table.Add(new NWidget()); NButtonStrip buttonStrip = new NButtonStrip(); buttonStrip.InitOKCancelButtonStrip(); table.Add(buttonStrip); dialog.Content = table; dialog.Opened += delegate(NEventArgs args) { nameTextBox.Focus(); }; dialog.Closed += delegate(NEventArgs args) { if (dialog.Result == ENWindowResult.OK) { NElementInfo elementInfo = (NElementInfo)m_TreeView.SelectedItem.Tag; elementInfo.Attributes.Set(nameTextBox.Text, valueTextBox.Text); UpdateTreeViewItemText(m_TreeView.SelectedItem); if (m_RemoveAttributeButton.Enabled == false) { m_RemoveAttributeButton.Enabled = true; } } }; dialog.Open(); }
private void OnRemoveAttributeButtonClick(NEventArgs arg) { NTopLevelWindow dialog = NApplication.CreateTopLevelWindow(); dialog.SetupDialogWindow("Select an Attribute to Remove", false); NListBox listBox = new NListBox(); NElementInfo elementInfo = (NElementInfo)m_TreeView.SelectedItem.Tag; INIterator <NKeyValuePair <string, string> > iter = elementInfo.Attributes.GetIterator(); while (iter.MoveNext()) { listBox.Items.Add(new NListBoxItem(iter.Current.Key)); } NButtonStrip buttonStrip = new NButtonStrip(); buttonStrip.InitOKCancelButtonStrip(); NPairBox pairBox = new NPairBox(listBox, buttonStrip, ENPairBoxRelation.Box1AboveBox2); pairBox.Spacing = NDesign.VerticalSpacing; dialog.Content = pairBox; dialog.Opened += delegate(NEventArgs args) { listBox.Focus(); }; dialog.Closed += delegate(NEventArgs args) { if (dialog.Result == ENWindowResult.OK) { // Remove the selected attribute NListBoxItem selectedItem = listBox.Selection.FirstSelected; if (selectedItem != null) { string name = ((NLabel)selectedItem.Content).Text; elementInfo.Attributes.Remove(name); UpdateTreeViewItemText(m_TreeView.SelectedItem); if (elementInfo.Attributes.Count == 0) { m_RemoveAttributeButton.Enabled = false; } } } }; dialog.Open(); }
private void OnMergeAndSaveToFolderButtonClick(NEventArgs arg) { NTextBox textBox = new NTextBox(); NButtonStrip buttonStrip = new NButtonStrip(); buttonStrip.InitOKCancelButtonStrip(); NPairBox pairBox = new NPairBox(textBox, buttonStrip, ENPairBoxRelation.Box1AboveBox2); NTopLevelWindow dialog = NApplication.CreateTopLevelWindow(); dialog.SetupDialogWindow("Enter Folder Path", false); dialog.Content = pairBox; dialog.Closed += OnEnterFolderDialogClosed; dialog.Open(); }
/// <summary> /// Creates and opens a child window of the specified owner window. /// </summary> /// <param name="ownerWindow"></param> private void OpenChildWindow(NWindow ownerWindow) { // Create the window NTopLevelWindow window = NApplication.CreateTopLevelWindow(ownerWindow); window.Title = "Window " + m_ChildWindowIndex++; window.PreferredSize = WindowSize; // subscribe for window state events window.Opened += new Function <NEventArgs>(OnWindowStateEvent); window.Activated += new Function <NEventArgs>(OnWindowStateEvent); window.Deactivated += new Function <NEventArgs>(OnWindowStateEvent); window.Closing += new Function <NEventArgs>(OnWindowStateEvent); window.Closed += new Function <NEventArgs>(OnWindowStateEvent); // subscribe for window UI events window.GotFocus += new Function <NFocusChangeEventArgs>(OnWindowUIEvent); window.LostFocus += new Function <NFocusChangeEventArgs>(OnWindowUIEvent); // Create its content NStackPanel stack = new NStackPanel(); stack.FillMode = ENStackFillMode.First; stack.FitMode = ENStackFitMode.First; string ownerName = ownerWindow is NTopLevelWindow ? ((NTopLevelWindow)ownerWindow).Title : "Examples Window"; NLabel label = new NLabel("Child Of \"" + ownerName + "\""); label.HorizontalPlacement = ENHorizontalPlacement.Center; label.VerticalPlacement = ENVerticalPlacement.Center; stack.Add(label); stack.Add(CreateOpenChildWindowButton()); window.Content = stack; // Open the window AddTreeViewItemForWindow(window); window.Open(); if (ownerWindow is NTopLevelWindow) { window.X = ownerWindow.X + 25; window.Y = ownerWindow.Y + 25; } }
private void OnAddChildItemButtonClick(NEventArgs arg) { NTopLevelWindow dialog = NApplication.CreateTopLevelWindow(NWindow.GetFocusedWindowIfNull(OwnerWindow)); dialog.SetupDialogWindow("Enter element's name", false); NTextBox textBox = new NTextBox(); NButtonStrip buttonStrip = new NButtonStrip(); buttonStrip.InitOKCancelButtonStrip(); NPairBox pairBox = new NPairBox(textBox, buttonStrip, ENPairBoxRelation.Box1AboveBox2); pairBox.Spacing = NDesign.VerticalSpacing; dialog.Content = pairBox; dialog.Opened += delegate(NEventArgs args) { textBox.Focus(); }; dialog.Closed += delegate(NEventArgs args) { if (dialog.Result == ENWindowResult.OK) { // Add an item with the specified name m_TreeView.SelectedItem.Items.Add(CreateTreeViewItem(textBox.Text)); m_TreeView.SelectedItem.Expanded = true; if (m_SerializeButton.Enabled == false) { m_SerializeButton.Enabled = true; } } }; dialog.Open(); }
private void OnOpenAutoSizeWindowButtonClick(NEventArgs arg) { NTopLevelWindow window = new NTopLevelWindow(); window.Modal = true; // open the window in the center of its parent, window.StartPosition = ENWindowStartPosition.CenterOwner; // implement auto width and height sizing { // bind the window Width to the DefaultWidth of the window NBindingFx widthBindingFx = new NBindingFx(window, NTopLevelWindow.DefaultWidthProperty); widthBindingFx.Guard = true; window.SetFx(NTopLevelWindow.WidthProperty, widthBindingFx); // bind the window Height to the DefaultHeight of the window NBindingFx heightBindingFx = new NBindingFx(window, NTopLevelWindow.DesiredHeightProperty); heightBindingFx.Guard = true; window.SetFx(NTopLevelWindow.HeightProperty, heightBindingFx); } // implement auto center { // scratch X and Y define the window center // they are implemented by simply calculating the center X and Y via formulas window.SetFx(NScratchPropertyEx.XPropertyEx, "X+Width/2"); window.SetFx(NScratchPropertyEx.YPropertyEx, "Y+Height/2"); // now that we have an automatic center, we need to write expressions that define the X and Y from that center. // These are cyclic expressions - CenterX depends on X, and X depends on CenterX. // The expressions that are assigned to X and Y are guarded and permeable. // guard is needed because X and Y are updated when the user moves the window around. // permeable is needed to allow the X and Y values to change when the user moves the window around. // When the the X and Y values change -> center changes -> X and Y expressions are triggered but they produce the same X and Y results and the cycle ends. // When the Width and Height change -> center changes -> X and Y expression are triggered but they produce the same X and Y results and the cycle ends. NFormulaFx xfx = new NFormulaFx(NScratchPropertyEx.XPropertyEx.Name + "-Width/2"); xfx.Guard = true; xfx.Permeable = true; window.SetFx(NTopLevelWindow.XProperty, xfx); NFormulaFx yfx = new NFormulaFx(NScratchPropertyEx.YPropertyEx.Name + "-Height/2"); yfx.Guard = true; yfx.Permeable = true; window.SetFx(NTopLevelWindow.YProperty, yfx); } // create a dummy tab that sizes to the currently selected page, // and add two pages with different sizes to the tab. NTab tab = new NTab(); window.Content = tab; tab.SizeToSelectedPage = true; NTabPage page1 = new NTabPage("Small Content"); NButton btn = new NButton("I am small"); page1.Content = btn; tab.TabPages.Add(page1); NTabPage page2 = new NTabPage("Large Content"); NButton btn2 = new NButton("I am LARGE"); btn2.PreferredSize = new NSize(200, 200); page2.Content = btn2; tab.TabPages.Add(page2); // open the window OwnerWindow.Windows.Add(window); window.Open(); }
static void Main() { try { Application.EnableVisualStyles(); Application.SetCompatibleTextRenderingDefault(false); // install Nevron Open Vision for Windows Forms NNovApplicationInstaller.Install( NTextModule.Instance, NChartModule.Instance, NDiagramModule.Instance, NScheduleModule.Instance, NGridModule.Instance, NBarcodeModule.Instance); // show the main form bool startWithNovWindow = false; if (startWithNovWindow) { // create a NOV top level window NTopLevelWindow window = NApplication.CreateTopLevelWindow(); window.BackgroundFill = new NColorFill(NColor.White); window.Content = new NExamplesContent(); window.Closed += OnWindowClosed; window.Title = "Nevron Open Vision Examples for Windows Forms"; window.AllowXResize = true; window.AllowYResize = true; window.ShowInTaskbar = true; window.Modal = true; window.PreferredSize = new NSize(500, 500); window.StartPosition = ENWindowStartPosition.CenterScreen; window.Open(); // run the application ApplicationContext context = new ApplicationContext(); Application.Run(context); } else { // create a WinForms form Form form = new Form(); // set form icon using (Stream stream = typeof(Program).Assembly.GetManifestResourceStream("Nevron.Nov.Examples.WinForm.Resources.NevronOpenVision.ico")) { Icon icon = new Icon(stream); form.Icon = icon; } // set form title and state form.Text = "Nevron Open Vision Examples for Windows Forms"; form.WindowState = FormWindowState.Maximized; // place a NOV WinForms Control that contains an NExampleContent widget NNovWidgetHost <NExamplesContent> host = new NNovWidgetHost <NExamplesContent>(); host.Dock = DockStyle.Fill; form.Controls.Add(host); // run the form Application.Run(form); } } catch (Exception ex) { NTrace.WriteException("Exception in Main", ex); } }