C# :: Custom Button Shape (WPF)

Nov 30, 2014

I have begun switching from WinForms to WPF and I'm having a hard time understanding the new concepts. In WinForms, I had a few User Controls, custom drawn using shapes (rectangles, ellipses, etc). They had some unique properties, like "Flashing" (setting this property to True and setting the "Flash Interval" property to 500 would have resulted in the control changing its background color to white and back again, every 0.5 seconds), "Beeping", etc.

I have tried to replicate these controls in WPF/XAML and so far managed to draw the shape. However, when it came to implementing a custom property that would redraw the background color of the rectangle every interval set by user in another property, i got stuck. The property is being set, but it doesn't change the background color. Alternatively, i have tried this method, with the same results (i got it to show in the "Properties" window in Visual Studio, i can set it, it is being stored in XAML, but it doesn't affect the background.

C# code behind:
public struct LCARSColors
{
public static Brush DarkBlue = (Brush)(new BrushConverter().ConvertFrom("#FF3366CC"));
public static Brush LightBlue = (Brush)(new BrushConverter().ConvertFrom("#FF99CCFF"));
public static Brush Pink = (Brush)(new BrushConverter().ConvertFrom("#FFCC99CC"));

[Code] ....

If i use this line (commented in this code sample):

<!--<SolidColorBrush x:Name="MySolidColorBrush" Color="{DynamicResource DarkBlue}" />-->

The background is colored in DarkBlue (as defined). But if i use this line:

<SolidColorBrush x:Name="MySolidColorBrush" Color="{Binding BackgroundColor, UpdateSourceTrigger=PropertyChanged, Mode=TwoWay}" />

Nothing happens, the rectangle disappears entirely. If i add this to the above line:

FallbackValue=LightYellow

The rectangle is colored in LightYellow, meaning that the property is not accepted and the fallback value is used. Why?

View 9 Replies


ADVERTISEMENT

C Sharp :: Loop In A Button / Runs Endless When Pressing The Button And Not Only Once

Jun 10, 2014

I have an code that makes form window + button bet bigger when pressed each time, but it runs endless till out of screen,

code:
{
int S1 = 300;
int S2 = 0;

[Code]...

make it so it runs only each time i press the button?

View 2 Replies View Related

C :: How To Print Another Shape Near Previous One

Nov 9, 2014

How do i print another shape near the one i did. I have this code but how i can put another shape near it like this

Code:
#include <stdio.h>
int main() {
int i;
for (i = 0; i < 5; i++)
switch (i) {
case 0:
printf(" *

[Code] .....

View 7 Replies View Related

C :: Drawing A Shape (Square) Into PGM Image

Nov 22, 2013

I'm doing a project and I need to draw a square into a pgm image if certain conditions are met, but I'm not sure how to draw the square into the image.

View 2 Replies View Related

C++ :: Generic Shape Area Calculator

Dec 6, 2013

I'm building a pretty basic calculator program that calculates the area of generic shapes (triangles, rectangles, and squares); for some reason though, my program is having troubles as soon as it hits the if/else code in the int main section. When I enter triangle, rectangle, or square, it just spits back out the "That's not one of the options. Please re-enter and try again." error line I created. When I isolate and run just the stuff inside the if/else statements it works great, but why it won't just understand my if (shape == triangle).... .

Code:

#include <iostream>
using namespace std;
class figure {
protected:
double x, y;

[Code] ....

View 2 Replies View Related

C++ :: How To Make A Shape Outside Of Main Function

Sep 8, 2014

I know how to define a shape and attach it to a window as follows:

#include <Simple_window.h>
void cir() { Circle c(Point(100,100),50); }
int main() {
Simple_window win(Point(100,100),600,400, "test");

Rectangle r(Point(100,100),Point(300,200));
win.attach(r);
win.wait_for_botton();
}

But how to define a shape (say a circle by that cir() function which is) outside of the main() function? And how to attach it to be visible on window win?

View 4 Replies View Related

C++ :: Use Construct Object (Shape) Efficiently?

Jun 27, 2014

have a problem with my code (I wish for answer with code). The conditions I have to grant:

- **Only** a pointer to an object must be saved in a **standard** class vector (e.g vector<ShapePtr>)
- Base class must be a polymorphic class (I call this class ShapePtr)
- I **must** have a deep copy process
- Constructor is **not** suppose to do a deep copy
- **clone()** is suppose to do the deep copy

Here is the code **provided** to me:

main.cpp
int main() {
typedef shared_ptr<Shape> ShapePtr;
vector<ShapePtr> shapevec;

[Code].....

View 1 Replies View Related

C/C++ :: Count The Times A Shape Was Selected?

Jul 28, 2014

This is part of the program, What should i do if i want to total the number of times a shape was selected at the end?

#include<iostream>
#include<string>
#include<iomanip>

[Code]....

View 3 Replies View Related

C/C++ :: How To Make A Shape Outside Of Main Function

Sep 8, 2014

I know how to define a shape (here, a rectangle) and attach it to a window in C++ as follows:

#include <Simple_window.h>
void cir() { Circle c(Point(100,100),50); }
int main() {
Simple_window win(Point(100,100),600,400, "test");
Rectangle r(Point(100,100),Point(300,200));
win.attach(r);
win.wait_for_botton();
}

But how to define a shape (say a circle by that cir() function which is) outside of the main() function? And how to attach it on the window win to be visible?

View 4 Replies View Related

C# :: API That Convert 2D Cross Sections Into 3D Shape

Mar 1, 2014

I have cross sections in the form of rectangles in the XY plane formed from two point (top left, bottom right) as well as their Z position. I'd like finding some sort of API that can extrude a basic linear-average-approximated 3D shape (preferably eventually into STL format) from these points. I've tried googling but to no avail. The aim is to build a 3D shape from 2D wireframes.

View 2 Replies View Related

C :: Pointer To N-dimensional Array That Has A Predefined Shape

Feb 12, 2013

dynamically allocated arrays. int (*ttt)[2][10]; If I'm not mistaken this declares a pointer (that's all). This pointer has an intrinsic shape that makes it easier to access row, column without doing my own math to calculate the offset.

ttt = malloc(2 * 10 * sizeof(int));

So I should be able to access elements like this: ttt[i][j].

ttt[i][j] = 123;

But the compiler says: error C2440: '=' : cannot convert from 'int' to 'int [10]'...how to go about accessing a monolithic block of allocated memory using 2 or more dimensions, using some sort of casting to a known shaped array if possible. As opposed to doing i * cols + j type stuff.

View 2 Replies View Related

C++ :: Detect Mouse Position - Square Shape

Jul 16, 2013

I am trying to detect when my mouse is over a item. I can get it working if its a square shape an stuff.

(LOWORD(lParam) > 133) && (LOWORD(lParam) < 154) && (HIWORD(lParam) > 0) && (HIWORD(lParam) < 21)

but how would i detect if its over the white spot in this image? [URL] ....

i just drew a simple shape i need to detect from more edges but how to do it?.

View 7 Replies View Related

C/C++ :: DX9 Program Pauses When Trying To Change Shape Of Object

Mar 9, 2014

And for some reason my program pauses (nothing displays, and my cursor changes to the little "loading" cursor thingy) when it hits line 139. That is where I added an additional piece of code that should change the shape of the triangle while the program is running.

#include <Windows.h>
#include <WindowsX.h>
#include <d3d9.h>
#define CUSTOMFVF (D3DFVF_XYZRHW | D3DFVF_DIFFUSE)

[Code].....

View 5 Replies View Related

C++ :: Shape Class Polymorphism Compiler Error

Dec 10, 2014

Having issues with program to create a shape area calculator with circle square and rectangle. the uml goes as follows:

Where the UML has shape as the abstract class with public area():double, getName():string,and getDimensions:string, rectangle derived from shape with protected height, and width, and a public rectangle(h:double, w:double), followed by a derived square from rectangle with just a public square(h:double), and finally a circle derived from shape with a private radius, and a public circle(r:double).

[URL]

Have linked my program and it is giving me the following compiler errors:

error: 'qdebug' was not declared in this scope line 15 of main

error: cannot declare variable 'shp' to be of abstract type 'shape' line 22 of main

error: expected primary-expression before ')' token lines 29 -31 of main

(note previously had qstring as a header file yet changed to string since I was getting error qstring was not declared in this scope.)

View 5 Replies View Related

Visual C++ :: How To Make A Shape Outside Of Main Function

Sep 9, 2014

I know how to define a shape (here, a rectangle) and attach it to a window in C++ as follows:

Code:
#include <Simple_window.h>
void cir() { Circle c(Point(100,100),50); }
int main() {
Simple_window win(Point(100,100),600,400, "test");

[Code] ....

But how to define a shape (say a circle by that cir() function which is) outside of the main() function that is how to create a circle inside of the cir() function and it returns that circle when I called it in my main() function so that I can attach it on the window win to be visible?

View 14 Replies View Related

C# :: For Loops To Make User Defined V Shape Output

Jul 29, 2014

Write a program to ask a user to input a symbol from the keyboard and to output that symbol in a n X n/2 sized V where n = the width of the V. You must use a loop to process the data

I am stuck at trying to figure out how to do the actual output formatting. This is where I am sitting currently.

string character = "";
int vheight = 0;
Console.WriteLine("Enter the character you wish to use for your V: ");

[Code]....

so Im really just a bit stumped on how to get the actual V shape to be formatted..

View 14 Replies View Related

Visual C++ :: Crescent Moon - Calculate Points On This Shape

Mar 28, 2013

My question is, I have been tasked to draw this shape,

![Crescent Moon][URL] ....

This is to be done using C++ to write code that will calculate the points on this shape.

Important details.

User Input - Centre Point (X, Y), number of points to be shown, Font Size (influences radius)

Output - List of co-ordinates on the shape.

The overall aim once I have the points is to put them into a graph on Excel and it will hopefully draw it for me, at the user inputted size!

I know that the maximum Radius is 165mm and the minimum is 35mm. I have decided that my base [Font Size][1] shall be 20. I then did some thinking and came up with the equation.

Radius = (Chosen Font Size/20)*130. This is just an estimation, I realise it probably not right, but I thought it could work at least as a template.

I then decided that I should create two different circles, with two different centre points, then link them together to create the shape. I thought that the INSIDE line will have to have a larger Radius and a centre point further along the X-Axis (Y staying constant), as then it could cut into the outside line.*

*(I know this is not what it looks like on the picture, just my chain of thought as it will still give the same shape)

So I defined 2nd Centre point as (X+4, Y). (Again, just estimation, thought it doesn't really matter how far apart they are).

I then decided Radius 2 = (Chosen Font Size/20)*165 (max radius)

So, I have my 2 Radii, and two centre points.

This is my code so far (it works, and everything is declared/inputted above)

for(int i=0; i<=n; i++) //output displayed to user {
Xnew = -i*(Y+R1)/n; //calculate x coordinate
Ynew = pow((((Y+R1)*(Y+R1)) - (Xnew*Xnew)), 0.5); //calculate y coordinate

[Code] ....

I am having the problem drawing the crescent moon that I cannot get the two circles to have the same starting point?

I have managed to get the results to Excel. Everything in that regard works. But when i plot the points on a graph on Excel, they do not have the same starting points. Its essentially just two half circles, one smaller than the other (Stops at the Y axis, giving the half doughnut shape).

If this makes sense, I am trying to get two parts of circles to draw the shape as such that they have the same start and end points. Currently all I am getting more a 'half doughnut' shape, due to the circles not being connected.

View 1 Replies View Related

Visual C++ :: Draw A Shape Or Font On Dialog And Then Fill The Outline?

Jul 8, 2013

I am trying to draw a shape or font on dialog and then fill the outline. I have 2 buttons on this 2 buttons I have the following code

Code:
case IDC_BUTTON1:
MessageBox(hDlg, L"Start Drawing!!", L"ButtonPressed", MB_OK | MB_ICONEXCLAMATION);
hDC = GetDC(hDlg);
brush = CreateSolidBrush(RGB(128, 128, 128));
SelectObject(hDC, brush);

[code].....

When I remove the BeginPath() and EndPath() functions my lines are being drawn. But when I insert this BeginPath() and EndPath() and StrokeAndFillPath(hDC); the nothing is being drawn.

Why it is not doing as per the expectations. I want to draw a shape for example A with a outline. And i want it to be closed when drawing is ended and filled the hollow portion.

What am I doing wrong in this ?I am not implementing it in WM_PAINT but drawing is done in WM_LBUTTONUP.

View 6 Replies View Related

C++ :: Draw A Crescent Moon Shape And Extracted Values To Excel To Be Drawn

Mar 28, 2013

I have some code that will allow me to draw a crescent moon shape, and have extracted the values to excel to be drawn. However in place of some numbers, there is '-1.#IND' in place.

View 3 Replies View Related

C++ :: Keyboard Function That Is Called In Main Function To Make Shape Move

Jan 19, 2013

Ok so I am working on a game and I'm in the process of developing my Player class. Anyways, what I have is a keyboard function that is called in my main function to make a shape move.

void myKeyboardFunction(unsigned char key, int x, int y) {
switch ( key ) {

[Code].....

But when I try to call it, trying to copy my previous method,

glutKeyboardFunc(Player1.playerControls);

I get an error

error C3867: 'Player::playerControls': function call missing argument list; use '&Player::playerControls' to create a pointer to member

I get an error saying it can't convert parameters. I would just like to understand why the arguments become a problem when I make the function a member of my class, when the first method I used is so easy.

View 2 Replies View Related

C++ :: How To Build A Custom Allocator

Feb 7, 2014

I'm trying to write a custom allocator that I can use with the STL. Here's what I have so far :

Code:
#include <cstddef>
#include <iostream>
#include <memory>
#include <vector>
template<class T>
struct customallocator {

[Code].....

I'm doing and currently, my push_back doesn't seem to do anything.

View 12 Replies View Related

C++ :: Custom Vector Class

Oct 9, 2014

Let's say we have a custom Vector class and I need to know which of the following is considered to be more efficient and why of course.

Vector Vector::operator+(const Vector &b) const {
return Vector(x+b.x,y+b.y);
}

Vector Vector::operator+(const Vector &b) const {
Vector tmp(x+b.x,y+b.y);
return tmp;
}

View 1 Replies View Related

C++ :: Using STL Sort With Custom Classes?

Oct 8, 2013

I've written a doubly linked list per my assignment instructions. I've implemented begin() and end() iterators for it, and they work with no problems when traversing the list. However, I need to sort the elements in the list. We are allowed to use the sort function defined in the <algorithm> header since we haven't yet covered sorting algorithms.

But, I'm running into a ton of problems. I figured as long as the begin() and end() iterators were defined for the list, then sort(list.begin(), list.end(), compare) would do the trick. The main errors I'm getting are:

error: no type named iterator_category
error: no type named value_type
error: no type named difference_type
error: no type named pointer
error: no type named reference

And also errors for no match of the + and - operators for the iterator class.

I understand reference, pointer, and value_type, but I have no idea about iterator_category and difference_type. Additionally, I'm a little unsure why the + and - operators need to be overloaded.

View 8 Replies View Related

C++ :: Add Custom MENUITEM To A POPUP?

Jul 13, 2014

I have a POPUP

MAIN_MENU MENU {
POPUP "&Manager" {
MENUITEM "New Royal Python", MENU_NEW_ROYAL_PYTHON
POPUP "&Select Python" {
}
}
}

I basically want to give the POPUP an ID so I can talk with it but it does not seem to be accepting a second parameter. Once I have done that I need to send a message to it to ask it to add a new item, what are the messages I need to send for this?

View 8 Replies View Related

C++ :: Creating A Custom Filetype?

May 21, 2013

I am making a level editor that needs to output a custom map file for use with source code that I will write for a graphics library.

My question is: What do I need to bear in mind when deciding how to structure a custom file type? Also how can I encode a standard bitmap image into my file (the tile set) so that it can all be contained in a single file rather two files; the map file and tile set (.bmp file).

View 3 Replies View Related

C# :: How To Make Custom GUI Theme

Jul 12, 2014

I've done some research and found that people use Mah metro, though I don't want to use that because I want to make a GUI that is fully mine, so I can do what ever I want to customize it to my liking.

I don't know how to get this done in WinForms....

View 2 Replies View Related







Copyrights 2005-15 www.BigResource.com, All rights reserved