private void Button_Clicked(object sender, EventArgs e) { ThemeHelper.Toggle(); }
private void DarkModeToggle_Unchecked(object sender, EventArgs e) { ThemeHelper.ApplyLightMode(); }
public override void OnConfigurationChanged(Configuration newConfig) { ThemeHelper.ChangeTheme(); base.OnConfigurationChanged(newConfig); }
private int getTopMarginAsPx(TimeSpan itemTime, TimeSpan baseTime) { return(ThemeHelper.AsPx(Context, (INITIAL_MARGIN + Math.Max((itemTime - baseTime).TotalHours * HEIGHT_OF_HOUR, 0)))); }
private async Task EnsureWindow(IActivatedEventArgs args) { // No matter what our destination is, we're going to need control data loaded - let's knock that out now. // We'll never need to do this again. await ControlInfoDataSource.Instance.GetGroupsAsync(); Frame rootFrame = GetRootFrame(); ThemeHelper.Initialize(); Type targetPageType = typeof(NewControlsPage); string targetPageArguments = string.Empty; if (args.Kind == ActivationKind.Launch) { if (args.PreviousExecutionState == ApplicationExecutionState.Terminated) { try { await SuspensionManager.RestoreAsync(); } catch (SuspensionManagerException) { //Something went wrong restoring state. //Assume there is no state and continue } } targetPageArguments = ((LaunchActivatedEventArgs)args).Arguments; } else if (args.Kind == ActivationKind.Protocol) { Match match; string targetId = string.Empty; switch (((ProtocolActivatedEventArgs)args).Uri?.AbsolutePath) { case string s when IsMatching(s, "/category/(.*)"): targetId = match.Groups[1]?.ToString(); if (ControlInfoDataSource.Instance.Groups.Any(g => g.UniqueId == targetId)) { targetPageType = typeof(SectionPage); } break; case string s when IsMatching(s, "/item/(.*)"): targetId = match.Groups[1]?.ToString(); if (ControlInfoDataSource.Instance.Groups.Any(g => g.Items.Any(i => i.UniqueId == targetId))) { targetPageType = typeof(ItemPage); } break; } targetPageArguments = targetId; bool IsMatching(string parent, string expression) { match = Regex.Match(parent, expression); return(match.Success); } } rootFrame.Navigate(targetPageType, targetPageArguments); ((Microsoft.UI.Xaml.Controls.NavigationViewItem)(((NavigationRootPage)(Window.Current.Content)).NavigationView.MenuItems[0])).IsSelected = true; // Ensure the current window is active Window.Current.Activate(); }
private void SetPortalCofig() { Hashtable hstPortals = GetPortals(); SageUserControl suc = new SageUserControl(); suc.PagePath = PagePath; int portalID = 1; #region "Get Portal SEO Name and PortalID" if (string.IsNullOrEmpty(Request.QueryString["ptSEO"])) { if (string.IsNullOrEmpty(PortalSEOName)) { PortalSEOName = GetDefaultPortalName(hstPortals, 1);// 1 is default parent PortalID } else if (!hstPortals.ContainsKey(PortalSEOName.ToLower().Trim())) { PortalSEOName = GetDefaultPortalName(hstPortals, 1); } else { portalID = int.Parse(hstPortals[PortalSEOName.ToLower().Trim()].ToString()); } } else { PortalSEOName = Request.QueryString["ptSEO"].ToString().ToLower().Trim(); portalID = Int32.Parse(Request.QueryString["ptlid"].ToString()); } #endregion suc.SetPortalSEOName(PortalSEOName.ToLower().Trim()); Session[SessionKeys.SageFrame_PortalSEOName] = PortalSEOName.ToLower().Trim(); Session[SessionKeys.SageFrame_PortalID] = portalID; Session[SessionKeys.SageFrame_AdminTheme] = ThemeHelper.GetAdminTheme(GetPortalID, GetUsername); Globals.sysHst[ApplicationKeys.ActiveTemplate + "_" + portalID] = TemplateController.GetActiveTemplate(GetPortalID).TemplateSeoName; Globals.sysHst[ApplicationKeys.ActivePagePreset + "_" + portalID] = PresetHelper.LoadActivePagePreset(GetActiveTemplate, GetPageSEOName(Request.Url.ToString())); suc.SetPortalID(portalID); SetPortalID(portalID); #region "Set user credentials for modules" if (SecurityPolicy.GetUser(GetPortalID) != string.Empty) { SettingProvider objSP = new SettingProvider(); SageFrameConfig sfConfig = new SageFrameConfig(); if (SecurityPolicy.GetUser(GetPortalID) != string.Empty) { string strRoles = string.Empty; List <SageUserRole> sageUserRolles = objSP.RoleListGetByUsername(SecurityPolicy.GetUser(GetPortalID), GetPortalID); if (sageUserRolles != null) { foreach (SageUserRole userRole in sageUserRolles) { strRoles += userRole.RoleId + ","; } } if (strRoles.Length > 1) { strRoles = strRoles.Substring(0, strRoles.Length - 1); } if (strRoles.Length > 0) { SetUserRoles(strRoles); } } } #endregion }
private void RenderSchedule() { var timesViewGroup = _scheduleHost.GetChildAt(0) as ViewGroup; // Remove the existing content timesViewGroup.RemoveAllViews(); for (int i = 1; i < _scheduleHost.ChildCount; i++) { var col = _scheduleHost.GetChildAt(i) as ViewGroup; // Remove all but the day header and all items while (col.ChildCount > 2) { col.RemoveViewAt(2); } } // If there's no items, stop if (!ViewModel.IsValid()) { return; } // Get earliest start and end date DateTime today = DateTime.Today; DateTime classStartTime = today.Add(ViewModel.StartTime); DateTime classEndTime = today.Add(ViewModel.EndTime); // Fill in the times on the left column for (DateTime tempClassStartTime = classStartTime; classEndTime >= tempClassStartTime; tempClassStartTime = tempClassStartTime.AddHours(1)) { timesViewGroup.AddView(SetMargin(new TextView(Context) { Text = DateHelper.ToShortTimeString(tempClassStartTime).TrimEnd(' ', 'P', 'A', 'M', 'a', 'p', 'm') }, left: ThemeHelper.AsPx(Context, 12), top: getTopMarginAsPx(tempClassStartTime.TimeOfDay, classStartTime.TimeOfDay) - ThemeHelper.AsPx(Context, 4), right: ThemeHelper.AsPx(Context, 12), bottom: ThemeHelper.AsPx(Context, 24))); } // First render the all day items so we'll know the heights for (int i = 0; i < 7; i++) { RenderAllDayItems(ViewModel.StartDate.AddDays(i)); } ResetAllDayItemsViewsHeight(); RenderAllDates(); }
private void Dashboard_Load(object sender, EventArgs e) { ThemeHelper.ChangeFormBackgroundColor(this); }
protected override View CreateTitle() { _title = new TextView(Context) { TextSize = 16 }; _title.SetPaddingRelative(ThemeHelper.AsPx(Context, 16), ThemeHelper.AsPx(Context, 12), 0, ThemeHelper.AsPx(Context, 12)); return(_title); }
void OverrideDiagnosticInfo(StackPanel panel) { var infoPanel = panel.Children[1].GetFirstVisualChild <ItemsControl>()?.GetFirstVisualChild <StackPanel>(); if (infoPanel == null) { // try the first item (symbol title may be absent) infoPanel = panel.Children[0].GetFirstVisualChild <ItemsControl>()?.GetFirstVisualChild <StackPanel>(); if (infoPanel?.GetFirstVisualChild <WrapPanel>() != null) { return; } } if (infoPanel == null) { return; } foreach (var item in infoPanel.Children) { var cp = (item as UIElement).GetFirstVisualChild <TextBlock>(); if (cp == null) { continue; } if (Diagnostics != null && Diagnostics.Count > 0) { var t = cp.GetText(); var d = Diagnostics.FirstOrDefault(i => i.GetMessage() == t); if (d != null) { cp.ToolTip = String.Empty; cp.Tag = d; cp.SetGlyph(ThemeHelper.GetImage(GetGlyphForSeverity(d.Severity))); cp.ToolTipOpening += ShowToolTipForDiagnostics; } } else { cp.SetGlyph(ThemeHelper.GetImage(KnownImageIds.StatusInformation)); } } int GetGlyphForSeverity(DiagnosticSeverity severity) { switch (severity) { case DiagnosticSeverity.Warning: return(KnownImageIds.StatusWarning); case DiagnosticSeverity.Error: return(KnownImageIds.StatusError); case DiagnosticSeverity.Hidden: return(KnownImageIds.StatusHidden); default: return(KnownImageIds.StatusInformation); } } void ShowToolTipForDiagnostics(object sender, ToolTipEventArgs e) { var t = sender as TextBlock; var d = t.Tag as Diagnostic; var tip = new ThemedToolTip(); tip.Title.Append(d.Descriptor.Category + " (" + d.Id + ")", true); tip.Content.Append(d.Descriptor.Title.ToString()); if (String.IsNullOrEmpty(d.Descriptor.HelpLinkUri) == false) { tip.Content.AppendLine().Append("Help: " + d.Descriptor.HelpLinkUri); } if (d.IsSuppressed) { tip.Content.AppendLine().Append("Suppressed"); } if (d.IsWarningAsError) { tip.Content.AppendLine().Append("Content as error"); } t.ToolTip = tip; t.ToolTipOpening -= ShowToolTipForDiagnostics; } }
// Initialization code. Don't use any Avalonia, third-party APIs or any // SynchronizationContext-reliant code before AppMain is called: things aren't initialized // yet and stuff might break. public static int Main(string[] args) { AppDomain.CurrentDomain.UnhandledException += CurrentDomain_UnhandledException; TaskScheduler.UnobservedTaskException += TaskScheduler_UnobservedTaskException; bool runGui = true; try { if (CrashReporter.TryGetExceptionFromCliArgs(args, out var exceptionToShow)) { // Show the exception. Console.WriteLine($"TODO Implement crash reporting. {exceptionToShow}"); runGui = false; } } catch (Exception ex) { // Anything happens here just log it and do not run the Gui. Logger.LogCritical(ex); runGui = false; } Exception? exceptionToReport = null; SingleInstanceChecker?singleInstanceChecker = null; if (runGui) { try { string dataDir = EnvironmentHelpers.GetDataDir(Path.Combine("WalletWasabi", "Client")); SetupLogger(dataDir, args); var(uiConfig, config) = LoadOrCreateConfigs(dataDir); singleInstanceChecker = new SingleInstanceChecker(config.Network); singleInstanceChecker.EnsureSingleOrThrowAsync().GetAwaiter().GetResult(); Global = CreateGlobal(dataDir, uiConfig, config); // TODO only required due to statusbar vm... to be removed. Locator.CurrentMutable.RegisterConstant(Global); Logger.LogSoftwareStarted("Wasabi GUI"); BuildAvaloniaApp(Global) .AfterSetup(_ => ThemeHelper.ApplyTheme(Global.UiConfig.DarkModeEnabled)) .StartWithClassicDesktopLifetime(args); } catch (OperationCanceledException ex) { Logger.LogDebug(ex); } catch (Exception ex) { exceptionToReport = ex; Logger.LogCritical(ex); } } // Start termination/disposal of the application. TerminateService.Terminate(); if (singleInstanceChecker is { } single) { Task.Run(async() => await single.DisposeAsync()).Wait(); } if (exceptionToReport is { })
private void CustomerMenu_Load(object sender, EventArgs e) { ThemeHelper.ChangeFormBackgroundColor(this); }
private void ApplyThemes() { bool isLight = AppSettings.Instance.AppTheme == ApplicationTheme.Light; ThemeHelper.ApplyAppTheme(isLight); }
protected override void OnStart() { ThemeHelper.GetSystemRequestedTheme(); }
public override CacheDependency GetCacheDependency(string virtualPath, IEnumerable virtualPathDependencies, DateTime utcStart) { var styleResult = ThemeHelper.IsStyleSheet(virtualPath); if (styleResult == null || styleResult.IsCss) { return(base.GetCacheDependency(virtualPath, virtualPathDependencies, utcStart)); } if (styleResult.IsThemeVars || styleResult.IsModuleImports) { return(null); } // Is Sass Or Less Or StyleBundle var arrPathDependencies = virtualPathDependencies.Cast <string>().ToArray(); // Exclude the special imports from the file dependencies list, // 'cause this one cannot be monitored by the physical file system var fileDependencies = ThemeHelper.RemoveVirtualImports(arrPathDependencies); if (fileDependencies == arrPathDependencies) { // No themevars or moduleimports import... so no special considerations here return(base.GetCacheDependency(virtualPath, virtualPathDependencies, utcStart)); } if (fileDependencies.Any()) { string cacheKey = null; var isThemeableAsset = (!styleResult.IsBundle && ThemeHelper.PathIsInheritableThemeFile(virtualPath)) || (styleResult.IsBundle && fileDependencies.Any(x => ThemeHelper.PathIsInheritableThemeFile(x))); if (isThemeableAsset) { var theme = ThemeHelper.ResolveCurrentTheme(); int storeId = ThemeHelper.ResolveCurrentStoreId(); // invalidate the cache when variables change cacheKey = FrameworkCacheConsumer.BuildThemeVarsCacheKey(theme.ThemeName, storeId); if (styleResult.IsSass && (ThemeHelper.IsStyleValidationRequest())) { // Special case: ensure that cached validation result gets nuked in a while, // when ThemeVariableService publishes the entity changed messages. return(new CacheDependency(new string[0], new string[] { cacheKey }, utcStart)); } } var files = ThemingVirtualPathProvider.MapDependencyPaths(fileDependencies); return(new CacheDependency( files, cacheKey == null ? new string[0] : new string[] { cacheKey }, utcStart)); } return(null); }
public MyCalendarDayView(Context context, MyCalendarView calendarView, CalendarViewModel viewModel) : base(context) { _calendarView = calendarView; _viewModel = viewModel; int margin = ThemeHelper.AsPx(Context, 1); Clickable = true; LayoutParameters = new LinearLayout.LayoutParams( LinearLayout.LayoutParams.MatchParent, LinearLayout.LayoutParams.MatchParent); _backgroundView = new View(Context) { LayoutParameters = new FrameLayout.LayoutParams( FrameLayout.LayoutParams.MatchParent, FrameLayout.LayoutParams.MatchParent) { TopMargin = margin, LeftMargin = margin, RightMargin = margin, BottomMargin = margin } }; base.AddView(_backgroundView); _backgroundOverlayView = new View(Context) { LayoutParameters = new FrameLayout.LayoutParams( FrameLayout.LayoutParams.MatchParent, FrameLayout.LayoutParams.MatchParent) { TopMargin = margin, LeftMargin = margin, RightMargin = margin, BottomMargin = margin }, Visibility = ViewStates.Gone }; base.AddView(_backgroundOverlayView); var padding = ThemeHelper.AsPx(Context, 4); _myHomeworkCircles = new MyHomeworkCircles(Context) { LayoutParameters = new FrameLayout.LayoutParams( FrameLayout.LayoutParams.MatchParent, FrameLayout.LayoutParams.WrapContent) { Gravity = GravityFlags.Bottom, LeftMargin = padding, BottomMargin = padding, RightMargin = padding } }; this.AddView(_myHomeworkCircles); _tv = new TextView(Context) { Gravity = GravityFlags.Top | GravityFlags.Right, LayoutParameters = new FrameLayout.LayoutParams( FrameLayout.LayoutParams.MatchParent, FrameLayout.LayoutParams.WrapContent) { TopMargin = ThemeHelper.AsPx(Context, 2), RightMargin = padding } }; _defaultTextColors = _tv.TextColors; this.AddView(_tv); _selectedRectangleView = new View(Context) { LayoutParameters = new FrameLayout.LayoutParams( FrameLayout.LayoutParams.MatchParent, FrameLayout.LayoutParams.MatchParent), Visibility = ViewStates.Gone }; _selectedRectangleView.Background = ContextCompat.GetDrawable(Context, Resource.Drawable.CalendarSelectedDayBorder); ViewCompat.SetBackgroundTintList(_selectedRectangleView, new ColorStateList(new int[][] { new int[0] }, new int[] { new Color(46, 54, 109) })); this.AddView(_selectedRectangleView); this.Click += MyCalendarDayView_Click; UpdateSelectedStatus(); _calendarView.SelectedDateChanged += new WeakEventHandler <EventArgs>(_calendarView_SelectedDateChanged).Handler; }
public string GetCallbackResult() { //return string.Empty; ThemeHelper theme = new ThemeHelper(Theme); if (!Enabled) { return(string.Empty); } mv.Width = DateBoxWidth; mv.BorderStyle = BorderStyle.None; mv.ShowTitle = false; mv.DayRender += MonthViewDayRender; mv.Font.Name = "Tahoma"; mv.DayStyle.MergeWith(theme.DayStyle); mv.DayHeaderStyle.MergeWith(theme.DayStyle); mv.SelectedDayStyle.MergeWith(theme.SelectedDayStyle); mv.TodayDayStyle.MergeWith(theme.TodayDayStyle); //next & prev formats DropDownList list = theme.CreateFooterDropDownList(); //list.MergeStyle(monthYearDropDownStyle); StringBuilder sb = new StringBuilder(); StringWriter writer = new StringWriter(sb); HtmlTextWriter tw = new HtmlTextWriter(writer); if (this.EnableDropShadow) { tw.AddStyleAttribute(HtmlTextWriterStyle.Display, "#EFEFEF"); } tw.AddAttribute(HtmlTextWriterAttribute.Id, "FADatePickerDropShadow_" + this.ClientID); tw.AddStyleAttribute(HtmlTextWriterStyle.ZIndex, (this.ZIndex + 1).ToString()); tw.AddStyleAttribute(HtmlTextWriterStyle.Left, this.CalendarOffsetX.ToString()); tw.AddStyleAttribute(HtmlTextWriterStyle.Top, this.CalendarOffsetY.ToString()); tw.AddStyleAttribute(HtmlTextWriterStyle.Position, "absolute"); tw.AddStyleAttribute(HtmlTextWriterStyle.Display, "inline"); tw.AddStyleAttribute("min-width", this.mv.Width.ToString()); tw.AddAttribute("CellPadding", "0"); tw.AddAttribute("CellSpacing", "0"); tw.RenderBeginTag(HtmlTextWriterTag.Table); tw.RenderBeginTag(HtmlTextWriterTag.Tr); tw.RenderBeginTag(HtmlTextWriterTag.Td); tw.AddStyleAttribute(HtmlTextWriterStyle.BackgroundColor, "white"); tw.AddStyleAttribute(HtmlTextWriterStyle.BorderColor, "gray"); tw.AddStyleAttribute(HtmlTextWriterStyle.BorderStyle, "solid"); tw.AddStyleAttribute(HtmlTextWriterStyle.BorderWidth, "1px"); tw.AddStyleAttribute(HtmlTextWriterStyle.Left, "-4px"); tw.AddStyleAttribute(HtmlTextWriterStyle.Top, "-4px"); tw.AddStyleAttribute(HtmlTextWriterStyle.Width, this.mv.Width.ToString()); tw.AddAttribute(HtmlTextWriterAttribute.Id, "FADatePickerCalendarContainer_" + this.ClientID); tw.AddAttribute("CellPadding", "0"); tw.AddAttribute("CellSpacing", "0"); tw.RenderBeginTag(HtmlTextWriterTag.Table); tw.RenderBeginTag(HtmlTextWriterTag.Tr); tw.RenderBeginTag(HtmlTextWriterTag.Td); Table table = theme.CreateTitleTable(this.Page); table.Width = Unit.Percentage(100.0); table.MergeStyle(this.MonthViewTitleStyle); table.ID = "FADatePickerCalendarTitle_" + this.ClientID; table.RenderBeginTag(tw); tw.RenderBeginTag(HtmlTextWriterTag.Tr); TableCell cell = new TableCell(); cell.Style.Add(HtmlTextWriterStyle.TextAlign, "left"); cell.MergeStyle(this.MonthViewNextPrevStyle); cell.RenderBeginTag(tw); if ((this.mv.VisibleDate.Month > this.MinDate.Month) || (this.mv.VisibleDate.Year > this.MinDate.Year)) { try { DateTime dt = this.mv.VisibleDate.AddMonths(-1); dt = dt.AddDays((double)-(dt.Day - 1)); if (this.NextPrevFormat == NextPrevFormat.ShortMonth) { tw.WriteLine("<div style='cursor:pointer;' onclick=\"javascript:CallServer_" + this.ClientID + "('" + dt.ToShortDateString() + "')\">" + dt.ToString("MMM") + "</div>"); } else if (this.NextPrevFormat == NextPrevFormat.FullMonth) { tw.WriteLine("<div style='cursor:pointer;' onclick=\"javascript:CallServer_" + this.ClientID + "('" + dt.ToShortDateString() + "')\">" + dt.ToString("MMMM") + "</div>"); } else { tw.WriteLine("<div style='cursor:pointer;' onclick=\"javascript:CallServer_" + this.ClientID + "('" + dt.ToShortDateString() + "')\">" + this.PrevMonthText + "</div>"); } } catch { } } cell.RenderEndTag(tw); tw.AddStyleAttribute(HtmlTextWriterStyle.TextAlign, "center"); tw.RenderBeginTag(HtmlTextWriterTag.Td); tw.WriteLine(this.mv.VisibleDate.ToString("MMMM yyyy")); tw.RenderEndTag(); TableCell cell2 = new TableCell(); cell2.Style.Add(HtmlTextWriterStyle.TextAlign, "right"); cell2.MergeStyle(this.MonthViewNextPrevStyle); cell2.RenderBeginTag(tw); if ((this.mv.VisibleDate.Month < this.MaxDate.Month) || (this.mv.VisibleDate.Year < this.MaxDate.Year)) { try { DateTime time9 = this.mv.VisibleDate.AddMonths(1); time9 = time9.AddDays((double)-(time9.Day - 1)); if (this.NextPrevFormat == NextPrevFormat.ShortMonth) { tw.WriteLine("<div style='cursor:pointer;' onclick=\"javascript:CallServer_" + this.ClientID + "('" + time9.ToShortDateString() + "')\">" + time9.ToString("MMM") + "</div>"); } else if (this.NextPrevFormat == NextPrevFormat.FullMonth) { tw.WriteLine("<div style='cursor:pointer;' onclick=\"javascript:CallServer_" + this.ClientID + "('" + time9.ToShortDateString() + "')\">" + time9.ToString("MMMM") + "</div>"); } else { tw.WriteLine("<div style='cursor:pointer;' onclick=\"javascript:CallServer_" + this.ClientID + "('" + time9.ToShortDateString() + "')\">" + this.NextMonthText + "</div>"); } } catch { } } cell2.RenderEndTag(tw); tw.RenderEndTag(); table.RenderEndTag(tw); this.mv.RenderControl(tw); Table table2 = theme.CreateFooterTable(this.Page); table2.ID = string.Format("{0}_Footer", this.ClientID); table2.Style.Add(HtmlTextWriterStyle.TextAlign, "center"); table2.Width = Unit.Percentage(100.0); table2.MergeStyle(this.MonthViewFooterStyle); table2.RenderBeginTag(tw); tw.RenderBeginTag(HtmlTextWriterTag.Tr); tw.RenderBeginTag(HtmlTextWriterTag.Td); if (this.ShowTodayButton) { Button button = theme.CreateFooterButton(); //button.MergeStyle(this.TodayButtonStyle); //button.Text = this.TodayButtonText; button.OnClientClick = "javascript:SetDate_" + this.ClientID + "('" + DateTime.Today.ToString(this.DateFormat) + "'); return false;"; button.RenderControl(tw); } if (this.ShowEmptyButton) { Button button2 = theme.CreateFooterButton(); //button2.MergeStyle(this.TodayButtonStyle); //button2.Text = this.NoneButtonText; button2.OnClientClick = "javascript:SetDate_" + this.ClientID + "(''); return false;"; button2.RenderControl(tw); } list.RenderControl(tw); //list2.RenderControl(tw); tw.RenderEndTag(); tw.RenderEndTag(); table2.RenderEndTag(tw); tw.RenderEndTag(); tw.RenderEndTag(); tw.RenderEndTag(); tw.RenderEndTag(); tw.RenderEndTag(); tw.RenderEndTag(); return(sb.ToString()); }
private static void InitTheme() { ThemeHelper.SetAppTheme(App.Current.RequestedTheme); App.Current.RequestedThemeChanged += (_, e) => ThemeHelper.SetAppTheme(e.RequestedTheme); }
/// <summary> /// Ensure dark theme is applied for the course of a single test. /// </summary> private IDisposable UseDarkTheme() => ThemeHelper.UseDarkTheme();
public MyScheduleItem(Context context, ViewItemSchedule s) : base(context) { Schedule = s; ViewItemClass c = s.Class as ViewItemClass; base.Orientation = Orientation.Vertical; base.Background = new ColorDrawable(ColorTools.GetColor(c.Color)); double hours = (s.EndTime.TimeOfDay - s.StartTime.TimeOfDay).TotalHours; base.LayoutParameters = new RelativeLayout.LayoutParams( RelativeLayout.LayoutParams.MatchParent, (int)Math.Max(HeightOfHour * hours, 0)); var marginSides = ThemeHelper.AsPx(context, 6); var marginBetween = ThemeHelper.AsPx(context, -2); var tvClass = new TextView(context) { Text = c.Name, Typeface = Typeface.DefaultBold }; tvClass.SetTextColor(Color.White); tvClass.SetSingleLine(true); tvClass.SetPadding(marginSides, 0, marginSides, 0); var tvTime = new TextView(context) { Text = PowerPlannerResources.GetStringTimeToTime(DateHelper.ToShortTimeString(s.StartTime), DateHelper.ToShortTimeString(s.EndTime)), Typeface = Typeface.DefaultBold }; tvTime.SetTextColor(Color.White); tvTime.SetSingleLine(true); tvTime.SetPadding(marginSides, marginBetween, marginSides, 0); var tvRoom = new TextView(context) { Text = s.Room, Typeface = Typeface.DefaultBold }; tvRoom.SetTextColor(Color.White); tvRoom.SetPadding(marginSides, marginBetween, marginSides, 0); if (hours >= 1.1) { base.AddView(tvClass); base.AddView(tvTime); base.AddView(tvRoom); } else { LinearLayout firstGroup = new LinearLayout(context); tvClass.LayoutParameters = new LinearLayout.LayoutParams( 0, LinearLayout.LayoutParams.WrapContent) { Weight = 1 }; firstGroup.AddView(tvClass); tvTime.SetPadding(marginSides, 0, marginSides, 0); tvTime.LayoutParameters = new LinearLayout.LayoutParams( LinearLayout.LayoutParams.WrapContent, LinearLayout.LayoutParams.WrapContent); firstGroup.AddView(tvTime); base.AddView(firstGroup); base.AddView(tvRoom); } }
private void AddVisualItem(View visual, DayScheduleItemsArranger.BaseScheduleItem item, DayOfWeek day) { View root; if (item.NumOfColumns > 1) { var grid = new LinearLayout(Context) { LayoutParameters = new LinearLayout.LayoutParams(LinearLayout.LayoutParams.MatchParent, LinearLayout.LayoutParams.WrapContent), Orientation = Orientation.Horizontal }; for (int i = 0; i < item.NumOfColumns; i++) { View colView; if (i == item.Column) { colView = visual; } else { colView = new View(Context); } colView.LayoutParameters = new LinearLayout.LayoutParams(0, LinearLayout.LayoutParams.MatchParent) { Weight = 1 }; grid.AddView(colView); } root = grid; } else { root = visual; } double leftMargin = item.LeftOffset; leftMargin += 12; root.LayoutParameters = new FrameLayout.LayoutParams(LayoutParams.MatchParent, LayoutParams.WrapContent) { LeftMargin = ThemeHelper.AsPx(Context, leftMargin), TopMargin = ThemeHelper.AsPx(Context, item.TopOffset + INITIAL_MARGIN + _currAllDayItemsViewsHeight), RightMargin = ThemeHelper.AsPx(Context, 12), BottomMargin = ThemeHelper.AsPx(Context, 24) }; if (item is DayScheduleItemsArranger.ScheduleItem) { root.LayoutParameters.Height = ThemeHelper.AsPx(Context, item.Height); } ViewGroup viewGroup = _scheduleHost.GetChildAt(getColumn(day)) as ViewGroup; viewGroup.AddView(root); }
public MyAdditionalItemsVisual(Context context) : base(context) { base.SetPaddingRelative(ThemeHelper.AsPx(context, 2), 0, 0, 0); Visibility = ViewStates.Gone; }
public void SetItems(IEnumerable <object> items) { base.RemoveAllViews(); foreach (var i in items) { if (i is BaseViewItemHomeworkExam) { var itemView = new MainCalendarItemView(Context) { Item = i as BaseViewItemHomeworkExam }; (itemView.LayoutParameters as LinearLayout.LayoutParams).RightMargin = ThemeHelper.AsPx(Context, 2); base.AddView(itemView); } else if (i is ViewItemHoliday) { var itemView = new ListItemHolidayScheduleView(Context) { Holiday = i as ViewItemHoliday }; (itemView.LayoutParameters as LinearLayout.LayoutParams).RightMargin = ThemeHelper.AsPx(Context, 2); base.AddView(itemView); } } // Adding a scroll view doesn't seem to work (nested scroll views probably aren't happy), // so we'll just let it be infinitely tall for now. We could add a "tap for more" in the future. HeightInDP = (base.ChildCount) * MainCalendarItemView.TOTAL_HEIGHT_IN_DP; }
public UXRadioButton() { Properties.SetStyleKey(this, "DefaultRadioButtonStyle"); _themer = new ThemeHelper(this); }
private void ThemeCombobox_SelectionChanged(object sender, SelectionChangedEventArgs e) { ThemeHelper.ApplyTheme((sender as ComboBox).SelectedIndex); }
public frmScript(bool forceBlank = false) { InitializeComponent(); ThemeHelper.ExcludeFromTheme(txtScriptContent); txtScriptContent.ForeColor = Color.Black; DebugInfo.ApplyConfig(); List <string> builtInScripts = new List <string> { "DmcCapture.lua", "DrawMode.lua", "Example.lua", "GameBoyMode.lua", "Grid.lua", "LogParallax.lua", "ModifyScreen.lua", "NtscSafeArea.lua", "ReverseMode.lua", "SpriteBox.lua" }; foreach (string script in builtInScripts) { ToolStripItem item = mnuBuiltInScripts.DropDownItems.Add(script); item.Click += (s, e) => { LoadBuiltInScript(item.Text); }; } tsToolbar.AddItemsToToolbar( mnuOpen, mnuSave, null, mnuRun, mnuStop, null, mnuBuiltInScripts ); //Make sure labels are loaded DebugWorkspaceManager.GetWorkspace(); DebugInfo config = ConfigManager.Config.DebugInfo; _popupMenu = new AutocompleteMenu(txtScriptContent, this); _popupMenu.ImageList = new ImageList(); _popupMenu.ImageList.Images.Add(Resources.Enum); _popupMenu.ImageList.Images.Add(Resources.Function); _popupMenu.SelectedColor = Color.LightBlue; _popupMenu.SearchPattern = @"[\w\.]"; List <AutocompleteItem> items = new List <AutocompleteItem>(); _availableFunctions.Sort((a, b) => { int type = a[0].CompareTo(b[0]); if (type == 0) { return(a[1].CompareTo(b[1])); } else { return(-type); } }); foreach (List <string> item in _availableFunctions) { MethodAutocompleteItem autocompleteItem = new MethodAutocompleteItem(item[1]); autocompleteItem.ImageIndex = item[0] == "func" ? 1 : 0; autocompleteItem.ToolTipTitle = item[2]; if (!string.IsNullOrWhiteSpace(item[3])) { autocompleteItem.ToolTipText = "Parameters" + Environment.NewLine + item[3] + Environment.NewLine + Environment.NewLine; } if (!string.IsNullOrWhiteSpace(item[4])) { autocompleteItem.ToolTipText += "Return Value" + Environment.NewLine + item[4] + Environment.NewLine + Environment.NewLine; } if (!string.IsNullOrWhiteSpace(item[5])) { autocompleteItem.ToolTipText += "Description" + Environment.NewLine + item[5] + Environment.NewLine + Environment.NewLine; } items.Add(autocompleteItem); } _popupMenu.Items.SetAutocompleteItems(items); UpdateRecentScripts(); mnuTutorialScript.Checked = config.ScriptStartupBehavior == ScriptStartupBehavior.ShowTutorial; mnuBlankWindow.Checked = config.ScriptStartupBehavior == ScriptStartupBehavior.ShowBlankWindow; mnuAutoLoadLastScript.Checked = config.ScriptStartupBehavior == ScriptStartupBehavior.LoadLastScript; if (!forceBlank) { if (mnuAutoLoadLastScript.Checked && mnuRecentScripts.DropDownItems.Count > 0) { string scriptToLoad = config.RecentScripts.Where((s) => File.Exists(s)).FirstOrDefault(); if (scriptToLoad != null) { LoadScriptFile(scriptToLoad, false); } } else if (mnuTutorialScript.Checked) { LoadBuiltInScript("Example.lua"); } } RestoreLocation(config.ScriptWindowLocation, config.ScriptWindowSize); mnuSaveBeforeRun.Checked = config.SaveScriptBeforeRun; if (config.ScriptCodeWindowHeight >= ctrlSplit.Panel1MinSize) { if (config.ScriptCodeWindowHeight == Int32.MaxValue) { ctrlSplit.CollapsePanel(); } else { ctrlSplit.SplitterDistance = config.ScriptCodeWindowHeight; } } txtScriptContent.Font = new Font(config.ScriptFontFamily, config.ScriptFontSize, config.ScriptFontStyle); txtScriptContent.Zoom = config.ScriptZoom; }
public ctrlNsfPlayer() { InitializeComponent(); ThemeHelper.ExcludeFromTheme(this); }
public ctrlLinkLabel() { ThemeHelper.ExcludeFromTheme(this); }
/// <summary> /// Initializes a new instance of the <see cref="DataWindow"/> class. /// </summary> /// <param name="viewModel">The view model.</param> /// <param name="mode"><see cref="DataWindowMode"/>.</param> /// <param name="additionalButtons">The additional buttons.</param> /// <param name="defaultButton">The default button.</param> /// <param name="setOwnerAndFocus">if set to <c>true</c>, set the main window as owner window and focus the window.</param> /// <param name="infoBarMessageControlGenerationMode">The info bar message control generation mode.</param> /// <param name="focusFirstControl">if set to <c>true</c>, the first control will get the focus.</param> public DataWindow(IViewModel viewModel, DataWindowMode mode, IEnumerable <DataWindowButton> additionalButtons = null, DataWindowDefaultButton defaultButton = DataWindowDefaultButton.OK, bool setOwnerAndFocus = true, InfoBarMessageControlGenerationMode infoBarMessageControlGenerationMode = InfoBarMessageControlGenerationMode.Inline, bool focusFirstControl = true) { if (CatelEnvironment.IsInDesignMode) { return; } // Set window style (WPF doesn't allow styling on root elements of XAML files, too bad) // For more info, see http://social.msdn.microsoft.com/Forums/en-US/wpf/thread/3059c0e4-c372-4da2-b384-28f271feef05/ SetResourceReference(StyleProperty, typeof(DataWindow)); Mode = mode; DefaultButton = defaultButton; _infoBarMessageControlGenerationMode = infoBarMessageControlGenerationMode; this.FixBlurriness(); SizeToContent = SizeToContent.WidthAndHeight; ShowInTaskbar = false; ResizeMode = ResizeMode.NoResize; WindowStartupLocation = WindowStartupLocation.CenterOwner; this.ApplyIconFromApplication(); ThemeHelper.EnsureCatelMvvmThemeIsLoaded(); _logic = new WindowLogic(this, null, viewModel); _logic.TargetViewPropertyChanged += (sender, e) => { // Do not call this for ActualWidth and ActualHeight WPF, will cause problems with NET 40 // on systems where NET45 is *not* installed if (!string.Equals(e.PropertyName, nameof(ActualWidth), StringComparison.InvariantCulture) && !string.Equals(e.PropertyName, nameof(ActualHeight), StringComparison.InvariantCulture)) { PropertyChanged?.Invoke(this, e); } }; _logic.ViewModelClosedAsync += OnViewModelClosedAsync; _logic.ViewModelChanged += (sender, e) => RaiseViewModelChanged(); _logic.ViewModelPropertyChanged += (sender, e) => { OnViewModelPropertyChanged(sender, e); ViewModelPropertyChanged?.Invoke(this, e); }; Loaded += (sender, e) => { _viewLoaded?.Invoke(this, EventArgs.Empty); OnLoaded(e); }; Unloaded += (sender, e) => { _viewUnloaded?.Invoke(this, EventArgs.Empty); OnUnloaded(e); }; SetBinding(TitleProperty, new Binding("Title")); if (additionalButtons != null) { foreach (var button in additionalButtons) { _buttons.Add(button); } } CanClose = true; CanCloseUsingEscape = true; Loaded += (sender, e) => Initialize(); DataContextChanged += (sender, e) => _viewDataContextChanged?.Invoke(this, new DataContextChangedEventArgs(e.OldValue, e.NewValue)); // #1150 Subscribe in dispatcher to allow derived types to be the first handler Dispatcher.BeginInvoke(() => { Closing += OnDataWindowClosing; }); _focusFirstControl = focusFirstControl; if (setOwnerAndFocus) { this.SetOwnerWindowAndFocus(focusFirstControl: focusFirstControl); } else if (focusFirstControl) { this.FocusFirstControl(); } }
private void Application_Startup(object sender, StartupEventArgs e) { Global.StartupDateTime = DateTime.Now; //Unhandled Exceptions. AppDomain.CurrentDomain.UnhandledException += CurrentDomain_UnhandledException; //Increases the duration of the tooltip display. ToolTipService.ShowDurationProperty.OverrideMetadata(typeof(DependencyObject), new FrameworkPropertyMetadata(int.MaxValue)); //Set network connection properties. ServicePointManager.Expect100Continue = true; ServicePointManager.SecurityProtocol = SecurityProtocolType.Tls11 | SecurityProtocolType.Tls12 | SecurityProtocolType.Tls13; //Parse arguments. if (e.Args.Length > 0) { Argument.Prepare(e.Args); } LocalizationHelper.SelectCulture(UserSettings.All.LanguageCode); ThemeHelper.SelectTheme(UserSettings.All.MainTheme.ToString()); //Render mode. RenderOptions.ProcessRenderMode = UserSettings.All.DisableHardwareAcceleration ? RenderMode.SoftwareOnly : RenderMode.Default; #region Net Framework if (!FrameworkHelper.HasFramework()) { var ask = Dialog.Ask(LocalizationHelper.Get("S.Warning.Net.Title"), LocalizationHelper.Get("S.Warning.Net.Header"), LocalizationHelper.Get("S.Warning.Net.Message")); if (ask) { Process.Start("http://go.microsoft.com/fwlink/?LinkId=2085155"); return; } } #endregion #region Net Framework HotFixes //Only runs on Windows 7 SP1. if (Environment.OSVersion.Version.Major == 6 && Environment.OSVersion.Version.Minor == 1) { Task.Factory.StartNew(() => { try { var search = new ManagementObjectSearcher("SELECT HotFixID FROM Win32_QuickFixEngineering WHERE HotFixID = 'KB4055002'").Get(); Global.IsHotFix4055002Installed = search.Count > 0; } catch (Exception ex) { LogWriter.Log(ex, "Error while trying to know if a hot fix was installed."); } }); } #endregion #region Tray icon and view model NotifyIcon = (NotifyIcon)FindResource("NotifyIcon"); if (NotifyIcon != null) { NotifyIcon.Visibility = UserSettings.All.ShowNotificationIcon || UserSettings.All.StartMinimized || UserSettings.All.StartUp == 5 ? Visibility.Visible : Visibility.Collapsed; //Replace the old option with the new setting. if (UserSettings.All.StartUp == 5) { UserSettings.All.StartMinimized = true; UserSettings.All.ShowNotificationIcon = true; UserSettings.All.StartUp = 0; } //using (var iconStream = GetResourceStream(new Uri("pack://application:,,,/Resources/Logo.ico"))?.Stream) //{ // if (iconStream != null) // NotifyIcon.Icon = new System.Drawing.Icon(iconStream); //} } MainViewModel = (ApplicationViewModel)FindResource("AppViewModel") ?? new ApplicationViewModel(); RegisterShortcuts(); #endregion //var select = new SelectFolderDialog(); select.ShowDialog(); return; //var select = new TestField(); select.ShowDialog(); return; //var select = new Encoder(); select.ShowDialog(); return; //var select = new EditorEx(); select.ShowDialog(); return; #region Tasks Task.Factory.StartNew(MainViewModel.ClearTemporaryFilesTask, TaskCreationOptions.LongRunning); Task.Factory.StartNew(MainViewModel.UpdateTask, TaskCreationOptions.LongRunning); Task.Factory.StartNew(MainViewModel.SendFeedback, TaskCreationOptions.LongRunning); #endregion #region Startup //When starting minimized, the if (UserSettings.All.StartMinimized) { return; } if (UserSettings.All.StartUp == 4 || Argument.FileNames.Any()) { MainViewModel.OpenEditor.Execute(null); return; } if (UserSettings.All.StartUp < 1 || UserSettings.All.StartUp > 4) { MainViewModel.OpenLauncher.Execute(null); return; } if (UserSettings.All.StartUp == 1) { MainViewModel.OpenRecorder.Execute(null); return; } if (UserSettings.All.StartUp == 2) { MainViewModel.OpenWebcamRecorder.Execute(null); return; } if (UserSettings.All.StartUp == 3) { MainViewModel.OpenBoardRecorder.Execute(null); } #endregion }