예제 #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();
        }
예제 #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
                };
            }
        }
예제 #3
0
        /// <summary>
        /// Реагирует на нажатие кнопки добавления нового элемента
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        protected virtual void ButtonAddDisplayerRequested(object sender, ReferenceEventArgs e)
        {
            try
            {
                Form form;

                if (ViewedType.Name == nameof(AircraftWorkerCategory))
                {
                    form = new AircraftWorkerCategoryForm(new AircraftWorkerCategory());
                }
                //else if (ViewedType.Name == typeof(DetailModel).Name || ViewedType.Name == typeof(AircraftModel).Name)
                //{
                //    ConstructorInfo ci = ViewedType.GetConstructor(new Type[0]);
                //    BaseEntityObject item = (BaseEntityObject)ci.Invoke(null);
                //    form = new CommonEditorForm(item);
                //}
                else if (ViewedType.Name == nameof(Product))
                {
                    form = new ProductForm(new Product());
                }
                else if (ViewedType.Name == nameof(ComponentModel))
                {
                    form = new ModelForm(new ComponentModel());
                }
                else if (ViewedType.Name == nameof(GoodStandart))
                {
                    form = new GoodStandardForm(new GoodStandart());
                }
                else
                {
                    ConstructorInfo  ci   = ViewedType.GetConstructor(new Type[0]);
                    BaseEntityObject item = (BaseEntityObject)ci.Invoke(null);
                    form = new CommonEditorForm(item);
                }

                if (form.ShowDialog(this) == DialogResult.OK)
                {
                    AnimatedThreadWorker.DoWork -= AnimatedThreadWorkerDoWork;
                    AnimatedThreadWorker.DoWork -= AnimatedThreadWorkerDoFilteringWork;
                    AnimatedThreadWorker.DoWork += AnimatedThreadWorkerDoWork;

                    AnimatedThreadWorker.RunWorkerAsync();
                }
            }
            catch (Exception ex)
            {
                Program.Provider.Logger.Log("Error while building new object", ex);
            }
        }
        protected virtual void ItemsListViewMouseDoubleClick(object sender, MouseEventArgs e)
        {
            if (SelectedItem == null)
            {
                return;
            }
            DisplayerAttribute da =
                (DisplayerAttribute)_viewedType.GetCustomAttributes(typeof(DisplayerAttribute), false)
                .FirstOrDefault();

            if (da == null || da.DisplayerType == DisplayerType.Form)
            {
                Form form;
                if (SelectedItem is AircraftWorkerCategory)
                {
                    form = new AircraftWorkerCategoryForm((AircraftWorkerCategory)SelectedItem);
                }
                else if (SelectedItem is AccessoryDescription)
                {
                    form = new AccessoryDescriptionForm((AccessoryDescription)SelectedItem);
                }
                else if (SelectedItem is AccessoryRequired)
                {
                    form = new KitForm((AccessoryRequired)SelectedItem);
                }
                else
                {
                    form = new CommonEditorForm(SelectedItem);
                }
                if (form.ShowDialog() == DialogResult.OK)
                {
                    itemsListView.Items[itemsListView.Items.IndexOf(itemsListView.SelectedItems[0])] =
                        new ListViewItem(GetListViewSubItems(SelectedItem), null)
                    {
                        Tag = SelectedItem
                    };
                }
            }
            else if (da.DisplayerType == DisplayerType.Screen)
            {
                OnDisplayerRequested();
            }
        }
예제 #5
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;
            }
        }
        private void ButtonAddClick(object sender, EventArgs e)
        {
            try
            {
                Form form;

                if (ViewedType.Name == typeof(AircraftWorkerCategory).Name)
                {
                    form = new AircraftWorkerCategoryForm(new AircraftWorkerCategory());
                }
                else if (ViewedType.Name == typeof(AccessoryDescription).Name)
                {
                    form = new AccessoryDescriptionForm(new AccessoryDescription());
                }
                else if (ViewedType.Name == typeof(AccessoryRequired).Name)
                {
                    form = new KitForm(new AccessoryRequired());
                }
                else
                {
                    ConstructorInfo  ci   = ViewedType.GetConstructor(new Type[0]);
                    BaseEntityObject item = (BaseEntityObject)ci.Invoke(null);
                    form = new CommonEditorForm(item);
                }
                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;
            }
        }
예제 #7
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;
            }
        }