Exemplo n.º 1
0
        public async Task <IActionResult> PutGuides([FromRoute] int id, [FromBody] Guides guides)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            if (id != guides.GuideId)
            {
                return(BadRequest());
            }

            _context.Entry(guides).State = EntityState.Modified;

            try
            {
                await _context.SaveChangesAsync();
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!GuidesExists(id))
                {
                    return(NotFound());
                }
                else
                {
                    throw;
                }
            }

            return(NoContent());
        }
Exemplo n.º 2
0
        public async Task <IActionResult> Edit(int id, [Bind("GuideTitle,GuideContent,DateSubmitted,LastUpdated,UserProfilesId,GameId")] Guides guides)
        {
            if (id != guides.Id)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(guides);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!GuidesExists(guides.Id))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            ViewData["GameId"] = new SelectList(_context.Games, "Id", "GameTitle", guides.GameId);
            //ViewData["UserProfilesId"] = new SelectList(_context.UserProfiles, "Id", "DisplayName", guides.UserProfilesId);
            return(View(guides));
        }
        private bool IsNameExist(Guides guide)
        {
            try
            {
                DataTable dtList = GetAll();
                var       rows   = dtList.AsEnumerable().Where(x => ((string)x["Name"]).ToString() == guide.Name);
                DataTable dt     = rows.Any() ? rows.CopyToDataTable() : dtList.Clone();

                if (dt != null)
                {
                    if (dt.Rows.Count > 0)
                    {
                        return(true);
                    }
                    else
                    {
                        return(false);
                    }
                }
                else
                {
                    return(false);
                }
            }
            catch (Exception)
            {
                throw;
            }
        }
Exemplo n.º 4
0
        public void Update(NetToolProxy netTool)
        {
            _measurements.Clear();
            DebugState = "";

            if (!netTool.IsEnabled || netTool.Mode == NetTool.Mode.Upgrade)
            {
                return;
            }

            Segment.CalculateSegmentBranchAngles(netTool, _measurements);
            Segment.CalculateJoinAngles(netTool, _measurements);
            Node.CalculateBranchAngles(netTool, _measurements);
            Node.CalculateJoinAngles(netTool, _measurements);
            Guides.CalculateGuideLineAngle(netTool, _measurements);
            Guides.CalculateGuideLineDistance(netTool, _measurements);

            CalculateNearbySegments(netTool, _measurements);

            CalculateControlPointDistances(netTool, _measurements);
            CalculateControlPointAngle(netTool, _measurements);

            CalculateControlPointElevation(netTool, _measurements);
            CalculateCompassAngle(netTool, _measurements);
        }
Exemplo n.º 5
0
        public bool Delete(Guides guide)
        {
            QuaintDatabaseManager db = new QuaintDatabaseManager(true);

            try
            {
                bool flag = false;
                db.AddParameters("GuideId", guide.GuideId);
                int affectedRows = db.ExecuteNonQuery("Delete_Guide", true);

                if (affectedRows > 0)
                {
                    flag = true;
                }

                return(flag);
            }
            catch (Exception)
            {
                throw;
            }
            finally
            {
                db.Disconnect();
            }
        }
Exemplo n.º 6
0
        /// <inheritdoc/>
        public override void Assign(Base source)
        {
            base.Assign(source);

            ReportPage src = source as ReportPage;

            Landscape        = src.Landscape;
            PaperWidth       = src.PaperWidth;
            PaperHeight      = src.PaperHeight;
            RawPaperSize     = src.RawPaperSize;
            LeftMargin       = src.LeftMargin;
            TopMargin        = src.TopMargin;
            RightMargin      = src.RightMargin;
            BottomMargin     = src.BottomMargin;
            MirrorMargins    = src.MirrorMargins;
            FirstPageSource  = src.FirstPageSource;
            OtherPagesSource = src.OtherPagesSource;
            Duplex           = src.Duplex;
            Columns.Assign(src.Columns);
            Guides.Assign(src.Guides);
            Border = src.Border.Clone();
            Fill   = src.Fill.Clone();
            Watermark.Assign(src.Watermark);
            TitleBeforeHeader   = src.TitleBeforeHeader;
            OutlineExpression   = src.OutlineExpression;
            PrintOnPreviousPage = src.PrintOnPreviousPage;
            ResetPageNumber     = src.ResetPageNumber;
            ExtraDesignWidth    = src.ExtraDesignWidth;
            StartOnOddPage      = src.StartOnOddPage;
            StartPageEvent      = src.StartPageEvent;
            FinishPageEvent     = src.FinishPageEvent;
            ManualBuildEvent    = src.ManualBuildEvent;
        }
Exemplo n.º 7
0
 protected void btnDelete_Command(object sender, CommandEventArgs e)
 {
     try
     {
         string id = Convert.ToString(e.CommandArgument);
         if (!string.IsNullOrEmpty(id))
         {
             GuideBLL guideBLL = new GuideBLL();
             Guides   guide    = new Guides();
             guide.GuideId = Convert.ToInt32(QuaintSecurityManager.Decrypt(id));
             if (guide.GuideId > 0)
             {
                 if (guideBLL.Delete(guide))
                 {
                     Alert(AlertType.Success, "Deleted successfully.");
                     LoadList();
                 }
                 else
                 {
                     Alert(AlertType.Error, "Failed to delete.");
                 }
             }
         }
     }
     catch (Exception)
     {
         Alert(AlertType.Error, "Failed to delete.");
     }
 }
Exemplo n.º 8
0
        protected override void ParseData(SqliteDataReader reader)
        {
            if (reader == null || !reader.HasRows)
            {
                return;
            }

            while (reader.Read())
            {
                var guide = new GuideData();

                guide.Id              = DBTextResource.ParseUI(GetReaderString(reader, "guide_id"));
                guide.Priority        = DBTextResource.ParseUS(GetReaderString(reader, "priority"));
                guide.PreSys          = DBTextResource.ParseUI(GetReaderString(reader, "sys"));
                guide.MinLevel        = DBTextResource.ParseUI(GetReaderString(reader, "min_level"));
                guide.MaxLevel        = DBTextResource.ParseUI(GetReaderString(reader, "max_level"));
                guide.InstanceType    = DBTextResource.ParseI_s(GetReaderString(reader, "inst_type"), -1);
                guide.InstanceSubType = DBTextResource.ParseI_s(GetReaderString(reader, "inst_sub_type"), -1);
                guide.TriggerType     = (GuideData.GuideTrigger)Enum.Parse(typeof(GuideData.GuideTrigger), GetReaderString(reader, "trigger_type"));
                guide.TriggerParams   = new List <uint>();
                string[] param = TextHelper.GetListFromString(GetReaderString(reader, "trigger_params"));
                if (param != null)
                {
                    foreach (string s in param)
                    {
                        guide.TriggerParams.Add(DBTextResource.ParseUI_s(s, 0));
                    }
                }

                string rawStr = GetReaderString(reader, "auto_fight_when_finish");
                if (string.IsNullOrEmpty(rawStr) == true || rawStr.Equals("0") == true)
                {
                    guide.AutoFightWhenFinish = false;
                }
                else
                {
                    guide.AutoFightWhenFinish = true;
                }

                guide.TimelineWhenFinish = DBTextResource.ParseUI_s(GetReaderString(reader, "timeline_when_finish"), 0);

                rawStr = GetReaderString(reader, "guide_main_task_when_finish_and_return_main_wnd");
                if (string.IsNullOrEmpty(rawStr) == true || rawStr.Equals("0") == true)
                {
                    guide.GuideMainTaskWhenFinishAndReturnMainWnd = false;
                }
                else
                {
                    guide.GuideMainTaskWhenFinishAndReturnMainWnd = true;
                }

                guide.IsFinished = false;

                Guides.Add(guide.Id, guide);
                GuideList.Add(guide);
            }

            GuideList.Sort();
        }
Exemplo n.º 9
0
 public GuideData GetGuideById(uint guideId)
 {
     if (!Guides.ContainsKey(guideId))
     {
         return(null);
     }
     return(Guides [guideId]);
 }
Exemplo n.º 10
0
    public IconCanvasGuide(IconCanvas canvas, Vector2 normalizedPos, IconCanvasGuideType type)
    {
        this.canvas = canvas;
        this.type   = type;

        SetLocalPosition(normalizedPos);

        Guides.Add(this);
    }
Exemplo n.º 11
0
        private void btSave_Click(object sender, EventArgs e)
        {
            Guides guides = new Guides();

            guides.HeroID      = (int)cbListHero.SelectedValue;
            guides.Name        = tbNameGuide.Text;
            guides.Description = tbDecription.Text;

            EditService.AddGuides(guides);
        }
Exemplo n.º 12
0
        private async Task SearchGuides()
        {
            if (!SearchSectionCurrentLoading[ServiceBroker.SearchFilters.Guide])
            {
                if (GuidesMore)
                {
                    try
                    {
                        LoadingCounter++;
                        SearchSectionCurrentLoading[ServiceBroker.SearchFilters.Guide] = true;
                        var Result = await Broker.SearchGuides(AppBase.Current.SearchTerm, SearchSectionCurrentPage[ServiceBroker.SearchFilters.Guide]);

                        this.GuidesItemLabel = string.Format("{0} ({1})", International.Translation.Guides, Result.totalResults);
                        this.GuidesMore      = Result.moreResults;
                        if (Result != null)
                        {
                            foreach (var item in Result.results)
                            {
                                var newItem = new SearchResultItem
                                {
                                    Name     = item.title.Trim().Replace("&quot;", "''"),
                                    Summary  = item.type.ToUpper(),
                                    ImageUrl = item.image != null ? item.image.standard : "",
                                    UniqueId = item.guideid.ToString()
                                };
                                if (!Guides.Contains(newItem))
                                {
                                    Guides.Add(newItem);
                                }
                            }

                            SearchSectionCurrentPage[ServiceBroker.SearchFilters.Guide]   += 1;
                            SearchSectionCurrentLoading[ServiceBroker.SearchFilters.Guide] = false;
                            SearchSectionResult[ServiceBroker.SearchFilters.Guide]         = (RESTModels.Search.Guide.Common)Result;

                            if (Result.totalResults == 0)
                            {
                                GuidesDescription = International.Translation.NoGuidesFound;
                            }
                            else
                            {
                                GuidesDescription = string.Empty;
                            }
                        }

                        LoadingCounter--;
                    }
                    catch (Exception ex)
                    {
                        LoadingCounter--;
                        //  _uxService.ShowAlert(International.Translation.ErrorSearchDevices).RunSynchronously();
                    }
                }
            }
        }
Exemplo n.º 13
0
        public async Task <IActionResult> PostGuides([FromBody] Guides guides)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            _context.Guides.Add(guides);
            await _context.SaveChangesAsync();

            return(CreatedAtAction("GetGuides", new { id = guides.GuideId }, guides));
        }
 public bool Delete(Guides guide)
 {
     try
     {
         GuideDAL guideDAL = new GuideDAL();
         return(guideDAL.Delete(guide));
     }
     catch (Exception)
     {
         throw;
     }
 }
Exemplo n.º 15
0
        /// <summary>
        /// 指定的新手引导是否已经完成
        /// </summary>
        /// <param name="guide_id"></param>
        /// <returns></returns>
        public bool IsGuideFinish(uint guide_id)
        {
            GuideData guide = null;

            if (Guides.TryGetValue(guide_id, out guide))
            {
                return(guide.IsFinished);
            }
            else
            {
                return(false);
            }
        }
Exemplo n.º 16
0
        public async Task <IActionResult> Create([Bind("GuideTitle,GuideContent,DateSubmitted,LastUpdated,UserProfilesId,GameId")] Guides guides)
        {
            if (ModelState.IsValid)
            {
                _context.Add(guides);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Guide)));
            }
            ViewData["GameId"] = new SelectList(_context.Games, "Id", "GameTitle", guides.GameId);
            //ViewData["UserProfilesId"] = new SelectList(_context.UserProfiles, "Id", "DisplayName", guides.UserProfilesId);
            return(View(guides));
        }
Exemplo n.º 17
0
        /// <inheritdoc/>
        public override void Assign(Base source)
        {
            base.Assign(source);

            BandBase src = source as BandBase;

            Guides.Assign(src.Guides);
            StartNewPage          = src.StartNewPage;
            FirstRowStartsNewPage = src.FirstRowStartsNewPage;
            PrintOnBottom         = src.PrintOnBottom;
            KeepChild             = src.KeepChild;
            OutlineExpression     = src.OutlineExpression;
            BeforeLayoutEvent     = src.BeforeLayoutEvent;
            AfterLayoutEvent      = src.AfterLayoutEvent;
        }
Exemplo n.º 18
0
 private void ClearCurrent()
 {
     Items.Clear();
     Guides.Clear();
     BreadCrumb.Clear();
     this.BackgroundImageUrl = string.Empty;
     this.CategoryName       = string.Empty;
     this.Description        = string.Empty;
     this.LongDescription    = string.Empty;
     this.ImageUrl           = string.Empty;
     this.CategoryBreadcrumb = string.Empty;
     this.DisplayTitle       = string.Empty;
     this.ImageUrl           = string.Empty;
     HasGuides = true;
 }
        /*   protected void Button3_Click(object sender, EventArgs e)
         * {
         *     MySqlConnection con = new MySqlConnection(@"server = localhost; user id = root; pwd=shri@1234;persistsecurityinfo = True; database = auto");
         *     con.Open();
         *     string str="select G_id  from S_group where Allo_guide=0";
         *     MySqlCommand cmd = new MySqlCommand(str, con);
         *     MySqlDataReader sdr = cmd.ExecuteReader();
         *
         *     sdr.Read();
         *     int grpid=new List<int> sdr.Read();
         *     foreach (int element in sdr.Read())
         *
         *
         *
         * }
         */

        protected void Button4_Click(object sender, EventArgs e)
        {
            MySqlConnection con = new MySqlConnection(@"server = localhost; user id = root; pwd=shri@1234;persistsecurityinfo = True; database = auto");
            MySqlCommand    cmd;

            try {
                con.Open();
                cmd = new MySqlCommand("insert into GuideGroup(Guide_Emp_id,G_id) values('" + TextBox2.Text + "','" + TextBox1.Text + "')", con);
                cmd.ExecuteNonQuery();
                cmd = new MySqlCommand("Update s_group set allo_Guide='" + TextBox2.Text + "' where G_id='" + TextBox1.Text + "'", con);
                cmd.ExecuteNonQuery();
                MySqlCommand cmd2 = new MySqlCommand("Update Guide set no_groups=no_groups+1  where Guide_Emp_id='" + TextBox2.Text + "'", con);
                cmd2.ExecuteNonQuery();
            }
            catch (Exception)
            {
                Response.Write("Guide or Group is already assigned ");
            }

            string str = ("select * from Guide");

            cmd = new MySqlCommand(str, con);

            MySqlDataAdapter sda  = new MySqlDataAdapter(str, con);
            DataTable        dtb1 = new DataTable();

            sda.Fill(dtb1);
            Guides.DataSource = dtb1;
            Guides.DataBind();


            str = ("select * from s_group");
            cmd = new MySqlCommand(str, con);

            sda  = new MySqlDataAdapter(str, con);
            dtb1 = new DataTable();
            sda.Fill(dtb1);
            Groups.DataSource = dtb1;
            Groups.DataBind();

            {
            }


            con.Close();
        }
        protected void Button2_Click(object sender, EventArgs e)
        {
            MySqlConnection con = new MySqlConnection(@"server = localhost; user id = root; pwd=shri@1234;persistsecurityinfo = True; database = auto");

            using (con)
            {
                con.Open();

                string       str = ("select * from Guide");
                MySqlCommand cmd = new MySqlCommand(str, con);

                MySqlDataAdapter sda  = new MySqlDataAdapter(str, con);
                DataTable        dtb1 = new DataTable();
                sda.Fill(dtb1);
                Guides.DataSource = dtb1;
                Guides.DataBind();
            }
        }
        public bool Save(Guides guide)
        {
            try
            {
                GuideDAL guideDAL = new GuideDAL();

                if (IsNameExist(guide))
                {
                    throw new Exception("Name already exist.");
                }
                else
                {
                    return(guideDAL.Save(guide));
                }
            }
            catch (Exception)
            {
                throw;
            }
        }
Exemplo n.º 22
0
        public bool Update(Guides guide)
        {
            QuaintDatabaseManager db = new QuaintDatabaseManager(true);

            try
            {
                bool flag = false;
                db.AddParameters("GuideId", guide.GuideId);
                db.AddParameters("GuideCode", guide.GuideCode);
                db.AddParameters("Name", guide.Name);
                db.AddParameters("ContactNumber", guide.ContactNumber);
                db.AddParameters("Email", guide.Email);
                db.AddParameters("AddressLine1", guide.AddressLine1);
                db.AddParameters("AddressLine2", guide.AddressLine2);
                db.AddParameters("IsActive", guide.IsActive);
                db.AddParameters("CreatedDate", ((guide.CreatedDate == null) ? guide.CreatedDate : guide.CreatedDate.Value));
                db.AddParameters("CreatedBy", guide.CreatedBy);
                db.AddParameters("CreatedFrom", guide.CreatedFrom);
                db.AddParameters("UpdatedDate", ((guide.UpdatedDate == null) ? guide.UpdatedDate : guide.UpdatedDate.Value));
                db.AddParameters("UpdatedBy", guide.UpdatedBy);
                db.AddParameters("UpdatedFrom", guide.UpdatedFrom);
                db.AddParameters("LocationId", guide.LocationId);
                int affectedRows = db.ExecuteNonQuery("Update_Guide", true);

                if (affectedRows > 0)
                {
                    flag = true;
                }

                return(flag);
            }
            catch (Exception)
            {
                throw;
            }
            finally
            {
                db.Disconnect();
            }
        }
Exemplo n.º 23
0
        private void PointGuides(IToolContext context, double x, double y)
        {
            var horizontal = new LineShape()
            {
                StartPoint = new PointShape(0, y, null),
                Point      = new PointShape(context.CurrentContainer.Width, y, null),
                Style      = Settings.GuideStyle
            };

            var vertical = new LineShape()
            {
                StartPoint = new PointShape(x, 0, null),
                Point      = new PointShape(x, context.CurrentContainer.Height, null),
                Style      = Settings.GuideStyle
            };

            Guides.Add(horizontal);
            Guides.Add(vertical);

            context.WorkingContainer.Shapes.Add(horizontal);
            context.WorkingContainer.Shapes.Add(vertical);
        }
Exemplo n.º 24
0
        public List <Guides> GetGuides()
        {
            string Connect;

            Connect = "Database=" + "guides_league_of_legends" + ";Server=" + "localhost" + ";User="******"root" + ";Password="******"; CharSet=utf8";

            List <Guides> list = new List <Guides>();

            using (MySqlConnection mysql_db = new MySqlConnection(Connect))
            {
                mysql_db.Open();

                MySqlDataReader QueryResult;

                MySqlCommand MySqlQuery = mysql_db.CreateCommand();

                MySqlQuery.CommandText = "SELECT * FROM `guides`";

                QueryResult = MySqlQuery.ExecuteReader();

                while (QueryResult.Read())
                {
                    Guides guides = new Guides();

                    guides.ID          = (int)QueryResult["ID"];
                    guides.HeroID      = (int)QueryResult["HERO_ID"];
                    guides.Name        = QueryResult["NAME"].ToString();
                    guides.Description = QueryResult["DESCRIPTION"].ToString();

                    list.Add(guides);
                }

                //Закрываем соеденинение
                QueryResult.Close();
                mysql_db.Close();
            }
            return(list);
        }
Exemplo n.º 25
0
        /// <inheritdoc/>
        public override void Assign(Base source)
        {
            base.Assign(source);

            ReportPage src = source as ReportPage;

            ExportAlias   = src.ExportAlias;
            Landscape     = src.Landscape;
            PaperWidth    = src.PaperWidth;
            PaperHeight   = src.PaperHeight;
            RawPaperSize  = src.RawPaperSize;
            LeftMargin    = src.LeftMargin;
            TopMargin     = src.TopMargin;
            RightMargin   = src.RightMargin;
            BottomMargin  = src.BottomMargin;
            MirrorMargins = src.MirrorMargins;
            AssignPreview(src);
            Columns.Assign(src.Columns);
            Guides.Assign(src.Guides);
            Border = src.Border.Clone();
            Fill   = src.Fill.Clone();
            Watermark.Assign(src.Watermark);
            TitleBeforeHeader    = src.TitleBeforeHeader;
            OutlineExpression    = src.OutlineExpression;
            PrintOnPreviousPage  = src.PrintOnPreviousPage;
            ResetPageNumber      = src.ResetPageNumber;
            ExtraDesignWidth     = src.ExtraDesignWidth;
            BackPage             = src.BackPage;
            StartOnOddPage       = src.StartOnOddPage;
            StartPageEvent       = src.StartPageEvent;
            FinishPageEvent      = src.FinishPageEvent;
            ManualBuildEvent     = src.ManualBuildEvent;
            UnlimitedHeight      = src.UnlimitedHeight;
            PrintOnRollPaper     = src.PrintOnRollPaper;
            UnlimitedWidth       = src.UnlimitedWidth;
            UnlimitedHeightValue = src.UnlimitedHeightValue;
            UnlimitedWidthValue  = src.UnlimitedWidthValue;
        }
Exemplo n.º 26
0
        public void AddGuides(Guides guides)
        {
            string Connect;

            Connect = "Database=" + "guides_league_of_legends" + ";Server=" + "localhost" + ";User="******"root" + ";Password="******"; CharSet=utf8";

            using (MySqlConnection mysql_db = new MySqlConnection(Connect))
            {
                mysql_db.Open();

                MySqlDataReader QueryResult;

                MySqlCommand MySqlQuery = mysql_db.CreateCommand();

                MySqlQuery.CommandText = "INSERT INTO `guides` (HERO_ID,NAME,DESCRIPTION) VALUES ('" + guides.HeroID + "','" + guides.Name + "','" + guides.Description + "') ";

                QueryResult = MySqlQuery.ExecuteReader();

                //Закрываем соеденинение
                QueryResult.Close();
                mysql_db.Close();
            }
        }
Exemplo n.º 27
0
        public static NetTool.ControlPoint SnapDirectionGuideLines(NetTool.ControlPoint newPoint,
                                                                   NetTool.ControlPoint oldPoint,
                                                                   NetInfo info, ref bool success, ref float minDistanceSq)
        {
            var controlPoint = newPoint;

            lock (GuideLineLock)
            {
                SnappedGuideLine = null;
                GuideLines.Clear();

                Guides.CalculateGuideLines(info, oldPoint, controlPoint, GuideLines);

                if (GuideLines.Count == 0)
                {
                    if (Debug.Enabled)
                    {
                        DebugPrint += " (No GuideLines Found)";
                    }

                    return(newPoint);
                }

                var minDist     = float.MaxValue;
                var closestLine = GuideLines[0];

                if (GuideLines.Count > 1)
                {
                    for (var i = 0; i < GuideLines.Count; i++)
                    {
                        var gl   = GuideLines[i];
                        var dist = Vector3Extensions.DistanceSquared(gl.Origin, newPoint.m_position) +
                                   gl.Distance * gl.Distance;

                        if (dist < minDist)
                        {
                            closestLine = gl;
                            minDist     = dist;
                        }
                    }
                }

                if (closestLine.Distance <= Settings.GuideLinesSnapDistance + closestLine.Width)
                {
                    minDistanceSq = closestLine.Distance * closestLine.Distance;

                    if (Debug.Enabled)
                    {
                        DebugPrint += " Guide: " + closestLine.Intersect;
                    }

                    controlPoint.m_position   = closestLine.Intersect;
                    controlPoint.m_position.y = newPoint.m_position.y;
                    controlPoint.m_direction  = oldPoint.m_position.DirectionTo(newPoint.m_position);
                    success = true;

                    SnappedGuideLine = closestLine;
                }

                return(controlPoint);
            }
        }
Exemplo n.º 28
0
        private string GetMenu(User user = null, bool drawActions = true)
        {
            bool showTooltips = user?.Config?.Tooltips ?? true;

            StringBuilder panel = new StringBuilder();

            panel.AppendLine("> **Help Menu**");

            if (showTooltips)
            {
                panel.AppendLine("> 🛠️ Use `help <name>` to learn more about a command or category.");
            }

            // TODO: Handle report status icon management
            if (Guides?.Any() ?? false)
            {
                panel.AppendLine();
                panel.AppendLine("**Guides**");

                foreach (GuideNode guide in Guides)
                {
                    panel.AppendLine($"> {guide.Tooltip}");
                }
            }

            if (Modules.Any())
            {
                panel.AppendLine();
                panel.AppendLine("**Categories**");

                foreach (ModuleNode module in GetBaseModules().Select(x => new ModuleNode(x)))
                {
                    panel.Append("> ");

                    if (Check.NotNull(module.Icon))
                    {
                        panel.Append($"{module.Icon} ");
                    }

                    panel.Append($"**{module.Name}**");

                    if (Check.NotNull(module.Subtitle) || module.Commands.Count > 0)
                    {
                        panel.Append(": ");
                    }

                    if (Check.NotNull(module.Subtitle))
                    {
                        panel.AppendLine(module.Subtitle);
                    }

                    if (module.Commands.Count > 0)
                    {
                        if (Check.NotNull(module.Subtitle))
                        {
                            panel.Append("> ");
                        }

                        int inserted = 0;
                        foreach (CommandNode command in module.Commands.OrderBy(x => x.Name))
                        {
                            if (inserted >= MAX_COMMAND_DISPLAY)
                            {
                                break;
                            }

                            if (inserted > 0)
                            {
                                panel.Append(" ");
                            }

                            panel.Append($"`{command.Name}`");

                            inserted++;
                        }

                        if (module.Commands.Count() - inserted > 0)
                        {
                            panel.Append($" (+**{module.Commands.Count() - inserted}** more)");
                        }

                        panel.AppendLine();
                    }
                    else
                    {
                        panel.Append("...");
                        panel.AppendLine();
                    }
                }
            }

            //if (user != null && drawActions)
            //   if (user.Husk != null)
            //       panel.Append(GetActions(user));

            return(panel.ToString());
        }
Exemplo n.º 29
0
        public string GetPanel(string content = null, User user = null, bool drawActions = true, string prefix = "[")
        {
            if (!Check.NotNull(content))
            {
                return(GetMenu(user, drawActions));
            }

            if (Check.NotNullOrEmpty(Guides))
            {
                // TODO: Clean up chapter parsing (Regex).
                bool isGuideName = Guides.Any(x => content.ToLower().StartsWith(x.Id));
                bool hasIndex    = isGuideName && content.Split(' ').Count() == 2;

                if (isGuideName)
                {
                    if (hasIndex)
                    {
                        if (int.TryParse(content.Split(' ')[1], out int index))
                        {
                            return(Guides.First(x => content.ToLower().StartsWith(x.Id)).GetChapter(index));
                        }
                    }
                    else if (Guides.Any(x => x.Id == content.ToLower()))
                    {
                        return(Guides.First(x => x.Id == content.ToLower()).GetChapter(1));
                    }
                }
            }

            ContextNode ctx = Search(content, out string error);

            if (!string.IsNullOrWhiteSpace(error))
            {
                return(error);
            }

            bool allowTooltips = user?.Config?.Tooltips ?? true;
            var  panel         = new StringBuilder();

            if (allowTooltips)
            {
                /*
                 * string tooltip = ctx switch
                 * {
                 *  CommandNode c => $"> Use `help {ctx.Name}+<index>` to learn more about a specific command method.",
                 *  ModuleNode m when ctx.Type == InfoType.Group => $"> Use `help {ctx.Name} <command>` to learn more about a specific command method within a group.",
                 *  _ => ""
                 * };*/

                if (ctx.Type == InfoType.Command)
                {
                    if ((ctx as CommandNode).Overloads.Count > 1)
                    {
                        panel.AppendLine($"> 🛠️ Use `help {ctx.Name}+<index>` to learn more about a specific command overload.\n");
                    }
                }
                else if (ctx.Type == InfoType.Group)
                {
                    panel.AppendLine($"> 🛠️ Use `help {ctx.Name} <command>` to learn more about a specific command method within a group.\n");
                }
                else if (ctx.Type == InfoType.Module)
                {
                    panel.AppendLine("> 🛠️ Use `help <command>` to learn more about a specific command.\n");
                }
            }

            if (ctx is OverloadNode overload)
            {
                if (allowTooltips && overload.Parameters.Count > 0)
                {
                    panel.AppendLine($"> 🛠️ Use `help {ctx.Name}{(overload.Count > 1 ? $"+{overload.Index}" : "")}(<parameter>` to learn more about a specific parameter.\n");
                }

                SetExample(overload, prefix);
                ctx = overload;
            }

            panel.Append(ctx.ToString());
            return(panel.ToString());
        }
Exemplo n.º 30
0
 public override void Unload()
 {
     base.Unload();
     Guides.Clear();
     GuideList.Clear();
 }