private void EnsureToolTipCreated() { if (null == inspectionToolTip) { inspectionToolTip = new InspectionToolTip(); } if (null == inspectionToolTipPopup) { inspectionToolTipPopup = new ExtensionPopup(this); inspectionToolTipPopup.Child = inspectionToolTip; inspectionToolTipPopup.IsOpen = false; } }
private void EnsureAutoCompleteListCreated() { if (null == autoCompleteList) { autoCompleteList = new AutoCompleteList(); autoCompleteList.SetTextEditorControl(textEditorControl); } if (null == autoCompletePopup) { autoCompletePopup = new ExtensionPopup(this); autoCompletePopup.Child = autoCompleteList; autoCompletePopup.IsOpen = false; } }
private void EnsureToolTipCreated() { if (null == functionSignatureControl) { functionSignatureControl = new FunctionSignatureControl(); functionSignatureControl.Visibility = Visibility.Visible; } if (functionSignaturePopup == null) { functionSignaturePopup = new ExtensionPopup(this); functionSignaturePopup.Child = functionSignatureControl; functionSignaturePopup.IsOpen = false; } }
/// <summary> /// Shows the numeric slider for the first time when there has been a mouse click on a number. /// </summary> /// <param name="cursor">The cursor position at which the mouse click occurred.</param> private void ShowNumericSlider() { System.Drawing.Point cursor = textCore.CursorPosition; // Get the fragment on which the cursor has been placed. textCore.GetFragment(cursor.X, cursor.Y, out fragmentNumber); if (null == fragmentNumber || (fragmentNumber.CodeType != CodeFragment.Type.Number)) { // Fragment is not numeric, hide the slider. if (null != numericSliderPopup) { numericSliderPopup.IsOpen = false; } return; } if (numericSliderPopup == null) { numericSlider = new NumericSlider(); numericSlider.UpdateSliderValue += new SliderValueUpdated(OnSliderValueUpdated); // Set the alignment of the slider. numericSlider.HorizontalAlignment = System.Windows.HorizontalAlignment.Left; numericSlider.VerticalAlignment = System.Windows.VerticalAlignment.Top; numericSlider.Width = 172; numericSlider.Height = 40; numericSliderPopup = new ExtensionPopup(this); numericSliderPopup.Child = numericSlider; numericSliderPopup.IsOpen = false; } // Set the SliderMode to double if the fragment contains a decimal point in it. numericSlider.numSliderMode = NumericSlider.SliderMode.Integer; if (fragmentNumber.Text.Contains('.')) { numericSlider.numSliderMode = NumericSlider.SliderMode.Double; } // Check if the current fragment is '-' sign(fragment type is also Number) // and get the next fragment to set the SliderMode. if (fragmentNumber.Text == "-") { // @TODO(Suba): Use a GetNextFragment that takes "CodeFragment". CodeFragment nextFragment; //textCore.GetNextFragment(fragmentNumber, out nextFragment); textCore.GetFragment(cursor.X + 1, cursor.Y, out nextFragment); if (nextFragment == null) { return; } numericSlider.numSliderMode = NumericSlider.SliderMode.Integer; if (nextFragment.Text.Contains('.')) { numericSlider.numSliderMode = NumericSlider.SliderMode.Double; } // Set the currentFragment to be the fragment containing the "number" instead of "-" fragmentNumber = nextFragment; } numericSliderPopup.Placement = PlacementMode.Custom; numericSliderPopup.PlacementTarget = textEditorCanvas; numericSliderPopup.CursorPosition = cursor; numericSliderPopup.IsOpen = true; System.Windows.Input.Keyboard.Focus(numericSlider); numericSlider.SetCurrentPointOnScreen(cursor); // Get the previous fragment to determine if it is a '-' sign to set the Slider value. // @TODO(Suba): Make this to take CodeFragment instead. textCore.GetPreviousFragment(fragmentNumber.ColStart, fragmentNumber.Line, out fragmentSign); // If the mode is integer then you set the slider value by calling the ResetSlider which takes an 'int' // and if it is a Double value then you call the ResetSlider which takes in a 'double' if (numericSlider.numSliderMode == NumericSlider.SliderMode.Integer) { if (fragmentSign.Text.Equals("-")) { numericSlider.ResetSlider(textEditorControl, (-1) * Convert.ToInt32(fragmentNumber.Text)); } else { fragmentSign = null; numericSlider.ResetSlider(textEditorControl, Convert.ToInt32(fragmentNumber.Text)); } } else { if (fragmentSign.Text.Equals("-")) { numericSlider.ResetSlider(textEditorControl, (-1.0) * Convert.ToDouble(fragmentNumber.Text)); } else { fragmentSign = null; numericSlider.ResetSlider(textEditorControl, Convert.ToDouble(fragmentNumber.Text)); } } }
private void EnsureToolTipCreated() { if (null == inspectionToolTip) inspectionToolTip = new InspectionToolTip(); if (null == inspectionToolTipPopup) { inspectionToolTipPopup = new ExtensionPopup(this); inspectionToolTipPopup.Child = inspectionToolTip; inspectionToolTipPopup.IsOpen = false; } }
/// <summary> /// Shows the numeric slider for the first time when there has been a mouse click on a number. /// </summary> /// <param name="cursor">The cursor position at which the mouse click occurred.</param> private void ShowNumericSlider() { System.Drawing.Point cursor = textCore.CursorPosition; // Get the fragment on which the cursor has been placed. textCore.GetFragment(cursor.X, cursor.Y, out fragmentNumber); if (null == fragmentNumber || (fragmentNumber.CodeType != CodeFragment.Type.Number)) { // Fragment is not numeric, hide the slider. if (null != numericSliderPopup) numericSliderPopup.IsOpen = false; return; } if (numericSliderPopup == null) { numericSlider = new NumericSlider(); numericSlider.UpdateSliderValue += new SliderValueUpdated(OnSliderValueUpdated); // Set the alignment of the slider. numericSlider.HorizontalAlignment = System.Windows.HorizontalAlignment.Left; numericSlider.VerticalAlignment = System.Windows.VerticalAlignment.Top; numericSlider.Width = 172; numericSlider.Height = 40; numericSliderPopup = new ExtensionPopup(this); numericSliderPopup.Child = numericSlider; numericSliderPopup.IsOpen = false; } // Set the SliderMode to double if the fragment contains a decimal point in it. numericSlider.numSliderMode = NumericSlider.SliderMode.Integer; if (fragmentNumber.Text.Contains('.')) numericSlider.numSliderMode = NumericSlider.SliderMode.Double; // Check if the current fragment is '-' sign(fragment type is also Number) // and get the next fragment to set the SliderMode. if (fragmentNumber.Text == "-") { // @TODO(Suba): Use a GetNextFragment that takes "CodeFragment". CodeFragment nextFragment; //textCore.GetNextFragment(fragmentNumber, out nextFragment); textCore.GetFragment(cursor.X + 1, cursor.Y, out nextFragment); if (nextFragment == null) return; numericSlider.numSliderMode = NumericSlider.SliderMode.Integer; if (nextFragment.Text.Contains('.')) numericSlider.numSliderMode = NumericSlider.SliderMode.Double; // Set the currentFragment to be the fragment containing the "number" instead of "-" fragmentNumber = nextFragment; } numericSliderPopup.Placement = PlacementMode.Custom; numericSliderPopup.PlacementTarget = textEditorCanvas; numericSliderPopup.CursorPosition = cursor; numericSliderPopup.IsOpen = true; System.Windows.Input.Keyboard.Focus(numericSlider); numericSlider.SetCurrentPointOnScreen(cursor); // Get the previous fragment to determine if it is a '-' sign to set the Slider value. // @TODO(Suba): Make this to take CodeFragment instead. textCore.GetPreviousFragment(fragmentNumber.ColStart, fragmentNumber.Line, out fragmentSign); // If the mode is integer then you set the slider value by calling the ResetSlider which takes an 'int' // and if it is a Double value then you call the ResetSlider which takes in a 'double' if (numericSlider.numSliderMode == NumericSlider.SliderMode.Integer) { if (fragmentSign.Text.Equals("-")) numericSlider.ResetSlider(textEditorControl, (-1) * Convert.ToInt32(fragmentNumber.Text)); else { fragmentSign = null; numericSlider.ResetSlider(textEditorControl, Convert.ToInt32(fragmentNumber.Text)); } } else { if (fragmentSign.Text.Equals("-")) numericSlider.ResetSlider(textEditorControl, (-1.0) * Convert.ToDouble(fragmentNumber.Text)); else { fragmentSign = null; numericSlider.ResetSlider(textEditorControl, Convert.ToDouble(fragmentNumber.Text)); } } }