|
Working on a project that involves generating SVG (Scalable Vector Graphics) charts with C# I have come across the following problem. For reasons of performance I would like to use CSS (Cascading Style Sheets) to represent style properties of SVG elements.
Finally it should look something like that:
<style>
.rectangle
{
fill: blue;
stroke: green;
stroke-opacity: 0.5;
}
</style>
<svg>
<rect x="100" y="40" width="200" height="29" class="rectangle" />
</svg>
A style-area defines all CSS rules which will then be applied in various elements in the SVG document. I'm striving for an elegant solution to represent the CSS properties adequately. Shall I build a few classes representing CSS stylesheets and include these in my classes generating SVG output via composition (see following code snippet).
As you can see the SVG (XML) output is generated via XmlTextWriter class.
<code>
public class SvgElement
{
double x1, x2, y1, y2;
XmlTextWriter writer;
CSSRule rule; // include css rules via composition?
public SvgElement(double x1, double x2, double y1, double y2)
{
this.x1 = x1;
this.x2 = x2;
this.y1 = y1;
this.y2 = y2;
}
public void Draw()
{
writer.WriteStartElement("line");
writer.WriteAttributeString("class", rule.name);
writer.WriteAttributeString("x1", coordX1.ToString());
writer.WriteAttributeString("y1", coordY1.ToString());
writer.WriteAttributeString("x2", coordX2.ToString());
writer.WriteAttributeString("y2", coordY2.ToString());
writer.WriteEndElement();
}
}
</code>
As I'm lacking to describe my problem precisely, please do not hesitate to comment. I'm more than willing to give further details
Thanks,
Goebel
-- modified at 3:07 Tuesday 22nd August, 2006
|
|
|
|
|
Hi guys.
In my project, I'm opening an MS Excel file and then trying to update some of the cells within it. The only catch however is this particular excel file contains two additional pivottables as well which contain a macro that executes code the instant the excel file is opened.
So, due to the fact that I'm trying update cells at the same time this macro is trying to execute its code, I'm receiving an error which reads:
"Call was rejected by callee"
I've provided my code below. It fails on line 3 ("sheet = MSExcel..."):
----------------------------------------------------
workbook = excel.Workbooks.Open(filePath,0, false, 5, "", "", false, MSExcel.XlPlatform.xlWindows, "",true, false, 0, true, false, false);
sheet = (MSExcel.Sheets)workbook.Worksheets;
worksheet = (MSExcel._Worksheet)sheet.get_Item(currentSheet);
------------------------------------------------------
Apparently, Excel is single-threaded so it can't handle two things at once. I noticed this because while debugging, if I set a breakpoint on my line of code that opens excel and "step into" the next few lines of code, everything works fine (i.e. I gave the macro enough time to execute its code first).
So anyway, I was just wondering if anyone has ever come across this issue before and what can be done to correct it.
Thanks in advance.
-Goalie35
|
|
|
|
|
Here is a hack workaround. So, go ahead and skip this reply if you want a clean solution.
In my experience I've found that Excell/Access/Word Macros are basically hack jobs anyway, so it probably won't hurt much hacking it up some more.
Can you modify the macro that runs when the file is opened every time that you run that code?
Alternatively modify the macro to check for a condition that you set to exit immdediately.
Example:
Step 1.) Modify or remove problem macro
Step 2.) Run your code
Step 3.) Restore problem macro
Step 4.) Possibly run problem macro
|
|
|
|
|
I have a user control that I would like to embed win forms controls in (for example System.Windows.Forms.Button)
I would like to embed the control in a control that is a property on my user control
I do not know how to then make the embedded control paint so that the user can see it.
public class SideBarMenu : UserControl
{
public class MyMenuItem : Control
{
public bool isActive = false;
}
// ... other code omitted
protected override void OnPaint(PaintEventArgs e)
{
base.OnPaint(e);
//what do I do to paint the child controls
//that can be contained in a MyMenuItem
}
}
public class Test1
{
public static void Test()
{
SideBarMenu mnu = new SideBarMenu();
MyMenuItem i = mnu.AddMenuItem("Hello");
Button b = new Button();
b.Text = "button1";
i.Controls.Add(b);
}
}
|
|
|
|
|
Hello
Maybe I'm not following you! So forgive me if I stray.
You don't have to worry about painting any controls inside your custom control. Just define their sizes and locations and they will draw themselves. You have only to paint your control to be viewd properly to the user, and of course to have a valid size to view all sub-controls.
So in the paint method you only have to paint your control, maybe would want to refresh() or invalidate() all sub-controls and they will draw themselves.
Another event you might want to handle is AddedControl. Have a look at it on MSDN.
Regards
|
|
|
|
|
I have a method:
internal void SetTopic( )
{
}
Using Reflection I want to call it
PropertyInfo method = type.GetMethod("SetTopic", BindingFlags.?);
Which binding flag do I include to find a method with an Internal modifier?
Thanks,
Nick
--------------------------------------------------------
1 line of code equals many bugs. So don't write any!!
My mad coder blog
|
|
|
|
|
MethodInfo method = type.GetMethod("SetTopic", BindingFlags.Instance | BindingFlags.NonPublic);
Vitaliy Tsvayer
Tikle
|
|
|
|
|
I want to add a new line to one of the Datagrid Column Value.
How do i do it
Suppose i have Mike and Bond
and i want Mike and Bond in different lines but in the
same column.
Thanks
Kal
|
|
|
|
|
Hello
Correct me if I'm wrong, but I don't think it's possible.
Regards
|
|
|
|
|
You can set DefaultCellStyle.WrapMode = DataGridViewTriState.True.
So, you can enter value to cell as "Mike" + Environment.NewLine + "Bond".
BUT, in this case if some other cell width is small its value will be wrapped as well.
To avoid this you can leave DefaultCellStyle in its default value and set individual cell's style only.
Vitaliy Tsvayer
Tikle
|
|
|
|
|
Hello,
I have a project in Visual Studio that references some external "Debug" dll's. It works fine in "Debug" mode.
I want to rebuild this project in "Release" mode. Visual Studio complains that it cannot find the "Release" version of those external dlls. When I try to add the "Release" version of that external dll it complains that a reference to this dll (Debug version) already exists in this project. Replacing the the "Debug" version of the external dll with its "Release" version lets me rebuild my project in "Release" mode.
I was wondering if there was a way around this, instead of switching the versions of the external dll's I use (between "Debug" and "Release") everytime I want to do a "Debug" or "Release" version of my project.
I've never seen this before, it usually just finds the right dll by default. It suprised me.
Thanks and Regards,
Ramanan
"One of the Georges," said Psmith, "I forget which, once said that a
certain number of hours' sleep a day--I cannot recall for the moment how
many--made a man something, which for the time being has slipped my
memory."
|
|
|
|
|
Hello
AFAIK your project shouldn't care if the version of the external dlls is debug or release. Did you make these dlls?? Maybe you referenced them by the project?? Try cleaning things up:
1- BACKUP YOUR PROJECT -sorry for the uppercase;)-
2- Remove all references to the dlls
3- Copy only the dlls files to your project's folder
4- Reference to the new dlls in your folder
5- Make sure "Copy Local" property is set to true
Regards
|
|
|
|
|
I am looking for a good tutorial for C# for the web, for someone that has never touched an ounce of C code in his life (ASP, VB, HTML, some Java). If anyone knows any that are useful, and have been in the same situation I am, please post them here. I have a book and have been going through it, but I'm still not grasping the fundamental and required things a C# wep-page should be built around; any tutorials that compare C# to ASP or HTML and teach it comparitively would be wonderful. Thanks in advance!
Jesse "Soot" Myer
jessemyer06@aol.com
|
|
|
|
|
Hello
If you want general lessons about C# try This link[^]
If you want only web development Try these videos[^]
For more google for "C# tutorials"
Regards
|
|
|
|
|
I have a dataset of items (UPC, price, quantity, name) that I would like to combine based on like items. For example, all items with the same name, I would like to combine so that the quantity and prices are changed accordingly. Are there any built in functions that will let me do this? Or do I have to create a routine which will sort the dataset, create a new set, and then go through the old dataset and combine like items and then add to the new dataset?
thanks!
|
|
|
|
|
I guess this would be more of a datarow combining/merging question./..
|
|
|
|
|
Hello
jeweladdict wrote: Are there any built in functions that will let me do this?
Well, maybe you're talking about Stored Procedures?
Anyway, here is an approach to do something like what you want -even though I don't like it but I can't really think of something better-.
1- Make a datagridview and feed it with your table
2- Sort it according by the name -if that's what you want
3- Iterate through the rows comparing each row with its previous one -except the first row of course-
4- Find similar rows and combine their values, then delete the second one
NB. You don't have to make the DataGridView visible to the user
Please, if someone has a better approach post. I believe there should be a better way. but this should work!
Regards
|
|
|
|
|
that works like a charm. Thanks!
|
|
|
|
|
Hello
An Even much better approach is to use the DataView class instead of a DataGridView!! Sorry that such a simple solution didn't cross my mind , I've been awake for almost two days now!!
Regards
|
|
|
|
|
I am using a datagridview control. I want to select multiple cells that contain numbers and add them. What would be the best way to do this?
Thanks.
|
|
|
|
|
Hello
int Sum = (int)MyDataTable.Rows[RowIndex].ItemArray[Index].Value + (int)MyDataTable.Rows[SecondRow].ItemArray[SecondIndex].Value;
And so on...
Regards
|
|
|
|
|
If I understand you right, you use DataGridView control with MultipleSelect set to true and when you select some cells you want to add numbers within them. To do that you can handle SelectionChanged event like below:
private void dataGridView1_SelectionChanged(object sender, EventArgs e)
{
foreach (DataGridViewCell cell in dataGridView1.SelectedCells)
{
}
}
BUT, be carefull to check whether selected cells has an integer value!
Vitaliy Tsvayer
Tikle
|
|
|
|
|
Thanks for your help. That worked great.
|
|
|
|
|
??
A strange request i know, but there it is.
|
|
|
|
|
You're kidding, right? Or am I missing something? I hope you're asking if it's divisible by 9.
if( str.Length % 9 == 0 )
return true;
else
return false;
Or the old way:
if( (float)(str.Length / 9) == (str.Length / 9.0) )
return true;
else
return false;
Dave Kreskowiak
Microsoft MVP - Visual Basic
|
|
|
|