コード例 #1
0
        /// <summary>
        /// Exports the calendar to a picture file.
        /// </summary>
        public static bool GenerateImage(string filename)
        {
            Calendar.DropSelection();
            Draw.Multiplier = Multiplier;
            Draw.Recalculate();

            Global.Canvas.Dispatcher.Invoke(DispatcherPriority.Render, (Action) delegate() { });

            RenderTargetBitmap rtb = new RenderTargetBitmap(
                DrawClass.CanvasWidth, DrawClass.CanvasHeight,
                96, 96, PixelFormats.Default);

            rtb.Render(Global.Canvas);

            BitmapEncoder pngEncoder = new PngBitmapEncoder();

            pngEncoder.Frames.Add(BitmapFrame.Create(rtb));

            using (Stream stream = System.IO.File.OpenWrite(filename))
            {
                pngEncoder.Save(stream);
            }

            Draw.Multiplier = 1;
            Draw.Recalculate();

            return(true);
        }
コード例 #2
0
        /// <summary>
        /// Creates a new instance of the Calendar object.
        /// </summary>
        /// <param name="newInstance">Whether or not the calendar should act as a new instance, and create its content itself.
        /// <para>The alternative is when loading a saved calendar.</para></param>
        public Calendar(bool newInstance)
        {
            Global.Calendar = this;
            Global.ResetCalendarData();

            if (newInstance)
            {
                GetCalendar();
            }

            Draw.Recalculate();
        }
コード例 #3
0
ファイル: File.cs プロジェクト: vivianvea/calendar-designer
        /// <summary>
        /// Opens a calendar file.
        /// <para>Returns the success of the opperation.</para>
        /// </summary>
        /// <param name="filename">The path of the calendar to open.</param>
        public static bool Open(string filename)
        {
            bool success = ReadFile(filename, out Calendar calendar);

            if (!success)
            {
                return(false);
            }

            Global.ResetCalendarData();
            Global.Path = filename;
            Draw.Recalculate();

            return(true);
        }