コード例 #1
0
 public override void AssignImage(ImageProvider imageProvider)
 {
 }
コード例 #2
0
 public abstract void AssignImage(ImageProvider imageProvider);
コード例 #3
0
        public FlipWindow(MoveableProvider provider,
                          ImageProvider imageProvider,
                          OpenDeleteScriptDelegate openDeleteScriptDelegate,
                          SaveScriptDelegate saveScriptDelegate,
                          DeserialisationHelper deserialisationHelper)
        {
            if (provider == null)
            {
                throw new ArgumentNullException("provider");
            }
            if (imageProvider == null)
            {
                throw new ArgumentNullException("imageProvider");
            }
            if (openDeleteScriptDelegate == null)
            {
                throw new ArgumentNullException("openDeleteScriptDelegate");
            }
            if (saveScriptDelegate == null)
            {
                throw new ArgumentNullException("saveScriptDelegate");
            }
            if (deserialisationHelper == null)
            {
                throw new ArgumentNullException("deserialisationHelper");
            }

            this.provider                 = provider;
            this.imageProvider            = imageProvider;
            this.openDeleteScriptDelegate = openDeleteScriptDelegate;
            this.saveScriptDelegate       = saveScriptDelegate;
            ChosenDeserialisationHelper   = deserialisationHelper;

            InitializeComponent();

            /*
             * New SizedCanvas which unlike Canvas reports a desired size
             * (by overriding MeasureOverride) based on the positions of
             * its children, and hence can be used with a ScrollViewer.
             */
            mainCanvas            = new SizedCanvas();
            mainCanvas.Name       = "mainCanvas";
            mainCanvas.Background = Brushes.Transparent;
            mainCanvas.AllowDrop  = true;
            scrollViewer.Content  = mainCanvas;

            blockBox = new MoveablesPanel();
            Grid.SetRow(blockBox, 1);
            Grid.SetColumn(blockBox, 1);
            Grid.SetRowSpan(blockBox, 2);
            blockBox.PreviewDrop += ReturnMoveableToBox;

            provider.Populate(blockBox);

            mainGrid.Children.Add(blockBox);

            /*
             * Was MouseDown but ScrollViewer suppresses this event
             * so now using PreviewMouseDown. GetDragSource only
             * gets a reference to what was clicked on and where,
             * so there's no reason to believe this change would
             * affect any other program logic, and it doesn't seem to.
             */
            PreviewMouseDown += GetDragSource;
            MouseMove        += StartDrag;
            mainCanvas.Drop  += DroppedOnCanvas;

            PreviewDragEnter += CreateAdorner;
            PreviewDragOver  += UpdateAdorner;
            PreviewDragLeave += DestroyAdorner;
            PreviewDrop      += DestroyAdorner;

            // Set up trigger bar:
            triggerBar = new TriggerBar(new SpineFitter());
            triggerBar.SaveButton.Click += SaveScript;
            Canvas.SetTop(triggerBar, 30);
            Canvas.SetLeft(triggerBar, 30);
            mainCanvas.Children.Add(triggerBar);
            triggerBar.Changed += ScriptChanged;
            UpdateNaturalLanguageView(triggerBar);

            // Set up conditional frame:
            conditionalFrame = new ConditionalFrame();
            conditionalFrame.SaveButton.Click += SaveScript;
            //conditionalFrame.FinishButton.Click += LeaveConditionModeWithDialog;
            Canvas.SetTop(conditionalFrame, 30);
            Canvas.SetLeft(conditionalFrame, 30);
            mainCanvas.Children.Add(conditionalFrame);
            conditionalFrame.Changed += ScriptChanged;
            UpdateNaturalLanguageView(conditionalFrame);

            if (mainCanvas.ContextMenu == null)
            {
                mainCanvas.ContextMenu = new ContextMenu();
            }
            MenuItem paste = new MenuItem();

            paste.Header = "Paste";
            paste.Click += delegate
            {
                try {
                    if (Moveable.CopiedToClipboard != null)
                    {
                        Moveable copied   = Moveable.CopiedToClipboard.DeepCopy();
                        Point    position = Mouse.GetPosition(this);
                        copied.MoveTo(position);
                        PlaceInWorkspace(copied);
                        //ActivityLog.Write(new Activity("PlacedBlock","Block",copied.GetLogText(),"PlacedOn","Canvas"));
                        Log.WriteAction(LogAction.placed, "block", copied.GetLogText() + " on canvas");
                    }
                }
                catch (Exception x) {
                    MessageBox.Show("Something went wrong when copy-pasting.\n\n" + x);
                }
            };
            mainCanvas.ContextMenu.Items.Add(paste);
            mainCanvas.ContextMenuOpening += delegate
            {
                paste.IsEnabled = (Moveable.CopiedToClipboard != null);
            };

            LeaveConditionMode();
        }