Esempio n. 1
0
        public void CloseFile(DataView dv)
        {
            if (!dv.Buffer.FileOperationsAllowed)
            {
                return;
            }

            // if user decides not to close after all
            if (AskForSaveIfFileChanged(dv) == false)
            {
                return;
            }

            dataBook.RemoveView(dv);

            // promptly free resources memory (eg pixmaps)
            dv.Buffer.CloseFile();
            dv.Cleanup();

            // Make sure the new current DataView has the focus
            DataViewDisplay dvd = (DataViewDisplay)dataBook.CurrentPageWidget;

            if (dvd != null)
            {
                dvd.GrabKeyboardFocus();
            }
            else
            {
                // there is no dataview left,
                // update title and statusbars
                mainWindow.Title = "Bless - Gtk# Hex Editor";
                Services.UI.Info.ClearMessage();
            }
        }
Esempio n. 2
0
        ///<summary>Handle mouse button presses</summary>
        internal void OnButtonPress(object o, ButtonPressEventArgs args)
        {
            dvDisplay.GrabKeyboardFocus();

            Gdk.EventButton e         = args.Event;
            Area            clickArea = GetAreaByXY((int)e.X, (int)e.Y);

            if (clickArea == null)
            {
                return;
            }

            // get the position in the file
            Position pos = new Position();

            CalculatePosition(clickArea, (int)(e.X - clickArea.X), (int)(e.Y - clickArea.Y), ref pos);

            // right mouse button
            if (e.Button == 3)
            {
                // show the popup
                clickArea.ShowPopup(Services.UI.Manager);
                // if there is no selection change the cursor position
                if (dataView.Selection.IsEmpty())
                {
                    selStartPos = pos;
                    selEndPos   = pos;
                }
            }
            else
            {
                // update selection and cursor if they have changed externally
                UpdateSelection(pos.First != pos.Second);

                // if shift is pressed the position is the end position of the selection
                if ((e.State & Gdk.ModifierType.ShiftMask) != 0)
                {
                    selEndPos = pos;
                }
                else           // ... start a new selection
                {
                    selStartPos = pos;
                    selEndPos   = pos;
                }
            }

            // give the focus to the appropriate area
            // do this before setting the new cursor/selection
            UpdateFocus(clickArea);

            EvaluateSelection(DataViewDisplay.ShowType.Closest);
        }