|
Thanks Gerry, that is exactly what I'm trying to study and grasp right now.
Clues for the learner are welcome.
I'm trying to find the syntax for moving a rectangle from point A,B to point X,Y on the screen, and It's anything but obvious at this moment. I have been searching here, MSDN, and five or ten other sites with "C#, DirectX, Rectangle, Move" and so on, and I have yet to see the syntax.
I came across "clone" which may lead somewhere.
Anyway, if you can point me to a piece of sample code that shows how to move a rectangle A`B`C`D to a position at X,Y on the screen, please do so.
Certainly that has to be a perennially useful example.
Don't know how to post a screen cap of the form1 here or else I would.
|
|
|
|
|
Are you trying to do this in Windows Forms? If you are, simply use double buffering - it's very easy to set up as shown in this[^] article.
|
|
|
|
|
Here's a small C# WPF "code-only" example that allows you to move a rectangle using sliders. You can decide for yourself if the performance is acceptable. (You can accomplish the same thing using XAML)
using System;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Media;
using System.Windows.Shapes;
namespace WpfApplication1 {
class Program {
[STAThread]
static void Main( string[] args ) {
Window window = new Window() {
WindowStartupLocation = WindowStartupLocation.CenterScreen,
SizeToContent = SizeToContent.WidthAndHeight
};
Canvas canvas = new Canvas() { Width = 400, Height = 400 };
Rectangle rect = new Rectangle() {
Width = 20,
Height = 20,
Fill = Brushes.MediumBlue
};
canvas.Children.Add( rect );
Slider sliderY = new Slider() {
Orientation = Orientation.Vertical,
Maximum = 300,
Minimum = 100,
Value = 200
};
Slider sliderX = new Slider() {
Orientation = Orientation.Horizontal,
Maximum = 300,
Minimum = 100,
Value = 200
};
StackPanel sp1 = new StackPanel() { Orientation = Orientation.Horizontal };
StackPanel sp2 = new StackPanel() { Orientation = Orientation.Vertical };
sp1.Children.Add( canvas );
sp1.Children.Add( sliderY );
sp2.Children.Add( sp1 );
sp2.Children.Add( sliderX );
window.Content = sp2;
Binding bindingX = new Binding();
bindingX.Source = sliderX;
bindingX.Path = new PropertyPath( Slider.ValueProperty );
rect.SetBinding( Canvas.LeftProperty, bindingX );
Binding bindingY = new Binding();
bindingY.Source = sliderY;
bindingY.Path = new PropertyPath( Slider.ValueProperty );
rect.SetBinding( Canvas.TopProperty, bindingY );
Application app = new Application();
app.Run( window );
}
}
}
|
|
|
|
|
I wanna get the innertext from the html but some divs has not an id. And i cant reach then.. for example in this code how can i get 'İnşaat Mühendisliği' etc.
<div class="liste">
<div style="width:90px;"> </div>
<div style="width:160px;"><a id="ctl00_cphAlt_rpKisiListesi_ctl00_lbAdGuid" href="javascript:__doPostBack('ctl00$cphAlt$rpKisiListesi$ctl00$lbAdGuid','')">Abdulkerim Gökbulut</a> </div>
<div style="width:250px;">İnşaat Fakültesi </div>
<div style="width:250px;">İnşaat Mühendisliği </div>
</div>
<div class="liste">
<div style="width:90px;"> </div>
<div style="width:160px;"><a id="ctl00_cphAlt_rpKisiListesi_ctl01_lbAdGuid" href="javascript:__doPostBack('ctl00$cphAlt$rpKisiListesi$ctl01$lbAdGuid','')">A. Buğrahan Gökso...</a> </div>
<div style="width:250px;">İnşaat Fakültesi </div>
<div style="width:250px;">İnşaat Mühendisliği </div>
</div>
<div class="liste">
<div style="width:90px;"> </div>
<div style="width:160px;"><a id="ctl00_cphAlt_rpKisiListesi_ctl02_lbAdGuid" href="javascript:__doPostBack('ctl00$cphAlt$rpKisiListesi$ctl02$lbAdGuid','')">Abdulmecit Gökçe</a> </div>
<div style="width:250px;">Fen Bilimleri Enstitüsü </div>
<div style="width:250px;">Moleküler Biyoloji ve Genetik </div>
</div>
|
|
|
|
|
Well, if it were me, I'd do it using JavaScript, and not C#.
|
|
|
|
|
Then he can discover that innerText only works in one family of browsers...
Cheers,
Peter
Software rusts. Simon Stephenson, ca 1994. So does this signature. me, 2012
|
|
|
|
|
|
By reading the html source from top to bottom...
What do you actually want to do? Where does that html come from - is it produced by an application you have the source code?
To me, it looks like a textual representation of objects with 3 properties. And of course, you should find out the subject of study of the correct student...
|
|
|
|
|
What is the best (free) tool(s) to create UML diagrams?
Thanks.
|
|
|
|
|
Are you wanting to connect to one from C#?
|
|
|
|
|
Pete,
Thanks for your respond... Yes, from C#.
|
|
|
|
|
There are many types of diagrams in UML!
If you are interested in the Class Diagram only, you could use Visual Studio's functionality to create them from your code. But that functionality is very basic only.
|
|
|
|
|
I use StarUML. He is among the best that have ever tested.
|
|
|
|
|
Hello everyone!
I need to do a paint software in C# for the university.
I need to use polimorphysm,abstract class,overriding, POO concepts.
I have very dificultties in programmiing so im trying to find something nice to help me here ,but i just find codes for paint without using classes and POO concepts.
Do have something that can helps me?
|
|
|
|
|
mibetty wrote: I need to use polimorphysm,abstract class,overriding, POO concepts. I assume you mean OOP here, I don't now what POO is in your language but ...
The use of these features in your program requires you to do the design. It is not possible to provide a standard set that will do the work for you. You can also find lots of useful suggestions in the CodeProject Articles section[^].
One of these days I'm going to think of a really clever signature.
|
|
|
|
|
Errm, it's OOP not POO - POO concepts are something completely different.
If you understand OO, then breaking down your requirements becomes a lot easier. As an example, let's take the fact that you are going to want to draw multiple items, and they are probably going to be of different types. This suggests to me that you are going to have something to manage the collection of items, and that these items will share some common base.
When you consider OOP, you understand that OOP relies on encapsulation, so that everything to do with an item should belong to that item. So, we could figure out that we want to position the item somewhere, and that we want it to have a width and a height. Also, rather than having the code to paint these items on the screen in the paint handler of the application, we should consider that each item should know how to paint itself. So, we have some requirements for these objects - they all share some commonality, and they all have some operations that they must perform, but these operations will depend entirely on the item being drawn. So, I would consider that the X, Y, Width and Height were common (hey, if only .NET provided a handy Rectangle class to do this). The way you paint a rectangle would be different to the way you draw a circle though, so perhaps this should be abstract and require each draw able item to implement it.
As a first pass, I've now got something like this:
public class CanvasManager
{
private List<Shape> shapes = new List<Shape>();
public void AddShape(Shape shape)
{
shapes.Add(shape);
}
public void Paint()
{
foreach (Shape shape in shapes)
{
shape.Draw();
}
}
}
public abstract class Shape
{
public Shape(int x, int y, int width, int height)
{
Bounds = new Rectangle(x, y, width, height);
}
public Rectangle Bounds { get; set; }
public abstract Draw();
} That should give you more than enough to get started, and good luck. Just break your problem down using words and you'll soon get the hang of it.
|
|
|
|
|
Thanks very much all for your awnsewers.
Yes i meant OOP , sorry!
I already look at the code of that "Simple Paint" and others , but the problem is that i need to do a paint using several classes , not only one, i need to use a main class and than others that inherit from the main class.
I also need to use polymorfism , abstract class, overiding,lists..
For example teacher said that i need to have a main class "shape" and than a class for square , rectangle, etc that inherit from shape.
Maybe its something like Pete O'Hanlon wrote, i will try do here something with that
Thanks for trying to help me
|
|
|
|
|
|
Have you looked at the code in there? It's not a great example. Everything is done, pretty much, in one class.
|
|
|
|
|
The simplest way,
Understand the concept with simple example. try with more real life example. and then start working on your project.
best luck
Thanks
-Amit Gajjar (MinterProject)
|
|
|
|
|
That really doesn't add much to the discussion, so why bother posting it? The poster has already indicated that he has made some effort here, and that he just needs some pointers. Your answer was the equivalent of, when somebody asks you for directions to some place, you saying, first you should practice driving up and down this street.
|
|
|
|
|
I am just motivating him.... sometimes people need little bit more effort to get the result and those needs some motivation. And i believe so...
I am sorry if this should not be answer.
Thanks
-Amit Gajjar (MinterProject)
|
|
|
|
|
If the question is clear, and not a request for you to write all the code, then you should offer practical advice. Being given the piece of information you need to solve a problem is a much better motivator and is more help for a poster.
|
|
|
|
|
Thanks for the information. i will keep this in mind and will try to use in my next answers
Thanks
-Amit Gajjar (MinterProject)
|
|
|
|
|
Good job. I look forward to seeing your answers.
|
|
|
|
|