Exemple #1
0
 public GTKViewer(GTKViewerControl c)
 {
     control = c;
     control.ExposeEvent += new ExposeEventHandler(control_Expose);
     control.ButtonPressEvent += new ButtonPressEventHandler(control_ButtonPress);
     control.MotionNotifyEvent += new MotionNotifyEventHandler(control_MotionNotify);
     control.ButtonReleaseEvent += new ButtonReleaseEventHandler(control_ButtonRelease);
     control.KeyPressEvent += new KeyPressEventHandler(control_KeyPressEvent);
     control.KeyReleaseEvent += new KeyReleaseEventHandler(control_KeyReleaseEvent);
     control.SizeAllocated += new SizeAllocatedHandler(control_SizeAllocated);
     control.ScrollEvent += new ScrollEventHandler(control_ScrollEvent);
 }
Exemple #2
0
 public MainWindow()
     : base("MainWindow")
 {
     // create the table and pack into the window
     Table table = new Table(2, 3, false);
     Add(table);
     // Initialze DGraphics
     GTKHelper.InitGraphics();
     // create DViewerControl and attach to table
     GTKViewerControl dvc = new GTKViewerControl();
     table.Attach(dvc, 0, 1, 0, 1, AttachOptions.Fill | AttachOptions.Expand,
                  AttachOptions.Fill | AttachOptions.Expand, 0, 0);
     // create the scrollbars and pack into the table
     VScrollbar vsb = new VScrollbar(null);
     table.Attach(vsb, 1, 2, 0, 1, AttachOptions.Fill|AttachOptions.Shrink,
                  AttachOptions.Fill|AttachOptions.Shrink, 0, 0);
     HScrollbar hsb = new HScrollbar(null);
     table.Attach(hsb, 0, 1, 1, 2, AttachOptions.Fill|AttachOptions.Shrink,
                  AttachOptions.Fill|AttachOptions.Shrink, 0, 0);
     // tell the scrollbars to use the DViewerControl widget's adjustments
     vsb.Adjustment = dvc.Vadjustment;
     hsb.Adjustment = dvc.Hadjustment;
     // create debuging label
     l = new Label("debug");
     table.Attach(l, 0, 1, 2, 3, AttachOptions.Fill|AttachOptions.Shrink,
                  AttachOptions.Fill|AttachOptions.Shrink, 0, 0);
     // create DViewer and DEngine
     dv = new GTKViewer(dvc);
     dv.EditFigures = true;
     #if DEBUG
     dv.DebugMessage += new DebugMessageHandler(DebugMessage);
     #endif
     de = new DEngine(null);
     de.AddViewer(dv);
     de.HsmState = DHsmState.Select;
     #if DEBUG
     de.DebugMessage += new DebugMessageHandler(DebugMessage);
     #endif
     de.ContextClick += new ClickHandler(de_ContextClick);
     // add figures
     de.UndoRedo.Start("add initial figures");
     de.AddFigure(new EllipseFigure(new DRect(20, 30, 100, 100), 0));
     RectFigure rf = new RectFigure(new DRect(10, 20, 100, 100), 0);
     rf.Alpha = 0.7;
     rf.Fill = new DColor(80, 80, 80);
     de.AddFigure(rf);
     TextFigure tf = new TextFigure(new DPoint(150, 30), "hello", 0);
     tf.FontName = "Arial";
     tf.Underline = true;
     tf.Strikethrough = true;
     tf.Italics = true;
     de.AddFigure(tf);
     // compositing figure
     Figure f = new CompositedExampleFigure();
     f.Rect = new DRect(20, 150, 50, 50);
     de.AddFigure(f);
     // clock (IEditable) figure
     f = new ClockFigure();
     f.Rect = new DRect(200, 200, 100, 100);
     de.AddFigure(f);
     // triangle figure
     f = new TriangleFigure();
     f.Rect = new DRect(200, 100, 100, 100);
     ((TriangleFigure)f).StrokeWidth = 10;
     de.AddFigure(f);
     // line figure
     f = new LineFigure2(new DPoint(100, 100), new DPoint(200, 200));
     ((LineFigure2)f).StrokeStyle = DStrokeStyle.DashDot;
     ((LineFigure2)f).StrokeWidth = 5;
     de.AddFigure(f);
     de.UndoRedo.Commit();
     de.UndoRedo.ClearHistory();
     // resize window
     Resize(400, 300);
 }