Example #1
0
 public void Show(ObservationCtrl sender, CardChartClass cardChart)
 {
     base.Show();
     _currentObservationCtrl = sender;
     _myChart = cardChart;
     PopulateObservationForm(_currentObservationCtrl);
 }
Example #2
0
        private void MakeNewClearPanelChart()
        {
            //populate panelChart
            panelChart.Controls.Clear();
            int _rows = SharedObjects.NumRows;
            int _cols = SharedObjects.NumCols;

            SharedObjects.MyChart = new CardChartClass(_rows, _cols);
            int _cellWidth  = SharedObjects.CellWidth;
            int _cellHeight = SharedObjects.CellHeight;
            int xcoord      = 0 + _leftOffset + _gridThickness + _cellWidth;
            int ycoord      = 0 + _upperOffset + _gridThickness;

            button1.Location = new Point(0 + _leftOffset + _gridThickness, _upperOffset + _gridThickness);
            button1.Size     = new Size(_cellWidth, _cellHeight);
            for (int row = 0; row < _rows; row++)
            {
                for (int col = 0; col < _cols; col++)
                {
                    ObservationCtrl obsCtrl = new ObservationCtrl(row, col);
                    obsCtrl.Location = new Point(xcoord, ycoord);
                    //obs.Click += observationCtrl_Click;
                    panelChart.Controls.Add(obsCtrl);
                    xcoord += _cellWidth - _gridThickness;
                    if ((col + 1) % 7 == 0)
                    {
                        xcoord += _gridThickness;
                    }
                }
                xcoord  = _leftOffset + _gridThickness + _cellWidth;             //x poczatkowe
                ycoord += _cellHeight;
            }
        }
Example #3
0
        private void observationCtrl_Click(object sender, EventArgs e)
        {
            ObservationForm frm = new ObservationForm();

            _currentObservationCtrl = sender as ObservationCtrl;
            frm.Show(_currentObservationCtrl, SharedObjects.MyChart);
        }
Example #4
0
        private void otworzToolStripMenuItem_Click(object sender, EventArgs e)
        {
            {
                Stream         myStream        = null;
                OpenFileDialog openFileDialog1 = new OpenFileDialog();

                //openFileDialog1.InitialDirectory = "c:\\";
                openFileDialog1.Filter           = "NaproCard files (*.npr)|*.npr";
                openFileDialog1.FilterIndex      = 1;
                openFileDialog1.RestoreDirectory = true;

                if (openFileDialog1.ShowDialog() == DialogResult.OK)
                {
                    try
                    {
                        if ((myStream = openFileDialog1.OpenFile()) != null)
                        {
                            using (StreamReader reader = new StreamReader(myStream, System.Text.Encoding.UTF8))
                            {
                                // Insert code to read the stream here.
                                while (!reader.EndOfStream)
                                {
                                    String json = reader.ReadToEnd();
                                    SharedObjects.MyChart.CleanCard();
                                    SharedObjects.MyChart = new CardChartClass(ChartPanel, NumCols, NumRows, cellWidth, cellHeight);
                                    SharedObjects.MyChart.ChartElementsToExport = JsonConvert.DeserializeObject <List <List <ObservationClass> > >(json);
                                    List <List <ObservationClass> > ImportedObs = new List <List <ObservationClass> >();
                                    ImportedObs = SharedObjects.MyChart.ChartElementsToExport;
                                    foreach (List <ObservationClass> observationClassesList in ImportedObs)
                                    {
                                        int i = ImportedObs.IndexOf(observationClassesList);
                                        foreach (ObservationClass observation in observationClassesList)
                                        {
                                            int             j    = observationClassesList.IndexOf(observation);
                                            ObservationCtrl ctrl =
                                                SharedObjects.MyChart.ChartElements.ElementAt(i).ElementAt(j);
                                            observation.ObservationClassToCtrl(ctrl);
                                        }
                                    }
                                }
                                myStream.Close();
                                _currentSavedPath     = Path.GetDirectoryName(openFileDialog1.FileName);
                                _currentSavedFileName = Path.GetFileNameWithoutExtension(openFileDialog1.FileName);
                                this.Text             = _title + " - " + _currentSavedFileName;
                                //if (_currentSavedFileName != "")
                                //{
                                //    this.Text = _currentSavedFileName + " - " + _title;
                                //}
                            }
                        }
                    }
                    catch (Exception ex)
                    {
                        MessageBox.Show(ex.Message + ex.StackTrace);
                    }
                }
            }
        }
Example #5
0
 public void Show(ObservationCtrl sender, int row, int col)
 {
     _currentObservationRow = row;
     _currentObservationColumn = col;
     _myChart = SharedObjects.MyChart;
     _currentObservationCtrl = sender;
     base.Show();
     PopulateFormFromChart();
 }
Example #6
0
        void PopulateChart()
        {
            ChartElements = new List <List <ObservationCtrl> >();
            //zapelnianie karty
            int xcoord = 0;
            int ycoord = 0;

            ChartSize = new Point();

            for (int i = 0; i < _rows; i++)
            {
                List <ObservationCtrl> observationsList = new List <ObservationCtrl>();
                for (int j = 0; j < _cols; j++)
                {
                    ObservationCtrl obs = new ObservationCtrl();
                    obs.Location    = new Point(xcoord, ycoord);
                    obs.IsNew       = true;
                    obs.MarkerImage = null;
                    obs.MarkerImageDescriptionTag = "";
                    obs.Date      = DateTime.Parse("1753-01-01");
                    obs.Literki   = "";
                    obs.Cyferki   = "";
                    obs.CyferkiCD = "";
                    obs.IleRazy   = "";
                    obs.Uwagi     = new List <string>()
                    {
                        "", "", ""
                    };
                    obs.NoteMarks = new List <string>()
                    {
                        "", "", ""
                    };
                    obs.NotesContent = new List <string>()
                    {
                        "", "", ""
                    };
                    obs.row    = i;
                    obs.col    = j;
                    obs.Click += observationCtrl_Click;
                    //obs.MouseHover += observationCtrl_MouseHover;
                    //obs.MouseLeave += observationCtrl_MouseLeave;
                    observationsList.Add(obs);
                    _chartPanel.Controls.Add(obs);
                    xcoord += _cellWidth - _gridThickness;
                    if ((j + 1) % 7 == 0)
                    {
                        xcoord += _gridThickness;
                    }
                }
                ChartSize.X = xcoord + _gridThickness;
                ChartElements.Add(observationsList);
                xcoord  = 0;
                ycoord += _cellHeight;
            }
            ChartSize.Y = ycoord;
        }
Example #7
0
        private void ObservationCtrl_Click(object sender, EventArgs e)
        {
            ObservationForm frm = new ObservationForm();
            ObservationCtrl oc  = sender as ObservationCtrl;

            if (oc != null)
            {
                frm.Show(oc, _row, _col);
            }
        }
 public void ObservationClassToCtrl(ObservationCtrl obsCtrl)
 {
     obsCtrl.MarkerImageDescriptionTag = MarkerImageDescriptionTag;
     obsCtrl.Date                = Data;
     obsCtrl.Literki             = Literki;
     obsCtrl.Cyferki             = Cyferki;
     obsCtrl.CyferkiCD           = CyferkiCD;
     obsCtrl.IleRazy             = Ilerazy;
     obsCtrl.Uwagi               = Uwagi;
     obsCtrl.NoteMarks           = NoteMarks;
     obsCtrl.NotesContent        = NotesContent;
     obsCtrl.row                 = Row;
     obsCtrl.Location            = LocationPoint;
     obsCtrl.UserPictureFileInfo = this.UserPictureFileInfo;
 }
 public ObservationClass(ObservationCtrl obsCtrl)
 {
     MarkerImageDescriptionTag = obsCtrl.MarkerImageDescriptionTag;
     Data                     = obsCtrl.Date;
     Literki                  = obsCtrl.Literki;
     Cyferki                  = obsCtrl.Cyferki;
     CyferkiCD                = obsCtrl.CyferkiCD;
     Ilerazy                  = obsCtrl.IleRazy;
     Uwagi                    = obsCtrl.Uwagi;
     NoteMarks                = obsCtrl.NoteMarks;
     NotesContent             = obsCtrl.NotesContent;
     Col                      = obsCtrl.col;
     Row                      = obsCtrl.row;
     LocationPoint            = obsCtrl.Location;
     this.UserPictureFileInfo = obsCtrl.UserPictureFileInfo;
 }
Example #10
0
        /// <summary>
        /// ################## Wczytywanie danych podczas otwarcia
        /// </summary>
        #region Wczytywanie danych podczas otwarcia
        void PopulateObservationForm(ObservationCtrl obs)
        {
            //obrazek
            foreach (var VARIABLE in _markerCtrlsListList)
            {
                if (VARIABLE.Tag.ToString() == obs.MarkerImageDescriptionTag)
                {
                    VARIABLE.Checked = true;
                }
            }

            //data
            if (obs.Date == DateTime.Parse("1753 - 01 - 01"))
            {
                if (_currentObservationCtrl.col > 0)//czyli nie jest pierwsza
                {
                    int      r            = _currentObservationCtrl.row;
                    int      c            = _currentObservationCtrl.col;
                    DateTime prevCtrlDate = _myChart.ChartElements.ElementAt(r).ElementAt(c - 1).Date;
                    if (prevCtrlDate != DateTime.Parse("1753 - 01 - 01"))
                    {
                        dateTimePickerDataObserwacji.Value = prevCtrlDate.AddDays(1);
                    }
                }
                else
                {
                    dateTimePickerDataObserwacji.Value = DateTime.Today;
                }
            }
            else
            {
                dateTimePickerDataObserwacji.Value = obs.Date;
            }

            //literki
            foreach (var VARIABLE in groupBoxLiterki.Controls)
            {
                RadioButton rb = VARIABLE as RadioButton;
                if (rb != null)
                {
                    if (rb.Text == obs.Literki)
                    {
                        rb.Checked = true;
                    }
                }
            }

            //cyferki
            foreach (var VARIABLE in groupBoxCyferki.Controls)
            {
                RadioButton rb = VARIABLE as RadioButton;
                if (rb != null)
                {
                    if (rb.Text == obs.Cyferki)
                    {
                        rb.Checked = true;
                    }
                }
            }

            //cyferkiCD
            foreach (var VARIABLE in groupBoxCyferkiCD.Controls)
            {
                RadioButton rb = VARIABLE as RadioButton;
                if (rb != null)
                {
                    if (rb.Text == obs.Cyferki)
                    {
                        rb.Checked = true;
                    }
                }
            }

            //IleRazy
            foreach (var VARIABLE in groupBoxIleRazy.Controls)
            {
                RadioButton rb = VARIABLE as RadioButton;
                if (rb != null)
                {
                    if (rb.Text == obs.IleRazy)
                    {
                        rb.Checked = true;
                    }
                }
            }

            //Uwagi
            foreach (var VARIABLE in _checkboxUwagiList)
            {
                int i = _checkboxUwagiList.IndexOf(VARIABLE);
                if (VARIABLE.Text.Substring(0, 1) == obs.Uwagi.ElementAt(i))
                {
                    VARIABLE.Checked = true;
                }
            }
            //noteMarks and notes
            foreach (var VARIABLE in _textboxNoteMarksList)
            {
                int i = _textboxNoteMarksList.IndexOf(VARIABLE);
                VARIABLE.Text = obs.NoteMarks.ElementAt(i);                           //pierwsze litery
                _richtextNotesList.ElementAt(i).Text = obs.NotesContent.ElementAt(i); //tresc
            }
            //zdjecie
            if (_currentObservationCtrl.UserPictureFileInfo != "")
            {
                if (File.Exists(_currentObservationCtrl.UserPictureFileInfo))
                {
                    pictureBox1UserPicture.Image = Image.FromFile(_currentObservationCtrl.UserPictureFileInfo);
                }
            }
        }
Example #11
0
        private void otworzToolStripMenuItem_Click(object sender, EventArgs e)
        {
            Stream         myStream        = null;
            OpenFileDialog openFileDialog1 = new OpenFileDialog();

            //openFileDialog1.InitialDirectory = "c:\\";
            openFileDialog1.Filter           = "NaproCard files (*.npr)|*.npr";
            openFileDialog1.FilterIndex      = 1;
            openFileDialog1.RestoreDirectory = true;

            if (openFileDialog1.ShowDialog() == DialogResult.OK)
            {
                try
                {
                    if ((myStream = openFileDialog1.OpenFile()) != null)
                    {
                        using (StreamReader reader = new StreamReader(myStream, System.Text.Encoding.UTF8))
                        {
                            // Insert code to read the stream here.
                            while (!reader.EndOfStream)
                            {
                                String json = reader.ReadToEnd();
                                //SharedObjects.MyChart.ClearWholeChart();
                                List <List <ObservationClass> > importedChart = JsonConvert.DeserializeObject <List <List <ObservationClass> > >(json);
                                SharedObjects.NumRows = importedChart.Count;
                                SharedObjects.NumCols = importedChart.ElementAt(0).Count;
                                SharedObjects.MyChart = new CardChartClass(SharedObjects.NumRows, SharedObjects.NumCols);
                                _myChart = SharedObjects.MyChart;
                                _myChart.ChartElements = importedChart;
                            }
                            myStream.Close();

                            //okienko postepu
                            panelChart.Visible = false;
                            FileIOForm  frm         = new FileIOForm();
                            ProgressBar progressBar = frm.Controls.Find("progressBar", false).First() as ProgressBar;
                            Label       messaLabel  = frm.Controls.Find("labelMessage", false).First() as Label;
                            progressBar.Maximum = SharedObjects.NumRows * SharedObjects.NumCols;
                            progressBar.Value   = 0;
                            frm.Show();

                            MakeNewClearPanelChart();
                            foreach (Control ctrl in panelChart.Controls)
                            {
                                ObservationCtrl obsCtrl = ctrl as ObservationCtrl;
                                if (obsCtrl != null)
                                {
                                    ObservationClass cellData = _myChart.ChartElements.ElementAt(obsCtrl.Row).ElementAt(obsCtrl.Col);
                                    obsCtrl.PopulateObservationCtrl(cellData);
                                    progressBar.Value++;
                                }
                            }
                            messaLabel.Text = "Wczytano";
                            frm.Close();
                            panelChart.Visible = true;

                            _currentSavedPath     = Path.GetDirectoryName(openFileDialog1.FileName);
                            _currentSavedFileName = Path.GetFileNameWithoutExtension(openFileDialog1.FileName);
                            this.Text             = _title + " - " + _currentSavedFileName;
                            //if (_currentSavedFileName != "")
                            //{
                            //    this.Text = _currentSavedFileName + " - " + _title;
                            //}
                        }
                    }
                }
                catch (Exception ex)
                {
                    MessageBox.Show(ex.Message + ex.StackTrace);
                }
            }
        }