public uint GetNumberOfInputs() { uint numberInputs = 0; try { RGBERROR error = RGB.GetNumberOfInputs(out numberInputs); if (error != RGBERROR.NO_ERROR) { Trace.WriteLine("failed to get number of inputs"); return(0); } } catch (Exception e) { Trace.WriteLine(e.Message); } return(numberInputs); }
public void InitializeVisionDB() { // get the installed rgb executable path //if (Properties.Settings.Default.VisionPath == string.Empty) //{ // auto search the rgb exe foreach (String matchPath in Utils.Files.DirSearch(Environment.GetFolderPath(Environment.SpecialFolder.ProgramFilesX86), "rgbxcmd.com")) { rgbExecutablePath = matchPath; break; } if (rgbExecutablePath == String.Empty) { foreach (String matchPath in Utils.Files.DirSearch(Environment.GetFolderPath(Environment.SpecialFolder.ProgramFiles), "rgbxcmd.com")) { rgbExecutablePath = matchPath; break; } } //Properties.Settings.Default.VisionPath = rgbExecutablePath; //Properties.Settings.Default.Save(); //} // check if the db has data // if have return and do nothing, else proceed initialization if (GetAllVisionInputs().Count() > 0) { Trace.WriteLine("Already initialize"); return; } // get number of input from API uint numberInputs = GetNumberOfInputs(); if (numberInputs == 0) { Trace.WriteLine("Failed to get input count: initialize"); return; } // contruct default input entry in DB RGBERROR error = RGBERROR.NO_ERROR; for (uint i = 1; i <= numberInputs; i++) { // get the input type SIGNALTYPE signalType; uint captureWidth; uint captureHeight; uint refreshRate; if ((error = RGB.GetInputSignalType(i, out signalType, out captureWidth, out captureHeight, out refreshRate)) != RGBERROR.NO_ERROR) { Trace.WriteLine("failed to get signal of input: " + i); } IntPtr hRgb; uint croppingMode = 0; int top = 0; int left = 0; uint width = 0; uint height = 0; if ((error = RGB.OpenInput(i, out hRgb)) != RGBERROR.NO_ERROR) { if ((error = RGB.IsCroppingEnabled(hRgb, out croppingMode)) != RGBERROR.NO_ERROR) { RGB.GetCropping(hRgb, out top, out left, out width, out height); } // clean up RGB.CloseInput(hRgb); } Input visionInput = new Input() { InputNumber = i, LabelName = String.Format("{0}:{1}", System.Enum.GetName(typeof(Input.EInputType), signalType), i), InputCaptureWidth = captureWidth, InputCaptureHeight = captureHeight, InputCropping = croppingMode > 0 ? true:false, InputCropLeft = left, InputCropTop = top, InputCropWidth = width, InputCropHeight = height }; // get windows and OSD details Window visionWnd = new Window(); OnScreenDisplay visionOSD = new OnScreenDisplay(); AddVisionInput(visionWnd, visionInput, visionOSD); } ServerDbHelper.GetInstance().AddSystemInputCount((int)numberInputs); }
static void Main() { if (mutex.WaitOne(TimeSpan.Zero, true) == false) { MessageBox.Show("Only one instance of Vistrol application allowed."); return; } Application.EnableVisualStyles(); Application.SetCompatibleTextRenderingDefault(false); formLicense = new FormLicense(); LicenseChecker.LicenseChecker licenceChecker = null; DriveInfo[] allDrives = DriveInfo.GetDrives(); foreach (DriveInfo drive in allDrives) { string filePath = drive.RootDirectory + LicenseChecker.LicenseChecker.LICENSE_FILE_NAME; if (Utils.Files.IsFileExists(filePath)) { licenceChecker = new LicenseChecker.LicenseChecker(filePath); licenceChecker.EvtLicenseCheckStatus += licenceChecker_EvtLicenseCheckStatus; break; } } if (licenceChecker == null) { MessageBox.Show("No license found. Please plug in dongle and retry.", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error, MessageBoxDefaultButton.Button1); return; } // initialize database ConnectionManager connMgr = new ConnectionManager(); formServer = new FormServer(connMgr); wcfCallback = new WcfCallbackHandler(connMgr, formServer); Server.ServerDbHelper.GetInstance().Initialize(wcfCallback); RGBERROR error = 0; IntPtr hRGBDLL = IntPtr.Zero; try { error = RGB.Load(out hRGBDLL); if (error == RGBERROR.NO_ERROR) { ServerVisionHelper.getInstance().InitializeVisionDB(); } } catch (Exception) { } licenceChecker.StartCheck(); Application.Run(formServer); // clean up if (hRGBDLL != IntPtr.Zero) { RGB.Free(hRGBDLL); } licenceChecker.StopCheck(); }
public RgbEasyException(RGBERROR rgbError) : base($"An RGBEasy error occurred: {rgbError}") { RgbError = rgbError; }