Ejemplo n.º 1
0
        public void AppendChange(BatchChange change)
        {
            Log.updateLog(Log.LogType.CLICK, "Attempting to append change");
            int numChanges = changes.Length;

            BatchChange[] newChanges = new BatchChange[numChanges + 1];
            for (int i = 0; i < numChanges; i++)
            {
                newChanges[i] = changes[i];
            }

            newChanges[numChanges] = change;
            changes = newChanges;
            Log.updateLog(Log.LogType.CLICK, "Appended the change to changes");
            // If we do not have the max number of lines, add one
            if (lines.Length < maxLines)
            {
                AddChangeLine(change);
            }
            // if we do have the max number of lines, we should scroll down one
            else
            {
                scrollUpButton.Show();
                scrollDownButton.Show();
                Log.updateLog(Log.LogType.CLICK, "Attempting to scroll down instead of adding a new change line");
                ScrollToBottom();
            }
        }
Ejemplo n.º 2
0
        public void AddChange(string source, BatchChange.Operator operation, bool value)
        {
            BatchChange change = new BatchChange();

            change.source    = source;
            change.operation = operation;
            change.SetValue(value);
            AppendChange(change);
        }
Ejemplo n.º 3
0
        public void RemoveBatchChange(string lineText)
        {
            Log.updateLog(Log.LogType.CLICK, "Preparing to remove change");
            int numChanges = changes.Length;

            Log.updateLog(Log.LogType.LOOPS, "Current number of changes: " + numChanges);
            if (changes.Length == 0)
            {
                return;
            }

            BatchChange[] newChanges = new BatchChange[numChanges - 1];
            int           newIndex   = 0;
            bool          removed    = false;

            Log.updateLog(Log.LogType.LOOPS, "Looping through changes");
            for (int changesIndex = 0; changesIndex < numChanges; changesIndex++)
            {
                Log.updateLog(Log.LogType.LOOPS, "newIndex: " + newIndex + " | changesIndex: " + changesIndex);
                if (!removed)
                {
                    Log.updateLog(Log.LogType.LOOPS, "Have not found a match");
                    if (changes[changesIndex].GetLabelText(maxLabelLength).Equals(lineText))
                    {
                        Log.updateLog(Log.LogType.LOOPS, "Match Found!");
                        removed = true;
                    }
                    else
                    {
                        newChanges[newIndex] = changes[changesIndex];
                        newIndex++;
                    }
                }
                else
                {
                    newChanges[newIndex] = changes[changesIndex];
                    newIndex++;
                }
            }
            changes = newChanges;
        }
Ejemplo n.º 4
0
        public bool Equals(BatchChange other)
        {
            // if we don't have the same source, we are not equal
            if (!other.source.Equals(source))
            {
                return(false);
            }
            // if not the same operation
            if (other.operation != operation)
            {
                return(false);
            }
            // if not the same type
            if (other.type != type)
            {
                return(false);
            }
            // if a string value and not the same string value
            if (type == Type.STRING &&
                textValue.ToUpper().Equals(other.textValue.ToUpper()))
            {
                return(false);
            }
            // if a float value and not the same float value
            if (type == Type.FLOAT &&
                floatValue != other.floatValue)
            {
                return(false);
            }
            // if a bool value and not the same bool value
            if (type == Type.BOOL &&
                boolValue != other.boolValue)
            {
                return(false);
            }

            // if all is the same, return true
            return(true);
        }
Ejemplo n.º 5
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;
        }