Exemplo n.º 1
0
    public void SetDeskTopResolution()
    {
        Tapal_Settings setting = new Tapal_Settings();
        int            tempHeight = 0, tempWidth = 0;

        Screen Srn = Screen.PrimaryScreen;

        tempHeight = Srn.Bounds.Width;
        tempWidth  = Srn.Bounds.Height;
        //setting.ExistingResolution = tempHeight.ToString() + " , " + tempWidth.ToString();
        //setting.Save();
        //setting.Reload();
        //if(tempHeight<1024)
        //{
        string      str       = setting.ExistingResolution.ToString();
        CResolution ChangeRes = new CResolution(Int32.Parse(str.Split(',')[0].Trim().ToString()), Int32.Parse(str.Split(',')[1].Trim().ToString()));
        //}
    }
Exemplo n.º 2
0
        private void Application_Startup(object sender, EventArgs e)
        {
            DispatcherUnhandledException += (o, eventArgs) =>
            {
                var m = ShowErrorMessage(eventArgs.Exception);
                eventArgs.Handled = m != MessageBoxResult.Cancel || m != MessageBoxResult.No;
                CResolution.ResetResolution();
            };
            AppDomain.CurrentDomain.UnhandledException +=
                delegate(object o, UnhandledExceptionEventArgs eventArgs)
            {
                ShowErrorMessage(eventArgs.ExceptionObject as Exception);
                CResolution.ResetResolution();
            };
            var args = Environment.GetCommandLineArgs();

            if (args.Length > 1) // #0 is file path
            {
                bool showHelp = false;
                void AddHelp(OptionSet set)
                {
                    set.Add("h|help", "Show this message and exit", h => showHelp = h != null);
                }

                IBluescreenViewModel data = null;
                Type type       = null;
                var  currentSet = CmdParameterAttribute.GetBaseOptionSet(t => type = t, out var bluescreenOptions);
                AddHelp(currentSet);
                try
                {
                    foreach (var option in bluescreenOptions)
                    {
                        if (args.Contains(option.Value))
                        {
                            type = option.Key;
                            break;
                        }
                    }
                    if (type is null)
                    {
                        showHelp = true;
                        goto showHelp;
                    }
                    data       = (IBluescreenViewModel)Activator.CreateInstance(type);
                    currentSet = CmdParameterAttribute.GetOptionSetFor(type, data);
                    if (showHelp)
                    {
                        goto showHelp;
                    }
                    AddHelp(currentSet);
                    currentSet.Parse(args);
                }
                catch (OptionException ex)
                {
                    if (AttachConsole(AttachParentProcess))
                    {
                        Console.WriteLine("\n");
                        Console.Write("BluescreenSimulator: ");
                        Console.WriteLine(ex.Message);
                        Console.WriteLine("Try `--help' for more information.");
                        Console.WriteLine();
                        FreeConsole();
                    }
                    Shutdown(1);
                    return;
                }
showHelp:
                if (showHelp)
                {
                    ShowHelp(currentSet);
                    return;
                }

                if (data.EnableUnsafe)
                {
                    MessageBox.Show("You are entering Unsafe Mode. Be careful!", "Careful", MessageBoxButton.OK, MessageBoxImage.Warning);
                    RunGui(true);
                }
                else
                {
                    data.ShowView();
                }
            }
            else
            {
                RunGui(false);
            }
        }
Exemplo n.º 3
0
        //* ────────────-_______________________*
        //* constructor & destructor ───────────────────────*

        //* -----------------------------------------------------------------------*
        /// <summary>コンストラクタ。</summary>
        public CSprite()
        {
            resolution = new CResolution();
        }
Exemplo n.º 4
0
            public CResolution(int a, int b, int c)
            {
                Screen screen = Screen.PrimaryScreen;

                int iWidth     = a;
                int iHeight    = b;
                int iFrequency = c;

                DEVMODE dm = new DEVMODE();

                dm.dmDeviceName = new String(new char[32]);
                dm.dmFormName   = new String(new char[32]);
                dm.dmSize       = (short)Marshal.SizeOf(dm);

                if (0 != User_32.EnumDisplaySettings(null, User_32.ENUM_CURRENT_SETTINGS, ref dm))
                {
                    dm.dmPelsWidth        = iWidth;
                    dm.dmPelsHeight       = iHeight;
                    dm.dmDisplayFrequency = iFrequency;

                    int iRet = User_32.ChangeDisplaySettings(ref dm, User_32.CDS_TEST);

                    if (iRet == User_32.DISP_CHANGE_FAILED)
                    {
                        msgBox.Show("Description: Unable To Process Your Request. Sorry For This Inconvenience.", "Information", options.b.ok);
                    }
                    else
                    {
                        iRet = User_32.ChangeDisplaySettings(ref dm, User_32.CDS_UPDATEREGISTRY);

                        switch (iRet)
                        {
                        case User_32.DISP_CHANGE_SUCCESSFUL:
                        {
                            if (Display.revertSettings == 0)
                            {
                                var result = msgBox.Show("Please press OK to confirm the new settings." +
                                                         "\nThis window will close and revert to the old settings in 10 seconds if you do not press anything.",
                                                         "Confirm changes", options.b.okCancel, 10);
                                if (result == "cancel" || result == null)
                                {
                                    string[] bounds1;
                                    string[] bounds2;
                                    bounds1    = previousComboText.Split('@');
                                    bounds1[1] = bounds1[1].Substring(0, bounds1[1].Length - 2);
                                    bounds2    = bounds1[0].Split('x');
                                    bounds2[0] = bounds2[0].Substring(0, bounds2[0].Length - 1);
                                    bounds2[1] = bounds2[1].Substring(1);
                                    bounds2[1] = bounds2[1].Substring(0, bounds2[1].Length - 1);

                                    Display.revertSettings = 1;
                                    CResolution ChangeRes = new CResolution(Convert.ToInt32(bounds2[0]), Convert.ToInt32(bounds2[1]), Convert.ToInt32(bounds1[1]));
                                    Display.revertSettings = 0;
                                    var dw = new Display();
                                }
                                else if (result == "ok")
                                {
                                    Display.revertSettings    = 0;
                                    Display.previousComboText = $"{dm.dmPelsWidth} x {dm.dmPelsHeight} @{dm.dmDisplayFrequency}hz";
                                }
                            }
                            break;
                            //successfull change
                        }

                        case User_32.DISP_CHANGE_RESTART:
                        {
                            Display.revertSettings = 1;
                            CResolution ChangeRes = new CResolution(Display.startScreenWidth, Display.startScreenHeight, 60);
                            Display.revertSettings = 0;
                            //System.Windows.MessageBox.Show("Description: You Need To Reboot For The Change To Happen.\n If You Feel Any Problem After Rebooting Your Machine\nThen Try To Change Resolution In Safe Mode.", "Information", MessageBoxButton.OK, MessageBoxImage.Information);
                            break;
                            //windows 9x series you have to restart
                        }

                        default:
                        {
                            msgBox.Show("Description: Failed To Change The Resolution.", "Error updating display paramaters", options.b.ok);
                            break;
                            //failed to change
                        }
                        }
                    }
                }
            }