コード例 #1
0
        protected ContextMenu BuildContextMenu()
        {
            // menu according to header
            if (this.Header != null)
            {
                Parameter p = this.Header as Parameter;
                if (p != null)
                {
                    if (p.Buddy != null && p.CompResult < ComparisonResult.SAME)
                    {
                        ContextMenu cm = new ContextMenu();
                        cm.UseLayoutRounding = true;
                        MenuItem mi1 = new MenuItem();
                        mi1.Header  = "Eigenschaften übernehmen";
                        mi1.Command = new RelayCommand((x) => p.AdoptPropertiesOfBuddy());
                        mi1.Icon    = new Image {
                            Source = new BitmapImage(new Uri(@"../Data/icons/menu/menu_OK.png", UriKind.Relative)), Width = 16, Height = 16
                        };
                        cm.Items.Add(mi1);
                        return(cm);
                    }
                    else if (p.Buddy == null && p.CompResult == ComparisonResult.UNIQUE && this.OtherParentComp != null)
                    {
                        ContextMenu cm = new ContextMenu();
                        cm.UseLayoutRounding = true;
                        MenuItem mi1 = new MenuItem();
                        mi1.Header  = "in andere Komponente übertragen";
                        mi1.Command = new RelayCommand((x) => this.OtherParentComp.AddCopyOfParameter(p, this.User));
                        mi1.Icon    = new Image {
                            Source = new BitmapImage(new Uri(@"../Data/icons/menu/menu_REF_on.png", UriKind.Relative)), Width = 16, Height = 16
                        };
                        cm.Items.Add(mi1);
                        return(cm);
                    }
                }
                Calculation calc = this.Header as Calculation;
                if (calc != null)
                {
                    if (calc.Buddy != null && calc.CompResult == ComparisonResult.SAMENAMEUNIT_DIFFVALUE)
                    {
                        ContextMenu cm = new ContextMenu();
                        cm.UseLayoutRounding = true;
                        MenuItem mi1 = new MenuItem();
                        mi1.Header  = "Ausdruck übernehmen";
                        mi1.Command = new RelayCommand((x) => calc.AdoptPropertiesOfBuddy());
                        mi1.Icon    = new Image {
                            Source = new BitmapImage(new Uri(@"../Data/icons/menu/menu_OK.png", UriKind.Relative)), Width = 16, Height = 16
                        };
                        cm.Items.Add(mi1);
                        return(cm);
                    }
                    else if (calc.Buddy == null && calc.CompResult == ComparisonResult.UNIQUE && this.OtherParentComp != null)
                    {
                        ContextMenu cm = new ContextMenu();
                        cm.UseLayoutRounding = true;
                        MenuItem mi1 = new MenuItem();
                        mi1.Header  = "in andere Komponente übertragen";
                        mi1.Command = new RelayCommand((x) => this.OtherParentComp.AddCopyOfCalculation(calc, this.User));
                        mi1.Icon    = new Image {
                            Source = new BitmapImage(new Uri(@"../Data/icons/menu/menu_REF_on.png", UriKind.Relative)), Width = 16, Height = 16
                        };
                        cm.Items.Add(mi1);
                        return(cm);
                    }
                }
            }

            return(null);
        }