コード例 #1
0
ファイル: EditEntry.cs プロジェクト: easai/Logger
        public override void save()
        {
            using (var db = new OfficeLog())
            {
                var entry = db.Entries.Single(x => x.Id == id);
                entry.LogText = getRtf();

                int recordsAffected = db.SaveChanges();
            }
            logger.refreshScreen();
            Dispose();
        }
コード例 #2
0
ファイル: LoggerForm.cs プロジェクト: easai/Logger
 public void deleteImage(object sender, EventArgs e)
 {
     using (var log = new OfficeLog())
     {
         MenuItem menuItem = ((MenuItem)sender);
         string str = menuItem.Text.Substring(7);
         int index = int.Parse(str);
         var entry = log.Photos.Single(x => x.Id == index);
         log.Photos.Remove(entry);
         log.SaveChanges();
         setPhotoPanel(log);
     }
 }
コード例 #3
0
ファイル: NewEntry.cs プロジェクト: easai/Logger
 public virtual void save()
 {
     using (var db = new OfficeLog())
     {
         var entry = new Entry
         {
             LogDate = DateTime.Now,
             LogText = newEntryText.Rtf
         };
         db.Entries.Add(entry);
         int recordsAffected = db.SaveChanges();
     }
     logger.refreshScreen();
     Dispose();
 }
コード例 #4
0
ファイル: LoggerForm.cs プロジェクト: easai/Logger
        private void setLogPanel(OfficeLog db)
        {
            layout.Controls.Clear();
            var items = from i in db.Entries select i;
            items = items.OrderByDescending(i => i.LogDate).Take(5);
            int height = (int)((this.Height - 130) / 5.0);

            LogButton[] editButtonList = new LogButton[5];
            LogButton[] deleteButtonList = new LogButton[5];
            for (int i = 0; i < 5; i++)
            {
                editButtonList[i] = new LogButton();
                editButtonList[i].Text = "&Edit";
                deleteButtonList[i] = new LogButton();
                deleteButtonList[i].Text = "&Delete";
            }

            int index = 0;
            foreach (var i in items)
            {
                FlowLayoutPanel panel = new FlowLayoutPanel();
                panel.Size = new Size(this.Width, height);
                deleteButtonList[index].id = i.Id;
                deleteButtonList[index].Click += (sender, e) =>
                {
                    using (var log = new OfficeLog())
                    {
                        var entry = log.Entries.Single(x => x.Id == ((LogButton)sender).id);
                        log.Entries.Remove(entry);
                        log.SaveChanges();
                        refreshScreen();
                    }
                };
                editButtonList[index].id = i.Id;
                editButtonList[index].rtf = i.LogText;
                editButtonList[index].Click += (sender, e) =>
                {
                    using (var log = new OfficeLog())
                    {
                        var edit = new EditEntry(((LogButton)sender).id, this);
                        edit.setRtf(((LogButton)sender).rtf);

                        edit.ShowDialog();
                    }
                };
                Label tb = new Label();
                tb.Width = 140;
                tb.Text = i.LogDate.ToString();
                RichTextBox richTextBox = new RichTextBox();
                richTextBox.Dock = DockStyle.Bottom;
                richTextBox.Size = new Size(this.Width - 30, height - 30);
                richTextBox.ReadOnly = true;
                richTextBox.BorderStyle = BorderStyle.None;
                richTextBox.BackColor = Color.White;
                try
                {
                    richTextBox.Rtf = i.LogText;
                }
                catch (Exception)
                {
                    richTextBox.Text += i.LogText;
                }
                using (Graphics g = CreateGraphics())
                {
                    richTextBox.Height = (int)g.MeasureString(richTextBox.Text,
                        richTextBox.Font, richTextBox.Width).Height;
                    panel.Height = Math.Min(height,richTextBox.Height + 30);
                }

                panel.Controls.Add(deleteButtonList[index]);
                panel.Controls.Add(editButtonList[index]);
                panel.Controls.Add(tb);
                panel.Controls.Add(richTextBox);

                layout.Controls.Add(panel);
                index++;
            }
        }
コード例 #5
0
ファイル: LoggerForm.cs プロジェクト: easai/Logger
        private void saveBitmap(Bitmap bmp)
        {
            using (MemoryStream ms = new MemoryStream())
            {
                bmp.Save(ms, System.Drawing.Imaging.ImageFormat.Bmp);
                byte[] array = ms.ToArray();

                using (var log = new OfficeLog())
                {
                    var photo = new Photo
                    {
                        PhotoTime = DateTime.Now,
                        PhotoData = array
                    };
                    log.Database.Log = Console.WriteLine;
                    log.Photos.Add(photo);
                    log.SaveChanges();
                }
            }
        }
コード例 #6
0
ファイル: ImageEditor.cs プロジェクト: easai/Logger
        private void saveToolStripMenuItem_Click(object sender, EventArgs e)
        {
            using (MemoryStream ms = new MemoryStream())
            {

                float fx = (float)pictureBox.Image.Width / pictureBox.Width;
                float fy = (float)pictureBox.Image.Height / pictureBox.Height;
                drawOnImage(Graphics.FromImage(image));

                pictureBox.Image.Save(ms, System.Drawing.Imaging.ImageFormat.Bmp);
                byte[] array = ms.ToArray();

                using (var db = new OfficeLog())
                {
                    var entry = db.Photos.Single(x => x.Id == id);
                    entry.PhotoData = array;

                    int recordsAffected = db.SaveChanges();
                }
                Dispose();
            }
        }