Пример #1
0
 public void Exit(bool save = true)
 {
     ManagerForm.OnCloseForm(Id);
     if (save)
     {
         Save(false);
     }
     Close();
 }
Пример #2
0
        private void OpenForm()
        {
            if (selectedId == -1)
            {
                return;
            }

            List <SaveManager.SaveData> postits = SaveManager.LoadFiles();

            SaveManager.SaveData save = postits[selectedId];
            ManagerForm.NewWindow(save.Id, save.RichText, true, new Point(save.X, save.Y), new Size(save.Width, save.Height));
        }
Пример #3
0
        private void DeleteForm()
        {
            if (selectedId == -1)
            {
                return;
            }

            flowLayoutPanel1.Controls.Remove(buttons[selectedId]);
            buttons.Remove(selectedId);
            ManagerForm.OnDeleteForm(selectedId);
            SaveManager.Delete(selectedId);
        }
Пример #4
0
        public static void Delete(int id)
        {
            if (!Directory.Exists(RootPath))
            {
                return;
            }

            string path = Path.Combine(RootPath, $"Postit{id}.json");

            if (!File.Exists(path))
            {
                return;
            }

            File.Delete(path);
            ManagerForm.OnDeleteForm(id);
        }
Пример #5
0
        public PostItForm(int id, string rtf, bool select, Point?location, Size?size)
        {
            InitializeComponent();
            //Window style
            FormBorderStyle = FormBorderStyle.None;
            DoubleBuffered  = true;
            SetStyle(ControlStyles.FixedWidth, true);
            TextBox.AcceptsTab = true;
            TextBox.DetectUrls = true;
            TextBox.ScrollBars = RichTextBoxScrollBars.Vertical;
            if (select)
            {
                TextBox.Select();
            }

            Activate();

            Context = SynchronizationContext.Current;

            //Callbacks
            ExitButton.Click       += (x, y) => Exit();
            NewWindowButton.Click  += (x, y) => ManagerForm.NewWindow();
            SaveWindowButton.Click += (x, y) => SavesForm.OpenSavesForm();
            Move            += (x, y) => Save();
            SizeChanged     += (x, y) => Save();
            TextBox.KeyDown += TextBoxKeyDown;
            //Save data
            Id                   = id;
            TextBox.Rtf          = rtf;
            TextBox.TextChanged += TextUpdated;
            if (location != null)
            {
                StartPosition = FormStartPosition.Manual;
                Location      = location.Value;
            }
            if (size != null)
            {
                Size = size.Value;
            }
            ManagerForm.AddContextForm(Context, this);
        }