Click here to Skip to main content
15,166,498 members
Home / Discussions / C#
   

C#

 
QuestionSend Whatsapp Messages from C# Windows Forms Application Pin
Zeyad Jalil18-Oct-21 2:13
professionalZeyad Jalil18-Oct-21 2:13 
AnswerRe: Send Whatsapp Messages from C# Windows Forms Application Pin
OriginalGriff18-Oct-21 3:22
mveOriginalGriff18-Oct-21 3:22 
GeneralRe: Send Whatsapp Messages from C# Windows Forms Application Pin
Zeyad Jalil18-Oct-21 3:50
professionalZeyad Jalil18-Oct-21 3:50 
GeneralRe: Send Whatsapp Messages from C# Windows Forms Application Pin
Dave Kreskowiak18-Oct-21 4:54
mveDave Kreskowiak18-Oct-21 4:54 
QuestionSql dependency Pin
Nader Rostamkhani17-Oct-21 3:13
MemberNader Rostamkhani17-Oct-21 3:13 
AnswerRe: Sql dependency Pin
OriginalGriff17-Oct-21 3:44
mveOriginalGriff17-Oct-21 3:44 
QuestionDesigning a shape object class in C# Pin
holdorf17-Oct-21 1:48
Memberholdorf17-Oct-21 1:48 
AnswerRe: Designing a shape object class in C# Pin
BillWoodruff17-Oct-21 10:02
mveBillWoodruff17-Oct-21 10:02 
Hi, i happen to be working on a shape library for WinForms C# right now; i'll eventually publish it here, but, can't predict when. Let me offer some general ideas:

1) choice of Framework is important: a lot depends on what you want to do with your shapes. my usage is for custom ring design; for example, i need to calculate equally spaced points along a path like an oval, and that point's tangent (requires calculus); i deal primarily with polygons, circles and ellipses; my goal is to have mock-ups i can take to my manufacturers. so, i'm not concerned with 3d rendering on screen, texturing, etc. and i'm not concerned with interacting with selecting/moving/duplicating shapes on-screen as you expect in a drawing program,

2) for other purposes, like the ones i just said i'm not concerned with, WPF offers a superior graphics engine and facilities; and, for 3d; use Unity. if you do need to select/move/duplicate/dock etc., shapes on-screen: don't use WinForms, use WPF.

3) the interface i am using now: the use of System.Windows requires your WinForm project to have a reference to WindowsBase.dll
using System;
using System.Drawing;
using System.Drawing.Drawing2D;
using System.Windows;

using SdPoint = System.Drawing.Point;
using SwPoint = System.Windows.Point;
using SdSize = System.Drawing.Size;
using SwSize = System.Windows.Size;

using GraphicsPath = System.Drawing.Drawing2D.GraphicsPath;
using GReg = System.Drawing.Region;
using GMat2d = System.Drawing.Drawing2D.Matrix;
using GMatMed = System.Windows.Media.Matrix;

namespace GeomLib_August_2021_III
{
    public enum ShapeType
    {
        Line,
        Arc,
        Rectangle,
        Parallelogram,
        Circle,
        Ellipse,
        RegPolygon,
        IrregPolygon,
        Grid,
        Star
    }

    public interface IShape
    {
        string ShpName { get; }
        string ShpComment { get; }
        DateTime ShpTimeStamp { get; }
        ShapeType ShpType { get; }

        Rect SwRect { get; }
        SwPoint CenterF { get; }
        SwPoint[] PathPoints { get; }

        double GetArea();
        double GetPerimeter();
        SwPoint GetCenter();
        GraphicsPath GetGPath();
        Region GetRegion();

        IShape GetUnion(IShape s1, IShape s2);
        IShape GetIntersection(IShape s1, IShape s2);

        IShape Translate(IShape s1, Matrix m1);
        IShape Rotate(IShape s1, Matrix m1);
        IShape Scale(IShape s1, Matrix m1);

        SwPoint[] Flatten();
        void Render();
        void Save();
        void Load()
    }
}
Each shape name listed in the ShapeType Enum is implemented as a class that inherits from IShape, and implements its fields, and methods.

4) typical OO shape modeling uses "nested" inheritance; you might have:

class Poly : IShape
class Triangle : Poly
class Rectangle : Poly
class Parallelogram : Rectangle

class RegularPolygon : Poly
class EqTriangle : RegularPolygon // or EqTriangle : Triangle
class Square ; RegularPolygon // or Square : Rectangle

class Circle : IShape
class Ellipse : Circle

5) there any number of ways you can organize the top level hierarchy to meet your goals.
«The mind is not a vessel to be filled but a fire to be kindled» Plutarch


modified 18-Oct-21 3:18am.

GeneralRe: Designing a shape object class in C# Pin
Pete O'Hanlon17-Oct-21 22:47
mvaPete O'Hanlon17-Oct-21 22:47 
GeneralRe: Designing a shape object class in C# Pin
BillWoodruff18-Oct-21 1:59
mveBillWoodruff18-Oct-21 1:59 
AnswerRe: Designing a shape object class in C# Pin
Gerry Schmitz17-Oct-21 12:47
mveGerry Schmitz17-Oct-21 12:47 
QuestionLooking for feedback and contributions to database project Pin
Michael Sydney Balloni16-Oct-21 18:27
mvaMichael Sydney Balloni16-Oct-21 18:27 
AnswerRe: Looking for feedback and contributions to database project Pin
Richard MacCutchan16-Oct-21 22:14
mveRichard MacCutchan16-Oct-21 22:14 
GeneralRe: Looking for feedback and contributions to database project Pin
BillWoodruff17-Oct-21 0:36
mveBillWoodruff17-Oct-21 0:36 
GeneralRe: Looking for feedback and contributions to database project Pin
Richard MacCutchan17-Oct-21 2:25
mveRichard MacCutchan17-Oct-21 2:25 
GeneralRe: Looking for feedback and contributions to database project Pin
BillWoodruff17-Oct-21 5:24
mveBillWoodruff17-Oct-21 5:24 
GeneralRe: Looking for feedback and contributions to database project Pin
Richard MacCutchan17-Oct-21 22:52
mveRichard MacCutchan17-Oct-21 22:52 
GeneralRe: Looking for feedback and contributions to database project Pin
BillWoodruff18-Oct-21 4:56
mveBillWoodruff18-Oct-21 4:56 
GeneralRe: Looking for feedback and contributions to database project Pin
Richard MacCutchan18-Oct-21 5:35
mveRichard MacCutchan18-Oct-21 5:35 
GeneralRe: Looking for feedback and contributions to database project Pin
BillWoodruff18-Oct-21 6:38
mveBillWoodruff18-Oct-21 6:38 
GeneralRe: Looking for feedback and contributions to database project Pin
Richard MacCutchan18-Oct-21 6:48
mveRichard MacCutchan18-Oct-21 6:48 
GeneralRe: Looking for feedback and contributions to database project Pin
BillWoodruff18-Oct-21 12:40
mveBillWoodruff18-Oct-21 12:40 
GeneralRe: Looking for feedback and contributions to database project Pin
Richard MacCutchan18-Oct-21 22:39
mveRichard MacCutchan18-Oct-21 22:39 
AnswerRe: Looking for feedback and contributions to database project Pin
BillWoodruff17-Oct-21 0:25
mveBillWoodruff17-Oct-21 0:25 
GeneralRe: Looking for feedback and contributions to database project Pin
Michael Sydney Balloni24-Oct-21 15:14
mvaMichael Sydney Balloni24-Oct-21 15:14 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.