public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture) { try { Visibility?visibility = null; if (value is Visibility) { visibility = (Visibility)value; } else if (value is string) { visibility = (Visibility)Enum.Parse(typeof(Visibility), (string)value, true); } if (visibility.HasValue) { switch (visibility.Value) { case Visibility.Visible: return(false); case Visibility.Collapsed: return(true); case Visibility.Hidden: return(DependencyProperty.UnsetValue); } } } catch { } return(DependencyProperty.UnsetValue); }
/// <summary> /// Converts a value. /// </summary> /// <param name="value"></param> /// <param name="targetType"></param> /// <param name="parameter"></param> /// <param name="culture"></param> /// <returns></returns> public object ConvertBack(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture) { Visibility?v = value as Visibility?; return(((v.HasValue) || (v.Value == Visibility.Collapsed)) ? null : ""); }
/// <summary> /// Posting a new status /// </summary> /// <param name="status">The text of the status</param> /// <param name="visibility">either "direct", "private", "unlisted" or "public"</param> /// <param name="replyStatusId">local ID of the status you want to reply to</param> /// <param name="mediaIds">array of media IDs to attach to the status (maximum 4)</param> /// <param name="sensitive">set this to mark the media of the status as NSFW</param> /// <param name="spoilerText">text to be shown as a warning before the actual content</param> /// <param name="scheduledAt">DateTime to schedule posting of status</param> /// <param name="language">Override language code of the toot (ISO 639-2)</param> /// <param name="poll">Nested parameters to attach a poll to the status</param> /// <returns>Returns Status</returns> public Task <Status> PostStatus(string status, Visibility?visibility = null, String?replyStatusId = null, IEnumerable <string>?mediaIds = null, bool sensitive = false, string?spoilerText = null, DateTime?scheduledAt = null, string?language = null, PollParameters?poll = null) { if (string.IsNullOrEmpty(status) && (mediaIds == null || !mediaIds.Any())) { throw new ArgumentException("A status must have either text (status) or media (mediaIds)", nameof(status)); } var data = new List <KeyValuePair <string, string> >() { new KeyValuePair <string, string>("status", status), }; if (replyStatusId != null) { data.Add(new KeyValuePair <string, string>("in_reply_to_id", replyStatusId.ToString())); } if (mediaIds != null && mediaIds.Any()) { foreach (var mediaId in mediaIds) { data.Add(new KeyValuePair <string, string>("media_ids[]", mediaId.ToString())); } } if (sensitive) { data.Add(new KeyValuePair <string, string>("sensitive", "true")); } if (spoilerText != null) { data.Add(new KeyValuePair <string, string>("spoiler_text", spoilerText)); } if (visibility.HasValue) { data.Add(new KeyValuePair <string, string>("visibility", visibility.ToString().ToLowerInvariant())); } if (scheduledAt.HasValue) { data.Add(new KeyValuePair <string, string>("scheduled_at", scheduledAt.Value.ToString("o"))); } if (language != null) { data.Add(new KeyValuePair <string, string>("language", language)); } if (poll != null) { data.AddRange(poll.Options.Select(option => new KeyValuePair <string, string>("poll[options][]", option))); data.Add(new KeyValuePair <string, string>("poll[expires_in]", poll.ExpiresIn.TotalSeconds.ToString())); if (poll.Multiple.HasValue) { data.Add(new KeyValuePair <string, string>("poll[multiple]", poll.Multiple.Value.ToString())); } if (poll.HideTotals.HasValue) { data.Add(new KeyValuePair <string, string>("poll[hide_totals]", poll.HideTotals.Value.ToString())); } } return(Post <Status>("/api/v1/statuses", data)); }
public void Test_ConvertBack(bool expected, Visibility?input) { // Act. bool actual = (bool)converter.ConvertBack(input, typeof(bool), null, CultureInfo.InvariantCulture); // Assert. Assert.Equal(expected, actual); }
private static bool IsVisibilityHidden(Visibility? visibility) { return visibility == Visibility.Collapsed #if !SILVERLIGHT || visibility == Visibility.Hidden #endif ; }
public object Convert(object value, Type targetType, object parameter, CultureInfo culture) { Visibility?nullable = InverseBooleanToVisibilityConverter.\u202B(this._converter, value, targetType, parameter, culture) as Visibility?; label_1: int num1 = 583089230; object obj; while (true) { int num2 = 494567099; uint num3; int num4; int num5; switch ((num3 = (uint)(num1 ^ num2)) % 5U) { case 0: num4 = 2; break; case 1: Visibility visibility = Visibility.Collapsed; if (nullable.GetValueOrDefault() != visibility) { num1 = (int)num3 * -360165238 ^ 2115854616; continue; } num5 = nullable.HasValue ? 1 : 0; goto label_10; case 3: goto label_1; case 4: num5 = 0; goto label_10; default: goto label_12; } label_7: obj = (object)(Visibility)num4; num1 = 816360863; continue; label_10: if (num5 != 0) { num4 = 0; goto label_7; } else { num1 = 772636485; } } label_12: return(obj); }
private static void DoBlurTansition( IBlurParams blurParams, FrameworkElement target, RoutedEventHandler onLoaded, Visibility?visibility) { var reverse = Transitionz.IsVisibilityHidden(visibility); var blurEffect = new BlurEffect() { Radius = reverse ? blurParams.To : blurParams.From }; target.Effect = blurEffect; if (onLoaded != null && Transitionz.HasFlag(blurParams.TransitionOn, TransitionOn.Once)) { target.Loaded -= onLoaded; } var a = new DoubleAnimation { From = reverse ? blurParams.To : blurParams.From, To = reverse ? blurParams.From : blurParams.To, FillBehavior = blurParams.FillBehavior, BeginTime = TimeSpan.FromMilliseconds(blurParams.BeginTime), Duration = new Duration(TimeSpan.FromMilliseconds(blurParams.Duration)), EasingFunction = reverse ? (blurParams.ReverseEase ?? blurParams.Ease) : blurParams.Ease, AutoReverse = blurParams.AutoReverse, }; // Directly adding RepeatBehavior to constructor breaks existing animations, so only add it if properly defined if (blurParams.RepeatBehavior == RepeatBehavior.Forever || blurParams.RepeatBehavior.HasDuration || (blurParams.RepeatBehavior.HasDuration && blurParams.RepeatBehavior.Count > 0)) { a.RepeatBehavior = blurParams.RepeatBehavior; } if (blurParams.To == 0.0) { a.Completed += (_, __) => target.Effect = null; } if (visibility.HasValue) { a.Completed += (_, __) => target.Visibility = visibility.Value; } a.SetDesiredFrameRate(24); var storyboard = new Storyboard(); storyboard.Children.Add(a); Storyboard.SetTarget(a, ((BlurEffect)target.Effect)); Storyboard.SetTargetProperty(a, new PropertyPath(BlurEffect.RadiusProperty)); FreezeHelper.SetFreeze(storyboard, true); storyboard.Begin(); }
/// <summary> /// Initializes a new instance of the TextTrack class. /// </summary> /// <param name="fileName">The file name to the source file. This file /// is located in the storage container of the asset.</param> /// <param name="displayName">The display name of the text track on a /// video player. In HLS, this maps to the NAME attribute of /// EXT-X-MEDIA.</param> /// <param name="languageCode">The RFC5646 language code for the text /// track.</param> /// <param name="playerVisibility">When PlayerVisibility is set to /// "Visible", the text track will be present in the DASH manifest or /// HLS playlist when requested by a client. When the PlayerVisibility /// is set to "Hidden", the text will not be available to the client. /// The default value is "Visible". Possible values include: 'Hidden', /// 'Visible'</param> /// <param name="hlsSettings">The HLS specific setting for the text /// track.</param> public TextTrack(string fileName = default(string), string displayName = default(string), string languageCode = default(string), Visibility?playerVisibility = default(Visibility?), HlsSettings hlsSettings = default(HlsSettings)) { FileName = fileName; DisplayName = displayName; LanguageCode = languageCode; PlayerVisibility = playerVisibility; HlsSettings = hlsSettings; CustomInit(); }
public object ConvertBack(object value, Type targetType, object parameter, string language) { bool assert = parameter == null || !parameter.ToString().Equals("NEGATE", StringComparison.OrdinalIgnoreCase); Visibility?valueAsVisibility = value as Visibility?; return(assert ? (valueAsVisibility ?? Visibility.Collapsed) == Visibility.Visible : (valueAsVisibility ?? Visibility.Collapsed) == Visibility.Collapsed); }
public void Converts_Back_Null_Visibility_To_Boolean_False() { var converter = new BooleanToVisibilityConverter(); Visibility?inputValue = new Visibility?(); var actual = converter.ConvertBack(inputValue, typeof(Visibility), null, CultureInfo.CurrentCulture); var expected = false; Assert.Equal(expected, actual); }
public object Convert(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture) { Visibility?b = (Visibility)value; if (b.HasValue && b.Value == Visibility.Visible) { return(true); } return(false); }
public void Invalidate(string text, Visibility?visibility = null) { this.CanvasControl.Invalidate(); this.TipTextBlock.Text = text; if (visibility != null) { this.TipBorder.Visibility = visibility ?? Visibility.Collapsed; } }
public void Converts_Back_Nullable_Visibility_Collapsed_State_To_Boolean_True() { var converter = new BooleanToVisibilityInverterConverter(); Visibility?inputValue = new Visibility?(Visibility.Collapsed); var actual = converter.ConvertBack(inputValue, typeof(Visibility), null, CultureInfo.CurrentCulture); var expected = true; Assert.Equal(expected, actual); }
private static void DoScaleTansition( IScaleParams scaleParams, FrameworkElement target, RoutedEventHandler onLoaded, Visibility?visibility) { var reverse = Transitionz.IsVisibilityHidden(visibility); var scaleTransform = new ScaleTransform() { ScaleX = reverse ? scaleParams.To.X : scaleParams.From.X, ScaleY = reverse ? scaleParams.To.Y : scaleParams.From.Y }; target.LayoutTransform = scaleTransform; if (onLoaded != null && Transitionz.HasFlag(scaleParams.TransitionOn, TransitionOn.Once)) { target.Loaded -= onLoaded; } if (Math.Abs(scaleParams.From.X - scaleParams.To.X) > 0.001) { var x = new DoubleAnimation { From = reverse ? scaleParams.To.X : scaleParams.From.X, To = reverse ? scaleParams.From.X : scaleParams.To.X, FillBehavior = scaleParams.FillBehavior, BeginTime = TimeSpan.FromMilliseconds(scaleParams.BeginTime), Duration = new Duration(TimeSpan.FromMilliseconds(scaleParams.Duration)), EasingFunction = reverse ? (scaleParams.ReverseEase ?? scaleParams.Ease) : scaleParams.Ease, AutoReverse = scaleParams.AutoReverse, }; x.SetDesiredFrameRate(24); scaleTransform.BeginAnimation(ScaleTransform.ScaleXProperty, x); } if (Math.Abs(scaleParams.From.Y - scaleParams.To.Y) > 0.001) { var y = new DoubleAnimation { From = reverse ? scaleParams.To.Y : scaleParams.From.Y, To = reverse ? scaleParams.From.Y : scaleParams.To.Y, FillBehavior = scaleParams.FillBehavior, BeginTime = TimeSpan.FromMilliseconds(scaleParams.BeginTime), Duration = new Duration(TimeSpan.FromMilliseconds(scaleParams.Duration)), EasingFunction = reverse ? (scaleParams.ReverseEase ?? scaleParams.Ease) : scaleParams.Ease, AutoReverse = scaleParams.AutoReverse, }; y.SetDesiredFrameRate(24); scaleTransform.BeginAnimation(ScaleTransform.ScaleYProperty, y); } }
public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture) { Visibility?visible = value as Visibility?; if (visible.HasValue && visible.Value == Visibility.Hidden) { return(false); } return(visible == Visibility.Visible); }
//------------------------------------------------------------------------- public object ConvertBack(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture) { Visibility?v = value as Visibility?; if (v != null) { return(v == Visibility.Visible ? false : true); } return(false); }
public object ConvertBack(object value, Type targetType, object parameter, string language) { Visibility?v = value as Visibility?; if (v.HasValue && v.Value == Visibility.Visible) { return(true); } return(false); }
public object Convert(object value, Type targetType, object parameter, string language) { Visibility?visValue = value as Visibility?; if (visValue == null) { return(null); } return(visValue.Value == Visibility.Collapsed ? Visibility.Visible : Visibility.Collapsed); }
internal void RecalculateDownloadColumnWidths(double listWidth) { double staticColumnWidth = 90 + 90; // sum of columns with static widths double padding = 8; if (listWidth == 0) { return; // ActualWidth could be zero if list has not been rendered yet } // account for the scroll bar being visible and add extra padding ScrollViewer sv = FindVisualChild <ScrollViewer>(lstDownloads); Visibility? scrollVis = sv?.ComputedVerticalScrollBarVisibility; if (scrollVis.GetValueOrDefault() == Visibility.Visible) { padding = 26; } double remainingWidth = listWidth - staticColumnWidth - padding; double nameWidth = (0.66) * remainingWidth; // Download Name takes 66% of remaining width double progressWidth = (0.33) * remainingWidth; // Progress takes up 33% of remaining width double minNameWidth = 100; // don't resize columns less than the minimums double minProgressWidth = 60; try { if (nameWidth < listWidth && nameWidth > minNameWidth) { colDownloadName.Width = nameWidth; } else if (nameWidth <= minNameWidth) { colDownloadName.Width = minNameWidth; } if (progressWidth < listWidth && progressWidth > minProgressWidth) { colProgress.Width = progressWidth; } else if (nameWidth <= minProgressWidth) { colProgress.Width = minProgressWidth; } } catch (Exception e) { Logger.Warn(e, "failed to resize download list columns"); } }
private static void DoOpacityTransition( IOpacityParams transitionParams, FrameworkElement target, RoutedEventHandler onLoaded, Visibility?visibility) { var reverse = Transitionz.IsVisibilityHidden(visibility); target.Opacity = reverse ? transitionParams.To : transitionParams.From; if (onLoaded != null && Transitionz.HasFlag(transitionParams.TransitionOn, TransitionOn.Once)) { target.Loaded -= onLoaded; } var a = new DoubleAnimation { From = reverse ? transitionParams.To : transitionParams.From, To = reverse ? transitionParams.From : transitionParams.To, FillBehavior = transitionParams.FillBehavior, BeginTime = TimeSpan.FromMilliseconds(transitionParams.BeginTime), Duration = new Duration(TimeSpan.FromMilliseconds(transitionParams.Duration)), EasingFunction = reverse ? (transitionParams.ReverseEase ?? transitionParams.Ease) : transitionParams.Ease, AutoReverse = transitionParams.AutoReverse, }; // Directly adding RepeatBehavior to constructor breaks existing animations, so only add it if properly defined if (transitionParams.RepeatBehavior == RepeatBehavior.Forever || transitionParams.RepeatBehavior.HasDuration || (transitionParams.RepeatBehavior.HasDuration && transitionParams.RepeatBehavior.Count > 0)) { a.RepeatBehavior = transitionParams.RepeatBehavior; } a.SetDesiredFrameRate(24); var storyboard = new Storyboard(); storyboard.Children.Add(a); Storyboard.SetTarget(a, target); Storyboard.SetTargetProperty(a, new PropertyPath(UIElement.OpacityProperty)); a.Completed += (_, __) => { if (visibility.HasValue) { target.Visibility = visibility.Value; } target.Opacity = reverse ? transitionParams.From : transitionParams.To; storyboard.Stop(); }; storyboard.Begin(); }
/// <summary> /// Adds a list of constant gathered from macros/guids to a C# type. /// </summary> /// <param name="elementFinder">The C++ module to search.</param> /// <param name="macroRegexp">The macro regexp.</param> /// <param name="fullNameCSharpType">Full type of the name C sharp.</param> /// <param name="type">The type.</param> /// <param name="fieldName">Name of the field.</param> /// <param name="valueMap">The value map.</param> /// <param name="visibility">The visibility.</param> /// <param name="nameSpace">The current namespace.</param> public void AddConstantFromMacroToCSharpType(CppElementFinder elementFinder, string macroRegexp, string fullNameCSharpType, string type, string fieldName, string valueMap, Visibility?visibility, string nameSpace) { var constantDefinitions = elementFinder.Find <CppConstant>(macroRegexp); var regex = new Regex(macroRegexp); // $0: Name of the C++ macro // $1: Value of the C++ macro // $2: Name of the C# // $3: Name of current namespace if (valueMap != null) { valueMap = valueMap.Replace("{", "{{"); valueMap = valueMap.Replace("}", "}}"); valueMap = valueMap.Replace("$0", "{0}"); valueMap = valueMap.Replace("$1", "{1}"); valueMap = valueMap.Replace("$2", "{2}"); valueMap = valueMap.Replace("$3", "{3}"); } foreach (var macroDef in constantDefinitions) { var finalFieldName = fieldName == null ? macroDef.Name : NamingRules.ConvertToPascalCase( regex.Replace(macroDef.Name, fieldName), NamingFlags.Default); var finalValue = valueMap == null ? macroDef.Value : string.Format(valueMap, macroDef.Name, macroDef.Value, finalFieldName, nameSpace); var constant = AddConstantToCSharpType(macroDef, fullNameCSharpType, type, finalFieldName, finalValue); constant.Visibility = visibility ?? Visibility.Public | Visibility.Const; } var guidDefinitions = elementFinder.Find <CppGuid>(macroRegexp); foreach (var guidDef in guidDefinitions) { var finalFieldName = fieldName == null ? guidDef.Name : NamingRules.ConvertToPascalCase( regex.Replace(guidDef.Name, fieldName), NamingFlags.Default); var finalValue = valueMap == null? guidDef.Guid.ToString() : string.Format(valueMap, guidDef.Name, guidDef.Guid.ToString(), finalFieldName, nameSpace); var constant = AddConstantToCSharpType(guidDef, fullNameCSharpType, type, finalFieldName, finalValue); constant.Visibility = visibility ?? Visibility.Public | Visibility.Static | Visibility.Readonly; } }
internal void RecalculateColumnWidths(double listWidth) { var currentColumnSettings = GetColumnSettings(); if (currentColumnSettings == null) { return; // can not determine current column widths so return (translation problem?) } double staticColumnWidth = currentColumnSettings.Where(c => !c.AutoResize).Sum(s => s.Width); // sum of columns with static widths double padding = 8; if (listWidth == 0) { return; // ActualWidth could be zero if list has not been rendered yet } // account for the scroll bar being visible and add extra padding ScrollViewer sv = FindVisualChild <ScrollViewer>(lstCatalogMods); Visibility? scrollVis = sv?.ComputedVerticalScrollBarVisibility; if (scrollVis.GetValueOrDefault() == Visibility.Visible) { padding = 26; } double remainingWidth = listWidth - staticColumnWidth - padding; double nameWidth = (0.66) * remainingWidth; // Name takes 66% of remaining width double authorWidth = (0.33) * remainingWidth; // Author takes up 33% of remaining width double minNameWidth = 100; // don't resize columns less than the minimums double minAuthorWidth = 60; try { if (nameWidth < listWidth && nameWidth > minNameWidth) { colName.Width = nameWidth; } if (authorWidth < listWidth && authorWidth > minAuthorWidth) { colAuthor.Width = authorWidth; } } catch (Exception e) { Logger.Warn(e, "failed to resize columns"); } }
public static SyntaxTokenList VisibilityToTokenList(Visibility?visibility, params SyntaxKind[]?additionalKinds) { var additionalKindsSequence = additionalKinds ?? Enumerable.Empty <SyntaxKind>(); var kinds = visibility switch { { } visibilityValue => VisibilityToTokenKindList(visibilityValue), _ => Enumerable.Empty <SyntaxKind>() }; return(TokenList(kinds.Concat(additionalKindsSequence).Select(Token))); }
public void NullableEnumParameter() { Visibility?param = Visibility.Collapsed; ICommand command = CreateCommand <Visibility?>(x => param = x); Execute(command, "Visible"); Assert.AreEqual(Visibility.Visible, param); Execute(command, Visibility.Collapsed); Assert.AreEqual(Visibility.Collapsed, param); Execute(command, null); Assert.IsNull(param); Execute(command, new Nullable <Visibility>(Visibility.Collapsed)); Assert.AreEqual(Visibility.Collapsed, param); }
public object ConvertBack(object value, Type targetTypes, object parameter, System.Globalization.CultureInfo culture) { Visibility?V = value as Visibility?; if (V == Visibility.Collapsed) { return(false); } else { return(true); } }
public object ConvertBack(object value, Type targetType, object parameter, string language) { if (value is null) { throw new ArgumentNullException(); } Visibility?visibility = value as Visibility?; if (visibility == Visibility.Visible) { return(true); } return(false); }
public ClassDeclaration( string name, IReadOnlyCollection <Constructor>?constructors = null, Visibility?visibility = null, string[] inheritsImplements = null, bool isPartial = false, params IWriteableCode[] contents) { Name = name; Constructors = constructors ?? new Constructor[0]; Visibility = visibility ?? Visibility.None; InheritsImplements = inheritsImplements ?? new string[0]; IsPartial = isPartial; Contents = contents; }
public ViewModelServersList( BaseMultiplayerMenuServersController controller, Action <ViewModelServerInfoListEntry> onSelectedServerChanged) { controller.ReloadServersList(); this.controller = controller; this.onSelectedServerChanged = onSelectedServerChanged; this.ServersList = controller.ServersCollection; this.loadingDisplayVisibility = this.controller.IsListAvailable ? Visibility.Collapsed : Visibility.Visible; this.controller.IsListAvailableChanged += this.ControllerIsListAvailableChangedHandler; this.controller.ListChanged += this.ControllerListChangedHandler; this.RefreshListCount(); }
/// <summary> /// 搜索发帖者昵称、帖子文案、帖子标签包含关键字的帖子 /// </summary> /// <param name="visibility">可见性筛选</param> /// <param name="key">搜索关键字</param> /// <param name="cityCode">城市代码,若指定了城市代码,则只在属于该城市的帖子中搜索</param> /// <param name="pagingParameters">分页参数</param> /// <returns></returns> public async Task <PagedList <PostViewModel> > SearchPosts(Visibility?visibility, string key, string cityCode, PagingParameters pagingParameters) { var claim = _httpContextAccessor.HttpContext.User.FindFirst(ClaimTypes.NameIdentifier); var myId = claim == null ? Guid.Empty : Guid.Parse(claim.Value); var role = _httpContextAccessor.HttpContext.User.FindFirst(ClaimTypes.Role)?.Value ?? string.Empty; IQueryable <Domain.AggregatesModel.PostAggregate.Post> queryablePosts = null; if (role == "admin") { queryablePosts = _postContext.Posts.Where(p => p.PostType == PostType.Post); } else { queryablePosts = GetAvailablePosts(myId); } // 有搜索关键字时,搜索昵称、文案和标签 if (!string.IsNullOrWhiteSpace(key)) { key = key.ToLower(); queryablePosts = from p in queryablePosts where p.User.Nickname.ToLower().Contains(key) || (p.Text != null && p.Text.ToLower().Contains(key)) || (p.PublicTags != null && p.PublicTags.ToLower().Contains(key)) select p; } // 搜索城市代码 if (!string.IsNullOrEmpty(cityCode)) { queryablePosts = queryablePosts.Where(p => p.CityCode != null && p.CityCode.ToLower() == cityCode.ToLower()); } // 筛选可见性 if (visibility != null) { queryablePosts = queryablePosts.Where(p => p.Visibility == visibility); } var queryableUserPosts = GetAvailableUserPosts(queryablePosts); var queryableDto = GetQueryablePostViewModels(queryableUserPosts, myId).OrderByDescending(dto => dto.UpdatedTime); return(await GetPagedPostViewModelsAsync(queryableDto, pagingParameters)); }
private async void UIThread(BitmapImage bitmap = null, Visibility?visibility = null) { try { await MainPage.Current.Dispatcher.RunAsync(Windows.UI.Core.CoreDispatcherPriority.Normal, () => { if (bitmap != null) { Thumbnail = bitmap; } if (visibility != null) { VideoVisibility = visibility.Value; } }); } catch { } }
public DataGridRow() { this.MinHeight = DATAGRIDROW_defaultMinHeight; this.Index = -1; this._mouseOverColumnIndex = null; this._detailsDesiredHeight = double.NaN; this._detailsLoaded = false; this.SetValueNoCallback(DetailsVisibilityProperty, Visibility.Collapsed); this._appliedDetailsVisibility = Visibility.Collapsed; this.Cells = new DataGridCellCollection(this); this.Cells.CellAdded += new EventHandler<DataGridCellEventArgs>(DataGridCellCollection_CellAdded); this.Cells.CellRemoved += new EventHandler<DataGridCellEventArgs>(DataGridCellCollection_CellRemoved); this.MouseLeftButtonDown += new MouseButtonEventHandler(DataGridRow_MouseLeftButtonDown); this.MouseEnter += new MouseEventHandler(DataGridRow_MouseEnter); this.MouseLeave += new MouseEventHandler(DataGridRow_MouseLeave); DefaultStyleKey = typeof(DataGridRow); }
private void OnIsVisibleChanged(DependencyObject sender, DependencyProperty e) { if (Model.Chart == null || PreviousVisibility == Visibility) return; PreviousVisibility = Visibility; if (PreviousVisibility != null) Model.Chart.Updater.Run(); if (Visibility == Visibility.Collapsed || Visibility == Visibility.Collapsed) { Erase(false); } }
public DataGridRow() { this.MinHeight = DATAGRIDROW_defaultMinHeight; this.Index = -1; this.IsValid = true; this.Slot = -1; this._mouseOverColumnIndex = null; this._detailsDesiredHeight = double.NaN; this._detailsLoaded = false; this._appliedDetailsVisibility = Visibility.Collapsed; this.Cells = new DataGridCellCollection(this); this.Cells.CellAdded += new EventHandler<DataGridCellEventArgs>(DataGridCellCollection_CellAdded); this.Cells.CellRemoved += new EventHandler<DataGridCellEventArgs>(DataGridCellCollection_CellRemoved); this.AddHandler(FrameworkElement.MouseLeftButtonDownEvent, new MouseButtonEventHandler(DataGridRow_MouseLeftButtonDown), true); this.MouseEnter += new MouseEventHandler(DataGridRow_MouseEnter); this.MouseLeave += new MouseEventHandler(DataGridRow_MouseLeave); DefaultStyleKey = typeof(DataGridRow); }
private void UnloadDetailsTemplate(bool recycle) { if (_detailsElement != null) { if (_detailsContent != null) { if (_detailsLoaded) { this.OwningGrid.OnUnloadingRowDetails(this, _detailsContent); } _detailsContent.DataContext = null; if (!recycle) { _detailsContent.SizeChanged -= new SizeChangedEventHandler(DetailsContent_SizeChanged); _detailsContent = null; } } if (!recycle) { _detailsElement.Children.Clear(); } _detailsElement.ContentHeight = 0; } if (!recycle) { _appliedDetailsTemplate = null; this.SetValueNoCallback(DetailsTemplateProperty, null); } _detailsLoaded = false; _appliedDetailsVisibility = null; this.SetValueNoCallback(DetailsVisibilityProperty, Visibility.Collapsed); }
// Sets AreDetailsVisible on the row and animates if necessary internal void SetDetailsVisibilityInternal(Visibility visibility, bool raiseNotification, bool animate) { Debug.Assert(this.OwningGrid != null); Debug.Assert(this.Index != -1); if (_appliedDetailsVisibility != visibility) { if (_detailsElement == null) { if (raiseNotification) { _detailsVisibilityNotificationPending = true; } return; } _appliedDetailsVisibility = visibility; this.SetValueNoCallback(DetailsVisibilityProperty, visibility); StopDetailsAnimation(); // Applies a new DetailsTemplate only if it has changed either here or at the DataGrid level ApplyDetailsTemplate(true /* initializeDetailsPreferredHeight */); // no template to show if (_appliedDetailsTemplate == null) { if (_detailsElement.ContentHeight > 0) { _detailsElement.ContentHeight = 0; } return; } if (animate && this.DetailsVisibleStoryboard != null && _detailsHeightAnimation != null) { if (this.AreDetailsVisible) { // Expand _detailsHeightAnimation.From = 0.0; _detailsHeightAnimation.To = _detailsHeightAnimationToOverride.HasValue ? _detailsHeightAnimationToOverride.Value : _detailsDesiredHeight; _checkDetailsContentHeight = true; } else { // Collapse _detailsHeightAnimation.From = _detailsElement.ActualHeight; _detailsHeightAnimation.To = 0.0; } _animatingDetails = true; this.DetailsVisibleStoryboard.Begin(); } else { if (this.AreDetailsVisible) { // Set the details height directly _detailsElement.ContentHeight = _detailsDesiredHeight; _checkDetailsContentHeight = true; } else { _detailsElement.ContentHeight = 0; } } OnRowDetailsChanged(); if (raiseNotification) { this.OwningGrid.OnRowDetailsVisibilityChanged(new DataGridRowDetailsEventArgs(this, _detailsContent)); } } }