GetResourceStream() 공개 정적인 메소드

public static GetResourceStream ( System.Windows.Resources.StreamResourceInfo zipPackageStreamResourceInfo, Uri uriResource ) : System.Windows.Resources.StreamResourceInfo
zipPackageStreamResourceInfo System.Windows.Resources.StreamResourceInfo
uriResource Uri
리턴 System.Windows.Resources.StreamResourceInfo
예제 #1
0
        private static void SetThumbnailTitleAndIcon(UIElement content, IControlView activeView)
        {
            if (!_initialized)
            {
                throw new Exception("Not initialized");
            }
            TabbedThumbnail thumbnail = TaskbarManager.Instance.TabbedThumbnail.GetThumbnailPreview(content);

            if (thumbnail != null && activeView != null)
            {
                if (thumbnail.Title != activeView.Header)  //Title is not set yet or sth has changed
                {
                    thumbnail.Title   = activeView.Header;
                    thumbnail.Tooltip = activeView.HeaderToolTip;
                    var streamResourceInfo = Application.GetResourceStream(activeView.HeaderIcon);
                    if (streamResourceInfo != null)
                    {
                        Stream iconStream = streamResourceInfo.Stream;
                        var    bitmap     = new Bitmap(iconStream);
                        var    iconHandle = bitmap.GetHicon();
                        var    icon       = Icon.FromHandle(iconHandle);
                        thumbnail.SetWindowIcon(icon);
                    }
                    RefreshPreview((Frame)content);
                }
            }
        }
        public MainWindow()
        {
            GameConfig = new GameConfig {
                Column       = 9,
                Row          = 15,
                ColorsNumber = 3,
                MinChain     = 5
            };

            _taskFactory = new TaskFactory();
            _tokenSource = new CancellationTokenSource();
            _token       = _tokenSource.Token;
            _gameLogger  = new Logger();

            InitializeComponent();

            //var uri = new Uri("pack://application:,,,/Resources/License.txt");
            var uri            = new Uri("../Resources/License.txt", UriKind.Relative);
            var resourceStream = Application.GetResourceStream(uri);

            using (var reader = new StreamReader(resourceStream.Stream)) {
                var text = reader.ReadToEnd();
                LicenseTextBox.Text = text;
            }
        }
예제 #3
0
        public MainWindow()
        {
            IsClose     = false;
            _notifyIcon = new NotifyIcon();
            _notifyIcon.MouseDoubleClick += NotifyIconOnMouseDoubleClick;
            var menuItem1 = new MenuItem
            {
                Index = 0,
                Text  = "Exit"
            };

            menuItem1.Click += MenuItem1OnClick;

            _notifyIcon.ContextMenu = new ContextMenu();
            _notifyIcon.ContextMenu.MenuItems.Add(menuItem1);
            Stream iconStream = Application.GetResourceStream(new Uri("pack://application:,,,/bCash;component/Resources/icon_.ico")).Stream;

            _notifyIcon.Icon    = new System.Drawing.Icon(iconStream);
            _notifyIcon.Visible = true;
            if (!ConfigManager.GeneralConfigIsFileExist())
            {
                Helpers.ConsolePrint("NICEHASH", "No config file found. Running NiceHash Miner for the first time. Choosing a default language.");
                var showDlg = new ChoosingLanguageWindow();
                showDlg.ShowDialog();
            }

            // Init languages
            International.Initialize(ConfigManager.GeneralConfig.Language);
            InitializeComponent();
            ((MainViewModel)DataContext).SetDialogCoordinator(DialogCoordinator.Instance);
        }
예제 #4
0
        public MainWindow()
        {
            InitializeComponent();

            Stream normalCursor = Application.GetResourceStream(new Uri("pack://application:,,,/img/cursors/wow.cur")).Stream;
            Stream readlCursor  = Application.GetResourceStream(new Uri("pack://application:,,,/img/cursors/WOW-ESCRIVIR.cur")).Stream;
            Stream hightlCursor = Application.GetResourceStream(new Uri("pack://application:,,,/img/cursors/WOW-ENLACE-CURSOR.cur")).Stream;

            //this.Cursor = new Cursor(_normalCursor);
            MainGrid.Cursor = new Cursor(normalCursor);
            version.Cursor  = new Cursor(hightlCursor);
            NewsBox.Cursor  = new Cursor(readlCursor);

            SetProgressType(Properties.Settings.Default.progressBarType);

            if (CheckForInternetConnection())
            {
                FileSync();
            }
            else
            {
                MessageBox.Show("Невозможно подключиться к сети интернет, проверьте ваше подключение и повторите попытку", "Ошибка подключения", MessageBoxButton.OK, MessageBoxImage.Error);
                Application.Current.Shutdown();
            }
        }
예제 #5
0
        public MainWindow()
        {
            InitializeComponent();

            Stream normalCursor = Application.GetResourceStream(new Uri("pack://application:,,,/img/cursors/wow.cur")).Stream;
            Stream readlCursor  = Application.GetResourceStream(new Uri("pack://application:,,,/img/cursors/WOW-ESCRIVIR.cur")).Stream;
            Stream hightlCursor = Application.GetResourceStream(new Uri("pack://application:,,,/img/cursors/WOW-ENLACE-CURSOR.cur")).Stream;

            //this.Cursor = new Cursor(_normalCursor);
            MainGrid.Cursor = new Cursor(normalCursor);
            version.Cursor  = new Cursor(hightlCursor);
            NewsBox.Cursor  = new Cursor(readlCursor);

            SetProgressType(Properties.Settings.Default.progressBarType);

            if (CheckForInternetConnection())
            {
                FileSync();
            }
            else
            {
                MessageBox.Show("No puede conectarse a Internet, verifique su conexión y vuelva a intentarlo.", " Error de conexión.", MessageBoxButton.OK, MessageBoxImage.Error);
                Application.Current.Shutdown();
            }
        }
예제 #6
0
        private void Window_Loaded(object sender, RoutedEventArgs e)
        {
            // ReSharper disable once PossibleNullReferenceException
            Stream iconstream = Application.GetResourceStream(new Uri("pack://*****:*****@"ClipBase",
                Visible     = true,
                ContextMenu = contextmenu
            };

            iconstream.Close();

            TaskBarIcon.MouseClick += quickIcon_MouseClick;

            Point screenposition = Win32.GetWindowPosition(TaskBarIcon, this.Width, this.Height, 96);

            this.Left = screenposition.X;
            this.Top  = screenposition.Y;

            Hide();

            InitCBViewer();
        }
예제 #7
0
        private void InitIcon()
        {
            Stream LoadIcon()
            {
                var streamResourceInfo = Application.GetResourceStream(
                    new Uri(
                        "pack://application:,,,/PunchCardApp;component/timer.ico"));

                if (streamResourceInfo == null)
                {
                    throw new Exception("could not load icon");
                }
                return(streamResourceInfo.Stream);
            }

            _notifyIcon.Icon = new Icon(LoadIcon());

            var contextMenu = new ContextMenu();

            AddInfoMenu(contextMenu);
            AddAutoStartMenu(contextMenu);
            AddPunchCardWorkMenu(contextMenu);


            AddCloseMenu(contextMenu);
            AddLogMenu(contextMenu);
            _notifyIcon.ContextMenu = contextMenu;
        }
예제 #8
0
        public MainWindow()
        {
            Hide();
            InitializeComponent();

            Left = SystemParameters.PrimaryScreenWidth - Width - 10;
            Top  = SystemParameters.PrimaryScreenHeight - Height - 50;

            ni             = new NotifyIcon();
            ni.Icon        = new Icon(Application.GetResourceStream(new Uri("pack://application:,,,/home.ico", UriKind.RelativeOrAbsolute)).Stream);
            ni.MouseClick += Ni_MouseClick;
            Closing       += OnClosing;

            Instance = this;

            user = SaveLoad.Load();
            if (user.Email == null)
            {
                Auth auth = new Auth();
            }
            else
            {
                OpenWindow();
            }

            thread = new Thread(SendingPost);
            thread.Start();
        }
예제 #9
0
        public MainWindow()
        {
            InitializeComponent();

            var normalCursor = Application.GetResourceStream(new Uri("pack://application:,,,/img/cursors/wow.cur"))?.Stream;
            var readlCursor  = Application.GetResourceStream(new Uri("pack://application:,,,/img/cursors/WOW-ESCRIVIR.cur"))?.Stream;
            var hightlCursor = Application.GetResourceStream(new Uri("pack://application:,,,/img/cursors/WOW-ENLACE-CURSOR.cur"))?.Stream;

            MainGrid.Cursor = new Cursor(normalCursor ?? throw new NullReferenceException("Не найден ресурс wow.cur"));
            version.Cursor  = new Cursor(hightlCursor ?? throw new NullReferenceException("Не найден ресурс WOW-ESCRIVIR.cur"));
            NewsBox.Cursor  = new Cursor(readlCursor ?? throw new NullReferenceException("Не найден ресурс WOW-ENLACE-CURSOR.cur"));

            SetProgressType(Properties.Settings.Default.ProgressBarType);

            Directory.CreateDirectory(AppRoamingPath);
            if (Utilities.Network.IsInternetConnectionAvailable())
            {
                FileSync();
            }
            else
            {
                MessageBox.Show("Невозможно подключиться к сети интернет, проверьте ваше подключение и повторите попытку", "Ошибка подключения", MessageBoxButton.OK, MessageBoxImage.Error);
                Application.Current.Shutdown();
            }
        }
예제 #10
0
        public void SetIcon(string icoPath)
        {
            Uri    iconUri        = GResourceUtility.GetUri(icoPath);
            Stream resourceStream = Application.GetResourceStream(iconUri).Stream;
            Icon   icon           = new Icon(resourceStream);

            SetIcon(icon);
        }
예제 #11
0
 private Icon LoadIcon(string name)
 {
     using var stream = Application.GetResourceStream(
               new Uri($"pack://application:,,,/icon/{name}.ico")
               ).Stream;
     return(new Icon(
                stream
                ));
 }
예제 #12
0
        /// <summary>
        /// Initializes a new instance of the <see cref="ShellView"/> class.
        /// </summary>
        public ShellView()
        {
            this.InitializeComponent();

            IUserSettingService userSettingService = IoC.Get <IUserSettingService>();
            bool minimiseToTray = userSettingService.GetUserSetting <bool>(UserSettingConstants.MainWindowMinimize);

            if (minimiseToTray)
            {
                this.notifyIcon             = new System.Windows.Forms.NotifyIcon();
                this.notifyIcon.ContextMenu = new ContextMenu(new[] { new MenuItem("Restore", NotifyIconClick) });

                StreamResourceInfo streamResourceInfo = Application.GetResourceStream(new Uri("pack://application:,,,/handbrakepineapple.ico"));
                if (streamResourceInfo != null)
                {
                    Stream iconStream = streamResourceInfo.Stream;
                    this.notifyIcon.Icon = new System.Drawing.Icon(iconStream);
                }
                this.notifyIcon.DoubleClick += this.NotifyIconClick;
                this.StateChanged           += this.ShellViewStateChanged;
            }

            // Start Encode (Ctrl+S)
            // Stop Encode (Ctrl+K)
            // Open Log Window (Ctrl+L)
            // Open Queue Window (Ctrl+Q)
            // Add to Queue (Ctrl+A)
            // Scan a File (Ctrl+F)
            // Scan a Folder (Ctrl+R)
            // Show CLI Query (Ctrl+Shift+D)

            this.InputBindings.Add(new InputBinding(new ProcessShortcutCommand(new KeyGesture(Key.S, ModifierKeys.Control)), new KeyGesture(Key.S, ModifierKeys.Control)));
            this.InputBindings.Add(new InputBinding(new ProcessShortcutCommand(new KeyGesture(Key.K, ModifierKeys.Control)), new KeyGesture(Key.K, ModifierKeys.Control)));
            this.InputBindings.Add(new InputBinding(new ProcessShortcutCommand(new KeyGesture(Key.L, ModifierKeys.Control)), new KeyGesture(Key.L, ModifierKeys.Control)));
            this.InputBindings.Add(new InputBinding(new ProcessShortcutCommand(new KeyGesture(Key.Q, ModifierKeys.Control)), new KeyGesture(Key.Q, ModifierKeys.Control)));
            this.InputBindings.Add(new InputBinding(new ProcessShortcutCommand(new KeyGesture(Key.A, ModifierKeys.Control)), new KeyGesture(Key.A, ModifierKeys.Control)));
            this.InputBindings.Add(new InputBinding(new ProcessShortcutCommand(new KeyGesture(Key.F, ModifierKeys.Control)), new KeyGesture(Key.F, ModifierKeys.Control)));
            this.InputBindings.Add(new InputBinding(new ProcessShortcutCommand(new KeyGesture(Key.O, ModifierKeys.Control)), new KeyGesture(Key.O, ModifierKeys.Control)));
            this.InputBindings.Add(new InputBinding(new ProcessShortcutCommand(new KeyGesture(Key.R, ModifierKeys.Control)), new KeyGesture(Key.R, ModifierKeys.Control)));
            this.InputBindings.Add(new InputBinding(new ProcessShortcutCommand(new KeyGesture(Key.D, ModifierKeys.Control | ModifierKeys.Shift)), new KeyGesture(Key.D, ModifierKeys.Control | ModifierKeys.Shift)));
            this.InputBindings.Add(new InputBinding(new ProcessShortcutCommand(new KeyGesture(Key.G, ModifierKeys.Control | ModifierKeys.Shift)), new KeyGesture(Key.G, ModifierKeys.Control | ModifierKeys.Shift)));

            // Enable Windows 7 Taskbar progress indication.
            if (this.TaskbarItemInfo == null)
            {
                this.TaskbarItemInfo = Win7.WindowsTaskbar;
            }

            // Window Sizing
            if (AppArguments.IsInstantHandBrake)
            {
                this.SizeToContent = SizeToContent.WidthAndHeight;
                this.MinHeight     = 380;
                this.MinWidth      = 600;
            }
        }
예제 #13
0
        public MainWindow()
        {
            this.DataContext = new MainWindowViewModel();
            using (var iconStream = Application
                                    .GetResourceStream(new Uri("pack://application:,,,/VirtualGameMode;component/Resources/icon.ico"))
                                    ?.Stream)
            {
                _trayIcon = new NotifyIcon()
                {
                    Visible = true,
                    Icon    = new System.Drawing.Icon(iconStream)
                };
            }
            _trayIcon.DoubleClick += TrayIcon_DoubleClick;
            var menuItemShow = new System.Windows.Forms.ToolStripMenuItem()
            {
                Name = "Show/Hide",
                Text = Settings.Default.StartMinimized ? "Show" : "Minimize to tray"
            };

            menuItemShow.Click += (sender, args) =>
            {
                if (this.IsVisible)
                {
                    WindowState = WindowState.Minimized;
                }
                else
                {
                    this.Show();
                    this.WindowState = WindowState.Normal;
                }
            };
            var menuItemExit = new System.Windows.Forms.ToolStripMenuItem()
            {
                Name = "Exit",
                Text = "Exit"
            };

            menuItemExit.Click += (sender, args) => Application.Current.Shutdown();
            var contextMenu = new System.Windows.Forms.ContextMenuStrip();

            contextMenu.Items.Add(menuItemShow);
            contextMenu.Items.Add("-");
            contextMenu.Items.Add(menuItemExit);
            _trayIcon.ContextMenuStrip = contextMenu;
            if (Settings.Default.StartMinimized)
            {
                Hide();
                WindowState = WindowState.Minimized;
            }
            _mini              = new MiniWindow();
            _mini.Deactivated += MiniOnDeactivated;
            _trayIcon.Click   += TrayIconOnClick;
            Loaded            += MainWindow_Loaded;
        }
예제 #14
0
        /// <summary>
        /// Initializes a new instance of the <see cref="ShellView"/> class.
        /// </summary>
        public ShellView()
        {
            this.InitializeComponent();

            IUserSettingService userSettingService = IoC.Get <IUserSettingService>();
            bool minimiseToTray = userSettingService.GetUserSetting <bool>(UserSettingConstants.MainWindowMinimize);

            if (minimiseToTray)
            {
                INotifyIconService notifyIconService = IoC.Get <INotifyIconService>();
                this.notifyIcon             = new NotifyIcon();
                this.notifyIcon.ContextMenu = new ContextMenu(new[] { new MenuItem("Restore", NotifyIconClick), new MenuItem("Mini Status Display", ShowMiniStatusDisplay) });
                notifyIconService.RegisterNotifyIcon(this.notifyIcon);

                StreamResourceInfo streamResourceInfo = Application.GetResourceStream(new Uri("pack://application:,,,/handbrakepineapple.ico"));
                if (streamResourceInfo != null)
                {
                    Stream iconStream = streamResourceInfo.Stream;
                    this.notifyIcon.Icon = new Icon(iconStream);
                }

                this.notifyIcon.Click += this.NotifyIconClick;
                this.StateChanged     += this.ShellViewStateChanged;
            }

            this.InputBindings.Add(new InputBinding(new ProcessShortcutCommand(new KeyGesture(Key.E, ModifierKeys.Control)), new KeyGesture(Key.E, ModifierKeys.Control)));                                           // Start Encode
            this.InputBindings.Add(new InputBinding(new ProcessShortcutCommand(new KeyGesture(Key.K, ModifierKeys.Control)), new KeyGesture(Key.K, ModifierKeys.Control)));                                           // Stop Encode
            this.InputBindings.Add(new InputBinding(new ProcessShortcutCommand(new KeyGesture(Key.L, ModifierKeys.Control)), new KeyGesture(Key.L, ModifierKeys.Control)));                                           // Open Log Window
            this.InputBindings.Add(new InputBinding(new ProcessShortcutCommand(new KeyGesture(Key.Q, ModifierKeys.Control)), new KeyGesture(Key.Q, ModifierKeys.Control)));                                           // Open Queue Window
            this.InputBindings.Add(new InputBinding(new ProcessShortcutCommand(new KeyGesture(Key.A, ModifierKeys.Control)), new KeyGesture(Key.A, ModifierKeys.Control)));                                           // Add to Queue
            this.InputBindings.Add(new InputBinding(new ProcessShortcutCommand(new KeyGesture(Key.A, ModifierKeys.Alt)), new KeyGesture(Key.A, ModifierKeys.Alt)));                                                   // Add all to Queue
            this.InputBindings.Add(new InputBinding(new ProcessShortcutCommand(new KeyGesture(Key.A, ModifierKeys.Control | ModifierKeys.Shift)), new KeyGesture(Key.A, ModifierKeys.Control | ModifierKeys.Shift))); // Add selection to Queue

            this.InputBindings.Add(new InputBinding(new ProcessShortcutCommand(new KeyGesture(Key.O, ModifierKeys.Control)), new KeyGesture(Key.O, ModifierKeys.Control)));                                           // File Scan
            this.InputBindings.Add(new InputBinding(new ProcessShortcutCommand(new KeyGesture(Key.O, ModifierKeys.Alt)), new KeyGesture(Key.O, ModifierKeys.Alt)));                                                   // Scan Window
            this.InputBindings.Add(new InputBinding(new ProcessShortcutCommand(new KeyGesture(Key.O, ModifierKeys.Control | ModifierKeys.Shift)), new KeyGesture(Key.O, ModifierKeys.Control | ModifierKeys.Shift))); // Scan a Folder
            this.InputBindings.Add(new InputBinding(new ProcessShortcutCommand(new KeyGesture(Key.G, ModifierKeys.Control | ModifierKeys.Shift)), new KeyGesture(Key.G, ModifierKeys.Control | ModifierKeys.Shift))); // Garbage Colleciton
            this.InputBindings.Add(new InputBinding(new ProcessShortcutCommand(new KeyGesture(Key.F1, ModifierKeys.None)), new KeyGesture(Key.F1, ModifierKeys.None)));                                               // Help
            this.InputBindings.Add(new InputBinding(new ProcessShortcutCommand(new KeyGesture(Key.S, ModifierKeys.Control)), new KeyGesture(Key.S, ModifierKeys.Control)));                                           // Browse Destination

            // Tabs Switching
            this.InputBindings.Add(new InputBinding(new ProcessShortcutCommand(new KeyGesture(Key.D1, ModifierKeys.Control)), new KeyGesture(Key.D1, ModifierKeys.Control)));
            this.InputBindings.Add(new InputBinding(new ProcessShortcutCommand(new KeyGesture(Key.D2, ModifierKeys.Control)), new KeyGesture(Key.D2, ModifierKeys.Control)));
            this.InputBindings.Add(new InputBinding(new ProcessShortcutCommand(new KeyGesture(Key.D3, ModifierKeys.Control)), new KeyGesture(Key.D3, ModifierKeys.Control)));
            this.InputBindings.Add(new InputBinding(new ProcessShortcutCommand(new KeyGesture(Key.D4, ModifierKeys.Control)), new KeyGesture(Key.D4, ModifierKeys.Control)));
            this.InputBindings.Add(new InputBinding(new ProcessShortcutCommand(new KeyGesture(Key.D5, ModifierKeys.Control)), new KeyGesture(Key.D5, ModifierKeys.Control)));
            this.InputBindings.Add(new InputBinding(new ProcessShortcutCommand(new KeyGesture(Key.D6, ModifierKeys.Control)), new KeyGesture(Key.D6, ModifierKeys.Control)));
            this.InputBindings.Add(new InputBinding(new ProcessShortcutCommand(new KeyGesture(Key.D7, ModifierKeys.Control)), new KeyGesture(Key.D7, ModifierKeys.Control)));

            // Enable Windows 7 Taskbar progress indication.
            if (this.TaskbarItemInfo == null)
            {
                this.TaskbarItemInfo = Win7.WindowsTaskbar;
            }
        }
예제 #15
0
        private static Drawing.Icon FromImageSource(ImageSource icon)
        {
            if (icon == null)
            {
                return(null);
            }

            Uri iconUri = new Uri(icon.ToString());

            return(new Drawing.Icon(Application.GetResourceStream(iconUri).Stream));
        }
예제 #16
0
        public MainWindowView()
        {
            InitializeComponent();

            _icon = new NotifyIcon
            {
                Icon = new Icon(Application.GetResourceStream(new Uri("pack://application:,,,/Assets/Icons/Icon.ico")).Stream)
            };

            _icon.MouseDoubleClick += IconMouseDoubleClick;
        }
        private void WindowMain_Loaded(object sender, RoutedEventArgs e)
        {
            AeroGlassHelper.ExtendGlass(this, (int)windowContent.Margin.Left, (int)windowContent.Margin.Right, (int)windowContent.Margin.Top, (int)windowContent.Margin.Bottom);

            txtSSID.Text     = Settings.Default.SSID;
            txtPassword.Text = Settings.Default.Password;
            // Составляем список доступных коннектов
            FillSharedConnection(Settings.Default.SharedConnectionGuid);

            // This line is for testing purposes
            //panelConnections.Children.Add(new PeerDeviceView(new ConnectedPeer() { MacAddress = "AA-22-33-EE-EE-FF" }));

            var args   = Environment.GetCommandLineArgs();
            var minarg = (from a in args
                          where a.ToLowerInvariant().Contains("/min")
                          select a).FirstOrDefault();

            if (!string.IsNullOrEmpty(minarg))
            {
                WindowState   = WindowState.Minimized;
                ShowInTaskbar = false;
            }

            AddSystemMenuItems();

            _threadUpdateUI = new Thread(new ThreadStart(UpdateUIThread));
            _threadUpdateUI.Start();

            Closed += new EventHandler(WindowMain_Closed);

            // Show System Tray Icon
            var stream = Application.GetResourceStream(new Uri("/icons/virtualrouterdisabled.ico", UriKind.Relative)).Stream;
            var icon   = new System.Drawing.Icon(stream);

            _trayIcon      = new WpfNotifyIcon();
            _trayIcon.Icon = icon;
            _trayIcon.Show();
            _trayIcon.Text         = "Virtual Router (Disabled)";
            _trayIcon.DoubleClick += new EventHandler(TrayIcon_DoubleClick);

            var trayMenu = new ContextMenuStrip();

            trayMenu.Items.Add("&Manage Virtual Router...", null, new EventHandler(TrayIcon_Menu_Manage));
            trayMenu.Items.Add(new ToolStripSeparator());
            trayMenu.Items.Add("Check for &Updates...", null, new EventHandler(TrayIcon_Menu_Update));
            trayMenu.Items.Add("&About...", null, new EventHandler(TrayIcon_Menu_About));
            _trayIcon.ContextMenuStrip = trayMenu;

            StateChanged += new EventHandler(WindowMain_StateChanged);

            UpdateDisplay();
        }
예제 #18
0
        private void SetupNotifyIcon()
        {
            _notifyIcon      = new System.Windows.Forms.NotifyIcon();
            _notifyIcon.Text = "ILoveLucene v" + ProgramVersionInformation.Version;
            var imageUri = new Uri("/ILoveLucene;component/Images/1305540894_heart_magnifier.ico", UriKind.Relative);

            using (var stream = Application.GetResourceStream(imageUri).Stream)
            {
                _notifyIcon.Icon         = new System.Drawing.Icon(stream);
                _notifyIcon.DoubleClick += (sender, e) => ShowThisWindow();
                _notifyIcon.Visible      = true;
            }
        }
예제 #19
0
 private void InstallNewFiles(string resourceFolder)
 {
     foreach (string file in NEW_FILES)
     {
         using (Stream stream = Application.GetResourceStream(new Uri(resourceFolder + file)).Stream)
         {
             using (FileStream fileStream = File.Create(Path.Combine(_gamePath, file)))
             {
                 stream.CopyTo(fileStream);
             }
         }
     }
 }
예제 #20
0
        public MainWindow()
        {
            if (Properties.Settings.Default.OnlyOne)
            {
                if (Process.GetProcessesByName(Path.GetFileNameWithoutExtension(Assembly.GetEntryAssembly().Location)).Count() > 1)
                {
                    Process.GetCurrentProcess().Kill();                                                                                                                 //Only allow one instance of Bookpouch
                }
            }
            MW = this;
            var path = Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location);

            if (path != null)
            {
                Environment.CurrentDirectory = path; //Make sure the app's directory is correct, in case we launched via registry entry during boot
            }
            InitializeComponent();
            GenerateFilterPresetList();
            AllowDrop = true;
            Drop     += Add_OnDrop;

            if (Properties.Settings.Default.DebugOnStart)
            {
                DebugConsole.Open();
            }

            _trayIcon = new NotifyIcon
            {
                Icon    = new Icon(Application.GetResourceStream(new Uri("pack://application:,,,/Bookpouch;component/Img/BookPouch1.ico")).Stream),
                Visible = false,
                Text    = "Bookpouch"
            };

            _trayIcon.Click += (o, args) =>
            {
                Show();
                _trayIcon.Visible = false;
            };

            if (Environment.GetCommandLineArgs().Contains("-tray"))
            {
                Hide();
                _trayIcon.Visible = true;
            }

            if (Properties.Settings.Default.UsbAutoSync)
            {
                ReaderDetector.HookDectection();
            }
            //Start reader detection which automatically triggers UsbSync when the reader is connected to the pc
        }
예제 #21
0
        private void StartTrayTool()
        {
            var applicationName = Application.Current.MainWindow.Title;

            var contextMenuStrip = new ContextMenuStrip();

            contextMenuStrip.SuspendLayout();

            var exitToolStripMenuItem = new ToolStripMenuItem {
                Text = "Exit"
            };

            exitToolStripMenuItem.Click += (s, e) =>
            {
                actualClose = true;
                Close();
            };

            var openToolStripMenuItem = new ToolStripMenuItem {
                Text = $"Show {applicationName}..."
            };

            openToolStripMenuItem.Font   = new Font(openToolStripMenuItem.Font, openToolStripMenuItem.Font.Style | System.Drawing.FontStyle.Bold);
            openToolStripMenuItem.Click += RequestBringToFront;

            notifyIcon = new NotifyIcon
            {
                ContextMenuStrip = contextMenuStrip,
                Icon             = new Icon(Application.GetResourceStream(new Uri("pack://application:,,,/Hot Chocolate-96.ico")).Stream),
                Text             = applicationName,
                Visible          = true
            };
            notifyIcon.MouseClick += (s, e) =>
            {
                if ((e.Button & MouseButtons.Left) == MouseButtons.Left)
                {
                    BringToFront();
                }
            };

            contextMenuStrip.Items.AddRange(new ToolStripItem[]
            {
                openToolStripMenuItem,
                new ToolStripSeparator(),
                exitToolStripMenuItem
            });
            contextMenuStrip.Size = new System.Drawing.Size(179, 70);
            contextMenuStrip.ResumeLayout(false);
        }
예제 #22
0
        /// <summary>
        /// Initialise the passed values. (Simply set the correct fields of the class).
        /// </summary>
        /// <param name="title"><see cref="_title"/></param>
        /// <param name="iconResource"><see cref="_icon"/></param>
        /// <param name="doubleClick"><see cref="_doubleClick"/></param>
        /// <param name="items"><see cref="_items"/></param>
        protected virtual void Init(string title, string iconResource, EventHandler doubleClick, MenuItem[] items)
        {
            StreamResourceInfo streamResourceInfo = Application.GetResourceStream(new Uri(iconResource));

            if (streamResourceInfo == null)
            {
                throw new ArgumentException($@"Could not create a resource stream to {nameof(iconResource)}: {iconResource}. Is it really a resource in the format: pack://application:,,,/YourReferencedAssembly;component/YourPossibleSubFolder/YourResourceFile.ico",
                                            nameof(iconResource));
            }

            using (Stream iconStream = streamResourceInfo.Stream)
            {
                Init(title, new Icon(iconStream), doubleClick, items);
            }
        }
예제 #23
0
        private static IconBitmapDecoder loadIconFromResource(string iconName)
        {
            var stream = Application.GetResourceStream(
                new Uri("pack://application:,,,/TogglDesktop;component/Resources/" + iconName + ".ico"));

            if (stream == null)
            {
                throw new Exception("Icon resource not found");
            }

            return(new IconBitmapDecoder(
                       stream.Stream,
                       BitmapCreateOptions.None,
                       BitmapCacheOption.Default));
        }
예제 #24
0
        public void InitNotifyIcon()
        {
            // initialise code here
            _mNotifyIcon = new System.Windows.Forms.NotifyIcon
            {
                BalloonTipText  = @"The app has been minimized. Click the tray icon to show.",
                BalloonTipTitle = @"Easy Backup",
                Text            = @"Easy Backup",
                Icon            = new Icon(Application
                                           .GetResourceStream(new Uri("pack://application:,,,/Resources/Images/Icon_Sync01.ico"))
                                           ?.Stream ?? throw new InvalidOperationException())
            };

            ShowNotifyIcon();
            _mNotifyIcon.Click += _notifyIcon_Click;
        }
예제 #25
0
        NotifyIcon notifyIcon;  //托盘图标

        void Init_NotifyIcon()
        {
            notifyIcon      = new NotifyIcon();
            notifyIcon.Icon = new Icon(
                Application.GetResourceStream(
                    new Uri("Image/Printer_Ico.ico", UriKind.Relative)).Stream);//加载图标
            notifyIcon.Text    = "印兔打印机";
            notifyIcon.Visible = true;

            //鼠标右击事件
            MenuItem m1 = new MenuItem("退出");

            m1.Click += m1_click;
            MenuItem[] m = new MenuItem[] { m1 };
            notifyIcon.ContextMenu = new ContextMenu(m);
        }
예제 #26
0
        /// <summary>
        /// The set notify icon.
        /// </summary>
        private static void SetNotifyIcon()
        {
            notifyIcon              = new NotifyIcon();
            notifyIcon.DoubleClick += (s, args) => ShowMainWindow();
            var iconStream = Application.GetResourceStream(new Uri("pack://application:,,,/Resources/geometry.ico"));

            notifyIcon.Icon    = new Icon(iconStream?.Stream ?? throw new NullReferenceException());
            notifyIcon.Visible = true;

#if !DEBUG
            notifyIcon.BalloonTipIcon  = ToolTipIcon.Info;
            notifyIcon.BalloonTipTitle = "Bilgi";
            notifyIcon.BalloonTipText  = "ODM Mail senkronlayıcı çalışıyor";
            notifyIcon.ShowBalloonTip(3000);
#endif
            CreateContextMenu();
        }
        public BadgesWindow()
        {
            InitializeComponent();
            DataContextChanged += OnDataContextChanged;

            var icoUri     = new Uri("pack://application:,,,/CardIdleRemastered;component/CardIdle.ico");
            var iconStream = Application.GetResourceStream(icoUri).Stream;

            _ni = new NotifyIcon
            {
                Icon    = new System.Drawing.Icon(iconStream),
                Text    = "Card Idle",
                Visible = false
            };

            _ni.DoubleClick += ExpandWindow;
        }
        private static TaskbarIcon CreateIcon()
        {
            var contextMenu = new ContextMenu();

            var mnuConfigure = new MenuItem()
            {
                Header = TranslationService.Default.Configure
            };

            mnuConfigure.Click += TriggerConfigure;
            contextMenu.Items.Add(mnuConfigure);

            var mnuRestart = new MenuItem()
            {
                Header = TranslationService.Default.Restart
            };

            mnuRestart.Click += TriggerRestart;
            contextMenu.Items.Add(mnuRestart);

            var mnuRefresh = new MenuItem()
            {
                Header = TranslationService.Default.RefreshConnection
            };

            mnuRefresh.Click += TriggerRefresh;
            contextMenu.Items.Add(mnuRefresh);

            var mnuExit = new MenuItem()
            {
                Header = TranslationService.Default.Exit
            };

            mnuExit.Click += TriggerExit;
            contextMenu.Items.Add(mnuExit);

            var icon = Application.GetResourceStream(new Uri("pack://application:,,,/Gnome-Preferences-Desktop-Keyboard-Shortcuts.ico"))?.Stream;

            return(new TaskbarIcon
            {
                ToolTipText = "AppleWirelessKeyboard",
                Icon = icon != null ? new Icon(icon) : null,
                Visibility = Visibility.Collapsed,
                ContextMenu = contextMenu
            });
        }
예제 #29
0
        /// <summary>
        ///     Włącz/Wyłącz bota
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void ToggleBot(object sender, RoutedEventArgs e)
        {
            // Czy {_botThread} jest uruchomiony?
            if (_factory != null)
            {
                // Usuń event otrzymania wiadomości
                MainWindow.Skype.MessageStatus -= Skype_MessageRecieved;

                // Oczyszczanie pamięci
                _factory = null;
                _bot     = null;
                _botSessions.Clear();
                _botIds.Clear();
                _lastMsg.Clear();
                _sessions     = 0;
                _messagesSent = 0;

                // Zaktualizuj przycisk
                var resourceUri = new Uri("Resources/Toggle Off-96.png", UriKind.Relative);
                var streamInfo  = Application.GetResourceStream(resourceUri);
                var temp        = BitmapFrame.Create(streamInfo.Stream);
                var brush       = new ImageBrush();
                brush.ImageSource = temp;

                (sender as Button).Background = brush;

                // Zaktualizuj statystyki
                statisticsSessions.Text = _sessions.ToString();
                statisticsSent.Text     = _messagesSent.ToString();
            }
            else
            {
                // Uruchom bot-a
                EnableBot();

                // Zaktualizuj przycisk
                var resourceUri = new Uri("Resources/Toggle On-96.png", UriKind.Relative);
                var streamInfo  = Application.GetResourceStream(resourceUri);
                var temp        = BitmapFrame.Create(streamInfo.Stream);
                var brush       = new ImageBrush();
                brush.ImageSource = temp;

                (sender as Button).Background = brush;
            }
        }
예제 #30
0
        /// <summary>
        /// The create context menu.
        /// </summary>
        private static void CreateContextMenu()
        {
            var mailSynchronizer = container.GetService <MailSynchronizer>();

            notifyIcon.ContextMenuStrip = new ContextMenuStrip();
            var showButton = notifyIcon.ContextMenuStrip.Items.Add("Göster");

            showButton.Click += (s, e) => ShowMainWindow();
            showButton.Image  = Image.FromStream(Application.GetResourceStream(new Uri("pack://application:,,,/Resources/eye.png"))?.Stream);

            notifyIcon.ContextMenuStrip.Items.Add(new ToolStripSeparator());

            var start = notifyIcon.ContextMenuStrip.Items.Add("Başlat");

            start.Click += (s, e) => { mailSynchronizer.Start(); };
            start.Image  = Image.FromStream(Application.GetResourceStream(new Uri("pack://application:,,,/Resources/play-circle.png"))?.Stream);

            var stop = notifyIcon.ContextMenuStrip.Items.Add("Durdur");

            stop.Click += (s, e) => mailSynchronizer.Stop();
            stop.Image  = Image.FromStream(Application.GetResourceStream(new Uri("pack://application:,,,/Resources/stop-circle.png"))?.Stream);

            notifyIcon.ContextMenuStrip.Items.Add(new ToolStripSeparator());

            var exitButton = notifyIcon.ContextMenuStrip.Items.Add("Çıkış");

            exitButton.Click += (s, e) => ExitApplication();
            exitButton.Image  = Image.FromStream(Application.GetResourceStream(new Uri("pack://application:,,,/Resources/exit-to-app.png"))?.Stream);

            mailSynchronizer.WhenChanged(synchronizer => synchronizer.IsStarted,
                                         (synchronizer, b) => b)
            .Subscribe(b =>
            {
                if (b)
                {
                    start.Enabled = false;
                    stop.Enabled  = true;
                }
                else
                {
                    start.Enabled = true;
                    stop.Enabled  = false;
                }
            });
        }