Пример #1
0
        static void InitGlobalResourceFile()
        {
            String gtkResouceFile;

            Assembly myAssembly = Assembly.GetExecutingAssembly();

            string[] names = myAssembly.GetManifestResourceNames();
            foreach (string name in names)
            {
                Console.WriteLine(name);
                if (name.Contains("GtkThemeResource.rc"))
                {
                    gtkResouceFile = name;
                    break;
                }
                Console.WriteLine("Gtk Theme Resource not found in manifest");
            }

            var    tmpFile = Path.GetTempFileName();
            var    stream  = myAssembly.GetManifestResourceStream(gtkResouceFile);
            string gtkrc;

            using (StreamReader reader = new StreamReader(stream)) {
                gtkrc = reader.ReadToEnd();
            }
            using (StreamWriter outputFile = new StreamWriter(tmpFile)) {
                outputFile.WriteLine(gtkrc);
            }
            Rc.AddDefaultFile(tmpFile);
            Rc.Parse(tmpFile);
        }
Пример #2
0
        public Column ToColumn(Main m)
        {
            var v = new Twitterizer.Streaming.StreamOptions();

            v.Track.AddRange(Rc.CutString(",", Track));
            v.Follow.AddRange(Rc.CutString(",", Follow));
            try
            {
                if (Image == "null")
                {
                    return(new Column(new Twitterizer.Streaming.TwitterStream(m.Accounts[AccountName].OAuthTokens, "Alicium", v), ColumnType, Tille));
                }
                else
                {
                    using (var f = File.OpenRead(Image))
                    {
                        var b = Bitmap.FromStream(f);
                        return(new Column(new Twitterizer.Streaming.TwitterStream(m.Accounts[AccountName].OAuthTokens, "Alicium", v), ColumnType, Tille, (Image)b.Clone()));
                    }
                }
            }
            catch
            {
                MessageBox.Show("Can't find " + AccountName + " from accounts data.Please authenticate again.", "Not Found", MessageBoxButtons.OK, MessageBoxIcon.Exclamation, MessageBoxDefaultButton.Button1, MessageBoxOptions.DefaultDesktopOnly, false);
                return(null);
            }
        }
        public override void Paint(CellExposeEventArgs aArgs)
        {
            if (Area.IsInsideArea(aArgs.ClippingArea) == false)
            {
                return;
            }
            Style  style = Rc.GetStyle(ChameleonTemplates.Button);
            Widget wdg   = (Widget)Master;

            Gdk.Rectangle rect = aArgs.CellArea.CopyToGdkRectangle();
            rect.Height += 2;
            if (this.ResolveState() == StateType.Insensitive)
            {
                Style.PaintBox(style, aArgs.Drawable, StateType.Insensitive, ShadowType.Out, rect,
                               wdg, "button", rect.X, rect.Y, rect.Width, rect.Height);
                rect.Width = rect.Width - System.Convert.ToInt32(rect.Width * Progress);
                Style.PaintBox(style, aArgs.Drawable, StateType.Insensitive, ShadowType.Out, rect,
                               wdg, "button", rect.X, rect.Y, rect.Width, rect.Height);
            }
            else
            {
                Style.PaintBox(style, aArgs.Drawable, StateType.Normal, ShadowType.Out, rect,
                               wdg, "box", rect.X, rect.Y, rect.Width, rect.Height);
                rect.Width = rect.Width - System.Convert.ToInt32(rect.Width * Progress);
                Style.PaintBox(style, aArgs.Drawable, StateType.Selected, ShadowType.Out, rect,
                               wdg, "bar", rect.X, rect.Y, rect.Width, rect.Height);
            }
            style.Dispose();
        }
Пример #4
0
        public static void CreateScript(string Name, string Code, params Arg[] Args)
        {
            var FinalCode = Code + @"
namespace Script
{
    public static class Args
    {
";

            foreach (Arg a in Args)
            {
                Rc.saveData(a.XML, "ScriptData/" + a.ArgName);
                FinalCode += @"
        public static " + a.type + " " + a.ArgName + @"
        {
        get
            {
            return LoadFromXMLString<" + a.type + ">(loadData(" + Rc.loadData("ScriptData/DoubleQuortation") + "ScriptData/" + a.ArgName + Rc.loadData("ScriptData/DoubleQuortation") + @"));
            }
        }
";
            }
            FinalCode += add + @"
    }
}";
            Console.WriteLine(@"Compile code : 
" + FinalCode);
            Rc.saveData(FinalCode, "Scripts/" + Name + ".cs");
            Compile("Scripts/" + Name);
        }
Пример #5
0
        private void SetFlightPath()
        {
            float    speed    = (float)Rc.GetShipSpeed();
            Vector3D velocity = Rc.GetShipVelocities().LinearVelocity;

            if (speed > 5)
            {
                Vector3D endpoint = GridPosition + (Vector3D.Normalize(velocity) * 1000000);
            }
            else
            {
                Vector3D endpoint = GridPosition + (Rc.WorldMatrix.Forward * 1000000);
            }

            if (Math.Abs(_freighterSetup.CruiseSpeed - default(float)) > 0)
            {
                (Rc as MyRemoteControl)?.SetAutoPilotSpeedLimit(_freighterSetup.CruiseSpeed);
            }
            else
            {
                (Rc as MyRemoteControl)?.SetAutoPilotSpeedLimit(speed > 5 ? speed : 30);
            }

            (Rc as MyRemoteControl)?.SetCollisionAvoidance(true);
        }
Пример #6
0
        /// <summary>
        /// Download program settings ("LJ -> PC" button pressed)
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void _btnDownloadProgram_Click(object sender, EventArgs e)
        {
            if (_txtProgramFilePath.Text.Length == 0)
            {
                return;
            }

            // Parameter
            LJV7IF_TARGET_SETTING setting = GetSelectedProgramTargetSetting();
            UInt32 size = GetSelectedProgramDataSize();

            // Allocate buffer
            byte[] receiveBuffer = new byte[size];
            using (PinnedObject pin = new PinnedObject(receiveBuffer))
            {
                // Download
                Rc rc = (Rc)NativeMethods.LJV7IF_GetSetting(DEVICE_ID, SettingDepth.Running, setting, pin.Pointer, size);
                if (!CheckReturnCode(rc))
                {
                    return;
                }
            }
            // Save program data
            using (FileStream fs = new FileStream(_txtProgramFilePath.Text, FileMode.Create))
                using (BinaryWriter writer = new BinaryWriter(fs))
                {
                    writer.Write(receiveBuffer);
                }
        }
Пример #7
0
        /// <summary>
        /// Sets the Gtk theme based on the user's previous choice.
        /// </summary>
        public void RefreshTheme()
        {
#if NETFRAMEWORK
            if (Utility.Configuration.Settings.DarkTheme)
            {
                string tempFile = Path.Combine(Path.GetTempPath(), Guid.NewGuid().ToString() + ".gtkrc");
                using (Stream rcStream = Assembly.GetExecutingAssembly().GetManifestResourceStream("ApsimNG.Resources.dark.gtkrc"))
                {
                    using (StreamReader darkTheme = new StreamReader(rcStream))
                        File.WriteAllText(tempFile, darkTheme.ReadToEnd());
                }

                Rc.Parse(tempFile);
                // Remove black colour from colour pallete.
                Color black = Color.FromArgb(0, 0, 0);
                ColourUtilities.Colours = ColourUtilities.Colours.Where(c => c != black).ToArray();
            }
            else if (ProcessUtilities.CurrentOS.IsWindows)
            {
                // Apsim's default gtk theme uses the 'wimp' rendering engine,
                // which doesn't play nicely on non-windows systems.
                Rc.Parse(Path.Combine(Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location), ".gtkrc"));
            }
#else
            // tbi
#endif
        }
Пример #8
0
        /// <summary>
        /// "Advanced mode get profiles" button pressed.
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void _btnGetProfileAdvance_Click(object sender, EventArgs e)
        {
            LJV7IF_PROFILE_INFO profileInfo = new LJV7IF_PROFILE_INFO();

            LJV7IF_MEASURE_DATA[] measureData = new LJV7IF_MEASURE_DATA[NativeMethods.MesurementDataCount];
            int profileDataSize = MAX_PROFILE_COUNT +
                                  (Marshal.SizeOf(typeof(LJV7IF_PROFILE_HEADER)) + Marshal.SizeOf(typeof(LJV7IF_PROFILE_FOOTER))) / sizeof(int);

            int[] receiveBuffer = new int[profileDataSize];

            // Get profiles.
            using (PinnedObject pin = new PinnedObject(receiveBuffer))
            {
                Rc rc = (Rc)NativeMethods.LJV7IF_GetProfileAdvance(DEVICE_ID, ref profileInfo, pin.Pointer,
                                                                   (uint)(receiveBuffer.Length * sizeof(int)), measureData);
                if (!CheckReturnCode(rc))
                {
                    return;
                }
            }

            List <ProfileData> profileDatas = new List <ProfileData>();

            // Output profile data
            profileDatas.Add(new ProfileData(receiveBuffer, 0, profileInfo));

            // Save file
            SaveProfile(profileDatas, _txtSavePath.Text);
        }
Пример #9
0
        void PreStartHighSpeedAquisition()
        {
            try
            {
                LJV7IF_HIGH_SPEED_PRE_START_REQ req = new LJV7IF_HIGH_SPEED_PRE_START_REQ();
                req.bySendPos = (byte)2;

                // @Point
                // # SendPos is used to specify which profile to start sending data from during high-speed communication.
                // # When "Overwrite" is specified for the operation when memory full and
                //   "0: From previous send complete position" is specified for the send start position,
                //    if the LJ-V continues to accumulate profiles, the LJ-V memory will become full,
                //    and the profile at the previous send complete position will be overwritten with a new profile.
                //    In this situation, because the profile at the previous send complete position is not saved, an error will occur.

                LJV7IF_PROFILE_INFO profileInfo = new LJV7IF_PROFILE_INFO();

                rc = (Rc)NativeMethods.LJV7IF_PreStartHighSpeedDataCommunication(_currentDeviceId, ref req, ref profileInfo);

                CheckReturnValue(rc);

                _profileInfo = profileInfo;
            }
            catch (Exception)
            {
                throw;
            }
        }
Пример #10
0
        void InitHighSpeedUSBComms(uint profileCount)
        {
            try
            {
                _deviceData.ProfileData.Clear();  // Clear the retained profile data.
                _deviceData.MeasureData.Clear();

                rc = (Rc)NativeMethods.LJV7IF_HighSpeedDataUsbCommunicationInitalize(_currentDeviceId, _callback, profileCount,
                                                                                     (uint)_currentDeviceId);
                CheckReturnValue(rc);
                // @Point
                // # When the frequency of calls is low, the callback function may not be called once per specified number of profiles.
                // # The callback function is called when both of the following conditions are met.
                //   * There is one packet of received data.
                //   * The specified number of profiles have been received by the time the call frequency has been met.
                PreStartHighSpeedAquisition();
                if (rc == Rc.Ok)
                {
                    _deviceData.Status = DeviceStatus.UsbFast;
                }
            }
            catch (Exception)
            {
                throw;
            }
        }
Пример #11
0
        public static void Run(string name, string code, Action <object> Return, params Arg[] args)
        {
            string ScriptName = name;
            bool   issuccess  = Worker.CreateScript(ScriptName, code, args);

            try
            {
                if (issuccess)
                {
                    var p = Process.Start(AppDomain.CurrentDomain.BaseDirectory + "Scripts\\" + ScriptName + ".exe");
                    new Task(() =>
                    {
                        while (!p.HasExited)
                        {
                            ;
                        }
                        Return(File.Exists("Scripts/" + ScriptName) ? Rc.LoadFromXML <object>("Scripts/" + ScriptName) : null);
                        p.Dispose();
                    }).Start();
                }
            }
            catch (Exception e)
            {
                System.Windows.Forms.MessageBox.Show("Error: " + e.Message);
            }
        }
Пример #12
0
        /// <summary>
        ///     Returns true if Order instances are equal
        /// </summary>
        /// <param name="other">Instance of Order to be compared</param>
        /// <returns>Boolean</returns>
        public bool Equals(Order other)
        {
            // credit: http://stackoverflow.com/a/10454552/677735
            if (other == null)
            {
                return(false);
            }

            return((Side == other.Side || Side != null && Side.Equals(other.Side)) &&
                   (Sv == other.Sv || Sv != null && Sv.Equals(other.Sv)) &&
                   (Pt == other.Pt || Pt != null && Pt.Equals(other.Pt)) &&
                   (Ot == other.Ot || Ot != null && Ot.Equals(other.Ot)) &&
                   (P == other.P || P != null && P.Equals(other.P)) &&
                   (Sc == other.Sc || Sc != null && Sc.Equals(other.Sc)) &&
                   (Rc == other.Rc || Rc != null && Rc.Equals(other.Rc)) &&
                   (S == other.S || S != null && S.Equals(other.S)) &&
                   (Pd == other.Pd || Pd != null && Pd.Equals(other.Pd)) &&
                   (Rac == other.Rac || Rac != null && Rac.Equals(other.Rac)) &&
                   (Md == other.Md || Md != null && Md.Equals(other.Md)) &&
                   (Sl == other.Sl || Sl != null && Sl.Equals(other.Sl)) &&
                   (Avp == other.Avp || Avp != null && Avp.Equals(other.Avp)) &&
                   (Sm == other.Sm || Sm != null && Sm.Equals(other.Sm)) &&
                   (Id == other.Id || Id != null && Id.Equals(other.Id)) &&
                   (Bsp == other.Bsp || Bsp != null && Bsp.Equals(other.Bsp)) &&
                   (Status == other.Status || Status != null && Status.Equals(other.Status)) &&
                   (Sr == other.Sr || Sr != null && Sr.Equals(other.Sr)) &&
                   (Cd == other.Cd || Cd != null && Cd.Equals(other.Cd)));
        }
Пример #13
0
        public void solve_position_cornerTest()
        {
            var tests = new[]
            {
                "B B B B B B B B B R O R Y Y Y Y Y Y Y R O O O O O O O W W Y W W W W W W O Y W R R R R R R G G G G G G G G G",
                "R R R R R R R R R G B Y B B B B B B B W B W W W W W W W G G G G G G G G Y Y W Y Y Y Y Y Y O O O O O O O O O",
                "B B B B B B B B B Y R Y O O O O O O O Y W W W W W W W R O O R R R R R R W W R Y Y Y Y Y Y G G G G G G G G G"
            };

            var negativetests = new[]
            {
                "B B B B B B B B B Y R Y O O O O O O O Y W W W W W W W R O R R R R R R R W W R Y Y Y Y Y Y G G G G G G G G G"
            };

            foreach (var test in tests)
            {
                Rc.set_cube(test);
                Solver.solve_position_corner();
                Assert.IsTrue(validate_up_corner_positions(), "solve_position_cornerTest FAILED");
            }
            foreach (var test in negativetests)
            {
                Rc.set_cube(test);
                try
                {
                    Solver.solve_position_corner();
                    Assert.IsFalse(validate_up_corner_positions(), "solve_position_cornerTest FAILED");
                }
                catch
                {
                    Assert.IsFalse(validate_up_corner_positions(), "solve_position_cornerTest FAILED");
                }
            }
        }
Пример #14
0
        public void solve_position_edgesTest()
        {
            var tests = new[]
            {
                "O O O O O O O O O Y G Y Y Y Y Y Y Y G B G G G G G G G W W W W W W W W W B Y B B B B B B B R R R R R R R R R",
                "B B B B B B B B B O Y O O O O O O O W R W W W W W W W R W R R R R R R R Y O Y Y Y Y Y Y Y G G G G G G G G G"
            };

            var negativetests = new[]
            {
                "B B B B B B B B B G G O O O O O O O W R W W W W W W W R W R R R R R R R Y O Y Y Y Y Y Y Y G G G G G G G G G"
            };

            foreach (var test in tests)
            {
                Rc.set_cube(test);
                Solver.solve_position_edges();
                Assert.IsTrue(Rc.issolved(), "solve_position_edgesTest FAILED");
            }
            foreach (var test in negativetests)
            {
                Rc.set_cube(test);
                try
                {
                    Solver.solve_position_edges();
                    Assert.IsFalse(validate_up_corner_positions(), "solve_position_edgesTest FAILED");
                }
                catch
                {
                    Assert.IsFalse(validate_up_corner_positions(), "solve_position_edgesTest FAILED");
                }
            }
        }
Пример #15
0
        static void UpdateTreeStyle(Cairo.Color newBgColor)
        {
            string oddRowColor, bgColor;

            bgColor = CairoExtensions.ColorGetHex(newBgColor);
            if (bgColor == currentBgColor)
            {
                return;
            }

            if (IdeApp.Preferences.UserInterfaceTheme == Ide.Theme.Light)
            {
                oddRowColor = CairoExtensions.ColorGetHex(newBgColor.AddLight(-0.02));
            }
            else
            {
                oddRowColor = CairoExtensions.ColorGetHex(newBgColor.AddLight(-0.02));
            }

            string rc = "style \"" + innerTreeName + "\" = \"treeview\" {\n";

            rc += string.Format("GtkTreeView::odd-row-color = \"{0}\"\n", oddRowColor);
            rc += string.Format("base[NORMAL] = \"{0}\"\n", bgColor);
            rc += "\n}\n";
            rc += string.Format("widget \"*.{0}\" style \"{0}\" ", innerTreeName);

            Rc.ParseString(rc);
            currentBgColor = bgColor;
        }
Пример #16
0
 private void openOToolStripMenuItem_Click(object sender, EventArgs e)
 {
     if (openFileDialog1.ShowDialog() == System.Windows.Forms.DialogResult.OK)
     {
         this.textBox1.Text = Rc.loadData(openFileDialog1.FileName);
         EditingPath        = openFileDialog1.FileName;
     }
 }
Пример #17
0
 private void saveSToolStripMenuItem_Click(object sender, EventArgs e)
 {
     if (saveFileDialog1.ShowDialog() == System.Windows.Forms.DialogResult.OK)
     {
         Rc.saveData(this.textBox1.Text, saveFileDialog1.FileName);
         EditingPath = saveFileDialog1.FileName;
     }
 }
Пример #18
0
 static DockItem()
 {
     Rc.ParseString("style \"gdl-dock-item-default\" {\n" +
                    "xthickness = 0\n" +
                    "ythickness = 0\n" +
                    "}\n" +
                    "class \"Gdl_DockItem\" " +
                    "style : gtk \"gdl-dock-item-default\"\n");
 }
Пример #19
0
 static DockNotebook()
 {
     Rc.ParseString("style \"gdl-dock-notebook-default\" {\n" +
                    "xthickness = 2\n" +
                    "ythickness = 2\n" +
                    "}\n" +
                    "widget_class \"*.GtkNotebook.Gdl_DockItem\" " +
                    "style : gtk \"gdl-dock-notebook-default\"\n");
 }
Пример #20
0
 /// <summary>
 /// The check of a return code
 /// </summary>
 /// <param name="rc">Return code </param>
 /// <returns>OK or not</returns>
 /// <remarks>If not OK, return false after displaying message.</remarks>
 private bool CheckReturnCode(Rc rc)
 {
     if (rc == Rc.Ok)
     {
         return(true);
     }
     MessageBox.Show(this, string.Format("Error: 0x{0,8:x}", rc), this.Text, MessageBoxButtons.OK, MessageBoxIcon.Error);
     return(false);
 }
Пример #21
0
        public async Task ClientMultipleComputationsAndIterators()
        {
            var NUM_COMPUTATIONS = 1000;
            var grain            = GrainFactory.GetGrain <IMyOtherReactiveGrain>(random.Next());

            var Rcs = new List <IReactiveComputation <string[]> >();

            for (var i = 0; i < NUM_COMPUTATIONS; i++)
            {
                Rcs.Add(GrainFactory.StartReactiveComputation(async() =>
                {
                    var res1 = await grain.GetValue(1);
                    var res2 = await grain.GetValue(1);
                    var res3 = await grain.GetValue(2);
                    return(new[] { res1, res2, res3 });
                }));
            }

            var Its1 = Rcs.Select((rc) => rc.GetResultEnumerator()).ToList();
            var Its2 = Rcs.Select((rc) => rc.GetResultEnumerator()).ToList();


            var NextResults1 = await Task.WhenAll(Its1.Select((it) => it.NextResultAsync()).ToList());

            var NextResults2 = await Task.WhenAll(Its2.Select((it) => it.NextResultAsync()).ToList());

            foreach (var NextResult1 in NextResults1)
            {
                Assert.Equal(NextResult1, new[] { "foo", "foo", "foo" });
            }
            foreach (var NextResult2 in NextResults2)
            {
                Assert.Equal(NextResult2, new[] { "foo", "foo", "foo" });
            }

            await grain.SetValue("bar");

            // wait for all updates to propagate
            await Task.Delay(3000);

            NextResults1 = await Task.WhenAll(Its1.Select((it) => it.NextResultAsync()).ToList());

            NextResults2 = await Task.WhenAll(Its2.Select((it) => it.NextResultAsync()).ToList());

            foreach (var NextResult1 in NextResults1)
            {
                Assert.Equal(NextResult1, new string[] { "bar", "bar", "bar" });
            }
            foreach (var NextResult2 in NextResults2)
            {
                Assert.Equal(NextResult2, new[] { "bar", "bar", "bar" });
            }
            foreach (var Rc in Rcs)
            {
                Rc.Dispose();
            }
        }
Пример #22
0
        static public string GetErrorMessage(Rc rc)
        {
            try
            {
                switch (rc)
                {
                case Rc.ErrOpenDevice:
                    return("Failed to open the device");

                case Rc.ErrNoDevice:
                    return("Device not open");

                case Rc.ErrSend:
                    return("Command send error");

                case Rc.ErrReceive:
                    return("Response reception error");

                case Rc.ErrTimeout:
                    return("Timeout");

                case Rc.ErrNomemory:
                    return("No free space");

                case Rc.ErrParameter:
                    return("Parameter error");

                case Rc.ErrRecvFmt:
                    return("Received header format error");

                case Rc.ErrHispeedNoDevice:
                    return("Not open error (for high-speed communication)");

                case Rc.ErrHispeedOpenYet:
                    return("Already open error (for high-speed communication)");

                case Rc.ErrHispeedRecvYet:
                    return("Already performing high-speed communication error (for high-speed communication)");

                case Rc.ErrBufferShort:
                    return("Insufficient buffer size");

                case Rc.Ok:
                    return(" Normal termination");

                default:
                    return(" Unknown Error Return Code: " + string.Format(" 0x{0,8:x}", rc));
                }
            }
            catch (Exception)
            {
                throw;
            }
        }
 public override int GetHashCode()
 {
     unchecked
     {
         var result = Nazev?.GetHashCode() ?? 0;
         result = (result * 397) ^ ICO?.GetHashCode() ?? 0;
         result = (result * 397) ^ Rc?.GetHashCode() ?? 0;
         result = (result * 397) ^ Role?.GetHashCode() ?? 0;
         return(result);
     }
 }
Пример #24
0
 public void StopStorage()
 {
     try
     {
         rc = (Rc)NativeMethods.LJV7IF_StopStorage(_currentDeviceId);
         CheckReturnValue(rc);
     }
     catch (Exception)
     {
         throw;
     }
 }
Пример #25
0
 void TriggerSingle()
 {
     try
     {
         rc = (Rc)NativeMethods.LJV7IF_Trigger(_currentDeviceId);
         CheckReturnValue(rc);
     }
     catch (Exception)
     {
         throw;
     }
 }
Пример #26
0
        public static void Main(string[] args)
        {
            var theme = "ambiance_radiance_flat_blue.gtkrc";

            Application.Init();
            Rc.AddDefaultFile(theme);
            Rc.Parse(theme);
            var win = new MainWindow();

            win.Show();
            Application.Run();
        }
Пример #27
0
        /// <summary>
        /// 高速データ通信「終了」ボタン押下
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void _btnEndHighSpeed_Click(object sender, EventArgs e)
        {
            // 高速データ通信停止
            Rc rc = (Rc)NativeMethods.LJV7IF_StopHighSpeedDataCommunication(DEVICE_ID);

            if (CheckReturnCode(rc))
            {
                // 高速データ通信終了
                rc = (Rc)NativeMethods.LJV7IF_HighSpeedDataCommunicationFinalize(DEVICE_ID);
                CheckReturnCode(rc);
            }
        }
        public int EditUser(ApplicationUser appUser)
        {
            ApplicationUser applicationUser = GetUserById(appUser.Id);

            applicationUser.Name          = appUser.Name;
            applicationUser.Email         = appUser.Email;
            applicationUser.BirthDate     = appUser.BirthDate;
            applicationUser.WalletAddress = appUser.WalletAddress;
            applicationUser.State         = appUser.State;
            applicationUser.Country       = appUser.Country;
            return(Rc.SaveChanges());
        }
Пример #29
0
        /// <summary>
        /// High-speed data communication "Exit" button pressed.
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void _btnEndHighSpeed_Click(object sender, EventArgs e)
        {
            // Stop high-speed data communication.
            Rc rc = (Rc)NativeMethods.LJV7IF_StopHighSpeedDataCommunication(DEVICE_ID);

            if (CheckReturnCode(rc))
            {
                // Exit high-speed data communication.
                rc = (Rc)NativeMethods.LJV7IF_HighSpeedDataCommunicationFinalize(DEVICE_ID);
                CheckReturnCode(rc);
            }
        }
Пример #30
0
        /// <summary>
        /// "High-speed mode get profiles" button pressed.
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void _btnGetProfile_Click(object sender, EventArgs e)
        {
            LJV7IF_GET_PROFILE_REQ req = new LJV7IF_GET_PROFILE_REQ();

            req.byTargetBank = ProfileBank.Active;
            req.byPosMode    = ProfilePos.Current;
            req.dwGetProfNo  = 0;
            req.byGetProfCnt = 10;
            req.byErase      = 0;

            LJV7IF_GET_PROFILE_RSP rsp         = new LJV7IF_GET_PROFILE_RSP();
            LJV7IF_PROFILE_INFO    profileInfo = new LJV7IF_PROFILE_INFO();

            int profileDataSize = MAX_PROFILE_COUNT +
                                  (Marshal.SizeOf(typeof(LJV7IF_PROFILE_HEADER)) + Marshal.SizeOf(typeof(LJV7IF_PROFILE_FOOTER))) / sizeof(int);

            int[] receiveBuffer = new int[profileDataSize * req.byGetProfCnt];

            using (ProgressForm progressForm = new ProgressForm())
            {
                Cursor.Current = Cursors.WaitCursor;

                progressForm.Status = Status.Communicating;
                progressForm.Show(this);
                progressForm.Refresh();

                // Get profiles.
                using (PinnedObject pin = new PinnedObject(receiveBuffer))
                {
                    Rc rc = (Rc)NativeMethods.LJV7IF_GetProfile(DEVICE_ID, ref req, ref rsp, ref profileInfo, pin.Pointer,
                                                                (uint)(receiveBuffer.Length * sizeof(int)));
                    if (!CheckReturnCode(rc))
                    {
                        return;
                    }
                }

                // Output profile data
                List <ProfileData> profileDatas = new List <ProfileData>();
                int unitSize = ProfileData.CalculateDataSize(profileInfo);
                for (int i = 0; i < rsp.byGetProfCnt; i++)
                {
                    profileDatas.Add(new ProfileData(receiveBuffer, unitSize * i, profileInfo));
                }

                progressForm.Status = Status.Saving;
                progressForm.Refresh();

                // Save file
                SaveProfile(profileDatas, _txtSavePath.Text);
            }
        }
Пример #31
0
        private static async Task MainLoop( ConsoleColor bgc, ConsoleColor ec, ConsoleColor mc, int delay)
        {
            var r = new Random();
            int w = Console.WindowWidth, h = Console.WindowHeight;
            var chars = new Rc[h][];
            for ( int i = 0; i < h; i++ ) chars[ i ] = new Rc[w];
            for ( int i = 0; i < h; i++ ) {
                var c = chars[ i ];
                for ( int j = 0; j < w; j++ )
                    c[ j ] = new Rc { Char = (char) r.Next( 34, 127 ), Color = bgc };
            }
            //lines
            var lines = new Line[w];
            for ( int i = 0; i < w; i++ ) {
                var l = new Line { Height = r.Next( 4, h ) };
                l.Position = -h + r.Next( 0, h - l.Height + 1 );
                l.Speed = r.Next( 1, 4 );
                lines[ i ] = l;
            }
            var tid = 0UL;
            while ( true ) {
                var del = Task.Delay( delay );
                if ( Console.WindowHeight!=h || Console.WindowWidth!=w) {
                    return;
                }
                ++tid;
                //move
                var tid1 = tid;
                foreach (var line in lines.Where(line => tid1 % (ulong) line.Speed == 0UL))
                    line.Position = line.Position < h ? line.Position + 1 : -line.Height;

                //update chars
                for (var i = 0; i < lines.Length; i++ ) {
                    var line = lines[ i ];

                    var top = line.Position;
                    var bottom = top + line.Height - 1;

                    var topU = top < h;
                    var topD = top >= 0;
                    var topV = topU && topD;
                    var bottomU = bottom >= 0;
                    var bottomD = bottom < h;
                    var bottomV = bottomU && bottomD;
                    if ( bottomV || topV ) { //visible
                        if ( bottomV ) chars[ bottom ][ i ].Color = ec;
                        if ( topV ) chars[ top ][ i ].Color = ec;

                        var ms = Math.Max( 0, Math.Min( h, top+1 ) );
                        var me = Math.Max( 0, Math.Min( h, bottom ) );
                        for (var j = ms; j < me; j++ ) chars[ j ][ i ].Color = mc;

                        if ( topV )
                            for (var j = 0; j < top - 1; j++ )
                                chars[ j ][ i ].Color = bgc;
                        if (!bottomV) continue;
                        {
                            for ( var j = bottom+1; j < h; j++ )
                                chars[ j ][ i ].Color = bgc;
                        }
                    }
                    else
                        for (var j = 0; j < h; j++ )
                            chars[ j ][ i ].Color = bgc;
                }

                //render
                var cc = Console.ForegroundColor;
                int flushes = 0,
                    cf = 0,
                    pf = 0,
                    wf = 0;
                for ( var i = 0; i < h; i++ )
                {
                    var c = chars[ i ];
                    var pc = false;
                    for ( var j = 0; j < w; j++ ) {
                        var cur = c[ j ];
                        if ( cur.Changed && !(j==w-1&&i==h-1))
                        {
                            if ( !pc ) {
                                if ( !SetCursorPosition( j, i ) ) return;
                                flushes++;
                                pf++;
                            }
                            pc = true;
                            if (cc != cur.Color)
                            {
                                Console.ForegroundColor = cur.Color;
                                cc = cur.Color;
                                flushes++;
                                cf++;
                            }
                            {
                                Console.Write( cur.Char );
                                flushes++;
                                wf++;
                            }
                            cur.Changed = false;
                        }
                        else pc = false;
                    }
                    
                }
                await del.ConfigureAwait( false );
            }
        }
Пример #32
0
 /// <summary>
 /// Return code check
 /// </summary>
 /// <param name="rc">Return code</param>
 /// <returns>Is the return code OK?</returns>
 /// <remarks>If the return code is not OK, display a message and return false.</remarks>
 private bool CheckReturnCode(Rc rc)
 {
     if (rc == Rc.Ok) return true;
     MessageBox.Show(this, string.Format("Error: 0x{0,8:x}", rc), this.Text, MessageBoxButtons.OK, MessageBoxIcon.Error);
     return false;
 }