Пример #1
0
        private void execMessageReceived(OscMessage message, string idFromAddress)
        {
            if (!int.TryParse(idFromAddress, out int id) || (id < 0))
            {
                string errorMessage = string.Format("Received macro execute command through OSC, but ID \"{0}\" for macro is invalid.",
                                                    id);
                LogDispatcher.I(LOG_TAG, errorMessage);
                return;
            }

            Macro macro = MacroDatabase.Instance.GetTById(id);

            if (macro == null)
            {
                string errorMessage = string.Format("Received macro execute command through OSC, but no macro found with ID #{0}.",
                                                    id);
                LogDispatcher.I(LOG_TAG, errorMessage);
                return;
            }

            string logMessage = string.Format("Executing macro #{0} ({1}) by OSC.",
                                              macro.ID,
                                              macro.Name);

            LogDispatcher.I(LOG_TAG, logMessage);
            InvokeHelper.Invoke(() => macro.Run());
        }
Пример #2
0
 private void UpdateStatus(string p)
 {
     InvokeHelper.Invoke(lblStatusText, delegate() {
         lblStatusText.Text = p;
         Application.DoEvents();
     });
 }
Пример #3
0
 void Character_ItemsChanged(object sender, EventArgs e)
 {
     if (this.InvokeRequired)
     {
         InvokeHelper.Invoke(this, "Character_ItemsChanged", new object[] { null, null });
         return;
     }
     LoadBuffsFromCharacter();
 }
Пример #4
0
        private static void AddConnection(IXenConnection connection)
        {
            connection.Cache.RegisterCollectionChanged <VM>(CollectionChangedWithInvoke);

            connection.XenObjectsUpdated += connection_XenObjectsUpdated;

            InvokeHelper.Invoke(delegate()
            {
                UpdateAll(connection.Cache.VMs);
            });
        }
Пример #5
0
 private void UpdateProgressbar(int progress)
 {
     InvokeHelper.Invoke(stateProgress, delegate() {
         int value = Math.Max(0, Math.Min(100, progress));
         value     = (int)(((float)584 / 100f) * value);
         if (stateProgress.Width != value)
         {
             stateProgress.Width = value;
             stateProgress.Invalidate();
         }
     });
 }
Пример #6
0
        private void UpdateProgressbar(int progress)
        {
            InvokeHelper.Invoke(stateProgress, delegate() {
                int value = Math.Max(0, Math.Min(100, progress));
                value     = (int)Math.Floor((540f / 100f) * value);
                if (stateProgress.Width != value)
                {
                    stateProgress.Width = value;
                    stateProgress.Invalidate();
                }

                if (TaskbarManager.IsPlatformSupported)
                {
                    mWin7Taskbar.SetProgressValue(value, 100);
                }
            });
        }
Пример #7
0
        private static Dictionary <string, string> GetOtherConfigCopy(IXenObject o)
        {
            Dictionary <string, string> output = new Dictionary <string, string>();

            InvokeHelper.Invoke(delegate()
            {
                Dictionary <String, String> otherConfig = Helpers.GetOtherConfig(o);

                if (otherConfig == null)
                {
                    output = null;
                }
                else
                {
                    output = new Dictionary <string, string>(otherConfig);
                }
            });
            return(output);
        }
Пример #8
0
        private static void AddConnection(IXenConnection connection)
        {
            connection.Cache.RegisterCollectionChanged <Host>(CollectionChangedWithInvoke);
            connection.Cache.RegisterCollectionChanged <XenAPI.Network>(CollectionChangedWithInvoke);
            connection.Cache.RegisterCollectionChanged <Pool>(CollectionChangedWithInvoke);
            connection.Cache.RegisterCollectionChanged <SR>(CollectionChangedWithInvoke);
            connection.Cache.RegisterCollectionChanged <VDI>(CollectionChangedWithInvoke);
            connection.Cache.RegisterCollectionChanged <VM>(CollectionChangedWithInvoke);

            connection.XenObjectsUpdated += connection_XenObjectsUpdated;

            InvokeHelper.Invoke(delegate()
            {
                UpdateAll(connection.Cache.Hosts);
                UpdateAll(connection.Cache.Networks);
                UpdateAll(connection.Cache.Pools);
                UpdateAll(connection.Cache.SRs);
                UpdateAll(connection.Cache.VDIs);
                UpdateAll(connection.Cache.VMs);

                UpdateEmptyFolders(connection);
            });
        }
Пример #9
0
        public void Delete()
        {
            String key = SearchPrefix + uuid;

            foreach (IXenConnection connection in ConnectionsManager.XenConnectionsCopy)
            {
                if (!connection.IsConnected)
                {
                    continue;
                }

                Session session = connection.DuplicateSession();
                foreach (Pool pool in connection.Cache.Pools)
                {
                    Pool.remove_from_gui_config(session, pool.opaque_ref, key);
                }
            }

            InvokeHelper.Invoke(delegate()
            {
                searches.Remove(uuid);
                OnSearchesChanged();
            });
        }
Пример #10
0
        static PropertyAccessors()
        {
            foreach (vm_power_state p in Enum.GetValues(typeof(vm_power_state)))
            {
                VM_power_state_i18n[FriendlyNameManager.GetFriendlyName(string.Format("Label-VM.power_state-{0}", p.ToString()))] = p;
            }
            foreach (SR.SRTypes type in Enum.GetValues(typeof(SR.SRTypes)))
            {
                SRType_i18n[SR.getFriendlyTypeName(type)] = type;
            }

            VirtualisationStatus_i18n[Messages.VIRTUALIZATION_STATE_VM_NOT_OPTIMIZED] = VM.VirtualisationStatus.NOT_INSTALLED;
            VirtualisationStatus_i18n[Messages.OUT_OF_DATE] = VM.VirtualisationStatus.PV_DRIVERS_OUT_OF_DATE;
            VirtualisationStatus_i18n[Messages.UNKNOWN]     = VM.VirtualisationStatus.UNKNOWN;
            VirtualisationStatus_i18n[Messages.VIRTUALIZATION_STATE_VM_IO_OPTIMIZED_ONLY] = VM.VirtualisationStatus.IO_DRIVERS_INSTALLED;
            VirtualisationStatus_i18n[Messages.VIRTUALIZATION_STATE_VM_MANAGEMENT_AGENT_INSTALLED_ONLY] = VM.VirtualisationStatus.MANAGEMENT_INSTALLED;
            VirtualisationStatus_i18n[Messages.VIRTUALIZATION_STATE_VM_OPTIMIZED] = VM.VirtualisationStatus.IO_DRIVERS_INSTALLED | VM.VirtualisationStatus.MANAGEMENT_INSTALLED;

            ObjectTypes_i18n[Messages.VMS] = ObjectTypes.VM;
            ObjectTypes_i18n[Messages.XENSERVER_TEMPLATES] = ObjectTypes.DefaultTemplate;
            ObjectTypes_i18n[Messages.CUSTOM_TEMPLATES]    = ObjectTypes.UserTemplate;
            ObjectTypes_i18n[Messages.POOLS]   = ObjectTypes.Pool;
            ObjectTypes_i18n[Messages.SERVERS] = ObjectTypes.Server;
            ObjectTypes_i18n[Messages.DISCONNECTED_SERVERS] = ObjectTypes.DisconnectedServer;
            ObjectTypes_i18n[Messages.LOCAL_SRS]            = ObjectTypes.LocalSR;
            ObjectTypes_i18n[Messages.REMOTE_SRS]           = ObjectTypes.RemoteSR;
            ObjectTypes_i18n[Messages.NETWORKS]             = ObjectTypes.Network;
            ObjectTypes_i18n[Messages.SNAPSHOTS]            = ObjectTypes.Snapshot;
            ObjectTypes_i18n[Messages.VIRTUAL_DISKS]        = ObjectTypes.VDI;
            ObjectTypes_i18n[Messages.FOLDERS]      = ObjectTypes.Folder;
            ObjectTypes_i18n[Messages.VM_APPLIANCE] = ObjectTypes.Appliance;


            foreach (VM.HA_Restart_Priority p in VM.GetAvailableRestartPriorities(null)) //CA-57600 - From Boston onwards, the HA restart priorities list contains Restart instead of AlwaysRestartHighPriority and AlwaysRestart
            {
                HARestartPriority_i18n[Helpers.RestartPriorityI18n(p)] = p;
            }

            // This one is used for grouping and filtering i18n
            PropertyNames_i18n[PropertyNames.description]           = Messages.DESCRIPTION;
            PropertyNames_i18n[PropertyNames.host]                  = Messages.SERVER;
            PropertyNames_i18n[PropertyNames.label]                 = Messages.NAME;
            PropertyNames_i18n[PropertyNames.uuid]                  = Messages.UUID;
            PropertyNames_i18n[PropertyNames.networks]              = Messages.NETWORK;
            PropertyNames_i18n[PropertyNames.os_name]               = Messages.OPERATING_SYSTEM;
            PropertyNames_i18n[PropertyNames.pool]                  = Messages.POOL;
            PropertyNames_i18n[PropertyNames.power_state]           = Messages.POWER_STATE;
            PropertyNames_i18n[PropertyNames.start_time]            = Messages.START_TIME;
            PropertyNames_i18n[PropertyNames.storage]               = Messages.SR;
            PropertyNames_i18n[PropertyNames.disks]                 = Messages.VIRTUAL_DISK;
            PropertyNames_i18n[PropertyNames.type]                  = Messages.TYPE;
            PropertyNames_i18n[PropertyNames.virtualisation_status] = Messages.TOOLS_STATUS;
            PropertyNames_i18n[PropertyNames.ha_restart_priority]   = Messages.HA_RESTART_PRIORITY;
            PropertyNames_i18n[PropertyNames.appliance]             = Messages.VM_APPLIANCE;
            PropertyNames_i18n[PropertyNames.tags]                  = Messages.TAGS;
            PropertyNames_i18n[PropertyNames.shared]                = Messages.SHARED;
            PropertyNames_i18n[PropertyNames.ha_enabled]            = Messages.HA;
            PropertyNames_i18n[PropertyNames.isNotFullyUpgraded]    = Messages.POOL_VERSIONS_LINK_TEXT_SHORT;
            PropertyNames_i18n[PropertyNames.ip_address]            = Messages.ADDRESS;
            PropertyNames_i18n[PropertyNames.vm]                         = Messages.VM;
            PropertyNames_i18n[PropertyNames.dockervm]                   = "Docker VM";
            PropertyNames_i18n[PropertyNames.read_caching_enabled]       = Messages.VM_READ_CACHING_ENABLED_SEARCH;
            PropertyNames_i18n_false[PropertyNames.read_caching_enabled] = Messages.VM_READ_CACHING_DISABLED_SEARCH;
            PropertyNames_i18n[PropertyNames.memory]                     = Messages.MEMORY;
            PropertyNames_i18n[PropertyNames.sr_type]                    = Messages.STORAGE_TYPE;
            PropertyNames_i18n[PropertyNames.folder]                     = Messages.PARENT_FOLDER;
            PropertyNames_i18n[PropertyNames.folders]                    = Messages.ANCESTOR_FOLDERS;
            PropertyNames_i18n[PropertyNames.has_custom_fields]          = Messages.HAS_CUSTOM_FIELDS;
            PropertyNames_i18n[PropertyNames.in_any_appliance]           = Messages.IN_ANY_APPLIANCE;
            PropertyNames_i18n[PropertyNames.vendor_device_state]        = Messages.WINDOWS_UPDATE_CAPABLE;
            PropertyNames_i18n_false[PropertyNames.vendor_device_state]  = Messages.WINDOWS_UPDATE_CAPABLE_NOT;

            VM_power_state_images[vm_power_state.Halted]    = Icons.PowerStateHalted;
            VM_power_state_images[vm_power_state.Paused]    = Icons.PowerStateSuspended;
            VM_power_state_images[vm_power_state.Running]   = Icons.PowerStateRunning;
            VM_power_state_images[vm_power_state.Suspended] = Icons.PowerStateSuspended;
            VM_power_state_images[vm_power_state.unknown]   = Icons.PowerStateUnknown;

            ObjectTypes_images[ObjectTypes.DefaultTemplate]                = Icons.Template;
            ObjectTypes_images[ObjectTypes.UserTemplate]                   = Icons.TemplateUser;
            ObjectTypes_images[ObjectTypes.Pool]                           = Icons.Pool;
            ObjectTypes_images[ObjectTypes.Server]                         = Icons.Host;
            ObjectTypes_images[ObjectTypes.DisconnectedServer]             = Icons.HostDisconnected;
            ObjectTypes_images[ObjectTypes.LocalSR]                        = Icons.Storage;
            ObjectTypes_images[ObjectTypes.RemoteSR]                       = Icons.Storage;
            ObjectTypes_images[ObjectTypes.LocalSR | ObjectTypes.RemoteSR] = Icons.Storage;
            ObjectTypes_images[ObjectTypes.VM]        = Icons.VM;
            ObjectTypes_images[ObjectTypes.Network]   = Icons.Network;
            ObjectTypes_images[ObjectTypes.Snapshot]  = Icons.Snapshot;
            ObjectTypes_images[ObjectTypes.VDI]       = Icons.VDI;
            ObjectTypes_images[ObjectTypes.Folder]    = Icons.Folder;
            ObjectTypes_images[ObjectTypes.Appliance] = Icons.VmAppliance;

            property_types.Add(PropertyNames.pool, typeof(Pool));
            property_types.Add(PropertyNames.host, typeof(Host));
            property_types.Add(PropertyNames.os_name, typeof(string));
            property_types.Add(PropertyNames.power_state, typeof(vm_power_state));
            property_types.Add(PropertyNames.virtualisation_status, typeof(VM.VirtualisationStatus));
            property_types.Add(PropertyNames.type, typeof(ObjectTypes));
            property_types.Add(PropertyNames.networks, typeof(XenAPI.Network));
            property_types.Add(PropertyNames.storage, typeof(SR));
            property_types.Add(PropertyNames.ha_restart_priority, typeof(VM.HA_Restart_Priority));
            property_types.Add(PropertyNames.read_caching_enabled, typeof(bool));
            property_types.Add(PropertyNames.appliance, typeof(VM_appliance));
            property_types.Add(PropertyNames.tags, typeof(string));
            property_types.Add(PropertyNames.has_custom_fields, typeof(bool));
            property_types.Add(PropertyNames.ip_address, typeof(ComparableAddress));
            property_types.Add(PropertyNames.vm, typeof(VM));
            property_types.Add(PropertyNames.sr_type, typeof(SR.SRTypes));
            property_types.Add(PropertyNames.folder, typeof(Folder));
            property_types.Add(PropertyNames.folders, typeof(Folder));
            property_types.Add(PropertyNames.in_any_appliance, typeof(bool));
            property_types.Add(PropertyNames.disks, typeof(VDI));

            properties[PropertyNames.os_name]               = o => o is VM vm && vm.is_a_real_vm() ? vm.GetOSName() : null;
            properties[PropertyNames.power_state]           = o => o is VM vm && vm.is_a_real_vm() ? (IComparable)vm.power_state : null;
            properties[PropertyNames.vendor_device_state]   = o => o is VM vm && vm.is_a_real_vm() ? (bool?)vm.WindowsUpdateCapable() : null;
            properties[PropertyNames.virtualisation_status] = o => o is VM vm && vm.is_a_real_vm() ? (IComparable)vm.GetVirtualisationStatus(out _) : null;
            properties[PropertyNames.start_time]            = o => o is VM vm && vm.is_a_real_vm() ? (DateTime?)vm.GetStartTime() : null;
            properties[PropertyNames.read_caching_enabled]  = o => o is VM vm && vm.is_a_real_vm() ? (bool?)vm.ReadCachingEnabled() : null;

            properties[PropertyNames.label]    = Helpers.GetName;
            properties[PropertyNames.pool]     = o => o == null ? null : Helpers.GetPool(o.Connection);
            properties[PropertyNames.host]     = HostProperty;
            properties[PropertyNames.vm]       = VMProperty;
            properties[PropertyNames.dockervm] = o => o is DockerContainer dc ? new ComparableList <VM> {
                dc.Parent
            } : new ComparableList <VM>();
            properties[PropertyNames.networks] = NetworksProperty;
            properties[PropertyNames.storage]  = StorageProperty;
            properties[PropertyNames.disks]    = DisksProperty;

            properties[PropertyNames.has_custom_fields] = delegate(IXenObject o)
            {
                // this needs to be tidied up so that CustomFields calls don't require the event thread.

                bool ret = false;
                InvokeHelper.Invoke(delegate { ret = CustomFieldsManager.HasCustomFields(o); });
                return(ret);
            };

            properties[PropertyNames.memory] = o =>
            {
                if (o is VM vm && vm.is_a_real_vm() && vm.Connection != null)
                {
                    var metrics = vm.Connection.Resolve(vm.metrics);
                    if (metrics != null)
                    {
                        return(metrics.memory_actual);
                    }
                }
                return(null);
            };

            properties[PropertyNames.ha_restart_priority] = delegate(IXenObject o)
            {
                if (o is VM vm && vm.is_a_real_vm())
                {
                    Pool pool = Helpers.GetPool(vm.Connection);
                    if (pool != null && pool.ha_enabled)
                    {
                        return(vm.HaPriorityIsRestart() ? VM.HA_Restart_Priority.Restart : vm.HARestartPriority());
                    }

                    // CA-57600 - From Boston onwards, the HA_restart_priority enum contains Restart instead of
                    // AlwaysRestartHighPriority and AlwaysRestart. When searching in a pre-Boston pool for VMs
                    // with HA_restart_priority.Restart, the search will return VMs with HA_restart_priority
                    // AlwaysRestartHighPriority or AlwaysRestart
                }
                return(null);
            };

            properties[PropertyNames.appliance] = delegate(IXenObject o)
            {
                if (o is VM_appliance app)
                {
                    return(app);
                }

                if (o is VM vm && vm.is_a_real_vm() && vm.Connection != null)
                {
                    return(vm.Connection.Resolve(vm.appliance));
                }

                return(null);
            };

            properties[PropertyNames.in_any_appliance] = delegate(IXenObject o)
            {
                if (o is VM_appliance)
                {
                    return(true);
                }
                if (o is VM vm && vm.is_a_real_vm() && vm.Connection != null)
                {
                    return(vm.Connection.Resolve(vm.appliance) != null);
                }
                return(null);
            };

            properties[PropertyNames.connection_hostname] = ConnectionHostnameProperty;
            properties[PropertyNames.cpuText]             = CPUTextProperty;
            properties[PropertyNames.cpuValue]            = CPUValueProperty;
            properties[PropertyNames.description]         = DescriptionProperty;
            properties[PropertyNames.diskText]            = DiskTextProperty;
            properties[PropertyNames.folder]             = Folders.GetFolder;
            properties[PropertyNames.folders]            = Folders.GetAncestorFolders;
            properties[PropertyNames.haText]             = HATextProperty;
            properties[PropertyNames.ha_enabled]         = o => o is Pool pool ? (IComparable)pool.ha_enabled : null;
            properties[PropertyNames.isNotFullyUpgraded] = o => o is Pool pool ? (IComparable) !pool.IsPoolFullyUpgraded() : null;
            properties[PropertyNames.ip_address]         = IPAddressProperty;
            properties[PropertyNames.license]            = LicenseProperty;
            properties[PropertyNames.memoryText]         = MemoryTextProperty;
            properties[PropertyNames.memoryValue]        = MemoryValueProperty;
            properties[PropertyNames.memoryRank]         = MemoryRankProperty;
            properties[PropertyNames.networkText]        = NetworkTextProperty;
            properties[PropertyNames.shared]             = SharedProperty;
            properties[PropertyNames.size]    = o => o is VDI vdi ? (IComparable)vdi.virtual_size : null;
            properties[PropertyNames.sr_type] = o => o is SR sr ? (IComparable)sr.GetSRType(false) : null;
            properties[PropertyNames.tags]    = Tags.GetTagList;
            properties[PropertyNames.type]    = TypeProperty;
            properties[PropertyNames.uptime]  = UptimeProperty;
            properties[PropertyNames.uuid]    = UUIDProperty;

            column_sort_by[ColumnNames.name]    = PropertyNames.label;
            column_sort_by[ColumnNames.cpu]     = PropertyNames.cpuValue;
            column_sort_by[ColumnNames.memory]  = PropertyNames.memoryValue;
            column_sort_by[ColumnNames.disks]   = PropertyNames.diskText;
            column_sort_by[ColumnNames.network] = PropertyNames.networkText;
            column_sort_by[ColumnNames.ha]      = PropertyNames.haText;
            column_sort_by[ColumnNames.ip]      = PropertyNames.ip_address;
            column_sort_by[ColumnNames.uptime]  = PropertyNames.uptime;
        }
Пример #11
0
 private void mWorker_ProgressChanged(object sender, ProgressChangedEventArgs e)
 {
     InvokeHelper.Invoke(progressLoading, delegate() { progressLoading.Value = e.ProgressPercentage; });
 }
Пример #12
0
        private void RebuildItemList()
        {
            if (this.InvokeRequired)
            {
                InvokeHelper.Invoke(this, "RebuildItemList", null);
                return;
            }
            panelItems.SuspendLayout();

            ////Replaced this...
            //while (panelItems.Controls.Count < this.ItemCalculations.Length)
            //	panelItems.Controls.Add(new ItemSelectorItem());
            //while (panelItems.Controls.Count > this.ItemCalculations.Length)
            //	panelItems.Controls.RemoveAt(panelItems.Controls.Count - 1);

            ////...with this, so as not to constantly create and remove lots of controls
            int currentItemLength = panelItems.Controls.Count;
            int targetItemLength  = this.ItemCalculations.Length;

            if (currentItemLength < targetItemLength)
            {
                int itemSelectorsToCreate = targetItemLength - _itemSelectorItems.Count;
                for (int i = 0; i < itemSelectorsToCreate; i++)
                {
                    _itemSelectorItems.Add(new ItemSelectorItem());
                }
                for (int i = currentItemLength; i < targetItemLength; i++)
                {
                    panelItems.Controls.Add(_itemSelectorItems[i]);
                }
            }
            else if (currentItemLength > targetItemLength)
            {
                for (int i = currentItemLength; i > targetItemLength; i--)
                {
                    panelItems.Controls.RemoveAt(i - 1);
                }
            }

            float maxRating = 0;

            for (int i = 0; i < this.ItemCalculations.Length; i++)
            {
                ItemSelectorItem          ctrl = panelItems.Controls[i] as ItemSelectorItem;
                ComparisonCalculationBase calc = this.ItemCalculations[i];
                calc.Equipped        = calc.Item == _button.SelectedItem;
                ctrl.ItemCalculation = calc;
                ctrl.Sort            = this.Sort;
                ctrl.HideToolTip();
                bool visible = string.IsNullOrEmpty(this.toolStripTextBoxFilter.Text) || calc.Name.ToLower().Contains(this.toolStripTextBoxFilter.Text.ToLower());
                ctrl.Visible = visible;
                if (visible)
                {
                    float calcRating;
                    if (Sort == ComparisonGraph.ComparisonSort.Overall || this.Sort == ComparisonGraph.ComparisonSort.Alphabetical)
                    {
                        calcRating = calc.OverallPoints;
                    }
                    else
                    {
                        calcRating = calc.SubPoints[(int)Sort];
                    }
                    maxRating = Math.Max(maxRating, calcRating);
                }
            }
            panelItems.ResumeLayout(true);
            foreach (ItemSelectorItem ctrl in panelItems.Controls)
            {
                ctrl.MaxRating = maxRating;
            }
        }