Exemplo n.º 1
0
        /// <summary>
        /// 设置参数文件
        /// </summary>
        public void SetParameterFile()
        {
            //存储到文件
            string sFileDir = AppConfigOperation.GetConfigurationValue("ApplicationFullPath") + @"\PathPlanning\Method\Parameter\" +
                              ((int)EPathPlanningMethod.RRTStar).ToString() + ".ini"; //参数文件地址

            IniOperation.WriteProfileString("PlanningStep", "StepType", ((int)(MStepType)).ToString(), sFileDir);
            IniOperation.WriteProfileString("PlanningStep", "Step", MStep.ToString(), sFileDir);
            IniOperation.WriteProfileString("PlanningStep", "FixedNearDistanceRatio", FixedNearDistanceRatio.ToString(), sFileDir);
            IniOperation.WriteProfileString("PlanningStep", "RandomStepMax", MRandomStepMax.ToString(), sFileDir);
            IniOperation.WriteProfileString("PlanningStep", "RandomStepMin", MRandomStepMin.ToString(), sFileDir);
            IniOperation.WriteProfileString("Extension", "SelectionType", ((int)MSelectionType).ToString(), sFileDir);
            IniOperation.WriteProfileString("Extension", "ChooseTargetThreshold", MChooseTargetThreshold.ToString(), sFileDir);
            IniOperation.WriteProfileString("Extension", "MaxNodeNumber", MMaxNodeNumber.ToString(), sFileDir);
            IniOperation.WriteProfileString("Extension", "ReachMode", ((int)MReachMode).ToString(), sFileDir);
            IniOperation.WriteProfileString("Others", "AutoOptimizeParameter", (Convert.ToInt32(MAutoOptimizeParameter)).ToString(), sFileDir);
            IniOperation.WriteProfileString("Others", "IsDrawingTree", (Convert.ToInt32(MIsDrawingTree)).ToString(), sFileDir);

            IniOperation.WriteProfileString("Others", "IsDubinsMode", (Convert.ToInt32(MIsDubinsMode)).ToString(), sFileDir);
            IniOperation.WriteProfileString("Others", "TurningRadius", TurningRadius.ToString(), sFileDir);

            #region NearNodesFilter
            IniOperation.WriteProfileString("NearNodesFilter", "NearNodesFilter", (Convert.ToInt32(NearNodesFilter)).ToString(), sFileDir);
            IniOperation.WriteProfileString("NearNodesFilter", "TriggerNum", TriggerNum.ToString(), sFileDir);
            #endregion
        }
Exemplo n.º 2
0
        /// <summary>
        /// 设置参数文件
        /// </summary>
        public void SetParameterFile()
        {
            //存储到文件
            string sFileDir = System.AppDomain.CurrentDomain.BaseDirectory + @"PathPlanning\Method\Parameter\" +
                              typeof(JPSAlgorithmHelper).ToString() + ".ini"; //参数文件地址

            IniOperation.WriteProfileString("Others", "AutoOptimizeParameter", (Convert.ToInt32(AutoOptimizeParameter)).ToString(), sFileDir);
            IniOperation.WriteProfileString("ParameterSetting", "Step", Step.ToString(), sFileDir);
            IniOperation.WriteProfileString("ParameterSetting", "NeedPathSimplifed", (Convert.ToInt32(NeedPathSimplifed)).ToString(), sFileDir);
        }
Exemplo n.º 3
0
        // 加载本地设置
        private void LoadLocalSetting()
        {
            // 测试目录
            string testDir = IniOperation.ReadValue(FrmMain.APP_CFG_PATH, "cache", "test_filter_dir");

            if (testDir.Length > 0 && Directory.Exists(testDir))
            {
                ((CharmTextBox)mControls[0]).Text = testDir;
            }
        }
        /// <summary>
        /// 设置参数文件
        /// </summary>
        public void SetParameterFile()
        {
            //存储到文件
            string sFileDir = System.AppDomain.CurrentDomain.BaseDirectory + @"PathPlanning\Method\Parameter\" +
                              typeof(RRTBase).ToString() + ".ini"; //参数文件地址

            IniOperation.WriteProfileString("PlanningStep", "StepType", ((int)(m_StepType)).ToString(), sFileDir);
            IniOperation.WriteProfileString("PlanningStep", "Step", m_Step.ToString(), sFileDir);
            IniOperation.WriteProfileString("PlanningStep", "RandomStepMax", m_RandomStepMax.ToString(), sFileDir);
            IniOperation.WriteProfileString("PlanningStep", "RandomStepMin", m_RandomStepMin.ToString(), sFileDir);
            IniOperation.WriteProfileString("Extension", "SelectionType", ((int)m_SelectionType).ToString(), sFileDir);
            IniOperation.WriteProfileString("Extension", "ChooseTargetThreshold", m_ChooseTargetThreshold.ToString(), sFileDir);
            IniOperation.WriteProfileString("Extension", "MaxNodeNumber", m_MaxNodeNumber.ToString(), sFileDir);
            IniOperation.WriteProfileString("Extension", "ReachMode", ((int)m_ReachMode).ToString(), sFileDir);
            IniOperation.WriteProfileString("Others", "AutoOptimizeParameter", (Convert.ToInt32(m_AutoOptimizeParameter)).ToString(), sFileDir);
            IniOperation.WriteProfileString("Others", "DijkstraOptimizeParameter", (Convert.ToInt32(DijkstraOptimizeParameter)).ToString(), sFileDir);
        }
Exemplo n.º 5
0
        // 浏览路径按钮被单击事件
        private void btnViewPath_MouseClick(object sender, MouseEventArgs e)
        {
            string testDir = ((CharmTextBox)mControls[0]).Text;
            // 创建并实例化文件浏览对话框
            FolderBrowserDialog folderBrowserFialog = new FolderBrowserDialog
            {
                Description  = "请选择测试目录",
                SelectedPath = testDir
            };

            // 显示对话框并判断用户是否指定新的目录
            if (folderBrowserFialog.ShowDialog() == DialogResult.OK)
            {
                testDir = folderBrowserFialog.SelectedPath; // 用户指定新的目录
                ((CharmTextBox)mControls[0]).Text = testDir;
                IniOperation.WriteValue(FrmMain.APP_CFG_PATH, "cache", "test_filter_dir", testDir);
            }
        }
Exemplo n.º 6
0
        public static OperationReturn GetMachineID()
        {
            OperationReturn optReturn = new OperationReturn();

            optReturn.Result = true;
            optReturn.Code   = Defines.RET_SUCCESS;
            try
            {
                bool          bIsExist           = true;
                string        strProgramDataPath = Environment.GetFolderPath(Environment.SpecialFolder.CommonApplicationData) + "\\VoiceCyber\\UMP\\config";
                DirectoryInfo dir = new DirectoryInfo(strProgramDataPath);
                if (!dir.Exists)
                {
                    dir.Create();
                }
                string   strIniPath = strProgramDataPath + "\\localmachine.ini";
                FileInfo fi         = new FileInfo(strIniPath);
                if (!fi.Exists)
                {
                    FileStream fs = fi.Create();
                    fs.Close();
                    bIsExist = false;
                }
                IniOperation ini = new IniOperation(strIniPath);

                if (!bIsExist)
                {
                    string      strHostName = Dns.GetHostName(); //得到本机的主机名
                    IPHostEntry ipEntry     = Dns.GetHostEntry(strHostName);
                    if (ipEntry.AddressList.Count() > 0)
                    {
                        foreach (IPAddress adress in ipEntry.AddressList)
                        {
                            if (adress.AddressFamily == AddressFamily.InterNetwork)
                            {
                                ini.IniWriteValue("LocalMachine", "SubscribeAddress", "224.0.2.26,3789");
                                break;
                            }
                            //else if (adress.AddressFamily == AddressFamily.InterNetworkV6)
                            //{
                            //    ini.IniWriteValue("LocalMachine", "SubscribeAddress", "ff01::0226,3789");
                            //    break;
                            //}
                            continue;
                        }
                    }
                }
                string strMachineID = ini.IniReadValue("LocalMachine", "MachineID");
                if (string.IsNullOrEmpty(strMachineID))
                {
                    strMachineID = Guid.NewGuid().ToString();
                    ini.IniWriteValue("LocalMachine", "MachineID", strMachineID);
                }
                optReturn.Data    = strMachineID;
                App.gStrMachineID = strMachineID;
            }
            catch (Exception ex)
            {
                optReturn.Code    = Defines.RET_FAIL;
                optReturn.Result  = false;
                optReturn.Message = ex.Message;
            }

            return(optReturn);
        }
        /// <summary>
        /// 引发 Paint 事件
        /// </summary>
        /// <param name="e">包含事件数据的 PaintEventArgs</param>
        protected override void OnPaint(PaintEventArgs e)
        {
            // 获取绘制对象
            Graphics g = e.Graphics;

            // 循环绘制每项
            for (int i = 0; i < Items.Count; i++)
            {
                Rectangle            bounds = GetItemRectangle(i);
                StudyPlanListBoxItem item   = Items[i];
                // 绘制表项分界线
                Pen p = new Pen(Brushes.LightGray);
                //p.DashStyle = DashStyle.Dash;
                g.DrawLine(p, new Point(0, bounds.Top), new Point(Width, bounds.Top));
                // 绘制表项背景
                if (SelectedIndex != i)
                {
                    Color backColor = Color.FromArgb(20, 216, 211, 211);
                    using (SolidBrush brush = new SolidBrush(backColor))
                    {
                        //g.FillRectangle(new SolidBrush(Color.White),bounds);
                        g.FillRectangle(brush, new Rectangle(bounds.X, bounds.Y + 1, bounds.Width, bounds.Height - 1));
                    }
                }
                else
                {
                    g.FillRectangle(new SolidBrush(Color.FromArgb(250, 255, 252, 217)),
                                    new Rectangle(bounds.X, bounds.Y + 1, bounds.Width, bounds.Height - 1));
                }

                // 高亮非选中项
                if (mMouseItem == Items[i] && SelectedIndex != i)
                {
                    Color backColor = Color.FromArgb(200, 192, 224, 248);
                    using (SolidBrush brush = new SolidBrush(backColor))
                    {
                        //g.FillRectangle(new SolidBrush(Color.White),bounds);
                        g.FillRectangle(brush, new Rectangle(bounds.X, bounds.Y + 1, bounds.Width, bounds.Height - 1));
                    }
                }

                // 绘制表项内容
                // 行1
                g.DrawString("教程名称:", new Font("微软雅黑", 9), Brushes.Black, bounds.Left + 5, bounds.Top + 3);
                g.DrawString("教程类别:", new Font("微软雅黑", 9), Brushes.Black, bounds.Left + 250, bounds.Top + 3);
                g.DrawString("教程级别:", new Font("微软雅黑", 9), Brushes.Black, bounds.Left + 400, bounds.Top + 3);

                g.DrawString(item.CourseName, new Font("微软雅黑", 9, FontStyle.Bold), Brushes.Indigo, bounds.Left + 65, bounds.Top + 3);

                // 判断教程标识,转换不同类别
                string configPath = Application.StartupPath + "\\Config\\Config.ini";
                string planType   = IniOperation.ReadValue(configPath, "coursetype", item.CourseType);
                g.DrawString(planType, new Font("微软雅黑", 9, FontStyle.Bold), Brushes.Black, bounds.Left + 310, bounds.Top + 3);

                // 判断教程级别,指定不同颜色
                Brush  levelBrush = Brushes.Black;
                string planLevel  = string.Empty;
                switch (item.CourseLevel)
                {
                case "1":
                    planLevel  = "基础";
                    levelBrush = Brushes.Black;
                    break;

                case "2":
                    planLevel  = "中级";
                    levelBrush = Brushes.BlueViolet;
                    break;

                case "3":
                    planLevel  = "高级";
                    levelBrush = Brushes.MidnightBlue;
                    break;

                case "4":
                    planLevel  = "大师";
                    levelBrush = Brushes.Red;
                    break;

                case "5":
                    planLevel  = "骨灰";
                    levelBrush = Brushes.Purple;
                    break;
                }
                g.DrawString(planLevel, new Font("微软雅黑", 9, FontStyle.Bold), levelBrush, bounds.Left + 460, bounds.Top + 3);
                // 行2
                g.DrawString("起始日期:", new Font("微软雅黑", 9), Brushes.Black, bounds.Left + 5, bounds.Top + 24);
                g.DrawString("最近学习时间:", new Font("微软雅黑", 9), Brushes.Black, bounds.Left + 180, bounds.Top + 24);

                g.DrawString(item.StartDate, new Font("微软雅黑", 9, FontStyle.Bold), Brushes.Black, bounds.Left + 65, bounds.Top + 24);
                g.DrawString(item.LastestStudy, new Font("微软雅黑", 9, FontStyle.Bold), Brushes.Black, bounds.Left + 265, bounds.Top + 24);

                // 行3
                //计算学习进度百分比
                string[] info     = item.RelatedResIDs.Split('-');
                double   progress = item.StudyProgress / Convert.ToDouble(info[0]);
                if (progress == 0)
                {
                    progress = 0.01;
                }
                g.DrawString("教程学习进度:", new Font("微软雅黑", 9), Brushes.Black, bounds.Left + 5, bounds.Top + 45);
                g.DrawImage(new Bitmap(Resources.timeprogressbg, new Size(200, 18)),
                            new Point(bounds.Left + 95, bounds.Top + 44));
                g.DrawImage(new Bitmap(Resources.time_progress_fg_lightGreen, new Size((int)(200 * progress), 18)),
                            new Point(bounds.Left + 95, bounds.Top + 44));
                g.DrawString("取消订阅教程", new Font("微软雅黑", 9), Brushes.Blue, bounds.Left + 330, bounds.Top + 45);

                // 判断按钮状态
                // 按下态
                if (buttonDownIndex == i)
                {
                    g.DrawImage(Resources.btn_big_down,
                                new Rectangle(new Point(bounds.Left + 445, bounds.Top + 27), new Size(100, 30)));
                    g.DrawString("开始学习", new Font("微软雅黑", 10), Brushes.DarkGreen, bounds.Left + 467, bounds.Top + 32);
                }
                else
                {
                    // 高亮态
                    if (buttonHighlightIndex == i)
                    {
                        g.DrawImage(Resources.btn_big_hover,
                                    new Rectangle(new Point(bounds.Left + 445, bounds.Top + 27), new Size(100, 30)));
                    }
                    else
                    {
                        g.DrawImage(Resources.btn_big_normal,
                                    new Rectangle(new Point(bounds.Left + 445, bounds.Top + 27), new Size(100, 30)));
                    }
                    g.DrawString("开始学习", new Font("微软雅黑", 10), Brushes.DarkGreen, bounds.Left + 466, bounds.Top + 31);
                }

                g.DrawLine(p, new Point(0, bounds.Top + 65), new Point(Width, bounds.Top + 65));
                p.Dispose();
            }
            //base.OnPaint(e);
        }