public FormulateTreeController() { Persistence = EntityPersistence.Current.Manager; FolderHelper = new FolderHelper(Persistence, this); FormHelper = new FormHelper(this, FolderHelper); LayoutHelper = new LayoutHelper(this, FolderHelper); ValidationHelper = new ValidationHelper(this, FolderHelper); }
protected override void OnLoad(EventArgs e) { base.OnLoad(e); using (AutoGrow autoGrow = new AutoGrow(this, AnchorStyles.Right, false)) { autoGrow.AllowAnchoring = true; cellPropertiesControl.AdjustSize(); LayoutHelper.FixupOKCancel(buttonOK, buttonCancel); } }
protected override void OnLoad(EventArgs e) { base.OnLoad(e); if (!DesignMode) { LayoutHelper.NaturalizeHeightAndDistribute(8, Controls); linkLabelMoreAboutLiveClipboard.Top = pictureBoxLiveClipboardIcon.Top + 1; LayoutHelper.EqualizeButtonWidthsVert(AnchorStyles.Right, buttonChange.Width, int.MaxValue, buttonChange, buttonOptions); } }
void BuildLayout() { if (!LayoutHelper.IsChildElement(this, SelectedElement)) { Selector.Visibility = Visibility.Collapsed; return; } Selector.Visibility = Visibility.Visible; Rect rect = LayoutHelper.GetRelativeElementRect(SelectedElement, this); Selector.Margin = new Thickness(rect.Left, rect.Top, ActualWidth - rect.Left - rect.Width, ActualHeight - rect.Top - rect.Height); }
public override void Notify(ConnectionEventArgs e) { base.Notify(e); LayoutHelper.InvokeFromUiThread(async() => { NotifyOfPropertyChanged(() => IsConnected); if (IsConnected) { await FirstLoad(); } }); }
/// <summary> /// Page Layout /// </summary> void PageLayout() { try { StackLayout slLayout = new StackLayout { VerticalOptions = LayoutOptions.FillAndExpand, HorizontalOptions = LayoutOptions.FillAndExpand, BackgroundColor = LayoutHelper.PageBackgroundColor }; slLayout.Padding = LayoutHelper.IOSPadding(0, 20, 0, 0); string url = String.Format("{0}{1}", Services.BaseUri, _selectedProvider.Url); var hwv = new ExtendedWebView { VerticalOptions = LayoutOptions.FillAndExpand, HorizontalOptions = LayoutOptions.FillAndExpand }; //var hwv = new HybridWebView { VerticalOptions = LayoutOptions.FillAndExpand, HorizontalOptions = LayoutOptions.FillAndExpand }; slLayout.Children.Add(hwv); hwv.Source = new Uri(url); //hwv.RegisterCallback("dataCallback", t => // Device.BeginInvokeOnMainThread(() => // { // /**********************************/ // //THIS WILL WORK FOR PAGE 1 ONLY // /*********************************/ // System.Diagnostics.Debug.WriteLine("!!!!!!!!!!!!!!!!! dataCallback: " + t); // }) //); //hwv.LoadFinished += (s, e) => //{ // /***********************************/ // //THIS WILL WORK FOR PAGE 1 ONLY // //WEAK REFERENCE LOST??? // /***********************************/ // ParseUrlForAccessToken(hwv.Uri.ToString()); // System.Diagnostics.Debug.WriteLine("(!!!!!!!!!!!!!!!!!!!! LoadFinished"); //}; ScrollView scrollContent = new ScrollView { Content = slLayout }; this.Content = scrollContent; } catch (Exception ex) { } }
static DependencyObject FindObject(DependencyObject root, string elementName, bool useVisualTree) { if (GetObjectName(root) == elementName) { return(root); } DependencyObject res = null; FrameworkElement fe = root as FrameworkElement; FrameworkElement feParent = fe.Parent as FrameworkElement; FrameworkElement el = feParent ?? fe; #if !SILVERLIGHT && !NETFX_CORE try { res = LogicalTreeHelper.FindLogicalNode(el, elementName); } catch { } if (res != null) { return(res); } FrameworkContentElement fce = root as FrameworkContentElement; res = fce != null ? (DependencyObject)fce.FindName(elementName) : null; if (res != null) { return(res); } #endif res = el != null ? (DependencyObject)el.FindName(elementName) : null; if (res != null) { return(res); } if (useVisualTree) { res = feParent != null?LayoutHelper.FindElementByName(feParent, elementName) : null; if (res != null) { return(res); } res = fe != null?LayoutHelper.FindElementByName(fe, elementName) : null; if (res != null) { return(res); } } return(null); }
void EnsurePivot() { if (PivotGridControl != null) { return; } DemoModuleControl.DemoContent = DemoModuleControl.FindDemoContent(typeof(PivotGridControl), (DependencyObject)Content); if (DemoModuleControl.DemoContent as FrameworkElement == null) { return; } PivotGridControl = LayoutHelper.FindElement(((FrameworkElement)DemoModuleControl.DemoContent), IsPivot) as PivotGridControl; }
protected override void OnLoad(EventArgs e) { base.OnLoad(e); int delta = proxyLabel.Right + 10 - buttonBack.Left; if (delta > 0) { proxyLabel.AutoSize = false; proxyLabel.Width = buttonBack.Left - 10 - proxyLabel.Left; LayoutHelper.NaturalizeHeight(proxyLabel); proxyLabel.Top = buttonCancel.Top - ((proxyLabel.Height - buttonCancel.Height) / 2); } }
protected override void OnLoad(EventArgs e) { base.OnLoad(e); using (new AutoGrow(this, AnchorStyles.Bottom, false)) { LayoutHelper.NaturalizeHeightAndDistribute(12, labelError, labelExplanation, new ControlGroup(buttonYes, buttonNo), cbDontShowAgain); } }
public override void OnApplyTemplate() { if (TitleElement != null) { TitleElement.MouseLeftButtonUp -= OnTitleElementMouseLeftButtonUp; } base.OnApplyTemplate(); TitleElement = LayoutHelper.FindParentObject <LayoutGroup>(GetTemplateChild("MaximizeElement")); if (TitleElement != null) { TitleElement.MouseLeftButtonUp += new MouseButtonEventHandler(OnTitleElementMouseLeftButtonUp); } }
protected override void OnLoad(EventArgs e) { base.OnLoad(e); using (new AutoGrow(groupBoxProxy, AnchorStyles.Bottom, false)) { LayoutHelper.NaturalizeHeight(proxyEnabled); LayoutHelper.FitControlsBelow(8, proxyEnabled); LayoutHelper.NaturalizeHeight(proxyServerLabel, proxyPortLabel); AlignHelper.AlignBottom(proxyServerLabel, proxyPortLabel); LayoutHelper.FitControlsBelow(3, proxyServerLabel); } }
protected override void OnLoad(EventArgs e) { base.OnLoad(e); using (new AutoGrow(this, AnchorStyles.Bottom, true)) { LayoutHelper.NaturalizeHeightAndDistribute(4, label1, linkLabel1); LayoutHelper.DistributeVertically(12, false, linkLabel1, picCaptcha); LayoutHelper.DistributeVertically(4, picCaptcha, txtCaptcha); LayoutHelper.DistributeVertically(12, false, txtCaptcha, new ControlGroup(btnOK, btnCancel)); LayoutHelper.FixupOKCancel(btnOK, btnCancel); } }
private void AdjustLayout(LayoutEventArgs e) { AlignUnitsCollection alignUnitsCollectionFromTLP = AlignUnitsCollection.GetAlignUnitsCollectionFromTLP(this); foreach (IAlignRule alignRule in AlignSettings.RulesList) { alignRule.Apply(alignUnitsCollectionFromTLP); } foreach (AlignUnit alignUnit in alignUnitsCollectionFromTLP.Units) { alignUnit.Control.Margin = LayoutHelper.Scale(alignUnit.ResultMargin + new Padding(0, alignUnitsCollectionFromTLP.RowDeltaValue[alignUnit.Row], 0, 0), this.scaleFactor); } }
void OnPreviewMouseWheel(object sender, MouseWheelEventArgs e) { var scrollBar = (ScrollBar)LayoutHelper.FindElementByName(AssociatedObject, "PART_HorizontalScrollBar"); if (e.Delta > 0) { ScrollBar.LineLeftCommand.Execute(null, scrollBar); } else if (e.Delta < 0) { ScrollBar.LineRightCommand.Execute(null, scrollBar); } }
protected override void OnLoad(EventArgs e) { base.OnLoad(e); if (!DesignMode && !_layedOut) { LayoutHelper.FixupGroupBox(this.groupBoxPostWindows); LayoutHelper.FixupGroupBox(this.groupBoxPublishing); LayoutHelper.FixupGroupBox(this.groupBoxGeneral); LayoutHelper.NaturalizeHeightAndDistribute(8, groupBoxPostWindows, groupBoxPublishing, groupBoxGeneral); _layedOut = true; } }
private void InitPalette() { palettePanel = new PalettePanel(Setting_SwatchesPerRow); LayoutHelper.Below(toolStrip).Left(this).Bottom(this).Width(palettePanel.Width).Apply(palettePanel); palettePanel.Anchor = AnchorStyles.Top | AnchorStyles.Bottom | AnchorStyles.Left; palettePanel.SettingChanged += new EventHandler(PalettePanel_OnSettingChanged); palettePanel.SizeChanged += new EventHandler(PalettePanel_OnSizeChanged); this.Controls.Add(palettePanel); palettePanel.Set(Default_PaletteFileName); }
protected override void OnLoad(EventArgs e) { base.OnLoad(e); //Resize the form so that the panel will fit the new value's Size Size preferredSize = EditorControl.Size; int deltaHeight = preferredSize.Height - panelEditor.Height; int deltaWidth = preferredSize.Width - panelEditor.Width; Size = new Size(Width + deltaWidth, Height + deltaHeight); LayoutHelper.FixupOKCancel(buttonOK, buttonCancel); }
public OrderReview(Context context, IAttributeSet attrs) : base(LayoutHelper.GetLayoutForView(Resource.Layout.SubView_OrderReview, context), context, attrs) { this.DelayBind(() => { _lblName = Content.FindViewById <TextView>(Resource.Id.lblName); _lblDialCode = Content.FindViewById <TextView>(Resource.Id.lblDialCode); _lblPhone = Content.FindViewById <TextView>(Resource.Id.lblPhone); _lblNbPassengers = Content.FindViewById <TextView>(Resource.Id.lblNbPassengers); _lblDate = Content.FindViewById <TextView>(Resource.Id.lblDate); _lblVehicule = Content.FindViewById <TextView>(Resource.Id.lblVehicule); _lblChargeType = Content.FindViewById <TextView>(Resource.Id.lblChargeType); _lblApt = Content.FindViewById <TextView>(Resource.Id.lblApt); _lblRingCode = Content.FindViewById <TextView>(Resource.Id.lblRingCode); _lblBonusAmount = FindViewById <TextView>(Resource.Id.lblBonusAmount); _editNote = FindViewById <EditTextEntry>(Resource.Id.txtNotes); _editPromoCode = FindViewById <EditTextEntry>(Resource.Id.txtPromoCode); _btnPromo = FindViewById <Button>(Resource.Id.btnPromo); _sliderBonus = FindViewById <SeekBar>(Resource.Id.sliderBonus); _switchBonus = FindViewById <Switch>(Resource.Id.switchBonus); _driverBonusView = FindViewById <RelativeLayout>(Resource.Id.driverBonusView); _editNote.SetClickAnywhereToDismiss(); _switchBonus.CheckedChange += (sender, e) => { if (_switchBonus.Checked) { _lblBonusAmount.SetTextColor(Color.Black); } else { _lblBonusAmount.SetTextColor(Color.Rgb(208, 208, 208)); } }; // hack for scroll in view when in EditText _bottomPadding = Content.FindViewById <LinearLayout>(Resource.Id.HackBottomPadding); TextFieldInHomeSubviewsBehavior.ApplyTo( new List <EditText>() { _editNote, _editPromoCode }, () => _bottomPadding.Visibility = ViewStates.Visible, () => _bottomPadding.Visibility = ViewStates.Gone); var hintTextColor = Resources.GetColor(Resource.Color.drivernode_hint_color); _editNote.SetHintTextColor(hintTextColor); InitializeBinding(); }); }
protected override void OnLoad(EventArgs e) { base.OnLoad(e); using (new AutoGrow(this, AnchorStyles.Right | AnchorStyles.Bottom, false)) { // Fix up the Size group box using (new AutoGrow(groupBoxSize, AnchorStyles.Right, false)) { using (new AutoGrow(panelRowsAndColumns, AnchorStyles.Right, false)) { DisplayHelper.AutoFitSystemLabel(labelRows, 0, int.MaxValue); DisplayHelper.AutoFitSystemLabel(labelColumns, 0, int.MaxValue); LayoutHelper.DistributeHorizontally(8, labelRows, numericTextBoxRows); LayoutHelper.DistributeHorizontally(8, labelColumns, numericTextBoxColumns); LayoutHelper.DistributeHorizontally(16, new ControlGroup(labelRows, numericTextBoxRows), new ControlGroup(labelColumns, numericTextBoxColumns)); } } // Fix up the Appearance group box using (new AutoGrow(groupBoxAppearance, AnchorStyles.Right | AnchorStyles.Bottom, false)) { DisplayHelper.AutoFitSystemCheckBox(checkBoxShowBorder, 0, int.MaxValue); DisplayHelper.AutoFitSystemLabel(label1, 0, int.MaxValue); DisplayHelper.AutoFitSystemLabel(label3, 0, int.MaxValue); DisplayHelper.AutoFitSystemLabel(labelBorderPixels, 0, int.MaxValue); DisplayHelper.AutoFitSystemLabel(labelPaddingPixels, 0, int.MaxValue); DisplayHelper.AutoFitSystemLabel(labelSpacingPixels, 0, int.MaxValue); LayoutHelper.DistributeHorizontally( 8, new ControlGroup(checkBoxShowBorder, label1, label3), new ControlGroup(numericTextBoxBorder, numericTextBoxCellPadding, numericTextBoxCellSpacing), new ControlGroup(labelBorderPixels, labelPaddingPixels, labelSpacingPixels) ); } // Make the group boxes the same width int maxWidth = Math.Max(groupBoxAppearance.Width, groupBoxSize.Width); groupBoxAppearance.Width = maxWidth; groupBoxSize.Width = maxWidth; } // Align the OK/Cancel ControlGroup okCancelGroup = new ControlGroup(buttonOK, buttonCancel); okCancelGroup.Left = groupBoxAppearance.Right - okCancelGroup.Width; LayoutHelper.FixupOKCancel(buttonOK, buttonCancel); }
UIElement GetUIVisualHit(DependencyObject d) { if (d == null) { return(null); } UIElement element = d as UIElement; if (element != null) { return(element); } return(LayoutHelper.FindParentObject <UIElement>(d)); }
public virtual void Notify(ConnectionEventArgs e) { LayoutHelper.InvokeFromUiThread(() => { if (e.IsConnected) { return; } IsEmpty = false; IsLoading = false; NotifyOfPropertyChanged(() => IsConnected); }); }
public override void Notify(ConnectionEventArgs e) { base.Notify(e); LayoutHelper.InvokeFromUiThread(async() => { if (!e.IsConnected) { return; } Items.Clear(); await FirstLoad(); }); }
public override void DragAndDrop(Point p) { FrameworkElement ctrl = this.Controller.Control; if (!LayoutHelper.IsPointInsideElementBounds(p, ctrl, new Thickness())) { DragControl.SetVisible(false); DataObject dragData = new DataObject("DragDropDataDG", DragControl.DataContext); DragDrop.DoDragDrop(ctrl, dragData, DragDropEffects.Copy); DragControl.SetVisible(true); return; } base.DragAndDrop(p); }
private void Init() { _currentRoom = null; _background = new Layout(Settings.BackgroundSize); Room initRoom = RoomFactory.CreateInitRoom(); _background.Content = LayoutHelper.MergeLayouts( _background, initRoom.Layout, new Vector2(Settings.BackgroundSize.X / 2, Settings.BackgroundSize.Y / 2 - 1), initRoom.Layout.Size).Content; DisplayHelper.DisplayGameRules(); }
protected override void OnLoad(EventArgs e) { base.OnLoad(e); // size form (set anchor properties here because doing so in the designer causes // hosage of the designer) // listBoxPostSources.Anchor = AnchorStyles.Left | AnchorStyles.Top | AnchorStyles.Bottom ; // listBoxPosts.Anchor = AnchorStyles.Left | AnchorStyles.Right | AnchorStyles.Top | AnchorStyles.Bottom ; // Size = PostEditorSettings.OpenPostFormSize ; LayoutHelper.FixupOKCancel(buttonOK, buttonCancel); DisplayHelper.AutoFitSystemLabel(labelShow, 0, int.MaxValue); //DisplayHelper.AutoFitSystemCombo(comboBoxPosts, 0, int.MaxValue, false); DisplayHelper.AutoFitSystemLabel(labelPosts, 0, int.MaxValue); DisplayHelper.AutoFitSystemRadioButton(radioButtonPosts, 0, int.MaxValue); DisplayHelper.AutoFitSystemRadioButton(radioButtonPages, 0, int.MaxValue); int growBy = GetMaxWidth() - listBoxPosts.Right; if (growBy > 0) { Width += growBy; listBoxPosts.Width += growBy; } // post sources list listBoxPostSources.Initialize(_includeDrafts); listBoxPostSources.SelectedIndexChanged += new EventHandler(listBoxPostSources_SelectedIndexChanged); // number of posts combo comboBoxPosts.SelectedIndexChanged += new EventHandler(comboBoxPosts_SelectedIndexChanged); // post list listBoxPosts.Initialize(this); listBoxPosts.SelectedIndexChanged += new EventHandler(listBoxPosts_SelectedIndexChanged); listBoxPosts.PostsRefreshed += new EventHandler(listBoxPosts_PostsRefreshed); listBoxPosts.DoubleClick += new EventHandler(listBoxPosts_DoubleClick); buttonDelete.Height = comboBoxPosts.Height + 2; textBoxFilter.Width = listBoxPosts.Width; int inset = Convert.ToInt32((textBoxFilter.Height - filterPictureBox.Height) / 2f); filterPictureBox.Top = textBoxFilter.Top + inset; filterPictureBox.Left = textBoxFilter.Right - 16 - inset; // select post source SelectInitialPostSource(); }
protected override void OnLoad(EventArgs e) { base.OnLoad(e); int origY = label2.Bottom; LayoutHelper.NaturalizeHeight(label1, label2); LayoutHelper.DistributeVertically(12, new ControlGroup(rdPlainText, label1), new ControlGroup(rdFormatted, label2)); Height += Math.Max(0, label2.Bottom - origY); LayoutHelper.FixupOKCancel(btnOK, btnCancel); }
//#proc public void SetTextByCulture() { try { foreach (var menuItem in _menuItems) { var menuItemCpnt = this.DropDownItems.Find(menuItem.Name, true); menuItemCpnt[0].Text = LayoutHelper.GetControlDisplayName(_supportMutiLanguages, "", menuItem.Name, _annexes, menuItem.DisplayName); } } catch (Exception ex) { throw new ArgumentException("\n>> " + GetType().FullName + "." + "SetTextByCulture Error: " + ex.Message); } }
void Timer_Tick(object sender, EventArgs e) { lock (BusyIndicator.Locker) { if (ShouldStop) { Close(); } if (!SupportProgress) { return; } TextBlock tb = (TextBlock)LayoutHelper.FindElementByType(this, typeof(TextBlock)); tb.Text = string.Format("Progress: {0} in {1}", Progress, Count); } }
protected override bool CheckObjectType(DependencyObject dObject) { Type t = dObject.GetType(); bool res = Type == t || (!exactType && t.IsSubclassOf(typeof(T))); if (res) { UIElement elem = dObject as UIElement; if (onlyVisibleChildren && !LayoutHelper.IsVisibleInTree(elem)) { res = false; } } return(res); }
protected override void OnLoad(EventArgs e) { base.OnLoad(e); if (!DesignMode) { LayoutHelper.NaturalizeHeightAndDistribute(8, Controls); linkLabelDownloadPlugins.Top = pictureBoxAddPlugin.Top + 1; LayoutHelper.NaturalizeHeight(linkLabelPluginName); DisplayHelper.AutoFitSystemRadioButton(radioButtonEnablePlugin, 0, int.MaxValue); DisplayHelper.AutoFitSystemRadioButton(radioButtonDisablePlugin, 0, int.MaxValue); radioButtonEnablePlugin.BringToFront(); DisplayHelper.AutoFitSystemButton(buttonOptions); } }
public override void OnInspectorGUI () { //base.OnInspectorGUI (); EditorGUIUtility.LookLikeInspector (); layoutHelper = target as LayoutHelper; EditorGUILayout.PrefixLabel ("Transforms:"); layoutHelper.Transforms = ArrayEditor.DisplayArrayEditor<Transform> (layoutHelper.Transforms, EditTransform); DrawSeparator (); EditorGUILayout.PrefixLabel ("Layouts:"); layoutHelper.Layouts = ArrayEditor.DisplayArrayEditor<LayoutHelper.Layout> (layoutHelper.Layouts, EditLayout); }
LayoutHelper.Layout EditLayout( LayoutHelper.Layout layout ) { if ( layout == null ) { layout = new LayoutHelper.Layout () { LayoutName = "Layout" + layoutHelper.Layouts.Length }; } layout.LayoutName = EditorGUILayout.TextField ( "Name: ", layout.LayoutName ); EditorGUILayout.BeginHorizontal (); if (GUILayout.Button ("Capture")) { layout.CaptureLayout (layoutHelper.Transforms); } if (GUILayout.Button ("Enforce")) { layout.EnforceLayout (layoutHelper.Transforms); } EditorGUILayout.EndHorizontal (); return layout; }
void DisplayLines(HexBufferPoint bufferPosition, double verticalDistance, VSTE.ViewRelativePosition relativeTo, double viewportWidthOverride, double viewportHeightOverride, DisplayHexLineOptions options, double? newViewportTop) { if (IsClosed) throw new InvalidOperationException(); var oldBufferLines = hexBufferLineFormatter; var oldHexBufferLineFormatterOptions = hexBufferLineFormatterOptions; Debug.Assert(oldBufferLines != null); bool raiseBufferLinesChangedEvent = false; bool revalidateBufferPosition = false; canvas.Dispatcher.VerifyAccess(); if (bufferPosition.Buffer != Buffer) throw new ArgumentException(); if (relativeTo != VSTE.ViewRelativePosition.Top && relativeTo != VSTE.ViewRelativePosition.Bottom) throw new ArgumentOutOfRangeException(nameof(relativeTo)); if (viewportHeightOverride < 0 || double.IsNaN(viewportHeightOverride)) throw new ArgumentOutOfRangeException(nameof(viewportHeightOverride)); if (viewportWidthOverride < 0 || double.IsNaN(viewportWidthOverride)) throw new ArgumentOutOfRangeException(nameof(viewportWidthOverride)); bool invalidateAllLines = false; if (recreateHexBufferLineFormatter) invalidateAllLines = true; if (viewportWidthOverride != lastViewportWidth || viewportWidthOverride != lastFormattedLineSourceViewportWidth) { invalidateAllLines = true; lastViewportWidth = viewportWidthOverride; } // Make sure the scheduled method doesn't try to call this method delayLayoutLinesInProgress = false; if (invalidateAllLines) { invalidatedRegions.Clear(); invalidatedRegions.Add(new HexBufferSpan(new HexBufferPoint(Buffer, 0), new HexBufferPoint(Buffer, HexPosition.MaxEndPosition))); } var regionsToInvalidate = new NormalizedHexBufferSpanCollection(invalidatedRegions); invalidatedRegions.Clear(); if (invalidatedRegions.Capacity > 100) invalidatedRegions.TrimExcess(); if (invalidateAllLines || formattedLineSourceIsInvalidated) { CreateFormattedLineSource(viewportWidthOverride); formattedLineSourceIsInvalidated = false; recreateHexBufferLineFormatter = true; } // This one depends on FormattedLineSource and must be created afterwards if (recreateHexBufferLineFormatter) { recreateHexBufferLineFormatter = false; raiseBufferLinesChangedEvent = true; if ((options & DisplayHexLineOptions.CanRecreateBufferLines) != 0) { // It's safe to invalidate it here since we were called by the dispatcher and // not by user code. hexBufferLineFormatter = null; // Once the new instance gets created, the input bufferPosition could be invalid // because start and/or end got updated. Re-validate it before creating new lines. revalidateBufferPosition = true; } else { // Don't re-create it here. That can lead to exceptions if Start/End positions get // updated and bufferPosition becomes invalid. New BufferLines' IsValidPosition() throws. // It's recreated with a short delay after raising LayoutChanged. } } var lineTransformProvider = LineTransformProvider; if (InLayout) throw new InvalidOperationException(); inLayout = true; var oldVisibleLines = new HashSet<HexViewLine>(wpfHexViewLineCollection == null ? (IEnumerable<HexViewLine>)Array.Empty<HexViewLine>() : wpfHexViewLineCollection); wpfHexViewLineCollection?.Invalidate(); var layoutHelper = new LayoutHelper(BufferLines, lineTransformProvider, newViewportTop ?? 0, oldVisibleLines, GetValidCachedLines(regionsToInvalidate), FormattedLineSource); if (revalidateBufferPosition) { if (bufferPosition < BufferLines.BufferStart) { bufferPosition = BufferLines.BufferStart; relativeTo = VSTE.ViewRelativePosition.Top; verticalDistance = 0; } else if (bufferPosition > BufferLines.BufferEnd) { bufferPosition = BufferLines.BufferEnd; relativeTo = VSTE.ViewRelativePosition.Bottom; verticalDistance = 0; } } layoutHelper.LayoutLines(bufferPosition, relativeTo, verticalDistance, ViewportLeft, viewportWidthOverride, viewportHeightOverride); visiblePhysicalLines.AddRange(layoutHelper.AllVisiblePhysicalLines); wpfHexViewLineCollection = new WpfHexViewLineCollectionImpl(this, layoutHelper.AllVisibleLines); if (!InLayout) throw new InvalidOperationException(); inLayout = false; textLayer.AddVisibleLines(layoutHelper.AllVisibleLines); var newOrReformattedLines = layoutHelper.NewOrReformattedLines.ToArray(); var translatedLines = layoutHelper.TranslatedLines.ToArray(); if (layoutHelper.NewViewportTop != viewportTop) { viewportTop = layoutHelper.NewViewportTop; Canvas.SetTop(normalAdornmentLayerCollection, -viewportTop); } if ((options & DisplayHexLineOptions.CanRecreateBufferLines) != 0) { if (raiseBufferLinesChangedEvent) RaiseBufferLinesChanged(oldBufferLines); } else if (raiseBufferLinesChangedEvent && oldBufferLines == hexBufferLineFormatter) { var newOptions = GetHexBufferLineFormatterOptions(); if (!newOptions.Equals(oldHexBufferLineFormatterOptions)) { canvas.Dispatcher.BeginInvoke(DispatcherPriority.Send, new Action(() => { if (oldBufferLines == hexBufferLineFormatter) { hexBufferLineFormatter = null; var newBufferLines = BufferLines; RaiseBufferLinesChanged(oldBufferLines); var line = wpfHexViewLineCollection.FirstVisibleLine; verticalDistance = line.Top - ViewportTop; bufferPosition = line.BufferStart; if (bufferPosition < BufferLines.BufferStart) bufferPosition = BufferLines.BufferStart; else if (bufferPosition > BufferLines.BufferEnd) bufferPosition = BufferLines.BufferEnd; DisplayLines(bufferPosition, verticalDistance, VSTE.ViewRelativePosition.Top, ViewportWidth, ViewportHeight, DisplayHexLineOptions.CanRecreateBufferLines, ViewportTop); } })); } } // Raise this event after BufferLinesChanged event. BufferLinesChanged is more low level and // various code could use cached positions in LayoutChanged handlers (eg. the caret will use // its cached position). If this event is raised afterwards, they have a chance to re-validate // their cached values. RaiseLayoutChanged(viewportWidthOverride, viewportHeightOverride, newOrReformattedLines, translatedLines); }
void DisplayLines(SnapshotPoint bufferPosition, double verticalDistance, ViewRelativePosition relativeTo, double viewportWidthOverride, double viewportHeightOverride, double? newViewportTop) { if (IsClosed) throw new InvalidOperationException(); Dispatcher.VerifyAccess(); if (bufferPosition.Snapshot != TextSnapshot) throw new ArgumentException(); if (relativeTo != ViewRelativePosition.Top && relativeTo != ViewRelativePosition.Bottom) throw new ArgumentOutOfRangeException(nameof(relativeTo)); if (viewportHeightOverride < 0 || double.IsNaN(viewportHeightOverride)) throw new ArgumentOutOfRangeException(nameof(viewportHeightOverride)); if (viewportWidthOverride < 0 || double.IsNaN(viewportWidthOverride)) throw new ArgumentOutOfRangeException(nameof(viewportWidthOverride)); bool invalidateAllLines = false; if (viewportWidthOverride != lastViewportWidth || viewportWidthOverride != lastFormattedLineSourceViewportWidth) { invalidateAllLines = true; lastViewportWidth = viewportWidthOverride; } // Make sure the scheduled method doesn't try to call this method delayLayoutLinesInProgress = false; if (invalidateAllLines) { invalidatedRegions.Clear(); invalidatedRegions.Add(new SnapshotSpan(TextSnapshot, 0, TextSnapshot.Length)); } var regionsToInvalidate = new NormalizedSnapshotSpanCollection(invalidatedRegions.Select(a => a.TranslateTo(TextSnapshot, SpanTrackingMode.EdgeInclusive))); invalidatedRegions.Clear(); if (invalidatedRegions.Capacity > 100) invalidatedRegions.TrimExcess(); if (!(FormattedLineSource.SourceTextSnapshot == TextSnapshot && FormattedLineSource.TopTextSnapshot == VisualSnapshot)) invalidateAllLines = true; if (invalidateAllLines || formattedLineSourceIsInvalidated) { CreateFormattedLineSource(viewportWidthOverride); formattedLineSourceIsInvalidated = false; } Debug.Assert(FormattedLineSource.SourceTextSnapshot == TextSnapshot && FormattedLineSource.TopTextSnapshot == VisualSnapshot); var lineTransformProvider = LineTransformProvider; if (InLayout) throw new InvalidOperationException(); InLayout = true; var oldVisibleLines = new HashSet<ITextViewLine>(wpfTextViewLineCollection == null ? (IList<ITextViewLine>)Array.Empty<ITextViewLine>() : wpfTextViewLineCollection); wpfTextViewLineCollection?.Invalidate(); var layoutHelper = new LayoutHelper(lineTransformProvider, newViewportTop ?? 0, oldVisibleLines, GetValidCachedLines(regionsToInvalidate), FormattedLineSource, TextViewModel, VisualSnapshot, TextSnapshot); layoutHelper.LayoutLines(bufferPosition, relativeTo, verticalDistance, ViewportLeft, viewportWidthOverride, viewportHeightOverride); visiblePhysicalLines.AddRange(layoutHelper.AllVisiblePhysicalLines); wpfTextViewLineCollection = new WpfTextViewLineCollection(this, TextSnapshot, layoutHelper.AllVisibleLines); if (!InLayout) throw new InvalidOperationException(); InLayout = false; textLayer.AddVisibleLines(layoutHelper.AllVisibleLines); var newOrReformattedLines = layoutHelper.NewOrReformattedLines.ToArray(); var translatedLines = layoutHelper.TranslatedLines.ToArray(); if (layoutHelper.NewViewportTop != viewportTop) { viewportTop = layoutHelper.NewViewportTop; SetTop(normalAdornmentLayerCollection, -viewportTop); } RaiseLayoutChanged(viewportWidthOverride, viewportHeightOverride, newOrReformattedLines, translatedLines); }