Esempio n. 1
0
        /// <summary>
        /// Initializes this new instance of the Sketch class.
        /// </summary>
        internal void Initialize()
        {
            // Initialize Oval Style
            OvalStyle = new KimonoStyle()
            {
                StyleType = KimonoStyleType.Standard,
                HasFill   = true,
                HasFrame  = true
            };

            // Configure new Oval Style
            OvalStyle.Fill.BlendMode    = SKBlendMode.SrcOver;
            OvalStyle.Fill.IsAntialias  = true;
            OvalStyle.FillColor         = Orange;
            OvalStyle.Frame.BlendMode   = SKBlendMode.SrcOver;
            OvalStyle.Frame.IsAntialias = true;
            OvalStyle.Frame.StrokeWidth = 1f;
            OvalStyle.Frame.StrokeMiter = 4f;
            OvalStyle.Frame.StrokeJoin  = SKStrokeJoin.Mitter;
            OvalStyle.Frame.StrokeCap   = SKStrokeCap.Butt;
            OvalStyle.Frame.Color       = new SKColor(0, 0, 0, 255);


            // Property connections for Oval Style.
            OvalStyle.PropertyConnections.Add(new KimonoPropertyConnection(KimonoPropertyConnectionPoint.FillColor, ColorProperty));


            // Initialize Sketch
            Name        = "Sketch";
            DrawCanvas  = true;
            Width       = 640f;
            Height      = 480f;
            CanvasColor = new SKColor(255, 255, 255, 255);
            Portfolio   = new KimonoPortfolio(true);
            Portfolio.Sketches.Add(this);
            ObiScriptPortfolio.Portfolio = Portfolio;


            // Draw Oval shape
            var Oval = new KimonoShapeOval(40.5625f, 47.37891f, 192.1406f, 194.7109f)
            {
                RotationDegrees = 0,
                Visible         = true,
                Style           = OvalStyle
            };


            Shapes.Add(Oval);
            // Accumulate Kimono objects into the portfolio
            Portfolio.Colors.Add(Orange);
            Portfolio.Colors.Add(Purple);
            Portfolio.Styles.Add(OvalStyle);
            Portfolio.Properties.Add(UseOrange);
            Portfolio.Properties.Add(ColorProperty);
        }
Esempio n. 2
0
        /// <summary>
        /// Attempts to open the file at the specified URL. If the file is currently open
        /// in a window, that will be brought to the front and selected instead of opening
        /// another copy of the file.
        /// </summary>
        /// <returns><c>true</c>, if file was opened, <c>false</c> otherwise.</returns>
        /// <param name="url">A <c>NSUrl</c> pointing to the file to open.</param>
        public bool OpenFile(NSUrl url)
        {
            var good = false;

            // Trap all errors
            try
            {
                var path = url.Path;

                // Is the file already open?
                foreach (NSWindow window in NSApplication.SharedApplication.Windows)
                {
                    var content = window.ContentViewController as ViewController;
                    if (content != null && path == content.FilePath)
                    {
                        // Bring window to front
                        window.MakeKeyAndOrderFront(this);
                        return(true);
                    }
                }

                // Load in portfolio
                var data      = File.ReadAllText(path);
                var portfolio = new KimonoPortfolio(data);

                // Get new window
                var storyboard = NSStoryboard.FromName("Main", null);
                var controller = storyboard.InstantiateControllerWithIdentifier("MainWindow") as NSWindowController;

                // Display
                controller.ShowWindow(this);

                // Load portfolio into the window
                var viewController = controller.Window.ContentViewController as ViewController;
                viewController.Surface.Portfolio = portfolio;
                viewController.View.Window.SetTitleWithRepresentedFilename(Path.GetFileName(path));
                viewController.View.Window.RepresentedUrl = url;

                // Add document to the Open Recent menu
                NSDocumentController.SharedDocumentController.NoteNewRecentDocumentURL(url);

                // Make as successful
                good = true;
            }
            catch
            {
                // Mark as bad file on error
                good = false;
            }

            // Return results
            return(good);
        }
Esempio n. 3
0
        /// <summary>
        /// Replaces the last undo point with the one being passed in.
        /// </summary>
        /// <param name="portfolio">The current state of the <c>KimonoPortfolio</c>.</param>
        public void ReplaceLastUndoPoint(KimonoPortfolio portfolio)
        {
            // Clear the redo stack
            RedoStack.Clear();

            // Save point
            if (UndoStack.Count > 0)
            {
                UndoStack[0] = portfolio;
            }
            else
            {
                UndoStack.Add(portfolio);
            }
            RaiseUndoStateChanged();
        }
Esempio n. 4
0
        /// <summary>
        /// Pushes the undo point onto the stack.
        /// </summary>
        /// <param name="portfolio">The current state of the <c>KimonoPortfolio</c>.</param>
        public void PushUndoPoint(KimonoPortfolio portfolio)
        {
            // Clear the redo stack
            RedoStack.Clear();

            // Save point and update UI
            UndoStack.Insert(0, portfolio.Clone());
            RaiseUndoStateChanged();

            // Have we reached the maximum number of points?
            if (UndoStack.Count >= MaximumUndoPoints)
            {
                // Yes, discard older points
                UndoStack.RemoveAt(UndoStack.Count - 1);
            }
        }
Esempio n. 5
0
        /// <summary>
        /// Pops the redo point off the stack.
        /// </summary>
        /// <returns>The previous state of the <c>KimonoPortfolio</c>.</returns>
        /// <param name="portfolio">The current state of the <c>KimonoPortfolio</c>.</param>
        public KimonoPortfolio PopRedoPoint(KimonoPortfolio portfolio)
        {
            // Anything to process?
            if (!CanRedo)
            {
                return(null);
            }

            // Grab point
            var previousVersion = RedoStack[0];

            RedoStack.RemoveAt(0);

            // Save redo point and update UI
            UndoStack.Insert(0, portfolio);
            RaiseUndoStateChanged();

            // Return point
            return(previousVersion);
        }