Example #1
0
 public FindCellCommand(CanvasHostViewModel viewModel, System.Drawing.Color fillColor)
     : this(viewModel)
 {
     //Will fill the cell without asking for a color from the color dialog
     askForColor = false;
     this.fillColor = fillColor;
 }
        /// <summary>
        /// Loads the image file into a new CanvasHost model.
        /// </summary>
        private void OpenFile()
        {
            var dialog = new OpenFileDialog();

            dialog.Filter = "Images|*.jpg;*.png;*.gif";
            var result = dialog.ShowDialog();

            if (result == true)
            {
                CanvasHost  = new CanvasHostViewModel(new Uri(dialog.FileName));
                ImageLoaded = true;
                CanClose    = true;
                _frames.Add(new Frame());
            }
        }
        /// <summary>
        /// Constructs a new model from an specific image source.
        /// </summary>
        /// <param name="uri">The file path to the image to load into the background layer</param>
        public CanvasHostViewModel(Uri uri)
        {
            self      = this;
            animation = Animation.newInstance();

            Cells = new ObservableCollection <Cell>();
            Leds  = new ObservableCollection <Led>();
            //Frames = new ObservableCollection<Frame>();
            TouchRegions = new ObservableCollection <TouchRegion>();

            currentFrame = 0;
            animation.addFrame(new Frame());

            ImageSource = new BitmapImage(uri);
            _image      = new Bitmap(uri.LocalPath);
            Tolerance   = 30;
            _canvasMode = CanvasHostMode.None;
            BoardHeight = 150;
        }
        public static ICanvasHostCommand Create(CanvasHostViewModel viewModel,  CanvasHostMode mode)
        {
            switch (mode)
            {
                case CanvasHostMode.ColorFill:
                    return new FindCellCommand(viewModel);

                case CanvasHostMode.PlaceLED:
                    return new PlaceLedCommand(viewModel);

                case CanvasHostMode.CreateTouchRegion:
                    return new CreateTouchRegionCommand(viewModel);

                case CanvasHostMode.PlaceLEDWithoutCell:
                    return new FindCellCommand(viewModel, System.Drawing.Color.FromArgb(0, 0, 0, 0)); //Transparent white

                case CanvasHostMode.None:
                default:
                    return null;
            }
        }
Example #5
0
 public PlaceLedCommand(CanvasHostViewModel viewModel)
 {
     _viewModel = viewModel;
 }
 /// <summary>
 /// Constructor 
 /// </summary>
 /// <param name="viewModel"></param>
 public CreateTouchRegionCommand(CanvasHostViewModel viewModel)
 {
     _viewModel = viewModel;
 }
Example #7
0
 public FindCellCommand(CanvasHostViewModel viewModel)
 {
     _viewModel = viewModel;
 }