Пример #1
0
 public DialogResult ShowDialog(Solver solver)
 {
     Solver_ = solver;
     if (!Solver_.Timetable.RecomputeSolutions)
         return DialogResult.OK;
     base.ShowDialog();
     return (Result_ == SolverResult.Complete ? DialogResult.OK : DialogResult.Cancel);
 }
Пример #2
0
        public Solver(Timetable timetable, Solver other)
        {
            Timetable_ = timetable;

            this.Comparer_ = other.Comparer_.Clone();
            this.Filters_ = new List<Solver.Filter>(other.Filters_);

            this.Solutions_ = new List<Solution>(Solutions_);
            this.MaxResults_ = other.MaxResults_;

            // other variables are initiated during solving
        }
Пример #3
0
        public Solver.Filter ShowDialog(Solver.Filter filter)
        {
            if (filter == null)
            {
                Filter_ = null;
                Text = "Add Filter";
                btnRevert.Enabled = false;
            }
            else
            {
                Filter_ = filter.DeepCopy();
                Text = "Edit Filter";
                btnRevert.Enabled = true;
            }

            LoadFromFilter();

            DialogResult result = base.ShowDialog();
            if (result == DialogResult.OK)
                return Filter_;
            return null;
        }
Пример #4
0
        public Solver.Criteria ShowDialog(Solver.Criteria criteria)
        {
            if (criteria == null)
            {
                Criteria_ = null;
                Text = "Add Criteria";
                btnRevert.Enabled = false;
            }
            else
            {
                Criteria_ = criteria.DeepCopy();
                Text = "Edit Criteria";
                btnRevert.Enabled = true;
            }

            LoadFromCriteria();

            DialogResult result = base.ShowDialog();
            if (result == DialogResult.OK)
                return Criteria_;
            return null;
        }
Пример #5
0
        public FormMain()
        {
            Timetable_ = null;
            Solver_ = new Solver(null);

            InitializeComponent();

            DefaultSize_ = Size;

            // do anchoring here to make form design easier
            tableLayoutPanel2.Anchor = AnchorStyles.Left | AnchorStyles.Right | AnchorStyles.Top | AnchorStyles.Bottom;
            timetableControl1.Anchor = AnchorStyles.Left | AnchorStyles.Right | AnchorStyles.Top | AnchorStyles.Bottom;
            tableLayoutPanel1.Anchor = AnchorStyles.Right | AnchorStyles.Top | AnchorStyles.Bottom;
            //tableLayoutPanel1.Anchor = AnchorStyles.Right | AnchorStyles.Top | AnchorStyles.Bottom;

            Export_.Width = 800;
            Export_.Height = 600;
            Export_.ShowAll = false;
            Export_.ShowDays = true;
            Export_.ShowGrayArea = false;
            Export_.ShowLocation = true;
            Export_.ShowText = true;
            Export_.ShowTimes = true;
            Export_.Grayscale = false;

            SaveDialogXML_.AddExtension = true;
            SaveDialogXML_.CheckFileExists = false;
            SaveDialogXML_.OverwritePrompt = true;
            SaveDialogXML_.Title = "Save Timetable";
            SaveDialogXML_.Filter = "XML File (*.xml)|*.xml";

            OpenDialogXML_.Multiselect = false;
            OpenDialogXML_.AddExtension = true;
            OpenDialogXML_.CheckFileExists = true;
            OpenDialogXML_.ShowReadOnly = false;
            OpenDialogXML_.Title = "Load Timetable";
            OpenDialogXML_.Filter = "XML File (*.xml)|*.xml";

            SaveDialogRaster_.AddExtension = true;
            SaveDialogRaster_.CheckFileExists = false;
            SaveDialogRaster_.OverwritePrompt = true;
            SaveDialogRaster_.Title = "Save Image";
            SaveDialogRaster_.Filter = "PNG Image (*.png)|*.png|JPEG Image (*.jpg, *.jpeg)|*.jpg;*.jpeg|GIF Image (*.gif)|*.gif";

            SaveDialogVector_.AddExtension = true;
            SaveDialogVector_.CheckFileExists = false;
            SaveDialogVector_.OverwritePrompt = true;
            SaveDialogVector_.Title = "Save Image";
            SaveDialogVector_.Filter = "Enhanced Metafile (*.emf)|*.emf";

            SaveDialogWallpaper_.AddExtension = true;
            SaveDialogWallpaper_.CheckFileExists = false;
            SaveDialogWallpaper_.OverwritePrompt = true;
            SaveDialogWallpaper_.Title = "Save Image";
            SaveDialogWallpaper_.Filter = "Bitmap Image (*.bmp)|*.bmp";
            SaveDialogWallpaper_.FileName = "wallpaper";

            //pageSetupDialog1.PageSettings = printDocument1.DefaultPageSettings;
            pageSetupDialog.PageSettings.Landscape = true;
            pageSetupDialog.PageSettings.Margins = new Margins(10 * 1000 / 254, 10 * 1000 / 254, 10 * 1000 / 254, 10 * 1000 / 254);

            FitToScreen();

            EnableButtons(false);

            UpdateSettings();
        }
Пример #6
0
        /*public Timetable ShallowCopy()
        {
            Timetable t = new Timetable();
            t.SubjectList.AddRange(this.SubjectList);
            t.TypeList.AddRange(this.TypeList);
            t.StreamList.AddRange(this.StreamList);
            t.ClassList.AddRange(this.ClassList);
        }*/

        // construct a new timetable object with enough information to render a preview
        public Timetable PreviewSolution(Solver.Solution solution)
        {
            Timetable t = new Timetable();
            for (int i = 0; i < StreamList.Count; i++)
            {
                Stream stream = new Stream(StreamList[i]);
                if (solution.Streams.Contains(StreamList[i]))
                    stream.Selected = true;
                t.StreamList.Add(stream);

                stream.Classes.Clear();
                stream.Incompatible.Clear();
                stream.Equivalent.Clear();

                for (int j = 0; j < StreamList[i].Classes.Count; j++)
                {
                    Session session = new Session(StreamList[i].Classes[j]);
                    session.Stream = stream;
                    stream.Classes.Add(session);
                    t.ClassList.Add(session);
                }
            }
            t.UnavailableList = this.UnavailableList;

            return t;
        }
Пример #7
0
 public bool LoadSolution(Solver.Solution solution)
 {
     bool result = true;
     foreach (Stream stream in solution.Streams)
     {
         // attempt to add it, return false if failed
         if (!SelectStream(stream))
             result = false;
     }
     Update();
     return result;
 }
Пример #8
0
 private void LoadLists(Solver solver)
 {
     LoadLists(solver.Comparer.Criteria, solver.Filters);
 }
Пример #9
0
 public DialogResult ShowDialog(Solver solver)
 {
     Solver_ = solver;
     return base.ShowDialog();
 }
Пример #10
0
 private void LoadLists(Solver solver)
 {
     LoadLists(solver.Comparer.Criteria, solver.Filters);
 }
Пример #11
0
 public DialogResult ShowDialog(Solver solver)
 {
     Solver_ = solver;
     return(base.ShowDialog());
 }