Пример #1
0
        public void removeChartRow(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);
                ChartRow row   = new ChartRow();
                row.Label = "";
                void getRowLabel()
                {
                    row.Label = "";
                    for (int i = 1; i < additionalArgs.Length; i++)
                    {
                        row.Label += additionalArgs[i] + " ";
                    }

                    if (row.Label.EndsWith(" "))
                    {
                        row.Label = row.Label.TrimEnd(' ');
                    }
                }

                getRowLabel();
                if (v.RowData.Where(x => x.Label == row.Label).Count() > 0)
                {
                    row = v.RowData.Where(x => x.Label == row.Label).First();
                    v.RowData.Remove(row);
                    ChartMemory.Instance.Charts[index] = v;
                    ChartMemory.SaveToFile();
                }
                else
                {
                    MHE(source, client, "No such row in that chart");
                    return;
                }


                MHE(source, client, "Chart row deleted");
                return;
            }
        }
Пример #2
0
        public void addChartRow(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);
                ChartRow row   = new ChartRow();
                row.Label = "";
                row.Mask  = Convert.ToInt32(additionalArgs[1]);
                int  masterIndex;
                bool hasIndex = int.TryParse(additionalArgs[2], out masterIndex);
                void getRowLabel()
                {
                    row.Label = "";
                    if (hasIndex)
                    {
                        // the label is at 3 and above
                        for (int i = 3; i < additionalArgs.Length; i++)
                        {
                            row.Label += additionalArgs[i] + " ";
                        }

                        if (row.Label.EndsWith(" "))
                        {
                            row.Label = row.Label.TrimEnd(' ');
                        }
                    }
                    else
                    {
                        // the label is at 2 and above
                        for (int i = 2; i < additionalArgs.Length; i++)
                        {
                            row.Label += additionalArgs[i] + " ";
                        }

                        if (row.Label.EndsWith(" "))
                        {
                            row.Label = row.Label.TrimEnd(' ');
                        }
                    }
                }

                getRowLabel();
                if (v.RowData.Where(x => x.Label == row.Label).Count() > 0)
                {
                    MHE(source, client, "A chart row with that label already exists.");
                    return;
                }
                else
                {
                    // index optional
                    if (hasIndex)
                    {
                        v.RowData.Insert(masterIndex, row);
                        ChartMemory.Instance.Charts[index] = v;
                        ChartMemory.SaveToFile();
                    }
                    else
                    {
                        // row label might start at 2 instead, but we only add anyway
                        getRowLabel();

                        v.RowData.Add(row);
                        ChartMemory.Instance.Charts[index] = v;
                        ChartMemory.SaveToFile();
                    }
                }


                MHE(source, client, "Chart row added");
                return;
            }
        }