Пример #1
0
        void OnDoOperationClicked(object o, EventArgs args)
        {
            if (dataBook.NPages == 0)
            {
                return;
            }

            DataView dv = ((DataViewDisplay)dataBook.CurrentPageWidget).View;

            // get the operands as a byte array
            byte[] byteArray = null;

            try {
                byteArray = ParseOperand();
            }
            catch (FormatException e) {
                ErrorAlert ea = new ErrorAlert(Catalog.GetString("Error in Operand"), e.Message, null);
                ea.Run();
                ea.Destroy();
                return;
            }

            /// get the range to apply the operation to
            Util.Range range = dv.Selection;

            if (range.IsEmpty())
            {
                Util.Range bbRange = dv.Buffer.Range;

                range.Start = dv.CursorOffset;
                range.End   = range.Start + byteArray.Length - 1;
                range.Intersect(bbRange);
            }

            // don't allow buffer modification while the operation is perfoming
            dv.Buffer.ModifyAllowed         = false;
            dv.Buffer.FileOperationsAllowed = false;

            BitwiseOperation bo = new BitwiseOperation(dv.Buffer, byteArray, range,
                                                       (OperationType)OperationComboBox.Active,
                                                       Services.UI.Progress.NewCallback(), BitwiseOperationAsyncCallback, true);

            // start operation thread
            Thread boThread = new Thread(bo.OperationThread);

            boThread.IsBackground = true;
            boThread.Start();
        }