static void Main()
        {
            // Create an instance of the GSM class
            Thread.CurrentThread.CurrentCulture = CultureInfo.GetCultureInfo("en-GB");
            Display display = new Display(2.5F, "256K");
            Battery battery = new Battery(950, 35, BatteryType.LiIon);
            GSM gsmTest = new GSM("Samsung Ace", "Samsung Group", 545.00M, "Ivan Ivanov", battery, display);

            //Add few calls
            DateTime date = DateTime.Now;
            gsmTest.AddCallInHistory(date, "0889909988", 65);
            gsmTest.AddCallInHistory(date.AddHours(1), "0889969988", 25);
            gsmTest.AddCallInHistory(date.AddHours(2), "0883909988", 3600);
            gsmTest.AddCallInHistory(date.AddHours(6.5), "0889969988", 1000);

            //Display the information about the calls.
            Console.WriteLine("Print the call hisory of phone {0}", gsmTest.ModelOfGSM);
            Console.WriteLine(gsmTest.PrintCallHistory());

            //Assuming that the price per minute is 0.37 calculate and print the total price of the calls in the history
            //use readonly modificator about pricePerminute
            Console.ForegroundColor = ConsoleColor.Red;
            Console.WriteLine("Total price of calls is: {0}", gsmTest.CalcucateTotalPrice(0.37M));

            Console.ForegroundColor = ConsoleColor.Gray;
            //Remove the longest call from the history and calculate the total price again.
            gsmTest.RemoveCallByLongestDuration();
            Console.WriteLine(gsmTest.PrintCallHistory());

            //Finally clear the call history and print it.
            gsmTest.ClearCallHistory();
            Console.WriteLine(gsmTest.PrintCallHistory());
        }
Beispiel #2
0
        /// <summary>
        /// Handle a request.
        /// </summary>
        /// <param name="pDisplay">The display which called this function.</param>
        /// <param name="pSurface">The surface which this display is hosted on.</param>
        /// <param name="dArguments">A dictionary of arguments which are passed to the function as parameters.</param>
        /// <returns>True if the request was processed sucessfully.  False if there was an error.</returns>
        public bool ProcessRequest(Display pDisplay, Surface pSurface, JSObject dArguments)
        {
            // Check we have a sound file.
            var sSound = dArguments.GetValueOrDefault("file", "");
            if (sSound == null || sSound == "")
            {
                Log.Write("Cannot play sound.  Are you missing a 'file' parameter.", pDisplay.ToString(), Log.Type.DisplayWarning);
                return false;
            }

            // Attempt to play it.
            try
            {
                SoundPlayer pSound = new SoundPlayer(sSound);
                pSound.Play();
                return true;
            }
            
            // Log warnings.
            catch (Exception e)
            {
                Log.Write("Cannot play sound. " + e.Message, pDisplay.ToString(), Log.Type.DisplayWarning);
                return false;
            }
        }
Beispiel #3
0
 public GSM(string model, string manufacturer, decimal? price, string owner, Battery battery, Display display)
     : this(model, manufacturer, price)
 {
     this.owner = owner;
     this.Battery = battery;
     this.Display = display;
 }
Beispiel #4
0
    static void Main()
    {
        GSM gsm = new GSM("nokia", "nokiaman");
        GSM gsm1 = new GSM("nokia", "nok", 9.5m);
        Battery bat = new Battery("monbat", 500, 100, BatteryType.NiMH);
        Display dis = new Display(null, 256);

        GSM gsm2 = new GSM("erik", "erik", bat);
        GSM gsm3 = new GSM("koko", "ka", dis);

        Console.WriteLine(gsm.ToString());
        Console.WriteLine("-----");
        Console.WriteLine(gsm1.ToString());
        Console.WriteLine("-----");
        Console.WriteLine(gsm2.ToString());
        Console.WriteLine("-----");
        Console.WriteLine(gsm3.ToString());

        Console.WriteLine("---------------------------");

        GSM p = GSM.IPhone4S;
        p.Owner = "pesho";
        p.Battery = bat;
        Console.WriteLine(p.ToString());

        GSMCallHistoryTest.Test();




    }
Beispiel #5
0
        /// <summary>
        /// Handle a request.
        /// </summary>
        /// <param name="pDisplay">The display which called this function.</param>
        /// <param name="pSurface">The surface which this display is hosted on.</param>
        /// <param name="dArguments">A dictionary of arguments which are passed to the function as parameters.</param>
        /// <returns>True if the request was processed sucessfully.  False if there was an error.</returns>
        public bool ProcessRequest(Display pDisplay, Surface pSurface, JSObject dArguments)
        {
            // Check we have a function to return the results too.
            if (!dArguments.HasProperty("callback")) throw new Exception("Missing 'callback' argument.");

            // Return a list of surface names.
            JSValue[] lSurfaces = (from pSurf in Authority.Surfaces select new JSValue(pSurf.Identifier)).ToArray();

            // If that function is a string.
            var jsValue = dArguments["callback"];
            if (jsValue.IsString)
            {
                pDisplay.AsyncCallGlobalFunction(jsValue.ToString(), lSurfaces);
                return true;
            }

            /*
            // If it is a function.
            else if (jsValue.IsObject)
            {
                ((JSObject)jsValue).Invoke("call", lSurfaces);
                return true;
            }
            */

            // Throw the error.
            throw new Exception("Unknown type specified in 'callback' argument.  Expected string.");
        }
Beispiel #6
0
 //full specs without owner
 public GSM(string model, string manufacturer, decimal price, Battery battery, Display display)
     : this(model, manufacturer, price)
 {
     this.Battery = battery;
     this.Display = display;
     this.Owner = null;
 }
 public override Source CreateNewSource(Slide slide, ModuleConfiguration moduleConfiguration, Dictionary<String, IList<DeviceResourceDescriptor>> resources, Display display)
 {
     return new ArcGISMapSourceDesign 
     { 
         Type = this
     };
 }
Beispiel #8
0
        public void Execute(LiteEngine engine, StringScanner s, Display display, InputCommand input, Env env)
        {
            var col = this.ReadCollection(engine, s);
            var index = s.Scan(this.FieldPattern).Trim();

            display.WriteResult(engine.Max(col, index.Length == 0 ? "_id" : index));
        }
Beispiel #9
0
        public override void Execute(LiteShell shell, StringScanner s, Display display, InputCommand input)
        {
            if(s.Scan("false|off").Length > 0 && _writer != null)
            {
                display.TextWriters.Remove(_writer);
                input.OnWrite = null;
                _writer.Flush();
                _writer.Dispose();
                _writer = null;
            }
            else if(_writer == null)
            {
                if (shell.Database == null) throw LiteException.NoDatabase();

                var dbfilename = shell.Database.ConnectionString.Filename;
                var path = Path.Combine(Path.GetDirectoryName(dbfilename),
                    string.Format("{0}-spool-{1:yyyy-MM-dd-HH-mm}.txt", Path.GetFileNameWithoutExtension(dbfilename), DateTime.Now));

                _writer = File.CreateText(path);

                display.TextWriters.Add(_writer);

                input.OnWrite = (t) => _writer.Write(t);
            }
        }
        static void Main()
        {
            GSM[] mobilePhones = new GSM[3];

            GSM nokia = new GSM("3310", "Nokia");

            nokia.AddHistory(DateTime.Now, 0998080907, 1.08);
            nokia.AddHistory(DateTime.Now, 0998080907, 2132331.08);
            nokia.DeleteHistory(1);

            Battery sonyBattery5511 = new Battery("77ds7", 220, 10, BatteryType.NiMH);
            Display sonyDisplay5511 = new Display(23, 128);
            GSM sony = new GSM("5511", "Sony", 100.77m, "Pesho", sonyBattery5511, sonyDisplay5511);

            GSM samsung = new GSM("4433", "samsung", 50.22m, "Gosho");

            mobilePhones[0] = nokia;
            mobilePhones[1] = sony;
            mobilePhones[2] = samsung;

            //Console.WriteLine(nokia.CalcPriceHistory(2.2m));
            for (int i = 0; i < mobilePhones.Length; i++)
            {
                Console.WriteLine(mobilePhones[i]);
            }
        }
Beispiel #11
0
        public override bool Execute()
        {
            Image image = null;
              if (File.Exists(_path))
            {
              image = Image.Load(RunMode.Noninteractive, _path, _path);
            }
              else
            {
              var choose = new FileChooserDialog("Open...",
                         null,
                         FileChooserAction.Open,
                         "Cancel", ResponseType.Cancel,
                         "Open", ResponseType.Accept);
              if (choose.Run() == (int) ResponseType.Accept)
            {
              string fileName = choose.Filename;
              image = Image.Load(RunMode.Noninteractive, fileName, fileName);
            };
              choose.Destroy();
            }

              if (image != null)
            {
              image.CleanAll();
              ActiveDisplay = new Display(image);
              ActiveImage = image;
              return true;
            }

              return false;
        }
	/// <summary>
	/// <para>Construct a DCOP client handler to process DCOP messages.</para>
	/// </summary>
	///
	/// <param name="dpy">
	/// <para>The display to attach to the DCOP connection's message
	/// processor.</para>
	/// </param>
	///
	/// <param name="registerName">
	/// <para>The name of the application to register with DCOP, or
	/// <see langword="null"/> to register anonymously.</para>
	/// </param>
	///
	/// <param name="addPID">
	/// <para>Set to <see langword="true"/> to add the process ID to
	/// the registered name.</para>
	/// </param>
	///
	/// <exception cref="T:Xsharp.Dcop.DcopException">
	/// <para>Raised if the connection to the DCOP server could not be
	/// established.</para>
	/// </exception>

	public DcopClient(Display dpy, String registerName, bool addPID)
			: base(dpy, "DCOP", "KDE", "2.0", 2, 0, GetDcopServer(dpy))
			{
				// Construct the full registration name for the DCOP client.
				if(registerName == null)
				{
					registerName = "anonymous";
				}
			#if CONFIG_EXTENDED_DIAGNOSTICS
				if(addPID)
				{
					int pid = Process.GetCurrentProcess().Id;
					if(pid != -1 && pid != 0)
					{
						registerName += "-" + pid.ToString();
					}
				}
			#endif

				replyId = 0;
				key = new byte[4];

				// Register the name with the DCOP server.
				appId = registerAs(registerName);

				mainClient = this;

			}
Beispiel #13
0
 //initialize the static iPhone GSM
 static GSM()
 {
     DisplaySize iPhoneDisplaySize = new DisplaySize(1136, 640);
     Display iPhoneDisplay = new Display(32000, iPhoneDisplaySize);
     Battery iPhoneBattery = new Battery("Samsung", 24, 24, BatteryType.LiIon);
     iPhone4S = new GSM("4S", "Apple", 1000000, iPhoneDisplay, iPhoneBattery);
 }
    public static List<Display> GetList(String quotaion_no)
    {
        List<Display> list = new List<Display>();
        var idlist = from q in db.Quotation_Version
                 where q.Quotation_No.Equals(quotaion_no) & q.Quotation_Status == 5
                 select q.Quotation_Version_Id;
        //var data = from qt in db.Quotation_Target from q in list from c in db.country where idlist.Contains((int)qt.quotation_id) & qt.country_id == c.country_id select new { Text = qt.target_description + "(" + q.No + " - "+q.Version  +") - [" + c.country_name + "]", Id = qt.Quotation_Target_Id, Version = q.Version };
        var data = from qt in db.Quotation_Target from c in db.country where idlist.Contains((int)qt.quotation_id) & qt.country_id == c.country_id select new { Text = qt.target_description, CountryName = c.country_name, Id = qt.Quotation_Target_Id, qId = qt.quotation_id };
        foreach (var item in data)
        {
          Display dis = new Display();
          var lists = from q in db.Quotation_Version
                  where q.Quotation_Version_Id == item.qId
                  select new
                  {
                    No = q.Quotation_No,
                    Version = q.Vername,
                    Id = q.Quotation_Version_Id
                  };
          dis.Text = item.Text + "(" + lists.First().No + " - V" + lists.First().Version + ") - [ " + item.CountryName + " ]";
          dis.Id = item.Id.ToString();
          list.Add(dis);
        }

        return list;
    }
Beispiel #15
0
        public override void Execute(ref IShellEngine engine, StringScanner s, Display display, InputCommand input)
        {
            if (engine == null) throw ShellExpcetion.NoDatabase();

            var direction = s.Scan(@"[><]\s*").Trim();
            var filename = s.Scan(@".+").Trim();

            //dump import
            if(direction == "<")
            {
                using (var reader = new StreamReader(filename, Encoding.UTF8))
                {
                    string line;
                    while ((line = reader.ReadLine()) != null)
                    {
                        engine.Run(line, new Display()); // no output
                    }
                }
            }
            // dump export
            else
            {
                using (var writer = new StreamWriter(filename, false, Encoding.UTF8, 65536))
                {
                    writer.AutoFlush = true;
                    writer.WriteLine("-- LiteDB v{0}.{1}.{2} dump file @ {3}", 
                        engine.Version.Major, engine.Version.Minor, engine.Version.Build,
                        DateTime.Now);
                    engine.Dump(writer);
                    writer.Flush();
                }
            }
        }
Beispiel #16
0
 static void Main()
 {
     Display testDisplay = new Display(14, 16.5f);
         Battery testBattery = new Battery("test");
         GSM myPhone = new GSM("test", "test", "Owner",1234, testBattery, testDisplay);
         Console.WriteLine(myPhone.display.Size);
 }
    private static void Main()
    {
        // Generate some test batteries and displays
        var premiumDisplay = new Display(4.5, Display.ColorDepth._32Bit);
        var mediocreDisplay = new Display(3.5, Display.ColorDepth._16Bit);
        var poorDisplay = new Display(2.5, Display.ColorDepth._8bit);
        var premiumBattery = new Battery("Sanyo-SN532e", 120, 20, Battery.Type.LiPol);
        var mediocreBattery = new Battery("Shanzungmang-2341", 80, 15, Battery.Type.LiIon);
        var poorBattery = new Battery("Mistucura-1224fe", 40, 5, Battery.Type.NiMH);

        // initilize gsms in the array
        var gsmArray = new GSM[4];
        gsmArray[0] = new GSM("One", "HTC", "Kiro", premiumDisplay, premiumBattery, 200);
        gsmArray[1] = new GSM("Blade", "Zte");
        gsmArray[2] = new GSM("Galaxy S4", "Samsung", "Misho", premiumDisplay, mediocreBattery, 1000);
        gsmArray[3] = new GSM("Ascend G600", "Huawei",  "Mtel", premiumDisplay, 
            new Battery("Toshiba-tbsae", 380, 6, Battery.Type.LiPol), 600);

        // print the gsms
        foreach (var phone in gsmArray)
        {
            Console.WriteLine(phone);
        }

        // print the static property Iphone4S
        Console.WriteLine(GSM.Iphone4S);

        // test GsmCallHistory
        GSMCallHistoryTest.Test();
    }
        static void Main(string[] args)
        {
            try
            {
                //Create battery and display for the GSM
                Battery battery = new Battery("BL-5C",360,7,Battery.BatteryType.LithiumLon);
                Display display = new Display(3,65536);
                //Create GSM
                GSM gsm = new GSM("1208", "nokia", 50, "Georgi", battery, display);
                //Console.WriteLine(gsm.ToString()); //Print GSM data

                //Mace some calls and print the history
                gsm.AddCall(new Call(new DateTime(2013, 02, 22, 19, 01, 22), "00359888888888", 200));
                gsm.AddCall(new Call(new DateTime(2013,02,22,20,02,33),"0887888888",302));
                gsm.AddCall(new Call(new DateTime(2013, 02, 22, 20, 30, 19), "0889-88-88-88", 178));
                gsm.PrintCallHistiry();
                //Calculate the price of all calls
                decimal price = 0.37m;
                gsm.CalculateTotalCallsPrice(price);

                //Remove the longest call and calculate the price again
                gsm.DeleteCall(1); //The calls in the list start from 0, so the second call(longest) is 1
                gsm.CalculateTotalCallsPrice(price);

                //Clear the history and print it
                gsm.ClearCallHistory();
                gsm.PrintCallHistiry();

            }
            catch (Exception ex)
            {

                Console.WriteLine("Error!"+ex.Message);
            }
        }
Beispiel #19
0
        public void Execute(LiteEngine engine, StringScanner s, Display d, InputCommand input, Env env)
        {
            var sb = new StringBuilder();
            var enabled = !(s.Scan(@"off\s*").Length > 0);

            env.Log.Level = enabled ? Logger.FULL : Logger.NONE;
        }
Beispiel #20
0
    static void Main(string[] args)
    {
        GSM[] gsmArray = new GSM[3];

            Battery myBattery = new Battery("Nokia", 50,50, BatteryType.LiIon);
            Display myDisplay = new Display(10, 1000000);
            GSM firstGsm = new GSM("N8", "Nokia", 500, "Me", myBattery, myDisplay);
            gsmArray[0] = firstGsm;

            myBattery = new Battery("Samsung", 60, 60, BatteryType.NiCd);
            myDisplay = new Display(12, 1200000);
            GSM secondGsm = new GSM("Galaxy", "Samsung", 700, "Me", myBattery, myDisplay);
            gsmArray[1] = secondGsm;

            myBattery = new Battery("HTC", 40, 40, BatteryType.NiMH);
            myDisplay = new Display(8, 800000);
            GSM thirdGsm = new GSM("K8", "HTC", 450, "Me", myBattery, myDisplay);
            gsmArray[2] = thirdGsm;

            foreach (var item in gsmArray)
            {
                Console.WriteLine(item);
                Console.WriteLine();
            }
            Console.WriteLine(GSM.IPhone4S);

            GSMCallHistoryTest.Test();
    }
    public string GetCallbackResult()
    {
        //SAPDB db = new SAPDB();
        Display disp = new Display();
        //List<Employee> emps = db.getEmployeeListForCurrentDepartment(StartDateOfPeriod, EndDateOfPeriod, "00000050", "1", eventArgument);
        EmployeeList emp_list = new EmployeeList();
        List<Employee> emps = null;// emp_list.getEmployeesOfDepartment(eventArgument, employees);
        EmployeeComparerByPostASC cmpByPostASC = new EmployeeComparerByPostASC();
        emps.Sort(cmpByPostASC);
        string html = "";
        html += eventArgument;
        html += "||";
        //int k = 0;
        //for (int j = 0; j < 100; j++)
        /*foreach (Employee em in emps)
        {
            //k++;
            html += "<table cellpadding='0' cellspacing='0' border='0' class='employee'><tr><td class='employee_post'><div style='width: 105px; height: 80px; overflow: hidden;'>" + em.Post + "</div></td><td class='employee_id'>" + em.EmployeeID + "</td><td class='employee_name' ><img src='App_Resources/person.gif' style='cursor: hand; cursor: pointer;'>&nbsp<span style='cursor: hand; cursor: pointer;'  onclick='window.open(\"" + getCardUrl(em) + "\",\"_blank\",\"menubar=no,width=800,height=600,resizable=yes,scrollbars=yes\")'>" + em.FullName + CheckRedundantEmployee(em) + "</span></td><td>" + disp.DisplaySchedules(count_days, 18, em, em.PostID, eventArgument, hours, overhours, em.Schedule, em.ScheduleDeflection, role, check, closed, false) + "</td></tr></table>";

        }
        */
        html += "||";

        DevDescriptionDB devDB = new DevDescriptionDB();
        List<DevDescription> devdescription = devDB.getDevDescription();
        html += "<table cellpadding='0' cellspacing='0' border='0' width='100%'><tr><td align='center' colspan='2'><b>����������� � SAP</b></td></tr>";

        foreach (DevDescription dev in devdescription)
            html += "<tr><td width='30px' align='center'><b>" + dev.Symbols + "</b></td><td>" + dev.Name + "</td></tr>";

        html += "</table>";

        return html;
    }
Beispiel #22
0
 public override void Configure(Display.ChartComponent[] components_)
 {
   reset(components_);
   setComponent(components_[0], CTDValuePair.TY, 2d);
   setComponent(components_[1], CTDValuePair.CT5, -1d);
   setComponent(components_[2], CTDValuePair.CT10, -1d);
 }
Beispiel #23
0
        public void Execute(LiteEngine engine, StringScanner s, Display display, InputCommand input, Env env)
        {
            var col = this.ReadCollection(engine, s);
            var doc = JsonSerializer.Deserialize(s.ToString()).AsDocument;

            display.WriteResult(engine.Update(col, doc));
        }
Beispiel #24
0
        /// <summary>
        /// Handle a request.
        /// </summary>
        /// <param name="pDisplay">The display which called this function.</param>
        /// <param name="pSurface">The surface which this display is hosted on.</param>
        /// <param name="dArguments">A dictionary of arguments which are passed to the function as parameters.</param>
        /// <returns>True if the request was processed sucessfully.  False if there was an error.</returns>
        public bool ProcessRequest(Display pDisplay, Surface pSurface, JSObject dArguments)
        {
            // Find the new surface.
            var pTargetSurface = Authority.FindSurface(dArguments.GetValueOrDefault("target", ""));
            if (pTargetSurface == null)
            {
                Log.Write("Cannot swap display to target surface.  Missing valid 'target' parameter.", pDisplay.ToString(), Log.Type.DisplayWarning);
                return false;
            }

            // Check the surface this view is on is not our target.
            if (pTargetSurface == pDisplay.ActiveSurface)
            {
                Log.Write("Cannot swap display to target surface because it is already there.", pDisplay.ToString(), Log.Type.DisplayWarning);
                return false;
            }

            // If the target surface has a display, get a reference and remove it.
            Display pOtherView = pTargetSurface.ActiveDisplay;
            if (pOtherView != null)
                Authority.RemoveDisplay(pOtherView);

            // Remove this display from this surface and put it on the target surface.
            Authority.RemoveDisplay(pDisplay);
            Authority.ShowDisplay(pDisplay, pTargetSurface);

            // Now put the other display on the original surface.
            if (pOtherView != null)
                Authority.ShowDisplay(pOtherView, pSurface);

            // Boom.
            return true;
        }
        //[XmlIgnore]
        //[Browsable(false)]
        //public override bool IsSupportPreview
        //{
        //    get { return true; }
        //}


        public override Source CreateNewSource(Slide slide, ModuleConfiguration moduleConfiguration, Dictionary<string, IList<DeviceResourceDescriptor>> resources, Display display)
        {
            //IEDocumentSourceDesign source = new IEDocumentSourceDesign() { Type = this };
            //return source;

            return new IEDocumentSourceDesign { Type = this };
        }
Beispiel #26
0
        public static string Auth(string callbackUrl, string state, Scope scope = Scope.None, Display display = Display.Page)
        {
            var parameters = new List<Parameter> {
                new Parameter { Name = OAuth2Parameter.ConsumerID.Value(), Value = clientId },
                new Parameter { Name = OAuth2Parameter.CallbackUrl.Value(), Value = callbackUrl },
                new Parameter { Name = OAuth2Parameter.State.Value(), Value = state }
            };

            if (display != Display.Page)
                parameters.Add(new Parameter { Name = OAuth2Parameter.Display.Value(), Value = display.Value() });

            if (scope != Scope.None) {
                var permissionNames = new List<string>();
                if ((scope & Scope.Email) == Scope.Email)
                    permissionNames.Add(Scope.Email.Value());
                if ((scope & Scope.Birthday) == Scope.Birthday)
                    permissionNames.Add(Scope.Birthday.Value());
                if ((scope & Scope.Publish) == Scope.Publish)
                    permissionNames.Add(Scope.Publish.Value());

                if (permissionNames.Count > 0)
                    parameters.Insert(0, new Parameter { Name = OAuth2Parameter.Scope.Value(), Value = string.Join(scopeDelimiter, permissionNames) });
            }

            return Utils.CreateUri(AuthorizeEndpoint, parameters).AbsoluteUri;
        }
Beispiel #27
0
        public SlideLayout(IEnumerable<Display> ADisplays, Slide ASlide)
        {
            m_slide = ASlide;
            m_displays = new List<Display>();
            foreach (Display d in ADisplays)
            {
                if (!WeContainDisplay(d))
                {
                    AddDisplayToSlide(d);
                }
                else
                {
                    m_displays.Add(FindDisplay(d));
                }
            }

            if (m_displays.Count > 0)
            {
                m_windowList = new List<Window>(m_displays[0].WindowList);
                firstDisplay = m_displays.First();
            }
            else
                m_windowList = new List<Window>();

            UpdateDisplayLayout();
        }
Beispiel #28
0
    static void Main()
    {
        DateTime date1 = new DateTime(2013, 5, 24, 11, 11, 30);
        DateTime date2 = new DateTime(2013, 5, 24, 15, 23, 2);
        DateTime date3 = new DateTime(2013, 5, 31, 9, 00, 00);
        DateTime date4 = new DateTime(2013, 5, 31, 18, 12, 20);

        Call call1 = new Call(date1, "0888313233", 850);
        Call call2 = new Call(date2, "0888909090", 95);
        Call call3 = new Call(date3, "0889556677", 213);
        Call call4 = new Call(date4, "0888313233", 37);

        Battery battery = new Battery ("PX8", BatteryType.LiIon, 300, 8);
        Display display = new Display(4, 16000000);
        GSM gsm = new GSM("I900", "Samsung", 500, "Me", battery, display);

        gsm.AddCalls(call1);
        gsm.AddCalls(call2);
        gsm.AddCalls(call3);
        gsm.AddCalls(call4);

        foreach (var call in gsm.CallHistory)
        {
            Console.WriteLine(call);
        }

        Console.WriteLine("Total amount to pay: {0:C}",gsm.TotalCallsPrice);

        gsm.DeleteCalls(call1);
        Console.WriteLine("Total amount to pay: {0:C}", gsm.TotalCallsPrice);

        gsm.ClearHistory();
        Console.WriteLine("Total amount to pay: {0:C}", gsm.TotalCallsPrice);
    }
Beispiel #29
0
 static void Main(string[] args)
 {
     var display = new Display(Console.Out, Console.In);
     var problemLoader = new ProblemLoader(display);
     bool exit = false;
     while (!exit)
     {
         display.Write("Enter Problem Number ('q' to quit): ");
         var input = display.ReadLine();
         if (input == "q")
         {
             exit = true;
             continue;
         }
         try
         {
             int problemNumber = int.Parse(input);
             var problem = problemLoader.LoadProblem(problemNumber);
             problem.Run();
         }
         catch (Exception)
         {
             display.WriteLine("Problem Solution does not exist for {0}.", input);
         }
     }
 }
Beispiel #30
0
 public static void Init(Game game, SpriteBatch spriteBatch, Display display)
 {
     _game        = game;
     _spriteBatch = spriteBatch;
     _display     = display;
 }
Beispiel #31
0
        static void Main(string[] args)
        {
            #region Instantiering af dependencies
            IUsbCharger usbCharger = new UsbCharger();
            IDisplay    display    = new Display();
            IDoor       door       = new Door();
            ILogging    logging    = new LogFileDAL();
            IRFIDReader rfidReader = new RFIDReader();

            IChargeControl chargeControl = new ChargeControl(usbCharger);

            IStationControl stationControl = new StationControl(door, rfidReader, chargeControl, logging, display);
            #endregion


            bool finish = false;
            do
            {
                string input;
                System.Console.WriteLine("Indtast E (exit), O (open), C (close), R (rfid), P (phone): ");
                input = Console.ReadLine();
                if (string.IsNullOrEmpty(input))
                {
                    continue;
                }


                switch (input[0])
                {
                case 'E':
                case 'e':
                    finish = true;
                    break;

                case 'O':
                case 'o':
                    if (stationControl.State == PhoneLockerState.DoorOpen)
                    {
                        display.DisplayText("Ladedøren er allerede åben. Frakobl eller tilslut mobil.");
                        break;
                    }
                    else
                    {
                        stationControl.State = PhoneLockerState.DoorOpen;
                        display.DisplayText("Døren er åben");
                        display.DisplayText("Tilslut telefon");
                    }
                    break;

                case 'C':
                case 'c':
                    if (stationControl.State != PhoneLockerState.DoorOpen)
                    {
                        break;
                    }
                    stationControl.State = PhoneLockerState.Available;
                    display.DisplayText("Døren er lukket");
                    display.DisplayText("Scan venligst RFID");
                    break;

                case 'R':
                case 'r':
                    Console.Clear();
                    display.DisplayText("Indtast RFID id: ");
                    string idString = System.Console.ReadLine();

                    int id = Convert.ToInt32(idString);
                    rfidReader.ReadRFID(id);

                    break;

                case 'P':
                case 'p':
                    if (stationControl.State != PhoneLockerState.DoorOpen)
                    {
                        display.DisplayText("Døren er lukket. Åben før der kan tilsluttes.");
                        break;
                    }
                    if (chargeControl.Connected)
                    {
                        chargeControl.Connected = false;
                        display.DisplayText("Telefon frakoblet");
                    }
                    else
                    {
                        chargeControl.Connected = true;
                        display.DisplayText("Telefon tilsluttet");
                    }
                    break;

                default:
                    break;
                }
            } while (!finish);
        }
Beispiel #32
0
    private bool runAway()
    {
        Display.write("You run away from "); Display.write(monster.name, monster.color); Display.write(Environment.NewLine);
        Display.write(Environment.NewLine);
        for (int i = 0; i < 3; i++)
        {
            Display.write("..." + Environment.NewLine);
            Display.write(Environment.NewLine);
            Display.wait();
        }
        Display.write("Unfortunately, "); Display.wait();
        Display.write(monster.name, monster.color); Display.write(" catches you!"); Display.write(Environment.NewLine);
        Display.write(Environment.NewLine);
        Display.wait();

        player.getHurt(100);
        Display.write("..." + Environment.NewLine);
        Display.write(Environment.NewLine);

        return(false);
    }
Beispiel #33
0
        /// <summary>
        /// Process Attachments and Links creation. Has to be at the end
        /// </summary>
        /// <param name="imWorkItem"></param>
        /// <param name="setMigStatus"></param>
        private bool ProcessAttachmentsAndLinks(InMemoryWorkItem imWorkItem, bool setMigStatus)
        {
            bool retVal = true;

            Logger.Write(LogSource.WorkItemTracking, TraceLevel.Verbose,
                         "[{0}] attachments for work item [{1}]", imWorkItem.Attachments.Count, m_sourceWorkItemId);
            Logger.Write(LogSource.WorkItemTracking, TraceLevel.Verbose,
                         "[{0}] links for work item [{1}]", imWorkItem.Links.Count, m_sourceWorkItemId);
            try
            {
                // create new web service call xml fragment
                WSHelper webServiceHelper = new WSHelper(WSHelper.WebServiceType.UpdateWorkItem);

                webServiceHelper.SetWorkItemAndRevision(m_currentWorkItem.Id, ++m_revision);

                // process links
                if (imWorkItem.Links.Count > 0)
                {
                    foreach (InMemoryLinkItem imLink in imWorkItem.Links)
                    {
                        if (!IsLinkMigrated(imLink))
                        {
                            if (imLink.CurrituckLinkedId == -1)
                            {
                                // link cannot be set as well as description cannot be found in history
                                webServiceHelper.AddDescriptiveField(VSTSConstants.HistoryFieldRefName,
                                                                     String.Concat(VSTSUtil.ConverterComment, imLink.LinkDescription), true);
                            }
                            else
                            {
                                // set the link information in work item.. as a related link
                                webServiceHelper.AddLink(imLink.CurrituckLinkedId, imLink.LinkDescription);

                                // check if it is duplicate link and setting Duplicate WI is allowed
                                if (m_canSetDuplicateWiId &&
                                    imLink is InMemoryDuplicateLinkItem &&
                                    m_vstsConnection.store.FieldDefinitions.Contains(m_duplicateWiId))
                                {
                                    Logger.Write(LogSource.WorkItemTracking, TraceLevel.Info, "Creating Duplicate Link as Related Link from {0} to {1} with comment {2}",
                                                 m_currentWorkItem.Id, imLink.CurrituckLinkedId, imLink.LinkDescription);
                                    webServiceHelper.AddColumn(m_wi.Fields[m_duplicateWiId].ReferenceName, imLink.CurrituckLinkedId.ToString(CultureInfo.InvariantCulture));
                                }
                            } // end of else
                        }     // end of isLinkMigrated()
                        else
                        {
                            Logger.Write(LogSource.WorkItemTracking, TraceLevel.Warning,
                                         "Cannot add link as it already exists: {0}", imLink.CurrituckLinkedId);
                        }
                    }
                }

                // process attachments
                if (imWorkItem.Attachments.Count > 0)
                {
                    int    noOfAttachmentsProcessed = 0;
                    string areaNodeUri = GetAreaNodeUri(m_vstsWorkItem.areaId);
                    Debug.Assert(!String.IsNullOrEmpty(areaNodeUri), "No area node uri found");
                    foreach (InMemoryAttachment attach in imWorkItem.Attachments)
                    {
                        if (IsAttachmentMigrated(attach))
                        {
                            continue;
                        }
                        try
                        {
                            webServiceHelper.AddAttachment(attach.FileName, attach.Comment, attach.IsLinkedFile, areaNodeUri);
                        }
                        catch (ConverterException conEx)
                        {
                            // attachment upload failed.. add into migration report
                            string errMsg = UtilityMethods.Format(
                                VSTSResource.VstsAttachmentUploadFailed,
                                Path.GetFileName(attach.FileName),
                                m_sourceWorkItemId, conEx.Message);

                            ConverterMain.MigrationReport.WriteIssue(String.Empty, ReportIssueType.Error,
                                                                     errMsg, m_sourceWorkItemId.ToString(CultureInfo.InvariantCulture));
                            Display.DisplayError(errMsg);
                            // and make sure that Migration Status is not set
                            setMigStatus = false;
                            retVal       = false;
                        }
                        noOfAttachmentsProcessed++;

                        if (noOfAttachmentsProcessed % 32 == 0)
                        {
                            // save at every 32nd attachment
                            webServiceHelper.AddDescriptiveField(
                                VSTSConstants.HistoryFieldRefName,
                                UtilityMethods.Format(
                                    VSTSResource.VstsAttachmentLinkHistory), true);
                            Logger.Write(LogSource.WorkItemTracking, TraceLevel.Warning, "Performing interim save for work item {0} since no of attachments exceeds 32", m_sourceWorkItemId);
                            if (imWorkItem.Attachments.Count == noOfAttachmentsProcessed)
                            {
                                // boundary case .. this is the last attachment..
                                // set the Migration Status also
                                if (setMigStatus)
                                {
                                    webServiceHelper.AddColumn(VSTSConstants.MigrationStatusField, "Done");
                                }
                            }
                            webServiceHelper.Save();
                            if (noOfAttachmentsProcessed < imWorkItem.Attachments.Count)
                            {
                                // some attachemnts left.. reset the webserviceHelper handle
                                webServiceHelper = new WSHelper(WSHelper.WebServiceType.UpdateWorkItem);
                                webServiceHelper.SetWorkItemAndRevision(m_currentWorkItem.Id, ++m_revision);
                            }
                            else
                            {
                                // no more save required for the current work item
                                webServiceHelper = null;
                            }
                        } // end of if (noOfAttachmentsProcessed % 32 == 0)
                    }     // end of foreach attachments
                }

                if (webServiceHelper != null)
                {
                    webServiceHelper.AddDescriptiveField(
                        VSTSConstants.HistoryFieldRefName,
                        UtilityMethods.Format(
                            VSTSResource.VstsAttachmentLinkHistory), true);

                    // Set migration status field
                    if (setMigStatus)
                    {
                        webServiceHelper.AddColumn(VSTSConstants.MigrationStatusField, "Done");
                    }

                    webServiceHelper.Save();
                }
                SetCurrentWorkItem(m_currentWorkItem.Id);
            }
            finally
            {
            }
            return(retVal);
        }
Beispiel #34
0
 public override void Execute(ref IShellEngine engine, StringScanner s, Display display, InputCommand input)
 {
     input.Timer.Start();
 }
Beispiel #35
0
 public static void Main()
 {
     CreateItem.CreateNewItem();
     Display.DisplayItems();
     Display.DisplayItemsTotal()
 }
Beispiel #36
0
 protected void Refresh(object sender, EventArgs e)
 {
     Display.Refresh();
     //Display.Invalidate();
 }
Beispiel #37
0
 /// <summary>
 /// Check if this palyer can observe a certain display
 /// </summary>
 public bool IsDisplayObserver(Display display)
 {
     return(MtaServer.TextDisplayIsObserver(display.DisplayElement, element));
 }
Beispiel #38
0
 public override void Draw(DrawContext dc)
 {
     Display.Clear(ClearColor ? new Vector4?(new Vector4(Color)) : null, ClearDepth ? new float?(Depth) : null, ClearStencil ? new int?(Stencil) : null);
 }
Beispiel #39
0
        /// <summary>
        /// Processes screen saver arguments and initializes the screen saver.
        /// </summary>
        /// <param name="arguments">The command line arguments that have been passed into Main().</param>
        /// <exception cref="ArgumentException"></exception>
        public void Initialize(string[] arguments)
        {
            // No arguments specified, treat like /c.
            if (arguments.Length == 0)
            {
                ScreenSaverMode = ScreenSaverMode.Configure;
                OnShowConfiguration();
                return;
            }

            string firstArgument  = arguments[0].ToLower().Trim();
            string secondArgument = null;

            // Handle cases where arguments are separated by colon.
            // Example: /c:1234567 or /P:1234567 or /P|1234567 (Windows 10).
            if (firstArgument.Length > 2)
            {
                secondArgument = firstArgument.Substring(3).Trim();
                firstArgument  = firstArgument.Substring(0, 2);
            }
            else if (arguments.Length > 1)
            {
                secondArgument = arguments[1];
            }

            switch (firstArgument)
            {
            case "/c":
                ScreenSaverMode = ScreenSaverMode.Configure;
                OnShowConfiguration();
                break;

            case "/s":
                ScreenSaverMode = ScreenSaverMode.ScreenSaver;
                OnShowScreenSaver(Display.GetBounds());
                break;

            case "/p":
                if (secondArgument == null)
                {
                    throw new ArgumentException("The preview window handle was expected but not provided.", nameof(arguments));
                }

                long handleNum;
                bool success = long.TryParse(secondArgument, out handleNum);

                if (!success)
                {
                    throw new ArgumentException("The provided preview handle was not valid.", nameof(arguments));
                }

                PreviewHandle   = new IntPtr(handleNum);
                ScreenSaverMode = ScreenSaverMode.Preview;
                // Allows the screen saver to size properly within the official preview window (only apparent with atypical DPI scaling).
                NativeMethods.SetProcessDPIAware();
                OnShowPreview(new PreviewWindow(PreviewHandle));
                break;

            default:
                throw new ArgumentException(
                          "The command line argument \"" + firstArgument + "\" is not valid.",
                          nameof(arguments));
            }
        }
Beispiel #40
0
        // ---------------------------------------------------------------------------------------------------------------------------------------------------------
        /// <summary>
        /// Detects Table-Structure Definition structural changes, and aplying them to the original-entity.
        /// Plus, inform those changes to the registered dependant Designators of this Table-Structure Definition.
        /// </summary>
        public static bool ApplyTableDefStructureAlter(TableDefinition CurrentEntityState, TableDefinition PreviousEntityState,
                                                       IEnumerable <object> Parameters = null)  // Parameters required for instance-controller pre-apply invocation
        {
            //! Fix crash after deleting field which is not removed at the stored value cells level
            var OmitWarning = (Parameters != null && Parameters.Any() && Parameters.First() is bool && (bool)Parameters.First());

            // Ensure deletion of nonexistent field definitions from complementary field collections.
            var NonexistentUniqueKeyFields = CurrentEntityState.UniqueKeyFieldDefs.Where(fld => !CurrentEntityState.FieldDefinitions.Contains(fld)).ToList();

            NonexistentUniqueKeyFields.ForEach(nonex => CurrentEntityState.UniqueKeyFieldDefs.Remove(nonex));

            var NonexistentDominantRefFields = CurrentEntityState.DominantRefFieldDefs.Where(fld => !CurrentEntityState.FieldDefinitions.Contains(fld)).ToList();

            NonexistentDominantRefFields.ForEach(nonex => CurrentEntityState.DominantRefFieldDefs.Remove(nonex));

            var NonexistentLabelFields = CurrentEntityState.LabelFieldDefs.Where(fld => !CurrentEntityState.FieldDefinitions.Contains(fld)).ToList();

            NonexistentLabelFields.ForEach(nonex => CurrentEntityState.LabelFieldDefs.Remove(nonex));

            // Detect changes between original-entity field sets and those of the edited-agent.
            // Notice the safe non-by-instance comparison made by GlobalId (a GUID), which is not recreated at cloning.
            // Here, a change in relevant properties, such as Data-Type or Unique-Key fields order can happen.
            var DetectedFieldDefinitionChanges   = PreviousEntityState.FieldDefinitions.GetDifferencesFrom(CurrentEntityState.FieldDefinitions, (current, changed) => current.GlobalId == changed.GlobalId, General.DetermineDifferences, General.IsEquivalent);
            var DetectedUniqueKeyFieldsChanges   = PreviousEntityState.UniqueKeyFieldDefs.GetDifferencesFrom(CurrentEntityState.UniqueKeyFieldDefs, (current, changed) => current.GlobalId == changed.GlobalId, General.DetermineDifferences, General.IsEquivalent);
            var DetectedDominantRefFieldsChanges = PreviousEntityState.DominantRefFieldDefs.GetDifferencesFrom(CurrentEntityState.DominantRefFieldDefs, (current, changed) => current.GlobalId == changed.GlobalId, General.DetermineDifferences, General.IsEquivalent);
            var DetectedLabelFieldsChanges       = PreviousEntityState.LabelFieldDefs.GetDifferencesFrom(CurrentEntityState.LabelFieldDefs, (current, changed) => current.GlobalId == changed.GlobalId, General.DetermineDifferences, General.IsEquivalent);
            var DetectedFieldDefDataTypeChanges  = PreviousEntityState.FieldDefinitions.Where(
                current =>
            {
                var Changed = CurrentEntityState.FieldDefinitions.FirstOrDefault(changed => changed.GlobalId == current.GlobalId);
                if (Changed == null)
                {
                    return(false);
                }

                var AreDifferent = !current.FieldType.IsEqual(Changed.FieldType);
                return(AreDifferent);
            }).ToList();

            // If no changes were made, then exit and proceed with non table-structure-changes Apply.
            if (DetectedFieldDefinitionChanges == null && DetectedUniqueKeyFieldsChanges == null &&
                DetectedDominantRefFieldsChanges == null && DetectedLabelFieldsChanges == null &&
                DetectedFieldDefDataTypeChanges.Count < 1)
            {
                return(true);
            }

            /* Determine if structural alterations (which implies Table data change/loss) were made.
             * ( The items of the Tuples reporting Field-Definition changes are...
             *   [1]Created (informing new position),  [2]Deleted (informing previous position),
             *   [3]Moved (informing new and previous positions), [4]Modified Data (informing new item position, plus field-name, new and previous values) )*/

            var FieldsSetAlteration = (DetectedFieldDefinitionChanges != null &&
                                       (DetectedFieldDefinitionChanges.Item1.Count > 0 ||
                                        DetectedFieldDefinitionChanges.Item2.Count > 0 ||
                                        DetectedFieldDefinitionChanges.Item4.Any(chg => chg.Value.Any(fld => fld.Key == FieldDefinition.__FieldType.TechName))));

            // Notice that Moved field-defs are not considered.
            // HOWEVER: These key field-defs should be used to Sort by default.
            var UniqueKeyAlteration = (DetectedUniqueKeyFieldsChanges != null &&
                                       (DetectedUniqueKeyFieldsChanges.Item1.Count > 0 ||
                                        DetectedUniqueKeyFieldsChanges.Item2.Count > 0));

            if (FieldsSetAlteration || UniqueKeyAlteration)
            {
                var AffectedObjects = new List <SimpleElement>();
                var DepDesignators  = PreviousEntityState.GetDependentDesignators(); // Old: CurrentEntityState
                foreach (var Dependant in DepDesignators)
                {
                    AffectedObjects.Add(Dependant.Owner.GetValue(defn => new SimpleElement("Idea Definition: " + defn.Name, "", defn.Summary),
                                                                 idea => new SimpleElement("Idea: " + idea.Name + " - Detail: " + Dependant.Name, "", idea.Summary)));
                }

                if (!OmitWarning && AffectedObjects.Count > 0 &&
                    !Display.DialogMultiItem("Confirmation", "The structural changes just made will affect the next Idea-Definitions/Ideas...",
                                             null, null, true, AffectedObjects.ToArray()))
                {
                    return(false);
                }
            }

            var PreserveCompatibleValues = AppExec.GetConfiguration <bool>("TableDefinition", "StructureAlter.PreserveCompatibleValues", PRESERVE_COMPATIBLE_VALUES_DEFAULT);

            if (!FieldsSetAlteration && !UniqueKeyAlteration)
            {
                return(true);
            }

            CurrentEntityState.AlterStructure(PreserveCompatibleValues, PreviousEntityState.FieldDefinitions);     // Alter the entity actual structure and propagate to dependants.

            return(true);
        }
Beispiel #41
0
 public void Execute(LiteEngine db, StringScanner s, Display display)
 {
     display.WriteBson(this.ReadCollection(db, s).DropIndex(s.Scan(@"\w+").Trim()));
 }
Beispiel #42
0
 public void Setup()
 {
     uut = new Display();
 }
Beispiel #43
0
 private void Awake()
 {
     display = GetComponent <Display>();
 }
Beispiel #44
0
        public DrawingVisual CreateActionerFor(double PosX, double PosY, ESymbolManipulationAction Manipulation)
        {
            ImageSource Source = null;

            if (Manipulation == ESymbolManipulationAction.ActionShowCompositeAsView)
            {
                Source = ImgSrcSwitchContent ?? Display.GetAppImage("show_composite.png");
            }

            if (Manipulation == ESymbolManipulationAction.ActionEditProperties)
            {
                Source = ImgSrcEditProperties ?? Display.GetAppImage("page_white_edit.png");
            }

            if (Manipulation == ESymbolManipulationAction.ActionSwitchRelated)
            {
                /*if (this.ManipulatedElement.OwnerRepresentation.AreRelatedTargetsShown
                || this.ManipulatedElement.OwnerRepresentation.AreRelatedOriginsShown)
                ||  Source = ImgSrcSwitchRelated ?? Display.GetAppImage("related_collapsed.png");
                || else*/
                Source = ImgSrcSwitchRelated ?? Display.GetAppImage("related_expanded.png");
            }

            if (Manipulation == ESymbolManipulationAction.ActionSwitchDetails)
            {
                if (this.ManipulatedSymbol.AreDetailsShown)
                {
                    Source = ImgSrcEditFormat ?? Display.GetAppImage("details_close.png");
                }
                else
                {
                    Source = ImgSrcEditFormat ?? Display.GetAppImage("details_open.png");
                }
            }

            if (Manipulation == ESymbolManipulationAction.ActionShowCompositeAsDetail)
            {
                if (this.ManipulatedSymbol.ShowCompositeContentAsDetails)
                {
                    Source = ImgSrcEditProperties ?? Display.GetAppImage("detail_view.png");
                }
                else
                {
                    Source = ImgSrcEditProperties ?? Display.GetAppImage("composite_view.png");
                }
            }

            if (Manipulation == ESymbolManipulationAction.ActionAddDetail)
            {
                Source = ImgSrcEditProperties ?? Display.GetAppImage("detail_new.png");
            }

            if (Source == null)
            {
                throw new InternalAnomaly("Actioner is not defined for manipulation-action.", Manipulation);
            }

            var ContainerArea = new Rect(PosX, PosY, ACTIONER_SIZE, ACTIONER_SIZE);
            var ContentArea   = new Rect(PosX + 2, PosY + 2, ACTIONER_SIZE - 4, ACTIONER_SIZE - 4);
            var Drawer        = new DrawingGroup();

            Drawer.Children.Add(new GeometryDrawing(ActStroke, ActPencil, new RectangleGeometry(ContainerArea, 2, 2)));
            Drawer.Children.Add(new ImageDrawing(Source, ContentArea));
            Drawer.Opacity = 1.0;
            return(Drawer.RenderToDrawingVisual());
        }
Beispiel #45
0
 public GSM(string model, string manufacturer, double price, string owner, Battery battery, Display display)
 {
     this.model        = model;
     this.manufacturer = manufacturer;
     this.price        = price;
     this.owner        = owner;
     this.battery      = battery;
     this.display      = display;
 }
Beispiel #46
0
 public static void Init(Game game, INavigation navigation, SpriteBatch spriteBatch, Display display)
 {
     _game        = game;
     _content     = game.Content;
     _navigation  = navigation;
     _spriteBatch = spriteBatch;
     _display     = display;
     DefaultFont.Load(_content);
 }
 public SymbolContainer(Point point, Display display, int priority, IBitmap symbol) : this(point, display, priority, symbol, 0, true)
 {
 }
Beispiel #48
0
        protected override void OnCreate(Bundle savedInstanceState)
        {
            base.OnCreate(savedInstanceState);
            RequestWindowFeature(WindowFeatures.ActionBar);
            SetContentView(Resource.Layout.Index1);

            Display display = this.WindowManager.DefaultDisplay;

            this.mDeviceHeight = display.Height;
            this.mDeviceWidth  = display.Width;

            ColorDrawable color = new ColorDrawable(Color.OrangeRed);

            this.ActionBar.SetBackgroundDrawable(color);
            //http://eggeggss.ddns.net/sse/Request.aspx?catelog=GetBarCodeItem
            List <Item> list = new List <Item>();

            list.Add(new Item()
            {
                Descrip = "DevExpress", Link = "https://www.devexpress.com/"
            });
            list.Add(new Item()
            {
                Descrip = "Xamarin", Link = "https://www.xamarin.com/"
            });
            list.Add(new Item()
            {
                Descrip = "Microsoft", Link = "https://www.microsoft.com/zh-cn"
            });
            list.Add(new Item()
            {
                Descrip = "百度雲", Link = "https://login.bce.baidu.com/"
            });
            list.Add(new Item()
            {
                Descrip = "小米官網", Link = "http://www.mi.com/tw/events/school831/"
            });
            list.Add(new Item()
            {
                Descrip = "奇摩", Link = "http://www.yahoo.com.tw"
            });

            // list.Add(new Item() { Descrip = "Xpage測試報表", Link = "http://arc-ap2.arcadyan.com.tw/GP/VendorReport.nsf/TEST.xsp" });

            //list.Add(new Item() { Descrip = "測試報表", Link = "http://eggeggss.ddns.net/notesbarcode/notesservice1.aspx" });

            string folder = System.Environment.GetFolderPath(System.Environment.SpecialFolder.Personal);

            _itemdb = new ItemDB(folder);

            List <Item> listFromDb = _itemdb.SelectItem();

            if (listFromDb.Count == 0)
            {
                _itemdb.InsertAllItem(list);
                listFromDb = _itemdb.SelectItem();
            }
            var listview = this.FindViewById <ListView>(Resource.Id.listview);

            adapter = new MyList();

            adapter.Context      = this;
            adapter.List         = listFromDb;
            adapter.DeviceHeight = this.mDeviceHeight;
            adapter.DeviceWidth  = this.mDeviceWidth;
            listview.Adapter     = adapter;

            var refresh = this.FindViewById <SwipeRefreshLayout>(Resource.Id.refresher1);

            refresh.Refresh += async(s1, e1) =>
            {
                try
                {
                    String uri = this.AppSetting.WebAPI;

                    if (!(String.IsNullOrEmpty(uri)))
                    {
                        var items = await WebApi.DownloadJsonDataCustom <IEnumerable <Item> >(uri);

                        foreach (var item in items)
                        {
                            _itemdb.InsertItem(item);
                        }
                    }
                }
                catch (Exception ex)
                {
                    Toast.MakeText(this, "下載失敗 " + ex.Message, ToastLength.Short).Show();
                    //Util.Dialog(this, "Information", "Please Check NetWork Status", null, null);
                }
                var dbitems = _itemdb.SelectItem();
                adapter.List = dbitems;
                adapter.NotifyDataSetChanged();
                refresh.Refreshing = false;
            };
            // Create your application here
        }
Beispiel #49
0
        /// <summary>
        /// Draws the maze
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void GlControl_Paint(object sender, PaintEventArgs e)
        {
            if (DesignMode)
            {
                return;
            }

            GlControlBox.MakeCurrent();
            Display.ClearBuffers();

            Batch.Begin();

            // Background texture
            Rectangle dst = new Rectangle(Point.Empty, GlControlBox.Size);

            Batch.Draw(CheckerBoard, dst, dst, Color.White);


            if (Maze != null)
            {
                // Blocks
                for (int y = 0; y < Maze.Size.Height; y++)
                {
                    for (int x = 0; x < Maze.Size.Width; x++)
                    {
                        Square block    = Maze.GetSquare(new Point(x, y));
                        Point  location = new Point(x, y);
                        Color  color    = Color.White;
                        if (block.Type == SquareType.Illusion)
                        {
                            color = Color.LightGreen;
                        }

                        Batch.DrawTile(Icons, block.Type == SquareType.Ground ? 1 : 0, new Point(Offset.X + x * 25, Offset.Y + y * 25));

                        if (block.ItemCount > 0)
                        {
                            Batch.DrawTile(Icons, 19, new Point(Offset.X + x * 25, Offset.Y + y * 25));
                        }


                        if (block.Actor != null)
                        {
                            // Doors
                            if (block.Actor is Door)
                            {
                                Door door = block.Actor as Door;

                                int tileid = 0;

                                if (Maze.IsDoorNorthSouth(location))
                                {
                                    tileid = 3;
                                }
                                else
                                {
                                    tileid = 2;
                                }


                                // Door opened or closed
                                if (door.State == DoorState.Broken || door.State == DoorState.Opened || door.State == DoorState.Opening)
                                {
                                    tileid += 2;
                                }

                                Batch.DrawTile(Icons, tileid, new Point(Offset.X + x * 25, Offset.Y + y * 25));
                            }


                            if (block.Actor is PressurePlate)
                            {
                                Batch.DrawTile(Icons, 18, new Point(Offset.X + x * 25, Offset.Y + y * 25));
                            }

                            if (block.Actor is Pit)
                            {
                                Batch.DrawTile(Icons, 19, new Point(Offset.X + x * 25, Offset.Y + y * 25));
                            }

                            if (block.Actor is Teleporter)
                            {
                                Batch.DrawTile(Icons, 11, new Point(Offset.X + x * 25, Offset.Y + y * 25));
                            }

                            if (block.Actor is ForceField)
                            {
                                ForceField field = block.Actor as ForceField;

                                int id;
                                if (field.Type == ForceFieldType.Spin)
                                {
                                    id = 12;
                                }
                                else if (field.Type == ForceFieldType.Move)
                                {
                                    id = 13 + (int)field.Direction;
                                }
                                else
                                {
                                    id = 17;
                                }

                                Batch.DrawTile(Icons, id, new Point(Offset.X + x * 25, Offset.Y + y * 25));
                            }


                            if (block.Actor is Stair)
                            {
                                Stair stair = block.Actor as Stair;
                                Batch.DrawTile(Icons, stair.Type == StairType.Up ? 6 : 7, new Point(Offset.X + x * 25, Offset.Y + y * 25));
                            }

/*
 *                                                      // Alcoves
 *                                                      if (block.HasAlcoves)
 *                                                      {
 *                                                              // Alcoves coords
 *                                                              Point[] alcoves = new Point[]
 *                                                              {
 *                                                                      new Point(7, 0),
 *                                                                      new Point(7, 19),
 *                                                                      new Point(0, 7),
 *                                                                      new Point(19, 7),
 *                                                              };
 *
 *
 *                                                              foreach (CardinalPoint side in Enum.GetValues(typeof(CardinalPoint)))
 *                                                              {
 *                                                                      if (block.HasAlcove(side))
 *                                                                      {
 *                                                                              Batch.DrawTile(Icons, 100 + ((int) side > 1 ? 0 : 1),
 *                                                                                      new Point(Offset.X + x * 25 + alcoves[(int) side].X,
 *                                                                                              Offset.Y + y * 25 + alcoves[(int) side].Y));
 *
 *                                                                      }
 *                                                              }
 *                                                      }
 */
                        }


                        // Draw monsters
                        if (block.HasMonster)
                        {
                            Batch.DrawTile(Icons, 8, new Point(Offset.X + location.X * 25, Offset.Y + location.Y * 25));
                        }
                    }
                }


                // Target
                if (Target.Maze == Maze.Name)
                {
                    Batch.DrawRectangle(new Rectangle(Offset.X + Target.Coordinate.X * 25, Offset.Y + Target.Coordinate.Y * 25, 25, 25), Color.White);
                }
            }

            Batch.End();
            GlControlBox.SwapBuffers();
        }
Beispiel #50
0
        private bool ShowDock(Gdk.Event evnt)
        {
            Adjustment adj = slider.Adjustment;
            int        x, y, m, dx, dy, sx, sy, ystartoff;
            uint       event_time;
            double     v;

            if (previous_volume != (int)slider.Adjustment.Lower)
            {
                previous_volume = Volume;
            }

            if (evnt is Gdk.EventKey)
            {
                event_time = ((Gdk.EventKey)evnt).Time;
            }
            else if (evnt is Gdk.EventButton)
            {
                event_time = ((Gdk.EventButton)evnt).Time;
            }
            else if (evnt is Gdk.EventScroll)
            {
                event_time = ((Gdk.EventScroll)evnt).Time;
            }
            else
            {
                throw new ApplicationException("ShowDock expects EventKey, EventButton, or EventScroll");
            }

            dock.Screen = Screen;

            GdkWindow.GetOrigin(out x, out y);
            x += Allocation.X;
            y += Allocation.Y;

            dock.Move(x, y - (SCALE_SIZE / 2));
            dock.ShowAll();

            dock.GdkWindow.GetOrigin(out dx, out dy);
            dy += dock.Allocation.Y;

            slider.GdkWindow.GetOrigin(out sx, out sy);
            sy       += slider.Allocation.Y;
            ystartoff = sy - dy;

            timeout = true;

            v  = Volume / (adj.Upper - adj.Lower);
            x += (Allocation.Width - dock.Allocation.Width) / 2;
            y -= ystartoff;
            y -= slider.MinSliderSize / 2;
            m  = slider.Allocation.Height - slider.MinSliderSize;
            y -= (int)(m * (1.0 - v));

            if (evnt is Gdk.EventButton)
            {
                y += (int)((Gdk.EventButton)evnt).Y;
            }
            else if (evnt is Gdk.EventScroll)
            {
                y += (int)((Gdk.EventScroll)evnt).Y;
            }

            dock.Move(x, y);
            slider.GdkWindow.GetOrigin(out sx, out sy);

            bool base_result = evnt is Gdk.EventButton
                ? base.OnButtonPressEvent((Gdk.EventButton)evnt)
                : true;

            Gtk.Grab.Add(dock);

            if (Gdk.Pointer.Grab(dock.GdkWindow, true,
                                 Gdk.EventMask.ButtonPressMask |
                                 Gdk.EventMask.ButtonReleaseMask |
                                 Gdk.EventMask.PointerMotionMask, null, null, event_time) != Gdk.GrabStatus.Success)
            {
                Gtk.Grab.Remove(dock);
                dock.Hide();
                return(false);
            }

            if (Gdk.Keyboard.Grab(dock.GdkWindow, true, event_time) != Gdk.GrabStatus.Success)
            {
                Display.PointerUngrab(event_time);
                Gtk.Grab.Remove(dock);
                dock.Hide();
                return(false);
            }

            if (evnt is Gdk.EventButton)
            {
                dock.GrabFocus();

                Gdk.EventButton evnt_copy = (Gdk.EventButton)Gdk.EventHelper.Copy(evnt);
                m = slider.Allocation.Height - slider.MinSliderSize;
                UpdateEventButton(evnt_copy, slider.GdkWindow, slider.Allocation.Width / 2,
                                  ((1.0 - v) * m) + slider.MinSliderSize / 2);
                slider.ProcessEvent(evnt_copy);
                Gdk.EventHelper.Free(evnt_copy);
            }
            else
            {
                slider.GrabFocus();
            }

            pop_time = event_time;

            return(base_result);
        }
        /// <summary>
        /// Adjusts the viewport in preparation for 3D rendering.
        /// </summary>
        /// <param name="dc">The current drawing context.</param>
        /// <returns>The previous viewport.</returns>
        private Viewport AdjustViewportFor3D(DrawingContext dc)
        {
            dc.Flush();

            var posDips = TransformToAncestor(View.LayoutRoot, Point2D.Zero);
            var posPixs = (Vector2)Display.DipsToPixels(posDips);

            var transform = dc.GlobalTransform;

            Vector2.Transform(ref posPixs, ref transform, out posPixs);

            var oldViewport = Ultraviolet.GetGraphics().GetViewport();
            var newViewport = new Viewport((Int32)posPixs.X, (Int32)posPixs.Y,
                                           (Int32)Display.DipsToPixels(ActualWidth), (Int32)Display.DipsToPixels(ActualHeight));

            Ultraviolet.GetGraphics().SetViewport(newViewport);

            return(oldViewport);
        }
Beispiel #52
0
 public GSM(string model, string manufacturer, decimal?price, Display displayInfo)
     : this(model, manufacturer, price, displayInfo, new Battery(""))
 {
 }
Beispiel #53
0
 static void Main(string[] args)
 {
     Display d = new Display();
 }
Beispiel #54
0
 // return end of displayCmd accounting for prompt
 public int endOfDisplayCmdPos()
 {
     return(Display.createPrompt(this).Length + this.displayCmd.Length);
 }
Beispiel #55
0
 public ReparentNotify(Display display, byte [] data)
     : base(display, data, 8)
 {
 }
Beispiel #56
0
        public void GetData(int typeId)
        {
            FrameType type = (FrameType)typeId;

            byte[] ToDecode;
            byte[] Decoded;

            /*Log.Invoke(new EventHandler(delegate
             * {
             *  Log.AppendText("get frame " + type +"\n");
             * }));*/


            switch (type)
            {
            case FrameType.MSG:
                #region MSG
                if (IsConnected())
                {
                    int    n             = Port.BytesToRead;
                    byte[] msgByteBuffer = new byte[n];

                    Port.Read(msgByteBuffer, 0, n);     //считываем сообщение
                    string Message = Encoding.Default.GetString(msgByteBuffer);
                    Log.Invoke(new EventHandler(delegate
                    {
                        Log.AppendText("(" + Port.PortName + ") GetData: new message > " + Message + "\n");
                    }));

                    WriteData(null, FrameType.ACK);
                }
                else
                {
                    WriteData(null, FrameType.RET_MSG);
                }
                break;

                #endregion
            case FrameType.FILEOK:
                #region FILEOK
                if (IsConnected())
                {
                    int    n             = Port.BytesToRead;
                    byte[] msgByteBuffer = new byte[n];

                    Port.Read(msgByteBuffer, 0, n);     //считываем сообщение
                    string Message = Encoding.Default.GetString(msgByteBuffer);
                    Log.Invoke(new EventHandler(delegate
                    {
                        Log.AppendText("[" + DateTime.Now + "] : Получено предложение на прием файла размером: " + Message + "\n");
                    }));
                    //SuccessfulFrameNumber = int.Parse(Message);
                    int    Message_num = int.Parse(Message);
                    double fileSize    = Math.Round((double)Message_num / 1024, 3);
                    if (MessageBox.Show("Файл. Размер: " + fileSize.ToString() + " Кбайт.\nПринять?", "Прием файла", MessageBoxButtons.YesNo) == DialogResult.Yes)
                    {
                        WriteData("OK", FrameType.ACK);
                    }
                }
                else
                {
                    WriteData(null, FrameType.RET_MSG);
                }
                break;

                #endregion
            case FrameType.FRAME:
                #region FRAME
                //if (IsConnected())
                //{
                //    int n = Port.BytesToRead;
                //    byte[] msgByteBuffer = new byte[n];

                //    Port.Read(msgByteBuffer, 0, n); //считываем сообщение
                //    string Message = Encoding.Default.GetString(msgByteBuffer);
                //    Log.Invoke(new EventHandler(delegate
                //    {
                //        Log.AppendText("[" + DateTime.Now + "] : Получено подтверждение об успешной доставке Frame " + Message + "\n");
                //    }));
                //    SuccessfulFrameNumber = int.Parse(Message);

                //    WriteData(null, FrameType.FILE);
                //}
                //else
                //{
                //    WriteData(null, FrameType.RET_MSG);
                //}
                //break;
                #endregion
            case FrameType.FILE:

                #region FILE
                if (IsConnected())
                {
                    byte   fileId   = (byte)Port.ReadByte();
                    string typeFile = TypeFileAnalysis(fileId);

                    byte[] size = new byte[sizeLenght];
                    Port.Read(size, 0, sizeLenght);
                    int ssize = (int)Double.Parse(Encoding.Default.GetString(size));

                    byte[] byte_NumOfFrames = new byte[NumOfFrameLenght];
                    Port.Read(byte_NumOfFrames, 0, NumOfFrameLenght);
                    int NumOfFrames = (int)Double.Parse(Encoding.Default.GetString(byte_NumOfFrames));

                    byte[] byte_FrameNumber = new byte[NumOfFrameLenght];
                    Port.Read(byte_FrameNumber, 0, NumOfFrameLenght);
                    int FrameNumber = (int)Double.Parse(Encoding.Default.GetString(byte_FrameNumber));


                    if (FrameNumber == 1)
                    {
                        //DialogResult result;

                        //result = MessageBox.Show("Файл. Размер: " + fileSize.ToString() + " Кбайт.\nПринять?", "Прием файла", MessageBoxButtons.YesNo);
                        //if (result == DialogResult.Yes)
                        //{
                        file_buffer = new byte[NumOfFrames * (Port.WriteBufferSize - 27)];
                        //}

                        //else
                        //{
                        //    Display.Invoke(new EventHandler(delegate
                        //    {
                        //        Display.AppendText(
                        //        "[" + DateTime.Now + "] : " + ": "
                        //        + "Вы не сохранили файл"
                        //        + "\r\n");
                        //        Display.ScrollToCaret();
                        //    }));
                        //}
                    }


                    int    n       = Port.WriteBufferSize - InfoLen;
                    byte[] newPart = new byte[n];
                    Port.Read(newPart, 0, n);

                    newPart.CopyTo(file_buffer, n * (FrameNumber - 1));


                    if (FrameNumber == NumOfFrames)
                    {
                        Decoded  = new byte[ssize];
                        ToDecode = new byte[2];

                        for (int i = 0; i < ssize; i++)
                        {
                            ToDecode[0] = file_buffer[i * 2];
                            ToDecode[1] = file_buffer[(i * 2) + 1];
                            Decoded[i]  = Hamming.Decode(ToDecode);
                        }


                        SaveFileDialog saveFileDialog = new SaveFileDialog();

                        MainForm.Invoke(new EventHandler(delegate
                        {
                            saveFileDialog.FileName = "";
                            saveFileDialog.Filter   = "TypeFile (*." + typeFile + ")|*." + typeFile + "|All files (*.*)|*.*";
                            if (DialogResult.OK == saveFileDialog.ShowDialog())
                            {
                                File.WriteAllBytes(saveFileDialog.FileName, Decoded);
                                //WriteData(null, FrameType.ACK);
                                Display.Invoke(new EventHandler(delegate
                                {
                                    Display.AppendText(
                                        "[" + DateTime.Now + "] : "
                                        + "Файл успешно получен"
                                        + "\r\n");
                                    Display.ScrollToCaret();
                                }));
                            }
                            else
                            {
                                // MessageBox.Show("Отмена ");
                                Display.Invoke(new EventHandler(delegate
                                {
                                    Display.AppendText(
                                        "[" + DateTime.Now + "] : " + ": "
                                        + "Вы не сохранили файл"
                                        + "\r\n");
                                    Display.ScrollToCaret();
                                }));
                            }
                        }));
                    }

                    WriteData(FrameNumber.ToString(), FrameType.FRAME);
                }
                else
                {
                    WriteData(null, FrameType.RET_FILE);
                }

                break;
                #endregion
            //======================================================



            case FrameType.ACK:
                #region ACK
                WriteData(FilePath, FrameType.FILE);
                break;
                #endregion

            case FrameType.RET_MSG:
                #region RET_MSG
                Log.AppendText("Message error! No connection\n");
                break;
                #endregion

            case FrameType.RET_FILE:
                #region RET_FILE
                Log.AppendText("File error! No connection\n");
                break;
                #endregion
            }
        }
        public override View GetSampleContent(Context context)
        {
            Display        display        = ((Activity)context).WindowManager.DefaultDisplay;
            DisplayMetrics displayMetrics = new DisplayMetrics();

            display.GetMetrics(displayMetrics);

            var wInches = displayMetrics.WidthPixels / (double)displayMetrics.DensityDpi;
            var hInches = displayMetrics.HeightPixels / (double)displayMetrics.DensityDpi;

            double screenDiagonal = Math.Sqrt(Math.Pow(wInches, 2) + Math.Pow(hInches, 2));

            isTablet = screenDiagonal >= 7.0;

            //Create SfDiagram.
            diagram = new SfDiagram(context);
            diagram.EnableSelection = false;

            FillColor = new Dictionary <string, Color>();
            FillColor.Add("Managing Director", Color.Rgb(239, 75, 93));
            FillColor.Add("Project Manager", Color.Rgb(49, 162, 255));
            FillColor.Add("Senior Manager", Color.Rgb(49, 162, 255));
            FillColor.Add("Project Lead", Color.Rgb(0, 194, 192));
            FillColor.Add("Senior S/W Engg", Color.Rgb(0, 194, 192));
            FillColor.Add("Software Engg", Color.Rgb(0, 194, 192));
            FillColor.Add("Team Lead", Color.Rgb(0, 194, 192));
            FillColor.Add("Project Trainee", Color.Rgb(255, 129, 0));

            StrokeColor = new Dictionary <string, Color>();
            StrokeColor.Add("Managing Director", Color.Rgb(201, 32, 61));
            StrokeColor.Add("Project Manager", Color.Rgb(23, 132, 206));
            StrokeColor.Add("Senior Manager", Color.Rgb(23, 132, 206));
            StrokeColor.Add("Project Lead", Color.Rgb(4, 142, 135));
            StrokeColor.Add("Senior S/W Engg", Color.Rgb(4, 142, 135));
            StrokeColor.Add("Software Engg", Color.Rgb(4, 142, 135));
            StrokeColor.Add("Team Lead", Color.Rgb(4, 142, 135));
            StrokeColor.Add("Project Trainee", Color.Rgb(206, 98, 9));

            dataModel = new DataModel();
            diagram.BackgroundColor  = Color.White;
            diagram.BeginNodeRender += Dia_BeginNodeRender;

            dataModel.Data();

            //To Represent DataSourceSttings Properties
            DataSourceSettings settings = new DataSourceSettings();

            settings.ParentId          = "ReportingPerson";
            settings.Id                = "Name";
            settings.DataSource        = dataModel.employee;
            diagram.DataSourceSettings = settings;

            //(diagram.LayoutManager.Layout as DirectedTreeLayout).IsDraggable


            //To Represent LayoutManager Properties
            diagram.LayoutManager = new LayoutManager()
            {
                Layout = new DirectedTreeLayout()
                {
                    Type = LayoutType.Organization,
                    HorizontalSpacing = 70 * MainActivity.Factor,
                    VerticalSpacing   = 70 * MainActivity.Factor
                }
            };

            for (int i = 0; i < diagram.Connectors.Count; i++)
            {
                diagram.Connectors[i].TargetDecoratorType = DecoratorType.None;
                diagram.Connectors[i].Style.StrokeBrush   = new SolidBrush(Color.Rgb(127, 132, 133));
            }
            diagram.NodeClicked     += Diagram_NodeClicked;
            diagram.ItemLongPressed += Diagram_ItemLongPressed;
            diagram.Loaded          += Diagram_Loaded;

            int width = (int)(context.Resources.DisplayMetrics.WidthPixels - context.Resources.DisplayMetrics.Density) / 3;

            linearLayout4             = new LinearLayout(context);
            linearLayout4.Orientation = Android.Widget.Orientation.Vertical;
            linearLayout4.SetMinimumHeight((int)(190 * currentDensity));
            linearLayout4.SetMinimumWidth(width);
            diagram.LayoutNodeDropped += Diagram_OnLayoutNodeDropped;
            return(diagram);
        }
Beispiel #58
0
        // return relative cusor pos without prompt
        public int relativeCmdCursorPos()
        {
            int promptLength = Display.createPrompt(this).Length;

            return(this.relativeCursorPos() - promptLength);
        }
Beispiel #59
0
 // returns total length of display cmd + prompt. Used to check for text wrap in
 // so we know what to do with our cursor
 public int totalDisplayLength()
 {
     return(Display.createPrompt(this).Length + this.displayCmd.Length);
 }
Beispiel #60
-12
        public void Execute(LiteEngine engine, StringScanner s, Display display, InputCommand input, Env env)
        {
            var col = this.ReadCollection(engine, s);
            var query = this.ReadQuery(s);

            display.WriteResult(engine.Delete(col, query));
        }