Exemplo n.º 1
0
        public void RemoveBatchEditLine(Object sender, EventArgs e)
        {
            Button        button = (Button)sender;
            BatchEditLine line   = new BatchEditLine();

            Log.updateLog(Log.LogType.CLICK, "User has clicked a remove button");
            // Find the BatchEditLine that owns this button
            foreach (BatchEditLine l in lines)
            {
                if (l.MyButton(button))
                {
                    Log.updateLog(Log.LogType.CLICK, "Found button owner");
                    line = l;
                }
            }

            // If there are more changes than the max number of lines displayed, then we should not yet remove a line
            if (changes.Length - 1 < maxLines)
            {
                Log.updateLog(Log.LogType.CLICK, "Removing the last line");
                int numLines = lines.Length;
                Log.updateLog(Log.LogType.CLICK, "Number of lines before removal: " + numLines);
                if (numLines == 0)
                {
                    return;
                }

                BatchEditLine[] newLines = new BatchEditLine[numLines - 1];

                // Doesn't matter which one was clicked, we'll just update the text so that the last box can be removed
                for (int i = 0; i < newLines.Length; i++)
                {
                    newLines[i] = lines[i];
                }

                Log.updateLog(Log.LogType.CLICK, "Removing Controls of last line");
                lines[numLines - 1].RemoveControls();
                lines = newLines;

                // having now that we are below the maxLines, if the scroll buttons are visible, we should hide them
                HideScrollButtons();
            }

            // Now remove the change that was represented by this line, even if we don't remove the line
            RemoveBatchChange(line.GetLabel());
            // having removed the change, we should update the lines
            UpdateLines();
        }
Exemplo n.º 2
0
        public void AddChangeLine(BatchChange change)
        {
            Log.updateLog(Log.LogType.CLICK, "Attempting to add a new change line");
            int numLines = lines.Length;

            // The first line is special
            // We just create it and return because we don't need to copy an array nor do we need to verify maxLines
            if (numLines == 0)
            {
                Log.updateLog(Log.LogType.CLICK, "This is the first change line to be created");
                lines    = new BatchEditLine[1];
                lines[0] = new BatchEditLine(x, y, RemoveBatchEditLine, mainWindow);
                lines[0].SetLabel(change.GetLabelText(maxLabelLength));
                lines[0].Show();
                labelHeight = lines[0].GetLabelHeight();
                return;
            }

            Log.updateLog(Log.LogType.CLICK, "Current total of lines: " + numLines);
            BatchEditLine[] newLines = new BatchEditLine[numLines + 1];
            for (int i = 0; i < numLines; i++)
            {
                newLines[i] = lines[i];
            }
            Log.updateLog(Log.LogType.CLICK, "Creating new line");
            // Create a new line using the provided change
            BatchEditLine lastLine = newLines[numLines - 1];
            BatchEditLine newLine  = new BatchEditLine(
                lastLine.x,
                lastLine.y + labelHeight + verticalSpacing,
                RemoveBatchEditLine, mainWindow);

            newLine.SetLabel(change.GetLabelText(maxLabelLength));
            newLine.Show();
            newLines[numLines] = newLine;
            lines = newLines;
        }