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 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 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."; }
private void OnGetTextButtonClick(NEventArgs args) { NDataObject dataObject = NClipboard.GetDataObject(); object data = dataObject.GetData(NDataFormat.TextFormat); if (data != null) { m_TextBox.Text = (string)data; } }
private void OnGetRTFButtonClick(NEventArgs args) { NDataObject dataObject = NClipboard.GetDataObject(); byte[] data = dataObject.GetRTF(); if (data != null) { m_RichText.LoadFromStream(new MemoryStream(data), new NRtfTextFormat()); } }
private void OnSourceMouseDown(NMouseButtonEventArgs args) { if (NDragDrop.CanRequestDragDrop()) { NDataObject dataObject = (NDataObject)args.CurrentTargetNode.Tag; NDragDropSource dropSource = new NDragDropSource(ENDragDropEffects.All); dropSource.DragStarting += new Function <NDragDropSourceEventArgs>(OnDropSourceDragStarting); dropSource.DragEnded += new Function <NDragEndedEventArgs>(OnDropSourceDragEnded); dropSource.QueryDragAction += new Function <NQueryDragActionEventArgs>(OnDropSourceQueryDragAction); NDragDrop.RequestDragDrop(dropSource, dataObject); } }
private void OnGetRasterButtonClick(NEventArgs args) { // get a data object from the clipboard NDataObject dataObject = NClipboard.GetDataObject(); // try get a raster from the data object object data = dataObject.GetData(NDataFormat.RasterFormat); if (data == null) { return; } // place it inside the image box NRaster raster = (NRaster)data; m_ImageBox.Image = new NImage(raster); m_ImageBox.Visibility = ENVisibility.Visible; }
private void OnSetRTFButtonClick(NEventArgs args) { NDataObject dataObject = new NDataObject(); using (MemoryStream stream = new MemoryStream()) { m_RichText.SaveToStream(stream, new NRtfTextFormat()); dataObject.SetData(NDataFormat.RTFFormat, stream.ToArray()); NClipboard.SetDataObject(dataObject); } // Clear the rich text m_RichText.Content.Sections.Clear(); NSection section = new NSection(); m_RichText.Content.Sections.Add(section); section.Blocks.Add(new NParagraph("Rich text content moved to clipboard.")); }
protected override NWidget CreateExampleContent() { // sources NGroupBox sourcesGroup = new NGroupBox("Drag Drop Sources"); { NStackPanel sourcesStack = new NStackPanel(); sourcesGroup.Content = sourcesStack; NContentHolder textSource1 = CreateDemoElement("Drag Source Text 1"); NDataObject dataObject1 = new NDataObject(); dataObject1.SetData(NDataFormat.TextFormat, "Text string 1"); textSource1.Tag = dataObject1; sourcesStack.Add(textSource1); textSource1.MouseDown += new Function <NMouseButtonEventArgs>(OnSourceMouseDown); NContentHolder textSource2 = CreateDemoElement("Drag Source Text 2"); NDataObject dataObject2 = new NDataObject(); dataObject2.SetData(NDataFormat.TextFormat, "Text string 2"); textSource2.Tag = dataObject2; sourcesStack.Add(textSource2); textSource2.MouseDown += new Function <NMouseButtonEventArgs>(OnSourceMouseDown); //NContentHolder widgetSource1 = CreateDemoElement("Drag Button"); //widgetSource1.Tag = new NContentDataObject(new NButton("Widget In Drag and Drop")); //sourcesStack.Add(widgetSource1); //widgetSource1.MouseDown += new Function<NMouseEventArgs>(OnSourceMouseDown); //NContentHolder compositeSource1 = CreateDemoElement("Composite Data Object"); //compositeSource1.Tag = new NCompositeDataObject( // new NContentDataObject(new NButton("Widget In Drag and Drop")), // new NContentDataObject("Hello there")); //sourcesStack.Add(compositeSource1); //compositeSource1.MouseDown += new Function<NMouseEventArgs>(OnSourceMouseDown); } // targets NGroupBox targetsGroup = new NGroupBox("Drop Targets"); { NStackPanel targetsStack = new NStackPanel(); targetsGroup.Content = targetsStack; NContentHolder dropTextTarget = CreateDemoElement("Drop Text On Me"); targetsStack.Add(dropTextTarget); dropTextTarget.DragOver += new Function <NDragActionEventArgs>(OnDragOverTextTarget); dropTextTarget.DragDrop += new Function <NDragActionEventArgs>(OnDragDropTextTarget); } // create the source and targets splitter NSplitter splitter = new NSplitter(); splitter.SplitMode = ENSplitterSplitMode.Proportional; splitter.SplitFactor = 0.5d; splitter.Pane1.Content = sourcesGroup; splitter.Pane2.Content = targetsGroup; // create the inspector on the bottom NGroupBox inspectorGroup = new NGroupBox("Data Object Ispector"); NListBox inspector = new NListBox(); inspectorGroup.Content = inspector; inspector.DragEnter += new Function <NDragOverChangeEventArgs>(OnInspectorDragEnter); inspector.DragLeave += new Function <NDragOverChangeEventArgs>(OnInspectorDragLeave); NStackPanel stack = new NStackPanel(); stack.HorizontalPlacement = ENHorizontalPlacement.Fit; stack.VerticalPlacement = ENVerticalPlacement.Fit; stack.FillMode = ENStackFillMode.Last; stack.Add(splitter); stack.Add(inspectorGroup); return(stack); }