Example #1
0
        private bool SetResearchParameterValues(ResearchParameter rp, UIElement uIValue, ref Type paramType)
        {
            ResearchParameterInfo[] info = (ResearchParameterInfo[])rp.GetType().GetField(rp.ToString()).GetCustomAttributes(typeof(ResearchParameterInfo), false);
            paramType = info[0].Type;
            string paramName = rp.ToString();
            object value;

            if (paramType == typeof(Boolean))
            {
                value = (bool)((CheckBox)uIValue).IsChecked ? true : false;
            }
            else
            {
                String paramValue = ((TextBox)uIValue).Text;
                value = Convert.ChangeType(paramValue, paramType, CultureInfo.InvariantCulture);
            }
            // TODO validate
            if (paramType == typeof(double) && !((double)value >= 0 && (double)value <= 1))
            {
                MessageBox.Show(paramName + " parameter value must be rational number between 0 and 1.", "Error");
                return(false);
            }
            LabSessionManager.SetResearchParameterValue(rp, value);
            return(true);
        }
Example #2
0
        private bool SetAnalyzeOptionsValues()
        {
            AnalyzeOption opts = AnalyzeOption.None;
            int           numOfSelectedItems = 0;

            foreach (Control c in AnalyzeOptionsStackPanel.Children)
            {
                Debug.Assert(c is CheckBox);
                CheckBox cc = c as CheckBox;
                // TODO maybe better content and text
                AnalyzeOption current = (AnalyzeOption)Enum.Parse(typeof(AnalyzeOption), cc.Content.ToString());
                if (cc.IsChecked.GetValueOrDefault())
                {
                    opts |= current;
                    numOfSelectedItems++;
                }
            }
            if ((researchType == ResearchType.Activation || researchType == ResearchType.Evolution) &&
                numOfSelectedItems != 1)
            {
                MessageBox.Show("Exactly one item form Analyze Options must be selected.");
                return(false);
            }
            LabSessionManager.SetAnalyzeOptions(opts);
            return(true);
        }
Example #3
0
 public ActivationResearchDraw() : base(ModelType.ER)
 {
     StepCount            = LabSessionManager.GetActivationStepCount();
     activesCount         = new ObservableCollection <KeyValuePair <int, int> >();
     MWindow.XAxisMaximum = StepCount + 1;
     MWindow.YAxisMaximum = LabSessionManager.GetMaximumActiveNodesCount() + 1;
 }
Example #4
0
        private void InitializeParametersGroup()
        {
            ParametersStackPanelName.Children.Clear();
            ParametersStackPanelValue.Children.Clear();
            List <ResearchParameter> researchParameters = LabSessionManager.GetRequiredResearchParameters(researchType);

            foreach (ResearchParameter p in researchParameters)
            {
                TextBlock pName = new TextBlock
                {
                    Text   = p.ToString() + ":",
                    Margin = new Thickness(7),
                    Name   = p.ToString() + "Name"
                };
                ParametersStackPanelName.Children.Add(pName);
                if (GetTypeForResearchParameter(p) == typeof(Boolean))
                {
                    CheckBox pValue = new CheckBox()
                    {
                        Margin      = new Thickness(50, 5, 50, 5),
                        BorderBrush = (SolidColorBrush) new BrushConverter().ConvertFromString("#aaaaaa")
                    };
                    ParametersStackPanelValue.Children.Add(pValue);
                }
                else
                {
                    TextBox pValue = new TextBox
                    {
                        Height = 20,
                        Width  = 100,
                        Margin = new Thickness(5),
                        Name   = p.ToString(),
                        Text   = GetDefaultValueForResearchParameter(p)
                    };
                    ParametersStackPanelValue.Children.Add(pValue);
                }
            }
            List <GenerationParameter> generationParameters = LabSessionManager.GetRequiredGenerationParameters(researchType, GetCurrentModelType());

            foreach (GenerationParameter p in generationParameters)
            {
                TextBlock pName = new TextBlock
                {
                    Text   = p.ToString() + ":",
                    Margin = new Thickness(7),
                    Name   = p.ToString() + "Name"
                };
                ParametersStackPanelName.Children.Add(pName);

                TextBox pValue = new TextBox
                {
                    Height = 20,
                    Width  = 100,
                    Margin = new Thickness(5),
                    Name   = p.ToString(),
                    Text   = GetDefaultValueForGenerationParameter(p)
                };
                ParametersStackPanelValue.Children.Add(pValue);
            }
        }
Example #5
0
 private void InitializeModelTypeCmb()
 {
     ModelTypeComboBox.Items.Clear();
     foreach (ModelType m in LabSessionManager.GetAvailableModelTypes(researchType))
     {
         ModelTypeComboBox.Items.Add(m);
     }
 }
Example #6
0
        public WSDraw(Canvas mainCanvas) : base(mainCanvas)
        {
            StepCount = (int)LabSessionManager.GetGenerationParameterValues()[GenerationParameter.StepCount];
            Edges     = (int)LabSessionManager.GetGenerationParameterValues()[GenerationParameter.Edges];

            //LabSessionManager.Generate((int)this.InitialVertexCount, this.Probability, (int)StepCount, (int)Edges);
            GetNetwork();
        }
Example #7
0
 public EvolutionResearchDraw() : base(ModelType.ER)
 {
     edgesAddedRemoved    = LabSessionManager.GetEvolutionInformation();
     StepCount            = edgesAddedRemoved == null ? 0 : edgesAddedRemoved.Count;
     trianglesCount       = LabSessionManager.GetTrianglesCount();
     MWindow.XAxisMaximum = StepCount + 1;
     MWindow.YAxisMaximum = LabSessionManager.GetMaximumTrianglesCount() + 1;
 }
Example #8
0
        private void ShowCreateResearchDialog(ResearchType researchType)
        {
            CreateResearchWindow createResearchWnd = new CreateResearchWindow(researchType)
            {
                Owner = this
            };

            createResearchWnd.ShowDialog();
            if (!(createResearchWnd.DialogResult.HasValue && createResearchWnd.DialogResult.Value))
            {
                return;
            }

            researchDraw = FactoryReserchDraw.CreateResearchDraw(researchType, LabSessionManager.GetResearchModelType());

            Start.Visibility = Visibility.Visible;
            Start.IsEnabled  = true;
            Save.Visibility  = Visibility.Visible;
            Save.IsEnabled   = true;
            AddResearchToTable();
            FillParametersTable();
            researchDraw.SetStatisticsParameters();
            if (researchType == ResearchType.Basic)
            {
                Initial.Visibility  = Visibility.Visible;
                Initial.IsEnabled   = false;
                Final.Visibility    = Visibility.Visible;
                Final.IsEnabled     = false;
                Next.Visibility     = Visibility.Visible;
                Next.IsEnabled      = false;
                Previous.Visibility = Visibility.Visible;
                Previous.IsEnabled  = false;
                Grid.SetColumn(Save, 5);
            }
            else
            {
                Initial.Visibility  = Visibility.Collapsed;
                Final.Visibility    = Visibility.Collapsed;
                Next.Visibility     = Visibility.Collapsed;
                Previous.Visibility = Visibility.Collapsed;
                ChartData           = null;
                Grid.SetColumn(Save, 1);
            }
            Start.Content = "Start";

            mainCanvas.Children.Clear();

            if (LabSessionManager.GetResearchType() == ResearchType.Basic &&
                (LabSessionManager.GetResearchModelType() == ModelType.RegularHierarchic || LabSessionManager.GetResearchModelType() == ModelType.NonRegularHierarchic))
            {
                Flat.Visibility = System.Windows.Visibility.Visible;
                Flat.IsEnabled  = false;
            }
            else
            {
                Flat.Visibility = System.Windows.Visibility.Hidden;
            }
        }
Example #9
0
        private void DrawAcivationStep()
        {
            BitArray step = LabSessionManager.GetActivationStep(ResearchStepNumber);

            for (int j = 0; j < step.Count; ++j)
            {
                DrawObj.ActivateOrDeactivateVertex(j, step[j]);
            }
        }
Example #10
0
        protected override void GetNetwork()
        {
            for (int i = 0; i <= StepCount; i++)
            {
                edgesBySteps.Add(LabSessionManager.GetStep(i));
            }

            initialNetwork = edgesBySteps[0];
        }
Example #11
0
        public BADraw(Canvas mainCanvas) : base(mainCanvas)
        {
            StepCount             = (int)LabSessionManager.GetGenerationParameterValues()[GenerationParameter.StepCount];
            Edges                 = (int)LabSessionManager.GetGenerationParameterValues()[GenerationParameter.Edges];
            newVertices           = new List <Ellipse>();
            VerticesAddedToCanvas = new List <Ellipse>();
            addedVertexPoints     = new Point[StepCount];

            //LabSessionManager.Generate((int)this.InitialVertexCount, this.Probability, (int)StepCount, (int)Edges);
            GetNetwork();
        }
Example #12
0
        protected override void GetNetwork()
        {
            //edgesBySteps.Add(LabSessionManager.GetStep(StepCount));

            // GetStep(0) - initial network, GetStep(i) - i = 1, ..., StepCount - generation steps
            for (int i = 0; i <= StepCount; ++i)
            {
                edgesBySteps.Add(LabSessionManager.GetStep(i));
            }

            initialNetwork = edgesBySteps[0];
        }
        private void DrawFinal()
        {
            stepNumber = LabSessionManager.GetStepCount() - 1;
            MWindow.mainCanvas.Children.Clear();
            DrawObj.DrawFinal();
            MWindow.TextBoxStepNumber.Text = stepNumber.ToString();

            MWindow.Next.IsEnabled     = false;
            MWindow.Previous.IsEnabled = true;
            MWindow.Initial.IsEnabled  = true;
            MWindow.Final.IsEnabled    = false;
        }
Example #14
0
        protected override void GetNetwork()
        {
            int stepCount = LabSessionManager.GetStepCount();

            try
            {
                for (int i = 0; i < stepCount; ++i)
                {
                    edgesBySteps.Add(LabSessionManager.GetStep(i));
                }
            }
            catch (System.ArgumentOutOfRangeException) { }
        }
Example #15
0
        private void InitializeEditResearchDialog()
        {
            ResearchTypeTextBox.Text = LabSessionManager.GetResearchType().ToString();
            ResearchNameTextBox.Text = LabSessionManager.GetResearchName();
            ModelTypeComboBox.Text   = LabSessionManager.GetResearchModelType().ToString();

            Dictionary <GenerationParameter, object> paramValues = LabSessionManager.GetGenerationParameterValues();
            List <ResearchParameter> param = LabSessionManager.GetRequiredResearchParameters(LabSessionManager.GetResearchType());

            for (int i = 0; i < ParametersStackPanelValue.Children.Count; i++)
            {
                GenerationParameter g;
                Enum.TryParse(((TextBox)ParametersStackPanelValue.Children[i]).Name, out g);
                ((TextBox)(ParametersStackPanelValue.Children[i])).Text = paramValues[g].ToString();
            }
        }
Example #16
0
        private void FillParametersTable()
        {
            ParametersGrid.Items.Clear();

            /*ResearchListView.SelectedIndex = ResearchListView.Items.Add(new ResearchToDrawStruct
             * {
             *  ResearchType = LabSessionManager.GetResearchType().ToString(),
             *  Name = LabSessionManager.GetResearchName(),
             *  Model = LabSessionManager.GetResearchModelType().ToString(),
             *  DrawStatus = LabSessionManager.GetResearchStatus().ToString(),
             * });
             *
             * researchInfoTable.Rows.Add("Research ID", r[0].ToString());
             * researchInfoTable.Rows.Add("Research Name", StatSessionManager.GetResearchName(r[0]));
             * researchInfoTable.Rows.Add("Research Type", StatSessionManager.GetResearchType(r[0]));
             * researchInfoTable.Rows.Add("Model Type", StatSessionManager.GetResearchModelType(r[0]));
             * researchInfoTable.Rows.Add("Realization Count", st.RealizationCountSum);
             * researchInfoTable.Rows.Add("Date", StatSessionManager.GetResearchDate(r[0]));
             * researchInfoTable.Rows.Add("Size", StatSessionManager.GetResearchNetworkSize(r[0]));
             * researchInfoTable.Rows.Add("Edges", st.EdgesCountAvg);*/

            Dictionary <ResearchParameter, object> researchParamValues = LabSessionManager.GetResearchParameterValues();

            foreach (ResearchParameter key in researchParamValues.Keys)
            {
                object value = researchParamValues[key];
                if (value != null)
                {
                    ParametersGrid.Items.Add(new ModelParameterStruct {
                        Name = key.ToString(), Value = value.ToString()
                    });
                }
            }

            Dictionary <GenerationParameter, object> genParamValues = LabSessionManager.GetGenerationParameterValues();

            foreach (GenerationParameter key in genParamValues.Keys)
            {
                object value = genParamValues[key];
                if (value != null)
                {
                    ParametersGrid.Items.Add(new ModelParameterStruct {
                        Name = key.ToString(), Value = value.ToString()
                    });
                }
            }
        }
Example #17
0
        private void InitializeAnalyzeOptionsGroup()
        {
            AnalyzeOptionsStackPanel.Children.Clear();
            AnalyzeOption options = LabSessionManager.GetAvailableAnalyzeOptions(researchType, GetCurrentModelType());

            for (int i = 0; i < Enum.GetNames(typeof(AnalyzeOption)).Length; ++i)
            {
                int k = (int)options & (1 << i);
                if (k != 0)
                {
                    CheckBox option = new CheckBox()
                    {
                        Content = ((AnalyzeOption)k).ToString()
                    };
                    AnalyzeOptionsStackPanel.Children.Add(option);
                }
            }
        }
Example #18
0
        private void AddAnalizeOptionsList()
        {
            if (!LabSessionManager.IsResearchCreated())
            {
                return;
            }
            AnalyzeOptionsMenuItem.Items.Clear();
            AnalyzeOption options = LabSessionManager.GetAvailableAnalyzeOptions(LabSessionManager.GetResearchType(), LabSessionManager.GetResearchModelType());

            for (int i = 0; i < Enum.GetNames(typeof(AnalyzeOption)).Length; ++i)
            {
                int k = (int)options & (1 << i);
                if (k != 0)
                {
                    CheckBox option = new CheckBox()
                    {
                        Content = ((AnalyzeOption)k).ToString()
                    };
                    AnalyzeOptionsMenuItem.Items.Add(option);
                }
            }
        }
Example #19
0
        private void Create_Button_Click(object sender, RoutedEventArgs e)
        {
            if (ResearchNameTextBox.Text == "")
            {
                MessageBox.Show("Research Name should be specified.", "Error");
                ResearchNameTextBox.Focus();
                return;
            }
            else
            {
                LabSessionManager.CreateResearch(researchType);
                SetGeneralValues();
                if (!SetParameterValues() || !SetAnalyzeOptionsValues())
                {
                    return;
                }

                LabSessionManager.StartResearch();

                DialogResult = true;
                Close();
            }
        }
Example #20
0
        private bool SetGenerationParameterValues(GenerationParameter gp, UIElement uIValue, ref Type paramType)
        {
            GenerationParameterInfo[] info = (GenerationParameterInfo[])gp.GetType().GetField(gp.ToString()).GetCustomAttributes(typeof(GenerationParameterInfo), false);
            string paramName = gp.ToString();

            paramType = info[0].Type;
            String paramValue = ((TextBox)uIValue).Text;

            object value = Convert.ChangeType(paramValue, paramType, CultureInfo.InvariantCulture);

            if (gp == GenerationParameter.Probability && !((double)value >= 0 && (double)value <= 1))
            {
                MessageBox.Show(paramName + " parameter value must be rational number between 0 and 1.", "Error");
                return(false);
            }
            if (gp == GenerationParameter.Vertices && (int)value > MAX_VERTEX_COUNT)
            {
                MessageBox.Show("Maximum number of vertices is " + MAX_VERTEX_COUNT);
                return(false);
            }
            LabSessionManager.SetGenerationParameterValue(gp, value);
            return(true);
        }
Example #21
0
 private void UpdateChart()
 {
     activesCount.Add(new KeyValuePair <int, int>(ResearchStepNumber, LabSessionManager.GetActiveNodesCountbyStep(ResearchStepNumber)));
     MWindow.ChartData = activesCount;
 }
Example #22
0
 public NonHierarchicDraw(Canvas mainCanvas) : base(mainCanvas)
 {
     InitialVertexCount = (Int32)LabSessionManager.GetGenerationParameterValues()[GenerationParameter.Vertices];
     Probability        = (double)LabSessionManager.GetGenerationParameterValues()[GenerationParameter.Probability];
     edgesBySteps       = new List <List <EdgesAddedOrRemoved> >();
 }
Example #23
0
 private void SetGeneralValues()
 {
     LabSessionManager.SetResearchName(ResearchNameTextBox.Text);
     LabSessionManager.SetResearchModelType(GetCurrentModelType());
 }
Example #24
0
 public NonRegularBlockHierarchicDraw(Canvas mainCanvas) : base(mainCanvas)
 {
     InitialVertexCount = (Int32)LabSessionManager.GetGenerationParameterValues()[GenerationParameter.Vertices];
 }
 public BasicResearchDraw(ModelType modelType = ModelType.ER) : base(modelType)
 {
     StepCount = LabSessionManager.GetStepCount();
 }