private static bool SetBackgroundBmp(string filename)
        {
#if !__MonoCS__
            var spif = SPIF.SPIF_SENDCHANGE | SPIF.SPIF_UPDATEINIFILE | SPIF.SPIF_SENDWININICHANGE;     // SPIF.SPIF_UPDATEINIFILE | SPIF.SPIF_SENDWININICHANGE
            if (!SystemParametersInfo(SystemParameterInfoActionType.SPI_SETDESKWALLPAPER, 0, filename, spif))
            {
                ErrorBox.ShowLastWin32Error();
                return(false);
            }
#else
            var process = new Process();
            process.StartInfo.FileName               = "dconf";
            process.StartInfo.Arguments              = String.Concat("write \"/org/gnome/desktop/background/picture-uri\" \"'file://", filename, "'\"");
            process.StartInfo.UseShellExecute        = false;
            process.StartInfo.RedirectStandardError  = true;
            process.StartInfo.RedirectStandardInput  = true;
            process.StartInfo.RedirectStandardOutput = true;
            process.Start();
            process.WaitForExit();
            var error = process.StandardError.ReadToEnd();
            if (!String.IsNullOrWhiteSpace(error))
            {
                ErrorBox.Show("Change background error", error);
                return(false);
            }
#endif

            return(true);
        }
Example #2
0
        public static void ProcessMessage(string mouseControlMessage)
        {
            var mouseEvents = mouseControlMessage.Split(new string[] { VncCommand.Mouse }, StringSplitOptions.RemoveEmptyEntries);

            for (int i = 0; i < mouseEvents.Length; i++)
            {
                var clickType = ClickButtonProvider.Get(mouseEvents[i]);
                if (clickType != -1)
                {
                    MouseHandler.ProcessMessage(mouseEvents[i], clickType);
                    Thread.Sleep(50);
                }
                else
                {
                    var mouseMoveArgs = mouseEvents[i].Split(' ');

                    try
                    {
                        var x = Convert.ToInt32(mouseMoveArgs[1]);
                        var y = Convert.ToInt32(mouseMoveArgs[2]);

                        if (!WinAPI.SetCursorPos(x, y))
                        {
                            ErrorBox.ShowLastWin32Error("MouseHandler.ProcessMessage");
                        }
                    }
                    catch (Exception ex)
                    {
                        // FIXME: mouseMoveArgs = 289getscre
                        //ErrorBox.Show("Mouse control error", $"Unable to parse message: {mouseControlMessage}. Exception: {ex}");
                    }
                }
            }
        }