protected override async void OnDeleteSelection()
        {
            StatusReady();
            if (await DialogService.ShowAsync("Confirm Delete", "Are you sure you want to delete selected order items?", "Ok", "Cancel"))
            {
                int count = 0;
                try
                {
                    if (SelectedIndexRanges != null)
                    {
                        count = SelectedIndexRanges.Sum(r => r.Length);
                        StartStatusMessage($"Deleting {count} order items...");
                        await DeleteRangesAsync(SelectedIndexRanges);

                        MessageService.Send(this, "ItemRangesDeleted", SelectedIndexRanges);
                    }
                    else if (SelectedItems != null)
                    {
                        count = SelectedItems.Count();
                        StartStatusMessage($"Deleting {count} order items...");
                        await DeleteItemsAsync(SelectedItems);

                        MessageService.Send(this, "ItemsDeleted", SelectedItems);
                    }
                }
                catch (Exception ex)
                {
                    StatusError($"Error deleting {count} order items: {ex.Message}");
                    LogException("OrderItems", "Delete", ex);
                    count = 0;
                }
                await RefreshAsync();

                SelectedIndexRanges = null;
                SelectedItems       = null;
                if (count > 0)
                {
                    EndStatusMessage($"{count} order items deleted");
                }
            }
        }
Esempio n. 2
0
        async Task Pick(params MediaFileType[] types)
        {
            try
            {
                if (SelectedItems?.Count() > 0)
                {
                    foreach (var item in SelectedItems)
                    {
                        item.Dispose();
                    }
                }

                var result = await MediaGallery.PickAsync(SelectionLimit, types);

                SelectedItems = result?.Files?.ToArray();
            }
            catch (Exception ex)
            {
                await DisplayAlertAsync(ex.Message);
            }
        }
Esempio n. 3
0
 private void TreeViewSolutionDoubleClick(object sender, EventArgs e)
 {
     if (treeViewSolution.SelectedNode.Tag != null)
     {
         IProjectFile file = treeViewSolution.SelectedNode.Tag as CrcsProject;
         if (file == null)
         {
             file = treeViewSolution.SelectedNode.Tag as CrcsSolution;
         }
         if (file != null)
         {
             MainForm.OpenFile(file);
             treeViewSolution.SelectedNode = treeViewSolution.SelectedNode.Parent;
             return;
         }
     }
     if (SelectedItems.Count() == 0)
     {
         return;
     }
     if (SelectedItems.OfType <CrcsProject>().Count() > 0)
     {
         return;
     }
     if (SelectedItems.OfType <CrcsSolution>().Count() > 0)
     {
         return;
     }
     try
     {
         Cursor = Cursors.WaitCursor;
         MainForm.OpenSelectedFiles();
     }
     finally
     {
         Cursor = Cursors.Default;
     }
 }
        /// <summary>
        /// 處理滑鼠左鍵連點在可選/已選項
        /// </summary>
        /// <param name="obj"></param>
        public void AddClickedItem(object obj)
        {
            System.Windows.Controls.TextBlock itemTextBlock = obj as System.Windows.Controls.TextBlock;
            if (itemTextBlock == null)
            {
                return;
            }
            DataTable availableItemsDataTable = Database.DBQueryTool.GetFurnItemInfo(SITE_ID);

            foreach (DataRow row in availableItemsDataTable.Rows.Cast <DataRow>())
            {
                if (row["ITEM_NAME"].ToString() == itemTextBlock.Text)
                {
                    SPCItemInfo info = new SPCItemInfo()
                    {
                        ItemList    = row["FURN_ITEM_INDEX"].ToString(),
                        Flag        = "I",
                        Description = row["ITEM_NAME"].ToString(),
                        Title       = row["ITEM_NAME"].ToString()
                    };
                    if (SelectedItems.Count() > 0)
                    {
                        var a = SelectedItems.Select(x => x.ItemList == info.ItemList);
                        a = a as IEnumerable <bool>;
                        if (!a.Contains(true))
                        {
                            SelectedItems.Add(info);
                            return;
                        }
                    }
                    else
                    {
                        SelectedItems.Add(info);
                        return;
                    }
                }
            }
        }
    private void SetValue()
    {
        var typeValue = NullableUnderlyingType ?? typeof(TValue);

        if (typeValue == typeof(string))
        {
            CurrentValueAsString = string.Join(",", SelectedItems.Select(i => i.Value));
        }
        else if (typeValue.IsGenericType || typeValue.IsArray)
        {
            var t        = typeValue.IsGenericType ? typeValue.GenericTypeArguments[0] : typeValue.GetElementType() !;
            var listType = typeof(List <>).MakeGenericType(t);
            var instance = (IList)Activator.CreateInstance(listType, SelectedItems.Count()) !;

            foreach (var item in SelectedItems)
            {
                if (item.Value.TryConvertTo(t, out var val))
                {
                    instance.Add(val);
                }
            }
            CurrentValue = (TValue)(typeValue.IsGenericType ? instance : listType.GetMethod("ToArray") !.Invoke(instance, null) !);
        }
    }
 void selectionPanel1_SelectionChanged(object sender, EventArgs e)
 {
     lblItems.Text = string.Format(strings.NumberOfComponentsPlusSelected, _counter, SelectedItems.Count());
 }
 private bool CanChange()
 {
     return(SelectedItems.Count() == 1 && IsDelEnable && IsEditEnable && IsNewEnable);
 }
Esempio n. 8
0
        private void printRotaToolStripMenuItem_Click(object sender, EventArgs e)
        {
            if (SelectedItems.Count() == 0)
            {
                return;
            }

            RotaPrintMenuFrm frm = new RotaPrintMenuFrm();

            if (frm.ShowDialog() != DialogResult.OK)
            {
                return;
            }

            int[] Weeks;

            //get an int array of week numbers
            if (frm.SelectedPrintSelection == RotaPrintMenuFrm.PrintSelection.AllWeeks)
            {
                Weeks = Enumerable.Range(1, Settings.Instance.rotaweekcount).ToArray();                // new int[] { 1, 2, 3, 4, 5, 6 };
            }
            else
            {
                Weeks = frm.SelectedWeeks;
            }

            //get how many pages there will be (amount of weeks * amount of workers)
            int totalPages = SelectedItems.Count() * Weeks.Length;

            //if there are gunna be over a hundred give a warning!
            if (totalPages > 100)
            {
                if (MessageBox.Show("You are about to generate rather a large amount of rota pages (" + totalPages.ToString() + ").\r\nThis may take a little time. Press Yes to continue", "Rota Generation", MessageBoxButtons.YesNo) == DialogResult.No)
                {
                    return;
                }
            }

            //sort the weeks lowest to highest
            Array.Sort <int>(Weeks,
                             new Comparison <int>(
                                 (i1, i2) => i1.CompareTo(i2)
                                 ));


            //create the document
            Document document = new Document(PageSize.A4.Rotate());


            PdfWriter writer;
            string    filename = (SelectedItems.Count() > 1 ? "multiworker" : SelectedItems.ElementAt(0).Name) + "-" + _periodstartdate.ToString("yyyyMMdd") + ".pdf";

            try
            {
                writer = PdfWriter.GetInstance(document, new FileStream(filename, FileMode.Create));
                document.Open();
            }
            catch (Exception ex)
            {
                MessageBox.Show("Failed to Open Rota Pdf Document.\r\n\r\n" + ex.Message);
                return;
            }

            //create some font stuff
            BaseFont bfTimes = BaseFont.CreateFont(BaseFont.COURIER, BaseFont.CP1252, false);

            iTextSharp.text.Font times                = new iTextSharp.text.Font(bfTimes, 8, iTextSharp.text.Font.NORMAL, iTextSharp.text.BaseColor.BLACK);
            iTextSharp.text.Font times_bold           = new iTextSharp.text.Font(bfTimes, 8, iTextSharp.text.Font.BOLD, iTextSharp.text.BaseColor.BLACK);
            iTextSharp.text.Font times_bold_underline = new iTextSharp.text.Font(bfTimes, 8, iTextSharp.text.Font.BOLD | iTextSharp.text.Font.UNDERLINE, iTextSharp.text.BaseColor.BLACK);

            //iterate over each worker
            foreach (Worker worker in SelectedItems)
            {
                //iterate over each week
                foreach (int week in Weeks)
                {
                    DateTime currentWeek = _periodstartdate.AddDays(7 * (week - 1));

                    document.Add(new Paragraph(worker.Name, times_bold));
                    document.Add(new Paragraph("\r\n\r\n"));

                    PdfPTable table = new PdfPTable(8);

                    table.WidthPercentage = 100;
                    PdfPCell cell = new PdfPCell(new Phrase("Week " + week.ToString() + "\r\n(" + currentWeek.ToString("dd/MM/yyyy") + ")\r\n", times));
                    cell.Padding             = 5;
                    cell.Colspan             = 8;
                    cell.HorizontalAlignment = 1;                     //0=left, 1=centre, 2=right
                    table.AddCell(cell);

                    table.AddCell("");


                    Dictionary <string, string[]> serviceUserText = new Dictionary <string, string[]>();

                    DateTime startOfWeek = currentWeek;

                    for (int day = 0; day < 7; day++)
                    {
                        string daytxt = ((System.DayOfWeek)((day + 1) % 7)).ToString();

                        if (worker.isDayOff(startOfWeek.AddDays(day)))
                        {
                            daytxt += " (Day Off)";
                        }
                        table.AddCell(new Phrase(daytxt, times_bold));
                    }


                    //iterate over each day of this week
                    for (int day = 0; day < 7; day++)
                    {
                        //get the current day
                        DateTime currentDay = startOfWeek.AddDays(day);

                        //now get all the calls that are on this day for this worker!
                        foreach (Call call in worker.Calls.Where(c => c.time >= currentDay && c.time < currentDay.AddDays(1)))
                        {
                            string[] dayText;
                            string   serviceusertxt = call.ServiceUser.Name + "\r\n" + call.ServiceUser.add1 + "\r\n" + call.ServiceUser.postcode;

                            //creeate a day text for a specific service user
                            if (!serviceUserText.TryGetValue(serviceusertxt, out dayText))
                            {
                                dayText = new string [] { "", "", "", "", "", "", "" };
                                serviceUserText.Add(serviceusertxt, dayText);
                            }

                            string doubleuptext = "";

                            if (call.required_workers == 2)
                            {
                                doubleuptext = "[D: ";

                                if (call.Workers.Count() == 1)
                                {
                                    doubleuptext += "Unassigned";
                                }
                                else
                                {
                                    Worker otherWorker = call.Workers.Single(w => w != worker);

                                    doubleuptext += otherWorker.ShortName;
                                }

                                doubleuptext += "]";
                            }

                            string calltxt = call.time.ToString("HH:mm") + " (" + call.duration_mins.ToString() + " min)\r\n" + doubleuptext;

                            dayText[day] += calltxt;
                        }
                    }


                    if (serviceUserText.Count == 0)
                    {
                        Phrase phr = new Phrase("No Calls", times);

                        phr.Font.SetStyle(1);                         //bold it for dramatic effect ;)

                        PdfPCell nocallscell = new PdfPCell(phr);
                        nocallscell.Padding             = 5;
                        nocallscell.Colspan             = 8;
                        nocallscell.HorizontalAlignment = 1;                         //0=Left, 1=Centre, 2=Right
                        table.AddCell(nocallscell);
                    }
                    else
                    {
                        foreach (KeyValuePair <string, string[]> entry in serviceUserText)
                        {
                            string   serviceusername = entry.Key;
                            string[] dayText         = entry.Value;

                            table.AddCell(new Phrase(serviceusername, times));

                            foreach (string text in dayText)
                            {
                                table.AddCell(new Phrase(text.Trim(), times));
                            }
                        }
                    }

                    document.Add(table);

                    if (week != Weeks[Weeks.Length - 1])
                    {
                        document.NewPage();
                    }
                }
                document.NewPage();
            }

            document.Close();
            document.Dispose();

            System.Diagnostics.Process.Start(@filename);
        }
Esempio n. 9
0
        private void contextMenuStrip1_Opening(object sender, CancelEventArgs e)
        {
            if (SelectedItems.Count() == 0 || (!_showContextMenu && !_showSimpleContextMenu))
            {
                e.Cancel = true;
            }
            else
            {
                //disableToolStripMenuItem.Visible = SelectedItem.idStatus == Worker.Status.Active;
                //enableToolStripMenuItem.Visible = SelectedItem.idStatus == Worker.Status.Inactive;

                if (_showSimpleContextMenu)
                {
                    editToolStripMenuItem.Visible          = false;
                    duplicateUserToolStripMenuItem.Visible = false;
                    disableToolStripMenuItem.Visible       = false;
                    enableToolStripMenuItem.Visible        = false;
                    deleteToolStripMenuItem.Visible        = false;
                    emailRotaToolStripMenuItem.Visible     = false;

                    toolStripSeparator2.Visible = false;
                    toolStripSeparator3.Visible = false;
                }
                else
                {
                    editToolStripMenuItem.Visible = _allowOpenWorker;
                }

                // ok first load up all the groups
                List <WorkerGroup> groups = WorkerGroupManager.Instance.WorkerGroups;

                List <WorkerGroup> groupsToAdd    = new List <WorkerGroup>(groups);
                List <WorkerGroup> groupsToRemove = new List <WorkerGroup>();

                // now remove all the groups to ADD except the <new group> one
                for (int i = addToGroupToolStripMenuItem.DropDownItems.Count - 1; i > 0; i--)
                {
                    addToGroupToolStripMenuItem.DropDownItems.RemoveAt(i);
                }

                //now remove all the groups to REMOVE.
                removeFromGroupToolStripMenuItem.DropDownItems.Clear();

                //=========================================
                // Add Section
                //
                // Here we are going to be adding groups
                // that none of the selected workers are
                // part of.
                //=========================================


                //first lets get all the groups that exist in all the selected items.
                List <WorkerGroup> selectedItemsGroups = new List <WorkerGroup>();

                // create a list of every group, some may occur multiple times. we can jsut use this to see if its for everyone
                foreach (Worker worker in SelectedItems)
                {
                    foreach (WorkerGroup group in worker.Groups)
                    {
                        selectedItemsGroups.Add(group);
                    }
                }


                while (selectedItemsGroups.Count() > 0)
                {
                    //get the last group in the list
                    WorkerGroup group = selectedItemsGroups[selectedItemsGroups.Count - 1];
                    selectedItemsGroups.RemoveAt(selectedItemsGroups.Count - 1);

                    int count = 1;

                    //now find any dupes!
                    for (int i = selectedItemsGroups.Count - 1; i >= 0; i--)
                    {
                        if (selectedItemsGroups[i] == group)
                        {
                            count++;
                            selectedItemsGroups.RemoveAt(i);
                        }
                    }

                    if (count == SelectedItems.Count())
                    {
                        //everyone selected is in this group!
                        groupsToAdd.Remove(group);
                    }
                    else
                    {
                        //only some people were in this group
                        //leave it in
                    }

                    groupsToRemove.Add(group);
                }

                foreach (WorkerGroup group in groupsToAdd)
                {
                    ToolStripItem item = new ToolStripMenuItem()
                    {
                        Text = group.GroupName, Tag = group
                    };
                    item.Click += itemAdd_Click;

                    addToGroupToolStripMenuItem.DropDownItems.Add(item);
                }


                foreach (WorkerGroup group in groupsToRemove)
                {
                    ToolStripItem item = new ToolStripMenuItem()
                    {
                        Text = group.GroupName, Tag = group
                    };
                    item.Click += itemRemove_Click;

                    removeFromGroupToolStripMenuItem.DropDownItems.Add(item);
                }

                //only show the remove menu if there are groups to remove!
                removeFromGroupToolStripMenuItem.Visible = removeFromGroupToolStripMenuItem.DropDownItems.Count != 0;
            }
        }
Esempio n. 10
0
        private void ContextMenuProjectOpening(object sender, CancelEventArgs e)
        {
            int selectedFilesCount = SelectedItems.Count();

            if (selectedFilesCount == 0)
            {
                e.Cancel = true;
                return;
            }
            int missingFilesCount  = SelectedNodes.Count(x => x.IsMissing);
            int selectedNodesCount = SelectedNodes.Count();

            if (missingFilesCount == selectedNodesCount)
            {
                foreach (ToolStripItem item in contextMenuProject.Items)
                {
                    item.Visible = false;
                }
                menuProjectRemove.Visible        = true;
                menuProjectReloadProject.Visible = SelectedNodes.Count(x => x.IsProject) == missingFilesCount;
                return;
            }
            bool onlyOneSelected  = SelectedNodes.Count() == 1;
            bool canReloadProject = (SelectedNodes.Count(node => node.IsProject) == SelectedNodes.Count() &&
                                     onlyOneSelected);
            bool isSolution          = (SelectedNodes.Count(node => node.IsSolution) > 0 && onlyOneSelected);
            bool isProjectOrSolution = (SelectedNodes.Count(node => node.IsSolution || node.IsProject) > 0);
            bool canShowPropertiesSelectedTreeNodes = CanShowPropertiesSelectedTreeNodes();
            bool canRemoveSelectedTreeNodes         = CanRemoveSelectedTreeNodes();
            bool canOpenSelectedTreeNodes           = CanOpenSelectedTreeNodes();
            bool canProcessSelectedTreeNodes        = CanProcessSelectedTreeNodes();
            bool canIncludeSelectedTreeNodes        = CanIncludeSelectedTreeNodes();
            bool canExcludeSelectedTreeNodes        = CanExcludeSelectedTreeNodes();
            bool canRevertSelectedTreeNodes         = CanRevertSelectedTreeNodes();
            bool canDecodeSelectedTreeNodes         = CanDecodeSelectedTreeNodes();
            bool canEncodeSelectedTreeNodes         = CanEncodeSelectedTreeNodes();
            bool canRecompileSelectedTreeNodes      = CanRecompileSelectedTreeNodes();
            bool canDecompileSelectedTreeNodes      = CanDecompileSelectedTreeNodes();
            bool canOptiPngSelectedTreeNodes        = CanOptimizePngSelectedTreeNodes();

            menuProjectOpen.Visible = canOpenSelectedTreeNodes;

            bool barVisible = canOpenSelectedTreeNodes;

            menuProjectBar1.Visible               = (canIncludeSelectedTreeNodes || canExcludeSelectedTreeNodes) && barVisible;
            menuProjectIncludeInProject.Visible   = canIncludeSelectedTreeNodes;
            menuProjectExcludeFromProject.Visible = canExcludeSelectedTreeNodes;

            barVisible = canIncludeSelectedTreeNodes || canExcludeSelectedTreeNodes || barVisible;
            bool bar2Visible = canProcessSelectedTreeNodes || canDecodeSelectedTreeNodes || canEncodeSelectedTreeNodes || canRecompileSelectedTreeNodes || canDecompileSelectedTreeNodes || canOptiPngSelectedTreeNodes;

            menuProjectBar2.Visible        = bar2Visible && barVisible;
            menuProjectProcess.Visible     = canProcessSelectedTreeNodes;
            menuProjectDecompile.Visible   = canDecompileSelectedTreeNodes;
            menuProjectRecompile.Visible   = canRecompileSelectedTreeNodes;
            menuProjectOptimizePng.Visible = canOptiPngSelectedTreeNodes;
            menuProjectDecode.Visible      = canDecodeSelectedTreeNodes;
            menuProjectEncode.Visible      = canEncodeSelectedTreeNodes;

            barVisible = bar2Visible || barVisible;
            bool canCompare  = CreateCompareToMenu();
            bool bar3Visible = canRevertSelectedTreeNodes || canCompare;

            menuProjectBar3.Visible   = bar3Visible && barVisible;
            menuProjectRevert.Visible = canRevertSelectedTreeNodes;

            barVisible = bar3Visible || barVisible;
            bool bar4Visible = !isProjectOrSolution && onlyOneSelected;

            menuProjectBar4.Visible                 = bar4Visible && barVisible;
            menuProjectCopyFullPath.Visible         = bar4Visible;
            menuProjectOpenContainingFolder.Visible = bar4Visible;

            barVisible = bar4Visible || barVisible;
            bool bar5Visible = canRemoveSelectedTreeNodes || canReloadProject;

            menuProjectBar5.Visible          = bar5Visible && barVisible;
            menuProjectRemove.Visible        = canRemoveSelectedTreeNodes;
            menuProjectReloadProject.Visible = canReloadProject;

            barVisible = bar5Visible || barVisible;
            menuProjectBar6.Visible       = canShowPropertiesSelectedTreeNodes && !isSolution && barVisible;
            menuProjectProperties.Visible = canShowPropertiesSelectedTreeNodes;
        }
Esempio n. 11
0
        protected BaseListViewModel(IUnityContainer container) : base(container)
        {
            DialogService   = Container.Resolve <IDialogService>();
            MessageService  = Container.Resolve <IMessageService>();
            EventAggregator = Container.Resolve <IEventAggregator>();

            Lookups = new ObservableCollection <TLookup>();

            NewItemCommand    = new DelegateLogCommand(NewItemCommand_Execute, NewItemCommand_CanExecute);
            EditItemCommand   = new DelegateLogCommand(EditItemCommand_Execute, EditItemCommand_CanExecute);
            RemoveItemCommand = new DelegateLogCommand(RemoveItemCommand_Execute, RemoveItemCommand_CanExecute);

            SelectItemCommand  = new DelegateLogCommand(SelectItemCommand_Execute, SelectItemCommand_CanExecute);
            SelectItemsCommand = new DelegateLogCommand(
                () =>
            {
                CloseRequested?.Invoke(this, new DialogRequestCloseEventArgs(true));
            },
                () => SelectedItems != null);

            RefreshCommand = new DelegateLogCommand(RefreshCommand_Execute);

            UnionCommand = new DelegateLogCommand(
                () =>
            {
                var selectedItem = container.Resolve <ISelectService>().SelectItem(SelectedItems);
                if (selectedItem == null)
                {
                    return;
                }

                IUnitOfWork unitOfWork    = container.Resolve <IUnitOfWork>();
                var repository            = unitOfWork.Repository <TEntity>();
                TEntity mainItem          = repository.GetById(selectedItem.Id);
                List <TEntity> otherItems = SelectedItems.Select(entity => repository.GetById(entity.Id)).ToList();
                otherItems.Remove(mainItem);

                if (UnionItemsAction(unitOfWork, mainItem, otherItems) == false)
                {
                    return;
                }

                foreach (var otherItem in otherItems)
                {
                    EventAggregator.GetEvent <TAfterRemoveEntityEvent>().Publish(otherItem);
                }
                repository.DeleteRange(otherItems);
                unitOfWork.SaveChanges();

                container.Resolve <IMessageService>().ShowOkMessageDialog("Информация", "Объединение успешно завершено!");
            },
                () => SelectedItems != null && SelectedItems.Count() > 1);

            EventAggregator.GetEvent <TAfterSaveEntityEvent>().Subscribe(OnAfterSaveEntity);
            EventAggregator.GetEvent <TAfterRemoveEntityEvent>().Subscribe(OnAfterRemoveEntity);

            this.LoadBegin += () => IsLoaded = false;
            this.Loaded    += () => IsLoaded = true;

            InitSpecialCommands();
            SubscribesToEvents();
            LastActionInCtor();
        }
Esempio n. 12
0
 public void OnSelectedItemsChanged()
 {
     SelectedItems.CreateFrom(Items.SelectedItems());
     NumberOfSelectedLocalSongs = SelectedItems.Count(e => (e.Item as PlaylistItem).Path.IsLocal());
     NumberOfSelectedStreams    = SelectedItems.Count(e => (e.Item as PlaylistItem).Path.IsStream());
 }
        private void DeleteCommandHandler()
        {
            if (MessageBox.ShowDialog(string.Format("Do you confirm delete {0} records.", SelectedItems.Count()), "Delete", System.Windows.Forms.MessageBoxButtons.YesNo) == System.Windows.Forms.DialogResult.Yes)
            {
                foreach (var item in SelectedItems.ToList())
                {
                    QuestionList.Remove(item);
                }
            }

            SaveCommand.Execute(null);
            RaiseCanExecuteChanged();
        }
Esempio n. 14
0
 public bool SelectionHasAtLeast <T>(int minCount)
 {
     return(SelectedItems.Count(x => x is T) >= minCount);
 }
Esempio n. 15
0
        public void UpdateUI()
        {
            Text = string.Format("{0}{1} ({2} for {3})",
                                 appPal.PaletteName, appPal.Dirty ? "*" : "",
                                 schemeBox.SelectedItem.ToString(), app.Color.ToHtml());

            var hasAny      = appPal.Palette.Colors.Count > 0;
            var hasMultiple = appPal.Palette.Colors.Count > 1;
            var selected    = SelectedItems.Count() > 0;
            var canPaste    = Clipboard.ContainsData("LPC") ||
                              Clipboard.ContainsText();
            var supportsMetadata = appPal.Palette is GimpPalette ||
                                   appPal.Palette is AcbPalette || appPal.Palette is ActPalette ||
                                   appPal.Palette is NativePalette;
            var supportsColourMetadata = appPal.Palette is AcbPalette ||
                                         appPal.Palette is NativePalette;

            propertiesToolStripMenuItem.Enabled     = supportsMetadata;
            propertiesToolStripMenuItem.ToolTipText = supportsMetadata ?
                                                      "" : "This file format doesn't support metadata.";
            changeMetadataToolStripMenuItem.Enabled        = selected && supportsColourMetadata;
            changeMetadataSubmenuToolStripMenuItem.Enabled = selected && supportsColourMetadata;
            changeMetadataToolStripMenuItem.ToolTipText    = supportsColourMetadata ?
                                                             "" : "This file format doesn't support metadata.";
            changeMetadataSubmenuToolStripMenuItem.ToolTipText = supportsColourMetadata ?
                                                                 "" : "This file format doesn't support metadata.";

            saveToolStripMenuItem.Enabled       = appPal.Dirty;
            saveAsHTMLToolStripMenuItem.Enabled = hasAny;

            undoToolStripMenuItem.Enabled = appPal.CanUndo();
            redoToolStripMenuItem.Enabled = appPal.CanRedo();
            undoToolStripMenuItem.Text    = appPal.CanUndo() ?
                                            "Undo " + appPal.UndoHistory.Peek().Name : "Can't Undo";
            redoToolStripMenuItem.Text = appPal.CanRedo() ?
                                         "Redo " + appPal.RedoHistory.Peek().Name : "Can't Redo";

            backToolStripMenuItem.Enabled    = app.CanUndo();
            forwardToolStripMenuItem.Enabled = app.CanRedo();

            brightenToolStripMenuItem.Enabled   = app.CanBrighten();
            darkenToolStripMenuItem.Enabled     = app.CanDarken();
            saturateToolStripMenuItem.Enabled   = app.CanSaturate();
            desaturateToolStripMenuItem.Enabled = app.CanDesaturate();

            cutSubmenuToolStripMenuItem.Enabled    = selected;
            cutToolStripMenuItem.Enabled           = selected;
            copyPCSubmenuToolStripMenuItem.Enabled = selected;
            copyPCToolStripMenuItem.Enabled        = selected;
            deleteSubmenuToolStripMenuItem.Enabled = selected;
            deleteToolStripMenuItem.Enabled        = selected;
            renameToolStripMenuItem.Enabled        = selected;
            renameSubmenuToolStripMenuItem.Enabled = selected;
            useToolStripMenuItem.Enabled           = selected;
            useSubmenuToolStripMenuItem.Enabled    = selected;
            changeToolStripMenuItem.Enabled        = selected;
            changeSubmenuToolStripMenuItem.Enabled = selected;
            selectAllToolStripMenuItem.Enabled     = !GridView && hasAny;
            sortToolStripMenuItem.Enabled          = hasMultiple;

            pasteAcquireToolStripMenuItem.Enabled = canPaste;
            pasteToolStripMenuItem.Enabled        = canPaste;

            nativeFormatToolStripMenuItem.Enabled = !GridView;

            UpdateUIPaletteList();
        }