|
Marco Bertschi wrote: Imagine you create the Crystal Report on a System but want to send it somewhere where neither PDFs nor Crystal Reports work (for whatever reason it may be
Keep in mind that the system wouldn't be able to support HTML either, because that is another possible output type.
So what sort of system doesn't support html but does support bitmaps? One of course might also wonder if this limited system only supports one type of bitmap.
|
|
|
|
|
jschell wrote: So what sort of system doesn't support html but does support bitmaps?
A system which is hardened down to meet some specific requirement defined by the customer, e.g. the customer doesn't want to have a browser installed?
The console is a black place
|
|
|
|
|
Marco Bertschi wrote: the customer doesn't want to have a browser installed?
Then they must be using a bit map viewer? Which would have its own limits?
|
|
|
|
|
Exactly. And since there was no mention of: number of pages; page size; etc.... It is rather premature to suggest solutions (to a poorly defined requirement).
I was once asked to send some (electronic) ascii text reports in a "larger font" because the final recipient didn't "see too well". Instead, I suggested they change the font size on their "viewer".
|
|
|
|
|
Probably the easiest way for you to do this would be to install an image printer[^] driver, and print to that rather than the default printer.
|
|
|
|
|
Damn. You were faster
Anyways, if he doesn't want to buy the ZAN license he could still use a free tool. We live in great times with loads of cool free stuff out there.
The console is a black place
|
|
|
|
|
As far as I'm concerned, Crystal Reports are designed to be printed out to whatever format, the format usually being a PDF or classic paper - I'm with Richard on this. Nowadays, we as Developers are in the lucky situation that a lot of freeware is out in the internet.
My approach would be to get a virtual printer driver which allows you to print a bitmap image ( instead of a physical piece of paper, or a PDF ) and then 'print' your report with this virtual printer. Of course this leads to the question if you don't want to print a PDF instead, if it is for the viewability of the report on different systems. If you want to use the report in a program which can't display Crystal Reports (for whatever reason it may be) stick with the Bitmap printer.
I had a quick look around, and found a few Bitmap virtual printers which I'd try out if I was you:
- ZAN Image printer [^] {Commercial License!}
- Virtual Image Printer Driver[^] {GPLv2}
The console is a black place
|
|
|
|
|
Consider this code:
public static T ConfigSetting<T>(string settingName)
{
return
} I already know it's not possible, because the caller needs to specify the type, but I want to know if there are other ways to achieve what I want, or if I have overlooked something simple.
|
|
|
|
|
try something like
T result = (T) CodeToRetrieveTofTheRightTypeDependingOnASettingInConfig();
return result; --edit
ehr.. wait, what?
Yes, see here[^]. May require you create a new overload for each type of constraint.
Bastard Programmer from Hell
If you can't read my code, try converting it here[^]
|
|
|
|
|
Eddy Vluggen wrote: a new overload for each type of constraint
That would probably work, even if it partly defeats the purpose with generics. But at least the calling methods would work like intended and receive the right type.
|
|
|
|
|
|
It's not the conversions I have a problem with.
I believe Eddy had the solution, even if it's not as elegant as I had wished for.
But I like the parsomatic.
|
|
|
|
|
This is exactly the problem that the Factory pattern was created to solve. If you want to get really fancy, you could use the Provider pattern.
|
|
|
|
|
That's actually what I'm trying to do, but while using generics.
I'm probably overdoing it.
<edit>I certainly had my head screwed on the wrong way yesterday, what I was trying to do is certainly not possible.
Factory it will be.</edit>
modified 2-Oct-14 3:44am.
|
|
|
|
|
Jörgen Andersson wrote: without the caller knowing what type to expect
Why bother then? Use a single class or a proxy.
|
|
|
|
|
Generics cannot be carried to runtime as generics, i.e., the generic type must be specified at compile time. In C#, the only type that can be determined at runtime is
dynamic Thus:
class A { }
class B:A { }
class C:B { }
public static dynamic ConfigSetting(string s)
{
switch (s)
{
case "A":
return new A();
case "C":
return new C();
case "double":
return (double)123;
case "int":
return 123;
default:
return null as string;
}
}
|
|
|
|
|
Hi,
I'm working on a course for 98-361 Software Development Fundamentals. I am given the following example:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.IO;
namespace Lesson02
{
abstract class Polygon
{
public double Length {get; protected set;}
public double Width {get; protected set;}
abstract public double GetArea();
}
class Rectangle: Polygon
{
public Rectangle(double length, double width)
{
Length = length;
Width = width;
}
public override double GetArea()
{
return Width * Length;
}
}
class Program
{
static void Main(string[] args)
{
Rectangle rect = new Rectangle(10, 20);
Console.WriteLine(
"Width={0}, Length={1}, Area = {2}",
rect.Width, rect.Length, rect.GetArea());
}
}
}
Here is a paragraph from the text that I am struggling with:
The properties Length and Width in the Polygon class are declared with a protected access modifier for the set accessor. This means that access to the set accessor is available only inside the Polygon class and its derived classes. You can still get the value of the Length and Width properties in the Main method, but you’ll get an error if you attempt to assign a value to these properties.
What I would like to know is to see code that shows how to use the set accessor properly and what does it look like if you try to assign a value from Main. I understand it will fail but I'd like to see it for myself. I am new to C# and unsure of how to introduce the code myself for an accurate demo.
Unfortunately, my instructors apparently don't write code so they are unable to answer my question.
Thank you!
Rob
modified 1-Oct-14 12:32pm.
|
|
|
|
|
robwm1 wrote: code that shows how to use the set accessor properly What do you mean by: "set properly" ?
The access modifier used on the 'set method in a Property, and the access modifier used on the Property itself determine what type of write access users of instances of the class will have.
... you are using .NET's auto-generated Properties here that create an invisible 'backing field ...
A 'private set restricts write access to the declaring class only: that would be useless here since the declaring class is 'abstract, and meant to be inherited from. You already know what using a 'protected setter does. With no access modifier the 'set inherits the access-modifier-state of its Property declaration.
You could also use 'internal as the access-modifier for the 'set: that would limit write access to only the assembly in which the Property is declared.robwm1 wrote: Unfortunately, my instructors apparently don't write code so they are unable to answer my question. Uh oh !
« I had therefore to remove knowledge, in order to make room for belief » Immanuel Kant
|
|
|
|
|
Richard Deeming seems to be on track with my question. If you look at his response, that is what I was looking for.
Thanks a lot for taking the time! I appreciate it!
|
|
|
|
|
robwm1 wrote: code that shows how to use the set accessor properly
Look at the constructor of the Rectangle class; it assigns values to the two properties, which succeeds because Rectangle is derived from Polygon .
robwm1 wrote: what does it look like if you try to assign a value from Main
You'll get a compilation error. The easiest way to see it is to try it:
static void Main(string[] args)
{
Rectangle rect = new Rectangle(10, 20);
rect.Width = 0;
}
"These people looked deep within my soul and assigned me a number based on the order in which I joined."
- Homer
|
|
|
|
|
Ok, that is what I was thinking in regards to causing the failure from Main. After the Rectangle object is instantiated, what if later during execution there is a need to change the Length or Width values. Is there a way to do that or would I have to instantiate another instance with the values I need. You certainly confirmed that it cannot be done from Main. It makes me think that the Rectangle class would need to be designed differently.
This is all just hypothetical. The only thing I'm trying to accomplish is a better understanding of how you could use an accessor that has a protected access modifier.
|
|
|
|
|
If you need to change the values, you have three options:
- Remove the
protected modifier from the <set>set accessors. The properties can then be set from any code.
abstract class Polygon
{
public double Length { get; set; }
public double Width { get; set; }
abstract public double GetArea();
} - Add a public method to the
Polygon or Rectangle class to change the property values. This method can then be called from any code.
abstract class Polygon
{
public double Length { get; protected set; }
public double Width { get; protected set; }
abstract public double GetArea();
public void ChangeDimensions(double newLength, double newHeight)
{
Length = newLength;
Height = newHeight;
}
} - If you want to preserve the immutability[^] of the class (Hint: This is almost always a good idea!), you'll need to create a new instance of the class with the new dimensions.
"These people looked deep within my soul and assigned me a number based on the order in which I joined."
- Homer
|
|
|
|
|
Perfect! That was exactly the explanation that I needed. I'm really disappointed that my instructors were unable to answer this. Looks like I'll be teaching myself...
|
|
|
|
|
This was a great question that led through to a very good explanation. I, for one, learnt something from this discussion.
Keep asking well thought questions like that here and you will learn...a lot!
I don't speak Idiot - please talk slowly and clearly
"I have sexdaily. I mean dyslexia. Fcuk!"
Driven to the arms of Heineken by the wife
|
|
|
|
|
I'm sure I'll have plenty more. Stay tuned!
|
|
|
|