예제 #1
0
 public O_TCP()
 {
     cfg = new INI(AppDomain.CurrentDomain.SetupInformation.ApplicationBase + "config\\tcp.ini");
     err = new LOG();
     rtVal = new PACK();
     ep = (EndPoint)new IPEndPoint(IPAddress.Parse(cfg.GetVal("Remote", "IP")), int.Parse(cfg.GetVal("Remote", "Port")));
 }
예제 #2
0
 public CustomReportCredentials()
 {
     INI cfg = new INI(AppDomain.CurrentDomain.SetupInformation.ApplicationBase + "config.ini");
     _UserName = cfg.GetVal("Advanced", "ReportUser");
     _PassWord = cfg.GetVal("Advanced", "ReportPassWord");
     _DomainName = cfg.GetVal("Advanced", "ReportDomain");
 }
예제 #3
0
파일: JIRC.cs 프로젝트: JamesP2/JIRC
 public JIRC()
 {
     InitializeComponent();
     INI ini = new INI();
     if (File.Exists("config.ini"))
     {
         ini.ReadINI("config.ini");
     }
     connectTo.CreateServerConnection += new EventHandler<ConnectionDetailArg>(CreateServerConnectionHandler);
     foreach (INISection section in ini.Sections)
     {
         //Build the server list in the connect to dialog
         if (section.Name.Equals("server"))
         {
             connectTo.srv.Add(section);
         }
         //Set the global config
         if (section.Name.Equals("global"))
         {
             foreach (INIProperty p in section.Properties)
             {
                 settings.Add(p.Property, p.Value);
             }
         }
     }
     connectTo.sortList();
     dbg("Ready.");
 }
예제 #4
0
 public static void AddObject(string name, INI.Object obj)
 {
     if (!objects.ContainsKey(name))
         objects.Add(name, obj);
     else
         //overwrite old object
         objects[name] = obj;
 }
예제 #5
0
파일: O_PI.cs 프로젝트: jerrybird/SISCell-1
 public O_PI()
 {
     cfg = new INI(AppDomain.CurrentDomain.SetupInformation.ApplicationBase + "config\\pi.ini");
     err = new LOG();
     _server = cfg.GetVal("Connect", "Server");
     _user = cfg.GetVal("Connect", "User");
     _password = cfg.GetVal("Connect", "Password");
 }
예제 #6
0
파일: O_HS.cs 프로젝트: jerrybird/SISCell-1
 public O_HS()
 {
     cfg = new INI(AppDomain.CurrentDomain.SetupInformation.ApplicationBase + "config\\hs.ini");
     err = new LOG();
     _serverIP = cfg.GetVal("Advanced", "IPAddress");
     _serverPort = cfg.GetVal("Advanced", "Port");
     _user = cfg.GetVal("Advanced", "UserId");
     _passWord = cfg.GetVal("Advanced", "PassWord");
 }
예제 #7
0
 public I_CPI()
 {
     cfg = new INI(AppDomain.CurrentDomain.SetupInformation.ApplicationBase + "config\\cpi.ini");
     err = new LOG();
     _server = cfg.GetVal("Connect", "Server");
     _dataBase = cfg.GetVal("Connect", "Database");
     _user = cfg.GetVal("Connect", "User");
     _password = cfg.GetVal("Connect", "Password");
     StringBuilder cmd = new StringBuilder(string.Format("Data Source={0},1433;Network Library=DBMSSOCN;Initial Catalog={1};User ID={2};Password={3};", _server, _dataBase, _user, _password));
     _concmd = cmd.ToString();
 }
예제 #8
0
파일: INI.cs 프로젝트: DCoderLT/cncpp
 public void CombineWithFile(INI otherINI)
 {
     foreach (var s in otherINI.Sections) {
         if(!SectionExists(s.Key)) {
             AddSection(s.Key);
         }
         var sect = Sections[s.Key];
         foreach (var e in s.Value.Entries) {
             if (!sect.ContainsKey(e.Value.Key)) {
                 sect.AddKey(e.Value.Key, e.Value.Value);
             } else {
                 sect[e.Value.Key] = e.Value;
             }
         }
     }
 }
예제 #9
0
        public O_MSSQL()
        {
            cfg = new INI(AppDomain.CurrentDomain.SetupInformation.ApplicationBase + "config\\sql.ini");
            err = new LOG();
            _server = cfg.GetVal("Connect", "Server");
            _dataBase = cfg.GetVal("Connect", "Database");
            _user = cfg.GetVal("Connect", "User");
            _password = cfg.GetVal("Connect", "Password");
            StringBuilder cmd = new StringBuilder(string.Format("Data Source={0};Initial Catalog={1};User ID={2};Password={3}", _server, _dataBase, _user, _password));
            _concmd = cmd.ToString();

            _tblName = cfg.GetVal("Output", "Table");
            _tagField = cfg.GetVal("Output", "tag");
            _valField = cfg.GetVal("Output", "val");
            _dtmField = cfg.GetVal("Output", "dtm");
        }
예제 #10
0
        string _user; //用户名

        #endregion Fields

        #region Constructors

        public I_FTP()
        {
            cfg = new INI(AppDomain.CurrentDomain.SetupInformation.ApplicationBase + "config\\ftp.ini");
            err = new LOG();
            _server = cfg.GetVal("Connect", "Server");
            _user = cfg.GetVal("Connect", "User");
            _password = cfg.GetVal("Connect", "Password");

            ftpPath = cfg.GetVal("Data", "FtpPath").Split(';');
            localPath = new string[ftpPath.Length];
            unit = new string[ftpPath.Length][][];
            nameModel = cfg.GetVal("Data", "FileName").Split(';');
            fileName = new string[nameModel.Length];
            string[] tmpperiod = cfg.GetVal("Data", "Period").Split(';');
            period = new int[tmpperiod.Length];
            lastDT = cfg.GetVal("Data", "LastTime").Split(';');

            for (int i = 0; i < ftpPath.Length; ++i)
            {
                localPath[i] = AppDomain.CurrentDomain.SetupInformation.ApplicationBase + ftpPath[i].Replace('/', '\\');
                if (!Directory.Exists(localPath[i])) Directory.CreateDirectory(localPath[i]);
                FileInfo[] filelist = new DirectoryInfo(localPath[i]).GetFiles();
                if (0 != filelist.Length)
                {
                    fileName[i] = filelist[i].Name;
                    GetFileData(i);
                }
            }

            for (int i = 0; i < tmpperiod.Length; ++i)
            {
                string[] tmp = tmpperiod[i].Split('_');
                switch (tmp[0])
                {
                    case "d":
                        period[i] = 1440 * int.Parse(tmp[1]);
                        break;
                    case "m":
                        int.TryParse(tmp[1], out period[i]);
                        break;
                }
            }

            flag = true;
        }
예제 #11
0
        protected override void OnStart(string[] args)
        {
            Timer t = new Timer();

            t.Interval  = 60000;
            t.AutoReset = true;
            t.Elapsed  += (object sender, ElapsedEventArgs e) =>
            {
                INI config = new INI(serviceConfigFile);

                if (config.KeyExists("ExtraFiles", "Files"))
                {
                    string[] extraFiles = config.Read("ExtraFiles", "Files").Split(',');
                    foreach (string file in extraFiles)
                    {
                        targetFiles.Add(file);
                    }
                }

                int now     = new UnixTimestamp().Timestamp;
                int nextRun = int.Parse(config.Read("NextRun", "Operation"));

                if (now >= nextRun)
                {
                    INI      pathsConfig = new INI(pathsConfigFile);
                    string[] paths       = new string[]
                    {
                        pathsConfig.Read("Tf2", "Folders"),
                        pathsConfig.Read("L4d2", "Folders")
                    };
                    List <string> linesToLog  = new List <string>();
                    string        logFileName = $"Log-{DateTime.Now.ToString("yyyy-MM-dd")}.log";

                    foreach (string path in paths)
                    {
                        linesToLog.Add(LogLine($"Processing folder {path}"));

                        int filesDeleted = 0;
                        foreach (string file in Directory.EnumerateFiles(path, "*.cache", SearchOption.AllDirectories))
                        {
                            if (File.Exists(file))
                            {
                                File.Delete(file);
                                filesDeleted++;
                                linesToLog.Add(LogLine($"Deleted cache file {file}"));
                            }
                        }

                        if (filesDeleted > 0)
                        {
                            linesToLog.Add(LogLine($"Deleted a total of {filesDeleted} file(s) from {path}"));
                        }
                        else
                        {
                            linesToLog.Add(LogLine($"{path} is already clean!"));
                        }
                    }

                    string runInterval = config.Read("CheckInterval", "Checking");
                    int    length;
                    switch (runInterval)
                    {
                    case "hourly":
                        length = 3600;
                        break;

                    case "daily":
                        length = 86400;
                        break;

                    default:
                    case "weekly":
                        length = 604800;
                        break;

                    case "monthly":
                        length = 2592000;
                        break;

                    case "yearly":
                        length = 31556952;
                        break;
                    }

                    int newNextRun = (now + length);

                    config.Write("NextRun", newNextRun.ToString(), "Operation");

                    linesToLog.Add(LogLine($"Setting next schedule run to {newNextRun}"));

                    File.WriteAllLines(Path.Combine(logFolder, logFileName), linesToLog);
                }
            };
            t.Start();
        }
예제 #12
0
        public void LoadOption()
        {
            StringBuilder temp = new StringBuilder(255);
            int           i;

            i = INI.GetPrivateProfileString("Setup", "Light Comm Port", "COM4", temp, 255, m_strSetupINIFile);
            txtLightCommPort.Text = temp.ToString();
            i = INI.GetPrivateProfileString("PLC", "Read D Address", "1000", temp, 255, m_strSetupINIFile);
            m_strPLCReadDAddress = temp.ToString();
            i = INI.GetPrivateProfileString("PLC", "Read M Address", "1000", temp, 255, m_strSetupINIFile);
            m_strPLCReadMAddress = temp.ToString();
            i = INI.GetPrivateProfileString("PLC", "Write D Address", "1100", temp, 255, m_strSetupINIFile);
            m_strPLCWriteDAddress = temp.ToString();
            i = INI.GetPrivateProfileString("PLC", "Write M Address", "1100", temp, 255, m_strSetupINIFile);
            m_strPLCWriteMAddress = temp.ToString();
            i                = INI.GetPrivateProfileString("PLC", "Port", "COM1", temp, 255, m_strSetupINIFile);
            m_strPLCPort     = temp.ToString();
            i                = INI.GetPrivateProfileString("PLC", "Baudrate", "9600", temp, 255, m_strSetupINIFile);
            m_strPLCBaudrate = temp.ToString();
            i                = INI.GetPrivateProfileString("PLC", "Channel", "01", temp, 255, m_strSetupINIFile);
            m_strPLCChannel  = temp.ToString();
            i                = INI.GetPrivateProfileString("Setup", "Mode", "1", temp, 255, m_strSetupINIFile);

            int.TryParse(temp.ToString(), out m_nMode);
            if (m_nMode == 1)
            {
                btnICT.BackColor = Color.LightGreen;
                btnFCT.BackColor = Color.LightPink;
            }
            else
            {
                m_nMode          = 2;
                btnFCT.BackColor = Color.LightGreen;
                btnICT.BackColor = Color.LightPink;
            }
            i                   = INI.GetPrivateProfileString("DB", "User ID", "", temp, 255, m_strSetupINIFile);
            txtDBID.Text        = temp.ToString();
            i                   = INI.GetPrivateProfileString("DB", "Password", "", temp, 255, m_strSetupINIFile);
            txtDBPassword.Text  = temp.ToString();
            i                   = INI.GetPrivateProfileString("DB", "IP Address", "", temp, 255, m_strSetupINIFile);
            txtDBIPAddress.Text = temp.ToString();
            string strdata;

            i       = INI.GetPrivateProfileString("DB", "Check DB1", "0", temp, 255, m_strSetupINIFile);
            strdata = temp.ToString();

            if (strdata == "1")
            {
                chkDBCheck1.Checked = true;
            }
            else
            {
                chkDBCheck1.Checked = false;
            }

            i       = INI.GetPrivateProfileString("DB", "Check DB2", "0", temp, 255, m_strSetupINIFile);
            strdata = temp.ToString();
            if (strdata == "1")
            {
                chkDBCheck2.Checked = true;
            }
            else
            {
                chkDBCheck2.Checked = false;
            }

            i       = INI.GetPrivateProfileString("Setup", "No Label Pass", "0", temp, 255, m_strSetupINIFile);
            strdata = temp.ToString();
            if (strdata == "1")
            {
                chkNoLabel.Checked = true;
            }
            else
            {
                chkNoLabel.Checked = false;
            }

            i       = INI.GetPrivateProfileString("Setup", "Save Image", "0", temp, 255, m_strSetupINIFile);
            strdata = temp.ToString();
            if (strdata == "1")
            {
                chkSaveImage.Checked = true;
            }
            else
            {
                chkSaveImage.Checked = false;
            }

            txtDReadAddr.Text  = m_strPLCReadDAddress;
            txtMReadAddr.Text  = m_strPLCReadMAddress;
            txtDWriteAddr.Text = m_strPLCWriteDAddress;
            txtMWriteAddr.Text = m_strPLCWriteMAddress;
            txtPLCPort.Text    = m_strPLCPort;
            txtBaudRate.Text   = m_strPLCBaudrate;
            txtPLCChannel.Text = m_strPLCChannel;
        }
예제 #13
0
        public static void LoadTemplates()
        {
            // Если уже кто-то загружает шаблоны (другой поток) - ждём максимум 4 секунды
            int i = 10; while (TemplatesIsLoading) { if (i-- < 0) return; Thread.Sleep(400); }

            // load templates from resource
            INI ini = new INI();
            Assembly assembly = Assembly.GetExecutingAssembly();
            Stream stream = null;
            try {
                stream = assembly.GetManifestResourceStream("HMSEditorNS.Resources.hms_templates.txt");
                if (stream != null) {
                    using (StreamReader reader = new StreamReader(stream)) {
                        stream = null;
                        ini.Text = reader.ReadToEnd();
                    }
                }
            }
            catch (Exception e) {
                LogError(e.ToString());

            } finally {
                stream?.Dispose();
            }

            TemplatesIsLoading = true; // Говорим какбе другим потокам, которые могут обновлять в фоне: "Стапэ - идёт загрузка и установка шаблонов".
            foreach (var lang in new[] { Language.CPPScript, Language.PascalScript, Language.BasicScript, Language.JScript }) {
                AddTemplatesFromIni(Templates, lang, ini);
                LoadTemplatesFromDirectory(Templates, lang, TemplatesDir + "/" + lang);
            }
            TemplatesIsLoading = false;
        }
예제 #14
0
        public static List <string> skipped = new List <string>();  // Define the skipped list for error tracking

        /// <summary>
        /// Installs the specified mods (requires for statement iteration for more than one mod).
        /// </summary>
        /// <param name="mod">File path to the mod's INI file.</param>
        /// <param name="name">Name of the mod by Title key.</param>
        public static void InstallMods(string mod, string name)
        {
            string platform = INI.DeserialiseKey("Platform", mod);                // Deserialise 'Platform' key
            bool   merge    = false;                                              // Deserialise 'Merge' key

            string[] read_only = INI.DeserialiseKey("Read-only", mod).Split(','); // Deserialise 'Read-only' key

            try {
                // Attempt to parse as a Boolean value
                merge = bool.Parse(INI.DeserialiseKey("Merge", mod));
            } catch { merge = false; }

            //Skip the mod if the platform is invalid
            string system = Literal.System(Properties.Settings.Default.Path_GameDirectory);

            if (system != platform && platform != "All Systems")
            {
                skipped.Add($"► {name} (failed because the mod was not targeted for the {system})");
                return;
            }

            // Search for all files with specified LINQ filters
            List <string> files = Directory.GetFiles(Path.GetDirectoryName(mod), "*.*", SearchOption.AllDirectories)
                                  .Where(s => s.Contains(".ar") ||
                                         s.EndsWith(".arl") ||
                                         s.EndsWith(".dds") ||
                                         s.EndsWith("default.xex") ||
                                         s.EndsWith("EBOOT.BIN") ||
                                         s.EndsWith(".sfd") ||
                                         s.EndsWith(".pfd") ||
                                         s.EndsWith(".csb") ||
                                         s.EndsWith(".cpk")).ToList();

            foreach (string file in files)
            {
                // Absolute file path
                string filePath = file.Remove(0, Path.GetDirectoryName(mod).Length);

                // Absolute file path (from the mod) combined with the game directory
                string vanillaFilePath = Path.Combine(Path.GetDirectoryName(Properties.Settings.Default.Path_GameDirectory), filePath.Substring(1));

                // Define string to store backed up file
                string targetFilePath = string.Empty;

                // Proceed with backup
                if ((targetFilePath = Content.CreateBackup(vanillaFilePath)) != string.Empty)
                {
                    // Decompress backed up ARL to compare AR count with later
                    if (Path.GetExtension(vanillaFilePath) == ".arl")
                    {
                        Decompress.DecompressBySystem(targetFilePath);
                    }

                    // Merge modified data
                    if (Path.GetFileName(file).Contains(".ar") && merge && !read_only.Contains(Path.GetFileName(file)))
                    {
                        if (RushInterface._debug)
                        {
                            Console.WriteLine($"Merging: {file}");
                        }
                        Content.Merge(vanillaFilePath, file);

                        // Copy the modified data
                    }
                    else
                    {
                        if (RushInterface._debug)
                        {
                            Console.WriteLine($"Copying: {file}");
                        }
                        File.Copy(file, vanillaFilePath, true);
                    }
                }
                else
                {
                    if (RushInterface._debug)
                    {
                        Console.WriteLine($"Copying: {file}");
                    }
                    File.Copy(file, vanillaFilePath, true);
                }
            }
        }
예제 #15
0
        public void SetConfig_Modbus(string configFile)
        {
            FileStream fs = new FileStream(configFile, FileMode.OpenOrCreate);
            fs.Close();

            //try
            {
                cfg = new INI(AppDomain.CurrentDomain.SetupInformation.ApplicationBase + configFile);
                m_IPAddress = cfg.GetVal("TCP/IP", "IPAddress");
                m_Port = Convert.ToInt32(cfg.GetVal("TCP/IP", "Port"));

                m_COM = cfg.GetVal("SerialPort", "COM");
                m_BaudRate = Convert.ToInt32(cfg.GetVal("SerialPort", "BaudRate"));
                m_DataBits = Convert.ToInt32(cfg.GetVal("SerialPort", "DataBits"));
                m_StopBits = Convert.ToInt32(cfg.GetVal("SerialPort", "StopBits"));
                m_Parity = Convert.ToInt32(cfg.GetVal("SerialPort", "Parity"));
                m_Handshake = Convert.ToInt32(cfg.GetVal("SerialPort", "Handshake"));
                m_ModbusType = cfg.GetVal("SerialPort", "ModbusType");

                m_DeviceAddress = Convert.ToByte(cfg.GetVal("Advanced", "DeviceAddress"));
                m_SendRate = Convert.ToSingle(cfg.GetVal("Advanced", "SendRate"));
                m_SendTaskInteval = Convert.ToSingle(cfg.GetVal("Advanced", "SendTaskInteval"));
                m_OPCServerName = cfg.GetVal("Advanced", "OPCServerName");
                //m_YcType = Convert.ToInt32(cfg.GetVal("Advanced", "ycType"));
                //m_YmType = Convert.ToInt32(cfg.GetVal("Advanced", "ymType"));

                m_coilsStartAddr = Convert.ToInt32(cfg.GetVal("DATA", "Coils_StartAddr"));
                m_coilsLen = Convert.ToInt32(cfg.GetVal("DATA", "Coils_Len"));
                m_inputsStartAddr = Convert.ToInt32(cfg.GetVal("DATA", "Inputs_StartAddr")) - 10000;
                m_inputsLen = Convert.ToInt32(cfg.GetVal("DATA", "Inputs_Len"));
                m_holdregStartAddr = Convert.ToInt32(cfg.GetVal("DATA", "HoldReg_StartAddr")) - 40000;
                m_holdregLen = Convert.ToInt32(cfg.GetVal("DATA", "HoldReg_Len"));
                m_inputregStartAddr = Convert.ToInt32(cfg.GetVal("DATA", "InputReg_StartAddr")) - 30000;
                m_inputregLen = Convert.ToInt32(cfg.GetVal("DATA", "InputReg_Len"));
                m_holdregType = Convert.ToInt32(cfg.GetVal("DATA", "HoldReg_Type"));
                m_inputregType = Convert.ToInt32(cfg.GetVal("DATA", "InputReg_Type"));

                //m_yxStartAddress = Convert.ToInt32(cfg.GetVal("DATA", "yx_StartAddress"));
                //m_yxEndAddress = Convert.ToInt32(cfg.GetVal("DATA", "yx_EndAddress"));
                //m_ycStartAddress = Convert.ToInt32(cfg.GetVal("DATA", "yc_StartAddress"));
                //m_ycEndAddress = Convert.ToInt32(cfg.GetVal("DATA", "yc_EndAddress"));
                //m_ymStartAddress = Convert.ToInt32(cfg.GetVal("DATA", "ym_StartAddress"));
                //m_ymEndAddress = Convert.ToInt32(cfg.GetVal("DATA", "ym_EndAddress"));
            }
            //catch
            //{
            //    StreamWriter sw1 = new StreamWriter(configFile);
            //    string w = "";
            //    sw1.Write(w);
            //    sw1.Close();
            //    StreamWriter sw = File.AppendText(configFile);
            //    sw.WriteLine("[SerialPort]");
            //    sw.WriteLine("COM=COM1");
            //    sw.WriteLine("BaudRate=9600");
            //    sw.WriteLine("Parity=0");
            //    sw.WriteLine("DataBits=8");
            //    sw.WriteLine("StopBits=1");
            //    sw.WriteLine("Handshake=0");
            //    sw.WriteLine("ModbusType=RTU");

            //    sw.WriteLine("[TCP/IP]");
            //    sw.WriteLine("IPAddress=127.0.0.1");
            //    sw.WriteLine("Port=502");

            //    sw.WriteLine("[Advanced]");
            //    sw.WriteLine("DeviceAddress=1");
            //    sw.WriteLine("SendRate=1");
            //    sw.WriteLine("SendTaskInteval=5");
            //    sw.WriteLine("OPCServerName=SAC.OPC.Modbus");

            //    sw.WriteLine("[DATA]");
            //    sw.WriteLine("Coils_StartAddr=0");
            //    sw.WriteLine("Coils_Len=10");
            //    sw.WriteLine("Inputs_StartAddr=0");
            //    sw.WriteLine("Inputs_Len=10");
            //    sw.WriteLine("HoldReg_StartAddr=0");
            //    sw.WriteLine("HoldReg_Len=10");
            //    sw.WriteLine("HoldReg_Type=1");
            //    sw.WriteLine("InputReg_StartAddr=0");
            //    sw.WriteLine("InputReg_Len=10");
            //    sw.WriteLine("InputReg_Type=1");

            //    sw.WriteLine("yx_StartAddress=1");
            //    sw.WriteLine("yx_EndAddress=10");
            //    sw.WriteLine("yc_StartAddress=40001");
            //    sw.WriteLine("yc_EndAddress=40012");
            //    sw.WriteLine("ym_StartAddress=30001");
            //    sw.WriteLine("ym_EndAddress=30012");
            //    sw.Close();
            //}
        }
예제 #16
0
        private void Login_Load(object sender, EventArgs e)
        {
            //string decryptstr = AES.Decrypt(Convert.FromBase64String("NzgOGTK08BvkZN5q8XvG6Q=="), "rBwj1MIAivVN222b");

            //string d;
            //d = Encoding.ASCII.GetString(b);

            //string id = MA.get_area_id(new string[] { "灯火摇曳的漫步之园", "通往金殿玉楼的山丘" });
            //MA.exploration_explore("50002", "5");

                //byte[] undecryptbyte = HTTP.HttpPost1("http://game1-CBT.ma.sdo.com:10001/connect/app/exploration/area?cyt=1", "", "Cookie: S=pb9qdcjmknq2r195mlhbsp7n32", "Cookie2: $Version=1");

                //

            ini = new INI(Application.StartupPath + "\\my.ini");
            string str = ini.IniReadValue("LOGIN", "user");
            if (str != null && str != "")
                textBox1.Text = str;

            //脱机用户名密码
            str = ini.IniReadValue("TJ", "proxy");
            if (str != null && str != "")
            {
                MA.http_proxy = str;
                textBox3.Text = str;
            }
        }
예제 #17
0
        private void LoadWidgets()
        {
            // 위젯 검색
            string[] Widgets = Directory.GetFiles(ConfigManager.WidgetPath, "*.ini", SearchOption.AllDirectories);

            // 검색된 위젯 추가
            foreach (string Path in Widgets)
            {
                // 위젯 구성 분석
                INI    Widget = new INI(Path);
                string Title  = Widget.GetValue("General", "Title");

                // 위젯 섬네일 컨트롤 생성
                StackPanel WidgetStack = new StackPanel
                {
                    Width  = 120,
                    Height = 120,
                    Margin = new Thickness(15, 10, 0, 0)
                };

                Image WidgerThumb = new Image
                {
                    Width  = 80,
                    Height = 80,
                    Source = ImageLoad(Directory.GetParent(Path) + "\\" + System.IO.Path.GetFileNameWithoutExtension(Path) + ".png")
                };
                WidgetStack.Children.Add(WidgerThumb);

                TextBlock WidgetTitle = new TextBlock
                {
                    Text                = Title,
                    Margin              = new Thickness(0, 10, 0, 0),
                    VerticalAlignment   = VerticalAlignment.Bottom,
                    HorizontalAlignment = HorizontalAlignment.Center
                };
                WidgetStack.Children.Add(WidgetTitle);

                // 위젯 섬네일 컨트롤 이벤트 설정
                WidgetStack.MouseLeftButtonDown += (s, e) =>
                {
                    IsDrawerOpen = false;
                    GridWidget Target = new GridWidget
                    {
                        NowLoading   = true,
                        LazyLoading  = Path,
                        LoadingImage = (BitmapImage)WidgerThumb.Source
                    };

                    if (Target.LoadConfig(Path))
                    {
                        Add(Target);
                        Target.StartMouseDown();
                    }
                    else
                    {
                        AlertDialog Dialog = new AlertDialog(Application.Current.MainWindow,
                                                             "오류",
                                                             "위젯을 로드할 수 없습니다.\n" +
                                                             "구성 파일 오류가 발생하였습니다.",
                                                             false);

                        Dialog.ShowDialog();
                    }
                };

                // 콘텐츠 스택에 섬네일 컨트롤 추가
                StackDrawerContent.Children.Add(WidgetStack);
            }
        }
예제 #18
0
 private void 颜色CToolStripMenuItem_Click(object sender, EventArgs e)//设置颜色并保存到配置
 {
     style.ShowColors();
     INI.SetModeColor(currentMode, style.Color.ToArgb().ToString());
 }
예제 #19
0
 private void applyModeColor()//读取配置并应用:颜色
 {
     richTextBox1.ForeColor = Color.FromArgb(int.Parse(INI.GetModeColor(currentMode)));
 }
예제 #20
0
 private void applyModeFont()//读取配置并应用:字体
 {
     string[] values = INI.GetModeFont(currentMode);
     richTextBox1.Font = new Font(values[0], (float)(Convert.ToDouble(values[1])), values[2] == "True" ? FontStyle.Bold : FontStyle.Regular);
 }
예제 #21
0
        private static void ExpiredDataValidate()
        {
            FileInfo fi = new FileInfo(programFolder + @"\ExpiredDate.ini");

            if (fi.Exists)
            {
                string[]      sections   = INI.INIGetAllSectionNames(fi.FullName);
                string[]      keys       = null;
                List <string> instrument = new List <string>();
                int           tempInt;
                foreach (string item in sections)
                {
                    if (Int32.TryParse(item, out tempInt))
                    {
                        standard.Add(item, new StandardInstrument(INI.INIGetStringValue(fi.FullName, item, "Name", null), INI.INIGetStringValue(fi.FullName, item, "Date", null)));
                    }
                    else
                    {
                        keys       = INI.INIGetAllItemKeys(fi.FullName, item);
                        instrument = new List <string>();
                        foreach (string item1 in keys)
                        {
                            instrument.Add(INI.INIGetStringValue(fi.FullName, item, item1, null));
                        }
                        if (standardUsage.ContainsKey(item))
                        {
                            standardUsage.Remove(item);
                        }
                        standardUsage.Add(item, instrument);
                    }
                }
            }
            else
            {
                LogHelper.AddDataError("找不到ExpiredDate.ini文件", true);
            }
        }
예제 #22
0
        public bool Load(string Path)
        {
            try
            {
                // 위젯 분석
                INI Widget = new INI(Path);
                string Local = "<%LOCAL%>";
                _INI = Path;
                _Title = Widget.GetValue("General", "Title");
                _Author = Widget.GetValue("General", "Author");
                _Summary = Widget.GetValue("General", "Summary");
                _AssemblyFile = Widget.GetValue("Assembly", "File").Replace(Local, System.IO.Path.GetDirectoryName(Path)).Trim();
                _AssemblyEntry = Widget.GetValue("Assembly", "Entry").Replace(Local, System.IO.Path.GetDirectoryName(Path)).Trim();
                _AssemblyArgument = Widget.GetValue("Assembly", "Argument").Replace(Local, System.IO.Path.GetDirectoryName(Path)).Trim();
                _AppearanceWidth = int.Parse(Widget.GetValue("Appearance", "Width"));
                _AppearanceHeight = int.Parse(Widget.GetValue("Appearance", "Height"));
                _AppearanceExpandable = bool.Parse(Widget.GetValue("Appearance", "Expandable"));

                if (AssemblyFile.Equals("local"))
                {
                    // 내부 어셈블리 사용
                    switch (AssemblyEntry)
                    {
                        case "WebView":
                            ChromiumWebBrowser WebView = new ChromiumWebBrowser();
                            WebView.Address = AssemblyArgument;
                            BorderContent.Child = WebView;
                            break;
                    }
                }
                else
                {
                    // 외부 어셈블리 참조
                    Assembly WidgetAssembly = Assembly.LoadFrom(AssemblyFile);
                    Type[] TypeList = WidgetAssembly.GetTypes();
                    foreach (Type Target in TypeList)
                    {
                        if (Target.Name == AssemblyEntry)
                        {
                            // 어셈블리 진입점 검색 및 인스턴스 생성
                            _WidgetTarget = Target;
                            _WidgetControl = Activator.CreateInstance(Target) as UserControl;

                            // 어셈블리에 전달할 인자가 존재하는 경우 메소드 호출
                            if (AssemblyArgument.Length > 0)
                            {
                                CallMethod("SetArgument", AssemblyArgument);
                            }

                            break;
                        }
                    };

                    // 검색된 컨트롤을 현재 컨트롤에 추가
                    BorderContent.Child = WidgetControl;
                }

                // 위젯 모양새 적용
                if (ParentDock != null)
                {
                    Width = AppearanceWidth * ParentDock.GridWidth;
                    Height = AppearanceHeight * ParentDock.GridHeight;
                }
                else
                {
                    WidthColumn = AppearanceWidth;
                    HeightRow = AppearanceHeight;
                }

                return true;
            }
            catch
            {
                return false;
            }
        }
예제 #23
0
    // Use this for initialization
    void Start()
    {
        if (IniGameMemory.instance == null)
        {
            return;
        }
        //Declare a "variable" on the fly....
        if (IniGameMemory.instance.GetDataValue(g, k) == -1)
        {
            //only declare if not found to have it be modable in editor.
            IniGameMemory.instance.WriteData(g, k, "5");
        }

        print(IniGameMemory.instance.GetDataValue(g, k) + " + 2 =");
        //add to the value of hte variable...
        IniGameMemory.instance.IncrementKeyValue(g, k, 2, 0);
        //print the result... should be 7...
        print(IniGameMemory.instance.GetDataValue(g, k));
        //write any number of variables inside of the same group.
        IniGameMemory.instance.WriteData(g, k2, 2);
        print("value of " + k2 + " is " + IniGameMemory.instance.GetDataString(g, k2));
        //int variable can be overriden with a string.
        IniGameMemory.instance.WriteData(g, k2, "bob");
        print("now, value of " + k2 + " is " + IniGameMemory.instance.GetDataString(g, k2));


        //try printing a variable that does not exist...
        //it can be given a default value if it doesn't find it in the list...
        print(IniGameMemory.instance.GetDataValue(g, k3, 32));
        //...write to that variable now...
        IniGameMemory.instance.WriteData(g, k3, 69);
        //if you write to that variable later on, it will print the new value ignoring the default value!
        print(IniGameMemory.instance.GetDataValue(g, k3, 32));
        //names can also have a default value:
        const string anotherGroup  = "AnotherGroup";
        const string nameKey       = "Name";
        string       resultingName = IniGameMemory.instance.GetDataString(anotherGroup, nameKey, "Brian");

        print("Hello, my name is " + resultingName);
        //a static class is included in Ackk.INI.Helpers.INI in order to make the instance easier to access...
        INI.Get().WriteData(g, floatKey, myFloatValue);
        print(INI.Get().GetDataFloat(g, floatKey, 0f));
        //...........................................
        string RPG = "RPG.Hero.Stats.Loto";

        //use shortcut features....
        INI.Write(RPG, "Name", "Loto");
        INI.Write(RPG, "MaxHp", 10);
        INI.Write(RPG, "MaxMp", 6);
        INI.Write(RPG, "Atk", 8);
        INI.Write(RPG, "Def", 3);
        INI.Write(RPG, "Luk", 4);
        INI.Write(RPG, "Spd", 5);
        RPG = "RPG.Hero.Stats.Wanda";
        INI.Write(RPG, "Name", "Wanda");
        INI.Write(RPG, "MaxHp", 9);
        INI.Write(RPG, "MaxMp", 10);
        INI.Write(RPG, "Atk", 6);
        INI.Write(RPG, "Def", 8);
        INI.Write(RPG, "Luk", 2);
        INI.Write(RPG, "Spd", 4);
        //or if writing the group is tedious:
        RPG = "RPG.Hero.Stats.Brian";
        INI.SetWorkingGroup(RPG);
        INI.Write("Name", "Brian");
        INI.Write("MaxHp", 10);
        INI.Write("MaxMp", 6);
        INI.Write("Atk", 8);
        INI.Write("Def", 3);
        INI.Write("Luk", 4);
        INI.Write("Spd", 5);
        //or you can just add to the working group via an array:
        RPG = "RPG.Hero.Stats.Anon";
        INI.SetWorkingGroup(RPG);
        string[] anonStats =
        {
            "Name:Anon",
            "MaxHp:10",
            "MaxMp:6",
            "Atk:75",
            "Def:18",
            "Luk:40",
            "Spd:2"
        };
        INI.AddArray(anonStats);
        //disable saving of any group (marks it so it doesn't write to the file)
        //this means you can have temp variables in a group!
        INI.Get().SetGroupSavability(INI.workingGroupStr, false);
        //if you dont want to use an array, use the string to array converter:
        RPG = "RPG.Hero.Stats.Master";
        INI.SetWorkingGroup(RPG);
        string defineMasterStats = "Name:Master,MaxHp:10,MaxMp:6,Atk:99999,Def:90,Spd:76";

        //don't forget to use chars for splitters and not strings!
        INI.AddArray(INI.Get().StringToIniKeyArray(defineMasterStats, ','), ':');


        //cache the address of a group/key //prints using  INI.Get().GetDataStringAtAddress(x,y) format (returns string use GetDataValueAtAddress() for int...
        int[] anonNameAddress = INI.Get().GetGroupKeyAddress("RPG.Hero.Stats.Anon", "Name");
        print("The name at address" + anonNameAddress[0] + "," + anonNameAddress[1] + " is:" + INI.Get().GetDataStringAtAddress(anonNameAddress[0], anonNameAddress[1]));
        print("Or insert the array as a single arg to get the same data:" + INI.Get().GetDataStringAtAddress(anonNameAddress));

        //note that caching can be dangerous for groups that are subject to sorting/deletion...
        print("if the address is not found it returns a value of:" + INI.Get().GetDataStringAtAddress(100, 100));
    }
예제 #24
0
        public void LoadConfig(string path)
        {
            try
            {
                /*
                 * string[] str = File.ReadAllLines(path);
                 * string[] str2 = new string[str.Count() * 2];
                 * for (int i = 0; i < str.Count(); i++)
                 * {
                 *  str2[i * 2] = str[i].Split('=')[0];
                 *  str2[i * 2 + 1] = str[i].Split('=')[1];
                 * }
                 *
                 * groupPicCount = Convert.ToInt16(str2[1]);
                 * groupColumnCount = Convert.ToInt16(str2[3]);
                 * picBoxRowCount = Convert.ToInt16(str2[5]);
                 * pageHeight = Convert.ToInt16(str2[7]);
                 * pageHeaderHeight = Convert.ToInt16(str2[9]);
                 * pageVerticalOffset = Convert.ToInt16(str2[11]);
                 * picBoxColumnCount = Convert.ToInt16(str2[13]);
                 * titleBoxRowCount = Convert.ToInt16(str2[15]);
                 * endBoxColumnCount = Convert.ToInt16(str2[17]);
                 * endBoxRowCount = Convert.ToInt16(str2[19]);
                 * INSPECTION_TIME_ROW_INDEX = Convert.ToInt16(str2[21]);
                 * INSPECTION_TIME_COLUMN_INDEX = Convert.ToInt16(str2[23]);
                 * ITEM_NO_ROW_INDEX = Convert.ToInt16(str2[25]);
                 * ITEM_NO_COLUMN_INDEX = Convert.ToInt16(str2[27]);
                 * FORTH_LINE_ROW_INDEX = Convert.ToInt16(str2[29]);
                 * FORTH_LINE_COLUMN_INDEX = Convert.ToInt16(str2[31]);
                 * DOC_TITLE_ROW_INDEX = Convert.ToInt16(str2[33]);
                 * DOC_TITLE_COLUMN_INDEX = Convert.ToInt16(str2[35]);
                 * ALERT_COLOR_CELL_ROW_INDEX = Convert.ToInt16(str2[37]);
                 * ALERT_COLOR_CELL_COLUMN_INDEX = Convert.ToInt16(str2[39]);
                 * PICTURE_MARGIN = Convert.ToDouble(str2[41]);
                 * STANDARD_ROW_HEIGHT = Convert.ToDouble(str2[43]);
                 */

                INI configFile = new INI(path);
                groupPicCount                 = Convert.ToInt16(configFile.GetValue("groupPicCount"));
                groupColumnCount              = Convert.ToInt16(configFile.GetValue("groupColumnCount"));
                picBoxRowCount                = Convert.ToInt16(configFile.GetValue("picBoxRowCount"));
                pageHeight                    = Convert.ToInt16(configFile.GetValue("pageHeight"));
                pageHeaderHeight              = Convert.ToInt16(configFile.GetValue("pageHeaderHeight"));
                pageVerticalOffset            = Convert.ToInt16(configFile.GetValue("pageVerticalOffset"));
                picBoxColumnCount             = Convert.ToInt16(configFile.GetValue("picBoxColumnCount"));
                titleBoxRowCount              = Convert.ToInt16(configFile.GetValue("titleBoxRowCount"));
                endBoxColumnCount             = Convert.ToInt16(configFile.GetValue("endBoxColumnCount"));
                endBoxRowCount                = Convert.ToInt16(configFile.GetValue("endBoxRowCount"));
                INSPECTION_TIME_ROW_INDEX     = Convert.ToInt16(configFile.GetValue("INSPECTION_TIME_ROW_INDEX"));
                INSPECTION_TIME_COLUMN_INDEX  = Convert.ToInt16(configFile.GetValue("INSPECTION_TIME_COLUMN_INDEX"));
                ITEM_NO_ROW_INDEX             = Convert.ToInt16(configFile.GetValue("ITEM_NO_ROW_INDEX"));
                ITEM_NO_COLUMN_INDEX          = Convert.ToInt16(configFile.GetValue("ITEM_NO_COLUMN_INDEX"));
                FORTH_LINE_ROW_INDEX          = Convert.ToInt16(configFile.GetValue("FORTH_LINE_ROW_INDEX"));
                FORTH_LINE_COLUMN_INDEX       = Convert.ToInt16(configFile.GetValue("FORTH_LINE_COLUMN_INDEX"));
                DOC_TITLE_ROW_INDEX           = Convert.ToInt16(configFile.GetValue("DOC_TITLE_ROW_INDEX"));
                DOC_TITLE_COLUMN_INDEX        = Convert.ToInt16(configFile.GetValue("DOC_TITLE_COLUMN_INDEX"));
                ALERT_COLOR_CELL_ROW_INDEX    = Convert.ToInt16(configFile.GetValue("ALERT_COLOR_CELL_ROW_INDEX"));
                ALERT_COLOR_CELL_COLUMN_INDEX = Convert.ToInt16(configFile.GetValue("ALERT_COLOR_CELL_COLUMN_INDEX"));
                PICTURE_MARGIN                = Convert.ToDouble(configFile.GetValue("PICTURE_MARGIN"));
                STANDARD_ROW_HEIGHT           = Convert.ToDouble(configFile.GetValue("STANDARD_ROW_HEIGHT"));
            }
            catch (Exception err)
            {
                Exit(err.Message);
                return;
            }
            finally
            {
                ProgressUpdated(2, "配置加载完成");
            }
        }
예제 #25
0
        private void frmMain_Load(object sender, EventArgs e)
        {
            //读测点配置类型
            INI cfgMain = new INI(AppDomain.CurrentDomain.SetupInformation.ApplicationBase + "main.ini");
            this.Text = cfgMain.GetVal("Display", "Title");
            string tagInfoType = cfgMain.GetVal("TagInfo", "Type");
            AddMsg(string.Format("测点配置类型为{0}.", tagInfoType));

            //读测点配置
            if ("CSV" == tagInfoType)
            {
                ArrayList numdtl = new ArrayList();
                ArrayList strdtl = new ArrayList();
                using (StreamReader sr = new StreamReader(AppDomain.CurrentDomain.SetupInformation.ApplicationBase + "tag.csv", Encoding.Default))
                {
                    string strline;
                    while (null != (strline = sr.ReadLine()))
                    {
                        string[] strfield = strline.Split(',');
                        if (99 != int.Parse(strfield[4])) numdtl.Add(strfield);
                        else strdtl.Add(strfield);
                    }
                }

                numNum = numdtl.Count;
                strNum = strdtl.Count;

                numRecord = new numInf[numNum];
                int idx = 0;
                foreach (string[] temp in numdtl)
                {
                    int.TryParse(temp[0], out numRecord[idx].sn);
                    numRecord[idx].srcId = temp[1];
                    numRecord[idx].dstId = temp[2];
                    numRecord[idx].desc = temp[3];
                    int.TryParse(temp[4], out numRecord[idx].datatype);
                    numRecord[idx++].ratio = temp[5];
                }

                strRecord = new strInf[strNum];
                idx = 0;
                foreach (string[] temp in strdtl)
                {
                    int.TryParse(temp[0], out strRecord[idx].sn);
                    strRecord[idx].srcId = temp[1];
                    strRecord[idx].dstId = temp[2];
                    strRecord[idx++].desc = temp[3];
                }
            }
            else
            {
                int.TryParse(cfgMain.GetVal("TagInfo", "NumCount"), out numNum);
                numRecord = new numInf[numNum];
                int.TryParse(cfgMain.GetVal("TagInfo", "StrCount"), out strNum);
                strRecord = new strInf[strNum];
            }

            string inputType = cfgMain.GetVal("IO", "Input");
            tslblIn.Text = inputType;
            Factory inProtocol = new Factory();
            inBrg = inProtocol.MakeInput(inputType);
            if (inBrg.Connect())
            {
                inBrg.InitPt(numNum, numRecord, strNum, strRecord);
                tslblIn.BackColor = Color.Green;
            }
            else
            {
                tslblIn.BackColor = Color.Red;
            }

            string outputType = cfgMain.GetVal("IO", "Output");
            tslblOut.Text = outputType;
            Factory outProtocol = new Factory();
            outBrg = outProtocol.MakeOutput(outputType);
            if (outBrg.Connect())
            {
                outBrg.InitPt(numNum, numRecord, strNum, strRecord);
                tslblOut.BackColor = Color.Green;
            }
            else
            {
                tslblOut.BackColor = Color.Red;
            }

            tslblCount.Text = string.Format("N:{0}_S:{1}", numNum.ToString(), strNum.ToString());
            AddMsg(String.Format("成功获取测点信息,数值点{0}个,字符串点{1}个.", numNum, strNum));

            cfg.Redraw = false;
            cfg.Rows.Count = strNum + numNum + 1;
            foreach (numInf nR in numRecord)
            {
                cfg[nR.sn + 1, 0] = nR.sn;
                cfg[nR.sn + 1, 1] = nR.srcId;
                cfg[nR.sn + 1, 2] = nR.dstId;
                cfg[nR.sn + 1, 3] = nR.desc;
            }

            foreach (strInf sR in strRecord)
            {
                cfg[sR.sn + 1, 0] = sR.sn;
                cfg[sR.sn + 1, 1] = sR.srcId;
                cfg[sR.sn + 1, 2] = sR.dstId;
                cfg[sR.sn + 1, 3] = sR.desc;
            }
            cfg.AutoSizeCol(0);
            cfg.AutoSizeCol(1);
            cfg.AutoSizeCol(2);
            cfg.AutoSizeCol(3);
            cfg.Cols[4].Width = (cfg.Width - cfg.Cols[0].Width - cfg.Cols[1].Width - cfg.Cols[2].Width - cfg.Cols[3].Width) / 2;
            cfg.Cols[5].Width = cfg.Cols[4].Width;
            cfg.Redraw = true;

            int.TryParse(cfgMain.GetVal("IO", "PeriodRT"), out periodrt);
            if (0 == periodrt) periodrt = 1;
            int.TryParse(cfgMain.GetVal("IO", "PeriodHST"), out periodhst);

            DateTime now = DateTime.Now;
            int idue = 1000 - now.Millisecond;
            thIO = new System.Threading.Timer(new TimerCallback(ThreadIO), null, idue, 1000);

            now = DateTime.Now;
            idue = 1000 - now.Millisecond;
            thCheck = new System.Threading.Timer(new TimerCallback(ThreadCheck), null, idue, 1000);

            am = new AddMsgCallback(AddMsg);
            uc = new UpdateCFGCallback(UpdateCFG);
            cl = new ColorLBLCallback(ColorLBL);
        }
예제 #26
0
 private void 根目录ToolStripMenuItem_Click(object sender, EventArgs e)
 {
     INI.OpenRoot();
 }
예제 #27
0
        /// <summary>
        /// 界面初始化
        /// </summary>
        private void InterfaceInit()
        {
            //电表基本参数初始化
            string[] ports = System.IO.Ports.SerialPort.GetPortNames();//获取当前电脑串口
            if (ports.Length < 1)
            {
                ports = new string[1] {
                    "COM1"
                };                               //如果当前电脑没有串口,默认写com1
            }
            Array.Sort(ports);
            toolStripComboBoxCom.Items.AddRange(ports);

            string fileRoot  = AppDomain.CurrentDomain.BaseDirectory;//获取当前根目录
            string strConfig = fileRoot + "/config.ini";

            if (File.Exists(@strConfig))//ini文件是否存在
            {
                INI ini = new INI(strConfig);

                bool isThePortExist = false;   //判断ini文件中保存的串口在当前电脑是否有
                for (int i = 0; i < ports.Length; i++)
                {
                    isThePortExist = (ports[i] == ini.ReadValue("ComPortSetting", "MeterCom") ? true : false);
                    if (isThePortExist)
                    {
                        toolStripComboBoxCom.Text = ini.ReadValue("ComPortSetting", "MeterCom");
                        break;
                    }
                }
                if (!isThePortExist)
                {
                    toolStripComboBoxCom.Text = ports[0];
                }

                toolStripComboBoxBps.Text    = ini.ReadValue("ComPortSetting", "MeterBaud");
                toolStripTextBoxOprCode.Text = ini.ReadValue("ComPortSetting", "MeterOprCode");
                toolStripTextBoxPsw.Text     = ini.ReadValue("ComPortSetting", "MeterPsw");
                toolStripTbAddr.Text         = ini.ReadValue("MeterInfo", "MeterAddress");
                //界面选择
                if (Functions.IsNum(ini.ReadValue("Interface", "TabControlSelect")))
                {
                    tabControl1.SelectedIndex = Convert.ToInt16(ini.ReadValue("Interface", "TabControlSelect"));
                }

                //是否显示更新信息
                if (ini.ReadValue("SoftWareInfo", "isUpdata") == "true")
                {
                    ini.Writue("SoftWareInfo", "isUpdata", "false");
                    AboutBox1 about = new AboutBox1();
                    about.ShowDialog();
                }
            }
            else
            {
                toolStripComboBoxCom.Text    = ports[0];
                toolStripComboBoxBps.Text    = "2400";
                toolStripTextBoxOprCode.Text = "00000001";
                toolStripTextBoxPsw.Text     = "00000002";
            }
            //初始化串口
            if (toolStripComboBoxCom.Text != string.Empty && toolStripComboBoxBps.Text != string.Empty)
            {
                IProtocol.PortName = toolStripComboBoxCom.Text;
                IProtocol.BaudRate = Convert.ToInt32(toolStripComboBoxBps.Text);
            }
            //ComPort.ComportName = toolStripComboBoxCom.Text;
            //ComPort.ComportBaudRate = int.Parse(toolStripComboBoxBps.Text);
            //底部状态栏初始化
            toolStripStatusLabel2.Text = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");
            timer1.Interval            = 1000;
            timer1.Start();
            //其他
            //btnEnergyTestStop.Enabled = false;
            //treeView1.ExpandAll();//展开treeView
            //通讯地址、密码、操作者代码
            Protocol645.Addr    = toolStripTbAddr.Text.PadLeft(12, '0');
            Protocol645.Psw     = toolStripTextBoxPsw.Text.PadLeft(8, '0');
            Protocol645.OprCode = toolStripTextBoxOprCode.Text.PadLeft(8, '0');
            //费率表格初始化
            //dgRates.Rows.Add(32);
            //for (int i = 0; i < 32; i++)
            //{
            //    dgRates.Rows[i].HeaderCell.Value = "费率" + (i + 1).ToString("D2");
            //    dgRates[1, i].Value = "NNNN.NNNN 元";
            //}
            //比较新旧版本是否一致,不一致则弹出更新信息
        }
예제 #28
0
 private void toolStripButton6_Click(object sender, EventArgs e)
 {
     INI.OpenRoot();
 }
예제 #29
0
        public static void LoadThemesFromString(string data)
        {
            INI tini = new INI {
                NoComments = true,
                Text       = data
            };
            Dict.Clear();
            foreach(string section in tini.Dict.Keys) {
                // ReSharper disable once UseObjectOrCollectionInitializer
                Theme tt = new Theme();
                tt.Name = section;
                tt.Background      = ToColor(tini.Get("Background"     , section, ""));
                tt.Caret           = ToColor(tini.Get("Caret"          , section, ""));
                tt.Foreground      = ToColor(tini.Get("Foreground"     , section, ""));
                tt.Invisibles      = ToColor(tini.Get("Invisibles"     , section, ""));
                tt.LineHighlight   = ToColor(tini.Get("LineHighlight"  , section, ""));
                tt.ChangedLines    = ToColor(tini.Get("ChangedLines"   , section, ""));
                tt.Selection       = ToColor(tini.Get("Selection"      , section, ""));
                tt.SelectionBorder = ToColor(tini.Get("SelectionBorder", section, ""));
                tt.SelectionForegr = ToColor(tini.Get("SelectionForegr", section, ""));
                tt.LineNumberColor = ToColor(tini.Get("LineNumberColor", section, ""));
                tt.IndentBackColor = ToColor(tini.Get("IndentBackColor", section, ""));

                tt.StringStyle       = ToStyle2(tini.Get("StringStyle"      , section, ""));
                tt.CommentStyle      = ToStyle2(tini.Get("CommentStyle"     , section, ""));
                tt.NumberStyle       = ToStyle2(tini.Get("NumberStyle"      , section, ""));
                tt.AttributeStyle    = ToStyle2(tini.Get("AttributeStyle"   , section, ""));
                tt.ClassNameStyle    = ToStyle2(tini.Get("ClassNameStyle"   , section, ""));
                tt.KeywordStyle      = ToStyle2(tini.Get("KeywordStyle"     , section, ""));
                tt.CommentTagStyle   = ToStyle2(tini.Get("CommentTagStyle"  , section, ""));
                tt.TagBracketStyle   = ToStyle2(tini.Get("TagBracketStyle"  , section, ""));
                tt.FunctionsStyle    = ToStyle2(tini.Get("FunctionsStyle"   , section, ""));
                tt.VariableStyle     = ToStyle2(tini.Get("VariableStyle"    , section, ""));
                tt.DeclFunctionStyle = ToStyle2(tini.Get("DeclFunctionStyle", section, ""));
                tt.PunctuationStyle  = ToStyle2(tini.Get("PunctuationStyle" , section, ""));
                tt.InvisibleStyle    = ToStyle (tini.Get("Invisibles"       , section, ""));
                tt.TypesStyle        = ToStyle2(tini.Get("TypesStyle"       , section, ""));
                Dict.Add(section, tt);
            }
        }
예제 #30
0
        public bool LoadConfig(string Path)
        {
            try
            {
                // 위젯 분석
                INI Widget = new INI(Path);
                string Local = "<%LOCAL%>";
                _INI = Path;
                _Title = Widget.GetValue("General", "Title");
                _Author = Widget.GetValue("General", "Author");
                _Summary = Widget.GetValue("General", "Summary");
                _AssemblyFile = Widget.GetValue("Assembly", "File").Replace(Local, System.IO.Path.GetDirectoryName(Path)).Trim();
                _AssemblyEntry = Widget.GetValue("Assembly", "Entry").Replace(Local, System.IO.Path.GetDirectoryName(Path)).Trim();
                _AssemblyArgument = Widget.GetValue("Assembly", "Argument").Replace(Local, System.IO.Path.GetDirectoryName(Path)).Trim();
                _AppearanceWidth = int.Parse(Widget.GetValue("Appearance", "Width"));
                _AppearanceHeight = int.Parse(Widget.GetValue("Appearance", "Height"));
                _AppearanceExpandable = bool.Parse(Widget.GetValue("Appearance", "Expandable"));

                // 위젯 모양새 적용
                if (ParentDock != null)
                {
                    Width = AppearanceWidth * ParentDock.GridWidth;
                    Height = AppearanceHeight * ParentDock.GridHeight;
                }
                else
                {
                    WidthColumn = AppearanceWidth;
                    HeightRow = AppearanceHeight;
                }

                return true;
            }
            catch
            {
                return false;
            }
        }
예제 #31
0
        /// <summary>
        /// Main program.
        /// </summary>
        /// <param name="args">Input commandline arguments</param>
        /// <returns>Return code</returns>
        static Int32 Main(String[] args)
        {
            // Assumes that in AssemblyInfo.cs, the version is specified as 1.0.* or the like,
            // with only 2 numbers specified;  the next two are generated from the date.
            System.Version v = System.Reflection.Assembly.GetExecutingAssembly().GetName().Version;

            // v.Build is days since Jan. 1, 2000, v.Revision*2 is seconds since local midnight
            Int32 buildYear = new DateTime(v.Build * TimeSpan.TicksPerDay + v.Revision * TimeSpan.TicksPerSecond * 2).AddYears(1999).Year;

            // Begin main code
            Console.Clear();
            Console.WriteLine("-----------------------------------------------------");
            Console.WriteLine("   TI AIS Hex File Generator for " + devString);
            Console.WriteLine("   (C) " + buildYear + ", Texas Instruments, Inc.");
            Console.WriteLine("   Ver. " + v.Major + "." + v.Minor.ToString("D2"));
            Console.WriteLine("-----------------------------------------------------");
            Console.Write("\n\n");


            // Parse the input command line parameters
            ProgramCmdParams cmdParams = ParseCmdLine(args);

            if (!cmdParams.valid)
            {
                DispHelp();
                return(-1);
            }

            // Now proceed with main program
            FileStream tempAIS_fs = null;

            Byte[] AISData, convertedData;

            AISGen_OMAP_L138 generator = new AISGen_OMAP_L138();

            // Update the default INI file name to the one supplied on the command line
            if (cmdParams.iniFileName == null)
            {
                cmdParams.iniFileName = generator.DeviceNameShort + ".ini";
            }

            // Read the INI data from file
            INISection[] iniSecs = INI.Parse(new FileStream(cmdParams.iniFileName, FileMode.Open, FileAccess.Read));

            // Force section-by-section CRC checks (may be overridden in INI file)
            generator.CRCType = CRCCheckType.SECTION_CRC;

            // Do the AIS generation
            try
            {
                AISData = AISGen.GenAIS(cmdParams.inputfileName, generator, iniSecs);
            }
            catch (Exception e)
            {
                System.Diagnostics.StackTrace trace = new System.Diagnostics.StackTrace(e, true);

                Console.WriteLine(e.StackTrace);
                Console.WriteLine("Unhandled Exception!!! Application will now exit.");
                return(-1);
            }

            tempAIS_fs = new FileStream(cmdParams.outFileName, FileMode.Create, FileAccess.Write);

            switch (cmdParams.convType)
            {
            case ConvType.Exec2Bin:
                tempAIS_fs.Write(AISData, 0, (int)AISData.Length);
                break;

            case ConvType.Exec2CArray:
                convertedData = CArray.bin2CArray(AISData, 4);
                tempAIS_fs.Write(convertedData, 0, (int)convertedData.Length);
                break;

            case ConvType.Exec2Srec:
                convertedData = SRecord.bin2srec(AISData, 0x60000000, 32);
                tempAIS_fs.Write(convertedData, 0, (int)convertedData.Length);
                break;

            case ConvType.Exec2Text:
                Console.WriteLine("Mode Not supported.");
                //Byte[] val = SRecord.bin2srec(aisData, 0x60000000, 32);
                break;
            }

            tempAIS_fs.Close();

            Console.WriteLine("Conversion is complete.");
            return(0);
        }
예제 #32
0
 public static void configurePathBackup()
 {
     Paths.PathPG         = INI.ReadValue("BACKUP", "PathPG");
     Paths.PathBackupFile = INI.ReadValue("BACKUP", "PathBackupFile");
 }
예제 #33
0
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {

                /////URL格式: http://.....?dcname=gl&reportpath=/Adventure Works/hourreport
                string dcname = Request.QueryString["DCName"].ToString();
                string reportpath = Request.QueryString["ReportPath"].ToString();

                //string dcname = "gl";
                //string reportpath = "/xsbmb/xsb001";

                INI cfg = new INI(AppDomain.CurrentDomain.SetupInformation.ApplicationBase + "config.ini");
                this.ReportViewer1.ServerReport.ReportServerUrl = new Uri(cfg.GetVal("Advanced", "ReportServer"));

                this.ReportViewer1.ServerReport.ReportPath = @reportpath;
                ReportViewer1.ServerReport.ReportServerCredentials = new CustomReportCredentials();

                //txtData.Value = DateTime.Now.ToString("yyyy-MM-dd");
                //SetParamet(txtData.Value, dcname);
                SetParamet(dcname);

            }
        }
예제 #34
0
        public bool Load(string Path)
        {
            try
            {
                // 위젯 분석
                INI    Widget = new INI(Path);
                string Local  = "<%LOCAL%>";
                _INI                  = Path;
                _Title                = Widget.GetValue("General", "Title");
                _Author               = Widget.GetValue("General", "Author");
                _Summary              = Widget.GetValue("General", "Summary");
                _AssemblyFile         = Widget.GetValue("Assembly", "File").Replace(Local, System.IO.Path.GetDirectoryName(Path)).Trim();
                _AssemblyEntry        = Widget.GetValue("Assembly", "Entry").Replace(Local, System.IO.Path.GetDirectoryName(Path)).Trim();
                _AssemblyArgument     = Widget.GetValue("Assembly", "Argument").Replace(Local, System.IO.Path.GetDirectoryName(Path)).Trim();
                _AppearanceWidth      = int.Parse(Widget.GetValue("Appearance", "Width"));
                _AppearanceHeight     = int.Parse(Widget.GetValue("Appearance", "Height"));
                _AppearanceExpandable = bool.Parse(Widget.GetValue("Appearance", "Expandable"));

                if (AssemblyFile.Equals("local"))
                {
                    // 내부 어셈블리 사용
                    switch (AssemblyEntry)
                    {
                    case "WebView":
                        ChromiumWebBrowser WebView = new ChromiumWebBrowser();
                        WebView.Address     = AssemblyArgument;
                        BorderContent.Child = WebView;
                        break;
                    }
                }
                else
                {
                    // 외부 어셈블리 참조
                    Assembly WidgetAssembly = Assembly.LoadFrom(AssemblyFile);
                    Type[]   TypeList       = WidgetAssembly.GetTypes();
                    foreach (Type Target in TypeList)
                    {
                        if (Target.Name == AssemblyEntry)
                        {
                            // 어셈블리 진입점 검색 및 인스턴스 생성
                            _WidgetTarget  = Target;
                            _WidgetControl = Activator.CreateInstance(Target) as UserControl;

                            // 어셈블리에 전달할 인자가 존재하는 경우 메소드 호출
                            if (AssemblyArgument.Length > 0)
                            {
                                CallMethod("SetArgument", AssemblyArgument);
                            }

                            break;
                        }
                    }
                    ;

                    // 검색된 컨트롤을 현재 컨트롤에 추가
                    BorderContent.Child = WidgetControl;
                }

                // 위젯 모양새 적용
                if (ParentDock != null)
                {
                    Width  = AppearanceWidth * ParentDock.GridWidth;
                    Height = AppearanceHeight * ParentDock.GridHeight;
                }
                else
                {
                    WidthColumn = AppearanceWidth;
                    HeightRow   = AppearanceHeight;
                }

                return(true);
            }
            catch
            {
                return(false);
            }
        }
예제 #35
0
        /// <summary>
        /// Removes redirected save data.
        /// </summary>
        public static void UninstallSaves(ListView.ListViewItemCollection listViewItems)
        {
            if (Properties.Settings.Default.Path_SaveData != string.Empty || File.Exists(Properties.Settings.Default.Path_SaveData))
            {
                foreach (ListViewItem mod in listViewItems)
                {
                    // Basically just to check 'SYS-DATA' as a directory
                    string saveLocation = Path.GetDirectoryName(Path.GetDirectoryName(Properties.Settings.Default.Path_SaveData));

                    // Deserialise 'Save' key
                    string savedata = INI.DeserialiseKey("Save", mod.SubItems[6].Text);

                    if (savedata != string.Empty)   // Speeds things up a bit - ensures it's not checking a default null parameter
                    {
                        if (Literal.Emulator(Properties.Settings.Default.Path_GameDirectory) == "Xenia")
                        {
                            string[] saves = Array.Empty <string>();

                            // Get all backup directories
                            if (Directory.Exists(saveLocation))
                            {
                                saves = Directory.GetDirectories(saveLocation, "SYS-DATA_back", SearchOption.AllDirectories);
                            }

                            foreach (var dir in saves)
                            {
                                // Original save data path
                                string saveFile = Path.Combine(dir.ToString().Remove(dir.Length - 5), Path.GetFileName(dir.ToString().Remove(dir.Length - 5)));

                                // Copy redirected save data back to the mod's directory (keeps user progress)
                                if (File.Exists(saveFile))
                                {
                                    Console.WriteLine($"Removing: {dir}");
                                    if (savedata != string.Empty)
                                    {
                                        File.Copy(saveFile, Path.Combine(Path.GetDirectoryName(mod.SubItems[6].Text), "savedata.360"), true);
                                    }
                                }

                                // Recursively erase redirected save data
                                if (Directory.Exists(dir.ToString().Remove(dir.Length - 5)))
                                {
                                    Console.WriteLine($"Removing: {dir}");
                                    Directory.Delete(dir.ToString().Remove(dir.Length - 5), true);
                                }

                                // Restore original save data
                                Directory.Move(dir.ToString(), dir.ToString().Remove(dir.Length - 5));
                            }
                        }
                        else if (Literal.Emulator(Properties.Settings.Default.Path_GameDirectory) == "RPCS3")
                        {
                            string[] saves = Array.Empty <string>();

                            // Original save data path
                            if (Directory.Exists(saveLocation))
                            {
                                saves = Directory.GetFiles(saveLocation, "SYS-DATA_back", SearchOption.AllDirectories);
                            }

                            foreach (var file in saves)
                            {
                                string saveFile = Path.Combine(file.ToString().Remove(file.Length - 5), Path.GetFileName(file.ToString().Remove(file.Length - 5)));

                                // Copy redirected save data back to the mod's directory (keeps user progress)
                                if (File.Exists(saveFile))
                                {
                                    Console.WriteLine($"Removing: {file}");
                                    if (savedata != string.Empty)
                                    {
                                        File.Copy(saveFile, Path.Combine(Path.GetDirectoryName(mod.SubItems[6].Text), "savedata.ps3"), true);
                                    }
                                }

                                // Erase redirected save data
                                if (File.Exists(file.ToString().Remove(file.Length - 5)))
                                {
                                    Console.WriteLine($"Removing: {file}");
                                    File.Delete(file.ToString().Remove(file.Length - 5));
                                }

                                // Restore original save data
                                File.Move(file.ToString(), file.ToString().Remove(file.Length - 5));
                            }
                        }
                    }
                }
            }
        }
예제 #36
0
 /// <summary>
 /// Mod initialization point.
 /// </summary>
 public void Start()
 {
     RConsole.Log("\"Utility Craft +\" starts loading.");
     INI.SetConfigurationFromINI();
     RConsole.Log("UtilCraft+ has been loaded!");
 }
예제 #37
0
    public static INI ReadString(string text, string filePath, bool fromFile, Flags?flags = null)
    {
        if (fromFile && !File.Exists(filePath))
        {
            return(new INI(filePath, flags));
        }
        INI ini = new INI(filePath, flags);

        string[] lines     = text.Split(new string[] { "\r\n", "\n" }, StringSplitOptions.None);
        char?    delimiter = null;
        string   section   = string.Empty;

        for (int i = 0; i < lines.Length; i++)
        {
            string line = lines[i].Trim();
            if (line.StartsWith(";") || line.StartsWith("#"))
            {
                continue;
            }
            if (line.ToLower() == "{global}")
            {
                section = string.Empty;
            }
            else
            {
                string newSection = Regex.Match(line, @"(?<=\[).*(?=\])").Value.Trim();
                if (!string.IsNullOrEmpty(newSection))
                {
                    section = newSection;
                }
            }
            string name = Regex.Match(line, (@"(?<=^\p{Zs}*|])[^]" + (!delimiter.HasValue ? "=:" : INIExtentions.RegexEscape(delimiter.Value)) + "]*(?=" +
                                             (!delimiter.HasValue ? "=|:" : INIExtentions.RegexEscape(delimiter.Value)) + ")")).Value.Trim();
            string value = string.Empty;
            if (ini.SetFlags.HasValue)
            {
                value = Regex.Match(line, "(?<==|:).*").Value.Trim();
                if (ini.SetFlags.Value.HasFlag(Flags.Quoted) && (value.CountOf('"') >= 2))
                {
                    value = value.Between(value.IndexOf('"'), (value.LastIndexOf('"') + 1));
                }
                else if (ini.SetFlags.Value.HasFlag(Flags.Apostrophized) && (value.CountOf('\'') >= 2))
                {
                    value = value.Between(value.IndexOf('\''), (value.LastIndexOf('\'') + 1));
                }
                else
                {
                    value = Regex.Match(value, "[^;#]*").Value.Trim();
                }
            }
            else
            {
                value = Regex.Match(line, "(?<=" + (!delimiter.HasValue ? "=|:" : INIExtentions.RegexEscape(delimiter.Value)) + ")[^;#]*").Value.Trim();
            }
            if (section == "ini")
            {
                if (!string.IsNullOrEmpty(name) && !string.IsNullOrEmpty(value))
                {
                    if (name == "delimiter")
                    {
                        if (value.CountOf('"') >= 2)
                        {
                            delimiter = value.Between((value.IndexOf('"') + 1), value.LastIndexOf('"'))[0];
                        }
                        if (value.CountOf('\'') >= 2)
                        {
                            delimiter = value.Between((value.IndexOf('\'') + 1), value.LastIndexOf('\''))[0];
                        }
                        ini.Delimiter = delimiter;
                    }
                    else if (name == "flags")
                    {
                        ini.SetFlags = (Flags)Enum.Parse(typeof(Flags), value);
                    }
                }
                section = string.Empty;
            }
            else if (!string.IsNullOrEmpty(name) && !string.IsNullOrEmpty(value))
            {
                ini.Nodes.Add(((!string.IsNullOrEmpty(section) ? (section + ".") : string.Empty) + name), value);
            }
        }
        //Console.WriteLine("flags: " + ini.SetFlags.ToString());
        //for (int i = 0; i < ini.Nodes.Count; i++) Console.WriteLine(string.Format("{0} = {1}.", ini.Nodes.KeyFromIndex(i), ini.Get(i)));
        return(ini);
    }
예제 #38
0
 private void 配置ToolStripMenuItem_Click(object sender, EventArgs e)
 {
     INI.OpenConfig();
 }
예제 #39
0
 private static void AddTemplatesFromIni(Templates parentItem, Language lang, INI ini)
 {
     string langString = lang.ToString();
     foreach (string section in ini.Dict.Keys) {
         if (!section.StartsWith(langString)) continue;
         string name = section.Substring(langString.Length + 1).Trim();
         string text = ini.GetSectionText(section);
         parentItem.Set(lang, name, text);
     }
 }
예제 #40
0
 static Settings()
 {
     ini = INI.ReadFile("settings.ini");
 }
예제 #41
0
        private void btnSave_Click(object sender, EventArgs e)
        {
            m_strPLCPort     = txtPLCPort.Text;
            m_strPLCBaudrate = txtBaudRate.Text;

            m_strPLCReadDAddress  = txtDReadAddr.Text;
            m_strPLCReadMAddress  = txtMReadAddr.Text;
            m_strPLCWriteDAddress = txtDWriteAddr.Text;
            m_strPLCWriteMAddress = txtMWriteAddr.Text;
            m_strPLCChannel       = txtPLCChannel.Text;

            string strdata;


            INI.WritePrivateProfileString("Setup", "Light Comm Port", txtLightCommPort.Text, m_strSetupINIFile);
            INI.WritePrivateProfileString("PLC", "Read D Address", m_strPLCReadDAddress, m_strSetupINIFile);
            INI.WritePrivateProfileString("PLC", "Read M Address", m_strPLCReadMAddress, m_strSetupINIFile);
            INI.WritePrivateProfileString("PLC", "Write D Address", m_strPLCWriteDAddress, m_strSetupINIFile);
            INI.WritePrivateProfileString("PLC", "Write M Address", m_strPLCWriteMAddress, m_strSetupINIFile);
            INI.WritePrivateProfileString("PLC", "Port", m_strPLCPort, m_strSetupINIFile);
            INI.WritePrivateProfileString("PLC", "Baudrate", m_strPLCBaudrate, m_strSetupINIFile);
            INI.WritePrivateProfileString("PLC", "Channel", m_strPLCChannel, m_strSetupINIFile);
            INI.WritePrivateProfileString("Setup", "Mode", m_nMode.ToString(), m_strSetupINIFile);
            INI.WritePrivateProfileString("DB", "User ID", txtDBID.Text, m_strSetupINIFile);
            INI.WritePrivateProfileString("DB", "Password", txtDBPassword.Text, m_strSetupINIFile);
            INI.WritePrivateProfileString("DB", "IP Address", txtDBIPAddress.Text, m_strSetupINIFile);
            if (chkDBCheck1.Checked)
            {
                strdata = "1";
            }
            else
            {
                strdata = "0";
            }

            INI.WritePrivateProfileString("DB", "Check DB1", strdata, m_strSetupINIFile);
            if (chkDBCheck2.Checked)
            {
                strdata = "1";
            }
            else
            {
                strdata = "0";
            }
            INI.WritePrivateProfileString("DB", "Check DB2", strdata, m_strSetupINIFile);
            if (chkNoLabel.Checked)
            {
                strdata = "1";
            }
            else
            {
                strdata = "0";
            }
            INI.WritePrivateProfileString("Setup", "No Label Pass", strdata, m_strSetupINIFile);
            if (chkSaveImage.Checked)
            {
                strdata = "1";
            }
            else
            {
                strdata = "0";
            }
            INI.WritePrivateProfileString("Setup", "Save Image", strdata, m_strSetupINIFile);
        }
예제 #42
0
        public void SetConfig_104(string configFile)
        {
            FileStream fs = new FileStream(configFile, FileMode.OpenOrCreate);
            fs.Close();
            //StreamReader sr = new StreamReader(configFile, Encoding.Default);
            //string s;
            //string[] word;
            //char[] separator = { '=' };
            //int flag = 0;
            //while ((s = sr.ReadLine()) != null)
            //{
            //    word = s.Split(separator);
            //    if (word[0] == "IPAddress")       m_IPAddress = word[1];
            //    if (word[0] == "Port")            m_Port = Convert.ToInt32(word[1]);
            //    if (word[0] == "PublicAddress")   m_PublicAddress = Convert.ToInt32(word[1]);
            //    if (word[0] == "SendRate")        m_SendRate = Convert.ToInt32(word[1]);
            //    if (word[0] == "YmRate")          m_YmRate = Convert.ToInt32(word[1]);
            //    if (word[0] == "CallAllRate")     m_CallAllRate = Convert.ToInt32(word[1]);
            //    if (word[0] == "SendTaskInteval") m_SendTaskInteval = Convert.ToInt32(word[1]);
            //    if (word[0] == "ACKNW")           m_AckNW = Convert.ToInt32(word[1]);

            //    //if (word[0] == "DataTye_Len")     m_DataTye_Len = Convert.ToInt32(word[1]);
            //    //if (word[0] == "SQ_Len")          m_SQ_Len = Convert.ToInt32(word[1]);
            //    //if (word[0] == "TransRes_Len")        m_TransRes_Len = Convert.ToInt32(word[1]);
            //    //if (word[0] == "PublicAddress_Len")   m_PublicAddress_Len = Convert.ToInt32(word[1]);
            //    //if (word[0] == "DataAddress_Len")     m_DataAddress_Len = Convert.ToInt32(word[1]);

            //    if (word[0] == "yx_StartAddress")     m_yxStartAddress = Convert.ToInt32(word[1]);
            //    if (word[0] == "yx_EndAddress")       m_yxEndAddress = Convert.ToInt32(word[1]);
            //    if (word[0] == "yc_StartAddress")     m_ycStartAddress = Convert.ToInt32(word[1]);
            //    if (word[0] == "yc_EndAddress")       m_yxEndAddress = Convert.ToInt32(word[1]);
            //    if (word[0] == "ym_StartAddress")     m_ymStartAddress = Convert.ToInt32(word[1]);
            //    if (word[0] == "ym_EndAddress")       m_ymEndAddress = Convert.ToInt32(word[1]);
            //    flag++;
            //}
            //sr.Close();
            //try
            {
                cfg = new INI(AppDomain.CurrentDomain.SetupInformation.ApplicationBase + configFile);
                m_IPAddress = cfg.GetVal("Advanced", "IPAddress");
                m_OPCServerName = cfg.GetVal("Advanced", "OPCServerName");
                m_Port = Convert.ToInt32(cfg.GetVal("Advanced", "Port"));
                m_PublicAddress = Convert.ToInt32(cfg.GetVal("Advanced", "PublicAddress"));
                m_SendRate = Convert.ToSingle(cfg.GetVal("Advanced", "SendRate"));
                m_YmRate = Convert.ToSingle(cfg.GetVal("Advanced", "YmRate"));
                m_CallAllRate = Convert.ToSingle(cfg.GetVal("Advanced", "CallAllRate"));
                m_SendTaskInteval = Convert.ToSingle(cfg.GetVal("Advanced", "SendTaskInteval"));
                m_AckNW = Convert.ToInt32(cfg.GetVal("Advanced", "ACKNW"));
                m_yxStartAddress = Convert.ToInt32(cfg.GetVal("DATA", "yx_StartAddress"));
                m_ycStartAddress = Convert.ToInt32(cfg.GetVal("DATA", "yc_StartAddress"));
                m_ymStartAddress = Convert.ToInt32(cfg.GetVal("DATA", "ym_StartAddress"));
            }
            //catch
            //{
            //    StreamWriter sw1 = new StreamWriter(configFile);
            //    string w = "";
            //    sw1.Write(w);
            //    sw1.Close();
            //    StreamWriter sw = File.AppendText(configFile);
            //    sw.WriteLine("[Advanced]");
            //    sw.WriteLine("IPAddress=127.0.0.1");
            //    sw.WriteLine("OPCServerName=SAC.OPC.104");
            //    sw.WriteLine("SendRate=1");
            //    sw.WriteLine("YmRate=300");
            //    sw.WriteLine("ACKNW=8");
            //    sw.WriteLine("CallAllRate=60");
            //    sw.WriteLine("SendTaskInteval=5");
            //    sw.WriteLine("PublicAddress=1");
            //    sw.WriteLine("Port=2404");
            //    sw.WriteLine("[DATA]");
            //    sw.WriteLine("yx_StartAddress=1");
            //    sw.WriteLine("yc_StartAddress=16385");
            //    sw.WriteLine("ym_StartAddress=25601");
            //    sw.Close();
            //}
        }
예제 #43
0
 /// <summary>
 /// Constructor
 /// </summary>
 /// <param name="path">Path</param>
 public SAMPConfig(string path)
 {
     this.path = path;
     ini       = INIFile.Open(path);
 }
예제 #44
0
    public string shenfenzhen(string username, string sex, string minzu, string shenfenzhen, string shenri, string shenfenzhenhao, string begin, string end, string jiguan, string address, string zhangdanhao)
    {
        LogUtil.WriteLog(zhangdanhao);
        #region 获取名字首字母大写
        string skrxm = GetNameDaXie.GetSpellCode(username);
        #endregion

        string sql = "update main_jiedai_ruzhu SET krxm={0},sax = {1},minzu = {2},shenfenzhentype = {3},kerenshenri ={4},shenfenzhenhao = {5},jiguan = {6},changzhudizhi = {7},ekrxm ={8} where zhangdanhao = {9}";

        sql = string.Format(sql, INI.psformat(username), INI.psformat(sex), INI.psformat(minzu), INI.psformat(shenfenzhen), INI.psformat(INI.sdd(shenri)), INI.psformat(shenfenzhenhao),
                            INI.psformat(jiguan), INI.psformat(address), INI.psformat(skrxm), INI.psformat(zhangdanhao));
        LogUtil.WriteLog("f**k" + sql);
        bool   isOK = INI.xb_exe_sql(sql);
        string x    = "";
        if (isOK)
        {
            x = Common.handleResponse(200, "录入成功");
        }
        else
        {
            x = Common.handleFail();
        }

        return(x);
    }
예제 #45
0
        //private string OpenFileDialog()
        //{
        //    return _openFileDialog.ShowDialog() ?? false ? _openFileDialog.FileName : "";
        //}

        private bool LoadINI(string path, out INI file)
        {
            if (!File.Exists(path))
            {
                file = null;
                return(false);
            }

            Regex iniHeader   = new Regex(@"^\[[^\]\r\n]+]");
            Regex iniKeyValue = new Regex(@"^([^=;\r\n]+)=([^;\r\n]*)");

            var lines = File.ReadAllLines(path);

            file = new INI();

            var duplicateKeys = new List <Tuple <string, string, string, string> >(); //block, key, old value, new value

            Dictionary <string, string> currentBlock = null;

            foreach (var line in lines)
            {
                try
                {
                    if (iniHeader.IsMatch(line))
                    {
                        file.Add(line.Trim(new char[] { ' ', ']', '[', '\t' }), currentBlock = new INIBlock());
                    }

                    if (iniKeyValue.IsMatch(line))
                    {
                        if (currentBlock == null)
                        {
                            file.Add("", currentBlock = new INIBlock());
                        }

                        var match = iniKeyValue.Match(line);
                        var key   = match.Groups[1].Value.Trim();
                        var value = match.Groups[2].Value.Trim();

                        if (currentBlock.ContainsKey(key))
                        {
                            var currentBlockName = file.FirstOrDefault(kv => kv.Value == currentBlock).Key;
                            duplicateKeys.Add(Tuple.Create(currentBlockName, key, currentBlock[key], value));

                            currentBlock[key] = value;
                        }
                        else
                        {
                            currentBlock.Add(key, value);
                        }
                    }
                }
                catch (Exception ex)
                {
                    MessageBox.Show("This INI could not be parsed. The line being parsed was:\n" + line +
                                    "\n\nDetailed exception information below:\n" + ex.InnerException
                                    , "Exception Alert", MessageBoxButton.OK, MessageBoxImage.Exclamation);
                    file = null;
                    return(false);
                }
            }
            if (duplicateKeys.Count > 0)
            {
                MessageBox.Show(string.Format("{0} values were overwritten by same keys in the same section. Only the last set value for the key will be used.\n[Section] Key = Early Value -> Later Value\n{1}"
                                              , duplicateKeys.Count, String.Join("\n", duplicateKeys.Select(dup => string.Format("[{0}] {1} = {2} -> {3}", dup.Item1, dup.Item2, dup.Item3, dup.Item4))))
                                , "Duplicate Key-Values Overwritten", MessageBoxButton.OK, MessageBoxImage.Information);
            }
            return(true);
        }
예제 #46
0
        public void SetConfig_101(string configFile)
        {
            FileStream fs = new FileStream(configFile, FileMode.OpenOrCreate);
            fs.Close();

            //try
            {
                cfg = new INI(AppDomain.CurrentDomain.SetupInformation.ApplicationBase + configFile);
                m_COM = cfg.GetVal("Advanced", "COM");
                m_OPCServerName = cfg.GetVal("Advanced", "OPCServerName");
                m_BaudRate = Convert.ToInt32(cfg.GetVal("Advanced", "BaudRate"));
                m_DataBits = Convert.ToInt32(cfg.GetVal("Advanced", "DataBits"));
                m_StopBits = Convert.ToInt32(cfg.GetVal("Advanced", "StopBits"));
                m_Parity = Convert.ToInt32(cfg.GetVal("Advanced", "Parity"));
                m_Handshake = Convert.ToInt32(cfg.GetVal("Advanced", "Handshake"));
                m_LinkAddress = Convert.ToByte(cfg.GetVal("Advanced", "LinkAddress"));
                m_PublicAddress = Convert.ToByte(cfg.GetVal("Advanced", "PublicAddress"));
                m_SendRate = Convert.ToSingle(cfg.GetVal("Advanced", "SendRate"));
                m_YmRate = Convert.ToSingle(cfg.GetVal("Advanced", "YmRate"));
                m_CallAllRate = Convert.ToSingle(cfg.GetVal("Advanced", "CallAllRate"));
                m_SendTaskInteval = Convert.ToSingle(cfg.GetVal("Advanced", "SendTaskInteval"));
                m_yxStartAddress = Convert.ToInt32(cfg.GetVal("DATA", "yx_StartAddress"));
                m_ycStartAddress = Convert.ToInt32(cfg.GetVal("DATA", "yc_StartAddress"));
                m_ymStartAddress = Convert.ToInt32(cfg.GetVal("DATA", "ym_StartAddress"));
            }
            //catch
            //{
            //    StreamWriter sw1 = new StreamWriter(configFile);
            //    string w = "";
            //    sw1.Write(w);
            //    sw1.Close();
            //    StreamWriter sw = File.AppendText(configFile);
            //    sw.WriteLine("[Advanced]");
            //    sw.WriteLine("COM=COM4");
            //    sw.WriteLine("BaudRate=9600");
            //    sw.WriteLine("DataBits=8");
            //    sw.WriteLine("StopBits=1");
            //    sw.WriteLine("Parity=0");
            //    sw.WriteLine("LinkAddress=1");
            //    sw.WriteLine("PublicAddress=1");
            //    sw.WriteLine("SendRate=1");
            //    sw.WriteLine("YmRate=100");
            //    sw.WriteLine("CallAllRate=60");
            //    sw.WriteLine("SendTaskInteval=5");
            //    sw.WriteLine("Handshake=0");
            //    sw.WriteLine("OPCServerName=SAC.OPC.101");
            //    sw.WriteLine("[DATA]");
            //    sw.WriteLine("yx_StartAddress=1");
            //    sw.WriteLine("yc_StartAddress=16385");
            //    sw.WriteLine("ym_StartAddress=25601");
            //    sw.Close();
            //}
        }
예제 #47
0
 public AsanaLibrary(FileInfo fi)
 {
     Ini   = new INI(fi.FullName);
     token = Ini.IniReadValue("Authorisation", "Token", string.Empty);
 }
예제 #48
0
 private void toolStripButton2_Click(object sender, EventArgs e)
 {
     INI.OpenConfig();
 }
예제 #49
0
    public string Insert_usermsg(string krxm, string fanghao, string tiansu, string fangpice, string yajinzonge, string sax, string fangjianname, string room_louloop, string room_loudong, string kefangfenge, string rensu, string id, string fanglei)
    {
        #region 生成账单号
        string zhangdanhao = INI.xb_get_zhangdanhao("ft");

        #endregion

        #region 自己获取参数
        string    guapai     = "select fangjianguapaijia from jiedai_fangpice_count where fangjianname in (select fangname from room where id ='" + id + "')";
        DataSet   ds         = INI.xb_get_database_record(guapai);
        DataTable da_guapai  = ds.Tables[0];
        string    guapaij    = da_guapai.Rows[0][0].ToString();
        string    zhixin     = "select fangjianzhixinjia from jiedai_fangpice_count where fangjianname in (select fangname from room where id ='" + id + "')";
        DataSet   ds1        = INI.xb_get_database_record(zhixin);
        DataTable da_guapai1 = ds1.Tables[0];
        string    zhixinj    = da_guapai1.Rows[0][0].ToString();
        string    loucen     = "select room_loudong,room_louloop,kefangfenge from room where id = '" + id + "'";
        DataSet   dskefang   = INI.xb_get_database_record(loucen);
        DataTable da_kefang  = dskefang.Tables[0];
        string    loucens    = da_kefang.Rows[0]["room_louloop"].ToString();
        string    loudons    = da_kefang.Rows[0]["room_loudong"].ToString();
        string    fenge      = da_kefang.Rows[0]["kefangfenge"].ToString();

        string x = "";
        if (fanglei.Equals("钟点房"))
        {
            x = "钟点码";
        }
        else if (fanglei.Equals("全天房"))
        {
            x = "执行码";
        }
        //入住时间
        string    now     = "SELECT convert(char(20),getdate(),120) as now";
        DataSet   ds_time = INI.xb_get_database_record(now);
        DataTable da_time = ds_time.Tables[0];
        string    timedao = da_time.Rows[0][0].ToString();
        // DateTime datanow = Convert.ToDateTime(timedao);
        //离店时间
        int       tian   = Convert.ToInt32(tiansu);
        string    niri   = "SELECT convert(char(20),getdate()+" + tian + ",120)";
        DataSet   ds_ni  = INI.xb_get_database_record(niri);
        DataTable da_ni  = ds_ni.Tables[0];
        string    timeni = da_ni.Rows[0][0].ToString();
        //DateTime dataniri = Convert.ToDateTime(timeni);
        //押金总额 房间总额 余额
        int zonge     = Convert.ToInt32(yajinzonge);
        int pice_fang = Convert.ToInt32(fangpice);
        int yue       = zonge - pice_fang;

        #endregion

        #region 插入入住表
        string sql = @"insert into main_jiedai_ruzhu (zhangdanhao,z_zhangdanhao,fangpice,guapaipice,room_louloop,
                                                      room_loudong,kefangfenge,status,ruzhustatus,
                                                      fanghao,zheqouma,daori,tiansu,yajinyue,niri,
                                                      xieyitype,kerentype,fangjianname)
                                                      Values
                                                      ({0},{1},{2},{3},{4},{5},{6},{7},{8},{9},{10},
                                                       {11},{12},{13},{14},{15},{16},{17})";
        sql = string.Format(sql, INI.psformat(zhangdanhao), INI.psformat(zhangdanhao), INI.psformat(zhixinj), INI.psformat(guapaij),
                            INI.psformat(loucens), INI.psformat(loudons), INI.psformat(kefangfenge), "'在住'", "'散客入住'", INI.psformat(fanghao),
                            INI.psformat(x), INI.psformat(INI.sd(timedao)), INI.psformat(tiansu), yue, INI.psformat(INI.sd(timeni)), "'酒店协议价'", "'自来的散客'", INI.psformat(fangjianname));
        LogUtil.WriteLog("改" + sql);
        DataSet   ds_msg = INI.xb_get_database_record(sql);
        DataTable da_msg = ds.Tables[0];
        string    c      = "";
        if (da_msg.Rows.Count >= 1)
        {
            string sql_fangtaiup = "update room set fangtai ='OC' where id = '" + id + "'";
            INI.xb_exe_sql(sql_fangtaiup);
            c = @"{'code':'200','msg':'成功','List':'" + zhangdanhao + @"'}";
            c = c.Replace("\'", "\"");
        }
        else
        {
            c = Common.handleFail();
        }

        return(c);

        #endregion
    }
예제 #50
0
        //public static Bitmap CreateQRCode(string content)
        //{
        //    Gma.QrCodeNet.Encoding.QrEncoder qrEncoder = new Gma.QrCodeNet.Encoding.QrEncoder();
        //    //Gma.QrCodeNet.Encoding.
        //    qrEncoder.ErrorCorrectionLevel = Gma.QrCodeNet.Encoding.ErrorCorrectionLevel.M;
        //    qrEncoder.Encode()
        //  //  QRCodeEncoder qrEncoder = new QRCodeEncoder();
        //    qrEncoder.QRCodeEncodeMode = QRCodeEncoder.ENCODE_MODE.BYTE;
        //    qrEncoder.QRCodeScale = Convert.ToInt32(4);
        //    qrEncoder.QRCodeVersion = Convert.ToInt32(3);
        //    qrEncoder.QRCodeErrorCorrect = QRCodeEncoder.ERROR_CORRECTION.M;
        //    try
        //    {
        //        Bitmap qrcode = qrEncoder.Encode(content, Encoding.UTF8);
        //        return qrcode;
        //    }
        //    catch (IndexOutOfRangeException ex)
        //    {
        //        return new Bitmap(100, 100);
        //    }
        //    catch (Exception ex)
        //    {
        //        return new Bitmap(100, 100);
        //    }
        //}

        public static void WritePrintername(string printerName)
        {
            INI iniclass = new INI("config.ini");
            iniclass.IniWriteValue("Other", "printer", printerName);
        }
예제 #51
0
        private void CompareINIs(INI file1, INI file2)
        {
            if (file1 == null || file2 == null)
            {
                return;
            }

            var paragraph1 = new Paragraph();
            var paragraph2 = new Paragraph();

            var matchedSections            = new List <string>();
            var missedSectionsAccountedFor = new List <string>();

            foreach (var section in file1)
            {
                if (file2.ContainsKey(section.Key))
                {
                    //this section is in both INIs compare it and output
                    matchedSections.Add(section.Key);

                    //but first, lets take a moment to find any sections from file2 that may have been skipped at this point. Specifically sections that are not in file1 at all so we can write them out.
                    var file2SectionKeys           = file2.Keys.ToList();
                    var file2SectionKeysNotSeenYet = file2SectionKeys.GetRange(0, file2SectionKeys.IndexOf(section.Key))
                                                     .Where(sectionKey => !matchedSections.Contains(sectionKey) && //haven't matched it before
                                                            !missedSectionsAccountedFor.Contains(sectionKey) && //haven't fixed it before
                                                            !file1.ContainsKey(sectionKey));                    //won't be getting to it later

                    foreach (var missingSectionKey in file2SectionKeysNotSeenYet)
                    {
                        //this section is not in the first INI, display it as added

                        if (missingSectionKey.Length > 0)
                        {
                            paragraph1.AppendLine();
                            paragraph2.AppendLine(string.Format("[{0}]", missingSectionKey), Brushes.LightGreen, bold: true);
                        }
                        foreach (var keyvalue in file2[missingSectionKey])
                        {
                            //none of the lines can match
                            paragraph1.AppendLine();
                            paragraph2.AppendLine(string.Format("{0} = {1}", keyvalue.Key, keyvalue.Value), Brushes.LightGreen);
                        }
                        paragraph1.AppendLine();
                        paragraph2.AppendLine();

                        missedSectionsAccountedFor.Add(missingSectionKey);
                    }


                    //okay, now we continue with this section
                    var matchedKeys            = new List <string>();
                    var missedKeysAccountedFor = new List <string>();

                    if (section.Key.Length > 0)
                    {
                        paragraph1.AppendLine(string.Format("[{0}]", section.Key), bold: true);
                        paragraph2.AppendLine(string.Format("[{0}]", section.Key), bold: true);
                    }
                    foreach (var keyvalue in section.Value)
                    {
                        //now check each line
                        if (file2[section.Key].ContainsKey(keyvalue.Key))
                        {
                            //this key is in both sections
                            matchedKeys.Add(keyvalue.Key);

                            //lets take a moment to find any keys from section2 that may have been skipped at this point. Specifically, keys are not in section1 at all, so we can write them out.
                            var section2Keys           = file2[section.Key].Keys.ToList();
                            var section2KeysNotSeenYet = section2Keys.GetRange(0, section2Keys.IndexOf(keyvalue.Key))
                                                         .Where(key => !matchedKeys.Contains(key) && //haven't matched it before
                                                                !missedKeysAccountedFor.Contains(key) && //haven't taken care of it before
                                                                !section.Value.ContainsKey(key)); //won't be getting to it

                            foreach (var missingKey in section2KeysNotSeenYet)
                            {
                                paragraph1.AppendLine();
                                paragraph2.AppendLine(string.Format("{0} = {1}", missingKey, file2[section.Key][missingKey]), Brushes.LightGreen);
                                missedKeysAccountedFor.Add(missingKey);
                            }

                            //okay, now we continue with this new match

                            //commented out, would only color the part of the INI line that changed, now its set to do the whole line
                            //paragraph1.Append(string.Format("{0} = ", keyvalue.Key));
                            //paragraph2.Append(string.Format("{0} = ", keyvalue.Key));

                            if (keyvalue.Value == file2[section.Key][keyvalue.Key])
                            {
                                //values are the same
                                //paragraph1.AppendLine(string.Format("{0}", keyvalue.Value));
                                //paragraph2.AppendLine(string.Format("{0}", keyvalue.Value));
                                paragraph1.AppendLine(string.Format("{0} = {1}", keyvalue.Key, keyvalue.Value));
                                paragraph2.AppendLine(string.Format("{0} = {1}", keyvalue.Key, keyvalue.Value));
                            }
                            else
                            {
                                //values are different
                                //paragraph1.AppendLine(string.Format("{0}", keyvalue.Value), Brushes.LightGray);
                                //paragraph2.AppendLine(string.Format("{0}", file2[section.Key][keyvalue.Key]), Brushes.LightGray);
                                paragraph1.Append(string.Format("{0} = ", keyvalue.Key), Brushes.LightGray);
                                paragraph2.Append(string.Format("{0} = ", keyvalue.Key), Brushes.LightGray);
                                paragraph1.AppendLine(string.Format("{0}", keyvalue.Value), Brushes.Gray, Brushes.White);
                                paragraph2.AppendLine(string.Format("{0}", file2[section.Key][keyvalue.Key]), Brushes.Gray, Brushes.White);
                            }
                        }
                        else
                        {
                            //this key is only in the first section
                            paragraph1.AppendLine(string.Format("{0} = {1}", keyvalue.Key, keyvalue.Value), Brushes.LightPink);
                            paragraph2.AppendLine();
                        }
                    }
                    foreach (var keyvalue in file2[section.Key])
                    {
                        if (matchedKeys.Contains(keyvalue.Key) || missedKeysAccountedFor.Contains(keyvalue.Key))
                        {
                            continue;
                        }

                        //if it got here then this key is not in the first INI, display it as added

                        //TODO: make this DRY, this exact code is used above for missing keys in-between other keys

                        paragraph1.AppendLine();
                        paragraph2.AppendLine(string.Format("{0} = {1}", keyvalue.Key, keyvalue.Value), Brushes.LightGreen);

                        missedKeysAccountedFor.Add(keyvalue.Key); //don't think it matters at this point
                    }
                    paragraph1.AppendLine();
                    paragraph2.AppendLine();
                }
                else
                {
                    //this section is not in the second INI, display it as removed

                    if (section.Key.Length > 0)
                    {
                        paragraph1.AppendLine(string.Format("[{0}]", section.Key), Brushes.LightPink, bold: true);
                        paragraph2.AppendLine();
                    }
                    foreach (var keyvalue in section.Value)
                    {
                        //none of the lines can match
                        paragraph1.AppendLine(string.Format("{0} = {1}", keyvalue.Key, keyvalue.Value), Brushes.LightPink);
                        paragraph2.AppendLine();
                    }
                    paragraph1.AppendLine();
                    paragraph2.AppendLine();
                }
            }
            foreach (var section2 in file2)
            {
                if (matchedSections.Contains(section2.Key) || missedSectionsAccountedFor.Contains(section2.Key))
                {
                    continue;
                }

                //if it got here then this section is not in the first INI, display it as added

                //TODO: make this DRY, this exact code is used above for missing sections in-between other sections

                if (section2.Key.Length > 0)
                {
                    paragraph1.AppendLine();
                    paragraph2.AppendLine(string.Format("[{0}]", section2.Key), Brushes.LightGreen, bold: true);
                }
                foreach (var keyvalue in section2.Value)
                {
                    //none of the lines can match
                    paragraph1.AppendLine();
                    paragraph2.AppendLine(string.Format("{0} = {1}", keyvalue.Key, keyvalue.Value), Brushes.LightGreen);
                }
                paragraph1.AppendLine();
                paragraph2.AppendLine();

                missedSectionsAccountedFor.Add(section2.Key);
            }

            INI1RichTextBox.Document = new FlowDocument(paragraph1);
            INI2RichTextBox.Document = new FlowDocument(paragraph2);
        }
예제 #52
0
        public static string ReadPrinterName()
        {
            INI iniclass = new INI("config.ini");
            return iniclass.IniReadValue("Other", "printer");

        }
예제 #53
0
        private void Form1_Load(object sender, EventArgs e)
        {
            //
            frmtray = new Tray(this);

            //hehe
            Script.frm = this;
            SysMsg.frm = this;
            frm = this;

            Log.Log_Create();
            RSA.Init();
            AES.InitKey();

            pictureBox1.Hide();

            //if (MessageBox.Show("脱机请选是,BS脚本请选否", "MAH", MessageBoxButtons.OKCancel) == DialogResult.Cancel)
            //{
            //    Tcp.AcceptTcp();
            //}

            Thread t = new Thread(RecvCMD);
            t.Start();

            //初始化AIRPACP

            string st = string.Empty;
            string type;

            if (MA.host == "game.ma.mobimon.com.tw:10001")
            {
                type = "\\tw.txt";
            }
            else
            {
                type = "\\cn.txt";
            }

            CardInfo.readData(Application.StartupPath + type);
            using (StreamReader sr = new StreamReader(new FileStream(Application.StartupPath + type, FileMode.Open, FileAccess.Read)))
            {
                while (sr.Peek() > 0)
                {
                    string strr = sr.ReadLine();
                    comboBox2.Items.Add(strr);
                }
                sr.Close();
            }

            //默认数据
            ini = new INI(Application.StartupPath + "\\my.ini");
            string str = ini.IniReadValue("CARD", "card1");
            if (str != null && str != "")
                d1 = str;
            str = ini.IniReadValue("CARD", "card2");
            if (str != null && str != "")
                d2 = str;

            //str = ini.IniReadValue("DEVICE", "netcard");
            //if (str != null && str != "")
            //{
            //    int n = int.Parse(str);
            //    if (n >= 0 && n < devicelist.Count)
            //    {
            //        usedev = devicelist[n];
            //    }
            //}

            str = ini.IniReadValue("AI", "begin");
            if (str != null && str != "")
            {
                int n = 0;
                int.TryParse(str, out n);
                if (n >= numericUpDown2.Minimum && n <= numericUpDown2.Maximum)
                {
                    numericUpDown2.Value = n;
                }
            }

            str = ini.IniReadValue("AI", "end");
            if (str != null && str != "")
            {
                int n = 0;
                int.TryParse(str, out n);
                if (n >= numericUpDown3.Minimum && n <= numericUpDown3.Maximum)
                {
                    numericUpDown3.Value = n;
                }
            }

            str = ini.IniReadValue("AI", "rjxbc");
            if (str != null && str != "")
            {
                int n = 0;
                int.TryParse(str, out n);
                if (n >= numericUpDown4.Minimum && n <= numericUpDown4.Maximum)
                {
                    numericUpDown4.Value = n;
                }
            }

            str = ini.IniReadValue("AI", "rpgbc");
            if (str != null && str != "")
            {
                int n = 0;
                int.TryParse(str, out n);
                if (n >= numericUpDown5.Minimum && n <= numericUpDown5.Maximum)
                {
                    numericUpDown5.Value = n;
                }
            }

            str = ini.IniReadValue("AI", "rpg");
            if (str != null && str != "")
            {
                int n = 0;
                int.TryParse(str, out n);
                checkBox1.Checked = n == 0 ? false : true;
            }

            //HKG
            str = ini.IniReadValue("HKG", "card");
            if (str != null && str != "")
                d3 = str;

            str = ini.IniReadValue("HKG", "ap");
            if (str != null && str != "")
            {
                int n = 0;
                int.TryParse(str, out n);
                if (n >= numericUpDown6.Minimum && n <= numericUpDown6.Maximum)
                {
                    numericUpDown6.Value = n;
                }
            }

            str = ini.IniReadValue("HKG", "bc");
            if (str != null && str != "")
            {
                int n = 0;
                int.TryParse(str, out n);
                if (n >= numericUpDown7.Minimum && n <= numericUpDown7.Maximum)
                {
                    numericUpDown7.Value = n;
                }
            }

            str = ini.IniReadValue("HKG", "step");
            if (str != null && str != "")
            {
                int n = 0;
                int.TryParse(str, out n);
                if (n >= numericUpDown8.Minimum && n <= numericUpDown8.Maximum)
                {
                    numericUpDown8.Value = n;
                }
            }

            int i=0;
            while (true)
            {
                   str = ini.IniReadValue("HKG", "area" + i++);
                   if (str != null && str != "")
                   {
                       if (i == 1)
                           listBox1.Items.Clear();
                       listBox1.Items.Add(str);
                   }
                   else
                       break;
            }

            //脱机用户名密码
            str = ini.IniReadValue("TJ", "user");
            if (str != null && str != "")
            {
                MA_Client.login_id = str;
                textBox3.Text = str;
            }
            str = ini.IniReadValue("TJ", "pass");
            if (str != null && str != "")
            {
                MA_Client.login_password = str;
                textBox4.Text = str;
            }

            //是否使用脱机出售

            str = ini.IniReadValue("TJ", "usesell");
            if (str != null && str != "")
            {
                int n = 0;
                int.TryParse(str, out n);
                checkBox3.Checked = (n == 0 ? false : true);
            }

            //是否使用脱机领卡

            str = ini.IniReadValue("TJ", "usegetcard");
            if (str != null && str != "")
            {
                int n = 0;
                int.TryParse(str, out n);
                checkBox8.Checked = false;
            }

            //是否使用自动探索
            str = ini.IniReadValue("TJ", "useexplore");
            if (str != null && str != "")
            {
                int n = 0;
                int.TryParse(str, out n);
                checkBox4.Checked = (n == 0 ? false : true);
            }

            //探索AP阈值
            str = ini.IniReadValue("TJ", "explore_ap");
            if (str != null && str != "")
            {
                int n = 0;
                int.TryParse(str, out n);
                if (n >= numericUpDown9.Minimum && n <= numericUpDown9.Maximum)
                {
                    numericUpDown9.Value = n;
                }
            }

            //探索BC阈值
            str = ini.IniReadValue("TJ", "explore_bc");
            if (str != null && str != "")
            {
                int n = 0;
                int.TryParse(str, out n);
                if (n >= numericUpDown10.Minimum && n <= numericUpDown10.Maximum)
                {
                    numericUpDown10.Value = n;
                }
            }

            //觉醒时间
            str = ini.IniReadValue("TJ", "jx_time_begin");
            if (str != null && str != "")
            {
                int n = 0;
                int.TryParse(str, out n);
                if (n >= numericUpDown14.Minimum && n <= numericUpDown14.Maximum)
                {
                    numericUpDown14.Value = n;
                }
            }

            //觉醒时间
            str = ini.IniReadValue("TJ", "jx_time_end");
            if (str != null && str != "")
            {
                int n = 0;
                int.TryParse(str, out n);
                if (n >= numericUpDown13.Minimum && n <= numericUpDown13.Maximum)
                {
                    numericUpDown13.Value = n;
                }
            }

            //觉醒BC
            str = ini.IniReadValue("TJ", "jx_bc");
            if (str != null && str != "")
            {
                int n = 0;
                int.TryParse(str, out n);
                if (n >= numericUpDown12.Minimum && n <= numericUpDown12.Maximum)
                {
                    numericUpDown12.Value = n;
                }
            }

            //觉醒等待
            str = ini.IniReadValue("TJ", "jx_wait");
            if (str != null && str != "")
            {
                int n = 0;
                int.TryParse(str, out n);
                if (n >= numericUpDown16.Minimum && n <= numericUpDown16.Maximum)
                {
                    numericUpDown16.Value = n;
                }
            }

            //探索BC阈值
            str = ini.IniReadValue("TJ", "explore_bc");
            if (str != null && str != "")
            {
                int n = 0;
                int.TryParse(str, out n);
                if (n >= numericUpDown10.Minimum && n <= numericUpDown10.Maximum)
                {
                    numericUpDown10.Value = n;
                }
            }

            //探索STEP
            str = ini.IniReadValue("TJ", "explore_step");
            if (str != null && str != "")
            {
                int n = 0;
                int.TryParse(str, out n);
                if (n >= numericUpDown11.Minimum && n <= numericUpDown11.Maximum)
                {
                    numericUpDown11.Value = n;
                }
            }

            //是否强制日怪
            str = ini.IniReadValue("TJ", "force_pg");
            if (str != null && str != "")
            {
                int n = 0;
                int.TryParse(str, out n);
                checkBox5.Checked = (n == 0 ? false : true);
            }

            //是否自动配卡
            str = ini.IniReadValue("TJ", "useautocard");
            if (str != null && str != "")
            {
                int n = 0;
                int.TryParse(str, out n);
                checkBox9.Checked = (n == 0 ? false : true);
            }

            //是否强制探索
            str = ini.IniReadValue("TJ", "force_explore");
            if (str != null && str != "")
            {
                int n = 0;
                int.TryParse(str, out n);
                checkBox7.Checked = (n == 0 ? false : true);
            }

            //是否强制探索一个区域
            str = ini.IniReadValue("TJ", "force_explore_area_next");
            if (str != null && str != "")
            {
                int n = 0;
                int.TryParse(str, out n);
                checkBox11.Checked = (n == 0 ? false : true);
            }

            //日怪血量
            str = ini.IniReadValue("TJ", "force_pg_bc");
            if (str != null && str != "")
            {
                int n = 0;
                int.TryParse(str, out n);
                if (n >= numericUpDown17.Minimum && n <= numericUpDown17.Maximum)
                {
                    numericUpDown17.Value = n;
                }
            }

            //轮询时间
            str = ini.IniReadValue("TJ", "loop_time");
            if (str != null && str != "")
            {
                int n = 0;
                int.TryParse(str, out n);
                if (n >= numericUpDown18.Minimum && n <= numericUpDown18.Maximum)
                {
                    numericUpDown18.Value = n;
                }
            }

            //刷无名BC
            str = ini.IniReadValue("TJ", "noname_bc");
            if (str != null && str != "")
            {
                int n = 0;
                int.TryParse(str, out n);
                if (n >= numericUpDown19.Minimum && n <= numericUpDown19.Maximum)
                {
                    numericUpDown19.Value = n;
                }
            }

            //自动配卡CP值
            str = ini.IniReadValue("TJ", "useautocard_cp");
            if (str != null && str != "")
            {
                int n = 0;
                int.TryParse(str, out n);
                if (n >= numericUpDown21.Minimum && n <= numericUpDown21.Maximum)
                {
                    numericUpDown21.Value = n;
                }
            }

            //自动领取
            str = ini.IniReadValue("TJ", "useautorewards");
            if (str != null && str != "")
            {
                int n = 0;
                int.TryParse(str, out n);
                checkBox13.Checked = (n == 0 ? false : true);
            }

            //无名亚瑟AP
            str = ini.IniReadValue("TJ", "noname_ap");
            if (str != null && str != "")
            {
                int n = 0;
                int.TryParse(str, out n);
                if (n >= numericUpDown20.Minimum && n <= numericUpDown20.Maximum)
                {
                    numericUpDown20.Value = n;
                }
            }

            //脱机出售数量
            str = ini.IniReadValue("TJ", "selln");
            if (str != null && str != "")
            {
                int n = 0;
                int.TryParse(str, out n);
                if (n >= numericUpDown15.Minimum && n <= numericUpDown15.Maximum)
                {
                    numericUpDown15.Value = n;
                }
            }

            //脱机出售id
            str = ini.IniReadValue("TJ", "sell");
            if (str != null && str != "")
            {
                string sell = null;
                string[] sz = str.Split('|');
                foreach (string s in sz)
                {
                    listBox2.Items.Add(s);
                    if (s.IndexOf(',') > 0)
                    {
                        if (sell == null)
                            sell = s.Substring(0, s.IndexOf(','));
                        else
                            sell += "," + s.Substring(0, s.IndexOf(','));
                    }
                }
                MA_Client.sell = sell;
            }

            str = ini.IniReadValue("TJ", "force_explore_area");
            if (str != null && str != "")
            {
                textBox6.Text = str;
            }

            str = ini.IniReadValue("TJ", "wake_up_key");
            if (str != null && str != "")
            {
                textBox5.Text = str;
            }

            //脱机卡组信息
            str = ini.IniReadValue("TJ", "card1");
            if (str != null && str != "")
            {
                //设置卡
                string strr, leader;
                cardformat(out strr, out leader, str);

                MA_Client.card1 = strr;
                MA_Client.card1l = leader;
            }

            str = ini.IniReadValue("TJ", "card2");
            if (str != null && str != "")
            {
                //设置卡
                string strr, leader;
                cardformat(out strr, out leader, str);

                MA_Client.card2 = strr;
                MA_Client.card2l = leader;
            }

            str = ini.IniReadValue("TJ", "card3");
            if (str != null && str != "")
            {
                //设置卡
                string strr, leader;
                cardformat(out strr, out leader, str);

                MA_Client.card3 = strr;
                MA_Client.card3l = leader;
            }

            str = ini.IniReadValue("TJ", "card4");
            if (str != null && str != "")
            {
                //设置卡
                string strr, leader;
                cardformat(out strr, out leader, str);

                MA_Client.card4 = strr;
                MA_Client.card4l = leader;
            }

            str = ini.IniReadValue("HKG", "usehkg");
            if (str != null && str != "")
            {
                int n = 0;
                int.TryParse(str, out n);
                if (n == 0)
                    checkBox2.Checked = false;
                else
                    checkBox2.Checked = true;
            }

            //初始化基本参数

            //try
            //{
            //    RegistryKey HKLM = Registry.LocalMachine;
            //    RegistryKey Run = HKLM.OpenSubKey(@"SOFTWARE\BlueStacks\Guests\Android\FrameBuffer\0");
            //    int Height = int.Parse(Run.GetValue("Height").ToString());
            //    int Width = int.Parse(Run.GetValue("Width").ToString());
            //    if (Height != 576 || Width != 1024)
            //    {
            //        //if (MessageBox.Show("检测到BlueStacks分辨率不是1024X576,是否进行修改", "notice",
            //        //MessageBoxButtons.OKCancel,
            //        //MessageBoxIcon.Question) == DialogResult.OK)
            //        //{
            //        //    Run.SetValue("Height", 576);
            //        //    Run.SetValue("Width", 1024);
            //        //    MessageBox.Show("修改成功,请重新退出模拟器重进");
            //        //}
            //        else
            //        {
            //            Environment.Exit(0);
            //        }
            //    }
            //}
            //catch (System.ArgumentNullException)
            //{
            //    MessageBox.Show("没有安装BlueStacks?");
            //    Environment.Exit(0);
            //}
            //catch (Exception ex)
            //{
            //    MessageBox.Show("没有安装BlueStacks?,如果使用脱机请无视.");
            //}
        }
예제 #54
0
        public static void LoadListFromINI(MapTheater TheaterData, bool arg)
        {
            String IniName = String.Format("{0}MD.INI", TheaterData.mixName);

            var INIStream = FileSystem.LoadFile(IniName);
            var isoINI = new INI(INIStream);

            int negative = -1;

            foreach (var lookup in TilesetIndices) {
                isoINI.GetInteger("General", lookup.Value.Name, out lookup.Value.TilesetIndex, negative);
            }

            int tsetIdx = 0;
            while (true) {
                String TilesetSection = String.Format("TileSet{0:d4}", tsetIdx);
                if (!isoINI.SectionExists(TilesetSection)) {
                    break;
                }
                var tsCfg = new TilesetConfig() {
                    TilesInSet = -1
                };
                isoINI.GetInteger(TilesetSection, "TilesInSet", out tsCfg.TilesInSet, negative);
                if (tsCfg.TilesInSet == -1) {
                    break;
                }

                foreach (var lookup in TilesetIndices) {
                    if (tsetIdx == lookup.Value.TilesetIndex) {
                        lookup.Value.TileIndex = All.Count;
                    }
                }

                ++tsetIdx;

                isoINI.GetString(TilesetSection, "SetName", out tsCfg.SetName, "No Name");
                isoINI.GetString(TilesetSection, "FileName", out tsCfg.FileName, "TILE");
                isoINI.GetInteger(TilesetSection, "MarbleMadness", out tsCfg.MarbleMadness, 65535);
                isoINI.GetInteger(TilesetSection, "NonMarbleMadness", out tsCfg.NonMarbleMadness, 65535);
                isoINI.GetBool(TilesetSection, "Morphable", out tsCfg.Morphable, false);
                isoINI.GetBool(TilesetSection, "AllowToPlace", out tsCfg.AllowToPlace, true);
                isoINI.GetBool(TilesetSection, "AllowBurrowing", out tsCfg.AllowBurrowing, true);
                isoINI.GetBool(TilesetSection, "AllowTiberium", out tsCfg.AllowTiberium, false);
                isoINI.GetBool(TilesetSection, "RequiredForRMG", out tsCfg.RequiredForRMG, false);
                isoINI.GetInteger(TilesetSection, "ToSnowTheater", out tsCfg.ToSnowTheater, -1);
                isoINI.GetInteger(TilesetSection, "ToTemperateTheater", out tsCfg.ToTemperateTheater, -1);
                isoINI.GetBool(TilesetSection, "ShadowCaster", out tsCfg.ShadowCaster, false);
                if (tsCfg.ShadowCaster) {
                    isoINI.GetInteger(TilesetSection, "ShadowTiles", out tsCfg.ShadowTiles, 0);
                }

                for (var i = 1; i <= tsCfg.TilesInSet; ++i) {
                    var TileFnameBase = String.Format("{0:s}{1:d2}", tsCfg.FileName, i);

                    var variation = 0;
                    var exists = false;
                    IsoTileTypeClass curTile = null;
                    do {
                        var TileFname = String.Format("{0:s}{1:s}.{2:s}", TileFnameBase, GetSuffix(variation), TheaterData.Extension);
                        ++variation;
                        var tileFile = FileSystem.LoadFile(TileFname);
                        if (tileFile == null) {
                            exists = false;
                        } else {
                            var tileVariation = new IsoTileTypeClass() {
                                cfg = tsCfg,
                                IndexInTileset = i,
                                AllowBurrowing = tsCfg.AllowBurrowing,
                                AllowTiberium = tsCfg.AllowTiberium,
                                AllowToPlace = tsCfg.AllowToPlace,
                                Morphable = tsCfg.Morphable,
                                RequiredForRMG = tsCfg.RequiredForRMG,
                                ToSnowTheater = tsCfg.ToSnowTheater,
                                ToTemperateTheater = tsCfg.ToTemperateTheater,
                            };
                            try {
                                var tmpVariation = new TMP(tileFile);
                                tileVariation.Tile = tmpVariation;
                                if (curTile == null) {
                                    curTile = tileVariation;
                                } else {
                                    curTile.NextVariation = tileVariation;
                                }
                                exists = true;
                            } catch (ArgumentException) {
                                // bleh, broken file
                            }
                        }
                        if (curTile == null) {
                            Debug.WriteLine("Failed to load tile {0}{1}", TileFname, ".");
                        }
                    } while (exists);

                    All.Add(curTile);
                }

            }
        }
예제 #55
0
 private static void GetValue(string FileName, string Section, string Key)
 {
     WriteLine(INI.getSetting(FileName, Section, Key));
 }
예제 #56
0
        public I_OPC()
        {
            try						// disabled for debugging
            {
                cfg = new INI(AppDomain.CurrentDomain.SetupInformation.ApplicationBase + "config\\opc.ini");
                strHostIP = cfg.GetVal("Connect", "OPCSERVER_IP");
                serverProgID = cfg.GetVal("Connect", "OPCSERVER_NAME");
                add_hours = Convert.ToInt32(cfg.GetVal("Connect", "ADD_HOURS"));
                if (strHostIP == "" || serverProgID == "")
                {
                    sw = File.AppendText("config\\opc.ini");
                    sw.WriteLine("OPCSERVER_IP=127.0.0.1");
                    sw.WriteLine("OPCSERVER_NAME=");
                    sw.WriteLine("ADD_HOURS=0");
                    sw.Close();
                }

                logfile = "log.txt";
                FileStream fs = new FileStream(logfile, FileMode.OpenOrCreate);
                fs.Close();

                sw = File.AppendText(logfile);
                sw.WriteLine("初始化配置成功!");
                sw.Close();

            }
            catch (Exception e)
            {
                Console.WriteLine(e.ToString());
                Console.ReadLine();
                return;
            }
        }
예제 #57
0
 public DBConnectioin()
 {
     ini = new INI();
 }
예제 #58
0
파일: Themes.cs 프로젝트: WendyH/HMSEditor
        public static void LoadThemesFromString(string data)
        {
            INI tini = new INI();
            tini.NoComments = true;
            tini.Text = data;
            Dict.Clear();
            foreach(string section in tini.Dict.Keys) {
                Theme tt = new Theme();
                tt.Name = section;
                tt.Background      = ToColor(tini.Get("Background"     , section, ""));
                tt.Caret           = ToColor(tini.Get("Caret"          , section, ""));
                tt.Foreground      = ToColor(tini.Get("Foreground"     , section, ""));
                tt.Invisibles      = ToColor(tini.Get("Invisibles"     , section, ""));
                tt.LineHighlight   = ToColor(tini.Get("LineHighlight"  , section, ""));
                tt.ChangedLines    = ToColor(tini.Get("ChangedLines"   , section, ""));
                tt.Selection       = ToColor(tini.Get("Selection"      , section, ""));
                tt.LineNumberColor = ToColor(tini.Get("LineNumberColor", section, ""));
                tt.IndentBackColor = ToColor(tini.Get("IndentBackColor", section, ""));

                tt.StringStyle       = ToStyle2(tini.Get("StringStyle"      , section, ""));
                tt.CommentStyle      = ToStyle2(tini.Get("CommentStyle"     , section, ""));
                tt.NumberStyle       = ToStyle2(tini.Get("NumberStyle"      , section, ""));
                tt.AttributeStyle    = ToStyle2(tini.Get("AttributeStyle"   , section, ""));
                tt.ClassNameStyle    = ToStyle2(tini.Get("ClassNameStyle"   , section, ""));
                tt.KeywordStyle      = ToStyle2(tini.Get("KeywordStyle"     , section, ""));
                tt.CommentTagStyle   = ToStyle2(tini.Get("CommentTagStyle"  , section, ""));
                tt.TagBracketStyle   = ToStyle2(tini.Get("TagBracketStyle"  , section, ""));
                tt.FunctionsStyle    = ToStyle2(tini.Get("FunctionsStyle"   , section, ""));
                tt.VariableStyle     = ToStyle2(tini.Get("VariableStyle"    , section, ""));
                tt.DeclFunctionStyle = ToStyle2(tini.Get("DeclFunctionStyle", section, ""));
                tt.InvisibleStyle    = ToStyle (tini.Get("Invisibles"       , section, ""));
                Dict.Add(section, tt);
            }
        }
예제 #59
0
파일: GridDock.xaml.cs 프로젝트: godhoop/12
        private void LoadWidgets()
        {
            // 위젯 검색
            string[] Widgets = Directory.GetFiles(ConfigManager.WidgetPath, "*.ini", SearchOption.AllDirectories);

            // 검색된 위젯 추가
            foreach(string Path in Widgets)
            {
                // 위젯 구성 분석
                INI Widget = new INI(Path);
                string Title = Widget.GetValue("General", "Title");

                // 위젯 섬네일 컨트롤 생성
                StackPanel WidgetStack = new StackPanel
                {
                    Width = 120,
                    Height = 120,
                    Margin = new Thickness(15, 10, 0, 0)
                };

                Image WidgerThumb = new Image
                {
                    Width = 80,
                    Height = 80,
                    Source = ImageLoad(Directory.GetParent(Path) + "\\" + System.IO.Path.GetFileNameWithoutExtension(Path) + ".png")
                };
                WidgetStack.Children.Add(WidgerThumb);

                TextBlock WidgetTitle = new TextBlock
                {
                    Text = Title,
                    Margin = new Thickness(0, 10, 0, 0),
                    VerticalAlignment = VerticalAlignment.Bottom,
                    HorizontalAlignment = HorizontalAlignment.Center
                };
                WidgetStack.Children.Add(WidgetTitle);

                // 위젯 섬네일 컨트롤 이벤트 설정
                WidgetStack.MouseLeftButtonDown  += (s, e) =>
                {
                    IsDrawerOpen = false;
                    GridWidget Target = new GridWidget
                    {
                        NowLoading = true
                    };
                    if (Target.Load(Path))
                    {
                        Add(Target);
                        Target.StartMouseDown();
                    }
                };

                // 콘텐츠 스택에 섬네일 컨트롤 추가
                StackDrawerContent.Children.Add(WidgetStack);
            }
        }
예제 #60
0
		public Program(string[] args) {
			string moviefile = null;
			string emufile = null;

			#region ini
			string inifile = _getprogdir() + @"\config.ini";
			_settings = new INI(inifile);
			string dirs = _settings["config", "dirs"];
			if ((dirs == null) || (dirs.Trim() == "")) {
				Console.WriteLine("Please select your rom dir...\n");
				if ((dirs = _adddirdlg()) == null) {
					fatal("'" + inifile + @"' not found or missing data. Please create and list your rom directories semicolon deliminated as follows:
					
[config]
dirs=c:\my roms\;c:\my other roms\;c:\etc\etc\etc\");
				} else {
					Console.WriteLine("Please note, that you can add new directories by modifying your '" + inifile + @"' configuration file. The dirs key should contain directories which are semicolon deliminated, for example:

[config]
dirs=c:\my roms\;c:\my other roms\;c:\etc\etc\etc\

Press any key to continue.");
					Console.ReadKey();
				}
			}
			#endregion

			#region args the lazy way
			moviefile = String.Join(" ", args).Replace('"', ' ').Trim();	//Hack.
			if ((moviefile == null) || (moviefile == "")) {
				_mainmenu();
				Environment.Exit(0);
			}
			if (!File.Exists(moviefile)) {
				fatal("Movie file '" + moviefile + @"' does not exist.

Usage:   program.exe movie file
Example: program.exe C:\blah\Dragon Warrior (U).exe");
			}
			#endregion

			db = new database(_getprogdir() + @"\roms." + _dbversion.ToString() + ".db");
			emuMovie movie = new emuMovie(moviefile);
			emufile = _settings["config", movie.FileExt];
			if (!File.Exists(emufile)) {		
				emufile = _filedlg(_promptdlgtype.emu);
				if (emufile == null)
					fatal("The movie can not be played with out an emulator being set. Please re-run the program and select one or please set the value through your ini as follows:\n\n[config]\n" + movie.FileExt + @"=C:\path\and\filename.exe");
				_settings["config", movie.FileExt] = emufile;
			}
			ArrayList romfiles = movie.ROM();
			string romfile = "";
			if (romfiles == null) {
				if (_promptyesno("Unable to locate the ROM in the database. Would you like to update? If not, a file selection dialog will show."))
					_updatedb(dirs);
			}
			romfiles = movie.ROM();
			if (romfiles == null) {
				romfile = _filedlg(_promptdlgtype.rom, movie.FileExt);
			} else if (romfiles.Count == 1) {
				romfile = romfiles[0].ToString();
			} else {
				for (int i = 0; i < romfiles.Count; i++)
					Console.WriteLine("{0})\t{1}", i+1, romfiles[i]);
				int selection = 0;
				try {
					selection = int.Parse(_prompt("Please enter the number for the rom you wish to use."));
				} catch (FormatException) {
					Program.fatal("Invalid selection.");
				}
				if ((selection > 0) && (selection <= romfiles.Count)) {
					romfile = romfiles[selection - 1].ToString();
				} else {
					Program.fatal("Invalid selection.");
				}
			}
			if (!File.Exists(romfile)) {
				if (romfiles == null) {
					db.Remove(romfile);
					fatal("The ROM file with hash of " + movie.Hash + " was identified in the database, but the file '" + romfile + "' associated with it was not found. The dead entry has been removed from the database.");
				}
			}
			_emuExec(emufile, movie, romfile);
			db.Close();
		}