Пример #1
0
        private void table_PropertyChanged(object sender, PropertyChangedEventArgs e)
        {
            MValueFunct2DInput table = sender as MValueFunct2DInput;

            if (table == null || e == null)
            {
                return;
            }
            if (!(table.Tag is int))
            {
                return;
            }
            int table_index = (int)table.Tag;

            // debug
            if (table.AxisValues.Xs.Count > 0)
            {
                var debug = table.AxisValues.Xs[0];
            }
            // debug

            if (e.PropertyName == "AxisValues")
            {
                for (int i = 0; i < this.tables.Count; i++)
                {
                    // update all, icluding the sender
                    this.tables[i].ApplyAxisValues(table.AxisValues);
                }
            }
            else if (e.PropertyName == "Bounds")
            {
                this.Bounds = table.Bounds;
            }
        }
Пример #2
0
        private void tabitem_LostFocus(object sender, RoutedEventArgs e)
        {
            TabItem ti = sender as TabItem;

            if (ti == null)
            {
                return;
            }

            TextBox ti_input = ti.Tag as TextBox;

            if (ti_input == null)
            {
                return;
            }

            ti_input.IsEnabled = false;

            // synchronize table axis values in all tabs
            MValueFunct2DInput ti_table = ti.Content as MValueFunct2DInput;

            if (ti_table == null)
            {
                return;
            }
            ti_table.SetAxisValues();
        }
Пример #3
0
        private static void NewPointPropertyChangedCallback(DependencyObject d, DependencyPropertyChangedEventArgs e)
        {
            MValueFunct2DInput instance = d as MValueFunct2DInput;

            if (instance == null)
            {
                return;
            }
            if (instance.NewPoint == null)
            {
                return;
            }

            instance.AddPointToFunction();
            instance.AddLineToCanvas();
        }
Пример #4
0
        private static void FinalizeFunctionPropertyChangedCallback(DependencyObject d, DependencyPropertyChangedEventArgs e)
        {
            MValueFunct2DInput instance = d as MValueFunct2DInput;

            if (instance == null)
            {
                return;
            }

            if (instance.FinalizeFunction)
            {
                instance.polylines.Add(instance.polyline);
                instance.polylines_names.Add(instance.FunctionName);
                instance.polyline         = new List <Point3D>();
                instance.FinalizeFunction = false;
                instance.ReDrawAllLines();
            }
        }
Пример #5
0
        private void PopulateTabITem(int _tag, ref TabItem tab_item)
        {
            if (tab_item == null)
            {
                return;
            }

            MValueFunct2DInput f_table = new MValueFunct2DInput();

            f_table.Width  = this.Width - 8;
            f_table.Height = this.Height - 24;
            f_table.HorizontalAlignment = System.Windows.HorizontalAlignment.Center;
            f_table.VerticalAlignment   = System.Windows.VerticalAlignment.Center;
            f_table.UnitX               = this.UnitX;
            f_table.UnitY               = this.UnitY;
            f_table.Tag                 = _tag;
            f_table.ShowGridLines       = false;
            f_table.SnapsToDevicePixels = true;
            f_table.PropertyChanged    += table_PropertyChanged;
            tab_item.Content            = f_table;

            this.tables.Add(f_table);
        }
Пример #6
0
        private void AdaptTabsToNrCellZChange()
        {
            int tab_nr_diff = this.NrCellsZ - this.nr_cell_z_prev;

            if (tab_nr_diff == 0)
            {
                return;
            }

            if (tab_nr_diff > 0)
            {
                // remove the tab holding the unit z label
                int nr_items = this.Items.Count;
                if (nr_items > 1)
                {
                    this.Items.RemoveAt(nr_items - 1);
                }

                // add tabs to existing ones
                for (int i = 0; i < tab_nr_diff; i++)
                {
                    // for each 2D Table -> define a separate TAB
                    TabItem ti = new TabItem();
                    ti.Header = "Tab " + i.ToString();

                    // input for the table names
                    TextBox ti_input = new TextBox();
                    ti_input.MinWidth  = 25;
                    ti_input.MinHeight = 15;
                    ti_input.Height    = 15;
                    ti_input.FontSize  = 10;
                    ti_input.Style     = (Style)ti_input.TryFindResource("ValueInput");
                    ti_input.IsEnabled = false;

                    ti.Tag        = ti_input;
                    ti.LostFocus += this.tabitem_LostFocus;
                    ti.GotFocus  += this.tabitem_GotFocus;

                    // apply style
                    ti.Style = (Style)this.TryFindResource("TabItem_ValueField_Input");

                    // add a new table
                    this.PopulateTabITem(i, ref ti);

                    // add Tab to the TabControl
                    this.Items.Add(ti);
                }

                // add the tab holding the unit z label
                this.AddUnitZTab("unit Z");
            }
            else
            {
                // remove tabs from the back
                int nr_items = this.Items.Count;
                for (int i = nr_items - 2; i > this.NrCellsZ - 1; i--)
                {
                    TabItem ti = this.Items[i] as TabItem;
                    if (ti != null)
                    {
                        MValueFunct2DInput ti_table = ti.Content as MValueFunct2DInput;
                        if (ti_table != null)
                        {
                            ti_table.PropertyChanged -= table_PropertyChanged;
                            this.tables.Remove(ti_table);
                        }
                    }
                    this.Items.RemoveAt(i);
                }
            }

            this.nr_cell_z_prev = this.NrCellsZ;
        }