Exemplo n.º 1
0
        public ManagerForm()
        {
            instance = this;
            InitializeComponent();
            FormBorderStyle = FormBorderStyle.None;
            ShowInTaskbar   = true;

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

            if (postits == null)
            {
                NewWindow();
                return;
            }

            IdCounter = postits.Count;
            bool select = true;

            foreach (SaveManager.SaveData save in postits)
            {
                if (!save.Open)
                {
                    continue;
                }
                NewWindow(save.Id, save.RichText, select, new Point(save.X, save.Y), new Size(save.Width, save.Height));
                select = false;
            }
            if (select)
            {
                SavesForm.OpenSavesForm();
            }

            contextInstance = SynchronizationContext.Current;
            FormClosed     += (x, y) => PostToForms(form => form.Close());
        }
Exemplo n.º 2
0
        public SavesForm()
        {
            if (Instance == null)
            {
                Instance = this;
            }
            else
            {
                throw new Exception("Only one instance allowed");
            }

            InitializeComponent();
        }
Exemplo n.º 3
0
        private void SavesForm_Load(object sender, EventArgs e)
        {
            OpenButton.Click   += (x, y) => OpenForm();
            DeleteButton.Click += (x, y) => DeleteForm();
            FormClosed         += (x, y) => Instance = null;

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

            foreach (SaveManager.SaveData save in postits)
            {
                Button button = new Button();
                buttons.Add(save.Id, button);
                button.Text   = save.Id.ToString();
                button.Click += (x, y) => selectedId = save.Id;
                flowLayoutPanel1.Controls.Add(button);
            }
        }
Exemplo n.º 4
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);
        }