예제 #1
0
        public void AddSticky(StickyBase stickyBase)
        {
            object temp = new object();
            int id = temp.GetHashCode();

            logger.Debug("Adding sticky with id " + id);

            NoteWindow window = new NoteWindow(id);

            stickies.Add(id, window);

            string[] parts = stickyBase.Text.Replace("\\r\\n", "~").Split('~');
            parts.Foreach((p) => window.TxtData.AppendText(p + Environment.NewLine));

            window.Left = stickyBase.X;
            window.Top = stickyBase.Y;
            window.Width = stickyBase.Width;
            window.Height = stickyBase.Height;
            window.Handle.Pinned = stickyBase.Pinned;
            if (stickyBase.Minimized)
            {
                window.Handle.OldHeight = stickyBase.Height;
                window.Handle.Minimize();
            }
            window.TxtData.FontSize = stickyBase.FontSize;

            window.Handle.OptionStore = store;
            window.Handle.WindowIsClosing += WindowClose;
            window.Handle.WindowIsDeactivated += LostFocus;

            if (stickyBase.Visible)
            {
                window.Show();
            }
            else
            {
                window.Hide();
            }

            if (stickyChanged != null)
            {
                stickyChanged(this, new KeyValuePair<int, NoteWindow>(id, window));
            }
        }
예제 #2
0
        public void LoadStickies()
        {
            logger.Info("Attempting to load stickies.");
            List<StickyBase> stickies = new List<StickyBase>();

            if (File.Exists(fullPath))
            {
                using (StreamReader reader = new StreamReader(fullPath))
                {
                    string line;
                    while ((line = reader.ReadLine()) != null)
                    {
                        if (line.Trim() != "")
                        {
                            try
                            {
                                string[] parts = line.Split(';');

                                StickyBase sticky = new StickyBase()
                                {
                                    Text = parts[0],
                                    X = Convert.ToInt32(parts[1]),
                                    Y = Convert.ToInt32(parts[2]),
                                    Width = Convert.ToInt32(parts[3]),
                                    Height = Convert.ToInt32(parts[4]),
                                    Minimized = Convert.ToBoolean(parts[5]),
                                    Pinned = Convert.ToBoolean(parts[6]),
                                    FontSize = Convert.ToDouble(parts[7]),
                                    Visible = Convert.ToBoolean(parts[8])
                                };

                                stickies.Add(sticky);
                            }
                            catch (Exception e)
                            {
                                logger.Error(e.Message);
                                Box.Show("An error occured while loading your sticky notes:\n\t" + e.Message, "Error Loading Stickies", MessageBoxButton.OK, MessageBoxImage.Error);
                            }
                        }
                    }
                }
            }

            if (stickies.Count > 0 && stickiesLoaded != null)
            {
                stickiesLoaded(this, stickies);
            }
        }
예제 #3
0
 public void AddSticky(string text)
 {
     StickyBase sticky = new StickyBase()
     {
         Text = text,
         X = 100,
         Y = 100,
         Width = 200,
         Height = 100,
         FontSize = 12,
         Visible = true
     };
     AddSticky(sticky);
 }