Exemplo n.º 1
0
        private void CreateButton(IoItem item)
        {
            var settings = SharedSettings.GetInstance();

            var content = new WrapPanel();

            content.Children.Add(new Image {
                Source = item.GetSmallIcon(), Height = 16, Width = 16, Margin = new Thickness(2)
            });
            content.Children.Add(new TextBlock {
                Text = item.Name, Margin = new Thickness(2), TextTrimming = TextTrimming.CharacterEllipsis, Width = 70
            });
            var btnProgram = new Button
            {
                Content = content,
                Tag     = item,
                HorizontalContentAlignment = HorizontalAlignment.Left,
                Foreground = settings.UiForeBrush,
                Background = settings.UiGradientBrushV,
                Margin     = new Thickness(5),
                Width      = 100,
                ToolTip    = item.Name
            };

            btnProgram.Click += BtnProgramClick;
            pnlPrograms.Children.Add(btnProgram);
        }
Exemplo n.º 2
0
        private HpcLibSettings()
        {
            string username = Environment.GetEnvironmentVariable("username");

            _sharedSettings = SharedSettings.Load(SettingsFileName);
            _localSettings  = LocalSettings.Load(LocalSettingsFileName, username);
        }
Exemplo n.º 3
0
            public static SharedSettings Load(string filename)
            {
                try
                {
                    string asmPath      = Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location);
                    string settingsPath = Path.Combine(asmPath, filename);
                    System.Xml.Serialization.XmlSerializer serializer = new System.Xml.Serialization.XmlSerializer(typeof(SharedSettings));

                    using (TextReader reader = File.OpenText(settingsPath))
                    {
                        SharedSettings result = (SharedSettings)serializer.Deserialize(reader);
                        result.KnownClusters = new Dictionary <string, ClusterInfo>(StringComparer.CurrentCultureIgnoreCase);
                        result.DummyField.ForEach(node => result.KnownClusters.Add(node.Name, node));

                        return(result);
                    }
                }
                catch (Exception e)
                {
                    Console.Error.WriteLine("Problem loading " + filename);
                    Console.Error.WriteLine(e.Message);
                    SharedSettings result = new SharedSettings();
                    result.KnownClusters = new Dictionary <string, ClusterInfo>();
                    return(result);
                }
            }
Exemplo n.º 4
0
 private static IHelper CreateHelper(Guid id, bool managed, SharedSettings s)
 {
     if (managed)
     {
         if (s.UseV2)
         {
             return(new ManagedCoder2(id));
         }
         else
         {
             return(new ManagedCoder(id));
         }
     }
     else
     {
         if (s.UseV2)
         {
             return(new NativeCoder2(id));
         }
         else
         {
             return(new NativeCoder(id));
         }
     }
 }
        private void RotateTargets()
        {
            var   boundsQConfig  = GetBoundsQConfig();
            float rotationAmount = InputDeviceManager.Get.MouseDelta.x * SharedSettings.RotationSensitivity;

            EditorUndoEx.RecordObjectTransforms(_targetParents);
            foreach (var grabTarget in _grabTargets)
            {
                if (grabTarget == null)
                {
                    continue;
                }

                OOBB targetOOBB = ObjectBounds.CalcHierarchyWorldOOBB(grabTarget.GameObject, boundsQConfig);
                if (!targetOOBB.IsValid)
                {
                    continue;
                }

                var layerGrabSettings = SharedSettings.GetLayerGrabSettings(grabTarget.GameObject.layer);
                if (layerGrabSettings.IsActive)
                {
                    Quaternion rotation = Quaternion.AngleAxis(rotationAmount, layerGrabSettings.AlignAxis ? grabTarget.SittingPlane.normal : Vector3.up);
                    grabTarget.Transform.RotateAroundPivot(rotation, targetOOBB.Center);
                }
                else
                {
                    Quaternion rotation = Quaternion.AngleAxis(rotationAmount, SharedSettings.AlignAxis ? grabTarget.SittingPlane.normal : Vector3.up);
                    grabTarget.Transform.RotateAroundPivot(rotation, targetOOBB.Center);
                }
            }

            CalculateGrabTargetsAnchorVectors();
        }
Exemplo n.º 6
0
 public ShutdownMenu()
 {
     InitializeComponent();
     settings = SharedSettings.GetInstance();
     settings.ColorsUpdated += new System.EventHandler(SettingsColorsUpdated);
     ColorComponents();
 }
Exemplo n.º 7
0
 public ShutdownMenu()
 {
     InitializeComponent();
     settings = SharedSettings.GetInstance();
     settings.ColorsUpdated += new System.EventHandler(SettingsColorsUpdated);
     ColorComponents();
 }
Exemplo n.º 8
0
        private void CreateButton(IoItem location)
        {
            var settings = SharedSettings.GetInstance();

            var content = new WrapPanel();

            content.Children.Add(new Image {
                Source = location.GetSmallIcon(), Height = 16, Width = 16, Margin = new Thickness(2)
            });
            content.Children.Add(new TextBlock {
                Text = location.Name, Margin = new Thickness(2)
            });
            var btnLocation = new Button
            {
                Content = content,
                Tag     = location,
                HorizontalContentAlignment = HorizontalAlignment.Left,
                Foreground = settings.UiForeBrush,
                Background = settings.UiGradientBrushV,
                Margin     = new Thickness(5)
            };

            btnLocation.Click += btnLocation_Click;

            pnlButtons.Children.Add(btnLocation);
        }
Exemplo n.º 9
0
        private void DetectWebRoot(SharedSettings settings, string applicationName)
        {
            /*
             * There are multiple hosting scenarios where the WebRoot is not in the
             * standard location ({contentRoot}/wwwroot) from the WebApplication libraries'
             * perspectives. The host needs to indicate to the libraries where they can find their
             * static content.
             *
             * Example hosts scenarios:
             * 1. Running MainHost (via dotnet run, or F5).
             * 2. Running tests under NCrunch which has the ContentRoot in ncrunch workspace directory.
             * 3. dotnet publish which publish library static content into a wwwroot/_content/{lib} folder.
             */

            // Applies to dotnet run / F5
            var path = Path.Combine(_environment.ContentRootPath, "..", applicationName);

            if (Directory.Exists(path))
            {
                settings.WebRootPathOverride = Path.Combine(path, "wwwroot");
                return;
            }

            // Applies to dotnet publish
            path = Path.Combine(_environment.ContentRootPath, "wwwroot", "_content", applicationName);
            if (Directory.Exists(path))
            {
                settings.WebRootPathOverride = path;
            }
        }
Exemplo n.º 10
0
 public ColorPickerSelector()
 {
     InitializeComponent();
     OldColor = Colors.Black;
     settings = SharedSettings.GetInstance();
     settings.ColorsUpdated += SettingsColorsUpdated;
     ColorComponents();
 }
Exemplo n.º 11
0
 public ColorPickerSelector()
 {
     InitializeComponent();
     OldColor = Colors.Black;
     settings = SharedSettings.GetInstance();
     settings.ColorsUpdated += SettingsColorsUpdated;
     ColorComponents();
 }
Exemplo n.º 12
0
        public LocationMenu()
        {
            InitializeComponent();
            LoadLocations();
            var settings = SharedSettings.GetInstance();

            icon.Foreground = settings.UiForeBrushGlassL;
            this.Loaded    += LocationMenu_Loaded;
        }
Exemplo n.º 13
0
        private void LoadMenu()
        {
            var manager = new ProgramManager();
            var items   = manager.GetProgramMenu();

            LoadMenuItems(items);

            var settings = SharedSettings.GetInstance();

            icon.Foreground = settings.UiForeBrushGlassL;
        }
Exemplo n.º 14
0
        public SettingsControl()
        {
            InitializeComponent();

            settings = SharedSettings.GetInstance();
            settings.ColorsUpdated += SettingsColorsUpdated;
            ColorComponents();
            LoadOptions();

            slGlass.ValueChanged += slGlass_ValueChanged;
            cbHideTaskbar.Click  += CbHideTaskbarClick;
        }
Exemplo n.º 15
0
        private void RotateTargetsAroundAnchor()
        {
            IInputDevice inputDevice = RTInputDevice.Get.Device;

            if (!inputDevice.WasMoved())
            {
                return;
            }

            float rotationAmount = inputDevice.GetFrameDelta().x *SharedSettings.RotationSensitivity;

            foreach (GrabTarget grabTarget in _grabTargets)
            {
                if (grabTarget == null)
                {
                    continue;
                }

                ObjectLayerGrabSettings layerGrabSettings = SharedSettings.GetLayerGrabSettings(grabTarget.GameObject.layer);
                if (layerGrabSettings.IsActive)
                {
                    if (layerGrabSettings.AlignAxis)
                    {
                        Quaternion rotation = Quaternion.AngleAxis(rotationAmount, _grabSurfaceInfo.AnchorNormal);
                        grabTarget.Transform.RotateAroundPivot(rotation, _grabSurfaceInfo.AnchorPoint);
                        grabTarget.AnchorVector = rotation * grabTarget.AnchorVector;
                    }
                    else
                    {
                        Quaternion rotation = Quaternion.AngleAxis(rotationAmount, Vector3.up);
                        grabTarget.Transform.RotateAroundPivot(rotation, _grabSurfaceInfo.AnchorPoint);
                        grabTarget.AnchorVector = rotation * grabTarget.AnchorVector;
                    }
                }
                else
                {
                    if (SharedSettings.AlignAxis)
                    {
                        Quaternion rotation = Quaternion.AngleAxis(rotationAmount, _grabSurfaceInfo.AnchorNormal);
                        grabTarget.Transform.RotateAroundPivot(rotation, _grabSurfaceInfo.AnchorPoint);
                        grabTarget.AnchorVector = rotation * grabTarget.AnchorVector;
                    }
                    else
                    {
                        Quaternion rotation = Quaternion.AngleAxis(rotationAmount, Vector3.up);
                        grabTarget.Transform.RotateAroundPivot(rotation, _grabSurfaceInfo.AnchorPoint);
                        grabTarget.AnchorVector = rotation * grabTarget.AnchorVector;
                    }
                }
            }

            SnapTargetsToSurface();
        }
Exemplo n.º 16
0
        public WorkspaceSetter(TaskWindow taskWindow, MenuWindow menu, Desktop desktop)
        {
            this.taskWindow = taskWindow;
            this.menu = menu;
            this.desktop = desktop;
            settings = SharedSettings.GetInstance();
            if (settings.TaskbarAlwaysVisible)
                taskWindow.SizeChanged += TaskWindowSizeChanged;
            menu.SizeChanged += TaskWindowSizeChanged;

            DrawWorkSpace();
        }
Exemplo n.º 17
0
        public SettingsControl()
        {
            InitializeComponent();

            settings = SharedSettings.GetInstance();
            settings.ColorsUpdated += SettingsColorsUpdated;
            ColorComponents();
            LoadOptions();

            slGlass.ValueChanged += slGlass_ValueChanged;
            cbHideTaskbar.Click += CbHideTaskbarClick;
        }
Exemplo n.º 18
0
        public void TestManagedIncludeDllCompression(string testDataFile, SerializiableTestClass testClass)
        {
            try
            {
                using (FileStream fs = File.Create(testDataFile))
                {
                    var encoder = new LZMA.CLzma2Enc(LZMA.ISzAlloc.SmallAlloc, LZMA.ISzAlloc.BigAlloc);

                    ObjectSerializer <SerializiableTestClass> testClassObjectSerializer = new ObjectSerializer <SerializiableTestClass>();
                    MemoryStream ms = new MemoryStream(testClassObjectSerializer.SerializeToByteArray(testClass));
                    byte[]       byteArrayToEncode = ms.ToArray();

                    ms = null;
                    GC.Collect();

                    SharedSettings settings = new SharedSettings
                    {
                        Algo            = 2,
                        UseV2           = true,
                        DictSize        = 0x2000000,
                        Level           = 5,
                        BTMode          = 1,
                        NumHashBytes    = 4,
                        WriteEndMark    = 1,
                        NumThreads      = 8,
                        NumTotalThreads = 8,
                        LC = 3,
                        LP = 0,
                        MC = 32,
                        FB = 32,
                        PB = 4,
                        NumBlockThreads = 8,
                        Variant         = 1,
                    };

                    settings.Src = new PZ(byteArrayToEncode);
                    settings.Dst = new PZ(new byte[byteArrayToEncode.Length]);
                    LZMA_Compress(settings);

                    fs.Write(settings.Dst.Buffer, 0, settings.WrittenSize);
                    fs.Flush();
                    fs.Close();

                    //LZMA.ISeqOutStream encoderOutputStream= new LZMA.CSeqOutStream();
                    //encoder.Lzma2Enc_Encode(fs, ms, null);
                }
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.Message);
            }
        }
Exemplo n.º 19
0
        public DesktopButton(IoItem desktopItem)
        {
            this.desktopItem = desktopItem;

            InitializeComponent();

            Background = new ImageBrush(desktopItem.GetLargeIcon()){Stretch = Stretch.None};
            DisplayName = desktopItem.Name;

            settings = SharedSettings.GetInstance();
            ColorComponents();
            settings.ColorsUpdated+=SettingsColorsUpdated;
        }
Exemplo n.º 20
0
        private void FillStart()
        {
            var settings = SharedSettings.GetInstance();

            AllApps.Foreground            = settings.UiForeBrush;
            Explore10.Foreground          = settings.UiForeBrush;
            Background                    = settings.UiBrushGlass;
            ProgramList.Visibility        = Visibility.Hidden;
            ProgramList.Height            = SystemParameters.FullPrimaryScreenHeight - 210;
            ProgramList.VerticalAlignment = VerticalAlignment.Top;
            ProgramParent.Visibility      = Visibility.Hidden;
            ProgramParent.Height          = SystemParameters.FullPrimaryScreenHeight - 210;
        }
Exemplo n.º 21
0
        public void LzmaCompress(SharedSettings s)
        {
            int srcBase = s.Src.Offset;
            int dstBase = s.Dst.Offset;

            LZMA.CLzma2EncProps props = new LZMA.CLzma2EncProps();
            props.Lzma2EncProps_Init();

            props.mLzmaProps.mLevel        = s.ActualLevel;
            props.mLzmaProps.mDictSize     = (uint)s.ActualDictSize;
            props.mLzmaProps.mLC           = s.ActualLC;
            props.mLzmaProps.mLP           = s.ActualLP;
            props.mLzmaProps.mPB           = s.ActualPB;
            props.mLzmaProps.mAlgo         = s.ActualAlgo;
            props.mLzmaProps.mFB           = s.ActualFB;
            props.mLzmaProps.mBtMode       = s.ActualBTMode;
            props.mLzmaProps.mNumHashBytes = s.ActualNumHashBytes;
            props.mLzmaProps.mMC           = s.ActualMC;
            props.mLzmaProps.mWriteEndMark = s.ActualWriteEndMark;
            props.mLzmaProps.mNumThreads   = s.ActualNumThreads;
            props.mBlockSize       = s.ActualBlockSize;
            props.mNumBlockThreads = s.ActualNumBlockThreads;
            props.mNumTotalThreads = s.ActualNumTotalThreads;

            LZMA.ISeqInStream  input  = new CSeqInStream(s);
            LZMA.ISeqOutStream output = new CSeqOutStream(s);

            var encoder = new LZMA.CLzma2Enc(LZMA.ISzAlloc.SmallAlloc, LZMA.ISzAlloc.BigAlloc);

            var res = encoder.Lzma2Enc_SetProps(props);

            if (res != LZMA.SZ_OK)
            {
                throw new Exception("Lzma2Compress/SetProps failed: " + res);
            }

            res = encoder.Lzma2Enc_Encode(output, input, null);
            if (res != LZMA.SZ_OK)
            {
                throw new Exception("Lzma2Compress/Encode failed: " + res);
            }

            s.WrittenSize = s.Dst.Offset - dstBase;
            s.Enc         = new PZ(new[] { encoder.Lzma2Enc_WriteProperties() });

            encoder.Lzma2Enc_Destroy();
            s.Src.Length += s.Src.Offset - srcBase;
            s.Src.Offset  = srcBase;
            s.Dst.Length += s.Dst.Offset - dstBase;
            s.Dst.Offset  = dstBase;
        }
Exemplo n.º 22
0
        private void LZMA_Compress(SharedSettings s)
        {
            long s_WrittenSize = s.Dst.Length;

            var props = LZMA.CLzmaEncProps.LzmaEncProps_Init();

            props.mLevel        = s.ActualLevel;
            props.mDictSize     = (uint)s.ActualDictSize;
            props.mLC           = s.ActualLC;
            props.mLP           = s.ActualLP;
            props.mPB           = s.ActualPB;
            props.mAlgo         = s.ActualAlgo;
            props.mFB           = s.ActualFB;
            props.mBtMode       = s.ActualBTMode;
            props.mNumHashBytes = s.ActualNumHashBytes;
            props.mMC           = s.ActualMC;
            props.mWriteEndMark = s.ActualWriteEndMark;
            props.mNumThreads   = s.ActualNumThreads;

            var enc = LZMA.LzmaEnc_Create(LZMA.ISzAlloc.BigAlloc);
            var res = enc.LzmaEnc_SetProps(props);

            if (res != LZMA.SZ_OK)
            {
                throw new Exception("SetProps failed: " + res);
            }
            res = enc.LzmaEnc_MemEncode(P.From(s.Dst), ref s_WrittenSize, P.From(s.Src), s.Src.Length,
                                        s.ActualWriteEndMark != 0, null, LZMA.ISzAlloc.SmallAlloc, LZMA.ISzAlloc.BigAlloc);
            if (res != LZMA.SZ_OK)
            {
                throw new Exception("MemEncode failed: " + res);
            }

            s.Enc = new PZ(new byte[LZMA.LZMA_PROPS_SIZE]);
            long s_Enc_Length = s.Enc.Length;

            res = enc.LzmaEnc_WriteProperties(P.From(s.Enc), ref s_Enc_Length);
            if (res != LZMA.SZ_OK)
            {
                throw new Exception("WriteProperties failed: " + res);
            }
            if (s.Enc.Length != s.Enc.Buffer.Length)
            {
                throw new NotSupportedException();
            }

            enc.LzmaEnc_Destroy(LZMA.ISzAlloc.SmallAlloc, LZMA.ISzAlloc.BigAlloc);
            s.WrittenSize = (int)s_WrittenSize;
            s.Enc.Length  = (int)s_Enc_Length;
        }
Exemplo n.º 23
0
        public WorkspaceSetter(TaskWindow taskWindow, MenuWindow menu, Desktop desktop)
        {
            this.taskWindow = taskWindow;
            this.menu       = menu;
            this.desktop    = desktop;
            settings        = SharedSettings.GetInstance();
            if (settings.TaskbarAlwaysVisible)
            {
                taskWindow.SizeChanged += TaskWindowSizeChanged;
            }
            menu.SizeChanged += TaskWindowSizeChanged;

            DrawWorkSpace();
        }
Exemplo n.º 24
0
        /// <summary>
        /// Gets items that are missing.
        /// </summary>
        /// <param name="find"></param>
        /// <returns></returns>
        protected IDictionary GetMissingItems()
        {
            IDictionary settings = SharedSettings.GetDefaultSharedSettings();

            // anything?
            if (settings.Count > 0)
            {
                return(this.GetMissingItems(settings));
            }
            else
            {
                return(settings);
            }
        }
Exemplo n.º 25
0
        private void OffsetTargetsFromSurface()
        {
            IInputDevice inputDevice = RTInputDevice.Get.Device;

            if (!inputDevice.WasMoved())
            {
                return;
            }

            float offsetAmount = inputDevice.GetFrameDelta().x *SharedSettings.OffsetFromSurfaceSensitivity;

            foreach (GrabTarget grabTarget in _grabTargets)
            {
                if (grabTarget == null)
                {
                    continue;
                }

                ObjectLayerGrabSettings layerGrabSettings = SharedSettings.GetLayerGrabSettings(grabTarget.GameObject.layer);
                if (layerGrabSettings.IsActive)
                {
                    if (layerGrabSettings.AlignAxis)
                    {
                        grabTarget.Transform.position += grabTarget.SittingPlane.normal * offsetAmount;
                        grabTarget.OffsetFromSurface  += offsetAmount;
                    }
                    else
                    {
                        grabTarget.Transform.position += Vector3.up * offsetAmount;
                        grabTarget.OffsetFromSurface  += offsetAmount;
                    }
                }
                else
                {
                    if (SharedSettings.AlignAxis)
                    {
                        grabTarget.Transform.position += grabTarget.SittingPlane.normal * offsetAmount;
                        grabTarget.OffsetFromSurface  += offsetAmount;
                    }
                    else
                    {
                        grabTarget.Transform.position += Vector3.up * offsetAmount;
                        grabTarget.OffsetFromSurface  += offsetAmount;
                    }
                }
            }

            CalculateGrabTargetsAnchorVectors();
        }
Exemplo n.º 26
0
        public Wifi()
        {
            InitializeComponent();
            //inital text
            var settings = SharedSettings.GetInstance();

            ucWifi.Foreground = settings.UiForeBrush;
            ucWifi.Text       = "Wifi Signal: " + GetWifiSignal();
            //set up timer
            var timer = new Timer(60000);

            timer.Elapsed  += Timer_Elapsed;
            timer.AutoReset = true;
            timer.Enabled   = true;
        }
Exemplo n.º 27
0
        /// <summary>
        /// Constructor where all dependencies are injected
        /// </summary>
        /// <param name="errorSettings"></param>
        /// <param name="sharedSettings"></param>
        /// <param name="matterCenterServiceFunctions"></param>
        /// <param name="customLogger"></param>
        /// <param name="logTables"></param>
        /// <param name="sharedRepository"></param>
        public SharedController(IOptions <ErrorSettings> errorSettings,
                                IOptions <SharedSettings> sharedSettings,
                                IMatterCenterServiceFunctions matterCenterServiceFunctions,
                                ICustomLogger customLogger, IOptions <LogTables> logTables,
                                ISharedRepository sharedRepository
                                )
        {
            this.errorSettings = errorSettings.Value;

            this.matterCenterServiceFunctions = matterCenterServiceFunctions;
            this.sharedRepository             = sharedRepository;
            this.customLogger   = customLogger;
            this.logTables      = logTables.Value;
            this.sharedSettings = sharedSettings.Value;
        }
Exemplo n.º 28
0
        public Battery()
        {
            InitializeComponent();
            //inital text
            var settings = SharedSettings.GetInstance();

            ucBattery.Foreground = settings.UiForeBrush;
            ucBattery.Text       = "Battery Remaining: " + GetBatteryPercent() + "%";
            //set up timer
            var timer = new Timer(60000);

            timer.Elapsed  += Timer_Elapsed;
            timer.AutoReset = true;
            timer.Enabled   = true;
        }
Exemplo n.º 29
0
        private void RotateTargetsAroundAnchor()
        {
            EditorUndoEx.RecordObjectTransforms(_targetParents);
            float rotationAmount = InputDeviceManager.Get.MouseDelta.x * SharedSettings.RotationSensitivity;

            foreach (var grabTarget in _grabTargets)
            {
                if (grabTarget == null)
                {
                    continue;
                }

                var layerGrabSettings = SharedSettings.GetLayerGrabSettings(grabTarget.GameObject.layer);
                if (layerGrabSettings.IsActive)
                {
                    if (layerGrabSettings.AlignAxis)
                    {
                        Quaternion rotation = Quaternion.AngleAxis(rotationAmount, _grabSurfaceInfo.AnchorNormal);
                        grabTarget.Transform.RotateAroundPivot(rotation, _grabSurfaceInfo.AnchorPoint);
                        grabTarget.AnchorVector = rotation * grabTarget.AnchorVector;
                    }
                    else
                    {
                        Quaternion rotation = Quaternion.AngleAxis(rotationAmount, Vector3.up);
                        grabTarget.Transform.RotateAroundPivot(rotation, _grabSurfaceInfo.AnchorPoint);
                        grabTarget.AnchorVector = rotation * grabTarget.AnchorVector;
                    }
                }
                else
                {
                    if (SharedSettings.AlignAxis)
                    {
                        Quaternion rotation = Quaternion.AngleAxis(rotationAmount, _grabSurfaceInfo.AnchorNormal);
                        grabTarget.Transform.RotateAroundPivot(rotation, _grabSurfaceInfo.AnchorPoint);
                        grabTarget.AnchorVector = rotation * grabTarget.AnchorVector;
                    }
                    else
                    {
                        Quaternion rotation = Quaternion.AngleAxis(rotationAmount, Vector3.up);
                        grabTarget.Transform.RotateAroundPivot(rotation, _grabSurfaceInfo.AnchorPoint);
                        grabTarget.AnchorVector = rotation * grabTarget.AnchorVector;
                    }
                }
            }

            SnapTargetsToSurface();
        }
Exemplo n.º 30
0
        public DesktopButton(IoItem desktopItem)
        {
            this.desktopItem = desktopItem;

            InitializeComponent();

            Background = new ImageBrush(desktopItem.GetLargeIcon())
            {
                Stretch = Stretch.None
            };
            DisplayName = desktopItem.Name;


            settings = SharedSettings.GetInstance();
            ColorComponents();
            settings.ColorsUpdated += SettingsColorsUpdated;
        }
Exemplo n.º 31
0
        private void RotateTargets()
        {
            IInputDevice inputDevice = RTInputDevice.Get.Device;

            if (!inputDevice.WasMoved())
            {
                return;
            }

            float rotationAmount = inputDevice.GetFrameDelta().x *SharedSettings.RotationSensitivity;

            foreach (GrabTarget grabTarget in _grabTargets)
            {
                if (grabTarget == null)
                {
                    continue;
                }

                ObjectLayerGrabSettings layerGrabSettings = SharedSettings.GetLayerGrabSettings(grabTarget.GameObject.layer);
                if (layerGrabSettings.IsActive)
                {
                    if (layerGrabSettings.AlignAxis)
                    {
                        grabTarget.Transform.Rotate(grabTarget.SittingPlane.normal, rotationAmount, Space.World);
                    }
                    else
                    {
                        grabTarget.Transform.Rotate(Vector3.up, rotationAmount, Space.World);
                    }
                }
                else
                {
                    if (SharedSettings.AlignAxis)
                    {
                        grabTarget.Transform.Rotate(grabTarget.SittingPlane.normal, rotationAmount, Space.World);
                    }
                    else
                    {
                        grabTarget.Transform.Rotate(Vector3.up, rotationAmount, Space.World);
                    }
                }
            }

            CalculateGrabTargetsAnchorVectors();
        }
        public void Constructor_Development_ShouldSetAllVariables()
        {
            // Arrange
            var webHostEnvironmentMock = DependencyMocker.GetWebHostEnvironment(TestValues.Development);

            // Act
            var sharedSettings = new SharedSettings(_optionsMock.Object, webHostEnvironmentMock.Object);

            // Assert
            sharedSettings.DevelopmentMode.Should().BeTrue();
            sharedSettings.AssetsDirectoryPath.Should().Be(DevAssetsDirectoryPathResult);
            sharedSettings.AssetsWebPath.Should().Be(DevAssetsWebPathResult);
            sharedSettings.ManifestPath.Should().Be(DevManifestPathResult);
            _optionsMock.VerifyGet(x => x.Value, Times.Exactly(5));
            _optionsMock.VerifyNoOtherCalls();
            webHostEnvironmentMock.VerifyGet(x => x.EnvironmentName, Times.Once);
            webHostEnvironmentMock.VerifyNoOtherCalls();
        }
Exemplo n.º 33
0
        public Task(Window window)
        {
            InitializeComponent();
            this.window = window;

            settings = SharedSettings.GetInstance();
            Loaded += UpdateThumb;
            SizeChanged += UpdateThumb;
            SizeChanged += TaskSizeChanged;

            imgIcon16.Source = window.ProgramIcon;
            imgIcon32.Source = window.ProgramIcon;
            taskLabel.Text = window.Title;

            window.TitleChanged += WindowTitleChanged;

            SetColors();
            settings.ColorsUpdated += SettingsColorsUpdated;
        }
Exemplo n.º 34
0
        public Task(Window window)
        {
            InitializeComponent();
            this.window = window;

            settings     = SharedSettings.GetInstance();
            Loaded      += UpdateThumb;
            SizeChanged += UpdateThumb;
            SizeChanged += TaskSizeChanged;

            imgIcon16.Source = window.ProgramIcon;
            imgIcon32.Source = window.ProgramIcon;
            taskLabel.Text   = window.Title;

            window.TitleChanged += WindowTitleChanged;

            SetColors();
            settings.ColorsUpdated += SettingsColorsUpdated;
        }
Exemplo n.º 35
0
        private void OffsetTargetsFromSurface()
        {
            float offsetAmount = InputDeviceManager.Get.MouseDelta.x * SharedSettings.OffsetFromSurfaceSensitivity;

            foreach (var grabTarget in _grabTargets)
            {
                if (grabTarget == null)
                {
                    continue;
                }

                var layerGrabSettings = SharedSettings.GetLayerGrabSettings(grabTarget.GameObject.layer);
                if (layerGrabSettings.IsActive)
                {
                    if (layerGrabSettings.AlignAxis)
                    {
                        grabTarget.Transform.position += grabTarget.SittingPlane.normal * offsetAmount;
                        grabTarget.OffsetFromSurface  += offsetAmount;
                    }
                    else
                    {
                        grabTarget.Transform.position += Vector3.up * offsetAmount;
                        grabTarget.OffsetFromSurface  += offsetAmount;
                    }
                }
                else
                {
                    if (SharedSettings.AlignAxis)
                    {
                        grabTarget.Transform.position += grabTarget.SittingPlane.normal * offsetAmount;
                        grabTarget.OffsetFromSurface  += offsetAmount;
                    }
                    else
                    {
                        grabTarget.Transform.position += Vector3.up * offsetAmount;
                        grabTarget.OffsetFromSurface  += offsetAmount;
                    }
                }
            }

            CalculateGrabTargetsAnchorVectors();
        }
        public MainWindow()
        {
            //show Stream Deck Device choice window
            string choiceMade = SharedSettings.config.Read("choiceMade", "StreamDeck_Device");

            if (choiceMade == "false")
            {
                DeviceChoice deviceChoice = new DeviceChoice();
                deviceChoice.Show();
                Close();
            }

            //make sure only one instance is running
            SharedSettings.CheckForTwins();
            InitializeComponent();

            //load all values from config file
            currentProfile = SharedSettings.config.Read("selectedProfile", "Current_Profile");
            PrepValueDisplay(currentProfile);
        }
Exemplo n.º 37
0
 void SlideMenuLoaded(object sender, RoutedEventArgs e)
 {
     settings = SharedSettings.GetInstance();
     settings.ColorsUpdated += SettingsColorsUpdated;
     ColorComponents();
 }
Exemplo n.º 38
0
        public void LzmaCompress(SharedSettings s)
        {
            int srcBase = s.Src.Offset;
            int dstBase = s.Dst.Offset;

            LZMA.CLzma2EncProps props = new LZMA.CLzma2EncProps();
            props.Lzma2EncProps_Init();

            props.mLzmaProps.mLevel = s.ActualLevel;
            props.mLzmaProps.mDictSize = (uint)s.ActualDictSize;
            props.mLzmaProps.mLC = s.ActualLC;
            props.mLzmaProps.mLP = s.ActualLP;
            props.mLzmaProps.mPB = s.ActualPB;
            props.mLzmaProps.mAlgo = s.ActualAlgo;
            props.mLzmaProps.mFB = s.ActualFB;
            props.mLzmaProps.mBtMode = s.ActualBTMode;
            props.mLzmaProps.mNumHashBytes = s.ActualNumHashBytes;
            props.mLzmaProps.mMC = s.ActualMC;
            props.mLzmaProps.mWriteEndMark = s.ActualWriteEndMark;
            props.mLzmaProps.mNumThreads = s.ActualNumThreads;
            props.mBlockSize = s.ActualBlockSize;
            props.mNumBlockThreads = s.ActualNumBlockThreads;
            props.mNumTotalThreads = s.ActualNumTotalThreads;

            LZMA.ISeqInStream input = new CSeqInStream(s);
            LZMA.ISeqOutStream output = new CSeqOutStream(s);

            var encoder = new LZMA.CLzma2Enc(LZMA.ISzAlloc.SmallAlloc, LZMA.ISzAlloc.BigAlloc);

            var res = encoder.Lzma2Enc_SetProps(props);
            if(res != LZMA.SZ_OK)
                throw new Exception("Lzma2Compress/SetProps failed: " + res);

            res = encoder.Lzma2Enc_Encode(output, input, null);
            if(res != LZMA.SZ_OK)
                throw new Exception("Lzma2Compress/Encode failed: " + res);

            s.WrittenSize = s.Dst.Offset - dstBase;
            s.Enc = new PZ(new[] { encoder.Lzma2Enc_WriteProperties() });

            encoder.Lzma2Enc_Destroy();
            s.Src.Length += s.Src.Offset - srcBase;
            s.Src.Offset = srcBase;
            s.Dst.Length += s.Dst.Offset - dstBase;
            s.Dst.Offset = dstBase;
        }
Exemplo n.º 39
0
        public void LzmaUncompress(SharedSettings s)
        {
            if(s.Enc.Length != 1)
                throw new ArgumentException("Settings must contain a single byte.", "propLength");

            if(s.Variant == 1)
            {
                LZMA.CLzma2Dec dec = new LZMA.CLzma2Dec();
                dec.Lzma2Dec_Construct();
                var res = dec.Lzma2Dec_Allocate(s.Enc[0], LZMA.ISzAlloc.SmallAlloc);
                if(res != LZMA.SZ_OK)
                    throw new Exception("Lzma2Dec_Allocate failed: " + res);
                dec.Lzma2Dec_Init();
                for(; ; )
                {
                    long s_WrittenSize = s.Dst.Length - s.Dst.Offset;
                    long s_UsedSize = s.Src.Length - s.Src.Offset;

                    LZMA.ELzmaStatus status;
                    res = dec.Lzma2Dec_DecodeToBuf(P.From(s.Dst), ref s_WrittenSize, P.From(s.Src), ref s_UsedSize, LZMA.ELzmaFinishMode.LZMA_FINISH_END, out status);
                    if(res != LZMA.SZ_OK)
                        throw new Exception("Lzma2Dec_DecodeToBuf failed: " + res);

                    s.Dst.Offset += checked((int)s_WrittenSize);
                    s.Src.Offset += checked((int)s_UsedSize);

                    if(status == LZMA.ELzmaStatus.LZMA_STATUS_NEEDS_MORE_INPUT
                        || status == LZMA.ELzmaStatus.LZMA_STATUS_NOT_FINISHED)
                        continue;

                    if(status == LZMA.ELzmaStatus.LZMA_STATUS_FINISHED_WITH_MARK)
                    {
                        if(s.ActualWriteEndMark == 0)
                            throw new Exception("Finished with mark even though we didn't want to write one.");
                        break;
                    }

                    if(status == LZMA.ELzmaStatus.LZMA_STATUS_MAYBE_FINISHED_WITHOUT_MARK)
                    {
                        if(s.ActualWriteEndMark != 0)
                            break;
                    }

                    throw new NotSupportedException("Unsupported status case: " + status);
                }
                s.WrittenSize = s.Dst.Offset;
                s.Dst.Offset = 0;
                s.UsedSize = s.Src.Offset;
                s.Src.Offset = 0;
            }
            else
            {
                long s_WrittenSize = s.Dst.Length;
                long s_UsedSize = s.Src.Length;

                LZMA.ELzmaStatus status;
                var res = LZMA.CLzma2Dec.Lzma2Decode(
                    P.From(s.Dst), ref s_WrittenSize,
                    P.From(s.Src), ref s_UsedSize,
                    s.Enc[0], LZMA.ELzmaFinishMode.LZMA_FINISH_END, out status,
                    LZMA.ISzAlloc.SmallAlloc);
                if(res != LZMA.SZ_OK)
                    throw new Exception("LzmaUncompress failed: " + res);
                switch(status)
                {
                case LZMA.ELzmaStatus.LZMA_STATUS_NEEDS_MORE_INPUT:
                    throw new EndOfStreamException();
                case LZMA.ELzmaStatus.LZMA_STATUS_FINISHED_WITH_MARK:
                    if(s.ActualWriteEndMark == 0)
                        throw new InvalidDataException();
                    break;
                case LZMA.ELzmaStatus.LZMA_STATUS_MAYBE_FINISHED_WITHOUT_MARK:
                    if(s.ActualWriteEndMark != 0)
                        throw new InvalidDataException();
                    break;
                default:
                    throw new Exception(status.ToString());
                }

                s.WrittenSize = checked((int)s_WrittenSize);
                s.UsedSize = checked((int)s_UsedSize);
            }
        }
Exemplo n.º 40
0
        public void LzmaCompress(SharedSettings s)
        {
            switch(s.Variant)
            {
            case 1:
                {
                    long s_WrittenSize = s.Dst.Length;

                    var props = LZMA.CLzmaEncProps.LzmaEncProps_Init();
                    props.mLevel = s.ActualLevel;
                    props.mDictSize = (uint)s.ActualDictSize;
                    props.mLC = s.ActualLC;
                    props.mLP = s.ActualLP;
                    props.mPB = s.ActualPB;
                    props.mAlgo = s.ActualAlgo;
                    props.mFB = s.ActualFB;
                    props.mBtMode = s.ActualBTMode;
                    props.mNumHashBytes = s.ActualNumHashBytes;
                    props.mMC = s.ActualMC;
                    props.mWriteEndMark = s.ActualWriteEndMark;
                    props.mNumThreads = s.ActualNumThreads;

                    var enc = LZMA.LzmaEnc_Create(LZMA.ISzAlloc.SmallAlloc);
                    var res = enc.LzmaEnc_SetProps(props);
                    if(res != LZMA.SZ_OK)
                        throw new Exception("SetProps failed: " + res);
                    res = enc.LzmaEnc_MemEncode(P.From(s.Dst), ref s_WrittenSize, P.From(s.Src), s.Src.Length,
                        s.ActualWriteEndMark != 0, null, LZMA.ISzAlloc.SmallAlloc, LZMA.ISzAlloc.BigAlloc);
                    if(res != LZMA.SZ_OK)
                        throw new Exception("MemEncode failed: " + res);

                    s.Enc = new PZ(new byte[LZMA.LZMA_PROPS_SIZE]);
                    long s_Enc_Length = s.Enc.Length;
                    res = enc.LzmaEnc_WriteProperties(P.From(s.Enc), ref s_Enc_Length);
                    if(res != LZMA.SZ_OK)
                        throw new Exception("WriteProperties failed: " + res);
                    if(s.Enc.Length != s.Enc.Buffer.Length)
                        throw new NotSupportedException();

                    enc.LzmaEnc_Destroy(LZMA.ISzAlloc.SmallAlloc, LZMA.ISzAlloc.BigAlloc);
                    s.WrittenSize = (int)s_WrittenSize;
                    s.Enc.Length = (int)s_Enc_Length;
                }
                break;
            default:
                {
                    long s_WrittenSize = s.Dst.Length;
                    s.Enc = new PZ(new byte[LZMA.LZMA_PROPS_SIZE]);
                    long s_Enc_Length = s.Enc.Length;
                    var res = LZMA.LzmaCompress(
                        P.From(s.Dst), ref s_WrittenSize,
                        P.From(s.Src), s.Src.Length,
                        s.Enc.Buffer, ref s_Enc_Length,
                        s.ActualLevel, s.ActualDictSize, s.ActualLC, s.ActualLP, s.ActualPB, s.ActualFB, s.ActualNumThreads);
                    s.WrittenSize = (int)s_WrittenSize;
                    s.Enc.Length = (int)s_Enc_Length;
                    if(res != LZMA.SZ_OK)
                        throw new Exception("LzmaCompress failed: " + res);
                    if(s.Enc.Length != s.Enc.Buffer.Length)
                        throw new NotSupportedException();
                }
                break;
            }
        }
Exemplo n.º 41
0
 public CSeqOutStream(SharedSettings s)
 {
     this.s = s;
 }
Exemplo n.º 42
0
        public void LzmaUncompress(SharedSettings s)
        {
            switch(s.Variant)
            {
            case 1:
                {
                    var decoder = new LZMA.CLzmaDec();
                    decoder.LzmaDec_Construct();

                    var res = decoder.LzmaDec_Allocate(P.From(s.Enc), checked((uint)s.Enc.Length), LZMA.ISzAlloc.SmallAlloc);
                    if(res != LZMA.SZ_OK)
                        throw new Exception("Allocate failed: " + res);

                    decoder.LzmaDec_Init();

                    P<byte> dstPtr = P.From(s.Dst);
                    long s_WrittenSize = s.Dst.Length;
                    s.WrittenSize = 0;

                    P<byte> srcPtr = P.From(s.Src);
                    long s_UsedSize = s.Src.Length;
                    s.UsedSize = 0;

                    for(; ; )
                    {
                        LZMA.ELzmaStatus status;
                        res = decoder.LzmaDec_DecodeToBuf(dstPtr, ref s_WrittenSize, srcPtr, ref s_UsedSize, LZMA.ELzmaFinishMode.LZMA_FINISH_END, out status);
                        if(res != LZMA.SZ_OK)
                            throw new Exception("DecodeToBuf failed: " + res);

                        s.WrittenSize += checked((int)s_WrittenSize);
                        s.UsedSize += checked((int)s_UsedSize);
                        dstPtr += s_WrittenSize;
                        srcPtr += s_UsedSize;
                        s_WrittenSize = dstPtr.mBuffer.Length - dstPtr.mOffset;
                        s_UsedSize = srcPtr.mBuffer.Length - srcPtr.mOffset;

                        if(status == LZMA.ELzmaStatus.LZMA_STATUS_NEEDS_MORE_INPUT
                            || status == LZMA.ELzmaStatus.LZMA_STATUS_NOT_FINISHED)
                            continue;

                        if(status == LZMA.ELzmaStatus.LZMA_STATUS_FINISHED_WITH_MARK)
                        {
                            if(s.ActualWriteEndMark == 0)
                                throw new Exception("Finished with mark even though we didn't want to write one.");
                            break;
                        }

                        if(status == LZMA.ELzmaStatus.LZMA_STATUS_MAYBE_FINISHED_WITHOUT_MARK)
                        {
                            if(s.ActualWriteEndMark != 0)
                                break;
                        }

                        throw new NotSupportedException("Unsupported status case: " + status);
                    }

                    decoder.LzmaDec_Free(LZMA.ISzAlloc.SmallAlloc);

                    s.WrittenSize = (int)dstPtr.mOffset;
                    s.UsedSize = (int)srcPtr.mOffset;
                }
                break;
            default:
                {
                    long s_WrittenSize = s.Dst.Length;
                    long s_UsedSize = s.Src.Length;
                    var res = LZMA.LzmaUncompress(
                        P.From(s.Dst), ref s_WrittenSize,
                        P.From(s.Src), ref s_UsedSize,
                        P.From(s.Enc), s.Enc.Length);
                    if(res != LZMA.SZ_OK)
                        throw new Exception("LzmaUcompress failed: " + res);
                    s.WrittenSize = (int)s_WrittenSize;
                    s.UsedSize = (int)s_UsedSize;
                }
                break;
            }
        }