public TextSheetNetworkService(SendingQueue sender, PresentationModel presentation, DeckModel deck, SlideModel slide, TextSheetModel sheet, SheetMessage.SheetCollection selector)
            : base(sender, presentation, deck, slide, sheet, selector)
        {
            this.sheet_ = sheet;

            this.sheet_.Changed["Text"].Add(new PropertyEventHandler(this.SendText));
            this.sheet_.Changed["Color"].Add(new PropertyEventHandler(this.SendText));
            this.sheet_.Changed["IsPublic"].Add(new PropertyEventHandler(this.SendPublic));
        }
        public TextSheetMessage(TextSheetModel sheet, SheetCollection collection)
            : base(sheet, collection)
        {
            using(Synchronizer.Lock(sheet.SyncRoot)) {
                this.Text = sheet.Text;
                this.font_ = sheet.Font;
                this.color_ = sheet.Color;
                this.is_public_ = sheet.IsPublic;

            }
        }
        public TextSheetRenderer(SlideDisplayModel display, TextSheetModel sheet)
            : base(display, sheet)
        {
            this.m_Sheet = sheet;

            repaint_dispatcher_ = new EventQueue.PropertyEventDispatcher(SlideDisplay.EventQueue, this.Repaint);
            /// Add event listeners
            this.m_Sheet.Changed["Text"].Add(new PropertyEventHandler(this.repaint_dispatcher_.Dispatcher));
            this.m_Sheet.Changed["Bounds"].Add(new PropertyEventHandler(this.repaint_dispatcher_.Dispatcher));
            this.m_Sheet.Changed["Color"].Add(new PropertyEventHandler(this.repaint_dispatcher_.Dispatcher));
            this.SlideDisplay.Changed["Slide"].Add(new PropertyEventHandler(this.repaint_dispatcher_.Dispatcher));
        }
        public TextSheetUndoService(EventQueue dispatcher, UndoModel undo, DeckModel deck, SlideModel slide, TextSheetModel sheet)
            : base(undo, deck, slide, sheet)
        {
            this.m_EventQueue = dispatcher;
            this.m_SheetChangedDispatcher = new EventQueue.PropertyEventDispatcher(this.m_EventQueue, new PropertyEventHandler(this.HandleSheetChanged));

            //Ignore any sheets with the Remote flag
            if ((sheet.Disposition & SheetDisposition.Remote) == 0) {
                this.Sheet.Changed["Text"].Add(this.m_SheetChangedDispatcher.Dispatcher);
                this.Sheet.Changed["Font"].Add(this.m_SheetChangedDispatcher.Dispatcher);
            }
        }
Exemple #5
0
        public override object CloneToRemote()
        {
            Rectangle bounds;

            using (Synchronizer.Lock(this.SyncRoot)) {
                bounds = this.Bounds;
            }
            TextSheetModel tsm = new TextSheetModel(Guid.NewGuid(), text_, this.Disposition | SheetDisposition.Remote, is_editable_, public_, bounds, color_, font_);

            tsm.is_editable_ = false;
            return(tsm);
        }
        /// <summary>
        /// Constructor for loading from a TextSheetModel 
        /// </summary>
        /// <param name="sheet"></param>
        /// <param name="viewer"></param>
        public TextItBox(TextSheetModel sheet, MainSlideViewer viewer)
            : base(sheet,viewer)
        {
            ///Initialize Components
            InitializeComponent();
            text_sheet_ = sheet;
            actual_control_ = textItText1;
            using (Synchronizer.Lock(text_sheet_.SyncRoot)) {
                textItText1.ForeColor = text_sheet_.Color;
                slide_font_ = text_sheet_.Font;
                this.textItText1.Text = text_sheet_.Text;
            }

            ///we got slide coordinates from the textsheet, and now need to transform the control
            ///appropriately
            Transform();

            PaintSheet(true);
            save_timer.Start();
        }
        protected override bool UpdateTarget(ReceiveContext context)
        {
            TextSheetModel sheet = this.Target as TextSheetModel;
            if (sheet == null) {
                ///if we sent it, this means that by definition the sheet is public
                ///edit: made is_editable true so that instructors can copy and paste student code
                this.Target = sheet = new TextSheetModel(((Guid)this.TargetId), this.Text, true, true, this.Bounds, this.color_, this.font_);
            }

            using (Synchronizer.Lock(sheet.SyncRoot)) {
                sheet.Text = this.Text;
                sheet.Font = this.font_;
                sheet.IsEditable = false;
                ///if we sent it, this means that by definition the sheet is public
                sheet.IsPublic = true;
                sheet.Color = this.color_;
            }

            base.UpdateTarget(context);

            return true;
        }
        /// <summary>
        /// Adds a text sheet to the annotationsheets at a point relative
        /// to the user's view
        /// </summary>
        /// <param name="p">where the text sheet will be located</param>
        /// <param name="scale_x"></param>
        /// <param name="scale_y"></param>
        /// <param name="i_scale_x"></param>
        /// <param name="i_scale_y"></param>
        private void AddTextSheet(Point p, float i_scale_x, float i_scale_y)
        {
            TextSheetModel t;

            using (Synchronizer.Lock(current_stylus_.SyncRoot)) {
                ///create a textsheetmodel so that it will appear where we clicked in a good size
                t = new TextSheetModel(Guid.NewGuid(), "", SheetDisposition.All, true, true, current_stylus_.DrawingAttributes.Color,
                    new Rectangle(new Point(Math.Min(p.X, SlideWidth - 10 - TextItBox.default_size.Width), Math.Min(p.Y, SlideHeight - TextItBox.default_size.Height)), TextItBox.default_size),
                    i_scale_x, i_scale_y);
            }
            //Remove the sheets that just represent empty text boxes.
            for (int i = Slide.AnnotationSheets.Count - 1; i >= 0; i--) {
                bool remove = false;
                SheetModel s = Slide.AnnotationSheets[i];
                using (Synchronizer.Lock(s.SyncRoot)) {
                    if (s is TextSheetModel) {
                        using (Synchronizer.Lock(((TextSheetModel)(s)).Text)) {
                            if (((TextSheetModel)(s)).Text == "") {
                                remove = true;
                            }
                        }
                    }
                }
                if (remove) {
                    using (Synchronizer.Lock(Slide.SyncRoot)) {
                        using (Synchronizer.Lock(Slide.AnnotationSheets)) {
                            Slide.AnnotationSheets.Remove(s);
                        }
                    }
                }
            }

            ///add the sheet to our annotationsheets.
            ///
            using (Synchronizer.Lock(this.Slide.SyncRoot)) {
                    this.Slide.AnnotationSheets.Add(t);
            }
        }
 public override object CloneToRemote()
 {
     Rectangle bounds;
     using (Synchronizer.Lock(this.SyncRoot)) {
         bounds = this.Bounds;
     }
     TextSheetModel tsm = new TextSheetModel(Guid.NewGuid(), text_, this.Disposition | SheetDisposition.Remote, is_editable_, public_, bounds, color_, font_);
     tsm.is_editable_ = false;
     return tsm;
 }