Example #1
0
        public string ExtractText()
        {
            var text = WindowUtils.ExtractTextFromConsoleWindow(ProcessId);

            text = text ?? WindowUtils.ExtractTextFromWindow(Handle);
            return(text);
        }
 private void Window_Loaded(object sender, RoutedEventArgs e)
 {
     WindowUtils.HideWindowFromAltTab(this);
     this.IsEnabled = true;
     // This activates fade-in
     this.hideTimer.Start();
 }
Example #3
0
    protected override void OnHandleCreated(EventArgs e)
    {
        // Use e.g. Color.FromArgb(128, Color.Lime) for a 50% opacity green tint.
        WindowUtils.EnableAcrylic(this, Color.Transparent);

        base.OnHandleCreated(e);
    }
 public LoginWindow()
 {
     InitializeComponent();
     HideIconAndTitle              = true;
     Translations.LanguageChanged += (s, e) => WindowUtils.Translate(this);
     _ = ProcessQRCode();
 }
Example #5
0
        private void Shell_Closing(object sender, System.ComponentModel.CancelEventArgs e)
        {
            if (SettingsClient.Get <bool>("Behaviour", "ShowTrayIcon") &
                SettingsClient.Get <bool>("Behaviour", "CloseToTray") &
                !this.isShuttingDown)
            {
                e.Cancel = true;

                // Minimize first, then hide from Taskbar. Otherwise a small window
                // remains visible in the lower left corner of the screen.
                this.WindowState = WindowState.Minimized;

                // When closing to tray, hide this window from Taskbar and ALT-TAB menu.
                this.ShowInTaskbar = false;

                try
                {
                    WindowUtils.HideWindowFromAltTab(this);
                }
                catch (Exception ex)
                {
                    LogClient.Error("Could not hide main window from ALT-TAB menu. Exception: {0}", ex.Message);
                }
            }
            else
            {
                if (this.mustPerformClosingTasks)
                {
                    e.Cancel = true;
                    this.PerformClosingTasksAsync();
                }
            }
        }
Example #6
0
        public override IEnumerable <Item> Perform(IEnumerable <Item> items, IEnumerable <Item> modItems)
        {
            IScreenItem screen = modItems.First() as IScreenItem;

            IEnumerable <Window> windows = null;

            if (items.First() is IApplicationItem)
            {
                windows = items.Cast <IApplicationItem> ().SelectMany(app => WindowUtils.WindowListForCmd(app.Exec));
            }
            else if (items.First() is IWindowItem)
            {
                windows = items.Cast <IWindowItem> ().SelectMany(wi => wi.Windows);
            }

            if (windows != null)
            {
                foreach (Wnck.Window window in windows)
                {
                    screen.Viewport.MoveWindowInto(window);
                }
            }

            return(null);
        }
Example #7
0
        private void UpdateBlur()
        {
            if (AssociatedObject == null)
            {
                return;
            }

            var windowHelper = new WindowInteropHelper(AssociatedObject);

            if (AssociatedObject.IsActive || KeepBlurEffectWhenInactive)
            {
                var a = Background.A;
                var r = Background.R;
                var g = Background.G;
                var b = Background.B;

                WindowUtils.EnableBlur(windowHelper, a, r, g, b);

                AssociatedObject.Background = BlurUtilBackground;
            }
            else
            {
                AssociatedObject.Background = _originalBackground;
                WindowUtils.DisableBlur(windowHelper);
            }
        }
Example #8
0
        /// Return true if Input is Valid
        public bool ValidateInput()
        {
            // Check NULL Username
            if (Username == "" || Username == null)
            {
                WindowUtils.Shake(this, 2);
                Glue.Dialogs.MessageError("Invalid UserName",
                                          "Please Set Your UserName, Null Username Found");
                return(false);
            }

            // If Insecure Authentication Mode Return Input OK
            if (SecureAuthentication == false)
            {
                return(true);
            }

            // Check NULL Password
            if (Password == "" || Password == null)
            {
                WindowUtils.Shake(this, 2);
                Glue.Dialogs.MessageError("Invalid Password",
                                          "Please Set Your Password, Null Password Found");
                return(false);
            }

            return(true);
        }
Example #9
0
        /// Check Login, Return null if Login failed
        public UserInfo CheckLogin()
        {
            MyInfo.Initialize(Username, SecureAuthentication);

            if (SecureAuthentication == false)
            {
                return(MyInfo.GetInstance());
            }

            // Login Progress Dialog
            LoginProgressDialog dialog   = new LoginProgressDialog(Password);
            ResponseType        response = (ResponseType)dialog.Run();
            string responseMsg           = dialog.ResponseMessage;

            dialog.Destroy();

            // Login OK
            if (response == ResponseType.Ok)
            {
                return(MyInfo.GetInstance());
            }

            WindowUtils.Shake(this, 2);
            if (responseMsg != null)
            {
                Glue.Dialogs.MessageError("Login Error", responseMsg);
            }
            return(null);
        }
 public DemoBTCNotice()
 {
     InitializeComponent();
     Translations.LanguageChanged += (s, e) => WindowUtils.Translate(this);
     BtcTextValidation();
     Closing += DemoBTCNotice_Closing;
 }
        public CustomConfigDataWindow()
        {
            InitializeComponent();
            WindowUtils.RemoveDefaultResourceDictionary(this);

            this.DataContext = this;
        }
Example #12
0
        //全屏录制状态修改
        public void SwitchFullScreen()
        {
            if (toggle_fullscreen.Checked != Settings.fullscreen)
            {
                toggle_fullscreen.Checked = Settings.fullscreen;
            }
            if (formSettings != null && formSettings.check_fullscreen.Checked != Settings.fullscreen)
            {
                if (Settings.fullscreen)
                {
                    formSettings.check_fullscreen.Checked = true;
                    formSettings.radio_rect_rec.Checked   = false;
                }
                else
                {
                    formSettings.check_fullscreen.Checked = false;
                    formSettings.radio_rect_rec.Checked   = true;
                }
            }

            formRecMini.TopMost = !Settings.fullscreen;
            if (Recorder.State != Recorder.Record_State.RECORDING && Recorder.State != Recorder.Record_State.SUSPENDED)
            {
                if (!Settings.fullscreen)
                {
                    WindowUtils.Show(formRect.Handle);
                    formRect.Invalidate();
                }
                else
                {
                    WindowUtils.Hide(formRect.Handle);
                }
            }
        }
Example #13
0
        //停止录制按钮
        public void btn_stop_BtnClick(object sender, EventArgs e)
        {
            if (Recorder.State == Recorder.Record_State.RECORDING ||
                Recorder.State == Recorder.Record_State.SUSPENDED)
            {
                Recorder.StopButton();
                recoder_update(Recorder.UpdateCallbackID.OnStop, IntPtr.Zero);
            }
            //结束之后对话框提示
            if (Settings.notify_when_finish && !exit)
            {
                TimeSpan ts = new TimeSpan(0, 0, Recorder.Duration);
                if (!WindowUtils.IsVisible(Handle))
                {
                    if (WindowState == FormWindowState.Minimized)
                    {
                        WindowState = FormWindowState.Normal;
                    }
                    WindowUtils.Show(Handle);
                }

                lb_reced_info.Text = "视频时长:" + ts.Hours.ToString("0") +
                                     ":" + ts.Minutes.ToString("00") + ":" + ts.Seconds.ToString("00") +
                                     "\n视频名称:" + System.IO.Path.GetFileName(Recorder.GetLastOutFileName());
                pl_rec_finish.Show();
            }
        }
Example #14
0
        //截图按钮
        private void btn_screen_shotcut_BtnClick(object sender, EventArgs e)
        {
            if (Recorder.State == Recorder.Record_State.NOT_BEGIN)
            {
                WindowUtils.Hide(Handle);
                if (!Settings.fullscreen)
                {
                    WindowUtils.Hide(formRect.Handle);
                }

                if (formScreenShutcut == null)
                {
                    formScreenShutcut = new FormScreenShutcut();
                    formScreenShutcut.Show(this);
                    formScreenShutcut.FormClosed += (object sender2, FormClosedEventArgs e2) =>
                    {
                        WindowUtils.Show(Handle);
                        if (!Settings.fullscreen)
                        {
                            WindowUtils.Show(formRect.Handle);
                        }
                        Invalidate();

                        formScreenShutcut = null;
                    };
                }
                else
                {
                    WindowUtils.Show(formScreenShutcut.Handle);
                    WindowUtils.SetForeground(formScreenShutcut.Handle);
                }
            }
        }
Example #15
0
        public NotificationDialog(int iconCharCode, int iconSize, string title, string content, string okText, bool showViewLogs, string viewLogsText) : base()
        {
            InitializeComponent();

            this.TitleBarHeight = Constants.DefaultWindowButtonHeight + 10;
            this.Icon.Text      = char.ConvertFromUtf32(iconCharCode);
            this.Icon.FontSize  = iconSize;
            this.Title          = title;
            //Me.TextBlockTitle.Text = iTitle.ToUpper
            this.TextBlockTitle.Text    = title;
            this.TextBlockContent.Text  = content;
            this.ButtonOK.Content       = okText;
            this.ButtonViewLogs.Content = viewLogsText;

            if (showViewLogs)
            {
                this.ButtonViewLogs.Visibility = Visibility.Visible;
            }
            else
            {
                this.ButtonViewLogs.Visibility = Visibility.Collapsed;
            }

            WindowUtils.CenterWindow(this);
        }
Example #16
0
        public SettingsWindow()
        {
            this.AppInstance = App.Instance;

            InitializeComponent();
            WindowUtils.RemoveDefaultResourceDictionary(this, Config.Default.DefaultGlobalizationFile);
        }
Example #17
0
 public WindowItemSource()
 {
     WindowUtils.Initialize();
     items = new List <Item> ();
     items.Add(new CurrentApplicationItem());
     items.Add(new CurrentWindowItem());
 }
Example #18
0
        public static bool Set(SetOptions op)
        {
            //Attempt to grab any window that matches
            IntPtr wndHandle = WindowUtils.FindWindowByTitle(op.windowName);

            if (wndHandle == IntPtr.Zero)
            {
                wndHandle = WindowUtils.FindWindowByClass(op.className);
            }

            //Fail early if we didn't find anything
            if (wndHandle == IntPtr.Zero)
            {
                Console.Error.WriteLine("Failed to find matching window.");
                return(false);
            }

            int x = 0, y = 0, w = 0, h = 0;

            parseBounds(op.bounds, out x, out y, out w, out h);

            //Set the wallpaper
            bool succesful = new WallpaperManager().SetWallpaper(wndHandle, x, y, w, h);

            if (!succesful)
            {
                Console.Error.WriteLine("Failed to set wallpaper");
            }

            return(succesful);
        }
Example #19
0
 private void FormChooseWindow_Load(object sender, EventArgs e)
 {
     //设置本窗口全屏
     screenWidth                      = API.GetSystemMetrics(API.SM_CXSCREEN);
     screenHeight                     = API.GetSystemMetrics(API.SM_CYSCREEN);
     Location                         = Point.Empty;
     Size                             = new Size(screenWidth, screenHeight);
     stringFormatCenter               = new StringFormat();
     stringFormatCenter.Alignment     = StringAlignment.Center;
     stringFormatCenter.LineAlignment = StringAlignment.Center;
     bitmapBg                         = new Bitmap(screenWidth, screenHeight, System.Drawing.Imaging.PixelFormat.Format32bppArgb);
     bitmapDrawingBoard               = new Bitmap(screenWidth, screenHeight, System.Drawing.Imaging.PixelFormat.Format32bppArgb);
     //截下桌面的图,然后作为背景进行绘画
     using (Graphics g = Graphics.FromImage(bitmapBg))
         g.CopyFromScreen(Point.Empty, Point.Empty, new Size(screenWidth, screenHeight));
     timer1.Start();
     rectPen       = new Pen(Color.DodgerBlue, 5);
     brushBg       = new SolidBrush(Color.FromArgb(100, 0, 0, 0));
     formColorPick = new FormColorPick(this);
     formColorPick.Show();
     formColorPick.KeyDown  += FormScreenShutcut_KeyDown;
     formEditScreenShutTools = new FormEditScreenShutTools(this);
     formEditScreenShutTools.Show();
     Cursor   = formEditScreenShutTools.cur_default;
     paintBox = new PaintBox.PaintBox(this, formEditScreenShutTools);
     WindowUtils.Top(Handle);
     WindowUtils.Hide(formEditScreenShutTools.Handle);
     WindowUtils.Top(formColorPick.Handle);
 }
Example #20
0
 private void FormRect_EnabledChanged(object sender, EventArgs e)
 {
     if (!Enabled)
     {
         TopMost = false;
         WindowUtils.Bottom(Handle);
         label1.BackColor      = Color.Gray;
         label2.BackColor      = Color.Gray;
         label3.BackColor      = Color.Gray;
         label4.BackColor      = Color.Gray;
         pictureBox1.BackColor = Color.Gray;
         BaseColor             = Color.Gray;
         Invalidate();
     }
     else
     {
         TopMost = true;
         WindowUtils.Top(Handle);
         label1.BackColor      = Color.Red;
         label2.BackColor      = Color.Red;
         label3.BackColor      = Color.Red;
         label4.BackColor      = Color.Red;
         pictureBox1.BackColor = Color.Red;
         BaseColor             = Color.Red;
         Invalidate();
     }
 }
        public MainWindow()
        {
            InitializeComponent();

            _vm   = this.AssertViewModel <MainVM>();
            Title = ApplicationStateManager.Title;

            base.SizeChanged += new SizeChangedEventHandler(this.OnSizeChangedSave);

            Translations.LanguageChanged += (s, e) => WindowUtils.Translate(this);
            LoadingBar.Visibility         = Visibility.Visible;
            Topmost = GUISettings.Instance.GUIWindowsAlwaysOnTop;
            CustomDialogManager.MainWindow = this;
            SetBurnCalledAction();
            SetNoDeviceAction();
            _timer.Interval = 1000 * 60 * 2; //2min
            _timer.Elapsed += CheckConnection;
            _timer.Start();

            if (GUISettings.Instance.MainFormSize != System.Drawing.Size.Empty)
            {
                this.Width  = GUISettings.Instance.MainFormSize.Width;
                this.Height = GUISettings.Instance.MainFormSize.Height;
            }
        }
Example #22
0
        public PlayerServiceImpl(Window window)
        {
            dataProviders = new DataProviderFactoryManager();
            dataProviders.RegisterDataProviderFactory(new DashDataProviderFactory());
            dataProviders.RegisterDataProviderFactory(new HLSDataProviderFactory());
            dataProviders.RegisterDataProviderFactory(new RTSPDataProviderFactory());

            var drmManager = new DrmManager();

            drmManager.RegisterDrmHandler(new CencHandler());

            if (window == null)
            {
                window = WindowUtils.CreateElmSharpWindow();
            }
            var player = new EsPlayer(window);

            playerController = new PlayerController(player, drmManager);

            subscriptions = new CompositeDisposable
            {
                playerController.StateChanged()
                .Subscribe(state => { State = state; }, SynchronizationContext.Current)
            };
        }
Example #23
0
        public static void StartPythonScreenCapture(IntPtr windowHandle)
        {
            var applicationPosition = WindowUtils.GetWindowPosition(windowHandle);

            string ARGS_FOR_PYTHON_SCREEN_CAPTURE = applicationPosition.Left + " "
                                                    + applicationPosition.Top + " "
                                                    + applicationPosition.Width + " "
                                                    + applicationPosition.Height
            ;

            var t = new Thread(
                () =>
            {
                ProcessStartInfo start       = new ProcessStartInfo();
                start.FileName               = PATH_TO_PYTHON_EXE;
                start.Arguments              = string.Format("{0} {1}", PATH_TO_PYTHON_SCREEN_CAPTURE, ARGS_FOR_PYTHON_SCREEN_CAPTURE);
                start.UseShellExecute        = false;
                start.RedirectStandardOutput = false;

                var process = Process.Start(start);
                _startedProcesses.Add(process);

                //using (Process process = Process.Start(start))
                //{
                //    using (StreamReader reader = process.StandardOutput)
                //    {
                //        string result = reader.ReadToEnd(); // not used
                //        Console.Write(result); // not used
                //    }
                //}
            });

            t.IsBackground = true;
            t.Start();
        }
        public CommandLineWindow(string commandLine)
        {
            InitializeComponent();
            WindowUtils.RemoveDefaultResourceDictionary(this, Config.Default.DefaultGlobalizationFile);

            this.DataContext = commandLine;
        }
 public ComputeDeviceItem()
 {
     InitializeComponent();
     DataContextChanged += ComputeDeviceItem_DataContextChanged;
     //DataContext = this;
     WindowUtils.Translate(this);
 }
        public PluginWindow()
        {
            InitializeComponent();

            _vm = this.AssertViewModel <PluginVM>();
            WindowUtils.InitWindow(this);
        }
Example #27
0
        private void OnMouseMove(object sender, MouseEventArgs e)
        {
            if (!IsDragging || e.LeftButton != MouseButtonState.Pressed)
            {
                if (popup.IsOpen)
                {
                    popup.IsOpen = false;
                }
                return;
            }

            // display the popup if it hasn't been opened yet
            if (!popup.IsOpen)
            {
                // switch to read-only mode
                ModDetailsGrid.IsReadOnly = true;

                // make sure the popup is visible
                popup.IsOpen = true;
            }

            var popupSize = new Size(popup.ActualWidth, popup.ActualHeight);

            popup.PlacementRectangle = new Rect(e.GetPosition(this), popupSize);

            // make sure the row under the grid is being selected
            var position = e.GetPosition(ModDetailsGrid);
            var row      = WindowUtils.TryFindFromPoint <DataGridRow>(ModDetailsGrid, position);

            if (row != null)
            {
                ModDetailsGrid.SelectedItem = row.Item;
            }
        }
        public AddUserWindow()
        {
            InitializeComponent();
            WindowUtils.RemoveDefaultResourceDictionary(this, Config.Default.DefaultGlobalizationFile);

            this.DataContext = this;
        }
Example #29
0
        public override void OnApplyTemplate()
        {
            foreach (var key in Enum.GetValues(typeof(ToggleButtonType)).Cast <ToggleButtonType>())
            {
                var name      = key.ToString();
                var tabButtom = GetRequiredTemplateChild <ToggleButton>(name);
                if (tabButtom == null)
                {
                    throw new Exception($"Template Missing ToggleButton with name '{name}'. Make sure your Sytle template contains ToggleButton with name '{name}'.");
                }
                tabButtom.Click    += TabButtonButton_Click;
                tabButtom.IsEnabled = false;
                if (HideInitTabButtonVisibility(name))
                {
                    tabButtom.Visibility = Visibility.Hidden;
                }
                WindowUtils.Translate(tabButtom.Content);
                Tabs[key] = tabButtom;
            }
            _gridLayoutRootOverlay = GetRequiredTemplateChild <Grid>("LayoutRootOverlay");
            _gridLayoutRootOverlay_MODAL_WINDOW             = GetRequiredTemplateChild <Grid>("MODAL_WINDOW_BLUR");
            _gridLayoutRootOverlay_MODAL_WINDOW_ContentGrid = GetRequiredTemplateChild <Grid>("MODAL_WINDOW_ContentGrid");

            _gridLayoutRootOverlay_MODAL_WINDOW_ContentGrid.MouseDown += _gridLayoutRootOverlay_MouseDown;
            _gridLayoutRootOverlay_MODAL_WINDOW.MouseDown             += _gridLayoutRootOverlay_MouseDown;
            _gridLayoutRootOverlay.MouseDown += _gridLayoutRootOverlay_MouseDown;

            _contentPresenter = GetRequiredTemplateChild <ContentPresenter>("MODAL_DIALOG");
            if (_contentPresenter != null)
            {
                _contentPresenter.AddHandler(Grid.MouseLeftButtonDownEvent, new MouseButtonEventHandler(this.OnHeaderBarMouseLeftButtonDown));
                _contentPresenter.Content = null;
            }
            base.OnApplyTemplate();
        }
Example #30
0
        public void SetTransparency(int percent)
        {
            var opacity = (byte)Math.Round(255 * (100 - percent) / 100f, MidpointRounding.AwayFromZero);

            WindowUtils.SetOpacity(Handle, opacity);
            State.Transparency = percent;
        }