/// <summary>
        /// Called when some of the window action buttons has been clicked.
        /// </summary>
        /// <param name="args"></param>
        private void OnWindowActionButtonClicked(NEventArgs args)
        {
            if (m_TreeView.SelectedItem == null)
            {
                return;
            }

            NTopLevelWindow window = (m_TreeView.SelectedItem.Tag as NTopLevelWindow);

            if (window == null)
            {
                return;
            }

            NButton button = (NButton)args.TargetNode;
            NLabel  label  = (NLabel)button.Content;

            switch (label.Text)
            {
            case ActivateButtonText:
                window.Activate();
                break;

            case FocusButtonText:
                window.Focus();
                break;

            case CloseButtonText:
                window.Close();
                break;
            }
        }
Example #2
0
        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();
        }
Example #3
0
        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();
        }
        /// <summary>
        /// Event handler for window state events (Opened, Activated, Deactivated, Closing, Closed)
        /// </summary>
        /// <param name="args"></param>
        private void OnWindowStateEvent(NEventArgs args)
        {
            if (args.EventPhase != ENEventPhase.AtTarget)
            {
                return;
            }

            NTopLevelWindow window    = (NTopLevelWindow)args.CurrentTargetNode;
            string          eventName = args.Event.Name;

            m_EventsLog.LogEvent(window.Title + " " + eventName.Substring(eventName.LastIndexOf('.') + 1));

            if (args.Event == NTopLevelWindow.ActivatedEvent)
            {
                // Select the corresponding item from the tree view
                NTreeViewItem item = (NTreeViewItem)window.Tag;
                m_TreeView.SelectedItem = item;
            }
            else if (args.Event == NTopLevelWindow.ClosedEvent)
            {
                // Remove the corresponding item from the tree view
                NTreeViewItem           item  = (NTreeViewItem)window.Tag;
                NTreeViewItemCollection items = (NTreeViewItemCollection)item.ParentNode;
                items.Remove(item);
            }
        }
        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();
        }
Example #7
0
        private void OnWindowQueryManualStartPosition(NEventArgs args)
        {
            // Get the top level window which queries for position
            NTopLevelWindow window = (NTopLevelWindow)args.TargetNode;

            // Set the top level window bounds (in DIPs)
            window.Bounds = new NRectangle(window.X, window.Y, window.DefaultWidth, window.DefaultHeight);
        }
Example #8
0
        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();
        }
        /// <summary>
        ///
        /// </summary>
        /// <param name="args"></param>
        private void OnWindowUIEvent(NEventArgs args)
        {
            NTopLevelWindow window = (NTopLevelWindow)args.CurrentTargetNode;

            string eventName = args.Event.Name;

            eventName = eventName.Substring(eventName.LastIndexOf('.') + 1);

            m_EventsLog.LogEvent(window.Title + " " + eventName + " from target: " + args.TargetNode.GetType().Name);
        }
Example #10
0
        private void OnEnterFolderDialogClosed(NEventArgs arg)
        {
            NTopLevelWindow dialog = (NTopLevelWindow)arg.TargetNode;

            if (dialog.Result == ENWindowResult.OK)
            {
                NTextBox textBox = (NTextBox)dialog.Content.GetFirstDescendant(NTextBox.NTextBoxSchema);
                MergeAndSaveToFolder(textBox.Text);
            }
        }
Example #11
0
        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();
        }
Example #12
0
        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;
            }
        }
            /// <summary>
            /// Creates a custom appointment edit dialog.
            /// </summary>
            /// <returns></returns>
            public override NTopLevelWindow CreateEditDialog()
            {
                NSchedule schedule = (NSchedule)GetFirstAncestor(NSchedule.NScheduleSchema);
                NWindow   window   = schedule != null ? schedule.OwnerWindow : null;

                // Create a dialog window
                NTopLevelWindow dialog = NApplication.CreateTopLevelWindow(NWindow.GetFocusedWindowIfNull(window));

                dialog.SetupDialogWindow("Appointment with Image Editor", true);

                NStackPanel stack = new NStackPanel();

                stack.FillMode = ENStackFillMode.Last;
                stack.FitMode  = ENStackFitMode.Last;

                // Add an image box with the image
                NImageBox imageBox = new NImageBox((NImage)NSystem.SafeDeepClone(Image));

                stack.Add(imageBox);

                // Add property editors for some of the appointment properties
                NDesigner designer = NDesigner.GetDesigner(this);
                NList <NPropertyEditor> editors = designer.CreatePropertyEditors(this,
                                                                                 SubjectProperty,
                                                                                 StartProperty,
                                                                                 EndProperty);

                for (int i = 0; i < editors.Count; i++)
                {
                    stack.Add(editors[i]);
                }

                // Add a button strip with OK and Cancel buttons
                NButtonStrip buttonStrip = new NButtonStrip();

                buttonStrip.InitOKCancelButtonStrip();
                stack.Add(buttonStrip);

                dialog.Content = new NUniSizeBoxGroup(stack);

                return(dialog);
            }
        private void AddTreeViewItemForWindow(NTopLevelWindow window)
        {
            NTreeViewItem item = new NTreeViewItem(window.Title);

            item.Tag   = window;
            window.Tag = item;

            NTopLevelWindow ownerWindow = window.OwnerWindow as NTopLevelWindow;

            if (ownerWindow == null)
            {
                m_TreeView.Items.Add(item);
            }
            else
            {
                NTreeViewItem parentItem = (NTreeViewItem)ownerWindow.Tag;
                parentItem.Items.Add(item);
                parentItem.Expanded = true;
            }
        }
Example #16
0
        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();
        }
Example #18
0
        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);
            }
        }
Example #19
0
        protected override NWidget CreateExampleContent()
        {
            // Create and initialize a top level window
            m_Window       = new NTopLevelWindow();
            m_Window.Title = "Top Level Window";
            m_Window.RemoveFromParentOnClose   = true;
            m_Window.AllowXResize              = true;
            m_Window.AllowYResize              = true;
            m_Window.PreferredSize             = new NSize(300, 300);
            m_Window.QueryManualStartPosition += new Function <NEventArgs>(OnWindowQueryManualStartPosition);
            m_Window.Closed += new Function <NEventArgs>(OnWindowClosed);

            // Create the top level window's content
            NStackPanel stack = new NStackPanel();

            stack.FitMode  = ENStackFitMode.First;
            stack.FillMode = ENStackFillMode.First;

            NLabel label = new NLabel("This is a top level window.");

            label.HorizontalPlacement = ENHorizontalPlacement.Center;
            label.VerticalPlacement   = ENVerticalPlacement.Center;
            stack.Add(label);

            NButton closeButton = new NButton("Close");

            closeButton.HorizontalPlacement = ENHorizontalPlacement.Center;
            closeButton.Click += new Function <NEventArgs>(OnCloseButtonClick);
            stack.Add(closeButton);
            m_Window.Content = stack;

            // Create example content
            m_SettingsStack = new NStackPanel();
            m_SettingsStack.HorizontalPlacement = ENHorizontalPlacement.Left;

            NList <NPropertyEditor> editors = NDesigner.GetDesigner(m_Window).CreatePropertyEditors(m_Window,
                                                                                                    NTopLevelWindow.TitleProperty,
                                                                                                    NTopLevelWindow.StartPositionProperty,
                                                                                                    NTopLevelWindow.XProperty,
                                                                                                    NTopLevelWindow.YProperty,
                                                                                                    NStylePropertyEx.ExtendedLookPropertyEx,

                                                                                                    NTopLevelWindow.ModalProperty,
                                                                                                    NTopLevelWindow.ShowInTaskbarProperty,
                                                                                                    NTopLevelWindow.ShowTitleBarProperty,
                                                                                                    NTopLevelWindow.ShowControlBoxProperty,

                                                                                                    NTopLevelWindow.AllowMinimizeProperty,
                                                                                                    NTopLevelWindow.AllowMaximizeProperty,
                                                                                                    NTopLevelWindow.AllowXResizeProperty,
                                                                                                    NTopLevelWindow.AllowYResizeProperty
                                                                                                    );

            // Change the text of the extended look property editor
            label      = (NLabel)editors[4].GetFirstDescendant(new NInstanceOfSchemaFilter(NLabel.NLabelSchema));
            label.Text = "Extended Look:";

            // Add the created property editors to the stack
            for (int i = 0, count = editors.Count; i < count; i++)
            {
                m_SettingsStack.Add(editors[i]);
            }

            // Create a button that opens the window
            NButton openWindowButton = new NButton("Open Window...");

            openWindowButton.Content.HorizontalPlacement = ENHorizontalPlacement.Center;
            openWindowButton.Click += new Function <NEventArgs>(OnOpenWindowButtonClick);
            m_SettingsStack.Add(openWindowButton);

            return(new NUniSizeBoxGroup(m_SettingsStack));
        }