示例#1
0
        private void Page_Loaded(object sender, RoutedEventArgs e)
        {
            LaunchSet_JavaJreList.ItemsSource       = Helper.OSHelper.GetJavaList();
            LaunchSet_JavaJreList.DisplayMemberPath = "JavaW";
            LaunchSet_JavaJreList.SelectedIndex     = 0;
            ConfigModel config = Config.GetConfig();

            if (config.users[0].java != null) // 选择之前设置的Java
            {
                LaunchSet_JavaJreMemorySize.Text = config.users[0].java.max_memory.ToString();
                if (config.users[0].java.jre_path != null || config.users[0].java.jre_path != "")
                {
                    int             i  = 0;
                    List <JavaInfo> ji = OSHelper.GetJavaList();
                    foreach (JavaInfo ij in ji)
                    {
                        if (ij.JavaW == config.users[0].java.jre_path)
                        {
                            LaunchSet_JavaJreList.SelectedIndex = i;
                        }
                        i++;
                    }
                }
                if (config.users[0].java.is_auto_memory || config.users[0].java.max_memory == 0)
                {
                    AutoMemory.IsChecked = true;
                    LaunchSet_JavaJreMemorySize.IsEnabled = false;
                }
            }
        }
示例#2
0
        static bool TryOpenByOtherInstance(string[] args)
        {
            var files = args.Where(arg => !arg.StartsWith("-")).ToArray();

            if (files.IsEmpty())
            {
                return(false);
            }

            var name           = Process.GetCurrentProcess().ProcessName;
            var otherInstances = Process.GetProcessesByName(name)
                                 .Where(inst => inst != Process.GetCurrentProcess() && inst.MainWindowHandle != IntPtr.Zero)
                                 .ToArray();

            if (!otherInstances.IsNullOrEmpty())
            {
                var inst   = otherInstances.First();
                var data   = Encoding.UTF8.GetBytes(files.JoinString(";"));
                var buffer = OSHelper.IntPtrAlloc(data);

                var cds = new COPYDATASTRUCT();
                cds.dwData = new IntPtr(OPEN_FILES_MESSAGE);
                cds.cbData = data.Length;
                cds.lpData = buffer;
                var    cbs_buffer = OSHelper.IntPtrAlloc(cds);
                IntPtr result     = User32.SendMessage(inst.MainWindowHandle, WinMessages.WM_COPYDATA, IntPtr.Zero, cbs_buffer);
                OSHelper.IntPtrFree(cbs_buffer);
                OSHelper.IntPtrFree(buffer);

                return(result != IntPtr.Zero);
            }

            return(false);
        }
示例#3
0
        protected override void OnStartup(StartupEventArgs e)
        {
            OSHelper.HandleDependencies();

            base.OnStartup(e);
            AppDomain.CurrentDomain.UnhandledException += AppDomainUnhandledException;
        }
示例#4
0
 public string GetOSName(Process process)
 {
     if (_osInfo == null)
     {
         _osInfo = OSHelper.GetComputerDescription();
     }
     return(_osInfo.ProductName);
 }
示例#5
0
 private void btnGithub_Click(object sender, EventArgs e)
 {
     if (MessageBox.Show(BoxartConfig.Credits + Environment.NewLine + Environment.NewLine + "Visit Github now?", "Hello",
                         MessageBoxButtons.YesNo,
                         MessageBoxIcon.Information) == DialogResult.OK)
     {
         OSHelper.OpenBrowser(BoxartConfig.RepositoryUrl);
     }
 }
示例#6
0
 public static void OSID_Was_Detected()
 {
     Assert.True(OSHelper.Current != OSID.None,
                 String.Format("OSID was not properly detected:{0}  The RuntimeInformation.OSDescription is = \'{1}\" {2}  The RuntimeIdentifier is = {3}",
                               Environment.NewLine,
                               RuntimeInformation.OSDescription,
                               Environment.NewLine,
                               OSHelper.GetRuntimeIdentifier()));
 }
示例#7
0
 protected override IUnixWbemClassHandler Build(object nativeObj)
 {
     return(base.Build(nativeObj).WithProperty(PathField, System.Net.Dns.GetHostName())
            .WithMethod("Rename", new UnixCimMethodInfo {
         Name = "Rename"
     })
            .WithProperty("Description", OSHelper.GetComputerDescription().ToString())
            .WithProperty("Domain", GetDomain()));
 }
示例#8
0
    public static void ListAllOSRIDs()
    {
        string testRuntime          = OSHelper.GetRuntimeIdentifier();
        OSID   id                   = OSHelper.OSIDfromRuntimeEnvironment();
        string runtimeOSDescription = RuntimeInformation.OSDescription;

        Assert.True(false, string.Format("Detected the current Runtime Identifier as: '{0}'\n" +
                                         "Which maps to OSID: '{1}'\n" +
                                         "Detected the current runtimeOSDescription as: '{2}'", testRuntime, id.Name(), runtimeOSDescription));
    }
示例#9
0
        protected override void OnCreate(Bundle savedInstanceState)
        {
            RequestWindowFeature(WindowFeatures.NoTitle);
            base.OnCreate(savedInstanceState);

            if (MSAAuthenticator.HasUserUniqueId() || CloudServiceAuthenticationHelper.IsAuthenticatedForApiV3())
            {
                LaunchHomeScreen();
                return;
            }

            (new Classes.WhatsNew(this)).Shown(); //Don't show what's new dialog if this is the first time user opens the app.

            Instance = this;

            SetTheme(Resource.Style.MyTheme_Dark);
            Window.SetFlags(WindowManagerFlags.Fullscreen, WindowManagerFlags.Fullscreen);
            if (Build.VERSION.SdkInt >= BuildVersionCodes.Lollipop)
            {
                Window.SetNavigationBarColor(Android.Graphics.Color.Black);
                Window.DecorView.SystemUiVisibility = StatusBarVisibility.Hidden;
            }

            SetContentView(Resource.Layout.Intro);

            viewPager = FindViewById <ViewPager>(Resource.Id.intro_viewPager);
            dots      = FindViewById <TextView>(Resource.Id.intro_dotsText);
            btnNext   = FindViewById <Button>(Resource.Id.intro_btnNext);
            btnSkip   = FindViewById <Button>(Resource.Id.intro_btnSkip);

            layouts = new List <int>()
            {
                Resource.Layout.Intro1,
                Resource.Layout.Intro2,
                Resource.Layout.Intro3,
                Resource.Layout.Intro4,
                Resource.Layout.Intro4_1,
                Resource.Layout.Intro5,
            };

            AddBottomDots(0);

            introViewPagerAdapter       = new IntroViewPagerAdapter(this);
            viewPager.Adapter           = introViewPagerAdapter;
            viewPagerPageChangeListener = new ViewPagerPageChangeListener();
            viewPager.AddOnPageChangeListener(viewPagerPageChangeListener);

            OSHelper.ClearWebViewCache(ApplicationContext);

            btnNext.Click += BtnNext_Click;
            btnSkip.Click += BtnSkip_Click;
        }
示例#10
0
        private XXPSocketsModel XXPSocketsExecuteCallBack(XXPSocketsModel mod)
        {
            LogHelper.WriteMethodLog(true);
            XXPSocketsModel refMod = new XXPSocketsModel();

            refMod.IpAddress = OSHelper.GetLocalIP();
            refMod.Type      = string.Empty;

            switch (mod.Type)
            {
            case XXPCoinMsgType.DBfile:
                refMod.Type  = XXPCoinMsgType.DBfile;
                refMod.Value = HandlleDBfileEvent(mod);
                break;

            case XXPCoinMsgType.Handshake:
                refMod.Type  = XXPCoinMsgType.Handshake;
                refMod.Value = this.HandlleHandshakeEvent(mod);
                break;

            case XXPCoinMsgType.NewAddresses:
                refMod.Type  = XXPCoinMsgType.NewAddresses;
                refMod.Value = handleNewAddress(mod);
                break;

            case XXPCoinMsgType.SyncBlocks:
                refMod.Type  = XXPCoinMsgType.SyncBlocks;
                refMod.Value = handleSyncBlocks(mod);
                break;

            case XXPCoinMsgType.Newtransactions:
                refMod.Type  = XXPCoinMsgType.Newtransactions;
                refMod.Value = handleNewtransactions(mod);
                break;

            case XXPCoinMsgType.NewBlock:
                refMod.Type  = XXPCoinMsgType.NewBlock;
                refMod.Value = handleNewBlock(mod);
                break;

            case XXPCoinMsgType.Message:
                break;

            default:

                break;
            }
            LogHelper.WriteMethodLog(false);
            return(refMod);
        }
示例#11
0
        public string GetOSVersion(Process process)
        {
            if (_osInfo == null)
            {
                _osInfo = OSHelper.GetComputerDescription();
            }
            var version = _osInfo.Version;

            if (!string.IsNullOrEmpty(_osInfo.BuildNumber))
            {
                version += " " + _osInfo.BuildNumber;
            }
            return(version);
        }
示例#12
0
 public async Task GetOSMetrics()
 {
     while (true)
     {
         try
         {
             var os = OSHelper.GetOSMetrics();
             await Clients.Caller.SendAsync("setOSMetrics", os);
         }
         catch
         {
         }
         await Task.Delay(1500);
     }
 }
示例#13
0
        /// <summary>
        /// Creates a RGB colour configuration file.
        /// </summary>
        public static void CreateRGBConfigurationFile()
        {
            try
            {
                if (OSHelper.IsSevenOrHigher())
                {
                    CommonSaveFileDialog csfd = new CommonSaveFileDialog();

                    csfd.Title = "Save Colours To:";

                    csfd.Filters.Add(new CommonFileDialogFilter("Colour Configuration File", ".ccf"));

                    csfd.Filters.Add(new CommonFileDialogFilter("Normal Text File", ".txt"));

                    csfd.DefaultFileName = $"Custom Colours Configuration File - { TranslationMethods.ReturnSafeFileNameDateTimeString() }";

                    csfd.AlwaysAppendDefaultExtension = true;

                    csfd.DefaultExtension = "ccf";

                    if (csfd.ShowDialog() == CommonFileDialogResult.Ok)
                    {
                        WriteRGBColoursToFile(csfd.FileName);
                    }
                }
                else
                {
                    SaveFileDialog dialog = new SaveFileDialog();

                    dialog.Title = "Save Colours To:";

                    dialog.Filter = "Colour Configuration File | *.ccf | Normal Text Files | *.txt";

                    dialog.DefaultExt = "ccf";

                    dialog.FileName = $"All Colour Configuration File - { TranslationMethods.ReturnSafeFileNameDateTimeString() }";

                    if (dialog.ShowDialog() == DialogResult.OK)
                    {
                        WriteRGBColoursToFile(dialog.FileName);
                    }
                }
            }
            catch (Exception exc)
            {
                ExtendedKryptonMessageBox.Show($"An unexpected error has occurred: '{ exc.Message }'", "Unexpected Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
示例#14
0
        public string ReserchNodes()
        {
            LogHelper.WriteMethodLog(true);
            AppSettings.SeedNodes = AppConfigHelper.GetConfigValByKey("SeedNodes");
            var lstSeeds = (from x in AppSettings.SeedNodes.Split('|')
                            where x != ""
                            select x).ToList();

            foreach (var item in lstSeeds)
            {
                if (item != OSHelper.GetLocalIP() && item != "127.0.0.1")
                {
                    this.RequestHandshake(item);
                }
            }
            if (this.dicAddressesPool.Count == 0)
            {
                return("Connect to XXPCoin Net failed");
            }

            HashSet <string> hsNew = new HashSet <string>();

            foreach (var item in this.dicAddressesPool)
            {
                List <string> lstAddress = this.RequestMoreNodes(item.Key);


                foreach (var Adds in lstAddress)
                {
                    if (Adds != OSHelper.GetLocalIP() && !this.dicAddressesPool.ContainsKey(Adds))
                    {
                        if (!hsNew.Contains(Adds))
                        {
                            hsNew.Add(Adds);
                        }
                    }
                }
            }
            foreach (var item in hsNew)
            {
                if (this.RequestHandshake(item))
                {
                    this.Add2AddressPool(item);
                }
            }
            LogHelper.WriteMethodLog(false);
            return(ConstHelper.BC_OK);
        }
示例#15
0
        /// <summary>
        /// Creates a RGB colour configuration file.
        /// </summary>
        public static void CreateRGBConfigurationFile()
        {
            try
            {
                if (OSHelper.IsSevenOrHigher())
                {
                    CommonSaveFileDialog csfd = new CommonSaveFileDialog();

                    csfd.Title = "Save Colours To:";

                    csfd.Filters.Add(new CommonFileDialogFilter("Colour Configuration File", ".ccf"));

                    csfd.Filters.Add(new CommonFileDialogFilter("Normal Text File", ".txt"));

                    csfd.DefaultFileName = $"All Colour Configuration File - { TranslationMethods.ReturnSafeFileNameDateTimeString() }";

                    csfd.AlwaysAppendDefaultExtension = true;

                    csfd.DefaultExtension = "ccf";

                    if (csfd.ShowDialog() == CommonFileDialogResult.Ok)
                    {
                        WriteRGBColoursToFile(csfd.FileName);
                    }
                }
                else
                {
                    SaveFileDialog dialog = new SaveFileDialog();

                    dialog.Title = "Save Colours To:";

                    dialog.Filter = "Colour Configuration File | *.ccf | Normal Text Files | *.txt";

                    dialog.DefaultExt = "ccf";

                    dialog.FileName = $"All Colour Configuration File - { TranslationMethods.ReturnSafeFileNameDateTimeString() }";

                    if (dialog.ShowDialog() == DialogResult.OK)
                    {
                        WriteRGBColoursToFile(dialog.FileName);
                    }
                }
            }
            catch (Exception exc)
            {
                ExceptionHandler.CaptureException(exc, icon: MessageBoxIcon.Error, methodSignature: MethodHelpers.GetCurrentMethod());
            }
        }
示例#16
0
        private void SetupThread()
        {
            this.logger.LogInformation($"[{this.Name}] Setting up Thread");
            this.executerThread = new Thread(new ThreadStart(this.LoopExecuting))
            {
                Name             = this.Name,
                CurrentCulture   = this.CurrentCulture,
                CurrentUICulture = this.CurrentUICulture,
            };

            // ApartmentState for COM Objects is not support on linux
            if (OSHelper.IsRunningOnWindows())
            {
                this.executerThread.SetApartmentState(ApartmentState.MTA);
            }
        }
示例#17
0
 private void skydrive_SessionChanged(object sender, Microsoft.Live.Controls.LiveConnectSessionChangedEventArgs e)
 {
     if (e != null && e.Status == LiveConnectSessionStatus.Connected)
     {
         App.ViewModelData.LiveClient = new LiveConnectClient(e.Session);
         UploadBtn.IsEnabled          = true;
     }
     else
     {
         App.ViewModelData.LiveClient = null;
         if (e.Error != null)
         {
             OSHelper.ShowToast(AppResources.TextID31);
         }
     }
 }
示例#18
0
        private List <string> GetMysoftSubKey()
        {
            RegistryKey localMachine = Registry.LocalMachine;
            string      name         = string.Empty;

            if (OSHelper.Is64Bit())
            {
                name = @"SOFTWARE\Wow6432Node\mysoft";
            }
            else
            {
                name = @"SOFTWARE\mysoft";
            }
            RegistryKey key2 = localMachine.OpenSubKey(name);

            if (key2 != null)
            {
                try
                {
                    foreach (string str2 in key2.GetSubKeyNames())
                    {
                        RegistryKey key3   = key2.OpenSubKey(str2);
                        DbConfig    config = new DbConfig();
                        object      obj2   = key3.GetValue("DBName");
                        config.DBName     = (obj2 == null) ? "" : obj2.ToString();
                        obj2              = key3.GetValue("SaPassword");
                        config.SaPassword = (obj2 == null) ? "" : Decode(obj2.ToString());
                        obj2              = key3.GetValue("ServerName");
                        config.ServerName = (obj2 == null) ? "" : obj2.ToString();
                        obj2              = key3.GetValue("UserName");
                        config.UserName   = (obj2 == null) ? "" : obj2.ToString();
                        key3.Close();
                        if (!this.dbDic.ContainsKey(str2))
                        {
                            this.dbDic.Add(str2, config);
                        }
                    }
                }
                finally
                {
                    key2.Close();
                    localMachine.Close();
                }
            }
            return(this.dbDic.Keys.ToList <string>());
        }
示例#19
0
        private async void LogOutDialogClickListener(object sender, DialogClickEventArgs e)
        {
            if (await ServiceFunctions.RemoveDevice(this) == false)
            {
                Android.App.AlertDialog.Builder alert = new Android.App.AlertDialog.Builder(this);
                alert.SetTitle("Failed to log out.\nPlease make sure you have a working internet connection. If the problem persists, contact us.");
                alert.SetPositiveButton("OK", (IDialogInterfaceOnClickListener)null);
                RunOnUiThread(() =>
                {
                    alert.Show();
                });

                return;
            }

            MSAAuthenticator.DeleteUserUniqueId();

            OSHelper.ClearAppDataAndExit();
            FinishAffinity();
        }
示例#20
0
        private async void PrepareFolderSkydrive()
        {
            try
            {
                LiveOperationResult operationResult = await App.ViewModelData.LiveClient.GetAsync("me/skydrive/files?filter=folders,albums");

                var folderData = operationResult.Result as dynamic;
                var folders    = folderData.data as dynamic;
                foreach (dynamic folder in folders)
                {
                    if (folder.name.ToString().Equals(Constant.SKYDRIVE_FOLDER_NAME))
                    {
                        App.ViewModelData.SkydriveFolderID = folder.id.ToString();
                        break;
                    }
                }

                if (string.IsNullOrEmpty(App.ViewModelData.SkydriveFolderID))
                {
                    Dictionary <string, object> skyDriveFolderData = new Dictionary <string, object>();
                    skyDriveFolderData.Add("name", Constant.SKYDRIVE_FOLDER_NAME);
                    LiveOperationResult createFolderResult = await App.ViewModelData.LiveClient.PostAsync("me/skydrive", skyDriveFolderData);

                    var folder = createFolderResult.Result as dynamic;

                    App.ViewModelData.SkydriveFolderID = folder.id.ToString();
                }
            }
            catch (Exception ex)
            {
                System.Diagnostics.Debug.WriteLine("Exception everywhere " + ex.GetType());
                OSHelper.ShowToast(AppResources.TextID32);
            }

            if (!string.IsNullOrEmpty(App.ViewModelData.SkydriveFolderID))
            {
                SetAppBarButtonsEnable(true);
            }

            ProgressIndicator.IsRunning = false;
        }
示例#21
0
        private string handleNewAddress(XXPSocketsModel socketMod)
        {
            LogHelper.WriteMethodLog(true);
            string strRet = string.Empty;

            if (string.IsNullOrEmpty(socketMod.Value))// give my addresspool to sender
            {
                Dictionary <string, int> dicAddPool = new Dictionary <string, int>();
                dicAddPool = this.dicAddressesPool;
                foreach (var item in dicAddPool)
                {
                    strRet += item.Key + "|";
                }

                return(strRet);
            }
            else // sender give his new addresses to me, handshake every one if dont contain
            {
                List <string> lstIpAddress = new List <string>();
                if (!string.IsNullOrEmpty(socketMod.Value))
                {
                    lstIpAddress = (from x in socketMod.Value.Split('|')
                                    where x != ""
                                    select x).ToList();
                }

                foreach (var item in lstIpAddress)
                {
                    if (item == OSHelper.GetLocalIP())
                    {
                        continue;
                    }
                    if (!this.dicAddressesPool.ContainsKey(item))
                    {
                        this.RequestHandshake(item);
                    }
                }
                LogHelper.WriteMethodLog(true);
                return("ths");
            }
        }
示例#22
0
        void OnWmCopyData(ref Message m)
        {
            var cbd = OSHelper.IntPtrToStruct <COPYDATASTRUCT>(m.LParam);

            if (cbd.dwData.ToInt64() == Program.OPEN_FILES_MESSAGE)
            {
                var buffer = OSHelper.GetBuffer(cbd.lpData, cbd.cbData);
                if (!buffer.IsNullOrEmpty())
                {
                    var str   = Encoding.UTF8.GetString(buffer);
                    var files = str.Split(new char[] { ';' }, StringSplitOptions.RemoveEmptyEntries);
                    OpenDocuments(files);
                    m.Result = new IntPtr(1);

                    if (this.WindowState == FormWindowState.Minimized)
                    {
                        this.WindowState = FormWindowState.Normal;
                    }
                    this.Activate();
                }
            }
        }
        //string ParseGoogleResponse(string data)
        //{
        //    var xmlElm = XElement.Parse(data);
        //    var status = (from elm in xmlElm.Descendants() where elm.Name == "status" select elm).FirstOrDefault();
        //    if (status.Value.ToLower() == "ok")
        //    {
        //        var res = (from elm in xmlElm.Descendants() where elm.Name == "formatted_address" select elm).FirstOrDefault();
        //        return res.Value;
        //    }
        //    return null;
        //}

        private async Task <GeoCoordinate> GetCurrentLocation()
        {
            Geolocator geoLocator = new Geolocator()
            {
                DesiredAccuracy = PositionAccuracy.High
            };

            try
            {
                var position = await geoLocator.GetGeopositionAsync(TimeSpan.FromHours(24), TimeSpan.FromSeconds(5));

                return(CoordinateConverter.ConvertGeocoordinate(position.Coordinate));
            }
            catch (Exception) { }

            Dispatcher.BeginInvoke(() =>
            {
                OSHelper.ShowToast(AppResources.TextID18);
            });

            return(null);
        }
示例#24
0
        public static void Start(HookCallback keyboardCallback, HookCallback mouseCallback)
        {
            OSHelper.Os os = OSHelper.GetOsVersion();
            if (os.System != OSHelper.Platform.Windows)
            {
                throw new InvalidOperatingSystemException("Windowhook can only be run on windows machines!");
            }

            if (Running)
            {
                throw new InvalidCastException("Windowhook already running");
            }

            ISLogger.Write("Starting Windowhook on " + os);

            KeyboardProcPtr = SetKeyboardHook(keyboardCallback);
            if (KeyboardProcPtr == IntPtr.Zero)
            {
                throw new Win32Exception("An error occurred while installing keyboard hook. Win32 error code " + Marshal.GetLastWin32Error());
            }
            else
            {
                ISLogger.Write("Installed keyboard hook");
            }

            MouseProcPtr = SetMouseHook(mouseCallback);
            if (MouseProcPtr == IntPtr.Zero)
            {
                throw new Win32Exception("An error occurred while installing mouse hook. Win32 error code " + Marshal.GetLastWin32Error());
            }
            else
            {
                ISLogger.Write("Installed Mouse hook");
            }

            Running = true;
        }
示例#25
0
        public void UpdateCheck()
        {
            try
            {
                var update = GithubClient.GetNewRelease(BoxartConfig.Repository, BoxartConfig.Version);

                if (update != null)
                {
                    var result = MessageBox.Show(update.UpdateText,
                                                 "A new update is available!",
                                                 MessageBoxButtons.YesNo,
                                                 MessageBoxIcon.Information);

                    if (result == DialogResult.Yes)
                    {
                        OSHelper.OpenBrowser(BoxartConfig.RepositoryReleasesUrl);
                    }
                }
            }
            catch (Exception e)
            {
                Log($"An error occured while looking for updates. {e.Message}");
            }
        }
示例#26
0
        public void TestReadProcessOutput()
        {
            OSHelper h = new OSHelper();

            h.ReadProcessOutput("sw_vers", "-productVersion");
        }
示例#27
0
        public void Start(int port)
        {
            if (Running)
            {
                throw new InvalidOperationException("Server already running");
            }

            try
            {
                Process.GetCurrentProcess().PriorityClass = ServerBasePriority;
            }catch (Exception ex)
            {
                ISLogger.Write("Cannot set process priority to {0}: {1}", ServerBasePriority, ex.Message);
            }


            ConnectedClient.LocalHost = new ConnectedClient(true);
            ISLogger.Write("Starting server...");
            ServerPort = port;
            clientMan  = new ClientManager(ServerDefaultMaxClients);
            clientMan.AddClient(ConnectedClient.LocalHost);
            tcpListener = new ClientListener();
            tcpListener.ClientConnected += TcpListener_ClientConnected;


            tcpListener.Start(port);


            SetConsoleText("Current client: localhost");

            //We need to determine which OS is being used
            OSHelper.Os os = OSHelper.GetOsVersion();

            switch (os.System)
            {
            case OSHelper.Platform.Windows:
            {
                inputMan    = new WindowsInputManager();
                curMonitor  = new WindowsCursorMonitor();
                outManager  = new WindowsOutputManager();
                procMonitor = new WindowsProcessMonitor();
                break;
            }

            default:
                throw new NotImplementedException();
            }
            inputMan.Start();

            curMonitor.Start();
            curMonitor.EdgeHit += LocalHost_EdgeHit;

            procMonitor.StartMonitoring();
            procMonitor.ProcessEnteredFullscreen += ProcMonitor_ProcessEnteredFullscreen;
            procMonitor.ProcessExitedFullscreen  += ProcMonitor_ProcessExitedFullscreen;
            Running = true;

            inputMan.InputReceived         += InputMan_InputReceived;
            inputMan.ClientHotkeyPressed   += InputMan_ClientHotkeyPressed;
            inputMan.FunctionHotkeyPressed += InputMan_FunctionHotkeyPressed;
            inputMan.ClipboardTextCopied   += InputMan_ClipboardTextCopied;

            LoadHotkeySettings();
        }
示例#28
0
 void saveImageWorker_RunWorkerCompleted(object sender, RunWorkerCompletedEventArgs e)
 {
     OSHelper.ShowToast(AppResources.TextID19);
 }
示例#29
0
        public CurrentOS(char pathDirectorySeparatorChar, string osVersionString, bool is64bit, OSHelper osHelper)
        {
            bool IsWindows = pathDirectorySeparatorChar == '\\';

            if (IsWindows)
            {
                Name = osVersionString;

                Name = Name.Replace("Microsoft ", "");
                Name = Name.Replace("  ", " ");
                Name = Name.Replace(" )", ")");
                Name = Name.Trim();

                Name = Name.Replace("NT 10", "10 %bit 10");
                Name = Name.Replace("NT 6.2", "8 %bit 6.2");
                Name = Name.Replace("NT 6.1", "7 %bit 6.1");
                Name = Name.Replace("NT 6.0", "Vista %bit 6.0");
                Name = Name.Replace("NT 5.", "XP %bit 5.");
                Name = Name.Replace("%bit", (is64bit ? "64bit" : "32bit"));
            }
            else
            {
                string UnixName = osHelper.ReadProcessOutput("uname", null);
                if (UnixName.Contains("Darwin"))
                {
                    Name = "Darwin MacOS X " + osHelper.ReadProcessOutput("sw_vers", "-productVersion");
                    Name = Name.Trim();

                    Name += (is64bit ? " 64bit" : " 32bit");
                }
                else if (UnixName != "")
                {
                    Name = "Unix";
                }
                else
                {
                    Name = "Unknown";
                }
            }
        }
示例#30
0
        static void Main(string[] args)
        {
            ConsoleEx.WriteGreenLine(BoxartConfig.Credits);
            Console.WriteLine();

            var config = new BoxartConfig();

            try
            {
                config.Load();
            }
            catch { Console.WriteLine("Could not load TwilightBoxart.ini - using defaults."); }

            if (!config.DisableUpdates)
            {
                try
                {
                    var update = GithubClient.GetNewRelease(BoxartConfig.Repository, BoxartConfig.Version);

                    if (update != null)
                    {
                        ConsoleEx.WriteGreenLine(update.UpdateText);

                        if (ConsoleEx.YesNoMenu())
                        {
                            OSHelper.OpenBrowser(BoxartConfig.RepositoryReleasesUrl);
                        }

                        Console.WriteLine();
                    }
                }
                catch (Exception e)
                {
                    Console.WriteLine($"Could not check for updates: {e.Message}");
                }
            }

            if (string.IsNullOrEmpty(config.SdRoot))
            {
                var allDrives = new List <DriveInfo>();
                try
                {
                    allDrives = DriveInfo.GetDrives().Where(c => c.DriveType == DriveType.Removable).ToList();
                }
                catch { }

                var choice = Path.GetDirectoryName(Assembly.GetEntryAssembly().Location);
                if (allDrives.Count > 0)
                {
                    var choices = allDrives.Select(c => c.Name).ToList();
                    choices.Add("Current Directory");
                    var i = ConsoleEx.MenuIndex("Select your SD location: ", true, choices.ToArray());
                    if (i != choices.Count - 1)
                    {
                        choice = allDrives[i].RootDirectory.FullName;
                    }
                }
                else
                {
                    Console.WriteLine("No settings or drives found. Using current directory.");
                }

                config.SdRoot = choice;
            }

            var boxArtPath = config.GetCorrectBoxartPath();

            ConsoleEx.WriteGreenLine("Loaded settings:");
            Console.WriteLine("SDRoot / Roms location: \t" + config.SdRoot);
            Console.WriteLine("BoxArt location: \t\t" + boxArtPath);
            Console.WriteLine();
            if (!ConsoleEx.YesNoMenu("Is this OK?"))
            {
                Console.WriteLine("Please edit TwilightBoxart.ini or insert your SD card and try again.");
                return;
            }
            Console.WriteLine();

            var progress = new Progress <string>(Console.WriteLine);
            var crawler  = new BoxartCrawler(progress);

            config.BoxartPath   = boxArtPath;
            config.SettingsPath = config.GetCorrectSettingsIniPath();
            crawler.DownloadArt(config).Wait();
        }