Example #1
0
        /// <summary>
        /// Load a Curve from given filename.
        /// </summary>
        /// <param name="filename"></param>
        /// <param name="name"></param>
        /// <param name="color"></param>
        /// <param name="commandHistory"></param>
        /// <returns></returns>
        public static EditCurve LoadFromFile(string filename, string name,
                                             System.Drawing.Color color, CommandHistory commandHistory)
        {
            EditCurve editCurve = null;

            using (XmlReader xr = XmlReader.Create(filename))
            {
                Curve curve = IntermediateSerializer.Deserialize <Curve>(xr,
                                                                         Path.GetDirectoryName(filename));
                editCurve = new EditCurve(name, color, curve, commandHistory);
            }

            return(editCurve);
        }
        /// <summary>
        /// Load a Curve from given filename.
        /// </summary>
        /// <param name="filename"></param>
        /// <param name="name"></param>
        /// <param name="color"></param>
        /// <param name="commandHistory"></param>
        /// <returns></returns>
        public static EditCurve LoadFromFile(string filename, string name,
                                             System.Drawing.Color color, CommandHistory commandHistory)
        {
            EditCurve editCurve = null;

            using (XmlReader xr = XmlReader.Create(filename))
            {
                throw new NotImplementedException("IntermediateSerializer.Deserialize<Curve>() has not been implemented in this fork.");
                //Curve curve = IntermediateSerializer.Deserialize<Curve>(xr,
                //                                    Path.GetDirectoryName(filename));
                //editCurve = new EditCurve(name, color, curve, commandHistory);
            }

            return(editCurve);
        }
        /// <summary>
        /// Make sure CommandHistory added as a service to given site.
        /// </summary>
        /// <param name="serviceProvider"></param>
        /// <remarks>You have to make sure added IServiceContainer to this
        /// serviceProvider.</remarks>
        public static CommandHistory EnsureHasService(IServiceProvider serviceProvider)
        {
            CommandHistory   result = null;
            IServiceProvider sp     = serviceProvider;

            if (sp != null)
            {
                // Add this CommandHistory service if given service
                // doesn't contains it.
                result = sp.GetService(typeof(CommandHistory)) as CommandHistory;
                if (result == null)
                {
                    // If there are no service, added new instance.
                    IServiceContainer s = sp.GetService(typeof(IServiceContainer))
                                          as IServiceContainer;

                    if (s == null)
                    {
                        throw new InvalidOperationException(
                                  CurveControlResources.RequireServiceContainer);
                    }

                    result = new CommandHistory();
                    s.AddService(typeof(CommandHistory), result);
                }
            }
            else
            {
                // If they don't have ISite, returns static instance.
                if (staticCommandHistory == null)
                {
                    staticCommandHistory = new CommandHistory();
                }

                result = staticCommandHistory;
            }

            return(result);
        }
Example #4
0
        /// <summary>
        /// Make sure CommandHistory added as a service to given site.
        /// </summary>
        /// <param name="serviceProvider"></param>
        /// <remarks>You have to make sure added IServiceContainer to this
        /// serviceProvider.</remarks>
        public static CommandHistory EnsureHasService(IServiceProvider serviceProvider)
        {
            CommandHistory result = null;
            IServiceProvider sp = serviceProvider;
            if (sp != null)
            {
                // Add this CommandHistory service if given service
                // doesn't contains it.
                result = sp.GetService(typeof(CommandHistory)) as CommandHistory;
                if (result == null)
                {
                    // If there are no service, added new instance.
                    IServiceContainer s = sp.GetService(typeof(IServiceContainer))
                        as IServiceContainer;

                    if (s == null)
                    {
                        throw new InvalidOperationException(
                            CurveControlResources.RequireServiceContainer);
                    }

                    result = new CommandHistory();
                    s.AddService(typeof(CommandHistory), result);
                }
            }
            else
            {
                // If they don't have ISite, returns static instance.
                if (staticCommandHistory == null)
                    staticCommandHistory = new CommandHistory();

                result = staticCommandHistory;
            }

            return result;
        }
Example #5
0
        /// <summary>
        /// Load a Curve from given filename.
        /// </summary>
        /// <param name="filename"></param>
        /// <param name="name"></param>
        /// <param name="color"></param>
        /// <param name="commandHistory"></param>
        /// <returns></returns>
        public static EditCurve LoadFromFile(string filename, string name,
                                            System.Drawing.Color color, CommandHistory commandHistory)
        {
            EditCurve editCurve = null;
            using (XmlReader xr = XmlReader.Create(filename))
            {
                Curve curve = IntermediateSerializer.Deserialize<Curve>(xr,
                                                    Path.GetDirectoryName(filename));
                editCurve = new EditCurve(name, color, curve, commandHistory);
            }

            return editCurve;
        }
Example #6
0
        public EditCurve(string name, System.Drawing.Color curveColor, Curve curve,
                            CommandHistory commandHistory)
        {
            originalCurve = curve;
            this.color = curveColor;
            keys = new EditCurveKeyCollection(this);

            state.Name = name;
            state.PreLoop = OriginalCurve.PreLoop;
            state.PostLoop = OriginalCurve.PostLoop;

            this.commandHistory = commandHistory;
        }
Example #7
0
 private void CurveEditor_Load(object sender, EventArgs e)
 {
     commandHistory = CommandHistory.EnsureHasService(Site);
 }