Beispiel #1
0
 private void Button2_Click(object sender, EventArgs e)// edit click event
 {
     try
     {
         if (title.Text == "" || tags.Text == "")
         {
             throw new emptySlotException("Please fill all the fields");
         }
         else if (oldTitle != title.Text && LogOperations.isThisLogExist(title.Text, activeUser))
         {
             throw new alreadyExistingLog("There is a log with this title please select another one");
         }
         else
         {
             LogOperations.editLogInfo(activeUser, oldTitle, title.Text, tags.Text, basicDatePicker1.getDate());
             MessageBox.Show("Log infos are successfully edited.");
             Close();
         }
     }
     catch (alreadyExistingLog er)
     {
         MessageBox.Show(er.Message);
     }
     catch (emptySlotException er)
     {
         MessageBox.Show(er.Message);
     }
     catch (Exception er)
     {
         MessageBox.Show(er.Message);
     }
 }
Beispiel #2
0
        private void LogText_TextChanged(object sender, EventArgs e)
        {
            int i = LogText.SelectionStart;

            Page[currentPage] = LogText.Text;
            LogText.SelectAll();
            LogText.SelectionFont = new Font(LogText.Font.FontFamily, LogText.Font.Size, LogText.Font.Style);
            LogText.DeselectAll();
            LogText.SelectionStart = i;
            writtenLetters++;
            if (writtenLetters == 25 && autoSave)
            {
                writtenLetters = 0;
                string backcolor = LogText.BackColor.R + "@" + LogText.BackColor.G + "@" + LogText.BackColor.B;
                string forecolor = LogText.ForeColor.R + "@" + LogText.ForeColor.G + "@" + LogText.ForeColor.B;
                int[]  style     = new int[3];
                if (LogText.Font.Bold)
                {
                    style[0] = 1;
                }
                if (LogText.Font.Italic)
                {
                    style[1] = 1;
                }
                if (LogText.Font.Underline)
                {
                    style[2] = 1;
                }
                LogOperations.saveTheLog(parentForm.activeUser, header.Text, Page, backcolor, forecolor, LogText.Font.FontFamily.Name, Convert.ToInt32(LogText.Font.Size), style, alig);
            }
        }
Beispiel #3
0
        public void fillTheLogsByMonth(string month)
        {
            int logStartX = 3;
            int logStartY = 3;

            removePanelControls();
            if (LogOperations.areThereLogsOfThisUser(activeUser))
            {
                Dictionary <string, string> LogInfo = LogOperations.getThisUsersLogsInfo(activeUser);
                DirectoryInfo DirInfo = new DirectoryInfo(Application.StartupPath + @"\Data\Logs");
                FileInfo[]    Files   = DirInfo.GetFiles("*.txt");
                for (int i = 0; i < Files.Length; i++)
                {
                    if (Files[i].Name.Contains(Encryption.MD5encryption(this.activeUser)))
                    {
                        string[]            info  = LogInfo[Files[i].Name.Replace(Encryption.MD5encryption(this.activeUser), "").Replace(".txt", "")].Split('@');
                        string[]            date  = info[2].Split('/');
                        LogOperations.Month value = (LogOperations.Month) int.Parse(date[1]);
                        if (value.ToString() == month)
                        {
                            logStartX += 150;
                            if (logStartX > 900)
                            {
                                logStartX  = logStartX % 900;
                                logStartY += 200;
                            }
                            createLog(logStartX, logStartY, info[0]);
                        }
                    }
                }
            }
            sortText.Text = "Sorted by " + Sort + " : " + month;
        }
Beispiel #4
0
        public NewLogScreen(Form parent, string activeUser, string Title)
        {
            InitializeComponent();
            this.StartPosition = FormStartPosition.CenterScreen;
            this.parent        = parent;
            this.activeUser    = activeUser;
            button2.Click     += Button2_Click;
            button2.Click     -= button2_Click;
            button2.Text       = "Edit";
            Dictionary <string, string> logInfo = LogOperations.getThisUsersLogsInfo(activeUser);
            string info = logInfo[Encryption.MD5encryption(Title)];

            string[] items = info.Split('@');
            string[] date  = items[2].Split('/');
            oldTitle = title.Text = items[0];
            foreach (string s in items[1].Split('*'))
            {
                if (s.Length > 0)
                {
                    tagList.Add(s.Replace("\n", ""));
                }
            }
            fillTags();
            if (DateTime.Today.Day.ToString() != date[0] || DateTime.Today.Month.ToString() != date[1] || DateTime.Today.Year.ToString() != date[2])
            {
                checkBox1.Checked = false;
                foreach (NumericUpDown N in basicDatePicker1.Controls.OfType <NumericUpDown>())
                {
                    if (N.Maximum > 32)
                    {
                        N.Value = int.Parse(date[2]);
                    }
                    else if (N.Maximum > 12)
                    {
                        N.Value = int.Parse(date[0]);
                    }
                    else
                    {
                        N.Value = int.Parse(date[1]);
                    }
                }
            }
        }
Beispiel #5
0
        public void fillTheLogsByName(string name)
        {
            int res       = 0;
            int logStartX = 3;
            int logStartY = 3;

            logPanel.Controls.Clear();
            NewLog newLogControl = new NewLog();

            newLogControl.Width       = 115;
            newLogControl.Height      = 115;
            newLogControl.Location    = new Point(3, 3);
            newLogControl.MouseClick += newLog1_MouseClick;
            logPanel.Controls.Add(newLogControl);
            if (LogOperations.areThereLogsOfThisUser(activeUser))
            {
                Dictionary <string, string> LogInfo = LogOperations.getThisUsersLogsInfo(activeUser);
                DirectoryInfo DirInfo = new DirectoryInfo(Application.StartupPath + @"\Data\Logs");
                FileInfo[]    Files   = DirInfo.GetFiles("*.txt");
                for (int i = 0; i < Files.Length; i++)
                {
                    if (Files[i].Name.Contains(Encryption.MD5encryption(this.activeUser)))
                    {
                        string[] info = LogInfo[Files[i].Name.Replace(Encryption.MD5encryption(this.activeUser), "").Replace(".txt", "")].Split('@');
                        if ((info[0].Contains(name) || info[0] == name) && Logs.ContainsValue(info[0]))
                        {
                            logStartX += 150;
                            if (logStartX > 900)
                            {
                                logStartX  = logStartX % 900;
                                logStartY += 200;
                            }
                            createLog(logStartX, logStartY, info[0]);
                            res++;
                        }
                    }
                }
            }
            sortText.Text = "Sorted by name : " + name;
            result        = res;
        }
Beispiel #6
0
        private void save_Click(object sender, EventArgs e)
        {
            string backcolor = LogText.BackColor.R + "@" + LogText.BackColor.G + "@" + LogText.BackColor.B;
            string forecolor = LogText.ForeColor.R + "@" + LogText.ForeColor.G + "@" + LogText.ForeColor.B;

            int[] style = new int[3];
            if (LogText.Font.Bold)
            {
                style[0] = 1;
            }
            if (LogText.Font.Italic)
            {
                style[1] = 1;
            }
            if (LogText.Font.Underline)
            {
                style[2] = 1;
            }
            LogOperations.saveTheLog(parentForm.activeUser, header.Text, Page, backcolor, forecolor, LogText.Font.FontFamily.Name, Convert.ToInt32(LogText.Font.Size), style, alig);
            MessageBox.Show("Saved");
        }
Beispiel #7
0
 public LogReader(Form parent, string title)
 {
     InitializeComponent();
     this.WindowState   = FormWindowState.Maximized;
     this.StartPosition = FormStartPosition.CenterScreen;
     parentForm         = ((Main)parent);
     parentForm.loseFocus();
     currentPage     = 0;
     header.Text     = title.Replace(Environment.NewLine, "");
     Page            = LogOperations.getLog(parentForm.activeUser, title);
     LogText.TabStop = false;
     if (Page.Count > 0)
     {
         LogText.Text = Page[0];
     }
     else
     {
         Page.Add("");
     }
     label1.Text = Page.Count.ToString();
 }
Beispiel #8
0
        /* Algorithm explanation of fillTheLogsBy.... functions
         *
         * If there is any logs of the current user
         * first takes a dictionary that haves encrypted and decrypted versions of files name
         * after that takes every logs that has been created by any user
         * each log that contains encrypted version of current user name
         * decrypt the text name and reach the log name and its selected criteria
         * after that if logs selecte criteria and users selected criteria matches
         * then that logs getting created by its decrypted names
         */

        //Fill the panel with logs that has selected criteria
        public void fillTheLogsByTag(string tag)
        {
            int logStartX = 3;
            int logStartY = 3;

            removePanelControls();
            if (LogOperations.areThereLogsOfThisUser(activeUser))
            {
                Dictionary <string, string> LogInfo = LogOperations.getThisUsersLogsInfo(activeUser);
                DirectoryInfo DirInfo = new DirectoryInfo(Application.StartupPath + @"\Data\Logs");
                FileInfo[]    Files   = DirInfo.GetFiles("*.txt");
                for (int i = 0; i < Files.Length; i++)
                {
                    if (Files[i].Name.Contains(Encryption.MD5encryption(this.activeUser)))
                    {
                        string[]      info    = LogInfo[Files[i].Name.Replace(Encryption.MD5encryption(this.activeUser), "").Replace(".txt", "")].Split('@');
                        string[]      tags    = info[1].Split('*');
                        List <string> tagList = new List <string>();
                        foreach (string s in tags)
                        {
                            if (s.Length > 0)
                            {
                                tagList.Add(s.Replace("\n", ""));
                            }
                        }
                        if (tagList.Contains(tag))
                        {
                            logStartX += 150;
                            if (logStartX > 900)
                            {
                                logStartX  = logStartX % 900;
                                logStartY += 200;
                            }
                            createLog(logStartX, logStartY, info[0]);
                        }
                    }
                }
            }
            sortText.Text = "Sorted by " + Sort + " : " + tag;
        }
Beispiel #9
0
        //Fill the panel with all logs that user have
        public void fillTheLogs()
        {
            /* If there is any logs of the current user
             * first takes a dictionary that haves encrypted and decrypted versions of files name
             * after that takes every logs that has been created by any user
             * each log that contains encrypted version of current user name
             * decrypt the text name and reach the log name after that logs are created by their names
             */
            int logStartX = 3;
            int logStartY = 3;

            removePanelControls();
            if (LogOperations.areThereLogsOfThisUser(activeUser))
            {
                Dictionary <string, string> LogInfo = LogOperations.getThisUsersLogsInfo(activeUser);
                DirectoryInfo DirInfo = new DirectoryInfo(Application.StartupPath + @"\Data\Logs");
                FileInfo[]    Files   = DirInfo.GetFiles("*.txt");
                string        x       = "";
                for (int i = 0; i < Files.Length; i++)
                {
                    if (Files[i].Name.Contains(Encryption.MD5encryption(this.activeUser)))
                    {
                        x = Files[i].Name;
                        x = x.Replace(".txt", "");
                        x = x.Remove(x.Length - 32, 32);
                        string[] info = LogInfo[x].Split('@');
                        logStartX += 150;
                        if (logStartX > 900)
                        {
                            logStartX  = logStartX % 900;
                            logStartY += 200;
                        }
                        createLog(logStartX, logStartY, info[0]);
                    }
                }
            }
            sortText.Text = "All";
        }
Beispiel #10
0
 private void button2_Click(object sender, EventArgs e)
 {
     try
     {
         if (title.Text == "" || tags.Text == "")
         {
             throw new emptySlotException("Please fill all the fields");
         }
         else if (LogOperations.isThisLogExist(title.Text, activeUser))
         {
             throw new alreadyExistingLog("There is a log with this title please select another one");
         }
         else
         {
             string path = LogOperations.createNewLog(title.Text, activeUser);
             LogOperations.addToBelongingList(activeUser, title.Text, tags.Text, basicDatePicker1.getDate());
             MessageBox.Show("Log successfully created.");
             TextEditor yeni = new TextEditor(parent, title.Text);
             yeni.Show();
             parent.Visible = false;
             Close();
         }
     }
     catch (alreadyExistingLog er)
     {
         MessageBox.Show(er.Message);
     }
     catch (emptySlotException er)
     {
         MessageBox.Show(er.Message);
     }
     catch (Exception er)
     {
         MessageBox.Show(er.Message);
     }
 }
Beispiel #11
0
        public TextEditor(Form parent, string title)
        {
            InitializeComponent();
            this.StartPosition = FormStartPosition.CenterScreen;
            parentForm         = ((Main)parent);
            parentForm.loseFocus();
            currentPage    = 0;
            header.Text    = title.Replace(Environment.NewLine, "");
            labelfont.Text = LogText.Font.FontFamily.Name;
            sizeLabel.Text = LogText.Font.Size.ToString();
            Page           = LogOperations.getLog(parentForm.activeUser, title);
            if (Page.Count > 0)
            {
                LogText.Text = Page[0];
            }
            else
            {
                Page.Add("");
            }
            LogText.SelectAll();
            List <string> style = LogOperations.getPageStyle(parentForm.activeUser, title);

            if (style.Count > 0)
            {
                string[] items;
                items                  = style[0].Split('@');
                LogText.BackColor      = Color.FromArgb(int.Parse(items[0]), int.Parse(items[1]), int.Parse(items[2]));
                items                  = style[1].Split('@');
                LogText.SelectionColor = LogText.ForeColor = Color.FromArgb(int.Parse(items[0]), int.Parse(items[1]), int.Parse(items[2]));
                LogText.SelectionFont  = LogText.Font = new Font(style[2], int.Parse(style[3]));

                labelfont.Text = style[2];
                sizeLabel.Text = style[3];
                if (style[4][0] == '1')
                {
                    Bold.BackColor = selectedColor; LogText.Font = new Font(LogText.Font, LogText.Font.Style ^ FontStyle.Bold);
                }
                if (style[4][1] == '1')
                {
                    Italic.BackColor = selectedColor; LogText.Font = new Font(LogText.Font, LogText.Font.Style ^ FontStyle.Italic);
                }
                if (style[4][2] == '1')
                {
                    underLine.BackColor = selectedColor; LogText.Font = new Font(LogText.Font, LogText.Font.Style ^ FontStyle.Underline);
                }
                alig = int.Parse(style[5]);
                if (alig == 1)
                {
                    alignLeft.BackColor   = selectedColor;
                    alignMiddle.BackColor = alignRight.BackColor = standartColor;
                }
                else if (alig == 2)
                {
                    alignMiddle.BackColor = selectedColor;
                    alignLeft.BackColor   = alignRight.BackColor = standartColor;
                }
                else
                {
                    alignRight.BackColor  = selectedColor;
                    alignMiddle.BackColor = alignMiddle.BackColor = standartColor;
                }
                changeAligment();
                LogText.DeselectAll();
            }
            LogText.SelectionStart = LogText.Text.Length;
            Dictionary <string, string> settings = RegisterLogin.getUserSettings();

            if (settings["AutoSave"] == "0")
            {
                autoSave = false;
            }
            else
            {
                autoSave = true;
            }
        }
Beispiel #12
0
 private void deleteToolStripMenuItem_Click(object sender, EventArgs e)
 {
     LogOperations.deleteLog(activeUser, Logs[(Log)lastRightClicked]);
     sortLogs(Sort);
 }
Beispiel #13
0
        //Sorts by selected criteria and fills the panel
        public void sortLogs(string sort)
        {
            /* after select a sorting criteria
             * first algorithm takes months/tags/years of logs that belongs to current user
             * and creates folders with these months/tags/years
             * and also assign the controls of folders list to global variable sorterlist
             * after that if there is any months/tags/years fills the screen with logs with that month/tag/year
             * if there isn't shows nothing
             */
            List <string> list;

            if (sort == "month")
            {
                Sort       = "month";
                list       = LogOperations.getAllTheMonths(activeUser);
                sorterList = fillTheSorters(list);
                if (list.Count > 0)
                {
                    fillTheLogsByMonth(list[0]);
                }
                else
                {
                    fillTheLogsByMonth("");
                }
            }
            else if (sort == "tag")
            {
                Sort       = "tag";
                list       = LogOperations.getAllTheTags(activeUser);
                sorterList = fillTheSorters(list);
                if (list.Count > 0)
                {
                    fillTheLogsByTag(list[0]);
                }
                else
                {
                    fillTheLogsByTag("");
                }
            }
            else if (sort == "year")
            {
                Sort       = "year";
                list       = LogOperations.getAllTheYears(activeUser);
                sorterList = fillTheSorters(list);
                if (list.Count > 0)
                {
                    fillTheLogsByYear(list[0]);
                }
                else
                {
                    fillTheLogsByYear("");
                }
            }
            else
            {
                Sort = "all";
                leftPanel.Controls.Clear();
                fillTheLogs();
                createFillerText();
            }
        }