|
Hi,
If you have a number of .bmp files, it isn't hard to create a stack of them in a new .bmp file without even using the Image or Bitmap classes, provided all images have equal width.
All it takes is some understanding of the BMP file format[^] (basically locate the height information, and the border between header and pixel data), creating the BMP header, and stitching the data half of each of the .bmp files together.
The input images don't even have to be files, you could apply the same to memory streams. So what I would suggest is this: open an output stream, emit the BMP header for the resulting image (could be based on an input image with the height adapted appropriately), then enumerate the images, and for each of them create the memory stream, then append the byte data skipping the input header.
However, I do agree with the others, my first approach would be to avoid the need for a huge image altogether, as working with huge images will cause heavy memory loads, big latency times, and/or fatal errors. When huge amounts of data are involved, streaming is the way to go; stitching things together statically goes the wrong way. If part of your system needs the whole data, then try and fix that if at all possible.
PS & FWIW: I guess it is easy to show your image using a ListBox where each item corresponds to one input image; make it user drawn so no time is wasted in loading and painting items that aren't currently visible.
modified 21-Oct-16 20:06pm.
|
|
|
|
|
hi guys,
I have developed a MVC implementation 5, it works perfectly locally
but I published it on IIS and I have had this problem
//
in the controller I
public ActionResult Index ()
{
CatalogModel m = new CatalogModel ();
m.LocalCodeColumn = 1;
m.PriceColumn = 2;
m.SelectedClientList = m.GetClientSelectedItems ();
return View (m);
}
and in the view:
Select Client: @ Html.DropDownListFor (m => m.SelectedClientList, Model.GetClientSelectedItems (), "--Select--", new {@id = "ddlClient"})
and this function :
public IEnumerable<SelectListItem> GetClientSelectedItems()
{
IEnumerable<SelectListItem> listClient = dataServices.GetClients();
return listClient;
}
i dont know if the problem with the framework on the server or else
Thank you
modified 20-Oct-16 11:12am.
|
|
|
|
|
This question would probably get a better response in the ASP.NET forum; it is not a pure C# issue.
|
|
|
|
|
|
I am attempting to design an interface for a set of calculation methods, inputs are:
MethodName
Collection of RateSet names
optional collection of tenors (key/value) per Rateset
Collection of Parameters (key/value)
Based on the MethodName the interface should then pass the collection values to the method
The method will crunch the values and output a collection of RateSets with Rates (key/value)
How would the implementation of MethodName to the actual method be done?
Reflections, case statement ???
Never underestimate the power of human stupidity
RAH
|
|
|
|
|
If you are passing the MethodName as a string, then reflection is probably your best option for calling it.
However, having said that, if you are designing the interface, why not have it with a property that is a method delegate? That way, instead of passing the name of the method to your implementation, you can pass the method itself. No reflection needed, no limited switch-case constructs, and no nasty little bugs when the signature of MethodName does not quite match what was expected.
Cheers,
Mick
------------------------------------------------
It doesn't matter how often or hard you fall on your arse, eventually you'll roll over and land on your feet.
|
|
|
|
|
Midi_Mick wrote: why not have it with a property that is a method delegate In which case what would be the benefit of using an interface, it would be no different to using the method direct.
Never underestimate the power of human stupidity
RAH
|
|
|
|
|
I was thinking you were looking for something like this:
public delegate ICollection<RateSet> Method(ICollection RateNames, IDictionary Parameters, IDictionary Tenors = null);
interface IRatesCalculator {
Method Method { get; }
ICollection RateNames { get; set; }
IDictionary Parameters { get; set; }
IDictionary Tenors { get; set; }
ICollection<RateSet> Results { get; }
}
public class RatesCalculator1 : IRatesCalculator {
public RatesCalculator1() {
Method = (ICollection RateNames, IDictionary Parameters, IDictionary Tenors) => {
List<RateSet> rateSet;
return rateSet;
}
};
public Method Method { get; }
public IDictionary Parameters { get; set; }
public ICollection RateNames { get; set; }
public IDictionary Tenors { get; set; } = null;
public ICollection<RateSet> Results {
get {
return Method?.Invoke(RateNames, Parameters, Tenors);
}
}
}
public class RatesCalculator2 {
public RatesCalculator2(Method calculator) {
Method = calculator;
}
public Method Method { get; }
public IDictionary Parameters { get; set; }
public ICollection RateNames { get; set; }
public IDictionary Tenors { get; set; } = null;
public ICollection<RateSet> Results {
get {
return Method?.Invoke(RateNames, Parameters, Tenors);
}
}
}
You may even need to make Method a Read/Write property if you wanted to set it after the creation of the class object.
Cheers,
Mick
------------------------------------------------
It doesn't matter how often or hard you fall on your arse, eventually you'll roll over and land on your feet.
|
|
|
|
|
This is a case where I would change my thinking around and use the Strategy patter[^] instead.
This space for rent
|
|
|
|
|
I think you are close to rediscovering abstract factory.
Calling a common interface which is implemented in number or classes and interface calling concrete methods according to some decision.
I suggest you read implementing factory/abstract factory before digging into reflection.
---
Pd.
|
|
|
|
|
So why aren't you just using a delegate here?
"There are three kinds of lies: lies, damned lies and statistics."
- Benjamin Disraeli
|
|
|
|
|
The methodname comes from a user selection and is a string!
Never underestimate the power of human stupidity
RAH
|
|
|
|
|
If it is from a user-selection, that you don't need to use a string. Most controls have a "display" value for the string, while your real value may be an enum. As Pete said, a strategy-pattern
Bastard Programmer from Hell
If you can't read my code, try converting it here[^]
|
|
|
|
|
Yeah, seems like an obvious reason to go with a delegate method. Don't even need to create new classes to handle it, and the delegate effectively takes the place of an interface.
Psudocode!
delegate object MyDelegate(IEnumerable<kvp> parameters, IEnumerable<kvp> tenors = null);
Dictionary<string,MyDelegate> UIDelegateAssociation = new{{Key = "uiSelection", Value = (p,t){}}};
UIDelegateAssociation["uiSelection"].Value.Invoke(params,tenors);
"There are three kinds of lies: lies, damned lies and statistics."
- Benjamin Disraeli
|
|
|
|
|
Can we use Azure Table as database in CRM application?
|
|
|
|
|
Can we? Yes. Should we? Depends on lot of factors.
Azure table is basically NoSql key-value set up. Does you data fit into this model?
"It is easy to decipher extraterrestrial signals after deciphering Javascript and VB6 themselves.", ISanti[ ^]
|
|
|
|
|
Thank's for answer.
How to maintain ACID properties and referential integrity in Azure Tables.
|
|
|
|
|
There is no referential integrity. Table Storage is just a key/value pair storage, like a Dictionary collection in .NET.
|
|
|
|
|
I'm trying to get a window to move along the x axis however currently the code(timer4_tick) that i have is having no effect. Is there something that i am missing? I'll try to post only the code that is relevant.
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.IO;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
public partial class Form1 : Form
{
private int WindowVx, WindowVy;
private int WindowX, WindowY;
private int width = Screen.PrimaryScreen.WorkingArea.Width;
private int height = Screen.PrimaryScreen.WorkingArea.Height;
private void timer1_Tick(object sender, EventArgs e)
{
WindowX = random.Next(width);
WindowY = random.Next(height);
int wx = random.Next(width / 2);
int wy = random.Next(height / 2);
WindowVx = random.Next (1, 4);
WindowVy = random.Next (1, 4);
this.Left = WindowX;
this.Top = WindowY;
this.Width = wx;
this.Height = wx;
}
private void timer4_Tick (object sender, EventArgs e)
{
WindowX += WindowVx;
if (WindowX < 0) {
WindowVx = -WindowVx;
} else if (WindowX + width > ClientSize.Width) {
WindowVx = -WindowVx;
}
this.Refresh ();
}
this.timer4 = new System.Windows.Forms.Timer (this.components);
this.timer4.Enabled = true;
this.timer4.Interval = 1000;
this.timer4.Tick += new System.EventHandler (this.timer4_Tick);
private System.Windows.Forms.Timer timer4;
|
|
|
|
|
That's because it doesn't move anything. All it does is change the values of your internal variables, which are only subsequently used in your timer1_tick method, but immediately overwritten.
You need to affect the Top and Left properties of the window itself in order to move it.
Bad command or file name. Bad, bad command! Sit! Stay! Staaaay...
|
|
|
|
|
Oh thank you! I got it working now!
|
|
|
|
|
You're welcome!
Bad command or file name. Bad, bad command! Sit! Stay! Staaaay...
|
|
|
|
|
Ok, I've gotten it to move horizontally, vertically and diagonally fine so i've added boundaries so that it can't move past the screen limits. However when i added that it just shakes back and forth. From what i understand it first increases the x co-ordinates, moving the window to the right. Then the if statement checks if it has gone past the left of the screen and if it has it will reverse the direction the window moves. The second if statement checks that x co-ordinates including the width of the window doesn't past the width of the screen. Is this all correct?
private void timer4_Tick (object sender, EventArgs e)
{
this.Left += WindowVx;
if (this.Left < 0) {
WindowVx = -WindowVx;
}
if (this.Left + this.Width > ClientSize.Width) {
WindowVx = -WindowVx;
}
this.Refresh ();
}
|
|
|
|
|
So what you want it to do is move all the way right, then when it reaches the edge, turn round and move the other way?
To do that isn't difficult - when you reach the screen edge, change the sign on the value you are adding! Then, when you reach the other edge, change it back again.
Left += deltaX;
if (Left < 0 || (Left + Width) > ClientSize.Width)
{
deltaX = -deltaX;
} You don't need to specify this all the time - you only need it when you have a local variable of the same name as your class level one and you want to access the class level variable.
You also don't need to refresh anything - when you update Left and Top they will refresh for you.
Bad command or file name. Bad, bad command! Sit! Stay! Staaaay...
|
|
|
|
|
Hm... for some reason the window just moves back and forth kind of like it's vibrating. I'm not really sure what's causing it as the code without the if statement works fine.
This is the code right now:
this.Left += WindowVx;
if (Left < 0 || (Left + this.Width) > ClientSize.Width){
WindowVx = -WindowVx;
}
|
|
|
|