Beispiel #1
0
        public MyForm()
        {
            Title  = "Simple image editor";
              Width  = 420;
              Height = 400;
              Background = System.Windows.Media.Brushes.Transparent;

              toolBar = new ToolBar();

              open = new Button();
              save = new Button();

              resize = new Button();

              incBright = new Button();
              decBright = new Button();

              incContrast = new Button();
              decContrast = new Button();

              flip90 = new Button();
              mirror = new Button();

              exit = new Button();

              open.Tag     = "Open";
              open.Content = "open";
              save.Tag     = "Save";
              save.Content = "save";

              resize.Tag     = "Resize";
              resize.Content = "resize";

              incBright.Tag     = "incBr";
              incBright.Content = "inc br";
              decBright.Tag     = "decBr";
              decBright.Content = "dec br";

              incContrast.Tag     = "incCon";
              incContrast.Content = "inc con";
              decContrast.Tag     = "decCon";
              decContrast.Content = "dec con";

              flip90.Tag     = "Flip90";
              flip90.Content = "flip";
              mirror.Tag     = "Mirror";
              mirror.Content = "mirror";

              exit.Tag     = "Exit";
              exit.Content = "exit";

              toolBar.Items.Add(open);
              toolBar.Items.Add(save);
              toolBar.Items.Add(new Separator());
              toolBar.Items.Add(resize);
              toolBar.Items.Add(incBright);
              toolBar.Items.Add(decBright);
              toolBar.Items.Add(incContrast);
              toolBar.Items.Add(decContrast);
              toolBar.Items.Add(flip90);
              toolBar.Items.Add(mirror);
              toolBar.Items.Add(new Separator());
              toolBar.Items.Add(exit);

              toolBar.Height = 32;
              toolBar.VerticalAlignment = VerticalAlignment.Top;
              this.AddChild(toolBar);

              foreach (var ctrl in toolBar.Items) {
            var btn = ctrl as Button;
            if (btn != null) {
              btn.Click += this.onClicked;
            }
              }

              imgView = new MyImageView(imgWidth, imgHeight);
              img = new MyImage("c:\\tmp\\f1.jpeg");

              Mouse.AddMouseUpHandler(this, onMouseUp);
              Mouse.AddMouseMoveHandler(this, onMouseMove);
              //this.MouseUp += new MouseEventHandler(onMouseUp);
              // MouseMove += new MouseEventHandler(onMouseMove);

              this.Show();
        }
Beispiel #2
0
        public MyForm()
        {
            Text = "Simple image editor";
              Size = new Size(420, 400);

              toolBar = new ToolBar();
              toolBar.Parent = this;

              open = new ToolBarButton();
              save = new ToolBarButton();

              resize = new ToolBarButton();

              incBright = new ToolBarButton();
              decBright = new ToolBarButton();

              incContrast = new ToolBarButton();
              decContrast = new ToolBarButton();

              flip90 = new ToolBarButton();
              mirror = new ToolBarButton();

              exit = new ToolBarButton();

              var spacer = new ToolBarButton();
              spacer.Style = ToolBarButtonStyle.Separator;

              open.Tag  = "Open";
              open.Text = "open";
              save.Tag  = "Save";
              save.Text = "save";

              resize.Tag  = "Resize";
              resize.Text = "resize";

              incBright.Tag  = "incBr";
              incBright.Text = "inc br";
              decBright.Tag  = "decBr";
              decBright.Text = "dec br";

              incContrast.Tag  = "incCon";
              incContrast.Text = "inc con";
              decContrast.Tag  = "decCon";
              decContrast.Text = "dec con";

              flip90.Tag  = "Flip90";
              flip90.Text = "flip";
              mirror.Tag  = "Mirror";
              mirror.Text = "mirror";

              exit.Tag  = "Exit";
              exit.Text = "exit";

              toolBar.ShowToolTips = true;
              toolBar.Buttons.AddRange(new ToolBarButton[] {open, save,
                                                    spacer,
                                                    resize,
                                                    incBright, decBright,
                                                    incContrast, decContrast,
                                                    flip90, mirror,
                                                    spacer,
                                                    exit});
              toolBar.ButtonClick += new ToolBarButtonClickEventHandler(onClicked);

              imgView = new MyImageView(imgWidth, imgHeight);
              img = new MyImage();

              Paint += new PaintEventHandler(onPaint);
              MouseUp += new MouseEventHandler(onMouseUp);
              MouseMove += new MouseEventHandler(onMouseMove);
        }