public MainShellViewModel(IResultFactory resultFactory,
                                  IEventAggregator eventAggregator,
                                  MainMenuViewModel mainMenuViewModel,
                                  MainToolBarTrayViewModel mainToolBarViewModel,
                                  IEnumerable <PanelViewModel> panels,
                                  ISettingsManager settingsManager,
                                  IFileSystem fileSystem,
                                  IPersistanceManager persistanceManager,
                                  IPaths paths,
                                  IPortable portable
                                  )
            : base(resultFactory)
        {
            this.eventAggregator = eventAggregator;
            eventAggregator.Subscribe(this);

            this.persistanceManager = persistanceManager;
            this.settingsManager    = settingsManager;
            this.fileSystem         = fileSystem;
            this.paths = paths;

            Menu        = mainMenuViewModel;
            ToolBarTray = mainToolBarViewModel;

            Scripts = new BindableCollection <MonitorViewModel>();
            Tools   = new BindableCollection <PanelViewModel>(panels);

            mainMenuViewModel.NewProfile();
        }
示例#2
0
        public MainShellViewModel(IResultFactory resultFactory,
                                  IEventAggregator eventAggregator,
                                  IPersistanceManager persistanceManager,
                                  ISettingsManager settingsManager,
                                  MainMenuViewModel mainMenuViewModel,
                                  IEnumerable <PanelViewModel> panels,
                                  IFileSystem fileSystem,
                                  ScriptDialogStrategy scriptDialogStrategy,
                                  IPaths paths,
                                  IParser parser,
                                  IPortable portable
                                  )
            : base(resultFactory)
        {
            this.eventAggregator = eventAggregator;
            eventAggregator.Subscribe(this);
            this.persistanceManager   = persistanceManager;
            this.settingsManager      = settingsManager;
            this.fileSystem           = fileSystem;
            this.scriptDialogStrategy = scriptDialogStrategy;
            this.paths  = paths;
            this.parser = parser;

            Scripts = new BindableCollection <ScriptEditorViewModel>();
            Tools   = new BindableCollection <PanelViewModel>(panels);

            Menu         = mainMenuViewModel;
            Menu.Plugins =
                settingsManager.ListConfigurablePluginSettings().Select(ps => new PluginSettingsMenuViewModel(ps));
            Menu.HelpFiles =
                settingsManager.ListPluginSettingsWithHelpFile().Select(ps => new PluginHelpFileViewModel(ps)).ToList();
            Menu.Views = Tools;

            DisplayName = string.Format("FreePIE - Programmable Input Emulator{0}", portable.IsPortable ? " (Portable mode)" : null);
        }
        public MainShellViewModel(IResultFactory resultFactory,
                                  IEventAggregator eventAggregator,
                                  IPersistanceManager persistanceManager,
                                  ISettingsManager settingsManager,
                                  MainMenuViewModel mainMenuViewModel,
                                  MainToolBarViewModel mainToolBarViewModel,
                                  IEnumerable <PanelViewModel> panels,
                                  IFileSystem fileSystem,
                                  ProfileDialogStrategy profileDialogStrategy,
                                  IPaths paths,
                                  IParser parser,
                                  IPortable portable
                                  )
            : base(resultFactory)
        {
            this.eventAggregator = eventAggregator;
            this.eventAggregator.Subscribe(this);
            this.persistanceManager    = persistanceManager;
            this.settingsManager       = settingsManager;
            this.fileSystem            = fileSystem;
            this.profileDialogStrategy = profileDialogStrategy;
            this.paths  = paths;
            this.parser = parser;

            Profiles = new BindableCollection <MonitorViewModel>();
            Tools    = new BindableCollection <PanelViewModel>(panels);

            Menu       = mainMenuViewModel;
            Menu.Views = Tools;
            ToolBar    = mainToolBarViewModel;

            DisplayName = "CockpitBuilder";
        }
示例#4
0
        /// <exception cref="System.IO.IOException"></exception>
        private IClassDefinition CreateNestedClassDef(IPortable portable, ClassDefinitionBuilder
                                                      nestedBuilder)
        {
            var writer = new ClassDefinitionWriter(context, nestedBuilder);

            portable.WritePortable(writer);
            return(context.RegisterClassDefinition(nestedBuilder.Build()));
        }
示例#5
0
        private void btnTake_Click(object sender, RoutedEventArgs e)
        {
            try
            {
                System.Media.SoundPlayer take = new System.Media.SoundPlayer();
                take.SoundLocation = "Music/Take.wav";
                if (lbItems.SelectedItem != null)
                {
                    string type = lbItems.SelectedItem.GetType().ToString();
                    switch (type)
                    {
                    case "TextBasedAdventureGame.HidingPlace":
                        MessageBox.Show("You cannot add that item to your inventory!");
                        break;

                    case "TextBasedAdventureGame.PortableHidingPlace":
                        IPortable portableHidingPlace = (PortableHidingPlace)lbItems.SelectedItem;
                        if (player.AddInventoryItem(portableHidingPlace))
                        {
                            player.Location.Items.RemoveAt(lbItems.SelectedIndex);
                            take.Play();
                        }
                        else
                        {
                            MessageBox.Show("Your inventory is full! You must drop an item.");
                        }
                        break;

                    case "TextBasedAdventureGame.InventoryItem":
                        IPortable inventoryItem = (InventoryItem)lbItems.SelectedItem;
                        if (player.AddInventoryItem(inventoryItem))
                        {
                            player.Location.Items.RemoveAt(lbItems.SelectedIndex);
                            take.Play();
                        }
                        else
                        {
                            MessageBox.Show("Your inventory is full! You must drop an item.");
                        }
                        if (lbItems.SelectedItem.ToString() == "Worms")
                        {
                            MessageBox.Show("Why would you want to pick that up?!", "Eww!");
                        }
                        break;
                    }
                    UpdateDisplay();
                }
                else
                {
                    MessageBox.Show("You must select an item.");
                }
            }
            catch (Exception exc)
            {
                MessageBox.Show(exc.Message);
            }
        }
 /// <exception cref="System.IO.IOException" />
 public IClassDefinition LookupOrRegisterClassDefinition(IPortable p)
 {
     var portableVersion = PortableVersionHelper.GetVersion(p, _version);
     var cd = LookupClassDefinition(p.GetFactoryId(), p.GetClassId(), portableVersion);
     if (cd == null)
     {
         var writer = new ClassDefinitionWriter(this, p.GetFactoryId(), p.GetClassId(), portableVersion);
         p.WritePortable(writer);
         cd = writer.RegisterAndGet();
     }
     return cd;
 }
示例#7
0
        /// <exception cref="System.IO.IOException" />
        public IClassDefinition LookupOrRegisterClassDefinition(IPortable p)
        {
            var portableVersion = PortableVersionHelper.GetVersion(p, _version);
            var cd = LookupClassDefinition(p.GetFactoryId(), p.GetClassId(), portableVersion);

            if (cd == null)
            {
                var writer = new ClassDefinitionWriter(this, p.GetFactoryId(), p.GetClassId(), portableVersion);
                p.WritePortable(writer);
                cd = writer.RegisterAndGet();
            }
            return(cd);
        }
示例#8
0
 public SettingWindowViewModel(Updater updater, IPortable portable)
 {
     _updater  = updater;
     _portable = portable;
     Settings  = Settings.Instance;
     Settings.PropertyChanged += (s, e) =>
     {
         if (e.PropertyName == nameof(Settings.ActivateTimes))
         {
             OnPropertyChanged(nameof(ActivatedTimes));
         }
     };
 }
示例#9
0
        /// <exception cref="System.IO.IOException"></exception>
        public void WritePortable(string fieldName, IPortable portable)
        {
            if (portable == null)
            {
                throw new HazelcastSerializationException("Cannot write null portable without explicitly "
                                                          + "registering class definition!");
            }
            int version = PortableVersionHelper.GetVersion(portable, context.GetVersion());
            IClassDefinition nestedClassDef = CreateNestedClassDef(portable, new ClassDefinitionBuilder
                                                                       (portable.GetFactoryId(), portable.GetClassId(), version));

            builder.AddPortableField(fieldName, nestedClassDef);
        }
示例#10
0
 public void RemoveInventoryItem(IPortable item)
 {
     try
     {
         //remove it from the list
         Inventory.Remove(item);
         Calc();
     }
     catch (Exception exc)
     {
         MessageBox.Show(exc.Message);
     }
 }
 public static int GetVersion(IPortable portable, int defaultVersion)
 {
     var version = defaultVersion;
     if (portable is IVersionedPortable)
     {
         var versionedPortable = (IVersionedPortable) portable;
         version = versionedPortable.GetClassVersion();
         if (version < 0)
         {
             throw new ArgumentException("Version cannot be negative!");
         }
     }
     return version;
 }
示例#12
0
 public SettingWindowViewModel(IPortable portable)
 {
     _updater  = new Updater(Wox.Properties.Settings.Default.GithubRepo);;
     _portable = portable;
     Settings  = Settings.Instance;
     Settings.PropertyChanged += (s, e) =>
     {
         if (e.PropertyName == nameof(Settings.ActivateTimes))
         {
             OnPropertyChanged(nameof(ActivatedTimes));
         }
     };
     AutoUpdates();
 }
        public static int GetVersion(IPortable portable, int defaultVersion)
        {
            var version = defaultVersion;

            if (portable is IVersionedPortable versionedPortable)
            {
                version = versionedPortable.ClassVersion;
                if (version < 0)
                {
                    throw new ArgumentException("Version cannot be negative!");
                }
            }
            return(version);
        }
示例#14
0
 public bool AddInventoryItem(IPortable itm)
 {
     //Calc();
     // Checking if there is space in the inventory
     if (inventorySize >= MaxInventory)
     {
         return(false);
     }
     else
     {
         Inventory.Add(itm);
         return(true);
     }
 }
示例#15
0
 public SettingWindowViewModel(Updater updater, IPortable portable)
 {
     _updater  = updater;
     _portable = portable;
     _storage  = new FlowLauncherJsonStorage <Settings>();
     Settings  = _storage.Load();
     Settings.PropertyChanged += (s, e) =>
     {
         if (e.PropertyName == nameof(Settings.ActivateTimes))
         {
             OnPropertyChanged(nameof(ActivatedTimes));
         }
     };
 }
示例#16
0
        /// <exception cref="System.IO.IOException" />
        public virtual void WritePortable(string fieldName, IPortable portable)
        {
            var fd     = SetPosition(fieldName, FieldType.Portable);
            var isNull = portable == null;

            _out.WriteBoolean(isNull);
            _out.WriteInt(fd.FactoryId);
            _out.WriteInt(fd.ClassId);
            if (!isNull)
            {
                CheckPortableAttributes(fd, portable);
                _serializer.WriteInternal(_out, portable);
            }
        }
示例#17
0
 private static void CheckPortableAttributes(IFieldDefinition fd, IPortable portable)
 {
     if (fd.FactoryId != portable.FactoryId)
     {
         throw new SerializationException(
                   "Wrong Portable type! Generic portable types are not supported! " + " Expected factory-id: " +
                   fd.FactoryId + ", Actual factory-id: " + portable.FactoryId);
     }
     if (fd.ClassId != portable.ClassId)
     {
         throw new SerializationException(
                   "Wrong Portable type! Generic portable types are not supported! " + "Expected class-id: " +
                   fd.ClassId + ", Actual class-id: " + portable.ClassId);
     }
 }
 private void CheckPortableAttributes(IFieldDefinition fd, IPortable portable)
 {
     if (fd.GetFactoryId() != portable.GetFactoryId())
     {
         throw new HazelcastSerializationException(
                   "Wrong Portable type! Generic portable types are not supported! " + " Expected factory-id: " +
                   fd.GetFactoryId() + ", Actual factory-id: " + portable.GetFactoryId());
     }
     if (fd.GetClassId() != portable.GetClassId())
     {
         throw new HazelcastSerializationException(
                   "Wrong Portable type! Generic portable types are not supported! " + "Expected class-id: " +
                   fd.GetClassId() + ", Actual class-id: " + portable.GetClassId());
     }
 }
示例#19
0
        /// <exception cref="System.IO.IOException"/>
        public virtual IPortable[] ReadPortableArray(string fieldName)
        {
            var currentPos = _in.Position();

            try
            {
                var fd = Cd.GetField(fieldName);
                if (fd == null)
                {
                    throw ThrowUnknownFieldException(fieldName);
                }
                if (fd.GetFieldType() != FieldType.PortableArray)
                {
                    throw new HazelcastSerializationException("Not a Portable array field: " + fieldName);
                }
                var pos = ReadPosition(fd);
                _in.Position(pos);
                var len       = _in.ReadInt();
                var factoryId = _in.ReadInt();
                var classId   = _in.ReadInt();

                if (len == Bits.NullArray)
                {
                    return(null);
                }

                CheckFactoryAndClass(fd, factoryId, classId);
                var portables = new IPortable[len];
                if (len > 0)
                {
                    var offset = _in.Position();
                    for (var i = 0; i < len; i++)
                    {
                        var start = _in.ReadInt(offset + i * Bits.IntSizeInBytes);
                        _in.Position(start);
                        portables[i] = Serializer.ReadAndInitialize(_in, factoryId, classId);
                    }
                }
                return(portables);
            }
            finally
            {
                _in.Position(currentPos);
            }
        }
示例#20
0
        /// <exception cref="System.IO.IOException"/>
        public virtual IPortable[] ReadPortableArray(string fieldName)
        {
            int currentPos = @in.Position();

            try
            {
                IFieldDefinition fd = cd.GetField(fieldName);
                if (fd == null)
                {
                    throw ThrowUnknownFieldException(fieldName);
                }
                if (fd.GetFieldType() != FieldType.PortableArray)
                {
                    throw new HazelcastSerializationException("Not a Portable array field: " + fieldName);
                }
                int pos = ReadPosition(fd);
                @in.Position(pos);
                int len       = @in.ReadInt();
                int factoryId = @in.ReadInt();
                int classId   = @in.ReadInt();

                if (len == Bits.NullArray)
                {
                    return(null);
                }

                CheckFactoryAndClass(fd, factoryId, classId);
                IPortable[] portables = new IPortable[len];
                if (len > 0)
                {
                    int offset = @in.Position();
                    for (int i = 0; i < len; i++)
                    {
                        int start = @in.ReadInt(offset + i * Bits.IntSizeInBytes);
                        @in.Position(start);
                        portables[i] = serializer.ReadAndInitialize(@in, factoryId, classId);
                    }
                }
                return(portables);
            }
            finally
            {
                @in.Position(currentPos);
            }
        }
示例#21
0
 public bool AddInventoryItem(IPortable item)
 {
     //check to make sure inventory size is not full
     if (inventorySize != MaxInventory)
     {
         //check that item will fit in inventory
         if ((inventorySize += item.Size) <= MaxInventory)
         {
             Inventory.Add(item);
             Calc();
             return(true);
         }
         else
         {
             return(false);
         }
     }
     else
     {
         return(false);
     }
 }
示例#22
0
        /// <exception cref="System.IO.IOException"></exception>
        public void WritePortableArray(string fieldName, IPortable[] portables)
        {
            if (portables == null || portables.Length == 0)
            {
                throw new HazelcastSerializationException("Cannot write null portable array without explicitly "
                                                          + "registering class definition!");
            }
            IPortable p       = portables[0];
            int       classId = p.GetClassId();

            for (int i = 1; i < portables.Length; i++)
            {
                if (portables[i].GetClassId() != classId)
                {
                    throw new ArgumentException("Detected different class-ids in portable array!");
                }
            }
            int version = PortableVersionHelper.GetVersion(p, context.GetVersion());
            IClassDefinition nestedClassDef = CreateNestedClassDef(p, new ClassDefinitionBuilder
                                                                       (p.GetFactoryId(), classId, version));

            builder.AddPortableArrayField(fieldName, nestedClassDef);
        }
示例#23
0
        private void btnDrop_Click(object sender, RoutedEventArgs e)
        {
            try
            {
                if (lbInventory.SelectedItem != null)
                {
                    string type = lbInventory.SelectedItem.GetType().ToString();
                    switch (type)
                    {
                    case "TextBasedAdventureGame.PortableHidingPlace":
                        IPortable portableHidingPlace = (PortableHidingPlace)lbInventory.SelectedItem;
                        player.RemoveInventoryItem(portableHidingPlace);
                        player.Location.Items.Add((GameObject)portableHidingPlace);
                        break;

                    case "TextBasedAdventureGame.InventoryItem":
                        IPortable inventoryItem = (InventoryItem)lbInventory.SelectedItem;
                        player.RemoveInventoryItem(inventoryItem);
                        player.Location.Items.Add((GameObject)inventoryItem);
                        break;
                    }
                    UpdateDisplay();
                    System.Media.SoundPlayer drop = new System.Media.SoundPlayer();
                    drop.SoundLocation = "Music/Drop.wav";
                    drop.Play();
                }
                else
                {
                    MessageBox.Show("You must select an item.");
                }
            }
            catch (Exception exc)
            {
                MessageBox.Show(exc.Message);
            }
        }
 /// <exception cref="System.IO.IOException"></exception>
 private IClassDefinition CreateNestedClassDef(IPortable portable, ClassDefinitionBuilder
     nestedBuilder)
 {
     var writer = new ClassDefinitionWriter(_context, nestedBuilder);
     portable.WritePortable(writer);
     return _context.RegisterClassDefinition(nestedBuilder.Build());
 }
 public void ReadData(IObjectDataInput input)
 {
     ds       = input.ReadObject <IIdentifiedDataSerializable>();
     portable = input.ReadObject <IPortable>();
     ds2      = input.ReadObject <IIdentifiedDataSerializable>();
 }
 public ComplexDataSerializable(IPortable portable, IIdentifiedDataSerializable ds, IIdentifiedDataSerializable ds2)
 {
     this.portable = portable;
     this.ds       = ds;
     this.ds2      = ds2;
 }
示例#27
0
        private static void AssertRepeatedSerialisationGivesSameByteArrays(SerializationService ss, IPortable p)
        {
            var data1 = ss.ToData(p);

            for (var k = 0; k < 100; k++)
            {
                var data2 = ss.ToData(p);
                Assert.AreEqual(data1, data2);
            }
        }
 private void CheckPortableAttributes(IFieldDefinition fd, IPortable portable)
 {
     if (fd.GetFactoryId() != portable.GetFactoryId())
     {
         throw new HazelcastSerializationException(
             "Wrong Portable type! Generic portable types are not supported! " + " Expected factory-id: " +
             fd.GetFactoryId() + ", Actual factory-id: " + portable.GetFactoryId());
     }
     if (fd.GetClassId() != portable.GetClassId())
     {
         throw new HazelcastSerializationException(
             "Wrong Portable type! Generic portable types are not supported! " + "Expected class-id: " +
             fd.GetClassId() + ", Actual class-id: " + portable.GetClassId());
     }
 }
示例#29
0
 public void RemoveInventoryItem(IPortable item)
 {
     Inventory.Remove(item);
     Calc();
 }
 public TestObject1(IPortable[] p)
 {
     portables = p;
 }
 public ComplexDataSerializable(IPortable portable, IIdentifiedDataSerializable ds, IIdentifiedDataSerializable ds2)
 {
     _portable = portable;
     _ds       = ds;
     _ds2      = ds2;
 }
示例#32
0
 /// <summary>
 /// Checks if machine is in scope.
 /// </summary>
 /// <param name="portable">The portable.</param>
 /// <returns><c>true</c> if XXXX, <c>false</c> otherwise.</returns>
 public static bool CheckIfMachineIsInScope(this IPortable portable) =>
 portable.MachineScopeId == ConfigurationHelpers.MachineGuid.Value;
示例#33
0
 /// <summary>
 /// Gets the machine identifier.
 /// </summary>
 /// <param name="_">The throw away parameter.</param>
 /// <returns>The Machine Guid.</returns>
 public static Guid GetMachineId(this IPortable _) => ConfigurationHelpers.MachineGuid.Value;
 public ComplexDataSerializable(IPortable portable, IDataSerializable ds, IDataSerializable ds2)
 {
     this.portable = portable;
     this.ds = ds;
     this.ds2 = ds2;
 }
 /// <exception cref="System.IO.IOException"></exception>
 public void WritePortable(string fieldName, IPortable portable)
 {
     if (portable == null)
     {
         throw new HazelcastSerializationException("Cannot write null portable without explicitly "
                                                   + "registering class definition!");
     }
     var version = PortableVersionHelper.GetVersion(portable, _context.GetVersion());
     var nestedClassDef = CreateNestedClassDef(portable, new ClassDefinitionBuilder
         (portable.GetFactoryId(), portable.GetClassId(), version));
     _builder.AddPortableField(fieldName, nestedClassDef);
 }
 /// <exception cref="System.IO.IOException"></exception>
 public void WritePortableArray(string fieldName, IPortable[] portables)
 {
     if (portables == null || portables.Length == 0)
     {
         throw new HazelcastSerializationException("Cannot write null portable array without explicitly "
                                                   + "registering class definition!");
     }
     var p = portables[0];
     var classId = p.GetClassId();
     for (var i = 1; i < portables.Length; i++)
     {
         if (portables[i].GetClassId() != classId)
         {
             throw new ArgumentException("Detected different class-ids in portable array!");
         }
     }
     var version = PortableVersionHelper.GetVersion(p, _context.GetVersion());
     var nestedClassDef = CreateNestedClassDef(p, new ClassDefinitionBuilder
         (p.GetFactoryId(), classId, version));
     _builder.AddPortableArrayField(fieldName, nestedClassDef);
 }
 /// <exception cref="System.IO.IOException" />
 public virtual void WritePortable(string fieldName, IPortable portable)
 {
     var fd = SetPosition(fieldName, FieldType.Portable);
     var isNull = portable == null;
     @out.WriteBoolean(isNull);
     @out.WriteInt(fd.GetFactoryId());
     @out.WriteInt(fd.GetClassId());
     if (!isNull)
     {
         CheckPortableAttributes(fd, portable);
         serializer.WriteInternal(@out, portable);
     }
 }
 private static void AssertRepeatedSerialisationGivesSameByteArrays(ISerializationService ss, IPortable p)
 {
     var data1 = ss.ToData(p);
     for (var k = 0; k < 100; k++)
     {
         var data2 = ss.ToData(p);
         Assert.AreEqual(data1, data2);
     }
 }
 /// <exception cref="System.IO.IOException" />
 public virtual void WritePortableArray(string fieldName, IPortable[] portables)
 {
     var fd = SetPosition(fieldName, FieldType.PortableArray);
     var len = portables == null ? Bits.NullArray : portables.Length;
     @out.WriteInt(len);
     @out.WriteInt(fd.GetFactoryId());
     @out.WriteInt(fd.GetClassId());
     if (len > 0)
     {
         var offset = @out.Position();
         @out.WriteZeroBytes(len*4);
         for (var i = 0; i < portables.Length; i++)
         {
             var portable = portables[i];
             CheckPortableAttributes(fd, portable);
             var position = @out.Position();
             @out.WriteInt(offset + i*Bits.IntSizeInBytes, position);
             serializer.WriteInternal(@out, portable);
         }
     }
 }
 public void ReadData(IObjectDataInput input)
 {
     ds = input.ReadObject<IDataSerializable>();
     portable = input.ReadObject<IPortable>();
     ds2 = input.ReadObject<IDataSerializable>();
 }
示例#41
0
 public PathsProvider(IPortable portable, Func <PortablePaths> portablePaths, Func <UacCompliantPaths> uacPaths)
 {
     this.portable      = portable;
     this.portablePaths = portablePaths;
     this.uacPaths      = uacPaths;
 }