public void SaveChanges() { returnBindingSource.EndEdit(); var newReturnNo = InventoryHelper.GetNextReturnNo(); itemReturn.ReturnNo = newReturnNo; itemReturn.StatusId = InventoryHelper.STATUS_PENDING; try { context.ItemReturns.AddObject(itemReturn); context.SaveChanges(); var obj = context.ItemReturns.Single(r => r.ReturnNo == newReturnNo); this.ReturnId = obj.ReturnId; this.DialogResult = DialogResult.OK; InventoryHelper.UpdateReturnNo(newReturnNo); } catch (Exception exception) { ViewHelper.ShowErrorMessage("Error saving new return record.", exception); } }
private double GetLogicalStatusBarHeight() { var logicalStatusBarHeight = 0d; var activity = ContextHelper.Current as Activity; var decorView = activity.Window.DecorView; var isStatusBarVisible = ((int)decorView.SystemUiVisibility & (int)SystemUiFlags.Fullscreen) == 0; var isStatusBarTranslucent = ((int)activity.Window.Attributes.Flags & (int)WindowManagerFlags.TranslucentStatus) != 0 || ((int)activity.Window.Attributes.Flags & (int)WindowManagerFlags.LayoutNoLimits) != 0; if (isStatusBarVisible && isStatusBarTranslucent) { int resourceId = Android.Content.Res.Resources.System.GetIdentifier("status_bar_height", "dimen", "android"); if (resourceId > 0) { logicalStatusBarHeight = ViewHelper.PhysicalToLogicalPixels(Android.Content.Res.Resources.System.GetDimensionPixelSize(resourceId)); } } return(logicalStatusBarHeight); }
public Rect MakeVisible(UIElement visual, Rect rectangle) { if (visual is FrameworkElement fe) { var scrollRect = new Rect( _occludedRectPadding.Left, _occludedRectPadding.Top, ActualWidth - _occludedRectPadding.Right, ActualHeight - _occludedRectPadding.Bottom ); var visualPoint = UIElement.TransformToVisual(visual, null).TransformPoint(new Point()); var visualRect = new Rect(visualPoint, new Size(fe.ActualWidth, fe.ActualHeight)); var deltaX = Math.Min(visualRect.Left - scrollRect.Left, Math.Max(0, visualRect.Right - scrollRect.Right)); var deltaY = Math.Min(visualRect.Top - scrollRect.Top, Math.Max(0, visualRect.Bottom - scrollRect.Bottom)); NativePanel.SmoothScrollBy(ViewHelper.LogicalToPhysicalPixels(deltaX), ViewHelper.LogicalToPhysicalPixels(deltaY)); } return(rectangle); }
public void SaveChanges() { issueBindingSource.EndEdit(); var newIssueNo = InventoryHelper.GetNextIssueNo(); issue.IssueNo = newIssueNo; issue.StatusId = InventoryHelper.STATUS_PENDING; try { context.Issues.AddObject(issue); context.SaveChanges(); var obj = context.Issues.Single(i => i.IssueNo == newIssueNo); this.IssueId = obj.IssueId; this.DialogResult = DialogResult.OK; InventoryHelper.UpdateIssueNo(newIssueNo); } catch (Exception exception) { ViewHelper.ShowErrorMessage("Error saving new issue record.", exception); } }
public void Can_Perform_Add_View_With_Default_Content() { // Arrange using (ScopeProvider.CreateScope()) { var repository = CreateRepository(ScopeProvider); // Act var template = new Template("test", "test") { Content = ViewHelper.GetDefaultFileContent() }; repository.Save(template); //Assert Assert.That(repository.Get("test"), Is.Not.Null); Assert.That(_fileSystems.MvcViewsFileSystem.FileExists("test.cshtml"), Is.True); Assert.AreEqual( @"@inherits Umbraco.Web.Mvc.UmbracoViewPage @{ Layout = null;}".StripWhitespace(), template.Content.StripWhitespace()); } }
/// <summary> /// Shows the document in the main shell. /// </summary> /// <typeparam name="TViewModel">The type of the view model.</typeparam> /// <param name="viewModel">The view model to show which will automatically be resolved to a view.</param> /// <param name="tag">The tag.</param> /// <exception cref="ArgumentNullException">The <paramref name="viewModel"/> is <c>null</c>.</exception> public void ShowDocument <TViewModel>(TViewModel viewModel, object tag = null) where TViewModel : IViewModel { Argument.IsNotNull("viewModel", viewModel); Log.Debug("Showing document for view model '{0}'", viewModel.UniqueIdentifier); var viewLocator = GetService <IViewLocator>(); var viewType = viewLocator.ResolveView(viewModel.GetType()); var document = AvalonDockHelper.FindDocument(viewType, tag); if (document == null) { var view = ViewHelper.ConstructViewWithViewModel(viewType, viewModel); document = AvalonDockHelper.CreateDocument(view, tag); } AvalonDockHelper.ActivateDocument(document); Log.Debug("Showed document for view model '{0}'", viewModel.UniqueIdentifier); }
protected override void OnCreate(Bundle savedInstanceState) { base.OnCreate(savedInstanceState); SetContentView(Resource.Layout.layout_setup); Inject(); nvMain.NavigationItemSelected += OnNavItemSelected; ViewHelper.InflateSetupOptions(liMain, nvMain); int intentOption = Intent.GetIntExtra(Constants.INTENT_HDMI_CEC_SETUP, -1); if (intentOption >= 0) { nvMain.PostDelayed((() => { OnOptionSelected(intentOption); }), 200); } OpenBroadcast(); }
public void DeleteObject() { tireBindingSource.EndEdit(); usageHistoryBindingSource.EndEdit(); try { var result = ViewHelper.ShowConfirmDialog( "Are you sure you want to delete the current tire and its associated data?"); if (result == DialogResult.Yes) { context.Tires.DeleteObject(tire); context.SaveChanges(); this.Close(); } } catch (Exception exception) { ViewHelper.ShowErrorMessage("Error deleting tire information", exception); } }
public void ViewHelperShouldWrapDocumentOwnerIfDependencyObject_Test_T122209() { var button = new Button(); var viewModel = new ViewModel(); var parentViewModel = new ViewModel(); IDocumentOwner owner = new TestDocumentOwner(); button.DataContext = viewModel; ViewHelper.InitializeView(button, null, "test", parentViewModel, owner); Assert.AreEqual(owner, viewModel.DocumentOwner); Assert.AreEqual(owner, ViewModelExtensions.GetDocumentOwner(button)); button = new Button(); button.DataContext = viewModel; owner = new TestServiceDocumentOwner(); ViewHelper.InitializeView(button, null, "test", parentViewModel, owner); ViewHelper.DocumentOwnerWrapper ownerWrapper = viewModel.DocumentOwner as ViewHelper.DocumentOwnerWrapper; Assert.IsNotNull(ownerWrapper); Assert.IsTrue(ownerWrapper.Equals(owner)); Assert.AreEqual(owner, ownerWrapper.ActualOwner); Assert.AreEqual(ownerWrapper, ViewModelExtensions.GetDocumentOwner(button)); }
protected internal override void onTransform(View view, float position) { if (position >= -1 || position <= 1) { // Modify the default slide transition to shrink the page as well //JAVA TO C# CONVERTER WARNING: The original Java variable was marked 'final': //ORIGINAL LINE: final float height = view.getHeight(); float height = view.Height; //JAVA TO C# CONVERTER WARNING: The original Java variable was marked 'final': //ORIGINAL LINE: final float scaleFactor = Math.max(MIN_SCALE, 1 - Math.abs(position)); float scaleFactor = Math.Max(MIN_SCALE, 1 - Math.Abs(position)); //JAVA TO C# CONVERTER WARNING: The original Java variable was marked 'final': //ORIGINAL LINE: final float vertMargin = height * (1 - scaleFactor) / 2; float vertMargin = height * (1 - scaleFactor) / 2; //JAVA TO C# CONVERTER WARNING: The original Java variable was marked 'final': //ORIGINAL LINE: final float horzMargin = view.getWidth() * (1 - scaleFactor) / 2; float horzMargin = view.Width * (1 - scaleFactor) / 2; // Center vertically ViewHelper.SetPivotY(view, 0.5f * height); if (position < 0) { ViewHelper.SetTranslationX(view, horzMargin - vertMargin / 2); } else { ViewHelper.SetTranslationX(view, -horzMargin + vertMargin / 2); } // Scale the page down (between MIN_SCALE and 1) ViewHelper.SetScaleX(view, scaleFactor); ViewHelper.SetScaleY(view, scaleFactor); // Fade the page relative to its size. ViewHelper.SetAlpha(view, MIN_ALPHA + (scaleFactor - MIN_SCALE) / (1 - MIN_SCALE) * (1 - MIN_ALPHA)); } }
//TODO generated code - but note call of base.OnMeasure protected override void OnMeasure(int widthMeasureSpec, int heightMeasureSpec) { var availableSize = ViewHelper.LogicalSizeFromSpec(widthMeasureSpec, heightMeasureSpec); if (!double.IsNaN(Width) || !double.IsNaN(Height)) { availableSize = new Size( double.IsNaN(Width) ? availableSize.Width : Width, double.IsNaN(Height) ? availableSize.Height : Height ); } var measuredSize = _layouter.Measure(availableSize); //We call ViewPager.OnMeasure here, because it creates the page views. base.OnMeasure( ViewHelper.SpecFromLogicalSize(measuredSize.Width), ViewHelper.SpecFromLogicalSize(measuredSize.Height) ); IFrameworkElementHelper.OnMeasureOverride(this); }
public void SaveChanges() { transferBindingSource.EndEdit(); var newTransferNo = InventoryHelper.GetNextTransferNo(); transfer.TransferNo = newTransferNo; transfer.StatusId = InventoryHelper.STATUS_PENDING; try { context.Transfers.AddObject(transfer); context.SaveChanges(); var obj = context.Transfers.Single(t => t.TransferNo == newTransferNo); this.TransferId = obj.TransferId; this.DialogResult = DialogResult.OK; InventoryHelper.UpdateTransferNo(newTransferNo); } catch (Exception exception) { ViewHelper.ShowErrorMessage("Error saving new stock transfer record.", exception); } }
/// <summary> /// This creates the window of the specified type. /// </summary> /// <param name="windowType">The type of the window.</param> /// <param name="data">The data that will be set as data context.</param> /// <param name="completedProc">The completed callback.</param> /// <param name="isModal">True if this is a ShowDialog request.</param> /// <returns>The created window.</returns> protected virtual FrameworkElement CreateWindow(Type windowType, object data, EventHandler <UICompletedEventArgs> completedProc, bool isModal) { var window = ViewHelper.ConstructViewWithViewModel(windowType, data); #if NET if (isModal) { var activeWindow = GetActiveWindow(); if (window != activeWindow) { PropertyHelper.TrySetPropertyValue(window, "Owner", activeWindow, false); } } #endif if ((window != null) && (completedProc != null)) { HandleCloseSubscription(window, data, completedProc, isModal); } return(window); }
public async Task <IActionResult> CancelSave(KanbanRequest model) { bool status = false; if (string.IsNullOrEmpty(model.CancelNote)) { ModelState.AddModelError("CancelNote", "The Cancel Note field is required"); } //if (ModelState.IsValid) else { KanbanRequest data = await DbContext.KanbanRequest.Where(a => a.KanbanReqId == model.KanbanReqId).FirstOrDefaultAsync(); try { if (data == null) { return(NotFound()); } else { data.CancelNote = model.CancelNote; data.StatusId = 2; data.EditDate = DateTime.Now; data.EditBy = LoginInfo.UserId; DbContext.KanbanRequest.Update(data); DbContext.SaveChanges(); status = true; } } catch (Exception e) { LogHelp.WriteErrorLog(e); } } IndexPrep(); return(Json(new { status, html = ViewHelper.RenderRazorViewToString(this, "CancelNote", model) })); //return Json(new { status }); }
public JsonResult BillingDocument(MSTInvoiceBillingReportingViewModel iModel) { BillingNumberItemDTO[] billingNumber; try { var dateFrom = DictionaryHelper.KendoDatePickerDateStringToDateTime(iModel.DateFromValue); var dateTo = DictionaryHelper.KendoDatePickerDateStringToDateTime(iModel.DateToValue); billingNumber = WCFClientManager.SAPServiceClient.QueryBillingNumbers(UserManagementHelper.GetSessionId(), iModel.SoldToFromValue, dateFrom, dateTo); } catch (Exception) { return(Json(new { html = ErrorResource.WCFCannotGetObjectHTML })); } var viewModel = BillingReportingHelper.GeneratePopupBillingDocumentViewModel(billingNumber, iModel); var renderedHtml = ViewHelper.RenderPartialViewToString(this, "_PartialPopupBillingDocumentListBilling", viewModel); return(Json(new { html = renderedHtml })); }
private void MountUnmountTire() { // If tire is currently mounted: // 1. Change status of the tire to Unmounted // 2. Request user to provide information regarding unmounted milage, date and remark // 3. Refresh usage history grid. if (tire.Status == FleetHelper.TIRE_STATUS_MOUNTED) { var result = ViewHelper.ShowConfirmDialog( "This tire is currently mounted and in use. Do you want to UnMount it?"); if (result == DialogResult.Yes) { ShowTireTransaction(); } } else { ShowTireTransaction(); } }
public void RemoveAndSelection3Test() { Person harry = new Person() { Firstname = "Harry" }; Person ron = new Person() { Firstname = "Ron" }; Person ginny = new Person() { Firstname = "Ginny" }; IEntityService entityService = Container.GetExportedValue <IEntityService>(); entityService.Persons.Add(harry); entityService.Persons.Add(ron); entityService.Persons.Add(ginny); PersonController personController = Container.GetExportedValue <PersonController>(); personController.Initialize(); MockPersonListView personListView = Container.GetExportedValue <MockPersonListView>(); PersonListViewModel personListViewModel = ViewHelper.GetViewModel <PersonListViewModel>(personListView); personListViewModel.PersonCollectionView = personListViewModel.Persons; // Remove all persons and check that nothing is selected anymore personListViewModel.SelectedPerson = harry; personListViewModel.AddSelectedPerson(harry); personListViewModel.AddSelectedPerson(ron); personListViewModel.AddSelectedPerson(ginny); personListViewModel.RemoveCommand.Execute(null); Assert.IsFalse(entityService.Persons.Any()); Assert.IsNull(personListViewModel.SelectedPerson); }
public ResponseModel Registrar(Publicacion publicacion) { using (var context = new RedSocialContext()) { try { // Llenamos los valores que faltan publicacion.FechaRegistro = ViewHelper.getDate(true); context.Publicacion.Add(publicacion); context.SaveChanges(); rm.SetResponse(true); } catch (Exception e) { ELog.Save(this, e); } } return(rm); }
protected override IView OnConvertToView(FigmaNode currentNode, ViewNode parentNode, ViewRenderService rendererService) { var combobox = new NSComboBox(); var frame = (FigmaFrame)currentNode; frame.TryGetNativeControlVariant(out var controlVariant); combobox.ControlSize = ViewHelper.GetNSControlSize(controlVariant); combobox.Font = ViewHelper.GetNSFont(controlVariant); FigmaText text = frame.children .OfType <FigmaText> () .FirstOrDefault(s => s.name == ComponentString.TITLE); if (text != null && !string.IsNullOrEmpty(text.characters)) { combobox.StringValue = rendererService.GetTranslatedText(text); } return(new View(combobox)); }
private void PostReceiving() { var confirm = ViewHelper.ShowConfirmDialog(@"This action is irreversible. Are you sure you want to continue?"); if (confirm == DialogResult.No || confirm == DialogResult.Cancel) { return; } try { if (receiving.IsValid() && receiving.IsSavable()) { SaveChanges(); InventoryHelper.PostReceiving(receiving.ReceivingId); ViewHelper.ShowSuccessMessage("Receiving posted successfully"); } } catch (Exception exception) { ViewHelper.ShowErrorMessage(exception.Message, exception.InnerException); } }
private void createCommand_Click(object sender, EventArgs e) { userBindingSource.EndEdit(); if (!ValidateForm()) { return; } try { newuser.SetPassword(newuser.Password); newuser.IsActive = true; newuser.CreatedDate = Security.Helpers.DateTimeHelper.ServerDateTime; repository.Users.Add(newuser); ViewHelper.ShowSuccessMessage("New user created successfully!"); this.DialogResult = DialogResult.OK; this.Close(); } catch (Exception ex) { ViewHelper.ShowErrorMessage("Unable to create new user", ex); } }
protected override void OnMeasure(int widthMeasureSpec, int heightMeasureSpec) { // Ensure the stretching of Content is taken into account var element = Content as FrameworkElement; if (element != null) { element.StretchAffectsMeasure = true; } // Drawer layout must be measured with MeasureSpecMode.Exactly otherwise an exception is thrown base.OnMeasure( ViewHelper.MakeMeasureSpec( ViewHelper.MeasureSpecGetSize(widthMeasureSpec), MeasureSpecMode.Exactly ), ViewHelper.MakeMeasureSpec( ViewHelper.MeasureSpecGetSize(heightMeasureSpec), MeasureSpecMode.Exactly ) ); }
public void SaveChanges() { receivingBindingSource.EndEdit(); var newGrn = InventoryHelper.GetNextGrnNo(); receiving.GRN = newGrn; receiving.StatusId = InventoryHelper.STATUS_PENDING; try { context.Receivings.AddObject(receiving); context.SaveChanges(); var obj = context.Receivings.Single(r => r.GRN == newGrn); this.NewReceivingId = obj.ReceivingId; this.DialogResult = DialogResult.OK; InventoryHelper.UpdateGRNumber(newGrn); } catch (Exception exception) { ViewHelper.ShowErrorMessage("Error saving new receiving record.", exception); } }
public TemplateDisplay GetScaffold(int id) { //empty default var dt = new Template("", ""); dt.Path = "-1"; if (id > 0) { var master = Services.FileService.GetTemplate(id); if (master != null) { dt.SetMasterTemplate(master); } } var content = ViewHelper.GetDefaultFileContent(layoutPageAlias: dt.MasterTemplateAlias); var scaffold = Mapper.Map <ITemplate, TemplateDisplay>(dt); scaffold.Content = content + "\r\n\r\n@* the fun starts here *@\r\n\r\n"; return(scaffold); }
internal void RaiseNativeSizeChanged() { var display = (ContextHelper.Current as Activity)?.WindowManager?.DefaultDisplay; var fullScreenMetrics = new DisplayMetrics(); // To get the real size of the screen, we should use GetRealMetrics // GetMetrics or Resources.DisplayMetrics return the usable metrics, ignoring the bottom rounded space on device like LG G7 ThinQ for example display?.GetRealMetrics(outMetrics: fullScreenMetrics); var newBounds = ViewHelper.PhysicalToLogicalPixels(new Rect(0, 0, fullScreenMetrics.WidthPixels, fullScreenMetrics.HeightPixels)); var statusBarHeight = GetLogicalStatusBarHeight(); var navigationBarHeight = GetLogicalNavigationBarHeight(); var newVisibleBounds = new Rect( x: newBounds.X, y: newBounds.Y + statusBarHeight, width: newBounds.Width, height: newBounds.Height - statusBarHeight - navigationBarHeight ); var applicationView = ApplicationView.GetForCurrentView(); if (applicationView != null && applicationView.VisibleBounds != newVisibleBounds) { applicationView.SetCoreBounds(newVisibleBounds); } if (Bounds != newBounds) { Bounds = newBounds; RaiseSizeChanged( new WindowSizeChangedEventArgs( new Windows.Foundation.Size(Bounds.Width, Bounds.Height) ) ); } }
protected override void OnDraw(Canvas canvas) { base.OnDraw(canvas); if (numberIndicatorResize == false) { RelativeLayout.LayoutParams lp = (LayoutParams)slider.numberIndicator.numberIndicator.LayoutParameters; lp.Height = (int)finalSize * 2; lp.Width = (int)finalSize * 2; slider.numberIndicator.numberIndicator.LayoutParameters = lp; } Paint paint = new Paint(); paint.AntiAlias = true; paint.Color = slider.backgroundColor; if (animate) { if (y == 0) { y = finalY + finalSize * 2; } y -= Utils.DpToPx(6, Resources); size += Utils.DpToPx(2, Resources); } canvas.DrawCircle(ViewHelper.GetX(slider.ball) + Utils.GetRelativeLeft((View)slider.ball.Parent) + slider.ball.Width / 2, y, size, paint); if (animate && size >= finalSize) { animate = false; } if (animate == false) { ViewHelper.SetX(slider.numberIndicator.numberIndicator, (ViewHelper.GetX(slider.ball) + Utils.GetRelativeLeft((View)slider.ball.Parent) + slider.ball.Width / 2) - size); ViewHelper.SetY(slider.numberIndicator.numberIndicator, y - size); slider.numberIndicator.numberIndicator.Text = slider.val.ToString() + ""; } slider.Invalidate(); }
private void GetTaskDetails(TaskStatisticsResult result) { try { this.applicationsList.BeginUpdate(); this.applicationsList.Items.Clear(); int appActiveTime = 0; foreach (ApplicationSummary applicationsSummaryRow in result.AppsSummaryList) { appActiveTime += (int)applicationsSummaryRow.TotalActiveTime; } foreach (ApplicationSummary applicationsSummaryRow in result.AppsSummaryList) { TimeSpan active = new TimeSpan(0, 0, (int)applicationsSummaryRow.TotalActiveTime); string activeTime = ViewHelper.TimeSpanToTimeString(active); double percent = 0; if (appActiveTime > 0) { percent = applicationsSummaryRow.TotalActiveTime / appActiveTime; } TreeListViewItem lvi = new TreeListViewItem(applicationsSummaryRow.Name, new string[] { activeTime, percent.ToString("0.0%", CultureInfo.InvariantCulture), applicationsSummaryRow.TaskId.ToString(CultureInfo.InvariantCulture) }); lvi.ImageIndex = IconsManager.GetIconFromFile(applicationsSummaryRow.ApplicationFullPath); this.applicationsList.Items.Add(lvi); } AppsActiveTimeValue.Text = ViewHelper.TimeSpanToTimeString(new TimeSpan(0, 0, appActiveTime)); } finally { this.applicationsList.EndUpdate(); SetReadyState(); } }
private void EditPop3EmailAccountDialog(MockEditEmailAccountView editEmailAccountView) { var editEmailAccountViewModel = ViewHelper.GetViewModel <EditEmailAccountViewModel>(editEmailAccountView) !; // Get the first page of the wizard var basicEmailAccountView = (MockBasicEmailAccountView)editEmailAccountViewModel.ContentView; var basicEmailAccountViewModel = ViewHelper.GetViewModel <BasicEmailAccountViewModel>(basicEmailAccountView) !; // We are on the first page thus it is not possible to go back Assert.IsFalse(editEmailAccountViewModel.BackCommand.CanExecute(null)); Assert.IsFalse(editEmailAccountViewModel.IsLastPage); // Simulate that a validation error occurred. We are not allowed to click on next. AssertHelper.CanExecuteChangedEvent(editEmailAccountViewModel.NextCommand, () => editEmailAccountViewModel.IsValid = false); Assert.IsFalse(editEmailAccountViewModel.NextCommand.CanExecute(null)); // Select a Pop3 account and call the next command editEmailAccountViewModel.IsValid = true; basicEmailAccountViewModel.IsPop3Checked = true; editEmailAccountViewModel.NextCommand.Execute(null); // We are now on the Pop3 settings page; call the back command Assert.IsInstanceOfType(editEmailAccountViewModel.ContentView, typeof(MockPop3SettingsView)); Assert.IsTrue(editEmailAccountViewModel.IsLastPage); AssertHelper.CanExecuteChangedEvent(editEmailAccountViewModel.BackCommand, () => editEmailAccountViewModel.BackCommand.Execute(null)); // We are back on the first page; call the next command Assert.AreEqual(basicEmailAccountView, editEmailAccountViewModel.ContentView); Assert.IsFalse(editEmailAccountViewModel.IsLastPage); AssertHelper.CanExecuteChangedEvent(editEmailAccountViewModel.BackCommand, () => editEmailAccountViewModel.NextCommand.Execute(null)); // We are now again on the Pop3 settings page; call the next command Assert.IsInstanceOfType(editEmailAccountViewModel.ContentView, typeof(MockPop3SettingsView)); editEmailAccountViewModel.NextCommand.Execute(null); // The wizard is finished Assert.IsFalse(editEmailAccountView.IsVisible); }
/// <summary> /// This checks what the default rendering engine is set in config but then also ensures that there isn't already /// a template that exists in the opposite rendering engine's template folder, then returns the appropriate /// rendering engine to use. /// </summary> /// <returns></returns> /// <remarks> /// The reason this is required is because for example, if you have a master page file already existing under ~/masterpages/Blah.aspx /// and then you go to create a template in the tree called Blah and the default rendering engine is MVC, it will create a Blah.cshtml /// empty template in ~/Views. This means every page that is using Blah will go to MVC and render an empty page. /// This is mostly related to installing packages since packages install file templates to the file system and then create the /// templates in business logic. Without this, it could cause the wrong rendering engine to be used for a package. /// </remarks> public RenderingEngine DetermineTemplateRenderingEngine(ITemplate template) { var engine = _templateConfig.DefaultRenderingEngine; var viewHelper = new ViewHelper(_viewsFileSystem); if (!viewHelper.ViewExists(template)) { if (template.Content.IsNullOrWhiteSpace() == false && MasterPageHelper.IsMasterPageSyntax(template.Content)) { //there is a design but its definitely a webforms design and we haven't got a MVC view already for it return(RenderingEngine.WebForms); } } var masterPageHelper = new MasterPageHelper(_masterpagesFileSystem); switch (engine) { case RenderingEngine.Mvc: //check if there's a view in ~/masterpages if (masterPageHelper.MasterPageExists(template) && viewHelper.ViewExists(template) == false) { //change this to webforms since there's already a file there for this template alias engine = RenderingEngine.WebForms; } break; case RenderingEngine.WebForms: //check if there's a view in ~/views if (viewHelper.ViewExists(template) && masterPageHelper.MasterPageExists(template) == false) { //change this to mvc since there's already a file there for this template alias engine = RenderingEngine.Mvc; } break; } return(engine); }
protected override StringBuilder OnConvertToCode(CodeNode currentNode, CodeNode parentNode, CodeRenderService rendererService) { var code = new StringBuilder(); string name = FigmaSharp.Resources.Ids.Conversion.NameIdentifier; var frame = (FigmaFrame)currentNode.Node; currentNode.Node.TryGetNativeControlType(out FigmaControlType controlType); currentNode.Node.TryGetNativeControlVariant(out NativeControlVariant controlVariant); if (rendererService.NeedsRenderConstructor(currentNode, parentNode)) { code.WriteConstructor(name, GetControlType(currentNode.Node), rendererService.NodeRendersVar(currentNode, parentNode)); } code.WritePropertyEquality(name, nameof(NSButton.BezelStyle), NSBezelStyle.Rounded); if (controlType == FigmaControlType.PopUpButtonPullDown) { code.WritePropertyEquality(name, nameof(NSPopUpButton.PullsDown), true); } code.WritePropertyEquality(name, nameof(NSButton.ControlSize), ViewHelper.GetNSControlSize(controlVariant)); code.WritePropertyEquality(name, nameof(NSSegmentedControl.Font), CodeHelper.GetNSFontString(controlVariant)); FigmaText text = frame.children .OfType <FigmaText>() .FirstOrDefault(s => s.name == ComponentString.TITLE); if (text != null && !string.IsNullOrEmpty(text.characters)) { var stringLabel = rendererService.GetTranslatedText(text); code.WriteMethod(name, nameof(NSPopUpButton.AddItem), stringLabel, inQuotes: !rendererService.Options.TranslateLabels); } return(code); }
/// <summary> /// Return a virtual path (with ~) for a given view in the current site's Theme folder /// </summary> /// <param name="templateFile"></param> /// <returns></returns> public string GetViewVirtualPath(ViewHelper.TemplateFile templateFile) { if (Context.CurrentSite.Theme != null) { return string.Concat(Context.CurrentSite.Theme.BasePath, "/", templateFile.ToString().Replace("_", ""), ".cshtml"); } return templateFile.ToString(); }