private static bool TryGetFactor(NXmlElement element, string attribute, out double result) { string str = NStringHelpers.SafeTrim(element.GetAttributeValue(attribute)); if (str == null || str.Length == 0) { result = 0; return(false); } bool isPercent = str[str.Length - 1] == '%'; if (isPercent) { str = str.Substring(0, str.Length - 1); } if (Double.TryParse(str, NumberStyles.Any, CultureInfo.InvariantCulture, out result) == false) { return(false); } if (isPercent) { result = result / 100; } return(true); }
private NGroupBox CreatePredefinedDocumentGroupBox() { const string DocxSuffix = "_docx"; NListBox testListBox = new NListBox(); string[] resourceName = NResources.Instance.GetResourceNames(); for (int i = 0, count = resourceName.Length; i < count; i++) { string resName = resourceName[i]; if (resName.EndsWith(DocxSuffix, StringComparison.Ordinal)) { // The current resource is a DOCX document, so add it to the list box string testName = resName.Substring(0, resName.Length - DocxSuffix.Length); testName = testName.Substring(testName.LastIndexOf('_') + 1); NListBoxItem item = new NListBoxItem(NStringHelpers.InsertSpacesBeforeUppersAndDigits(testName)); item.Tag = resName; testListBox.Items.Add(item); } } testListBox.Selection.Selected += OnListBoxItemSelected; testListBox.Selection.SingleSelect(testListBox.Items[1]); return(new NGroupBox("Predefined DOCX documents", testListBox)); }
private void OnGoButtonClick(NEventArgs arg1) { string address = NStringHelpers.SafeTrim(m_NavigationTextBox.Text); if (address == null || address.Length == 0) { return; } if (NFile.Exists(address)) { // Load from file using (Stream stream = NFile.OpenRead(address)) { LoadSource(stream); LoadHtml(stream, address); } return; } // Load from URI try { address = NormalizeUri(address); m_Stopwatch = NStopwatch.StartNew(); m_PreviewRichText.LoadFromUri(new NUri(address, ENUriKind.RelativeOrAbsolute)); } catch (Exception ex) { m_Stopwatch.Stop(); NMessageBox.Show(ex.Message, "Error", ENMessageBoxButtons.OK, ENMessageBoxIcon.Error); } }
protected override NWidget CreateExampleControls() { NStackPanel stack = new NStackPanel(); stack.FillMode = ENStackFillMode.Last; stack.FitMode = ENStackFitMode.Last; // Create the tool bar button type radio group NStackPanel buttonTypeStack = new NStackPanel(); ENToolBarButtonType[] buttonTypes = NEnum.GetValues <ENToolBarButtonType>(); for (int i = 0, count = buttonTypes.Length; i < count; i++) { // Get the current button type and its string representation ENToolBarButtonType buttonType = buttonTypes[i]; string text = NStringHelpers.InsertSpacesBeforeUppersAndDigits(buttonType.ToString()); // Create a radio button for the current button type NRadioButton radioButton = new NRadioButton(text); buttonTypeStack.Add(radioButton); } NRadioButtonGroup buttonTypeGroup = new NRadioButtonGroup(buttonTypeStack); buttonTypeGroup.SelectedIndexChanged += OnButtonTypeGroupSelectedIndexChanged; buttonTypeGroup.SelectedIndex = 2; stack.Add(new NGroupBox("Button Type", buttonTypeGroup)); // Create the events log m_EventsLog = new NExampleEventsLog(); stack.Add(m_EventsLog); return(stack); }
protected override NWidget CreateExampleContent() { Array predefinedCursors = NEnum.GetValues(typeof(ENPredefinedCursor)); NStackPanel stack = new NStackPanel(); NGroupBox predefinedGroupBox = new NGroupBox("Predefined"); stack.Add(predefinedGroupBox); NSplitter splitter = new NSplitter(); splitter.SplitMode = ENSplitterSplitMode.Proportional; splitter.SplitFactor = 0.5d; predefinedGroupBox.Content = splitter; for (int i = 0; i < 2; i++) { NStackPanel pstack = new NStackPanel(); pstack.VerticalSpacing = 1; switch (i) { case 0: splitter.Pane1.Content = new NGroupBox("Use Native If Possible", pstack); break; case 1: splitter.Pane2.Content = new NGroupBox("Use Built-In", pstack); break; default: throw new Exception("More cases?"); } for (int j = 0; j < predefinedCursors.Length; j++) { ENPredefinedCursor predefinedCursor = (ENPredefinedCursor)predefinedCursors.GetValue(j); NWidget element = CreateDemoElement(NStringHelpers.InsertSpacesBeforeUppersAndDigits(predefinedCursor.ToString())); element.Cursor = new NCursor(predefinedCursor, i == 0); pstack.Add(element); } } NWidget customElement = CreateDemoElement("Custom"); customElement.Cursor = NResources.Cursor_CustomCursor_cur; NGroupBox customGroupBox = new NGroupBox("Custom", customElement); stack.Add(customGroupBox); return(stack); }
private NSymbolBox AddSymbolBox(ENSymbolShape symbolShape, NSize size, NColor color) { NSymbol symbol = NSymbol.Create(symbolShape, size, color); NSymbolBox symbolBox = new NSymbolBox(symbol); m_SymbolsTable.Add(symbolBox); NLabel label = new NLabel(NStringHelpers.InsertSpacesBeforeUppersAndDigits(symbolShape.ToString())); label.VerticalPlacement = ENVerticalPlacement.Center; m_SymbolsTable.Add(label); return(symbolBox); }
protected override NWidget CreateExampleContent() { // store current date time m_Now = DateTime.Now; // create a view and get its grid NTableGridView view = new NTableGridView(); NTableGrid grid = view.Grid; // bind the grid to the data source grid.DataSource = CreateMailDataSource(); // create a grouping rule with a custom row value. // NOTE: The RowValue associated with each grouping rule, returns an object for each row of the data source. // the rows in the data source are grouped according to that object. // The NCustomRowValue provides a delegate that help you return a custom object object for each data source row. // In our example the NCustomRowValue returns a member of the ENMailGroup enumeraiton for each record, depending on its Received row value. NCustomRowValue <ENMailGroup> customRowValue = new NCustomRowValue <ENMailGroup>(); customRowValue.Description = "Received"; customRowValue.GetRowValueDelegate = GetRowValueDelegate; // NOTE: The NGroupingRule provides the following events: // CreateGroupRowCells - raised when the grid needs to create the cells of the group row. // CreateGroupingHeaderContent - raised when the grid needs to create a grouping header content for the grouping in the groupings panel. NGroupingRule groupingRule = new NGroupingRule(); groupingRule.RowValue = customRowValue; groupingRule.CreateGroupRowCellsDelegate = delegate(NGroupingRuleCreateGroupRowCellsArgs arg) { int groupValue = Convert.ToInt32(arg.GroupRow.GroupValue); string text = NStringHelpers.InsertSpacesBeforeUppersAndDigits(((ENMailGroup)groupValue).ToString()); return(new NGroupRowCell[] { new NGroupRowCell(text) }); }; groupingRule.CreateGroupingHeaderContentDelegate = delegate(NGroupingRule theGroupingRule) { return(new NLabel("Received")); }; grid.GroupingRules.Add(groupingRule); return(view); }
private void OnThemeTreeViewSelectedPathChanged(NValueChangeEventArgs arg1) { NTreeView treeView = (NTreeView)arg1.CurrentTargetNode; NTreeViewItem selectedItem = treeView.SelectedItem; if (selectedItem == null) { return; } if (selectedItem.Tag is NTheme) { // Apply the selected theme to the document box's document NTheme theme = (NTheme)selectedItem.Tag; m_DocumentBox.Document.InheritStyleSheets = false; m_DocumentBox.Document.StyleSheets.ApplyTheme(theme); } else if (NStringHelpers.Equals(selectedItem.Tag, "inherit")) { // Make the document inherit its style sheets and clear all current ones m_DocumentBox.Document.InheritStyleSheets = true; m_DocumentBox.Document.StyleSheets.Clear(); } }
private NGroupBox CreatePredefinedPageGroupBox() { const string HtmlSuitePrefix = "RSTR_HtmlSuite_"; NListBox testListBox = new NListBox(); string[] resourceName = NResources.Instance.GetResourceNames(); for (int i = 0, count = resourceName.Length; i < count; i++) { string resName = resourceName[i]; if (resName.StartsWith(HtmlSuitePrefix, StringComparison.Ordinal)) { // The current resource is an HTML page, so add it to the list box string testName = resName.Substring(HtmlSuitePrefix.Length, resName.Length - HtmlSuitePrefix.Length - 5); NListBoxItem item = new NListBoxItem(NStringHelpers.InsertSpacesBeforeUppersAndDigits(testName)); item.Tag = resName; testListBox.Items.Add(item); } } testListBox.Selection.Selected += OnListBoxItemSelected; testListBox.Selection.SingleSelect(testListBox.Items[0]); return(new NGroupBox("Predefined HTML pages", testListBox)); }
/// <summary> /// /// </summary> /// <returns></returns> protected override NWidget CreateExampleControls() { NStackPanel stack = new NStackPanel(); NUniSizeBoxGroup boxGroup = new NUniSizeBoxGroup(stack); stack.Add(new NLabel("Allowed Date Time Units")); NDateTimeUnit[] dateTimeUnits = new NDateTimeUnit[] { NDateTimeUnit.Century, NDateTimeUnit.Decade, NDateTimeUnit.Year, NDateTimeUnit.HalfYear, NDateTimeUnit.Quarter, NDateTimeUnit.Month, NDateTimeUnit.Week, NDateTimeUnit.Day, NDateTimeUnit.HalfDay, NDateTimeUnit.Hour, NDateTimeUnit.Minute, NDateTimeUnit.Second, NDateTimeUnit.Millisecond, NDateTimeUnit.Tick }; m_DateTimeUnitListBox = new NListBox(); for (int i = 0; i < dateTimeUnits.Length; i++) { NDateTimeUnit dateTimeUnit = dateTimeUnits[i]; NCheckBox dateTimeUnitCheckBox = new NCheckBox(NStringHelpers.InsertSpacesBeforeUppersAndDigits(dateTimeUnit.DateTimeUnit.ToString())); dateTimeUnitCheckBox.Checked = true; dateTimeUnitCheckBox.CheckedChanged += new Function <NValueChangeEventArgs>(OnDateTimeUnitCheckBoxCheckedChanged); dateTimeUnitCheckBox.Tag = dateTimeUnit; m_DateTimeUnitListBox.Items.Add(new NListBoxItem(dateTimeUnitCheckBox)); } stack.Add(m_DateTimeUnitListBox); OnDateTimeUnitCheckBoxCheckedChanged(null); NCheckBox enableUnitSensitiveFormattingCheckBox = new NCheckBox("Enable Unit Sensitive Formatting"); enableUnitSensitiveFormattingCheckBox.CheckedChanged += new Function <NValueChangeEventArgs>(OnEnableUnitSensitiveFormattingCheckBoxCheckedChanged); stack.Add(enableUnitSensitiveFormattingCheckBox); enableUnitSensitiveFormattingCheckBox.Checked = true; stack.Add(new NLabel("Start Date:")); m_StartDateTimeBox = new NDateTimeBox(); m_StartDateTimeBox.SelectedDateChanged += new Function <NValueChangeEventArgs>(OnStartDateTimeBoxSelectedDateChanged); stack.Add(m_StartDateTimeBox); stack.Add(new NLabel("End Date:")); m_EndDateTimeBox = new NDateTimeBox(); m_EndDateTimeBox.SelectedDateChanged += new Function <NValueChangeEventArgs>(OnEndDateTimeBoxSelectedDateChanged); stack.Add(m_EndDateTimeBox); NButton generateRandomDataButton = new NButton("Generate Random Data"); generateRandomDataButton.Click += new Function <NEventArgs>(OnGenerateRandomDataButtonClick); stack.Add(generateRandomDataButton); m_StartDateTimeBox.SelectedDate = DateTime.Now; m_EndDateTimeBox.SelectedDate = CultureInfo.CurrentCulture.Calendar.AddYears(m_StartDateTimeBox.SelectedDate, 2); return(boxGroup); }
protected override NWidget CreateExampleControls() { // Create the theme tree view NTheme theme; NTreeViewItem rootItem, themeItem; NTreeView themeTreeView = new NTreeView(); // Add the "Inherit Styles" root tree view item rootItem = new NTreeViewItem("Inherit Styles"); rootItem.Tag = "inherit"; themeTreeView.Items.Add(rootItem); themeTreeView.SelectedItem = rootItem; // Add the image based UI themes to the tree view rootItem = new NTreeViewItem("Part Based"); rootItem.Expanded = true; themeTreeView.Items.Add(rootItem); themeItem = new NTreeViewItem("Windows XP Blue"); themeItem.Tag = new NWindowsXPBlueTheme(); rootItem.Items.Add(themeItem); themeItem = new NTreeViewItem("Windows Aero"); themeItem.Tag = new NWindowsAeroTheme(); rootItem.Items.Add(themeItem); themeItem = new NTreeViewItem("Windows 8"); themeItem.Tag = new NWindows8Theme(); rootItem.Items.Add(themeItem); themeItem = new NTreeViewItem("Mac OS X 10.7 Lion"); themeItem.Tag = new NMacLionTheme(); rootItem.Items.Add(themeItem); themeItem = new NTreeViewItem("Mac OS X 10.11 El Capitan"); themeItem.Tag = new NMacElCapitanTheme(); rootItem.Items.Add(themeItem); themeItem = new NTreeViewItem("Nevron Dark"); themeItem.Tag = new NNevronDarkTheme(); rootItem.Items.Add(themeItem); themeItem = new NTreeViewItem("Nevron Light"); themeItem.Tag = new NNevronLightTheme(); rootItem.Items.Add(themeItem); // Add the windows classic UI themes to the tree view rootItem = new NTreeViewItem("Windows Classic"); rootItem.Expanded = true; themeTreeView.Items.Add(rootItem); ENUIThemeScheme[] windowsClassicSchemes = NEnum.GetValues <ENUIThemeScheme>(); for (int i = 0, count = windowsClassicSchemes.Length; i < count; i++) { ENUIThemeScheme scheme = windowsClassicSchemes[i]; theme = new NWindowsClassicTheme(scheme); themeItem = new NTreeViewItem(NStringHelpers.InsertSpacesBeforeUppersAndDigits(scheme.ToString())); themeItem.Tag = theme; rootItem.Items.Add(themeItem); } // Subscribe to the selected path changed event themeTreeView.SelectedPathChanged += new Function <NValueChangeEventArgs>(OnThemeTreeViewSelectedPathChanged); return(themeTreeView); }
/// <summary> /// Creates the menu drop down that allows the user to select a theme. /// </summary> /// <returns></returns> protected NMenuDropDown CreateThemesMenuDropDown() { NMenuDropDown themesMenu = new NMenuDropDown("Theme"); // Add the Windows Classic themes NMenuItem windowsClassicMenuItem = new NMenuItem("Windows Classic"); themesMenu.Items.Add(windowsClassicMenuItem); ENUIThemeScheme[] windowsClassicSchemes = NEnum.GetValues <ENUIThemeScheme>(); for (int i = 0, count = windowsClassicSchemes.Length; i < count; i++) { ENUIThemeScheme scheme = (ENUIThemeScheme)windowsClassicSchemes.GetValue(i); NWindowsClassicTheme theme = new NWindowsClassicTheme(scheme); NCheckableMenuItem themeItem = new NCheckableMenuItem(NStringHelpers.InsertSpacesBeforeUppersAndDigits(scheme.ToString())); themeItem.Tag = theme; themeItem.Click += OnThemeMenuItemClick; windowsClassicMenuItem.Items.Add(themeItem); } // Add the touch themes NMenuItem touchThemesMenuItem = new NMenuItem("Touch Themes"); themesMenu.Items.Add(touchThemesMenuItem); // Add the Windows 8 touch theme NCheckableMenuItem windows8ThemeMenuItemTouch = new NCheckableMenuItem("Windows 8 Touch"); windows8ThemeMenuItemTouch.Tag = new NWindows8Theme(true); windows8ThemeMenuItemTouch.Click += OnThemeMenuItemClick; touchThemesMenuItem.Items.Add(windows8ThemeMenuItemTouch); // Add the dark theme NCheckableMenuItem darkThemeTouch = new NCheckableMenuItem("Nevron Dark Touch"); darkThemeTouch.Tag = new NNevronDarkTheme(true); darkThemeTouch.Click += OnThemeMenuItemClick; touchThemesMenuItem.Items.Add(darkThemeTouch); // Add the light theme NCheckableMenuItem lightThemeTouch = new NCheckableMenuItem("Nevron Light Touch"); lightThemeTouch.Tag = new NNevronLightTheme(true); lightThemeTouch.Click += OnThemeMenuItemClick; touchThemesMenuItem.Items.Add(lightThemeTouch); // Add the Windows XP Blue theme NCheckableMenuItem xpBlueMenuItem = new NCheckableMenuItem("Windows XP Blue"); xpBlueMenuItem.Tag = new NWindowsXPBlueTheme(); xpBlueMenuItem.Click += OnThemeMenuItemClick; themesMenu.Items.Add(xpBlueMenuItem); // Add the Windows Aero theme NCheckableMenuItem aeroThemeMenuItem = new NCheckableMenuItem("Windows 7 Aero"); aeroThemeMenuItem.Tag = new NWindowsAeroTheme(); aeroThemeMenuItem.Click += OnThemeMenuItemClick; themesMenu.Items.Add(aeroThemeMenuItem); // Add the Windows 8 theme (the default theme) NCheckableMenuItem windows8ThemeMenuItem = new NCheckableMenuItem("Windows 8"); windows8ThemeMenuItem.Tag = new NWindows8Theme(); windows8ThemeMenuItem.Click += OnThemeMenuItemClick; themesMenu.Items.Add(windows8ThemeMenuItem); windows8ThemeMenuItem.Checked = true; m_CurrentThemeMenuItem = windows8ThemeMenuItem; // Add the Mac Lion theme NCheckableMenuItem macLionThemeMenuItem = new NCheckableMenuItem("Mac OS X Lion"); macLionThemeMenuItem.Tag = new NMacLionTheme(); macLionThemeMenuItem.Click += OnThemeMenuItemClick; themesMenu.Items.Add(macLionThemeMenuItem); // Add the Mac El Capitan theme NCheckableMenuItem macElCapitanTheme = new NCheckableMenuItem("Mac OS X El Capitan"); macElCapitanTheme.Tag = new NMacElCapitanTheme(); macElCapitanTheme.Click += OnThemeMenuItemClick; themesMenu.Items.Add(macElCapitanTheme); // Add the dark theme NCheckableMenuItem darkTheme = new NCheckableMenuItem("Nevron Dark"); darkTheme.Tag = new NNevronDarkTheme(); darkTheme.Click += OnThemeMenuItemClick; themesMenu.Items.Add(darkTheme); // Add the light theme NCheckableMenuItem lightTheme = new NCheckableMenuItem("Nevron Light"); lightTheme.Tag = new NNevronLightTheme(); lightTheme.Click += OnThemeMenuItemClick; themesMenu.Items.Add(lightTheme); return(themesMenu); }
private void OnMaskInputRejected(NMaskInputRejectedEventArgs arg) { m_EventsLog.LogEvent("Rejected Character: '" + arg.Character + "', reason: '" + NStringHelpers.InsertSpacesBeforeUppersAndDigits(arg.Reason.ToString()) + "'"); }