Beispiel #1
0
        private void Calculate()
        {
            if (storage != null)
            {
                #region Spines
                foreach (var key in storage.Keys)
                {
                    var spine = storage.GetDescription(key);

                    IDescriptionCalculator <SpineDescription> calc = null;

                    if (storage.direction == 0)
                    {
                        calc = new SpineLib.Geometry.DescriptionCalculators.Spine.LeftSide(spine);
                    }
                    else if (storage.direction == 1)
                    {
                        calc = new SpineLib.Geometry.DescriptionCalculators.Spine.RightSide(spine);
                    }
                    else if (storage.direction == 2)
                    {
                        calc = new SpineLib.Geometry.DescriptionCalculators.Spine.FrontSide(spine);
                    }
                    else if (storage.direction == 3)
                    {
                        calc = new SpineLib.Geometry.DescriptionCalculators.Spine.BackSide(spine);
                    }

                    if (SpinesDataGrid.Columns.Count == 0)
                    {
                        var ks = calc.Keys;
                        SpinesDataGrid.Columns.Add(new DataGridTextColumn()
                        {
                            Header  = "Позвонок",
                            Binding = new Binding("[0]"),
                        });
                        int index = 1;
                        foreach (var key_col in ks)
                        {
                            SpinesDataGrid.Columns.Add(
                                new DataGridTextColumn()
                            {
                                Header  = calc.GetParameterDescription(key_col),
                                Binding = new Binding(string.Format("[{0}]", index++)),
                            });
                        }
                    }

                    List <string> obj = new List <string>();

                    obj.Add(key);
                    var keys = calc.Keys;
                    foreach (var key_col in keys)
                    {
                        var value = calc.GetParameter(key_col);
                        if (calc.IsParameterLinear(key_col))
                        {
                            value /= storage.MarkerLength;
                            value *= storage.MarkerSize;
                        }

                        obj.Add(string.Format("{0:0.000}", value));
                    }

                    SpinesDataGrid.Items.Add(obj);
                }
                #endregion

                #region Interspines
                foreach (var key in storage.Keys)
                {
                    int keyind = SpineConstants.SpineNames.IndexOf(key);
                    if (keyind != SpineConstants.SpineNames.Count - 1)
                    {
                        var next = SpineConstants.SpineNames[(keyind + 1) % SpineConstants.SpineNames.Count];
                        if (storage.Keys.Contains(next))
                        {
                            var inter = new InterspineDescription();
                            inter.UpSpine   = key;
                            inter.DownSpine = next;
                            inter.storage   = storage;

                            IDescriptionCalculator <InterspineDescription> calc = null;

                            if (storage.direction == 0)
                            {
                                calc = new SpineLib.Geometry.DescriptionCalculators.Interspine.LeftSide(inter);
                            }
                            else if (storage.direction == 1)
                            {
                                calc = new SpineLib.Geometry.DescriptionCalculators.Interspine.RightSide(inter);
                            }
                            else if (storage.direction == 2)
                            {
                                calc = new SpineLib.Geometry.DescriptionCalculators.Interspine.FrontSide(inter);
                            }
                            else if (storage.direction == 3)
                            {
                                calc = new SpineLib.Geometry.DescriptionCalculators.Interspine.BackSide(inter);
                            }

                            if (InterspineDataGrid.Columns.Count == 0)
                            {
                                var ks = calc.Keys;
                                InterspineDataGrid.Columns.Add(new DataGridTextColumn()
                                {
                                    Header  = "Диск",
                                    Binding = new Binding("[0]"),
                                });
                                int index = 1;
                                foreach (var key_col in ks)
                                {
                                    InterspineDataGrid.Columns.Add(
                                        new DataGridTextColumn()
                                    {
                                        Header  = calc.GetParameterDescription(key_col),
                                        Binding = new Binding(string.Format("[{0}]", index++)),
                                    });
                                }
                            }

                            List <string> obj = new List <string>();

                            obj.Add(key + "-" + next);
                            var keys = calc.Keys;
                            foreach (var key_col in keys)
                            {
                                var value = calc.GetParameter(key_col);
                                if (calc.IsParameterLinear(key_col))
                                {
                                    value /= storage.MarkerLength;
                                    value *= storage.MarkerSize;
                                }

                                obj.Add(string.Format("{0:0.000}", value));
                            }

                            InterspineDataGrid.Items.Add(obj);
                        }
                    }
                }
                #endregion

                #region Processes
                foreach (var sp_key in storage.SpinousProcessKeys)
                {
                    IDescriptionCalculator <SpinousProcessDescription> calc = null;

                    var inter = storage.GetSpinousProcessDescription(sp_key);

                    if (storage.direction == 0)
                    {
                        calc = new SpineLib.Geometry.DescriptionCalculators.SpinousProcess.LeftSide(inter);
                    }
                    else if (storage.direction == 1)
                    {
                        calc = new SpineLib.Geometry.DescriptionCalculators.SpinousProcess.RightSide(inter);
                    }

                    if (ProcessDataGrid.Columns.Count == 0)
                    {
                        var ks = calc.Keys;
                        ProcessDataGrid.Columns.Add(new DataGridTextColumn()
                        {
                            Header  = "Участок",
                            Binding = new Binding("[0]"),
                        });
                        int index = 1;
                        foreach (var key_col in ks)
                        {
                            ProcessDataGrid.Columns.Add(
                                new DataGridTextColumn()
                            {
                                Header  = calc.GetParameterDescription(key_col),
                                Binding = new Binding(string.Format("[{0}]", index++)),
                            });
                        }
                    }

                    List <string> obj = new List <string>();

                    obj.Add(sp_key);
                    var keys = calc.Keys;
                    foreach (var key_col in keys)
                    {
                        var value = calc.GetParameter(key_col);
                        if (calc.IsParameterLinear(key_col))
                        {
                            value /= storage.MarkerLength;
                            value *= storage.MarkerSize;
                        }

                        obj.Add(string.Format("{0:0.000}", value));
                    }

                    ProcessDataGrid.Items.Add(obj);
                }
                #endregion
            }
        }
Beispiel #2
0
        private void Calculate()
        {
            if (storage_lay != null && storage_stay != null)
            {
                #region Spines
                foreach (var key in storage_lay.Keys)
                {
                    if (storage_stay.ContainDescription(key))
                    {
                        var spine_first  = storage_lay.GetDescription(key);
                        var spine_second = storage_stay.GetDescription(key);

                        IDescriptionCalculator <SpineDescription> calc_first  = null;
                        IDescriptionCalculator <SpineDescription> calc_second = null;

                        if (storage_lay.direction == 0)
                        {
                            calc_first = new SpineLib.Geometry.DescriptionCalculators.Spine.LeftSide(spine_first);
                        }
                        else if (storage_lay.direction == 1)
                        {
                            calc_first = new SpineLib.Geometry.DescriptionCalculators.Spine.RightSide(spine_first);
                        }
                        else if (storage_lay.direction == 2)
                        {
                            calc_first = new SpineLib.Geometry.DescriptionCalculators.Spine.FrontSide(spine_first);
                        }
                        else if (storage_lay.direction == 3)
                        {
                            calc_first = new SpineLib.Geometry.DescriptionCalculators.Spine.BackSide(spine_first);
                        }

                        if (storage_stay.direction == 0)
                        {
                            calc_second = new SpineLib.Geometry.DescriptionCalculators.Spine.LeftSide(spine_second);
                        }
                        else if (storage_stay.direction == 1)
                        {
                            calc_second = new SpineLib.Geometry.DescriptionCalculators.Spine.RightSide(spine_second);
                        }
                        else if (storage_stay.direction == 2)
                        {
                            calc_second = new SpineLib.Geometry.DescriptionCalculators.Spine.FrontSide(spine_second);
                        }
                        else if (storage_stay.direction == 3)
                        {
                            calc_second = new SpineLib.Geometry.DescriptionCalculators.Spine.BackSide(spine_second);
                        }

                        if (SpinesDataGrid.Columns.Count == 0)
                        {
                            SpinesDataGrid.Columns.Add(new DataGridTextColumn()
                            {
                                Header  = "Название",
                                Binding = new Binding("[0]"),
                            });

                            SpinesDataGrid.Columns.Add(new DataGridTextColumn()
                            {
                                Header  = "Лежа",
                                Binding = new Binding("[1]"),
                            });

                            SpinesDataGrid.Columns.Add(new DataGridTextColumn()
                            {
                                Header  = "Стоя",
                                Binding = new Binding("[2]"),
                            });

                            SpinesDataGrid.Columns.Add(new DataGridTextColumn()
                            {
                                Header  = "Сравнение",
                                Binding = new Binding("[3]"),
                            });
                        }

                        var ks = calc_first.Keys;


                        List <string> obj = new List <string>();
                        obj.Add("");
                        obj.Add(key);
                        obj.Add(key);
                        obj.Add("");

                        SpinesDataGrid.Items.Add(obj);

                        foreach (var key_col in ks)
                        {
                            obj = new List <string>();
                            var desc      = calc_first.GetParameterDescription(key_col);
                            var var_first = calc_first.GetParameter(key_col);
                            if (calc_first.IsParameterLinear(key_col))
                            {
                                var_first /= storage_lay.MarkerLength;
                                var_first *= storage_lay.MarkerSize;
                            }
                            var var_second = calc_second.GetParameter(key_col);
                            if (calc_second.IsParameterLinear(key_col))
                            {
                                var_second /= storage_stay.MarkerLength;
                                var_second *= storage_stay.MarkerSize;
                            }
                            obj.Add(desc);
                            obj.Add(string.Format("{0:0.000}", var_first));
                            obj.Add(string.Format("{0:0.000}", var_second));

                            if (calc_first.IsParameterLinear(key_col) && calc_second.IsParameterLinear(key_col))
                            {
                                var diff = Math.Abs((var_first - var_second) / var_first) * 100;

                                if (var_first < var_second)
                                {
                                    obj.Add(string.Format("Увеличение на {0} %", string.Format("{0:0.000}", diff)));
                                }
                                else
                                {
                                    obj.Add(string.Format("Уменьшение на {0} %", string.Format("{0:0.000}", diff)));
                                }
                            }
                            else
                            {
                                if (var_first < var_second)
                                {
                                    obj.Add(string.Format("Увеличение на {0}", string.Format("{0:0.000}", var_second - var_first)));
                                }
                                else
                                {
                                    obj.Add(string.Format("Уменьшение на {0}", string.Format("{0:0.000}", var_first - var_second)));
                                }
                            }

                            SpinesDataGrid.Items.Add(obj);
                        }
                    }
                }
                #endregion

                #region Interspines
                foreach (var key in storage_lay.Keys)
                {
                    InterspineDescription inter_first  = null;
                    InterspineDescription inter_second = null;

                    int keyind = SpineConstants.SpineNames.IndexOf(key);
                    if (keyind != SpineConstants.SpineNames.Count - 1)
                    {
                        var next = SpineConstants.SpineNames[(keyind + 1) % SpineConstants.SpineNames.Count];
                        if (storage_lay.Keys.Contains(next))
                        {
                            inter_first           = new InterspineDescription();
                            inter_first.UpSpine   = key;
                            inter_first.DownSpine = next;
                            inter_first.storage   = storage_lay;


                            if (storage_stay.Keys.Contains(next) && storage_stay.Keys.Contains(key))
                            {
                                inter_second           = new InterspineDescription();
                                inter_second.UpSpine   = key;
                                inter_second.DownSpine = next;
                                inter_second.storage   = storage_stay;

                                IDescriptionCalculator <InterspineDescription> calc_first_  = null;
                                IDescriptionCalculator <InterspineDescription> calc_second_ = null;

                                if (storage_lay.direction == 0)
                                {
                                    calc_first_ = new SpineLib.Geometry.DescriptionCalculators.Interspine.LeftSide(inter_first);
                                }
                                else if (storage_lay.direction == 1)
                                {
                                    calc_first_ = new SpineLib.Geometry.DescriptionCalculators.Interspine.RightSide(inter_first);
                                }
                                else if (storage_lay.direction == 2)
                                {
                                    calc_first_ = new SpineLib.Geometry.DescriptionCalculators.Interspine.FrontSide(inter_first);
                                }
                                else if (storage_lay.direction == 3)
                                {
                                    calc_first_ = new SpineLib.Geometry.DescriptionCalculators.Interspine.BackSide(inter_first);
                                }

                                if (storage_stay.direction == 0)
                                {
                                    calc_second_ = new SpineLib.Geometry.DescriptionCalculators.Interspine.LeftSide(inter_second);
                                }
                                else if (storage_stay.direction == 1)
                                {
                                    calc_second_ = new SpineLib.Geometry.DescriptionCalculators.Interspine.RightSide(inter_second);
                                }
                                else if (storage_stay.direction == 2)
                                {
                                    calc_second_ = new SpineLib.Geometry.DescriptionCalculators.Interspine.FrontSide(inter_second);
                                }
                                else if (storage_stay.direction == 3)
                                {
                                    calc_second_ = new SpineLib.Geometry.DescriptionCalculators.Interspine.BackSide(inter_second);
                                }

                                if (InterspineDataGrid.Columns.Count == 0)
                                {
                                    InterspineDataGrid.Columns.Add(new DataGridTextColumn()
                                    {
                                        Header  = "Название",
                                        Binding = new Binding("[0]"),
                                    });

                                    InterspineDataGrid.Columns.Add(new DataGridTextColumn()
                                    {
                                        Header  = "Лежа",
                                        Binding = new Binding("[1]"),
                                    });

                                    InterspineDataGrid.Columns.Add(new DataGridTextColumn()
                                    {
                                        Header  = "Стоя",
                                        Binding = new Binding("[2]"),
                                    });

                                    InterspineDataGrid.Columns.Add(new DataGridTextColumn()
                                    {
                                        Header  = "Сравнение",
                                        Binding = new Binding("[3]"),
                                    });
                                }

                                var ks = calc_first_.Keys;


                                List <string> obj = new List <string>();
                                obj.Add("");
                                obj.Add(SpineConstants.InterSpineNames[keyind]);
                                obj.Add(SpineConstants.InterSpineNames[keyind]);
                                obj.Add("");

                                InterspineDataGrid.Items.Add(obj);

                                foreach (var key_col in ks)
                                {
                                    obj = new List <string>();
                                    var desc      = calc_first_.GetParameterDescription(key_col);
                                    var var_first = calc_first_.GetParameter(key_col);
                                    if (calc_first_.IsParameterLinear(key_col))
                                    {
                                        var_first /= storage_lay.MarkerLength;
                                        var_first *= storage_lay.MarkerSize;
                                    }
                                    var var_second = calc_second_.GetParameter(key_col);
                                    if (calc_second_.IsParameterLinear(key_col))
                                    {
                                        var_second /= storage_stay.MarkerLength;
                                        var_second *= storage_stay.MarkerSize;
                                    }

                                    obj.Add(desc);
                                    obj.Add(string.Format("{0:0.000}", var_first));
                                    obj.Add(string.Format("{0:0.000}", var_second));

                                    if (calc_first_.IsParameterLinear(key_col) && calc_second_.IsParameterLinear(key_col))
                                    {
                                        var diff = Math.Abs((var_first - var_second) / var_first) * 100;

                                        if (var_first < var_second)
                                        {
                                            obj.Add(string.Format("Увеличение на {0} %", string.Format("{0:0.000}", diff)));
                                        }
                                        else
                                        {
                                            obj.Add(string.Format("Уменьшение на {0} %", string.Format("{0:0.000}", diff)));
                                        }
                                    }
                                    else
                                    {
                                        if (var_first < var_second)
                                        {
                                            obj.Add(string.Format("Увеличение на {0}", string.Format("{0:0.000}", var_second - var_first)));
                                        }
                                        else
                                        {
                                            obj.Add(string.Format("Уменьшение на {0}", string.Format("{0:0.000}", var_first - var_second)));
                                        }
                                    }

                                    InterspineDataGrid.Items.Add(obj);
                                }
                            }
                        }
                    }
                }
            }
            #endregion

            #region Processes
            foreach (var sp_key in storage_lay.SpinousProcessKeys)
            {
                if (storage_stay.ContainSpinousProcessDescription(sp_key))
                {
                    IDescriptionCalculator <SpinousProcessDescription> calc_first__  = null;
                    IDescriptionCalculator <SpinousProcessDescription> calc_second__ = null;

                    var desc_first  = storage_lay.GetSpinousProcessDescription(sp_key);
                    var desc_second = storage_stay.GetSpinousProcessDescription(sp_key);

                    if (storage_lay.direction == 0)
                    {
                        calc_first__ = new SpineLib.Geometry.DescriptionCalculators.SpinousProcess.LeftSide(desc_first);
                    }
                    else if (storage_lay.direction == 1)
                    {
                        calc_first__ = new SpineLib.Geometry.DescriptionCalculators.SpinousProcess.RightSide(desc_first);
                    }

                    if (storage_stay.direction == 0)
                    {
                        calc_second__ = new SpineLib.Geometry.DescriptionCalculators.SpinousProcess.LeftSide(desc_second);
                    }
                    else if (storage_stay.direction == 1)
                    {
                        calc_second__ = new SpineLib.Geometry.DescriptionCalculators.SpinousProcess.RightSide(desc_second);
                    }


                    if (ProcessDataGrid.Columns.Count == 0)
                    {
                        ProcessDataGrid.Columns.Add(new DataGridTextColumn()
                        {
                            Header  = "Название",
                            Binding = new Binding("[0]"),
                        });

                        ProcessDataGrid.Columns.Add(new DataGridTextColumn()
                        {
                            Header  = "Лежа",
                            Binding = new Binding("[1]"),
                        });

                        ProcessDataGrid.Columns.Add(new DataGridTextColumn()
                        {
                            Header  = "Стоя",
                            Binding = new Binding("[2]"),
                        });

                        ProcessDataGrid.Columns.Add(new DataGridTextColumn()
                        {
                            Header  = "Сравнение",
                            Binding = new Binding("[3]"),
                        });
                    }

                    var ks = calc_first__.Keys;


                    List <string> obj = new List <string>();
                    obj.Add("");
                    obj.Add(sp_key);
                    obj.Add(sp_key);
                    obj.Add("");

                    ProcessDataGrid.Items.Add(obj);

                    foreach (var key_col in ks)
                    {
                        obj = new List <string>();
                        var desc      = calc_first__.GetParameterDescription(key_col);
                        var var_first = calc_first__.GetParameter(key_col);
                        if (calc_first__.IsParameterLinear(key_col))
                        {
                            var_first /= storage_lay.MarkerLength;
                            var_first *= storage_lay.MarkerSize;
                        }
                        var var_second = calc_second__.GetParameter(key_col);
                        if (calc_second__.IsParameterLinear(key_col))
                        {
                            var_second /= storage_stay.MarkerLength;
                            var_second *= storage_stay.MarkerSize;
                        }

                        obj.Add(desc);
                        obj.Add(string.Format("{0:0.000}", var_first));
                        obj.Add(string.Format("{0:0.000}", var_second));

                        if (calc_first__.IsParameterLinear(key_col) && calc_second__.IsParameterLinear(key_col))
                        {
                            var diff = Math.Abs((var_first - var_second) / var_first) * 100;

                            if (var_first < var_second)
                            {
                                obj.Add(string.Format("Увеличение на {0} %", string.Format("{0:0.000}", diff)));
                            }
                            else
                            {
                                obj.Add(string.Format("Уменьшение на {0} %", string.Format("{0:0.000}", diff)));
                            }
                        }
                        else
                        {
                            if (var_first < var_second)
                            {
                                obj.Add(string.Format("Увеличение на {0}", string.Format("{0:0.000}", var_second - var_first)));
                            }
                            else
                            {
                                obj.Add(string.Format("Уменьшение на {0}", string.Format("{0:0.000}", var_first - var_second)));
                            }
                        }

                        ProcessDataGrid.Items.Add(obj);
                    }
                }
            }
            #endregion
        }