internal override void UpdateSections() { if (!IsControlLaoded) { return; } var d = ActualWidth < ActualHeight ? ActualWidth : ActualHeight; if (Sections.Any()) { foreach (var section in Sections) { if (section.Visibility == Visibility.Visible) { var slice = Slices[section]; var h = GetActualHeight() / (ToValue - FromValue) * (section.ToValue - section.FromValue); var bottom = (section.FromValue - FromValue) * GetActualHeight() / (ToValue - FromValue); Canvas.SetBottom(slice, bottom); Canvas.SetLeft(slice, ActualWidth * .5); slice.Height = h; slice.Width = BackWidth; slice.Fill = section.Fill; } } } }
public int FindSectionIndex(Vector2 displayPos, bool world = false, bool clamp = false) { if (!Sections.Any()) { return(-1); } if (world && Submarine != null) { displayPos -= Submarine.Position; } //if the sub has been flipped horizontally, the first section may be smaller than wallSectionSize //and we need to adjust the position accordingly if (Sections[0].rect.Width < WallSectionSize) { displayPos.X += WallSectionSize - Sections[0].rect.Width; } int index = (IsHorizontal) ? (int)Math.Floor((displayPos.X - rect.X) / WallSectionSize) : (int)Math.Floor((rect.Y - displayPos.Y) / WallSectionSize); if (clamp) { index = MathHelper.Clamp(index, 0, Sections.Length - 1); } else if (index < 0 || index > Sections.Length - 1) { return(-1); } return(index); }
/// <summary> /// Gets the raw value of the key. /// </summary> /// <returns>The value raw.</returns> /// <param name="sectionName">Section name.</param> /// <param name="keyName">Key name.</param> /// <param name="defaultValue">Default value returned if the key with the given name does not exist.</param> /// <typeparam name="T">The 1st type parameter.</typeparam> internal virtual T GetRawValue <T>(string sectionName, string keyName, T defaultValue) { if (string.IsNullOrWhiteSpace(sectionName)) { throw new ArgumentNullException(nameof(sectionName)); } if (string.IsNullOrWhiteSpace(keyName)) { throw new ArgumentNullException(nameof(keyName)); } var iniKey = new ConfigKeyValue <T>(keyName, Settings.KeyValueSeparator, defaultValue, -1); if (!sections.TryGetValue(sectionName, out var section)) { section = new ConfigSection(sectionName, Lines.Any() ? Lines.Max(l => l.LineNumber) : 0); if (Sections.Any()) { Sections.Last().AddLine(new ConfigLine()); } sections.Add(sectionName, section); } var key = section.Keys.FirstOrDefault(k => Equals(keyName, k.Name)); if (key != null) { return((T)key.ValueRaw); } section.AddLine(iniKey); return(defaultValue); }
private bool CanEdit(Section section) { if (!Sections.Any()) { return(false); } return(true); }
private bool CanSubmit() { return (State != null && !State.IsProcessing && !string.IsNullOrEmpty(Counterparty) && Sections.Any() && Sections.All(s => s.IsValid)); }
protected override void InitSections() { if (Sections.Any()) { return; } Sections.Add(new CustomDataCalendarSection(this)); foreach (var calendarSection in Sections) { calendarSection.AfterConstraction(); } }
protected async Task <ListContext> LoadSectionsAsync() { var query = Query.Create(ListUI !.PageSize, CurrentState.CurrentPage, CurrentState.SearchTerm, CurrentState.ActiveTab); query.CollectionAlias = CurrentState.CollectionAlias; if (ListUI.OrderBys != null) { query.SetOrderBys(ListUI.OrderBys); } var request = CurrentState.Related != null ? (GetEntitiesRequestModel) new GetEntitiesOfRelationRequestModel { CollectionAlias = CurrentState.CollectionAlias, Query = query, Related = CurrentState.Related, UsageType = CurrentState.UsageType, VariantAlias = CurrentState.VariantAlias } : (GetEntitiesRequestModel) new GetEntitiesOfParentRequestModel { CollectionAlias = CurrentState.CollectionAlias, ParentPath = CurrentState.ParentPath, Query = query, UsageType = CurrentState.UsageType, VariantAlias = CurrentState.VariantAlias }; var listContext = await PresentationService.GetEntitiesAsync <GetEntitiesRequestModel, ListContext>(request); await SetSectionsAsync(listContext); if (!query.MoreDataAvailable) { CurrentState.MaxPage = CurrentState.CurrentPage; if (CurrentState.CurrentPage > 1 && !Sections.Any()) { CurrentState.CurrentPage--; CurrentState.MaxPage = null; await LoadSectionsAsync(); } } if (CurrentState.MaxPage == CurrentState.CurrentPage && query.MoreDataAvailable) { CurrentState.MaxPage = null; } return(listContext); }
public MultiCategoriesNewTabViewModel(ITabControlAppParms parms, ITabFactoryService tabFactoryService) { m_Parms = parms; m_TabFactoryService = tabFactoryService; Init(); AddAllSections(); AddAllHeaderActions(); AddAllFooterActions(); if (Sections.Any()) { Sections.First().IsExpanded = true; } }
public override void CreateElements() { base.CreateElements(); Sections.AddRange(_page.Sections.Select(ElementFactory.CreateSection)); if (!Sections.Any()) { Sections.Add(ElementFactory.CreateSection(_page.Title, _page.Options)); } foreach (var section in Sections) { section.CreateElements(); } }
internal virtual void UpdateSections() { if (!IsControlLaoded) { return; } var fromAlpha = (360 - Wedge) * .5; var toAlpha = 360 - fromAlpha; var d = ActualWidth < ActualHeight ? ActualWidth : ActualHeight; if (Sections.Any()) { SectionsInnerRadius = SectionsInnerRadius > 1 ? 1 : (SectionsInnerRadius < 0 ? 0 : SectionsInnerRadius); foreach (var section in Sections) { //if (section.Visibility != Visibility.Visible) continue; var slice = Slices[section]; Canvas.SetTop(slice, ActualHeight * .5); Canvas.SetLeft(slice, ActualWidth * .5); var start = LinearInterpolation(fromAlpha, toAlpha, FromValue, ToValue, section.FromValue) + 180; var end = LinearInterpolation(fromAlpha, toAlpha, FromValue, ToValue, section.ToValue) + 180; slice.RotationAngle = start; slice.WedgeAngle = end - start; slice.Radius = d * .5; slice.InnerRadius = d * .5 * SectionsInnerRadius; slice.Fill = section.Fill; } } }
public void AddSection(Section section) { if (Sections.Contains(section)) { return; } if (Sections.Any()) { if (Sections.LastOrDefault().Last != section.First) { throw new Exception("Не верно составлен путь!"); } } Sections.Add(section); section.PropertyChanged += SectionPropertyChanged; if (section.First is StartNode) { section.First.PropertyChanged += SectionPropertyChanged; } }
public override void OnResume() { base.OnResume(); if (Sections.Any() && (_index > 0 || _top < -1)) { int sectionIndex, cellIndex; CellAdapter.GetSectionAndIndex(Sections, _index, out sectionIndex, out cellIndex); ScrollToCell(sectionIndex, cellIndex, false, _top); } SelectedIndex = _selectedIndex; if (PopoverFragment.Instance == null) { return; } var metrics = new DisplayMetrics(); DroidFactory.MainActivity.WindowManager.DefaultDisplay.GetMetrics(metrics); var width = (int)(metrics.WidthPixels * .6 + 16 * DroidFactory.DisplayScale); var height = LinearLayout.LayoutParams.WrapContent; PopoverFragment.Instance.Dialog.Window.SetLayout(width, height); }
/// <summary> /// Gets the raw value of the key. /// </summary> /// <returns>The value raw.</returns> /// <param name="sectionName">Section name.</param> /// <param name="keyName">Key name.</param> /// <param name="defaultValue">Default value returned if the key with the given name does not exist.</param> /// <typeparam name="T">The 1st type parameter.</typeparam> internal virtual T GetRawValue <T>(string sectionName, string keyName, T defaultValue) { if (sectionName is null) { throw new ArgumentNullException(nameof(sectionName)); } if (string.IsNullOrWhiteSpace(keyName)) { throw new ArgumentException("Key name must be a non-empty string.", nameof(keyName)); } var iniKey = new ConfigKeyValue <T>(keyName, Settings.KeyValueSeparator, defaultValue, -1); if (!sections.TryGetValue(sectionName, out var section)) { section = new ConfigSection(sectionName, Lines.Any() ? Lines.Max(l => l.LineNumber) : 0); if (Sections.Any()) { Sections.Last().AddLine(new ConfigLine()); } sections.Add(sectionName, section); } var key = (section ?? fileHeader?.Section).Keys.FirstOrDefault(k => Equals(keyName, k.Name)); if (key != null) { return((T)key.ValueRaw); } if (section is null && Settings.MultiLineValues.HasFlag(MultiLineValues.AllowEmptyTopSection)) { section = fileHeader.Section; } section?.AddLine(iniKey); return(defaultValue); }
private void DropTemplateSection([NotNull] string response, [NotNull] ExecuteResult executeresult) { Debug.ArgumentNotNull(response, nameof(response)); Debug.ArgumentNotNull(executeresult, nameof(executeresult)); if (!DataService.HandleExecute(response, executeresult)) { return; } XDocument doc; try { doc = XDocument.Parse(response); } catch { return; } var template = doc.Root; if (template == null) { return; } if (Sections.Any()) { Sections.RemoveAt(Sections.Count - 1); } LoadTemplateSections(template); RenderTemplate(); SetModified(true); }
public bool ContainsSection(int lessonId) => Sections.Any(s => s.LessonId == lessonId);
protected override void OnMouseMove(MouseEventArgs e) { if (Sections.Any()) { // show current mouse position value: var percentPos = (e.Location.X - Padding.Left) / (double)(Width - Padding.Horizontal); var val = CalculateActualValue(percentPos); if (CurrentMousePosition != val) { CurrentMousePosition = val; Invalidate(); } if (Drag(e, false)) { return; } else { // Change color on mouse over: foreach (var section in Sections) { var start = GetStartBounds(section); var end = GetEndBounds(section); var line = GetLineBounds(section); if (start.Contains(e.Location)) { if (section.MouseOver != TimelineSectionComponents.StartSeparator) { section.MouseOver = TimelineSectionComponents.StartSeparator; Invalidate(); toolTip1.Show($"{section.Start.DisplayText}{Environment.NewLine}{section.TooltipHeader}{Environment.NewLine}{section.TooltipBody}", this, start.Left, start.Top - 50); } } else if (section.End.IsVisible && end.Contains(e.Location)) { if (section.MouseOver != TimelineSectionComponents.EndSeparator) { section.MouseOver = TimelineSectionComponents.EndSeparator; Invalidate(); toolTip1.Show($"{section.End.DisplayText}{Environment.NewLine}{section.TooltipHeader}{Environment.NewLine}{section.TooltipBody}", this, end.Left, end.Top - 50); } } else if (line.Contains(e.Location)) { if (section.MouseOver != TimelineSectionComponents.Line) { section.MouseOver = TimelineSectionComponents.Line; Invalidate(); string duration = String.IsNullOrEmpty(section.TooltipDurationCustomText) ? $"{section.Start.DisplayText} - {section.End.DisplayText}" : section.TooltipDurationCustomText; toolTip1.Show($"{duration}{Environment.NewLine}{section.TooltipHeader}{Environment.NewLine}{section.TooltipBody}", this, line.Left + line.Width / 2, start.Top - 50); } } else { if (section.MouseOver != TimelineSectionComponents.None) { section.MouseOver = TimelineSectionComponents.None; Invalidate(); toolTip1.Hide(this); } } } } } base.OnMouseMove(e); }
public bool HasSection(string name) { return(Sections.Any(s => string.Compare(s.Name, name, StringComparison.InvariantCultureIgnoreCase) == 0)); }
/// <summary> /// Returns whether or not the notebook contains any pages which satisfy a given check function. /// </summary> /// <param name="check">A conditional predicate for a Page object.</param> /// <returns>True if at least one page contained in the notebook returns true when passed into the function.</returns> public bool HasPagesWhere(Func <Page, bool> check) => Sections.Any((section) => section.Pages.Any(check));
private bool CanSave() { if (Student == null) { return(false); } if (Student.Contacts == null) { return(false); } if (Sections == null) { return(false); } if (Student.StudentID == null || Student.LastName == null || Student.FirstName == null || !Student.Contacts.Any() || !Sections.Any()) { return(false); } return(!Student.HasErrors); }
private MarkdownSpec(IEnumerable <Tuple <string, MarkdownDocument> > sources) { Sources = sources; // (1) Add sections into the dictionary string url = "", title = ""; // (2) Turn all the antlr code blocks into a grammar var sbantlr = new StringBuilder(); foreach (var src in sources) { var reporter = new Reporter(src.Item1); var filename = Path.GetFileName(src.Item1); var md = src.Item2; foreach (var mdp in md.Paragraphs) { reporter.CurrentParagraph = mdp; reporter.CurrentSection = null; if (mdp.IsHeading) { try { var sr = new SectionRef(mdp as MarkdownParagraph.Heading, filename); if (Sections.Any(s => s.Url == sr.Url)) { reporter.Error("MD02", $"Duplicate section title {sr.Url}"); } else { Sections.Add(sr); url = sr.Url; title = sr.Title; reporter.CurrentSection = sr; } } catch (Exception ex) { reporter.Error("MD03", ex.Message); // constructor of SectionRef might throw } } else if (mdp.IsCodeBlock) { var mdc = mdp as MarkdownParagraph.CodeBlock; string code = mdc.code, lang = mdc.language; if (lang != "antlr") { continue; } var g = Antlr.ReadString(code, ""); Productions.Add(new ProductionRef(code, g.Productions)); foreach (var p in g.Productions) { p.Link = url; p.LinkName = title; if (p.Name != null && Grammar.Productions.Any(dupe => dupe.Name == p.Name)) { reporter.Warning("MD04", $"Duplicate grammar for {p.Name}"); } Grammar.Productions.Add(p); } } } } }
public bool HasSections() => Sections.Any();
private void Draw() { if (!IsControlLaoded) { return; } //No cache for you gauge :( kill and redraw please foreach (var child in Canvas.Children.Cast <UIElement>() .Where(x => !Equals(x, Stick)).ToArray()) { Canvas.Children.Remove(child); } Wedge = Wedge > 360 ? 360 : (Wedge < 0 ? 0 : Wedge); var fromAlpha = (360 - Wedge) * .5; var toAlpha = 360 - fromAlpha; var d = ActualWidth < ActualHeight ? ActualWidth : ActualHeight; Stick.Height = d * .5 * .8; Stick.Width = Stick.Height * .2; Canvas.SetLeft(Stick, ActualWidth * .5 - Stick.Width * .5); Canvas.SetTop(Stick, ActualHeight * .5 - Stick.Height * .9); var ticksHi = d * .5; var ticksHj = d * .47; var labelsHj = d * .44; if (Sections.Any()) { SectionsInnerRadius = SectionsInnerRadius > 1 ? 1 : (SectionsInnerRadius < 0 ? 0 : SectionsInnerRadius); foreach (var section in Sections) { var start = LinearInterpolation(fromAlpha, toAlpha, FromValue, ToValue, section.FromValue) + 180; var end = LinearInterpolation(fromAlpha, toAlpha, FromValue, ToValue, section.ToValue) + 180; var slice = new PieSlice { RotationAngle = start, WedgeAngle = end - start, Radius = d * .5, InnerRadius = d * .5 * SectionsInnerRadius, Fill = section.Fill }; Canvas.Children.Add(slice); Canvas.SetTop(slice, ActualHeight * .5); Canvas.SetLeft(slice, ActualWidth * .5); } } for (var i = FromValue; i <= ToValue; i += TicksStep) { var alpha = LinearInterpolation(fromAlpha, toAlpha, FromValue, ToValue, i) + 90; var tick = new Line { X1 = ActualWidth * .5 + ticksHi * Math.Cos(alpha * Math.PI / 180), X2 = ActualWidth * .5 + ticksHj * Math.Cos(alpha * Math.PI / 180), Y1 = ActualHeight * .5 + ticksHi * Math.Sin(alpha * Math.PI / 180), Y2 = ActualHeight * .5 + ticksHj * Math.Sin(alpha * Math.PI / 180) }; Canvas.Children.Add(tick); tick.SetBinding(Shape.StrokeProperty, new Binding { Path = new PropertyPath(TicksForegroundProperty), Source = this }); tick.SetBinding(Shape.StrokeThicknessProperty, new Binding { Path = new PropertyPath(TicksStrokeThicknessProperty), Source = this }); } for (var i = FromValue; i <= ToValue; i += LabelsStep) { var alpha = LinearInterpolation(fromAlpha, toAlpha, FromValue, ToValue, i) + 90; var tick = new Line { X1 = ActualWidth * .5 + ticksHi * Math.Cos(alpha * Math.PI / 180), X2 = ActualWidth * .5 + labelsHj * Math.Cos(alpha * Math.PI / 180), Y1 = ActualHeight * .5 + ticksHi * Math.Sin(alpha * Math.PI / 180), Y2 = ActualHeight * .5 + labelsHj * Math.Sin(alpha * Math.PI / 180) }; Canvas.Children.Add(tick); var label = new TextBlock { Text = LabelFormatter(i) }; label.SetBinding(EffectProperty, new Binding { Path = new PropertyPath(LabelsEffectProperty), Source = this }); Canvas.Children.Add(label); label.UpdateLayout(); Canvas.SetLeft(label, alpha < 270 ? tick.X2 : (Math.Abs(alpha - 270) < 4 ? tick.X2 - label.ActualWidth * .5 : tick.X2 - label.ActualWidth)); Canvas.SetTop(label, tick.Y2); tick.SetBinding(Shape.StrokeProperty, new Binding { Path = new PropertyPath(TicksForegroundProperty), Source = this }); tick.SetBinding(Shape.StrokeThicknessProperty, new Binding { Path = new PropertyPath(TicksStrokeThicknessProperty), Source = this }); } MoveStick(); }