public BallonNotifierFactory() { const string iconUri = "pack://application:,,,/AdmiralRoom;Component/Icons/app.ico"; Uri uri; if (!Uri.TryCreate(iconUri, UriKind.Absolute, out uri)) { return; } var streamResourceInfo = Application.GetResourceStream(uri); if (streamResourceInfo == null) { return; } using (var stream = streamResourceInfo.Stream) { notifyIcon = new NotifyIcon { Text = "提督の部屋", Icon = new Icon(stream), Visible = true }; } }
public void Initialize() { const string iconUri = "pack://application:,,,/KanColleViewer;Component/Assets/app.ico"; Uri uri; if (!Uri.TryCreate(iconUri, UriKind.Absolute, out uri)) { return; } var streamResourceInfo = Application.GetResourceStream(uri); if (streamResourceInfo == null) { return; } using (var stream = streamResourceInfo.Stream) { this.notifyIcon = new NotifyIcon { Text = App.ProductInfo.Title, Icon = new Icon(stream), Visible = true, }; } }
private void CreateNotifyIcon() { _notifyIcon = new NotifyIcon(); StreamResourceInfo info = Application.GetResourceStream(new Uri("/Resources/google.ico", UriKind.Relative)); using (Stream iconStream = info.Stream) { _notifyIcon.Icon = new Icon(iconStream); } _notifyIcon.Visible = false; _notifyIcon.DoubleClick += (sender, args) => DisplaySplashScreen.Raise(this); ToolStripMenuItem toTheGoogleCaveMenuItem = new ToolStripMenuItem { Text = "To the GoogleCave!" }; toTheGoogleCaveMenuItem.Font = new Font(toTheGoogleCaveMenuItem.Font, FontStyle.Bold); toTheGoogleCaveMenuItem.Click += (sender, args) => DisplaySplashScreen.Raise(this); toTheGoogleCaveMenuItem.ShortcutKeyDisplayString = "Win+G"; _runAtStartupMenuItem = new ToolStripMenuItem(); _runAtStartupMenuItem.Text = "Start with Windows"; _runAtStartupMenuItem.Click += (sender, args) => ChangeRunAtStartup.Raise(this); _notifyIcon.ContextMenuStrip = new ContextMenuStrip(); _notifyIcon.ContextMenuStrip.Items.AddRange( new ToolStripItem[] { toTheGoogleCaveMenuItem, _runAtStartupMenuItem, new ToolStripMenuItem("About", null, (sender, args) => DisplayAboutDialog.Raise(this)), new ToolStripSeparator(), new ToolStripMenuItem("Exit", null, (sender, args) => ExitApplication.Raise(this)) }); }
public static void InitializeNotifyIcon() { _notifyIcon = new NotifyIcon(); var streamResourceInfo = Application.GetResourceStream( new Uri("pack://application:,,,/TUnicodeEmoticons;component/Icons/TUnicodeEmoticons.ico")); if (streamResourceInfo == null) { throw new Exception("Could not load icon."); } using (var iconStream = streamResourceInfo.Stream) { _notifyIcon.Icon = new Icon(iconStream); } var menuItems = new MenuItem[2]; menuItems[0] = new MenuItem("Settings"); menuItems[0].Click += SettingsMenuItemClick; menuItems[1] = new MenuItem("Exit"); menuItems[1].Click += ExitMenuItemClick; _notifyIcon.ContextMenu = new ContextMenu(menuItems); _notifyIcon.Visible = true; _notifyIcon.ShowBalloonTip(5000, "TUnicodeEmoticons", "TUnicodeEmoticons is now ready for use.", ToolTipIcon.None); }
private static BamlDocument GetResourceBamlDocument(string filename) { Application.ResourceAssembly = Assembly.GetExecutingAssembly(); var streamInfo = Application.GetResourceStream(new Uri("/Resources/BamlGeneration/GenericXaml/" + filename, UriKind.Relative)); var expectedBamlDocument = BamlReader.ReadDocument(streamInfo.Stream); return(expectedBamlDocument); }
private SystemTray() { Ni = new System.Windows.Forms.NotifyIcon(); Stream iconStream = Application.GetResourceStream(new Uri("pack://application:,,,/StikyNotes;component/MyLogo.ico")).Stream; Ni.Icon = new System.Drawing.Icon(iconStream); Ni.Visible = true; Ni.MouseClick += Ni_MouseClick; }
private void SetTrayIcon(string resourcePath) { var iconInfo = Application.GetResourceStream(new Uri(resourcePath, UriKind.Relative)); if (iconInfo != null) { using (var iconStream = iconInfo.Stream) { _trayNotifier.Icon = new System.Drawing.Icon(iconStream); } } }
public void Initialize() { mp = new MediaPlayer(); timer.Tick += new EventHandler(timer_Tick); timer.Interval = TimeSpan.FromSeconds(3); timer.Start(); const string iconUri = "pack://application:,,,/KanColleViewer;Component/Assets/app.ico"; Uri uri; if (!Uri.TryCreate(iconUri, UriKind.Absolute, out uri)) { return; } var streamResourceInfo = Application.GetResourceStream(uri); if (streamResourceInfo == null) { return; } using (var stream = streamResourceInfo.Stream) { this.notifyIcon = new NotifyIcon { Text = App.ProductInfo.Title, Icon = new Icon(stream), }; ContextMenu menu = new ContextMenu(); MenuItem closeItem = new MenuItem(); closeItem.Text = "退出 KanColleViewer(强制)"; closeItem.Click += new EventHandler(delegate { Process[] killprocess = Process.GetProcessesByName("KanColleViewer"); foreach (Process p in killprocess) { p.Kill(); } }); MenuItem addItem = new MenuItem(); addItem.Text = "关闭计算机"; addItem.Click += new EventHandler(delegate { Process.Start("shutdown.exe", "-s -t 00"); }); menu.MenuItems.Add(addItem); menu.MenuItems.Add(closeItem); notifyIcon.ContextMenu = menu; } }
private System.Drawing.Image GetImage(string resourcePath) { var iconInfo = Application.GetResourceStream(new Uri(resourcePath, UriKind.Relative)); if (iconInfo != null) { using (var iconStream = iconInfo.Stream) { return(System.Drawing.Image.FromStream(iconStream)); } } return(null); }
private static byte[] GetFontBytes(string fontFile) { var streamInfo = Application.GetResourceStream( //cf: http://stackoverflow.com/questions/6005398/uriformatexception-invalid-uri-invalid-port-specified new Uri($"{PackUriHelper.UriSchemePack}://application:,,,/FontAwesome.Sharp;component/fonts/{fontFile}", UriKind.Absolute)); // ReSharper disable once PossibleNullReferenceException using (streamInfo.Stream) { return(ReadAllBytes(streamInfo.Stream)); } }
private static byte[] GetFontBytes(string fontFile, Assembly assembly = null, string path = "fonts") { var safeAssembly = assembly ?? typeof(FormsIconHelper).Assembly; var relativeUri = new Uri($"./{safeAssembly.GetName().Name};component/{path}/{fontFile}", UriKind.Relative); var uri = new Uri(IconHelper.BaseUri, relativeUri); var streamInfo = Application.GetResourceStream(uri); // ReSharper disable once PossibleNullReferenceException using (streamInfo.Stream) { return(ReadAllBytes(streamInfo.Stream)); } }
private static NotifyIcon CreateIcon() => new NotifyIcon { Text = "AppleWirelessKeyboard", Icon = new Icon(Application .GetResourceStream( new Uri("pack://application:,,,/Gnome-Preferences-Desktop-Keyboard-Shortcuts.ico"))?.Stream), Visible = true, ContextMenu = new ContextMenu(new[] { new MenuItem(TranslationService.Default.Configure, TriggerConfigure), new MenuItem(TranslationService.Default.Restart, TriggerRestart), new MenuItem(TranslationService.Default.RefreshConnection, TriggerRefresh), new MenuItem(TranslationService.Default.Exit, TriggerExit) }) };
/// <summary> /// Setups the notify icon. /// </summary> private void SetupNotifyIcon() { var icon = new Icon( Application.GetResourceStream( new Uri("Resources/record_icon.ico", UriKind.Relative)).Stream); this.notifyIcon = new NotifyIconViewModel(icon); this.notifyIcon.ShowBalloonTip( 7000, "ScreenGun", "When recording, click this icon to stop.", ToolTipIcon.Info); this.notifyIcon.LeftClicked += (sender, args) => this.StopRecording(); }
// Credits to someone, if you are hte creator and wish to be credited then contact me public static void LoadFlash(AxShockwaveFlash FlashObj, string Path) { StreamResourceInfo resource = Application.GetResourceStream(new Uri(Path, UriKind.Relative)); using (resource.Stream) { if (resource.ContentType != "application/x-shockwave-flash") { throw new FileFormatException("Path must be a valid swf."); } byte[] data = new byte[resource.Stream.Length]; resource.Stream.Read(data, 0, ( int )resource.Stream.Length); LoadFlash(FlashObj, data); } }
/// <inheritdoc /> /// <summary> /// Performs any required setup /// </summary> /// <param name="token">The cancellation token</param> /// <returns> /// A task, that when complete, will indicate the completion of the setup process /// </returns> public Task Setup(CancellationToken token) { using (var stream = Application.GetResourceStream(new Uri(@"pack://application:,,,/" + Assembly.GetExecutingAssembly().GetName().Name + ";component/" + "quicklogo.ico", UriKind.Absolute)).Stream) { Icon = new NotifyIcon { Icon = new Icon(stream), Visible = true, ContextMenu = new ContextMenu() }; Application.Current.Exit += (sender, args) => { Icon.Dispose(); }; var exitMenuItem = new MenuItem(); exitMenuItem.Text = "Exit"; exitMenuItem.Click += (sender, args) => Application.Current.Shutdown(0); Icon.ContextMenu.MenuItems.Add(exitMenuItem); return(Task.CompletedTask); } }
public AppNotifyIcon() { notifyIcon.Icon = Icon.FromHandle(new Bitmap(Application.GetResourceStream(new Uri("pack://application:,,,/img/logo32.png")).Stream).GetHicon()); notifyIcon.ContextMenu = CreateContextMenu(); notifyIcon.Visible = true; }