Esempio n. 1
0
        public DialogText(string document)
        {
            this.HyperlinkCommand = new LambdaUICommand(Properties.Resources.CommandHyperlink,
                                                        o => {
                try {
                    DialogHyperlink dialog = new DialogHyperlink(this.editor)
                    {
                        Owner = this
                    };
                    dialog.ShowDialog();
                } catch (Exception exception) {
                    App.Mainframe.ReportException(exception);
                }
            }
                                                        );
            this.InsertImageCommand = new LambdaUICommand(Properties.Resources.CommandInsertImage, o => this.InsertImage());

            this.Document    = document;
            this.DataContext = this;
            this.InitializeComponent();
            if (!string.IsNullOrEmpty(this.Document))
            {
                FlowDocument flowDoc = TextNote.Load(this.Document);
                if (flowDoc != null)
                {
                    this.editor.Document = flowDoc;
                }
            }
        }
Esempio n. 2
0
 protected override void OnPropertyChanged(DependencyPropertyChangedEventArgs e)
 {
     base.OnPropertyChanged(e);
     try {
         if (e.Property == MenuItem.CommandProperty)
         {
             Window window = Window.GetWindow(this);
             if (window != null)
             {
                 LambdaUICommand command = this.Command as LambdaUICommand;
                 if (command != null && command.KeyGesture != null)
                 {
                     CommandMenuItem.RemoveInputBinding(window, command.KeyGesture);
                     window.InputBindings.Add(new InputBinding(command, command.KeyGesture));
                 }
                 else
                 {
                     command = e.OldValue as LambdaUICommand;
                     if (command != null && command.KeyGesture != null)
                     {
                         CommandMenuItem.RemoveInputBinding(window, command.KeyGesture);
                     }
                 }
             }
         }
         else if (e.Property == MenuItem.IsVisibleProperty && this.IsVisible)
         {
             LambdaUICommand command = this.Command as LambdaUICommand;
             if (command != null)
             {
                 command.NotifyCanExecuteChanged();
             }
         }
     } catch (Exception exception) {
         App.Mainframe.ReportException(exception);
     }
 }
        public DialogTruthTable(LogicalCircuit logicalCircuit)
        {
            this.logicalCircuit = logicalCircuit;
            this.InvertFilter   = true;
            this.testSocket     = new CircuitTestSocket(this.logicalCircuit);
            int inputBits = this.testSocket.Inputs.Sum(p => p.Pin.BitWidth);

            if (0 < inputBits)
            {
                this.TotalRows = BigInteger.One << inputBits;
            }
            else
            {
                this.TotalRows  = 0;
                this.TruthTable = new ListCollectionView(new List <TruthState>());
            }

            this.BuildTruthTable();

            this.CommandDeleteOldFilter = new LambdaUICommand("-", o => this.RemoveFilter(o as string))
            {
                IconPath = "Icon/Delete.xaml"
            };

            this.DataContext = this;
            this.InitializeComponent();

            Dictionary <DataGridTextColumn, Func <TruthState, int> > dataAccessor = new Dictionary <DataGridTextColumn, Func <TruthState, int> >();

            void addColumn(Pin pin, string path, int i)
            {
                DataGridTextColumn column = new DataGridTextColumn();

                column.Header  = pin.Name.Replace("_", "__");
                column.Binding = new Binding(path);
                if (pin.PinType == PinType.Input)
                {
                    column.Binding.StringFormat = "{0:X}";
                }
                Style style = new Style(typeof(DataGridColumnHeader));

                style.Setters.Add(new Setter(ToolTipService.ToolTipProperty, pin.ToolTip));
                column.HeaderStyle = style;
                this.dataGrid.Columns.Add(column);
                dataAccessor.Add(column, DialogTruthTable.InputFieldAccesor(i));
            }

            int index = 0;

            foreach (InputPinSocket socket in this.testSocket.Inputs)
            {
                addColumn(socket.Pin, "Input[" + index + "]", index);
                index++;
            }
            index = 0;
            foreach (OutputPinSocket socket in this.testSocket.Outputs)
            {
                addColumn(socket.Pin, "[" + index + "]", index);
                index++;
            }

            this.sortComparer      = new TruthStateComparer(dataAccessor);
            this.dataGrid.Sorting += new DataGridSortingEventHandler(this.DataGridSorting);
            DataObject.AddPastingHandler(this.filter, this.OnFilterPaste);
            this.OldFilters.AddRange(this.logicalCircuit.Validators.Split('\t').Where(f => !string.IsNullOrWhiteSpace(f)).Select(f => f.Trim()));
        }