コード例 #1
0
ファイル: ChartCommands.cs プロジェクト: britneygx/BotCore5
        public void remChartCols(UUID client, int level, string[] additionalArgs,
                                 Destinations source,
                                 UUID agentKey, string agentName)
        {
            if (ChartMemory.HasChart(additionalArgs[0]))
            {
                Chart v     = ChartMemory.GetNamedChart(additionalArgs[0]);
                int   index = ChartMemory.Instance.Charts.IndexOf(v);
                if (v.ColumnData.Fields.Where(x => x.Label == additionalArgs[1]).Count() > 0)
                {
                    ChartColumnField theChartField = v.ColumnData.Fields.Where(x => x.Label == additionalArgs[1]).First();
                    v.ColumnData.Fields.Remove(theChartField);

                    ChartMemory.Instance.Charts[index] = v;
                    ChartMemory.SaveToFile();

                    MHE(source, client, "Column removed");
                }
                else
                {
                    MHE(source, client, "Column does not exist, nothing to remove");
                }
            }
            else
            {
                MHE(source, client, "No such chart");
            }
        }
コード例 #2
0
ファイル: ChartCommands.cs プロジェクト: britneygx/BotCore5
        public void setChartCols(UUID client, int level, string[] additionalArgs,
                                 Destinations source,
                                 UUID agentKey, string agentName)
        {
            if (ChartMemory.HasChart(additionalArgs[0]))
            {
                Chart       v     = ChartMemory.GetNamedChart(additionalArgs[0]);
                int         index = ChartMemory.Instance.Charts.IndexOf(v);
                ChartColumn col   = v.ColumnData;
                if (col == null)
                {
                    col = new ChartColumn();
                }
                if (col.Fields == null)
                {
                    col.Fields = new List <ChartColumnField>();
                }


                if (col.Fields.Where(x => x.Label == additionalArgs[1]).Count() > 0)
                {
                    // already has this column
                    MHE(source, client, "That column already exists");
                    return;
                }
                else
                {
                    ChartColumnField field = new ChartColumnField();
                    field.ColorCode = additionalArgs[2];
                    field.Label     = additionalArgs[1];


                    if (additionalArgs.Length == 4)
                    {
                        // insert at index
                        col.Fields.Insert(Convert.ToInt32(additionalArgs[3]), field);
                    }
                    else
                    {
                        col.Fields.Add(field);
                    }
                }

                v.ColumnData = col;
                ChartMemory.Instance.Charts[index] = v;
                ChartMemory.SaveToFile();

                MHE(source, client, "Column data has been updated");
            }
            else
            {
                MHE(source, client, "No such chart");
            }
        }