private void OnSetRasterButtonClick(NEventArgs args) { // get a raster to place on the clipbar NRaster raster = null; switch ((int)args.TargetNode.Tag) { case 0: raster = NResources.Image__48x48_Book_png.ImageSource.CreateRaster(); break; case 1: raster = NResources.Image__48x48_Clock_png.ImageSource.CreateRaster(); break; case 2: raster = NResources.Image__48x48_Darts_png.ImageSource.CreateRaster(); break; } // create a data object NDataObject dataObject = new NDataObject(); dataObject.SetData(NDataFormat.RasterFormat, raster); // set it on the clipboard NClipboard.SetDataObject(dataObject); }
private void OnLoadStateButtonClick(NEventArgs arg1) { if (m_MemoryStream == null) { return; } m_MemoryStream.Seek(0, SeekOrigin.Begin); try { NDomNodeDeserializer deserializer = new NDomNodeDeserializer(); NTestNode root = (NTestNode)deserializer.LoadFromStream(m_MemoryStream, ENPersistencyFormat.Binary)[0]; /* NDocumentBlock root = (NDocumentBlock)deserializer.LoadFromStream(m_MemoryStream, ENPersistencyFormat.Binary)[0]; * * if (root != null) * { * m_RichText.Document = new NRichTextDocument(root); * }*/ } catch (Exception ex) { NTrace.WriteLine(ex.Message); } }
private void OnBrowseButtonClick(NEventArgs arg1) { NOpenFileDialog openFileDialog = new NOpenFileDialog(); openFileDialog.FileTypes = new NFileDialogFileType[] { new NFileDialogFileType("Word Documents and Rich Text Files", new string[] { "docx", "rtf" }) }; openFileDialog.SelectedFilter = 0; openFileDialog.MultiSelect = false; openFileDialog.InitialDirectory = String.Empty; openFileDialog.Closed += new Function <NOpenFileDialogResult>( delegate(NOpenFileDialogResult result) { if (result.Result != ENCommonDialogResult.OK) { return; } string fileName = result.Files[0].Path; m_FileNameTextBox.Text = fileName; if (LoadRtfFromFile(fileName)) { ExportToHtml(); } } ); openFileDialog.RequestShow(); }
private void OnSwitchUIButtonClick(NEventArgs arg) { NButton switchUIButton = (NButton)arg.TargetNode; NLabel label = (NLabel)switchUIButton.Content; // Remove the rich text view from its parent m_ScheduleView.ParentNode.RemoveChild(m_ScheduleView); if (label.Text == SwitchToRibbon) { // We are in "Command Bars" mode, so switch to "Ribbon" label.Text = SwitchToCommandBars; // Create the ribbon m_ExampleTabPage.Content = m_RibbonBuilder.CreateUI(m_ScheduleView); } else { // We are in "Ribbon" mode, so switch to "Command Bars" label.Text = SwitchToRibbon; // Create the command bars if (m_CommandBarBuilder == null) { m_CommandBarBuilder = new NScheduleCommandBarBuilder(); } m_ExampleTabPage.Content = m_CommandBarBuilder.CreateUI(m_ScheduleView); } }
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 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); } }
void OnEditStrokeChanged(NEventArgs args) { NValueChangeEventArgs localValueChangeArgs = args as NValueChangeEventArgs; if (localValueChangeArgs != null) { for (int i = 0; i < m_arrStrokes.Length; i++) { NStroke stroke = m_arrStrokes[i]; stroke.SetValue(localValueChangeArgs.Property, localValueChangeArgs.NewValue); NCanvas canvas = m_CanvasStack[i] as NCanvas; double strokeWidth = stroke.Width; if (strokeWidth < 0) { strokeWidth = 0; } canvas.PreferredSize = GetCanvasPreferredSize(strokeWidth); if (canvas != null) { canvas.InvalidateDisplay(); } } } }
void OnNewDataButtonClick(NEventArgs arg) { m_Point.DataPoints.Clear(); NDataPointCollection <NPointDataPoint> dataPoints = m_Point.DataPoints; Random random = new Random(); for (int i = 0; i < 1000; i++) { double u1 = random.NextDouble(); double u2 = random.NextDouble(); if (u1 == 0) { u1 += 0.0001; } if (u2 == 0) { u2 += 0.0001; } double z0 = Math.Sqrt(-2 * Math.Log(u1)) * Math.Cos(2 * Math.PI * u2); double z1 = Math.Sqrt(-2 * Math.Log(u1)) * Math.Sin(2 * Math.PI * u2); dataPoints.Add(new NPointDataPoint(z0, z1)); } }
private void OnOpenFileButtonClick(NEventArgs arg) { NOpenFileDialog openFileDialog = new NOpenFileDialog(); openFileDialog.FileTypes = new NFileDialogFileType[] { new NFileDialogFileType("Xml Files (*.xml)", "xml") }; openFileDialog.Closed += OnOpenFileDialogClosed; openFileDialog.RequestShow(); }
private void OnRemoveSelectedButtonClick(NEventArgs args) { if (m_ComboBox.SelectedIndex != -1) { m_ComboBox.Items.RemoveAt(m_ComboBox.SelectedIndex); m_ComboBox.SelectedIndex = -1; } }
private void OnAddLargeItemButtonClick(NEventArgs args) { NWidget item = CreateDockedWidget(); item.MinSize = new NSize(40, 40); item.PreferredSize = new NSize(100, 100); m_DockPanel.Add(item); }
private void OnAddSmallItemButtonClick(NEventArgs args) { NButton item = new NButton("Small." + m_StackPanel.Count.ToString()); item.MinSize = new NSize(5, 5); item.PreferredSize = new NSize(25, 25); m_StackPanel.Add(item); }
private void OnHomeButtonClick(NEventArgs arg) { // Show the home page this.Content = m_ExamplesHomePage; // Clear the text of the search box m_ExamplesHomePage.m_SearchBox.Text = null; }
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); }
void OnLoadStateFromStreamButtonClick(NEventArgs arg) { if (m_Stream != null) { m_Stream.Seek(0, SeekOrigin.Begin); m_ChartView.LoadFromStream(m_Stream); } }
private void OnCopyLinkToClipboardClick(NEventArgs arg) { NDataObject dataObject = new NDataObject(); NXmlElement element = (NXmlElement)arg.CurrentTargetNode.Tag; dataObject.SetData(NDataFormat.TextFormat, m_ExamplesPath + "?example=" + element.GetAttributeValue("type")); NClipboard.SetDataObject(dataObject); }
private void OnShowDesignerButtonClicked(NEventArgs args) { NEditor editor = NDesigner.GetDesigner(m_ComboBox).CreateInstanceEditor(m_ComboBox); NEditorWindow window = NApplication.CreateTopLevelWindow <NEditorWindow>(); window.Editor = editor; window.Open(); }
private void OnAddLargeItemButtonClick(NEventArgs args) { NButton item = new NButton("Large." + m_StackPanel.Count.ToString()); item.MinSize = new NSize(20, 20); item.PreferredSize = new NSize(60, 60); m_StackPanel.Add(item); }
/// <summary> /// Called when the drawing view is registered to its owner document. /// </summary> /// <param name="arg"></param> private void OnDrawingViewRegistered(NEventArgs arg) { // Evaluate the drawing document m_DrawingDocument.Evaluate(); // Layout the shapes ArrangeDiagram(); }
private void OnAddSmallItemButtonClick(NEventArgs args) { NWidget item = CreateDockedWidget(); item.MinSize = new NSize(20, 20); item.PreferredSize = new NSize(60, 60); m_DockPanel.Add(item); }
private void OnImportButtonClick(NEventArgs arg1) { byte[] bytes = NEncoding.UTF8.GetBytes(m_HtmlTextBox.Text); using (MemoryStream stream = new MemoryStream(bytes)) { LoadHtml(stream, null); } }
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 OnRibbonButtonClicked(NEventArgs arg) { INRibbonButton button = arg.TargetNode as INRibbonButton; if (button != null) { m_EventsLog.LogEvent(button.Text + " clicked"); } }
void OnChangeYValuesButtonClick(NEventArgs arg) { Random random = new Random(); for (int i = 0; i < m_Bubble.DataPoints.Count; i++) { m_Bubble.DataPoints[i].Value = random.Next(-100, 100); } }
private void OnLoadButtonClick(NEventArgs arg1) { string fileName = m_FileNameTextBox.Text; if (NFile.Exists(m_FileNameTextBox.Text) && LoadRtfFromFile(m_FileNameTextBox.Text)) { ExportToHtml(); } }
void OnDailyDataButtonClick(NEventArgs arg) { // generate data for 30 days DateTime dtNow = DateTime.Now; DateTime dtEnd = new DateTime(dtNow.Year, dtNow.Month, dtNow.Day, 17, 0, 0, 0); DateTime dtStart = new DateTime(dtNow.Year, dtNow.Month, dtNow.Day, 7, 0, 0, 0); GenerateData(dtStart, dtEnd, new NDateTimeSpan(5, NDateTimeUnit.Minute)); }
void OnWeeklyDataButtonClick(NEventArgs arg) { // generate data for 30 weeks DateTime dtNow = DateTime.Now; DateTime dtEnd = new DateTime(dtNow.Year, dtNow.Month, dtNow.Day, 7, 0, 0, 0); DateTime dtStart = NDateTimeUnit.Week.Add(dtEnd, -30); GenerateData(dtStart, dtEnd, new NDateTimeSpan(1, NDateTimeUnit.Day)); }
private void OnSetTextButtonClick(NEventArgs args) { NDataObject dataObject = new NDataObject(); dataObject.SetData(NDataFormat.TextFormat, m_TextBox.Text); NClipboard.SetDataObject(dataObject); m_TextBox.Text = "Text box content moved to clipboard."; }
protected virtual void OnAddLargeItemButtonClick(NEventArgs args) { NShape item = CreateShape(); item.Width = 60; item.Height = 60; m_DrawingDocument.Content.ActivePage.Items.Add(item); ArrangeDiagram(); }
void OnDimFillButtonClick(NEventArgs arg) { NEditorWindow.CreateForType <NFill>( (NFill)m_NumericDisplay1.DimFill.DeepClone(), null, OwnerWindow, false, OnDimFillEdited).Open(); }