Example #1
0
        private static void OnButtonShowTextChanged(DependencyObject depobj, DependencyPropertyChangedEventArgs evargs)
        {
            PaletteButton tb = depobj as PaletteButton;

            tb.BtnText.SetVisible((bool)evargs.NewValue);
            tb.SetToolTip();
        }
Example #2
0
        protected void SetSelectedButton(PaletteButton SelectedButton)
        {
            var OptionButtonSource = OptionButtons[SelectedButton];

            var SourceExpositor = OptionButtonSource as WorkCommandExpositor;

            if (SourceExpositor != null)
            {
                this.BtnText.Text              = SourceExpositor.Name;
                this.BtnImage.Source           = SourceExpositor.Pictogram;
                this.Command                   = SourceExpositor.Command;
                this.CommandParameterExtractor = SourceExpositor.CommandParameterExtractor;
                this.CommandTargetExtractor    = SourceExpositor.CommandTargetExtractor;
                this.ToolTip                   = SourceExpositor.Summary;
                // In this case the execution is by Command-Binding
                this.Operation = null;
            }

            var SourceDeclaration = OptionButtonSource as Tuple <IRecognizableElement, Action <object> >;

            if (SourceDeclaration != null)
            {
                this.BtnText.Text              = SourceDeclaration.Item1.Name;
                this.BtnImage.Source           = SourceDeclaration.Item1.Pictogram;
                this.Command                   = null;
                this.CommandParameterExtractor = null;
                this.CommandTargetExtractor    = null;
                this.ToolTip                   = SourceDeclaration.Item1.Summary;
                this.Operation                 = SourceDeclaration.Item2;
            }
        }
Example #3
0
        private static void OnButtonImageSizeChanged(DependencyObject depobj, DependencyPropertyChangedEventArgs evargs)
        {
            PaletteButton tb = depobj as PaletteButton;

            tb.BtnImage.Width  = (double)evargs.NewValue;
            tb.BtnImage.Height = (double)evargs.NewValue;
        }
Example #4
0
        private static void OnButtonTextChanged(DependencyObject depobj, DependencyPropertyChangedEventArgs evargs)
        {
            PaletteButton tb = depobj as PaletteButton;

            tb.BtnText.Text = evargs.NewValue as string;

            tb.BtnText.SetVisible(!tb.BtnText.Text.IsAbsent() && tb.ButtonShowText);
            tb.SetToolTip();
        }
        public void Initialize(EntityEditEngine Engine, string SourceName, string SourcePropertyTechName, string TextTitle,
                               Func <string> Reader, Action <string> Writer, bool ShowWindowButtons = false,
                               params Tuple <string, ImageSource, string, Action <string> >[] ExtraButtons)
        {
            this.SourcePropertyTechName = SourcePropertyTechName;

            this.Reader = Reader;
            this.Writer = Writer;

            this.Engine       = Engine;
            this.ExtraButtons = ExtraButtons;

            this.TextEditor.SyntaxHighlighting = HighlightingManager.Instance.GetDefinition("TcTemplate");    // "C#");
            this.TextEditor.ShowLineNumbers    = true;

            // Bad idea: this.TextEditor.LostFocus += ((sender, args) => this.WriteTextToSource());

            this.TextEditor.TextArea.MouseRightButtonDown +=
                ((sender, args) =>
            {
                var position = this.TextEditor.GetPositionFromPoint(args.GetPosition(this.TextEditor));
                if (position.HasValue)
                {
                    this.TextEditor.TextArea.Caret.Position = position.Value;
                }
            });

            this.BtnOK.SetVisible(ShowWindowButtons);
            this.BtnCancel.SetVisible(ShowWindowButtons);

            if (this.ExtraButtons != null && this.ExtraButtons.Length > 0)
            {
                foreach (var Extra in ExtraButtons)
                {
                    var LocalExtra = Extra;
                    var NewButton  = new PaletteButton(LocalExtra.Item1, LocalExtra.Item2, Summary: LocalExtra.Item3);
                    NewButton.Click += ((sdr, args) => LocalExtra.Item4(this.TextEditor.Text));

                    this.PnlExtraButtons.Children.Add(NewButton);
                }
            }
        }
Example #6
0
        private static void OnButtonShowShadowChanged(DependencyObject depobj, DependencyPropertyChangedEventArgs evargs)
        {
            PaletteButton tb           = depobj as PaletteButton;
            var           ButtonBorder = tb.GetTemplateChild <Border>("BackBorder");

            if (ButtonBorder == null)
            {
                return;
            }

            /* WPF still has minor problems with fonts over shadow
             * if ((bool)evargs.NewValue)
             * {
             *  var Shadow = new System.Windows.Media.Effects.DropShadowEffect();
             *  Shadow.Color = Colors.Gray;
             *  Shadow.Opacity = 0.2;
             *  ButtonBorder.Effect = Shadow;
             * }
             * else
             *  ButtonBorder.Effect = null; */
        }
Example #7
0
        void IndividualEditPanel_Loaded(object sender, RoutedEventArgs e)
        {
            this.ParentWindow = Window.GetWindow(this);
            if (this.ParentWindow == null)
            {
                throw new InternalAnomaly("Window cannot be obtained for this UserControl.");
            }

            this.BtnApply = this.GetTemplateChild <PaletteButton>("BtnApply");
            BtnApply.SetVisible(this.ShowApply, true);

            //this.BtnRefresh = this.GetTemplateChild<PaletteButton>("BtnRefresh");
            //BtnRefresh.SetVisible(this.ShowRefresh, false);

            this.BtnAdvanced = this.GetTemplateChild <PaletteToggleButton>("BtnAdvanced");

            this.BtnHelp = this.GetTemplateChild <PaletteButton>("BtnHelp");
            BtnHelp.SetVisible(this.HasHelpForShowing, false);

            this.BtnOK     = this.GetTemplateChild <PaletteButton>("BtnOK");
            this.BtnCancel = this.GetTemplateChild <PaletteButton>("BtnCancel");

            this.ShowAdvancedMembers   = AppExec.GetConfiguration <bool>("UserInterface", "ShowAdvancedProperties", false);
            this.BtnAdvanced.IsChecked = this.ShowAdvancedMembers;

            this.ParentWindow.Loaded  += new RoutedEventHandler(ParentWindow_Loaded);
            this.ParentWindow.Closing += new System.ComponentModel.CancelEventHandler(ParentWindow_Closing);
            this.ParentWindow.Closed  += new EventHandler(ParentWindow_Closed);

            this.BtnHelp.SetVisible(this.HasHelpForShowing);

            // Asked here because may have been setted before template load
            if (!this.CanCancelEditing)
            {
                this.BtnCancel.IsEnabled = false;
            }

            // Append extra buttons
            var PnlButtons = this.GetTemplateChild <Panel>("PnlButtons");

            if (PnlButtons != null && this.ExtraButtons != null && this.ExtraButtons.Count > 0)
            {
                foreach (var Extra in this.ExtraButtons)
                {
                    var LocalExtra = Extra;
                    var NewButton  = new PaletteButton(LocalExtra.Item1, LocalExtra.Item3, Summary: LocalExtra.Item2);
                    NewButton.Margin = new Thickness(2);
                    NewButton.Click += ((sndr, args) => LocalExtra.Item4(this.AssociatedEntity));
                    PnlButtons.Children.Add(NewButton);
                }
            }

            // Set header
            var Header = Display.GetTemplateChild <Border>(this, "BrdHeader");

            if (Header == null)
            {
                return;
            }

            Header.Child = this.HeaderContent;
            Header.SetVisible(this.HeaderContent != null);
        }
Example #8
0
        private static void OnButtonOrientationChanged(DependencyObject depobj, DependencyPropertyChangedEventArgs evargs)
        {
            PaletteButton tb = depobj as PaletteButton;

            tb.BackPanel.Orientation = (Orientation)evargs.NewValue;
        }
Example #9
0
        private static void OnButtonImageChanged(DependencyObject depobj, DependencyPropertyChangedEventArgs evargs)
        {
            PaletteButton tb = depobj as PaletteButton;

            tb.BtnImage.Source = evargs.NewValue as ImageSource;
        }
Example #10
0
        private static void OnButtonClickActionChanged(DependencyObject depobj, DependencyPropertyChangedEventArgs evargs)
        {
            PaletteButton tb = depobj as PaletteButton;

            tb.ButtonClickAction = (Action <string, object>)evargs.NewValue;
        }
Example #11
0
        private static void OnButtonActionFieldSourceChanged(DependencyObject depobj, DependencyPropertyChangedEventArgs evargs)
        {
            PaletteButton tb = depobj as PaletteButton;

            tb.ButtonActionFieldSource = evargs.NewValue;
        }