Exemplo n.º 1
0
        //PRIVATE SHARED
        private static void LoadSettings()
        {
            RegistryKey TmpKey;
            RegistryKey TmpRegRoot;
            string      TmpS;

            try {
                //get the Registry-Key
                TmpRegRoot = RegistryKey.OpenRemoteBaseKey(RegistryHive.CurrentUser, "");
                TmpKey     = TmpRegRoot.OpenSubKey(cRegistryPath, true);
                if (!TmpKey == null)
                {
                    //Key exists
                    //load FCurrentRefactoryProvider
                    TmpS = TmpKey.GetValue("CurrentRefactoryProvider", "");
                    if (TmpS != "")
                    {
                        FCurrentRefactoryProvider = Activator.CreateInstance(Type.GetType(TmpS));
                    }
                    //load FAutoCloseStatusDialogs
                    TmpS = TmpKey.GetValue("AutoCloseStatusDialogs", "0");
                    FAutoCloseStatusDialogs = (TmpS == "1");
                    //load FAutoUpdateOnNewVersion
                    TmpS = TmpKey.GetValue("AutoUpdateOnNewVersion", "1");
                    FAutoUpdateOnNewVersion = (TmpS == "1");
                    //close Key
                    TmpKey.Close();
                }
                //close Registry
                TmpRegRoot.Close();
            } catch (Exception ex) {
            }
            //load default FCurrentRefactoryProvider
            if (FCurrentRefactoryProvider == null)
            {
                FCurrentRefactoryProvider = RefactoryNet20Provider.Instance;
            }
            //settings loaded ok
            FSettingsLoaded = true;
        }
Exemplo n.º 2
0
        private static void SaveSettings()
        {
            RegistryKey TmpKey;
            RegistryKey TmpRegRoot;

            try {
                //get the Registry-Key
                TmpRegRoot = RegistryKey.OpenRemoteBaseKey(RegistryHive.CurrentUser, "");
                TmpKey     = TmpRegRoot.OpenSubKey(cRegistryPath, true);
                if (TmpKey == null)
                {
                    //Key not exists, create
                    TmpKey = TmpRegRoot.CreateSubKey(cRegistryPath);
                }
                //save FCurrentRefactoryProvider
                TmpKey.SetValue("CurrentRefactoryProvider", ((object)FCurrentRefactoryProvider).GetType.FullName);
                //save FAutoCloseStatusDialogs
                if (FAutoCloseStatusDialogs)
                {
                    TmpKey.SetValue("AutoCloseStatusDialogs", "1");
                }
                else
                {
                    TmpKey.SetValue("AutoCloseStatusDialogs", "0");
                }
                //save FAutoCloseStatusDialogs
                if (FAutoUpdateOnNewVersion)
                {
                    TmpKey.SetValue("AutoUpdateOnNewVersion", "1");
                }
                else
                {
                    TmpKey.SetValue("AutoUpdateOnNewVersion", "0");
                }
                //close Key+Registry
                TmpKey.Close();
                TmpRegRoot.Close();
            } catch (Exception ex) {
            }
        }
Exemplo n.º 3
0
        public bool UploadInfosToDevice(string DevNam, int wdDeviceType, int intActivePage)
        {
            string strMainRemark = DevNam.Split('\\')[1].Trim();

            DevNam = DevNam.Split('\\')[0].Trim();
            byte bytSubID   = byte.Parse(DevNam.Split('-')[0].ToString());
            byte bytDevID   = byte.Parse(DevNam.Split('-')[1].ToString());
            int  wdMaxValue = DeviceTypeList.GetMaxValueFromPublicModeGroup(wdDeviceType);

            byte[] ArayMain      = new byte[20];
            byte[] arayTmpRemark = HDLUDP.StringToByte(strMainRemark);
            byte[] ArayTmp       = null;
            if (HDLSysPF.ModifyDeviceMainRemark(bytSubID, bytDevID, strMainRemark, wdDeviceType) == false)
            {
                return(false);
            }

            if (CsConst.calculationWorker != null && CsConst.calculationWorker.IsBusy)
            {
                CsConst.calculationWorker.ReportProgress(5, null);
            }
            if (intActivePage == 0 || intActivePage == 1)
            {
                #region
                byte[] arayLED = new byte[11];
                arayLED[0] = Backlight;   // modify LED and backlight
                arayLED[1] = Ledlight;
                if (CsConst.mySends.AddBufToSndList(arayLED, 0xE012, bytSubID, bytDevID, false, true, true, CsConst.minAllWirelessDeviceType.Contains(wdDeviceType)) == true)
                {
                    HDLUDP.TimeBetwnNext(20);
                }
                else
                {
                    return(false);
                }

                if (CsConst.calculationWorker != null && CsConst.calculationWorker.IsBusy)
                {
                    CsConst.calculationWorker.ReportProgress(10, null);
                }
                if (CsConst.mySends.AddBufToSndList(arayHotel, 0x2016, bytSubID, bytDevID, false, true, true, CsConst.minAllWirelessDeviceType.Contains(wdDeviceType)) == true)
                {
                    HDLUDP.TimeBetwnNext(20);
                }
                else
                {
                    return(false);
                }
                if (CsConst.calculationWorker != null && CsConst.calculationWorker.IsBusy)
                {
                    CsConst.calculationWorker.ReportProgress(15, null);
                }
                #endregion
            }

            if (intActivePage == 0 || intActivePage == 2)
            {
                #region
                byte[] arayKeyMode = new byte[wdMaxValue];
                byte[] arayRemark  = new byte[21];
                byte[] arayDely    = new byte[wdMaxValue * 2];
                foreach (Key TmpKey in myKeySetting)
                {
                    arayRemark = new byte[21];
                    TmpKey.UploadButtonRemarkAndCMDToDevice(bytSubID, bytDevID, wdDeviceType, -1, 255);

                    arayDely[(TmpKey.ID - 1) * 2]     = Convert.ToByte(TmpKey.Delay / 256);
                    arayDely[(TmpKey.ID - 1) * 2 + 1] = Convert.ToByte(TmpKey.Delay % 256);
                    arayKeyMode[TmpKey.ID - 1]        = TmpKey.Mode;

                    if (CsConst.calculationWorker != null && CsConst.calculationWorker.IsBusy)
                    {
                        CsConst.calculationWorker.ReportProgress(25 + TmpKey.ID, null);
                    }
                }
                if (CsConst.mySends.AddBufToSndList(arayKeyMode, 0xE00A, bytSubID, bytDevID, false, true, true, CsConst.minAllWirelessDeviceType.Contains(wdDeviceType)) == true)
                {
                    HDLUDP.TimeBetwnNext(20);
                }
                else
                {
                    return(false);
                }
                if (CsConst.calculationWorker != null && CsConst.calculationWorker.IsBusy)
                {
                    CsConst.calculationWorker.ReportProgress(40, null);
                }
                if (wdDeviceType != 3058 && wdDeviceType != 3060)
                {
                    if (CsConst.mySends.AddBufToSndList(arayDely, 0x2026, bytSubID, bytDevID, false, true, true, CsConst.minAllWirelessDeviceType.Contains(wdDeviceType)) == true)
                    {
                        HDLUDP.TimeBetwnNext(20);
                    }
                    else
                    {
                        return(false);
                    }
                    if (CsConst.calculationWorker != null && CsConst.calculationWorker.IsBusy)
                    {
                        CsConst.calculationWorker.ReportProgress(45, null);
                    }
                }
                #endregion
            }

            if (intActivePage == 0 || intActivePage == 3)
            {
                #region
                if (wdDeviceType == 3076 || wdDeviceType == 3078 || wdDeviceType == 3080)
                {
                    if (CsConst.calculationWorker != null && CsConst.calculationWorker.IsBusy)
                    {
                        CsConst.calculationWorker.ReportProgress(91);
                    }
                    int maxLength = wdMaxValue;
                    if (wdDeviceType == 3076 || wdDeviceType == 3078 || wdDeviceType == 3080)
                    {
                        maxLength = 3;
                    }
                    for (int i = 1; i <= maxLength; i++)
                    {
                        ArayTmp    = new byte[7];
                        ArayTmp[0] = Convert.ToByte(i);
                        Array.Copy(arayButtonColor, (i - 1) * 6, ArayTmp, 1, 6);
                        if (CsConst.mySends.AddBufToSndList(ArayTmp, 0xE14E, bytSubID, bytDevID, false, true, true, CsConst.minAllWirelessDeviceType.Contains(wdDeviceType)) == true)
                        {
                            HDLUDP.TimeBetwnNext(20);
                        }
                        else
                        {
                            return(false);
                        }
                    }
                    if (CsConst.calculationWorker != null && CsConst.calculationWorker.IsBusy)
                    {
                        CsConst.calculationWorker.ReportProgress(92);
                    }


                    if (arayButtonBalance[0] >= 0)
                    {
                        ArayTmp = new byte[arayButtonBalance[0] * 3];
                        Array.Copy(arayButtonBalance, 1, ArayTmp, 0, arayButtonBalance.Length - 1);
                        if (CsConst.mySends.AddBufToSndList(ArayTmp, 0x199A, bytSubID, bytDevID, false, true, true, CsConst.minAllWirelessDeviceType.Contains(wdDeviceType)) == true)
                        {
                            HDLUDP.TimeBetwnNext(20);
                        }
                        else
                        {
                            return(false);
                        }
                    }


                    ArayTmp = new byte[maxLength];
                    Array.Copy(arayButtonSensitiVity, 0, ArayTmp, 0, maxLength);
                    if (CsConst.mySends.AddBufToSndList(ArayTmp, 0xE152, bytSubID, bytDevID, false, false, false, CsConst.minAllWirelessDeviceType.Contains(wdDeviceType)) == true)
                    {
                        HDLUDP.TimeBetwnNext(20);
                    }
                    else
                    {
                        return(false);
                    }

                    if (CsConst.calculationWorker != null && CsConst.calculationWorker.IsBusy)
                    {
                        CsConst.calculationWorker.ReportProgress(93);
                    }
                }
                #endregion
            }
            if (CsConst.calculationWorker != null && CsConst.calculationWorker.IsBusy)
            {
                CsConst.calculationWorker.ReportProgress(100, null);
            }
            return(true);
        }