System.Windows.Forms.Clipboard.SetDataObject(object, bool)

Here are the examples of the csharp api class System.Windows.Forms.Clipboard.SetDataObject(object, bool) taken from open source projects. By voting up you can indicate which examples are most useful and appropriate.

69 Examples 7

1. Example

Project: PoESkillTree
Source File: MainWindow.xaml.cs
View license
private async Task ShowPoeUrlMessageAndAddToClipboard(string poeurl)
        {
            try
            {
                System.Windows.Forms.Clipboard.SetDataObject(poeurl, true);
                await this.ShowInfoAsync(L10n.Message("The PoEUrl link has been copied to Clipboard.") + "\n\n" + poeurl);
            }
            catch (Exception ex)
            {
                await this.ShowErrorAsync(L10n.Message("An error occurred while copying to Clipboard."), ex.Message);
            }
        }

2. Example

Project: DeOps
Source File: PacketsForm.cs
View license
private void TreeViewPacket_KeyDown(object sender, System.Windows.Forms.KeyEventArgs e)
		{
			if(e.Control && e.KeyCode == Keys.C)
				Clipboard.SetDataObject(TreeViewPacket.SelectedNode.Text, true);
		}

3. Example

View license
void copyExceptionsSelected_toClipboard() {
			Clipboard.SetDataObject(this.exceptionsSelectedInTree_AsString, true);
		}

4. Example

Project: logwizard
Source File: clipboard_util.cs
View license
public static void copy(string html, string plain) {
            var dataObject = new_data_object(html, plain);
            Clipboard.SetDataObject(dataObject, true);
        }

5. Example

View license
private void ClipboardCopyThread()
		{
			Clipboard.SetDataObject( ImageRender(), true );
		}

6. Example

Project: HTML-Renderer
Source File: ClipboardHelper.cs
View license
public static void CopyToClipboard(string html, string plainText)
        {
            var dataObject = CreateDataObject(html, plainText);
            Clipboard.SetDataObject(dataObject, true);
        }

7. Example

Project: HTML-Renderer
Source File: ClipboardHelper.cs
View license
public static void CopyToClipboard(string plainText)
        {
            var dataObject = new DataObject();
            dataObject.SetData(DataFormats.Text, plainText);
            dataObject.SetData(DataFormats.UnicodeText, plainText);
            Clipboard.SetDataObject(dataObject, true);
        }

8. Example

Project: poderosa
Source File: BasicCommands.cs
View license
private void CopyToClipboard(string data) {
            try {
                Clipboard.SetDataObject(data, false);
            }
            catch (Exception ex) {
                RuntimeUtil.ReportException(ex);
            }
        }

9. Example

Project: poderosa
Source File: CommandResultPopup.cs
View license
private void CopyToClipboard(string data) {
            try {
                Clipboard.SetDataObject(data, false);
            }
            catch (Exception ex) {
                RuntimeUtil.ReportException(ex);
            }
        }

10. Example

Project: poderosa
Source File: TerminalCommands.cs
View license
private static void CopyToClipboard(string data) {
            try {
                Clipboard.SetDataObject(data, false);
            }
            catch (Exception ex) {
                RuntimeUtil.ReportException(ex);
            }
        }

11. Example

Project: Florence
Source File: PlotControl.cs
View license
public void CopyDataToClipboard()
		{
			System.Text.StringBuilder sb = new System.Text.StringBuilder();

			for (int i=0; i<this.InteractivePlotSurface2D.Drawables.Count; ++i)
			{
				IPlot plot = this.InteractivePlotSurface2D.Drawables[i] as IPlot;
				if (plot != null)
				{
					Axis xAxis = this.InteractivePlotSurface2D.WhichXAxis( plot );
					Axis yAxis = this.InteractivePlotSurface2D.WhichYAxis( plot );

					RectangleD region = new RectangleD( 
						xAxis.WorldMin, 
						yAxis.WorldMin,
						xAxis.WorldMax - xAxis.WorldMin,
						yAxis.WorldMax - yAxis.WorldMin );

					plot.WriteData( sb, region, true );
				}
			}

			Clipboard.SetDataObject( sb.ToString(), true );
		}

12. Example

Project: QTTabBar
Source File: QTTabBarClass.cs
View license
internal static void SetStringClipboard(string str) {
            try {
                Clipboard.SetDataObject(str, true);
                if(!QTUtility.CheckConfig(Settings.DisableSound)) {
                    SystemSounds.Asterisk.Play();
                }
            }
            catch {
                SystemSounds.Hand.Play();
            }
        }

13. Example

View license
private void ClipboardCopyThread()
		{
			Clipboard.SetDataObject( ImageRender(), true );
		}

14. Example

Project: Zydeo
Source File: ClipboardHelper.cs
View license
public static void CopyToClipboard(string html, string plainText)
        {
            var dataObject = CreateDataObject(html, plainText);
            Clipboard.SetDataObject(dataObject, true);
        }

15. Example

View license
private void _component_CopyCannedTextRequested(object sender, EventArgs e)
		{
			string fullCannedText = _component.GetFullCannedText();
			if (!string.IsNullOrEmpty(fullCannedText))
				Clipboard.SetDataObject(fullCannedText, true);
		}

16. Example

View license
public void CopyToClipboard(bool showToast)
        {
            var dataObj = GetClipboardValue();
            if (null != dataObj)
            {
                Clipboard.SetDataObject(dataObj, true);
                Utils.ClearCliboard(Settings.Default.CopyToClipboardTimeToLive, Microsoft.Vault.Library.Utils.CalculateMd5(dataObj.GetText()));
                if (showToast)
                {
                    Utils.ShowToast($"{(_contentType.IsCertificate() ? "Certificate" : "Secret")} {Name} copied to clipboard");
                }
            }
        }

17. Example

Project: SeleniumBasic
Source File: Image.cs
View license
public IRange ToExcel(object target = null, bool autoDispose = true) {
            IRange range = ExcelExt.GetRange(target);
            Clipboard.SetDataObject(_bitmap, false);
            range.Worksheet.Paste(range, _bitmap);
            Clipboard.Clear();
            if (autoDispose)
                _bitmap.Dispose();
            return range;
        }

18. Example

View license
public static void CopyToClipboard(T objectToCopy)
        {
            var format = DataFormats.GetFormat(typeof(T).FullName);
            IDataObject dataObj = new DataObject();
            dataObj.SetData(format.Name, false, objectToCopy);
            Clipboard.SetDataObject(dataObj, false);
        }

19. Example

View license
public static void CopyToClipboard(T objectToCopy)
        {
            // register my custom data format with Windows or get it if it's already registered
            DataFormats.Format format = DataFormats.GetFormat(typeof(T).FullName);

            // now copy to clipboard
            IDataObject dataObj = new DataObject();
            dataObj.SetData(format.Name, false, objectToCopy);
            Clipboard.SetDataObject(dataObj, false);
        }

20. Example

Project: tfsprod
Source File: MergeWIControl.cs
View license
private void toolDClipboard_Click(object sender, EventArgs e)
        {
            string res = String.Format("Changeset={0}, WorkItem={1}, Date={2}, ServerPath={3}", ClickedItem.ChangesetID, ClickedItem.WorkitemID, ClickedItem.date, ClickedItem.sourcePath);

            Clipboard.Clear();
            Clipboard.SetDataObject(res, true);
        }

21. Example

Project: mwinapi
Source File: ClipboardEntry.cs
View license
internal void CopyToClipboard()
        {
            if (empty)
            {
                Clipboard.Clear();
            }
            else
            {
                DataObject o = new DataObject();
                foreach (KeyValuePair<string, object> p in entries)
                {
                    o.SetData(p.Key, false, p.Value);
                }
                Clipboard.SetDataObject(o, true);
            }
        }

22. Example

Project: nHydrate
Source File: DebugConsole.cs
View license
private void OutputView_KeyDown(object sender, System.Windows.Forms.KeyEventArgs e)
		{
			if(e.Modifiers == Keys.Control  && e.KeyCode == Keys.C)
			{
				var clipboardText = new StringBuilder();
				foreach(ListViewItem lvi in OutputView.SelectedItems)
				{
					clipboardText.Append(lvi.SubItems[2].Text).Append("\r\n");
				}
				Clipboard.SetDataObject(clipboardText.ToString(), true);
			}
		
		}

23. Example

View license
private void Copy()
        {
            //	Instantiate the data object.
            DataObject dataObject = new DataObject();

            //	Set a Text format with the selected entries string.
            dataObject.SetData(DataFormats.Text, SelectedEntriesString());

            //	Finally, set the data object on the clipboard.
            Clipboard.SetDataObject(dataObject, true);
        }

24. Example

Project: openHistorian
Source File: PlotSurface2D.cs
View license
public void CopyToClipboard()
        {
            System.Drawing.Bitmap b = new System.Drawing.Bitmap(this.Width, this.Height);
            Graphics g = Graphics.FromImage(b);
            g.Clear(Color.White);
            this.Draw(g, new Rectangle(0, 0, b.Width - 1, b.Height - 1));
            Clipboard.SetDataObject(b, true);
        }

25. Example

Project: tfsprod
Source File: MergeWIControl.cs
View license
private void ctxMenuChangesets_ItemClicked(object sender, ToolStripItemClickedEventArgs e)
        {/n ..... /n //View Source file for more details /n }

26. Example

Project: Florence
Source File: PlotControl.cs
View license
public void CopyToClipboard()
		{
			System.Drawing.Bitmap b = new System.Drawing.Bitmap( this.Width, this.Height );
			System.Drawing.Graphics g = Graphics.FromImage( b );
			g.Clear(Color.White);
			this.Draw( g, new Rectangle( 0, 0, b.Width-1, b.Height-1 ) );
			Clipboard.SetDataObject( b, true );
		}

27. Example

Project: ShareX
Source File: ClipboardHelper.cs
View license
private static void SetDataObject(IDataObject ido, bool copy)
        {
            lock (clipboardL/n ..... /n //View Source file for more details /n }

28. Example

Project: ShareX
Source File: ClipboardHelper.cs
View license
private static void SetDataObject(IDataObject ido, bool copy)
        {
            lock (clipboardL/n ..... /n //View Source file for more details /n }

29. Example

Project: Cropper
Source File: ClipboardFormat.cs
View license
protected override void ImageCaptured(object sender, ImageCapturedEventArgs e)
        {
           /n ..... /n //View Source file for more details /n }

30. Example

Project: WsdlUI
Source File: TextAreaClipboardHandler.cs
View license
static void SafeSetClipboard(object dataObject)
		{
			// Work around ExternalException bug. (SD2-426)
			// Best reproducable inside Virtual PC.
			int version = unchecked(++SafeSetClipboardDataVersion);
			try {
				Clipboard.SetDataObject(dataObject, true);
			} catch (ExternalException) {
				Timer timer = new Timer();
				timer.Interval = 100;
				timer.Tick += delegate {
					timer.Stop();
					timer.Dispose();
					if (SafeSetClipboardDataVersion == version) {
						try {
							Clipboard.SetDataObject(dataObject, true, 10, 50);
						} catch (ExternalException) { }
					}
				};
				timer.Start();
			}
		}

31. Example

Project: tesvsnip
Source File: MainView.cs
View license
internal static void SetClipboardData(object value)
        {
            if (Settings.Default.UseWindowsClipboard)
            {
                var cloneable = value as ICloneable;
                if (cloneable != null)
                {
                    var ido = new DataObject();
                    var srFormat = value.GetType().FullName;
                    ido.SetData(srFormat, cloneable.Clone());
                    ido.SetData("TESVSnip", srFormat);
                    System.Windows.Forms.Clipboard.Clear();
                    System.Windows.Forms.Clipboard.SetDataObject(ido, true);
                }
            }
            else
            {
                s_clipboard = value;
            }
        }

32. Example

Project: falloutsnip
Source File: MainView.Selection.cs
View license
internal static void SetClipboardData(object value)
        {
            if (Settings.Default.UseWindowsClipboard)
            {
                var cloneable = value as ICloneable;
                if (cloneable != null)
                {
                    var ido = new DataObject();
                    var srFormat = value.GetType().FullName;
                    ido.SetData(srFormat, cloneable.Clone());
                    ido.SetData("FalloutSnip", srFormat);
                    System.Windows.Forms.Clipboard.Clear();
                    System.Windows.Forms.Clipboard.SetDataObject(ido, true);
                }
            }
            else
            {
                s_clipboard = value;
            }
        }

33. Example

Project: Pyramid
Source File: TextAreaClipboardHandler.cs
View license
static void SafeSetClipboard(object dataObject)
		{
			// Work around ExternalException bug. (SD2-426)
			// Best reproducable inside Virtual PC.
			int version = unchecked(++SafeSetClipboardDataVersion);
			try {
				Clipboard.SetDataObject(dataObject, true);
			} catch (ExternalException) {
				Timer timer = new Timer();
				timer.Interval = 100;
				timer.Tick += delegate {
					timer.Stop();
					timer.Dispose();
					if (SafeSetClipboardDataVersion == version) {
						try {
							Clipboard.SetDataObject(dataObject, true, 10, 50);
						} catch (ExternalException) { }
					}
				};
				timer.Start();
			}
		}

34. Example

Project: fdotoolbox
Source File: ClipboardWrapper.cs
View license
static void SafeSetClipboard(object dataObject)
		{
			// Work around ExternalException bug. (SD2-426)
			// Best reproducable inside Virtual PC.
			int version = unchecked(++SafeSetClipboardDataVersion);
			try {
				Clipboard.SetDataObject(dataObject, true);
			} catch (ExternalException) {
				Timer timer = new Timer();
				timer.Interval = 100;
				timer.Tick += delegate {
					timer.Stop();
					timer.Dispose();
					if (SafeSetClipboardDataVersion == version) {
						try {
							Clipboard.SetDataObject(dataObject, true, 10, 50);
						} catch (ExternalException) { }
					}
				};
				timer.Start();
			}
		}

35. Example

View license
static void SafeSetClipboard(object dataObject)
		{
			// Work around ExternalException bug. (SD2-426)
			// Best reproducable inside Virtual PC.
			int version = unchecked(++SafeSetClipboardDataVersion);
			try {
				Clipboard.SetDataObject(dataObject, true);
			} catch (ExternalException) {
				Timer timer = new Timer();
				timer.Interval = 100;
				timer.Tick += delegate {
					timer.Stop();
					timer.Dispose();
					if (SafeSetClipboardDataVersion == version) {
						try {
							Clipboard.SetDataObject(dataObject, true, 10, 50);
						} catch (ExternalException) { }
					}
				};
				timer.Start();
			}
		}

36. Example

Project: ecsharp
Source File: TextAreaClipboardHandler.cs
View license
static void SafeSetClipboard(object dataObject)
		{
			// Work around ExternalException bug. (SD2-426)
			// Best reproducable inside Virtual PC.
			int version = unchecked(++SafeSetClipboardDataVersion);
			try {
				Clipboard.SetDataObject(dataObject, true);
			} catch (ExternalException) {
				Timer timer = new Timer();
				timer.Interval = 100;
				timer.Tick += delegate {
					timer.Stop();
					timer.Dispose();
					if (SafeSetClipboardDataVersion == version) {
						try {
							Clipboard.SetDataObject(dataObject, true, 10, 50);
						} catch (ExternalException) { }
					}
				};
				timer.Start();
			}
		}

37. Example

Project: ATF
Source File: DefaultTabCommands.cs
View license
public virtual void DoCommand(object commandTag)
        {
            switch ((Command)commandTag)
            {
                case Command.CloseCurrentTab:
                    Close(ControlRegistry.ActiveControl);
                    break;

                case Command.CloseOtherTabs:
                    CloseOthers(ControlRegistry.ActiveControl);
                    break;

                case Command.CopyFullPath:
                    Clipboard.SetDataObject(GetDocumentPath(ControlRegistry.ActiveControl), true);
                    break;

                case Command.OpenContainingFolder:
                    // Open in Explorer and select the file. http://support.microsoft.com/kb/314853
                    System.Diagnostics.Process.Start("explorer.exe", "/e,/select," + GetDocumentPath(ControlRegistry.ActiveControl));
                    break;
            }

        }

38. Example

View license
static void SafeSetClipboard(object dataObject)
		{
			// Work around ExternalException bug. (SD2-426)
			// Best reproducable inside Virtual PC.
			int version = unchecked(++SafeSetClipboardDataVersion);
			try {
				Clipboard.SetDataObject(dataObject, true);
			} catch (ExternalException) {
				Timer timer = new Timer();
				timer.Interval = 100;
				timer.Tick += delegate {
					timer.Stop();
					timer.Dispose();
					if (SafeSetClipboardDataVersion == version) {
						try {
							Clipboard.SetDataObject(dataObject, true, 10, 50);
						} catch (ExternalException) { }
					}
				};
				timer.Start();
			}
		}

39. Example

View license
static void SafeSetClipboard(object dataObject)
		{
			// Work around ExternalException bug. (SD2-426)
			// Best reproducable inside Virtual PC.
			int version = unchecked(++SafeSetClipboardDataVersion);
			try {
				Clipboard.SetDataObject(dataObject, true);
			} catch (ExternalException) {
				Timer timer = new Timer();
				timer.Interval = 100;
				timer.Tick += delegate {
					timer.Stop();
					timer.Dispose();
					if (SafeSetClipboardDataVersion == version) {
						try {
							Clipboard.SetDataObject(dataObject, true, 10, 50);
						} catch (ExternalException) { }
					}
				};
				timer.Start();
			}
		}

40. Example

View license
static void SafeSetClipboard(object dataObject)
		{
			// Work around ExternalException bug. (SD2-426)
			// Best reproducable inside Virtual PC.
			int version = unchecked(++SafeSetClipboardDataVersion);
			try {
				Clipboard.SetDataObject(dataObject, true);
			} catch (ExternalException) {
				Timer timer = new Timer();
				timer.Interval = 100;
				timer.Tick += delegate {
					timer.Stop();
					timer.Dispose();
					if (SafeSetClipboardDataVersion == version) {
						try {
							Clipboard.SetDataObject(dataObject, true, 10, 50);
						} catch (ExternalException) { }
					}
				};
				timer.Start();
			}
		}

41. Example

View license
static void SafeSetClipboard(object dataObject)
    {
      // Work around ExternalException bug. (SD2-426)
      // Best reproducible inside Virtual PC.
      int version = unchecked(++_safeSetClipboardDataVersion);
      try
      {
        Clipboard.SetDataObject(dataObject, true);
      }
      catch (ExternalException)
      {
        Timer timer = new Timer();
        timer.Interval = 100;
        timer.Tick += delegate
        {
          timer.Stop();
          timer.Dispose();
          if (_safeSetClipboardDataVersion == version)
          {
            try
            {
              Clipboard.SetDataObject(dataObject, true, 10, 50);
            }
            catch (ExternalException) { }
          }
        };
        timer.Start();
      }
    }

42. Example

Project: duality
Source File: ProjectFolderView.cs
View license
protected void ClipboardCutNodes(IEnumerable<TreeNodeAdv> nodes)
		{
			DataObject data = new DataObject();
			this.AppendNodesToData(data, nodes);
			Clipboard.SetDataObject(data, true);

			byte[] moveEffect = new byte[] {2, 0, 0, 0};
			MemoryStream dropEffect = new MemoryStream();
			dropEffect.Write(moveEffect, 0, moveEffect.Length);

			data.SetData("Preferred DropEffect", dropEffect);

			Clipboard.Clear();
			Clipboard.SetDataObject(data);
		}

43. Example

Project: tesvsnip
Source File: HexBox.cs
View license
public void Copy()
        {
            if (!CanCopy()) return;

            // put bytes into buffer
            var buffer = new byte[_selectionLength];
            int id = -1;
            for (long i = _bytePos; i < _bytePos + _selectionLength; i++)
            {
                id++;

                buffer[id] = _byteProvider.ReadByte(i);
            }

            var da = new DataObject();

            // set string buffer clipbard data
            string sBuffer = Encoding.Instance.GetString(buffer, 0, buffer.Length);
            da.SetData(typeof (string), sBuffer);

            //set memorystream (BinaryData) clipboard data
            var ms = new MemoryStream(buffer, 0, buffer.Length, false, true);
            da.SetData("BinaryData", ms);

            Clipboard.SetDataObject(da, true);
            UpdateCaret();
            ScrollByteIntoView();
            Invalidate();
        }

44. Example

Project: falloutsnip
Source File: HexBox.cs
View license
public void Copy()
        {
            if (!CanCopy()) return;

            // put bytes into buffer
            var buffer = new byte[_selectionLength];
            int id = -1;
            for (long i = _bytePos; i < _bytePos + _selectionLength; i++)
            {
                id++;

                buffer[id] = _byteProvider.ReadByte(i);
            }

            var da = new DataObject();

            // set string buffer clipbard data
            string sBuffer = Encoding.Instance.GetString(buffer, 0, buffer.Length);
            da.SetData(typeof (string), sBuffer);

            //set memorystream (BinaryData) clipboard data
            var ms = new MemoryStream(buffer, 0, buffer.Length, false, true);
            da.SetData("BinaryData", ms);

            Clipboard.SetDataObject(da, true);
            UpdateCaret();
            ScrollByteIntoView();
            Invalidate();
        }

45. Example

Project: ImageGlass
Source File: frmMain.cs
View license
private void CutFile()
        {
            try
            {
                if (GlobalSetting.IsImageError || !File.Exists(GlobalSetting.ImageList.GetFileName(GlobalSetting.CurrentIndex)))
                {
                    return;
                }
            }
            catch { return; }

            GlobalSetting.StringClipboard = new StringCollection();
            GlobalSetting.StringClipboard.Add(GlobalSetting.ImageList.GetFileName(GlobalSetting.CurrentIndex));

            byte[] moveEffect = new byte[] { 2, 0, 0, 0 };
            MemoryStream dropEffect = new MemoryStream();
            dropEffect.Write(moveEffect, 0, moveEffect.Length);

            DataObject data = new DataObject();
            data.SetFileDropList(GlobalSetting.StringClipboard);
            data.SetData("Preferred DropEffect", dropEffect);

            Clipboard.Clear();
            Clipboard.SetDataObject(data, true);

            DisplayTextMessage(
                string.Format(GlobalSetting.LangPack.Items["frmMain._CutFileText"],
                GlobalSetting.StringClipboard.Count), 1000);
        }

46. Example

Project: ImageGlass
Source File: frmMain.cs
View license
private void CutMultiFiles()
        {
            try
            {
                if (GlobalSetting.IsImageError || !File.Exists(GlobalSetting.ImageList.GetFileName(GlobalSetting.CurrentIndex)))
                {
                    return;
                }
            }
            catch { return; }

            //get filename
            string filename = GlobalSetting.ImageList.GetFileName(GlobalSetting.CurrentIndex);

            //exit if duplicated filename
            if (GlobalSetting.StringClipboard.IndexOf(filename) != -1)
            {
                return;
            }

            //add filename to clipboard
            GlobalSetting.StringClipboard.Add(filename);

            byte[] moveEffect = new byte[] { 2, 0, 0, 0 };
            MemoryStream dropEffect = new MemoryStream();
            dropEffect.Write(moveEffect, 0, moveEffect.Length);

            DataObject data = new DataObject();
            data.SetFileDropList(GlobalSetting.StringClipboard);
            data.SetData("Preferred DropEffect", dropEffect);

            Clipboard.Clear();
            Clipboard.SetDataObject(data, true);

            DisplayTextMessage(
                string.Format(GlobalSetting.LangPack.Items["frmMain._CutFileText"],
                GlobalSetting.StringClipboard.Count), 1000);
        }

47. Example

Project: AzureKeyVaultExplorer
Source File: Utils.cs
View license
public static void ClipboardSetHyperlink(string link, string name)
        {
            // HTML format which works fine with any Office product
            const string html = @"Version:0.9
                StartHTML:<<<<<<<1
                EndHTML:<<<<<<<2
                StartFragment:<<<<<<<3
                EndFragment:<<<<<<<4
                SourceURL: {0}
                <html>
                <body>
                <!--StartFragment-->
                <a href='{0}'>{1}</a>
                <!--EndFragment-->
                </body>
                </html>";
            var dataObj = new DataObject("Preferred DropEffect", DragDropEffects.Move); // "Cut" file to clipboard
            dataObj.SetData(DataFormats.Text, link);
            dataObj.SetData(DataFormats.UnicodeText, link);
            // Add HTML format and .URL as a file
            dataObj.SetData(DataFormats.Html, string.Format(html, link, name));
            var tempPath = Path.Combine(Path.GetTempPath(), name + ContentType.KeyVaultLink.ToExtension());
            File.WriteAllText(tempPath, $"[InternetShortcut]\r\nURL={link}\r\nIconIndex=47\r\nIconFile=%SystemRoot%\\system32\\SHELL32.dll");
            var sc = new StringCollection();
            sc.Add(tempPath);
            dataObj.SetFileDropList(sc);
            Clipboard.SetDataObject(dataObj, true);
        }

48. Example

Project: tesvsnip
Source File: Program.cs
View license
public static void CurrentDomainUnhandledException(object sender, UnhandledExceptionEventArgs e)
        {
            try
            {
                Exception ex = (Exception)e.ExceptionObject;

                // Since we can't prevent the app from terminating, log this to the event log. 
                if (!EventLog.SourceExists("ThreadException"))
                {
                    EventLog.CreateEventSource("ThreadException", "Application");
                }

                string errMsg =
                  "Message: " + ex.Message +
                  Environment.NewLine +
                  Environment.NewLine +
                  "StackTrace: " + ex.StackTrace +
                  Environment.NewLine +
                  Environment.NewLine +
                  "Source: " + ex.Source +
                  Environment.NewLine +
                  Environment.NewLine +
                  "GetType: " + ex.GetType().ToString();

                Clipboard.SetDataObject(errMsg, true);

                // Create an EventLog instance and assign its source.
                EventLog myLog = new EventLog();
                myLog.Source = "ThreadException";
                myLog.WriteEntry(errMsg );

                MessageBox.Show(errMsg, "Fatal Error", MessageBoxButtons.OK, MessageBoxIcon.Stop);
            }
            finally
            {
                Application.Exit();
            }
        }

49. Example

Project: tesvsnip
Source File: Program.cs
View license
public static void ApplicationThreadException(object sender, System.Threading.ThreadExceptionEventAr/n ..... /n //View Source file for more details /n }

50. Example

Project: falloutsnip
Source File: Program.cs
View license
public static void CurrentDomainUnhandledException(object sender, UnhandledExceptionEventArgs e)
        {
            try
            {
                Exception ex = (Exception)e.ExceptionObject;

                // Since we can't prevent the app from terminating, log this to the event log. 
                if (!EventLog.SourceExists("ThreadException"))
                {
                    EventLog.CreateEventSource("ThreadException", "Application");
                }

                string errMsg =
                  "Message: " + ex.Message +
                  Environment.NewLine +
                  Environment.NewLine +
                  "StackTrace: " + ex.StackTrace +
                  Environment.NewLine +
                  Environment.NewLine +
                  "Source: " + ex.Source +
                  Environment.NewLine +
                  Environment.NewLine +
                  "GetType: " + ex.GetType().ToString();

                Clipboard.SetDataObject(errMsg, true);

                // Create an EventLog instance and assign its source.
                EventLog myLog = new EventLog();
                myLog.Source = "ThreadException";
                myLog.WriteEntry(errMsg );

                MessageBox.Show(errMsg, "Fatal Error", MessageBoxButtons.OK, MessageBoxIcon.Stop);
            }
            finally
            {
                Application.Exit();
            }
        }