Example #1
0
        private void ButtonContextMenu_OnMouseDown(object sender, MouseButtonEventArgs e)
        {
            ContextMenu contextMenu = sender as ContextMenu;

            if (contextMenu == null)
            {
                return;
            }

            ToggleButton button = contextMenu.Parent as ToggleButton;

            if (button == null)
            {
                return;
            }

            DamageSector sector = button.Tag as DamageSector;

            if (sector == null)
            {
                return;
            }

            CommonEditorForm form = new CommonEditorForm(sector, sector.ItemId > 0);

            form.ShowDialog();
        }
Example #2
0
        void ContextMenuButtonClick(object sender, RoutedEventArgs e)
        {
            System.Windows.Controls.MenuItem menuItem = sender as System.Windows.Controls.MenuItem;
            if (menuItem == null)
            {
                return;
            }

            DependencyObject parent = menuItem.Parent;
            ToggleButton     button = menuItem.Tag as ToggleButton;

            while (parent != null)
            {
                if (parent is ContextMenu)
                {
                    parent = ((ContextMenu)parent).PlacementTarget;
                }
                if (parent is ToggleButton)
                {
                    button = parent as ToggleButton;
                    break;
                }
                if (parent is FrameworkElement)
                {
                    parent = ((FrameworkElement)parent).Parent;
                }
                else
                {
                    parent = null;
                }
            }
            if (button == null)
            {
                return;
            }

            DamageSector sector = button.Tag as DamageSector;

            if (sector == null)
            {
                return;
            }

            CommonEditorForm form = new CommonEditorForm(sector, sector.ItemId > 0);

            if (form.ShowDialog() == DialogResult.OK)
            {
                button.ToolTip = new ToolTip
                {
                    Content = string.IsNullOrEmpty(sector.Remarks) ? "No Information" : sector.Remarks
                };
            }
        }
Example #3
0
        private void ButtonAddClick(object sender, EventArgs e)
        {
            try
            {
                Form form;

                switch (ViewedType.Name)
                {
                case nameof(AircraftWorkerCategory):
                    form = new AircraftWorkerCategoryForm(new AircraftWorkerCategory());
                    break;

                case nameof(Product):
                    form = new ProductForm(new Product());
                    break;

                case nameof(AccessoryRequired):
                    form = new KitForm(new AccessoryRequired());
                    break;

                default:
                {
                    var ci   = ViewedType.GetConstructor(Type.EmptyTypes);
                    var item = (BaseEntityObject)ci.Invoke(null);
                    form = new CommonEditorForm(item);
                    break;
                }
                }
                if (form.ShowDialog() == DialogResult.OK)
                {
                    itemsListView.Items[itemsListView.Items.IndexOf(itemsListView.SelectedItems[0])] =
                        new ListViewItem(GetListViewSubItems(SelectedItem), null)
                    {
                        Tag = SelectedItem
                    };
                }
            }
            catch (Exception ex)
            {
                Program.Provider.Logger.Log("Error while building new object", ex);
                return;
            }
        }
Example #4
0
        private void ContextMenuButtonClick(object sender, RoutedEventArgs e)
        {
            System.Windows.Controls.MenuItem menuItem = sender as System.Windows.Controls.MenuItem;
            if (menuItem == null)
            {
                return;
            }

            DependencyObject parent = menuItem.Parent;
            ToggleButton     button = menuItem.Tag as ToggleButton;

            while (parent != null)
            {
                if (parent is ContextMenu)
                {
                    parent = ((ContextMenu)parent).PlacementTarget;
                }
                if (parent is ToggleButton)
                {
                    button = parent as ToggleButton;
                    break;
                }
                if (parent is FrameworkElement)
                {
                    parent = ((FrameworkElement)parent).Parent;
                }
                else
                {
                    parent = null;
                }
            }
            if (button == null)
            {
                return;
            }

            DamageSector sector = button.Tag as DamageSector;

            if (sector == null)
            {
                return;
            }

            CommonEditorForm form = new CommonEditorForm(sector, sector.ItemId > 0);

            if (form.ShowDialog() == DialogResult.OK)
            {
                System.Windows.Controls.RichTextBox rtb = new System.Windows.Controls.RichTextBox()
                {
                    FontFamily = FontFamily, FontSize = FontSize
                };
                FlowDocumentScrollViewer flowDocument = new FlowDocumentScrollViewer();
                string tooltipTex = string.IsNullOrEmpty(sector.Remarks) ? "No Information" : sector.Remarks;
                try
                {
                    //TextRange tr = new TextRange(rtb.Document.ContentStart, rtb.Document.ContentEnd);
                    var documentBytes = Encoding.UTF8.GetBytes(tooltipTex);
                    using (var reader = new MemoryStream(documentBytes))
                    {
                        reader.Position = 0;
                        rtb.SelectAll();
                        rtb.Selection.Load(reader, System.Windows.DataFormats.Rtf);
                    }

                    //using (var reader = new MemoryStream(documentBytes))
                    //{
                    //    tr.Load(reader, System.Windows.DataFormats.Rtf);
                    //}
                    flowDocument.Document = rtb.Document;
                }
                catch (Exception)
                {
                }
                button.ToolTip = flowDocument;
            }
        }