i have several AreaRegistration classes which one each registers own routes and each one have some duplicated elements such as bolded text in below:
context.MapRoute("Search", "**{culture}/{style}**/search",
new
{
**culture = cultureValue,
style = styleValue,**
controller = "search",
action = "default"
},
new
{
**culture = new CultureRouteConstraint(),
style = new StyleRouteConstraint()**
});
how i can have minimum AreaRegistrations with putting duplicated elements in single place which handles that? this is possible?
You can add routes to the Global.asax file and use the area route value. For example:
routes.MapRoute("Search", "{culture}/{style}/search", new
{
culture = cultureValue,
style = styleValue,
controller = "search",
action = "default",
area = "areaName"
});
Related
I wish to change the layout_strategy for the telescope plugin from the NvChad default value of horizontal to vertical. This should be possible by setting layout_strategy = "vertical" somewhere...
According to the NvChad docs I can override the default settings specified in plugins/configs/telescope.lua in my own custom/init.lua, but I also found that it could/should be done in the custom/chadrc.lua.
Question
What line(s) do I have to add to what file to change the default layout_strategy for the telescope plugin, and only that (keeping other defaults intact)?
I have tried adding to
custom/chadrc.lua
M.telescope = {
layout_strategy = "vertical"
}
Also tried
M.telescope = {
defaults = {
layout_strategy = "vertical",
},
}
}
and
local o = vim.telescope.defaults
o.layout_strategy = "vertical"
But that does not seem to work.
In your chadrc.lua you would override options like so:
M.plugins = {
-- ...
["nvim-telescope/telescope.nvim"] = {
override_options = function()
return {
defaults = {
layout_strategy = "vertical",
layout_config = {
height = 0.95,
prompt_position = "top",
vertical = {
mirror = true,
preview_cutoff = 0,
},
},
},
}
end,
},
-- ...
}
I included my additional layout_config in case you want to have the preview part in the bottom half. Also preview_cutoff was necessary for me or the preview would never show up.
Essentially, the returned table of override_options will forcefully extend the default configs provided by NvChad and the result table would be passed into the setup function of the plugin.
Defining override_options is the way to go for pre-installed plugins of NvChad. If you deal with a new custom plugin, you'd rather need to call the setup function of the plugin on your own in the config function of the plugin declaration like so:
M.plugins = {
-- ...
["any-vendor/any-custom-plugin.nvim"] = {
config = function()
require('custom-plugin').setup({
-- ...
})
end,
},
-- ...
}
This is not relevant for telescope.nvim, since it is pre-installed, but I wanted to address this for completeness anyways.
Is there a way to copy a chart control to a new form?
I have a Windows Form with a chart control on it, but the form is not allowed to be resizable. For that reason I have a button "Zoom" that opens the chart in a new form that is resizable. I have set a lot of chart properties in the "original" chart (axis color, axis intervalls etc.) and would like to just reuse this properties. I tried to call the constructor of the new form with the chart as parameter, but that didn't work.
public ZoomChartSeriesForm(Chart myChart)
My main problem is, that I allow zooming inside of the chart and that crashes, when I just copy the chart.
Here is the code of my "original chart" (example):
System.Drawing.Color color = System.Drawing.Color.Red;
//plot new doublelist
var series = new Series
{
Name = "Series2",
Color = color,
ChartType = SeriesChartType.Line,
ChartArea = "ChartArea1",
IsXValueIndexed = true,
};
this.chart1.Series.Add(series);
List<double> doubleList = new List<double>();
doubleList.Add(1.0);
doubleList.Add(5.0);
doubleList.Add(3.0);
doubleList.Add(1.0);
doubleList.Add(4.0);
series.Points.DataBindY(doubleList);
var chartArea = chart1.ChartAreas["ChartArea1"];
LabelStyle ls = new LabelStyle();
ls.ForeColor = color;
Axis a = chartArea.AxisY;
a.TitleForeColor = color; //color of axis title
a.MajorTickMark.LineColor = color; //color of ticks
a.LabelStyle = ls; //color of tick labels
chartArea.Visible = true;
chartArea.AxisY.Title = "TEST";
chartArea.RecalculateAxesScale();
chartArea.AxisX.Minimum = 1;
chartArea.AxisX.Maximum = doubleList.Count;
// Set automatic scrolling
chartArea.CursorX.AutoScroll = true;
chartArea.CursorY.AutoScroll = true;
// Allow user to select area for zooming
chartArea.CursorX.IsUserEnabled = true;
chartArea.CursorX.IsUserSelectionEnabled = true;
chartArea.CursorY.IsUserEnabled = true;
chartArea.CursorY.IsUserSelectionEnabled = true;
// Set automatic zooming
chartArea.AxisX.ScaleView.Zoomable = true;
chartArea.AxisY.ScaleView.Zoomable = true;
chartArea.AxisX.ScrollBar.IsPositionedInside = true;
chartArea.AxisY.ScrollBar.IsPositionedInside = true;
//reset zoom
chartArea.AxisX.ScaleView.ZoomReset();
chartArea.AxisY.ScaleView.ZoomReset();
chart1.Invalidate();
Copy as in deep copying the object?
I ran into this exact problem recently myself. Unfortunately, MS Chart has no method to clone their chart object and their class is not marked as serializable so you can't use the method suggested here.
If you want to do this the right way, you'll have to introduce a third party control such as Copyable or handle the reflection yourself, but this won't be easy.
A really nice workaround I found is to use the built-in serialization inside MS Chart control. The idea is to serialize the chart using memorystream, create a new instance of the chart and deserialize the chart.
private Chart CloneChart(Chart chart)
{
MemoryStream stream = new MemoryStream();
Chart clonedChart = chart;
clonedChart.Serializer.Save(stream);
clonedChart = new Chart();
clonedChart.Serializer.Load(stream);
return clonedChart;
}
Not exactly an efficient solution, but if performance isn't your priority, this works like a charm.
I have a probably rather basic problem in OpenLayers, it would be really great if someone could help me out on this one.
I have an array of markers, which should each have a different popup box text. However, I fail in applying the according text to a marker. I tried to do this via another array for the content of the popup boxes. However, i couldn't relate the correct text to a marker. Here is my code:
var vs_locations = [
[13.045240, 47.8013271],
[13.145240, 47.8013271],
[13.245240, 47.8013271],
];
var popupContentHTML = [
"Text for marker with loc[0]",
"Text for marker with loc[1]",
"Text for marker with loc[2]"
];
function addVS(){
for (var i = 0; i < vs_locations.length;i++){
var loc = vs_locations[i];
var feature = new OpenLayers.Feature(volksschulen, new OpenLayers.LonLat(loc[0],loc[1],loc[2]).transform(proj4326,proj900913));
feature.closeBox = true;
feature.data.icon = new OpenLayers.Icon('coffeehouse.png');
feature.popupClass = OpenLayers.Class(OpenLayers.Popup.FramedCloud, {
'autoSize': true,
});
marker = feature.createMarker();
volksschulen.addMarker(marker);
feature.data.popupContentHTML = ; //Here should be the text according to the marker
feature.data.overflow = "auto";
marker.events.register("mousedown", feature, markerClick);
feature.popup = feature.createPopup(feature.closeBox);
map.addPopup(feature.popup);
feature.popup.hide();
}
}
did you try:
feature.data.popupContentHTML = popupContentHTML[i];
assuming the length of your location array matches your text array, both in length anf position
I have a grid that is dynamically generated based on search criteria. I render the grid in a partial view using Ajax. That all works fine.
I now need to add a checkbox column as the first column.
Also, how do I get filtering, sorting paging etc. to work now since it is in a partial view.
When i click on a header to sort I get a Page not found error and the filter Icon doesnt do anything.
And one more thing. When I try to add a GridCommandColumnSettings to the grid I get the error
"Invalid initializer member declarator"
Code is below for the gridcolumnsettings
public GridColumnSettings[] NewColumns(DataTable fullDT)
{
GridColumnSettings[] newColumns = new GridColumnSettings[fullDT.Columns.Count];
for (int i = 0; i < fullDT.Columns.Count; i++)
{
// set the visibility property for the DeliveryID
bool boolDeliveryID;
if (fullDT.Columns[i].ColumnName == "DeliveryID")
boolDeliveryID = false;
else
boolDeliveryID = true;
newColumns[i] = new GridColumnSettings
{
new GridCommandColumnSettings
{
Commands =
{
new GridEditActionCommand(),
new GridDeleteActionCommand()
},
Width = "200px",
Title = "Commands"
},
Member = fullDT.Columns[i].ColumnName,
Title = fullDT.Columns[i].ColumnName,
Visible = boolDeliveryID,
Filterable = true,
Sortable = true
};
}
return newColumns;
}
Any suggestions would be appreciated.
Thanks
I edited my post to add my partial for the Grid
Here is my partial for the grid
#(Html.Telerik().Grid<System.Data.DataRow>(Model.Data.Rows.Cast<System.Data.DataRow>())
.Name("Grid")
.Columns(columns =>
{
columns.LoadSettings(Model.Columns as IEnumerable<GridColumnSettings>);
})
.DataBinding(dataBinding => dataBinding.Ajax().Select("_DeliveryManagerCustomBinding", "Deliveries"))
.EnableCustomBinding(true)
.Resizable(resize => resize.Columns(true))
)
I don't add columns this way when I use the Telerik Grid control, but looking at what you're doing I would hazard a guess to say you will need to do something like the following:
increase the size of the newColumns array by 1 (because we're going to add in the checkbox column):
GridColumnSettings[] newColumns = new GridColumnSettings[fullDT.Columns.Count + 1];
if you want it at the beginning you will need to do the following before your for-loop:
GridColumnSettings s = new GridColumnSettings() {
ClientTemplate("<input type=\"checkbox\" name=\"checkeditems\" value=\"some value\" />")
Title("title goes in here")
};
Then you will add it into your array:
newColumns[0] = s;
and then increase the start index for your for-loop to 1:
for (int i = 1; i < fullDT.Columns.Count; i++)
the checkbox column will go at the beginning
I have two different areas, and I have a route in one of those areas that is specific to that area, but I need to generate a link to that route using Html.RouteLink from another area (it's how you get over into the new area) but it won't work... It doesn't seem possible to use RouteLink to routes in a different area.
What is the best way around this? Should I just define a new route in the other area and name it differently?
UPDATE (code):
In master page in the main area (I've tried it multiple ways, all of which have produced same result):
<a href="<%= Url.Action("Index", "Home", new { area = "CustomerSite", route = "CustomerSite_preview", domain = (string)ViewData["DomainName"] }, null) %>">
In the CustomerSite area registration as the first route registered:
context.MapRouteLowercase(
"CustomerSite_preview",
"preview/{domain}/{controller}/{action}/{id}",
new { area = "CustomerSite", controller = "Home", action = "Index", id = "" },
new { isCustomerSite = new CustomerSiteRouteConstraint() },
new string[] { "GrayHills.CarLotHosting.Web.Areas.CustomerSite.Controllers" }
);
In your route object you just need a property named area with the name of the area.
Html.RouteLink("My Link Text",
new { area = "MyArea", controller = "MyController" ... },
null);
You need to change your route definition - see the answer ASP.NET MVC Url.Action routing error for more info.
In essence, your route should look as follows since you explicitly supply the controller name and action:
context.MapRouteLowercase(
"CustomerSite_preview",
"preview/{domain}/home/index/",
new { area = "CustomerSite"
, controller = "Home"
, action = "Index"},
new { isCustomerSite = new CustomerSiteRouteConstraint() },
new string[] {
"GrayHills.CarLotHosting.Web.Areas.CustomerSite.Controllers"}
The Url.Action will look like
<a href="<%= Url.Action("Index"
, new {domain = (string)ViewData["DomainName"] }
, null) %>">
which will result in a Url like http://localhost:56291/preview/somedomainname/home/index