Example #1
0
                protected override ILuaMultiValue InvokeInternal(ILuaMultiValue args)
                {
                    string str = Path.GetTempFileName();
                    Stream s   = File.Open(str, FileMode.OpenOrCreate, FileAccess.ReadWrite);

                    Remove.Add(s);
                    return(Environment.Runtime.CreateMultiValue(_CreateFile(s, Environment)));
                }
Example #2
0
            void EnumerateRemovals(string f, IEnumerable <FileObjectMapping> mappings)
            {
                var o = mappings.FirstOrDefault(x => x.FilePath.Equals(f));

                if (o == null)
                {
                    Remove.Add(f);
                }
            }
Example #3
0
        /// <summary>
        /// Set buttons for events
        /// </summary>
        /// <param name="EventsList"></param>
        private void setEventsButtons(List <Event> EventsList)
        {
            if (EventsList == null)
            {
                return;
            }
            // now for each event we need to set btn location, size and etc
            // first add all active Events
            foreach (Event ev in EventsList)
            {
                // calc column
                int evCol = ev.Day;
                // calc starting row
                int evStartRow = ev.StartTime - Globals.StartHour;
                // calc end row
                int evEndRow = ev.EndTime - Globals.StartHour;
                // now get rectangel  representring btn X and Y starting pos
                Rectangle rec = this.schdeulerWeeklyGrid.GetCellDisplayRectangle(evCol, evStartRow, true);
                // calc btn range
                rec.Height *= evEndRow - evStartRow;
                /**/

                // applay padding (we like bea-utiful GUI
                rec.X      += _padding;
                rec.Y      += _padding;
                rec.Width  -= 2 * _padding;
                rec.Height -= 2 * _padding;

                // create btn
                ev.btn                  = new EventButton(ev);
                ev.btn.Name             = "ev_" + ev.ID + "_" + ev.ParentCourse.Name + "_" + ev.EventType;
                ev.btn.TabIndex         = ev.ID;
                ev.btn.Text             = ev.btn_txt();
                ev.btn.TextAlign        = System.Drawing.ContentAlignment.MiddleCenter;
                ev.btn.TileTextFontSize = MetroFramework.MetroTileTextSize.Tall;
                // set location
                ev.btn.Location = new System.Drawing.Point(rec.X, rec.Y);
                // set size
                ev.btn.Size = rec.Size;
                // bind to a click INTERNAT funtion
                ev.btn.Click += Event_click;
                // def btn is hidden
                ev.btn.Hide();
            }
        }

        /// <summary>
        /// Event clicked handling
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void Event_click(object sender, EventArgs e)
        {
            Form form = new StaffInfoView((sender as EventButton).PraentEvent);

            form.Show();
        }

        /// <summary>
        /// Show Student own contrains
        /// public for testing
        /// </summary>
        public void showConstraints()
        {
            if (currentStudent.Constraints != null)
            {
                string[] constraints = currentStudent.Constraints.Split(';');
                foreach (string constrain in constraints)
                {
                    if (constrain == "")
                    {
                        continue;
                    }
                    MatchCollection match = Regex.Matches(constrain, @"[0-9]+");
                    int             col   = int.Parse(match[0].ToString());
                    int             row   = int.Parse(match[1].ToString());
                    Rectangle       rec   = new Rectangle();
                    MetroTile       c     = new MetroTile();
                    c.Name = "const_" + col + "_" + row;
                    // if in test mode, this can not be tested.
                    // assume success on location of the controler
                    try
                    {
                        rec        = this.schdeulerWeeklyGrid.GetCellDisplayRectangle(col, row, true);
                        c.Location = rec.Location;
                    }
                    catch
                    {
                        // in test, it's enought to test existnce
                        c.Location = new Point(0, 0);
                    }

                    c.Size    = rec.Size;
                    c.Enabled = false;
                    c.Style   = MetroFramework.MetroColorStyle.Orange;

                    this.warpper.Controls.Add(c);
                    c.BringToFront();
                    c.Show();
                }
            }
        }

        /// <summary>
        /// On Active course click
        /// Delete the course
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void active_courses_list_SelectedIndexChanged(object sender, EventArgs e)
        {
            // grab selected
            Course         ToRemove       = (Course)this.active_courses_list.SelectedItem;
            List <Control> EventsToRemove = new List <Control>();

            // If null selected, do nothign
            if (ToRemove == null)
            {
                return;
            }

            // Configure the message box to be displayed
            string messageBoxText = "Do you want to remove the course from the list?";
            string caption        = "Confirme course removal";

            // show yes no q
            if (MessageBox.Show(messageBoxText, caption, MessageBoxButtons.YesNo) == System.Windows.Forms.DialogResult.Yes)
            {
                // remove the course from active list
                // need to remove, but only to re-add back
                if (ToRemove.Must)
                {
                    this.must_do_courses_list.Items.Add(ToRemove);
                }
                else
                {
                    this.can_do_courses_list.Items.Add(ToRemove);
                }
                // find all btns on grid
                foreach (Control ctrl in this.warpper.Controls)
                {
                    if (ctrl.GetType().Name != "EventButton")
                    {
                        continue;
                    }
                    // if thats THE course btn
                    if ((ctrl as EventButton).Name.Contains(ToRemove.Name))
                    {
                        // remove the btn
                        EventsToRemove.Add(ctrl);
                        currentStudent.ActiveEventsList.Remove((ctrl as EventButton).PraentEvent);
                    }
                }


                // Remove as last step, cuz it's envoks selectedIndex change with null
                // we do not want to intturopt the original invokation
                this.active_courses_list.Items.Remove(ToRemove);

                foreach (Control ctrl in EventsToRemove)
                {
                    this.warpper.Controls.Remove(ctrl);
                }
                EnableSaveBtn();
            }
        }

        /// <summary>
        /// When user clicks must do course box
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void must_do_courses_list_Click(object sender, EventArgs e)
        {
            // first, clear the grid
            ClearGrid();
            // second, clear events selection boxs
            ClearEventsSelection();
            // deselect can do box
            this.can_do_courses_list.ClearSelected();
            // grab selected
            Course CourseToShow = (Course)this.must_do_courses_list.SelectedItem;

            // nothing selected?
            if (CourseToShow == null)
            {
                DisableSaveBtn();
                return;
            }
            // fill da boxs!
            FillEventsBox(CourseToShow);

            // update savebtn status
            SaveBtnCallBack(CourseToShow);
        }

        /// <summary>
        /// When user clicks Can do course box
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void can_do_courses_list_Click(object sender, EventArgs e)
        {
            // first, clear the grid
            ClearGrid();
            // second, clear events selection boxs
            ClearEventsSelection();
            // deselect can do box
            this.must_do_courses_list.ClearSelected();
            // grab selected
            Course CourseToShow = (Course)this.can_do_courses_list.SelectedItem;

            // nothing selected?
            if (CourseToShow == null)
            {
                DisableSaveBtn();
                return;
            }
            // fill da boxs!
            FillEventsBox(CourseToShow);
            // update savebtn status
            SaveBtnCallBack(CourseToShow);
        }

        /// <summary>
        /// Fill each Combo Box with the right events
        /// </summary>
        /// <param name="selectedCourse"></param>
        private void FillEventsBox(Course selectedCourse)
        {
            // for lectures
            foreach (Event ev in selectedCourse.LectEventsList)
            {
                // if event is not full (Max cap reached)
                if (!ev.Full)
                {
                    this.lectures_list.Items.Add(ev);
                }
            }
            // for practices
            foreach (Event ev in selectedCourse.PractEventsList)
            {
                if (!ev.Full)
                {
                    this.practice_list.Items.Add(ev);
                }
            }
            // for labs
            foreach (Event ev in selectedCourse.LabsEventsList)
            {
                if (!ev.Full)
                {
                    this.labs_list.Items.Add(ev);
                }
            }
        }

        /// <summary>
        /// remove all courses events from combox boxs
        /// </summary>
        private void ClearEventsSelection()
        {
            this.labs_list.Items.Clear();
            this.lectures_list.Items.Clear();
            this.practice_list.Items.Clear();
        }

        /// <summary>
        /// clear all NON active event on the grid
        /// </summary>
        private void ClearGrid()
        {
            List <Control> Remove = new List <Control>();

            /** clear grid every change in selection */
            foreach (Control btn in this.warpper.Controls)
            {
                // it's an event btn and it's NOT in active list?
                if (btn.Name.Contains("ev_") && currentStudent.ActiveEventsList.Find(ev => ev.btn == btn) == null)
                {
                    Remove.Add(btn);
                }
            }

            foreach (Control ctrl in Remove)
            {
                this.warpper.Controls.Remove(ctrl);
            }
        }